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);
147 int createGInputPort(int portType, int posinBox,GBoxModel *blackBox, BlackBoxInputDescriptor *desc);
148 int createGOutputPort(int portType, int posinBox,GBoxModel *blackBox, BlackBoxOutputDescriptor *desc);
149 int createGConnector(GPortModel* startPort);
151 void configGBlackBox(int idBox, double xIn, double yIn, double zIn, std::string name, bool boxExecutable,double xEn,double yEn,double zEn);
152 int configGConnetion( std::string nameStartBox, std::string nameStartPort, std::string nameEndBox, std::string nameEndPort);
153 void configGComBoxInputOutputPort(bool inputoutput, std::string inputPortName, double xIn, double yIn,double zIn);
154 GBoxModel* findGBox(std::string boxname);
158 vtkRenderWindow* getRenderWindow();
159 vtkRenderer* getRenderer();
161 virtual void update(int idController,int command);
165 void displayBlackBoxInfo(std::string packageName, std::string boxName);
166 void updateStatusBar(std::string textStatus);
169 //Get a collection of object ids
170 std::vector<int> getBlackBoxes();
171 std::vector<int> getConnections();
172 std::vector<int> getComplexInputPorts();
173 std::vector<int> getComplexOutputPorts();
175 //Get the map of selected objects (id, controller)
176 std::map<int,GObjectController*> getSelectedObjects();
178 //Get size of selected objects map
179 int getNumSelectedObjects();
181 //Complex box edition mode
183 void setComplexBox(bool val);
186 //Add an object to the list of controllers
187 int addObjectController(GObjectController* objController);
189 //Add a map of object controllers
190 void addObjects(std::map<int,GObjectController*> objectsMap);
192 /// Duplicates Objects to current a diagram
193 void DuplicateObjects(std::map<int,GObjectController*> objectsMap);///JLGR 21-05-2012
196 // Makes a BlackBox Executable
197 bool MakeBoxExecutable();//DFCH
199 //Returns a string with the BBS script of the current diagram.
200 std::string getDiagramBBS(bool wln=false);
202 //Returns a string with the BBS script of the complex box.
203 std::string saveComplexBoxBBS();
205 //Delete the object in the list of controllers with the id given by parameter.
206 bool deleteObject(int id);
208 void AddControlerToBeRemove(std::vector<int> *controllersToRemove, int id);
210 //Clear list of controllers and refresh
211 void deleteAllBoxes();
213 //Save the diagram in the BBG format, in the string given by param.
214 void saveDiagram(std::string &content);
217 void loadDiagram(std::stringstream &inputStream);
219 //Center the view of the camera in the initial position
222 bool boxExist(std::string boxname);
223 std::string generateANewNameForABox();
224 std::string findANewNameForABox();
227 void SetCbName(std::string cbNane);
228 void SetCbPackageName(std::string packagename);
229 void SetAuthor(std::string author);
230 void SetCategory(std::string category);
231 void SetDescription(std::string description);
232 void SetMessageKind(std::string kind);
233 void SetMessageLevel(std::string Level);
235 std::string GetCbName();
236 std::string GetCbPackageName();
237 std::string GetAuthor();
238 std::string GetCategory();
239 std::string GetDescription();
240 std::string GetMessageKind();
241 std::string GetMessageLevel();
243 // RaC2012 2nd HackFest
244 // External Inputs was the complex inputs in previous versions
245 // Get names of all external inputs
246 std::vector< std::string> GetExternalInputsNames();
247 void getCleanLine(std::stringstream &inputStream, std::string &line);
250 void printAll( int com, int sta );
253 std::vector<std::string> boxesDiagram;//CFT
258 std::string _cbPackageName;
260 std::string _Category;
261 std::string _Description;
262 std::string _MessageKind;
263 std::string _MessageLevel;
265 //wxPanel that uses the manager
266 wxGEditorTabPanel *_parent;
268 // Id of the manager, the same of the panel
271 // Boxes number in the scene
277 // creaMaracasVisu viewer
278 wxVtk3DBaseView *_baseView;
280 // State of the 3D Scene or the virtual world
283 //Map of id - objectController
284 std::map<int,GObjectController*> _controllers;
286 //Saves the id's of the selected objects in the controllers map
287 std::vector<int> _selectedObjects;
289 //Is the diagram in state complex box
292 int _idConnectionInCreation;
296 vtkTextActor3D *_textActor;
297 std::string _bugTextActor_text;
298 int _bugTextActor_status;
301 vtkActor *_fillObjectActor;
302 vtkDataSetMapper *_aPolygonMapper;
304 Factory::Pointer _bbtkfactory;
307 std::string LineNumber(bool withLineNumber, int &value);
308 int GetIndexInSelected(int idControler);
309 void UnSelectBlackBoxes();
310 GObjectController *GetGBlackBoxControlerPointedByMouse();
311 void CancelConnection();