2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
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.
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
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 # ------------------------------------------------------------------------
26 /*=========================================================================
32 =========================================================================*/
34 /* ---------------------------------------------------------------------
36 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
37 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
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.
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
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 * ------------------------------------------------------------------------ */
60 * \brief Class bbtk::BlackBox : abstract black-box interface.
64 * Design and Developpement of BBTK GEditor
65 * Ricardo A Corredor J <ra.corredor67@uniandes.edu.co>
69 #ifndef __wxVtkSceneManager_h__
70 #define __wxVtkSceneManager_h__
72 //Includes same project
73 #include "GObjectsMVCFactory.h"
75 #include "GBoxModel.h"
76 #include "GComplexBoxPortModel.h"
77 #include "GPortModel.h"
78 #include "vtkGConnectorView.h"
79 #include "GConnectorModel.h"
80 #include "GConnectorController.h"
81 #include "vtkGPortView.h"
82 #include "manualConnectorContourView.h"
83 #include "manualConnectorContourController.h"
84 #include "wxGEditorTabPanel.h"
87 #include <bbtkBlackBoxInputDescriptor.h>
88 #include <bbtkBlackBoxDescriptor.h>
90 //Includes creaMaracasVisu
91 #include <wxVtk3DBaseView.h>
92 #include <InteractorStyleMaracas.h>
93 #include <vtkInteractorStyleBaseView2D.h>
94 #include <manualContourControler.h>
95 #include <manualContourModel.h>
98 #include <vtkRenderWindow.h>
99 #include <vtkRenderWindowInteractor.h>
100 #include <vtkRenderer.h>
101 #include <vtkInteractorStyleImage.h>
102 #include <vtkActor.h>
103 #include <vtkPoints.h>
104 #include <vtkTextActor3D.h>
105 #include <vtkDataSetMapper.h>
116 class wxGEditorTabPanel;
118 class wxVtkSceneManager : public InteractorStyleMaracas , public Observer
122 //EED 15 oct 2012 wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView *baseView, int idManager);
123 wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView *baseView, int idManager,Factory::Pointer bbtkfactory);
125 ~wxVtkSceneManager();
126 void disconnectDrop();
129 void configureBaseView();
130 void registerController(InteractorStyleMaracas *param);
131 void unregisterController(InteractorStyleMaracas *param);
133 virtual bool OnChar();
134 virtual bool OnMouseMove();
135 virtual bool OnLeftButtonDown();
136 virtual bool OnLeftButtonUp();
137 virtual bool OnRightButtonUp();
138 virtual bool OnLeftDClick();
139 virtual bool OnMiddleButtonDown(); ///JLGR 21-05-2012
140 virtual bool OnMiddleButtonUp(); ///JLGR 21-05-2012
143 int createGBlackBox(int x, int y, std::string packageName, std::string boxType );
144 int createGComplexBoxInputPort(std::string inputName);
145 int createGComplexBoxOutputPort(std::string outputName);
146 GPortController* createGPort(int portType, std::string bbtkName, std::string bbtkType, std::string bbtkDescription, int posinBox,GBoxModel *blackBox);
149 // int createGInputPort(int portType, int posinBox,GBoxModel *blackBox, BlackBoxInputDescriptor *desc);
150 // int createGOutputPort(int portType, int posinBox,GBoxModel *blackBox, BlackBoxOutputDescriptor *desc);
151 int createGInputPort(int portType, int posinBox,GObjectController *gBoxControler, BlackBoxInputDescriptor *desc);
152 int createGOutputPort(int portType, int posinBox,GObjectController *gBoxControler, BlackBoxOutputDescriptor *desc);
154 int createGConnector(GPortModel* startPort);
156 void configGBlackBox(int idBox, double xIn, double yIn, double zIn, std::string name, bool boxExecutable,double xEn,double yEn,double zEn);
157 int configGConnetion( std::string nameStartBox, std::string nameStartPort, std::string nameEndBox, std::string nameEndPort);
158 void configGComBoxInputOutputPort(bool inputoutput, std::string inputPortName, double xIn, double yIn,double zIn);
159 GBoxModel* findGBox(std::string boxname);
163 vtkRenderWindow* getRenderWindow();
164 vtkRenderer* getRenderer();
166 virtual void update(int idController,int command);
170 void displayBlackBoxInfo(std::string packageName, std::string boxName);
171 void updateStatusBar(std::string textStatus);
174 //Get a collection of object ids
175 std::vector<int> getBlackBoxes();
176 std::vector<int> getConnections();
177 std::vector<int> getComplexInputPorts();
178 std::vector<int> getComplexOutputPorts();
180 //Get the map of selected objects (id, controller)
181 std::map<int,GObjectController*> getSelectedObjects();
183 //Get size of selected objects map
184 int getNumSelectedObjects();
186 //Complex box edition mode
188 void setComplexBox(bool val);
191 //Add an object to the list of controllers
192 int addObjectController(GObjectController* objController);
194 //Add a map of object controllers
195 void addObjects(std::map<int,GObjectController*> objectsMap);
197 /// Duplicates Objects to current a diagram
198 void DuplicateObjects(std::map<int,GObjectController*> objectsMap);///JLGR 21-05-2012
201 // Makes a BlackBox Executable
202 bool MakeBoxExecutable();//DFCH
204 //Returns a string with the BBS script of the current diagram.
205 std::string getDiagramBBS(bool wln=false);
207 //Returns a string with the BBS script of the complex box.
208 std::string saveComplexBoxBBS();
210 //Delete the object in the list of controllers with the id given by parameter.
211 bool deleteObject(int id);
213 void AddControlerToBeRemove(std::vector<int> *controllersToRemove, int id);
215 //Clear list of controllers and refresh
216 void deleteAllBoxes();
218 //Save the diagram in the BBG format, in the string given by param.
219 void saveDiagram(std::string &content);
222 void loadDiagram(std::stringstream &inputStream);
224 //Center the view of the camera in the initial position
227 bool boxExist(std::string boxname);
228 std::string generateANewNameForABox();
229 std::string findANewNameForABox();
232 void SetCbName(std::string cbNane);
233 void SetCbPackageName(std::string packagename);
234 void SetAuthor(std::string author);
235 void SetCategory(std::string category);
236 void SetDescription(std::string description);
237 void SetMessageKind(std::string kind);
238 void SetMessageLevel(std::string Level);
239 std::string GetCbName();
240 std::string GetCbPackageName();
241 std::string GetAuthor();
242 std::string GetCategory();
243 std::string GetDescription();
244 std::string GetMessageKind();
245 std::string GetMessageLevel();
247 // RaC2012 2nd HackFest
248 // External Inputs was the complex inputs in previous versions
249 // Get names of all external inputs
250 std::vector< std::string> GetExternalInputsNames();
251 void getCleanLine(std::stringstream &inputStream, std::string &line);
253 void printAll( int com, int sta );
256 void SelectBoxWithPossibleName( std::string possibleName );
258 std::vector<std::string> boxesDiagram;//CFT
261 std::string _cbPackageName;
263 std::string _Category;
264 std::string _Description;
265 std::string _MessageKind;
266 std::string _MessageLevel;
267 //wxPanel that uses the manager
268 wxGEditorTabPanel *_parent;
269 // Id of the manager, the same of the panel
271 // Boxes number in the scene
275 // creaMaracasVisu viewer
276 wxVtk3DBaseView *_baseView;
277 // State of the 3D Scene or the virtual world
279 //Map of id - objectController
280 std::map<int,GObjectController*> _controllers;
281 //Saves the id's of the selected objects in the controllers map
282 std::vector<int> _selectedObjects;
283 //Is the diagram in state complex box
285 int _idConnectionInCreation;
287 vtkTextActor3D *_textActor;
288 std::string _bugTextActor_text;
289 int _bugTextActor_status;
291 vtkActor *_fillObjectActor;
292 vtkDataSetMapper *_aPolygonMapper;
293 Factory::Pointer _bbtkfactory;
294 std::string LineNumber(bool withLineNumber, int &value);
295 int GetIndexInSelected(int idControler);
296 void UnSelectBlackBoxes();
297 GObjectController *GetGBoxControlerPointedByMouse();
298 void CancelConnection();