2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------
30 * wxCDMLibraryHelpDialog.cpp
32 * Created on: 11/1/2013
33 * Author: Daniel Felipe Gonzalez Obando
36 #include "wxCDMLibraryHelpDialog.h"
38 #include "creaDevManagerIds.h"
40 #include "modelCDMLib.h"
42 BEGIN_EVENT_TABLE(wxCDMLibraryHelpDialog, wxDialog)
43 EVT_BUTTON(ID_BUTTON_CANCEL, wxCDMLibraryHelpDialog::OnFinish)
44 EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMLibraryHelpDialog::OnCMakeLists)
45 EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMLibraryHelpDialog::OnCMakeLists)
46 EVT_CHECKBOX(ID_CHECKBOX_DISABLE_HELP, wxCDMLibraryHelpDialog::OnDisableHelp)
49 wxCDMLibraryHelpDialog::wxCDMLibraryHelpDialog(
51 modelCDMLibrary* library,
53 const wxString& caption,
54 const wxPoint& position,
59 wxCDMLibraryHelpDialog::Create(parent, id, caption, position, size, style);
60 this->library = library;
63 wxCDMLibraryHelpDialog::~wxCDMLibraryHelpDialog()
67 bool wxCDMLibraryHelpDialog::Create(
70 const wxString& caption,
71 const wxPoint& position,
76 wxDialog::Create(parent, id, caption, position, size, style);
78 this->CreateControls();
83 void wxCDMLibraryHelpDialog::CreateControls()
86 wxBoxSizer* v_sizer1 = new wxBoxSizer(wxVERTICAL);
89 wxStaticText* title = new wxStaticText(this, wxID_ANY, wxT("Working with Libraries"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);//new wxRichTextCtrl(this,wxID_ANY, wxString("Create a new project"), wxDefaultPosition, wxDefaultSize, wxRE_READONLY);
90 v_sizer1->Add(title, 0, wxALIGN_LEFT | wxALL | wxALIGN_CENTER_VERTICAL, 5);
92 wxStaticText* instruction = new wxStaticText(
96 "Libraries are made to expose the projects' main functionalities to the applications and black boxes of the project. "
97 "The functions and classes available in the libraries are the core of any project, thus they should implement important "
98 "tasks such as image processing algorithms or point cloud processing algorithms."
99 "Libraries are stored in the project's lib folder and each library has its own dedicated folder. Inside these folders "
100 "each library has its classes.\n"
102 "To start developing a library, go ahead and create a new class with the button \"Create Class\" and implement the main "
103 "functionalities of your project inside the created files.\n"
104 "If you need to separate classes in folders you can do it by creating a folder with the \"Create Folder\" button.\n"
105 "Then, in order to include your libraries in the project correctly you must include them in the lib's folder "
106 "\"CMakeLists.txt\" file. Also, if you create additional folders in your library you should include them in the library's "
107 "\"CMakeLists.txt\" file.\n"
109 "You can easily edit the CMakeLists files previously mentioned by clicking on the following buttons."),
114 v_sizer1->Add(instruction, 0,wxEXPAND | wxALL, 5);
116 wxButton* editCMakeLibraryBtn = new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, wxT("Open Library's directory CMakeLists file"));
117 editCMakeLibraryBtn->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibraryHelpDialog::OnCMakeListsEnter,NULL,this);
118 editCMakeLibraryBtn->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibraryHelpDialog::OnCMakeListsExit,NULL,this);
119 wxButton* editCMakeLibBtn= new wxButton(this, ID_BUTTON_OPENPROJECT, wxT("Open Lib's directory CMakeLists file"));
120 editCMakeLibBtn->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibraryHelpDialog::OnCMakeListsEnter,NULL,this);
121 editCMakeLibBtn->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMLibraryHelpDialog::OnCMakeListsExit,NULL,this);
123 v_sizer1->Add(editCMakeLibraryBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15);
124 v_sizer1->Add(editCMakeLibBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15);
126 v_sizer1->Add(new wxCheckBox(this, ID_CHECKBOX_DISABLE_HELP, wxT("&Disable help")), 0, wxALIGN_RIGHT | wxRIGHT, 10);
128 v_sizer1->Add(new wxButton(this, ID_BUTTON_CANCEL, wxT("Close")), 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM | wxALIGN_CENTER_VERTICAL, 30);
131 //v_sizer1->RecalcSizes();
134 void wxCDMLibraryHelpDialog::OnFinish(wxCommandEvent& event)
136 this->EndDialog(wxID_CANCEL);
139 void wxCDMLibraryHelpDialog::OnCMakeLists(wxCommandEvent& event)
143 if((int)((wxButton*)event.GetEventObject())->GetId() == (int)ID_BUTTON_EDIT_CMAKELISTSFILE)
146 if(!this->library->OpenCMakeListsFile(result))
147 wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
149 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
151 if(this->library->GetCMakeLists() != NULL)
153 int CMId = this->library->GetCMakeLists()->GetId();
154 newEvent->SetInt(CMId);
156 wxPostEvent(this->GetParent(), *newEvent);
159 else if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_OPENPROJECT)
161 modelCDMIProjectTreeNode* node = this->library;
162 while (node != NULL && dynamic_cast<modelCDMLib*>(node) == NULL)
164 node = node->GetParent();
168 if(!((modelCDMLib*)node)->OpenCMakeListsFile(result))
169 wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
171 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
173 if(((modelCDMLib*)node)->GetCMakeLists() != NULL)
175 int CMId = ((modelCDMLib*)node)->GetCMakeLists()->GetId();
176 newEvent->SetInt(CMId);
178 wxPostEvent(this->GetParent(), *newEvent);
183 wxMessageBox(crea::std2wx("No project CMakeLists file was found."),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
188 void wxCDMLibraryHelpDialog::OnCMakeListsEnter(wxMouseEvent& event)
190 if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_EDIT_CMAKELISTSFILE)
192 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
194 if(this->library->GetCMakeLists() != NULL)
196 int CMId = this->library->GetCMakeLists()->GetId();
197 newEvent->SetInt(CMId);
199 wxPostEvent(this->GetParent(), *newEvent);
202 else if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_OPENPROJECT)
204 modelCDMIProjectTreeNode* node = this->library;
205 while (node != NULL && dynamic_cast<modelCDMLib*>(node) == NULL)
207 node = node->GetParent();
211 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
213 if(((modelCDMLib*)node)->GetCMakeLists() != NULL)
215 int CMId = ((modelCDMLib*)node)->GetCMakeLists()->GetId();
216 newEvent->SetInt(CMId);
218 wxPostEvent(this->GetParent(), *newEvent);
225 void wxCDMLibraryHelpDialog::OnCMakeListsExit(wxMouseEvent& event)
227 if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_EDIT_CMAKELISTSFILE)
229 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
231 if(this->library->GetCMakeLists() != NULL)
233 int CMId = this->library->GetCMakeLists()->GetId();
234 newEvent->SetInt(CMId);
236 wxPostEvent(this->GetParent(), *newEvent);
239 else if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_OPENPROJECT)
241 modelCDMIProjectTreeNode* node = this->library;
242 while (node != NULL && dynamic_cast<modelCDMLib*>(node) == NULL)
244 node = node->GetParent();
248 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
250 if(((modelCDMLib*)node)->GetCMakeLists() != NULL)
252 int CMId = ((modelCDMLib*)node)->GetCMakeLists()->GetId();
253 newEvent->SetInt(CMId);
255 wxPostEvent(this->GetParent(), *newEvent);
262 void wxCDMLibraryHelpDialog::OnDisableHelp(wxCommandEvent& event)
264 wxPostEvent(this->GetParent(), event);