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