]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.h
#3253 Select manual of boxes
[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  *  \file
37  *  \brief Class bbtk::BlackBox : abstract black-box interface.
38  */
39
40 /****
41 * Design and Developpement of BBTK GEditor
42 * Ricardo A Corredor J <ra.corredor67@uniandes.edu.co>
43 * RaC - 2010
44 ****/
45
46 #ifndef __WxGUIEditorGraphicBBS_h__
47 #define __WxGUIEditorGraphicBBS_h__
48
49 //Includes same project
50 #include "wxTabPanelsManager.h"
51 #include "wxBlackBoxEditionDialog.h"
52 #include "wxDiagramPropertiesEditionDialog.h"
53 #include "wxVtkSceneManager.h"
54 #include "GlobalConstants.h"
55
56
57 #include "wxart_new.xpm" // JPR
58 #include "wxart_open.xpm"
59 #include "wxart_save.xpm"
60 #include "wxart_run.xpm"
61 #include "wxart_delete.xpm"
62 #include "wxart_centerview.xpm"
63 #include "wxart_box.xpm"
64 #include "wxart_executablebox.xpm"
65 #include "wxart_complexbox.xpm"
66 #include "wxart_complexinputport.xpm"
67 #include "wxart_complexoutputport.xpm"
68 #include "wxart_undo.xpm"
69 #include "wxart_redo.xpm"
70 #include "wxart_editProperties.xpm"
71 #include "wxart_showTree.xpm"
72
73 //Includes creaMaracasVisu
74
75 //Includes bbtk
76 #include <bbtkWxGUIPackageBrowser2.h>
77 #include <bbtkWxGUIHtmlBrowser.h>
78 #include <bbtkBlackBoxDescriptor.h>
79 #include <bbtkComplexBlackBoxDescriptor.h>
80 #include <bbtkUtilities.h>
81 #include <bbtkConfigurationFile.h>
82 #include <bbtkSystemTools.h>
83
84 //Includes vtk
85
86 //Includes wxWidgets
87 #include <wx/frame.h>
88 #include <wx/aui/aui.h>
89 #include <wx/aui/auibook.h>
90 #include <wx/panel.h>
91 #include <wx/toolbar.h>
92 #include <wx/bitmap.h>
93 #include <wx/menu.h>
94 #include <wx/dnd.h>
95 #include <wx/grid.h>
96
97 //Includes std
98 #include <iostream>
99 #include <fstream>
100 #include <vector>
101
102 namespace bbtk
103 {
104         //RaC: It is important if it exists a double relation
105         //e.g. wxTabPanelsManager includes wxGUIEditorGraphicBBS, and wxGUIEditorGraphicBBS includes wxTabPanelsManager
106         class wxTabPanelsManager;
107         class wxVtkSceneManager;
108
109         class  wxGUIEditorGraphicBBS : public wxFrame
110         {
111                 public:
112                         wxGUIEditorGraphicBBS(wxFrame *parent);
113                         ~wxGUIEditorGraphicBBS();
114
115                         void initToolbar();
116                         void initMenu();
117                         void initTabPanelsManager();
118                         void initPackageBrowser();
119                         void initHelpHTMLBrowser();
120                         wxAuiNotebook* getAuiNotebook();
121
122                         // Display the info of the black box highlighted in the PackageBrowser
123                         void displayBlackBoxInfo(std::string packageName, std::string boxName);
124
125                         // Shows the textStatus in the wxFrame status bar
126                         void updateStatusBar(std::string textStatus);
127
128                         // Executes the BBS script in parameter
129                         void executeScript(std::string script);
130
131                         // Shows the dialog to change the parameters and values of the black box
132                         void editBlackBox(GBlackBoxModel *bbmodel);
133
134                         bool boxNameExists(std::string boxname);
135                         bool isCurrentDiagramComplexBox();
136
137                         // Checks and adds if necessary the .bbg/.bbs extensions
138                         std::string CheckExtension (std::string filename, std::string extension);                       
139                         // Method that can be used to refresh the help and package browser
140                         // RaC TOFIX!!!
141                         void RegenerateAll();
142                         void DoRegeneratePackageDoc(const std::string& pack);
143                         void DoRegenerateBoxesLists();
144
145                         // Refresh the state of buttons and menus when changing for example the mode to edit complex box
146                         void refreshGUIControls();
147                         
148             void SaveActualBBS(std::string filename);
149             void AskComplexBoxConfiguration();
150             void SaveActualComplexBox(std::string filename);
151             void SaveActualDiagram(std::string filename);
152                         void SaveCurrentDiagramAs( ); //DFCH
153                         void SaveTempActualDiagram(const std::string &);//FCY
154
155
156
157                         // File menu and toolbar events
158                         void OnCreateNewTab(wxCommandEvent& event);
159                         void OnOpenDiagram(wxCommandEvent& event);
160                         void OpenDiagram(std::string filePathName, std::string fileName); 
161                         void OnSaveActualDiagram(wxCommandEvent& event); //DFCH
162                         void OnSaveAsActualDiagram(wxCommandEvent& event); //DFCH
163                         void OnExportConsoleExecCommand(wxCommandEvent& event); //RaC
164                         void OnOpenBBS(wxCommandEvent& event);
165                         void OpenBBS(std::string filePathName, std::string fileName);
166                         void OnSaveActualBBS(wxCommandEvent& event);
167                         void OnSaveActualComplexBox(wxCommandEvent& event);
168                         void OnExecuteActualDiagram(wxCommandEvent& event);
169                         void OnClickBtnExecutableBox(wxCommandEvent& event);
170                         void OnDeleteAllBoxesActualDiagram(wxCommandEvent& event);
171                         void OnCenterViewActualDiagram(wxCommandEvent& event);
172                         void OnClickBtnBox(wxCommandEvent& event);
173             void OnClickBtnSelectBoxes(wxCommandEvent& event);
174                         void OnClickBtnComplexBox(wxCommandEvent& event);
175                         void OnAddComplexBoxInput(wxCommandEvent& event);
176                         void OnAddComplexBoxOutput(wxCommandEvent& event);
177                         void OnExit(wxCommandEvent& event);
178                         void OnHelpBBeditor(wxCommandEvent& event);
179                         void OnUndo(wxCommandEvent& event);
180                         void OnRedo(wxCommandEvent& event);
181                         void OnChangeName(wxCommandEvent& event);
182                         void OnEditDiagramProperties(wxCommandEvent& event);
183                         void OnShowTree(wxCommandEvent& event); //CFT
184                         void OnEditComplexBoxScript(wxCommandEvent& event);
185
186                 
187                         // Edit menu events
188                         void OnCopySelectedToComplexDiagram(wxCommandEvent& event);                   
189                        
190
191                         // Tool menu events
192                         void OnCreatePackage(wxCommandEvent& event);
193                         void OnCreateBlackBox(wxCommandEvent& event);
194                         void OnPlugPackage(wxCommandEvent& event);
195                         void OnEditConfig(wxCommandEvent& event);
196                         void OnShowHTMLDoc(wxCommandEvent& event);
197                         void OnCreateIndex(wxCommandEvent& event);
198                         void OpenScript(std::string filePathNameBBS ,std::string boxType);
199
200                         bool TryToOpenScriptApplication(std::string packageName ,std::string boxType);
201                         bool TryToOpenScriptComplexBox(std::string packageName ,std::string boxType);
202                         bool TryToOpenScript(std::string packageName ,std::string boxType,bool scriptApplication, bool scriptComplexBox);
203                 
204                         Factory::Pointer GetBBTKFactory();
205                 
206                         // RaC-2012
207                         void enableComplexBox();
208                         void disableComplexBox();
209
210                         // Getters and Setters of current diagram properties
211
212                         void setCurrentDiagramDescription(std::string description);
213                         void setCurrentDiagramAuthor(std::string author);
214                         void setCurrentDiagramCategory(std::string category);
215                         void setCurrentDiagramMessageKind(std::string kind);
216                         void setCurrentDiagramMessageLevel(std::string level);
217
218                         std::string getCurrentDiagramDescription();
219                         std::string getCurrentDiagramAuthor();
220                         std::string getCurrentDiagramCategory();
221                         std::string getCurrentDiagramMessageKind();
222                         std::string getCurrentDiagramMessageLevel();
223                 
224                 private:
225
226                         //AuiManager for the wxWindow
227                         wxAuiManager                                            *_frameAUIMgr;
228
229                         //Class that manages all the tabs in the window
230                         wxTabPanelsManager                                      *_tabsMgr;
231
232                         //Notebook managed by the wxTabPanelsManager
233                         wxAuiNotebook                                           *_notebook;
234
235                         //Instance to the BBTK Package Browser
236                         WxGUIPackageBrowser2                            *_pkgBrowser;
237
238                         //Instance to the BBTK Help Browser
239                         WxGUIHtmlBrowser                                        *_helpHtmlBrowser;
240
241                         //Name of the box and its package that is shown in the browser
242                         std::string                         _actualPkgBrowserBoxName;
243                         std::string                         _actualPkgBrowserPkgName;
244
245                         // VERY IMPORTANT FOR SAVE&LOAD PROCESSES
246                         // RaC 2012 2nd HackFest
247                         std::string                                             _currentBBGversion;
248                         
249                         NodeTreeC                           tree;
250                         wxVtkSceneManager                   *_sceneM;
251                 protected:
252
253
254  };
255
256
257 }
258 // namespace bbtk
259 #endif
260