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 * wxCDMBlackBoxHelpDialog.cpp
32 * Created on: 11/1/2013
33 * Author: Daniel Felipe Gonzalez Obando
36 #include "wxCDMBlackBoxHelpDialog.h"
38 #include "creaDevManagerIds.h"
40 #include "modelCDMProject.h"
41 #include "modelCDMPackage.h"
43 BEGIN_EVENT_TABLE(wxCDMBlackBoxHelpDialog, wxDialog)
44 EVT_BUTTON(ID_BUTTON_CANCEL, wxCDMBlackBoxHelpDialog::OnFinish)
45 EVT_BUTTON(ID_BUTTON_OPENPROJECT, wxCDMBlackBoxHelpDialog::OnCMakeLists)
46 EVT_BUTTON(ID_BUTTON_EDIT_CMAKELISTSFILE, wxCDMBlackBoxHelpDialog::OnCMakeLists)
47 EVT_CHECKBOX(ID_CHECKBOX_DISABLE_HELP, wxCDMBlackBoxHelpDialog::OnDisableHelp)
50 wxCDMBlackBoxHelpDialog::wxCDMBlackBoxHelpDialog(
52 modelCDMBlackBox* blackBox,
54 const wxString& caption,
55 const wxPoint& position,
60 wxCDMBlackBoxHelpDialog::Create(parent, id, caption, position, size, style);
61 this->blackBox = blackBox;
64 wxCDMBlackBoxHelpDialog::~wxCDMBlackBoxHelpDialog()
68 bool wxCDMBlackBoxHelpDialog::Create(
71 const wxString& caption,
72 const wxPoint& position,
77 wxDialog::Create(parent, id, caption, position, size, style);
79 this->CreateControls();
84 void wxCDMBlackBoxHelpDialog::CreateControls()
87 wxBoxSizer* v_sizer1 = new wxBoxSizer(wxVERTICAL);
90 wxStaticText* title = new wxStaticText(this, wxID_ANY, wxT("Working with BlackBoxes"), wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);//new wxRichTextCtrl(this,wxID_ANY, wxString("Create a new project"), wxDefaultPosition, wxDefaultSize, wxRE_READONLY);
91 v_sizer1->Add(title, 0, wxALIGN_LEFT | wxALL | wxALIGN_CENTER_VERTICAL, 5);
93 wxStaticText* instruction = new wxStaticText(
97 "Black boxes are made to work in a modular fashion. They have programmer defined inputs and outputs. Their "
98 "purpose is to use the functions available in the libraries and expose them to be used as boxes in the crea "
100 "Black boxes are stored in the src folder of a package and they are composed of two files, the header(.h) "
101 "and the implementation(.cxx) files.\n"
102 "To start developing black boxes, go ahead and open the header file with the button \"Open .h\" and define "
103 "the inputs and outputs of the black box. Then, you will be able to use them in the implementation file, which "
104 "you can open using the \"Open .cxx\" button.\n"
105 "If you don't understand how this inputs and outputs are used, try looking at the sample black boxes available "
106 "in the sample package, which is shipped with every new project.\n"
107 "Also, don't forget to include the libraries your boxes use in the header and implementation files. They should "
108 "also be pointed and included in the package's directory CMakeLists.txt file by uncommenting the \"SET\" commands "
109 "for third party libraries or by including the library name inside the \"SET(${BBTK_PACKAGE_NAME}_LIBS\"command "
110 "and its path inside the \"SET(${BBTK_PACKAGE_NAME}_INCLUDE_DIRS\" command for custom libraries. You must also "
111 "include the package your black box is in by including the command \"ADD_SUBDIRECTORY([packageName])\" in the "
112 "project's directory CMakeLists.txt file. Again, please take a look at the sample package and its boxes to see "
113 "how to include libraries in order to use them in the boxes.\n"
115 "You can easily edit the CMakeLists files previously mentioned by clicking on the following buttons."),
120 v_sizer1->Add(instruction, 0,wxEXPAND | wxALL, 5);
122 wxButton* editCMakePkgBtn = new wxButton(this, ID_BUTTON_EDIT_CMAKELISTSFILE, wxT("Open Package's directory CMakeLists file"));
123 editCMakePkgBtn->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMBlackBoxHelpDialog::OnCMakeListsEnter,NULL,this);
124 editCMakePkgBtn->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMBlackBoxHelpDialog::OnCMakeListsExit,NULL,this);
125 wxButton* editCMakePrjBtn= new wxButton(this, ID_BUTTON_OPENPROJECT, wxT("Open Project's directory CMakeLists file"));
126 editCMakePrjBtn->Connect(wxEVT_ENTER_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMBlackBoxHelpDialog::OnCMakeListsEnter,NULL,this);
127 editCMakePrjBtn->Connect(wxEVT_LEAVE_WINDOW, (wxObjectEventFunction)(wxEventFunction)(wxMouseEventFunction)&wxCDMBlackBoxHelpDialog::OnCMakeListsExit,NULL,this);
129 v_sizer1->Add(editCMakePkgBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15);
130 v_sizer1->Add(editCMakePrjBtn, 0, wxEXPAND | wxLEFT | wxRIGHT, 15);
132 v_sizer1->Add(new wxCheckBox(this, ID_CHECKBOX_DISABLE_HELP, wxT("&Disable help")), 0, wxALIGN_RIGHT | wxRIGHT, 10);
134 v_sizer1->Add(new wxButton(this, ID_BUTTON_CANCEL, wxT("Close")), 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM | wxALIGN_CENTER_VERTICAL, 30);
137 //v_sizer1->RecalcSizes();
140 void wxCDMBlackBoxHelpDialog::OnFinish(wxCommandEvent& event)
142 this->EndDialog(wxID_CANCEL);
145 void wxCDMBlackBoxHelpDialog::OnCMakeLists(wxCommandEvent& event)
149 if((int)((wxButton*)event.GetEventObject())->GetId() == (int)ID_BUTTON_EDIT_CMAKELISTSFILE)
151 modelCDMIProjectTreeNode* node = this->blackBox;
152 while (node != NULL && dynamic_cast<modelCDMPackage*>(node) == NULL)
154 node = node->GetParent();
158 if(!((modelCDMPackage*)node)->OpenCMakeListsFile(result))
159 wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
161 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
163 if(((modelCDMPackage*)node)->GetCMakeLists() != NULL)
165 newEvent->SetClientData(((modelCDMPackage*)node)->GetCMakeLists());
167 wxPostEvent(this->GetParent(), *newEvent);
172 wxMessageBox(crea::std2wx("No project CMakeLists file was found."),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
175 else if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_OPENPROJECT)
177 modelCDMIProjectTreeNode* node = this->blackBox;
178 while (node != NULL && dynamic_cast<modelCDMProject*>(node) == NULL)
180 node = node->GetParent();
184 if(!((modelCDMProject*)node)->OpenCMakeListsFile(result))
185 wxMessageBox(crea::std2wx(*result),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
187 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
189 if(((modelCDMProject*)node)->GetCMakeLists() != NULL)
191 newEvent->SetClientData(((modelCDMProject*)node)->GetCMakeLists());
193 wxPostEvent(this->GetParent(), *newEvent);
198 wxMessageBox(crea::std2wx("No project CMakeLists file was found."),_T("Open CMakeLists File - Error!"),wxOK | wxICON_ERROR);
203 void wxCDMBlackBoxHelpDialog::OnCMakeListsEnter(wxMouseEvent& event)
205 if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_EDIT_CMAKELISTSFILE)
207 modelCDMIProjectTreeNode* node = this->blackBox;
208 while (node != NULL && dynamic_cast<modelCDMPackage*>(node) == NULL)
210 node = node->GetParent();
214 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
216 if(((modelCDMPackage*)node)->GetCMakeLists() != NULL)
218 newEvent->SetClientData(((modelCDMPackage*)node)->GetCMakeLists());
220 wxPostEvent(this->GetParent(), *newEvent);
224 else if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_OPENPROJECT)
226 modelCDMIProjectTreeNode* node = this->blackBox;
227 while (node != NULL && dynamic_cast<modelCDMProject*>(node) == NULL)
229 node = node->GetParent();
233 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED);
235 if(((modelCDMProject*)node)->GetCMakeLists() != NULL)
237 newEvent->SetClientData(((modelCDMProject*)node)->GetCMakeLists());
239 wxPostEvent(this->GetParent(), *newEvent);
246 void wxCDMBlackBoxHelpDialog::OnCMakeListsExit(wxMouseEvent& event)
248 if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_EDIT_CMAKELISTSFILE)
250 modelCDMIProjectTreeNode* node = this->blackBox;
251 while (node != NULL && dynamic_cast<modelCDMPackage*>(node) == NULL)
253 node = node->GetParent();
257 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
259 if(((modelCDMPackage*)node)->GetCMakeLists() != NULL)
261 newEvent->SetClientData(((modelCDMPackage*)node)->GetCMakeLists());
263 wxPostEvent(this->GetParent(), *newEvent);
267 else if(((wxButton*)event.GetEventObject())->GetId() == ID_BUTTON_OPENPROJECT)
269 modelCDMIProjectTreeNode* node = this->blackBox;
270 while (node != NULL && dynamic_cast<modelCDMProject*>(node) == NULL)
272 node = node->GetParent();
276 wxCommandEvent* newEvent = new wxCommandEvent(wxEVT_COMMAND_LISTBOX_SELECTED);
278 if(((modelCDMProject*)node)->GetCMakeLists() != NULL)
280 newEvent->SetClientData(((modelCDMProject*)node)->GetCMakeLists());
282 wxPostEvent(this->GetParent(), *newEvent);
289 void wxCDMBlackBoxHelpDialog::OnDisableHelp(wxCommandEvent& event)
291 wxPostEvent(this->GetParent(), event);