]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h
2396 bbGEditor Feature New Normal Feature Show Tree 2014-06-18 15:29
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsWxGUIEditorGraphic / bbtkwxGUIEditorGraphicBBS.h
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
5 #                        pour la Santé)
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 #
8 #  This software is governed by the CeCILL-B license under French law and 
9 #  abiding by the rules of distribution of free software. You can  use, 
10 #  modify and/ or redistribute the software under the terms of the CeCILL-B 
11 #  license as circulated by CEA, CNRS and INRIA at the following URL 
12 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
13 #  or in the file LICENSE.txt.
14 #
15 #  As a counterpart to the access to the source code and  rights to copy,
16 #  modify and redistribute granted by the license, users are provided only
17 #  with a limited warranty  and the software's author,  the holder of the
18 #  economic rights,  and the successive licensors  have only  limited
19 #  liability. 
20 #
21 #  The fact that you are presently reading this means that you have had
22 #  knowledge of the CeCILL-B license and that you accept its terms.
23 # ------------------------------------------------------------------------  
24 */
25
26 /*=========================================================================
27   Program:   bbtk
28   Module:    $RCSfile$
29   Language:  C++
30   Date:      $Date$
31   Version:   $Revision$
32 =========================================================================*/
33
34 /* ---------------------------------------------------------------------
35
36 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
37 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
38 *
39 *  This software is governed by the CeCILL-B license under French law and
40 *  abiding by the rules of distribution of free software. You can  use,
41 *  modify and/ or redistribute the software under the terms of the CeCILL-B
42 *  license as circulated by CEA, CNRS and INRIA at the following URL
43 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
44 *  or in the file LICENSE.txt.
45 *
46 *  As a counterpart to the access to the source code and  rights to copy,
47 *  modify and redistribute granted by the license, users are provided only
48 *  with a limited warranty  and the software's author,  the holder of the
49 *  economic rights,  and the successive licensors  have only  limited
50 *  liability.
51 *
52 *  The fact that you are presently reading this means that you have had
53 *  knowledge of the CeCILL-B license and that you accept its terms.
54 * ------------------------------------------------------------------------ */
55
56
57
58 /**
59  *  \file
60  *  \brief Class bbtk::BlackBox : abstract black-box interface.
61  */
62
63 /****
64 * Design and Developpement of BBTK GEditor
65 * Ricardo A Corredor J <ra.corredor67@uniandes.edu.co>
66 * RaC - 2010
67 ****/
68
69 #ifndef __WxGUIEditorGraphicBBS_h__
70 #define __WxGUIEditorGraphicBBS_h__
71
72 //Includes same project
73 #include "wxTabPanelsManager.h"
74 #include "wxBlackBoxEditionDialog.h"
75 #include "wxDiagramPropertiesEditionDialog.h"
76 #include "wxVtkSceneManager.h"
77 #include "GlobalConstants.h"
78
79
80 #include "wxart_new.xpm" // JPR
81 #include "wxart_open.xpm"
82 #include "wxart_save.xpm"
83 #include "wxart_run.xpm"
84 #include "wxart_delete.xpm"
85 #include "wxart_centerview.xpm"
86 #include "wxart_box.xpm"
87 #include "wxart_executablebox.xpm"
88 #include "wxart_complexbox.xpm"
89 #include "wxart_complexinputport.xpm"
90 #include "wxart_complexoutputport.xpm"
91 #include "wxart_undo.xpm"
92 #include "wxart_redo.xpm"
93 #include "wxart_editProperties.xpm"
94 #include "wxart_showTree.xpm"
95
96 //Includes creaMaracasVisu
97
98 //Includes bbtk
99 #include <bbtkWxGUIPackageBrowser2.h>
100 #include <bbtkWxGUIHtmlBrowser.h>
101 #include <bbtkBlackBoxDescriptor.h>
102 #include <bbtkComplexBlackBoxDescriptor.h>
103 #include <bbtkUtilities.h>
104 #include <bbtkConfigurationFile.h>
105 #include <bbtkSystemTools.h>
106
107 //Includes vtk
108
109 //Includes wxWidgets
110 #include <wx/frame.h>
111 #include <wx/aui/aui.h>
112 #include <wx/aui/auibook.h>
113 #include <wx/panel.h>
114 #include <wx/toolbar.h>
115 #include <wx/bitmap.h>
116 #include <wx/menu.h>
117 #include <wx/dnd.h>
118 #include <wx/grid.h>
119
120 //Includes std
121 #include <iostream>
122 #include <fstream>
123 #include <vector>
124
125 namespace bbtk
126 {
127         //RaC: It is important if it exists a double relation
128         //e.g. wxTabPanelsManager includes wxGUIEditorGraphicBBS, and wxGUIEditorGraphicBBS includes wxTabPanelsManager
129         class wxTabPanelsManager;
130         class wxVtkSceneManager;
131
132         class  wxGUIEditorGraphicBBS : public wxFrame
133         {
134                 public:
135                         wxGUIEditorGraphicBBS(wxFrame *parent);
136                         ~wxGUIEditorGraphicBBS();
137
138                         void initToolbar();
139                         void initMenu();
140                         void initTabPanelsManager();
141                         void initPackageBrowser();
142                         void initHelpHTMLBrowser();
143                         wxAuiNotebook* getAuiNotebook();
144
145                         // Display the info of the black box highlighted in the PackageBrowser
146                         void displayBlackBoxInfo(std::string packageName, std::string boxName);
147
148                         // Shows the textStatus in the wxFrame status bar
149                         void updateStatusBar(std::string textStatus);
150
151                         // Executes the BBS script in parameter
152                         void executeScript(std::string script);
153
154                         // Shows the dialog to change the parameters and values of the black box
155                         void editBlackBox(GBlackBoxModel *bbmodel);
156
157                         bool boxNameExists(std::string boxname);
158                         bool isCurrentDiagramComplexBox();
159
160                         // Checks and adds if necessary the .bbg/.bbs extensions
161                         std::string CheckExtension (std::string filename, std::string extension);                       
162                         // Method that can be used to refresh the help and package browser
163                         // RaC TOFIX!!!
164                         void RegenerateAll();
165                         void DoRegeneratePackageDoc(const std::string& pack);
166                         void DoRegenerateBoxesLists();
167
168                         // Refresh the state of buttons and menus when changing for example the mode to edit complex box
169                         void refreshGUIControls();
170                         
171             void SaveActualBBS(std::string filename);
172             void AskComplexBoxConfiguration();
173             void SaveActualComplexBox(std::string filename);
174             void SaveActualDiagram(std::string filename);
175                         void SaveCurrentDiagramAs( ); //DFCH
176                         void SaveTempActualDiagram(const std::string &);//FCY
177
178
179
180                         // File menu and toolbar events
181                         void OnCreateNewTab(wxCommandEvent& event);
182                         void OnOpenDiagram(wxCommandEvent& event);
183                         void OpenDiagram(std::string filePathName, std::string fileName); 
184                         void OnSaveActualDiagram(wxCommandEvent& event); //DFCH
185                         void OnSaveAsActualDiagram(wxCommandEvent& event); //DFCH
186                         void OnExportConsoleExecCommand(wxCommandEvent& event); //RaC
187                         void OnOpenBBS(wxCommandEvent& event);
188                         void OpenBBS(std::string filePathName, std::string fileName);
189                         void OnSaveActualBBS(wxCommandEvent& event);
190                         void OnSaveActualComplexBox(wxCommandEvent& event);
191                         void OnExecuteActualDiagram(wxCommandEvent& event);
192                         void OnClickBtnExecutableBox(wxCommandEvent& event);
193                         void OnDeleteAllBoxesActualDiagram(wxCommandEvent& event);
194                         void OnCenterViewActualDiagram(wxCommandEvent& event);
195                         void OnClickBtnBox(wxCommandEvent& event);
196                         void OnClickBtnComplexBox(wxCommandEvent& event);
197                         void OnAddComplexBoxInput(wxCommandEvent& event);
198                         void OnAddComplexBoxOutput(wxCommandEvent& event);
199                         void OnExit(wxCommandEvent& event);
200                         void OnHelpBBeditor(wxCommandEvent& event);
201                         void OnUndo(wxCommandEvent& event);
202                         void OnRedo(wxCommandEvent& event);
203                         void OnChangeName(wxCommandEvent& event);
204                         void OnEditDiagramProperties(wxCommandEvent& event);
205                         void OnShowTree(wxCommandEvent& event); //CFT
206                         void OnEditComplexBoxScript(wxCommandEvent& event);
207
208                 
209                         // Edit menu events
210                         void OnCopySelectedToComplexDiagram(wxCommandEvent& event);                   
211                        
212
213                         // Tool menu events
214                         void OnCreatePackage(wxCommandEvent& event);
215                         void OnCreateBlackBox(wxCommandEvent& event);
216                         void OnPlugPackage(wxCommandEvent& event);
217                         void OnEditConfig(wxCommandEvent& event);
218                         void OnShowHTMLDoc(wxCommandEvent& event);
219                         void OnCreateIndex(wxCommandEvent& event);
220                         void OpenScript(std::string filePathNameBBS ,std::string boxType);
221
222                         bool TryToOpenScriptApplication(std::string packageName ,std::string boxType);
223                         bool TryToOpenScriptComplexBox(std::string packageName ,std::string boxType);
224                         bool TryToOpenScript(std::string packageName ,std::string boxType,bool scriptApplication, bool scriptComplexBox);
225                 
226                         Factory::Pointer GetBBTKFactory();
227                 
228                         // RaC-2012
229                         void enableComplexBox();
230                         void disableComplexBox();
231
232                         // Getters and Setters of current diagram properties
233
234                         void setCurrentDiagramDescription(std::string description);
235                         void setCurrentDiagramAuthor(std::string author);
236                         void setCurrentDiagramCategory(std::string category);
237                         void setCurrentDiagramMessageKind(std::string kind);
238                         void setCurrentDiagramMessageLevel(std::string level);
239
240                         std::string getCurrentDiagramDescription();
241                         std::string getCurrentDiagramAuthor();
242                         std::string getCurrentDiagramCategory();
243                         std::string getCurrentDiagramMessageKind();
244                         std::string getCurrentDiagramMessageLevel();
245                 
246                 private:
247
248                         //AuiManager for the wxWindow
249                         wxAuiManager                                            *_frameAUIMgr;
250
251                         //Class that manages all the tabs in the window
252                         wxTabPanelsManager                                      *_tabsMgr;
253
254                         //Notebook managed by the wxTabPanelsManager
255                         wxAuiNotebook                                           *_notebook;
256
257                         //Instance to the BBTK Package Browser
258                         WxGUIPackageBrowser2                            *_pkgBrowser;
259
260                         //Instance to the BBTK Help Browser
261                         WxGUIHtmlBrowser                                        *_helpHtmlBrowser;
262
263                         //Name of the box and its package that is shown in the browser
264                         std::string                         _actualPkgBrowserBoxName;
265                         std::string                         _actualPkgBrowserPkgName;
266
267                         // VERY IMPORTANT FOR SAVE&LOAD PROCESSES
268                         // RaC 2012 2nd HackFest
269                         std::string                                             _currentBBGversion;
270                         
271                         NodeTreeC tree;
272                         wxVtkSceneManager *_sceneM;
273                 protected:
274
275
276  };
277
278
279 }
280 // namespace bbtk
281 #endif
282