1 /*=========================================================================
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 * This software is governed by the CeCILL-B license under French law and
15 * abiding by the rules of distribution of free software. You can use,
16 * modify and/ or redistribute the software under the terms of the CeCILL-B
17 * license as circulated by CEA, CNRS and INRIA at the following URL
18 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19 * or in the file LICENSE.txt.
21 * As a counterpart to the access to the source code and rights to copy,
22 * modify and redistribute granted by the license, users are provided only
23 * with a limited warranty and the software's author, the holder of the
24 * economic rights, and the successive licensors have only limited
27 * The fact that you are presently reading this means that you have had
28 * knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */
35 * \brief Class bbtk::BlackBox : abstract black-box interface.
39 * Design and Developpement of BBTK GEditor
40 * Ricardo A Corredor J <ra.corredor67@uniandes.edu.co>
44 #ifndef __wxVtkSceneManager_h__
45 #define __wxVtkSceneManager_h__
47 //Includes same project
48 #include "GObjectsMVCFactory.h"
50 #include "GBoxModel.h"
51 #include "GComplexBoxPortModel.h"
52 #include "GPortModel.h"
53 #include "vtkGConnectorView.h"
54 #include "GConnectorModel.h"
55 #include "GConnectorController.h"
56 #include "vtkGPortView.h"
57 #include "manualConnectorContourView.h"
58 #include "manualConnectorContourController.h"
59 #include "wxGEditorTabPanel.h"
62 #include <bbtkBlackBoxInputDescriptor.h>
63 #include <bbtkBlackBoxDescriptor.h>
65 //Includes creaMaracasVisu
66 #include <wxVtk3DBaseView.h>
67 #include <InteractorStyleMaracas.h>
68 #include <vtkInteractorStyleBaseView2D.h>
69 #include <manualContourControler.h>
70 #include <manualContourModel.h>
73 #include <vtkRenderWindow.h>
74 #include <vtkRenderWindowInteractor.h>
75 #include <vtkRenderer.h>
76 #include <vtkInteractorStyleImage.h>
78 #include <vtkPoints.h>
79 #include <vtkTextActor3D.h>
80 #include <vtkDataSetMapper.h>
91 class wxGEditorTabPanel;
93 class wxVtkSceneManager : public InteractorStyleMaracas , public Observer
97 //EED 15 oct 2012 wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView *baseView, int idManager);
98 wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView *baseView, int idManager,Factory::Pointer bbtkfactory);
100 ~wxVtkSceneManager();
101 void disconnectDrop();
104 void configureBaseView();
105 void registerController(InteractorStyleMaracas *param);
106 void unregisterController(InteractorStyleMaracas *param);
108 virtual bool OnChar();
109 virtual bool OnMouseMove();
110 virtual bool OnLeftButtonDown();
111 virtual bool OnLeftButtonUp();
112 virtual bool OnRightButtonUp();
113 virtual bool OnLeftDClick();
114 virtual bool OnMiddleButtonDown(); ///JLGR 21-05-2012
115 virtual bool OnMiddleButtonUp(); ///JLGR 21-05-2012
118 int createGBlackBox(int x, int y, std::string packageName, std::string boxType );
119 int createGComplexBoxInputPort(std::string inputName);
120 int createGComplexBoxOutputPort(std::string outputName);
121 GPortController* createGPort(int portType, std::string bbtkName, std::string bbtkType, std::string bbtkDescription, int posinBox,GBoxModel *blackBox);
122 int createGInputPort(int portType, int posinBox,GBoxModel *blackBox, BlackBoxInputDescriptor *desc);
123 int createGOutputPort(int portType, int posinBox,GBoxModel *blackBox, BlackBoxOutputDescriptor *desc);
124 int createGConnector(GPortModel* startPort);
126 void configGBlackBox(int idBox, double xIn, double yIn, double zIn, std::string name, bool boxExecutable,double xEn,double yEn,double zEn);
127 int configGConnetion( std::string nameStartBox, std::string nameStartPort, std::string nameEndBox, std::string nameEndPort);
128 void configGComBoxInputOutputPort(bool inputoutput, std::string inputPortName, double xIn, double yIn,double zIn);
129 GBoxModel* findGBox(std::string boxname);
133 vtkRenderWindow* getRenderWindow();
134 vtkRenderer* getRenderer();
136 virtual void update(int idController,int command);
140 void displayBlackBoxInfo(std::string packageName, std::string boxName);
141 void updateStatusBar(std::string textStatus);
144 //Get a collection of object ids
145 std::vector<int> getBlackBoxes();
146 std::vector<int> getConnections();
147 std::vector<int> getComplexInputPorts();
148 std::vector<int> getComplexOutputPorts();
150 //Get the map of selected objects (id, controller)
151 std::map<int,GObjectController*> getSelectedObjects();
153 //Get size of selected objects map
154 int getNumSelectedObjects();
156 //Complex box edition mode
158 void setComplexBox(bool val);
161 //Add an object to the list of controllers
162 int addObjectController(GObjectController* objController);
164 //Add a map of object controllers
165 void addObjects(std::map<int,GObjectController*> objectsMap);
167 /// Duplicates Objects to current a diagram
168 void DuplicateObjects(std::map<int,GObjectController*> objectsMap);///JLGR 21-05-2012
171 // Makes a BlackBox Executable
172 bool MakeBoxExecutable();//DFCH
174 //Returns a string with the BBS script of the current diagram.
175 std::string getDiagramBBS(bool wln=false);
177 //Returns a string with the BBS script of the complex box.
178 std::string saveComplexBoxBBS();
180 //Delete the object in the list of controllers with the id given by parameter.
181 bool deleteObject(int id);
183 void AddControlerToBeRemove(std::vector<int> *controllersToRemove, int id);
185 //Clear list of controllers and refresh
186 void deleteAllBoxes();
188 //Save the diagram in the BBG format, in the string given by param.
189 void saveDiagram(std::string &content);
192 void loadDiagram(std::stringstream &inputStream);
194 //Center the view of the camera in the initial position
197 bool boxExist(std::string boxname);
198 std::string generateANewNameForABox();
199 std::string findANewNameForABox();
202 void SetCbName(std::string cbNane);
203 void SetCbPackageName(std::string packagename);
204 void SetAuthor(std::string author);
205 void SetCategory(std::string category);
206 void SetDescription(std::string description);
208 std::string GetCbName();
209 std::string GetCbPackageName();
210 std::string GetAuthor();
211 std::string GetCategory();
212 std::string GetDescription();
214 // RaC2012 2nd HackFest
215 // External Inputs was the complex inputs in previous versions
216 // Get names of all external inputs
217 std::vector< std::string> GetExternalInputsNames();
218 void getCleanLine(std::stringstream &inputStream, std::string &line);
221 void printAll( int com, int sta );
228 std::string _cbPackageName;
230 std::string _Category;
231 std::string _Description;
233 //wxPanel that uses the manager
234 wxGEditorTabPanel *_parent;
236 // Id of the manager, the same of the panel
239 // Boxes number in the scene
245 // creaMaracasVisu viewer
246 wxVtk3DBaseView *_baseView;
248 // State of the 3D Scene or the virtual world
251 //Map of id - objectController
252 std::map<int,GObjectController*> _controllers;
254 //Saves the id's of the selected objects in the controllers map
255 std::vector<int> _selectedObjects;
257 //Is the diagram in state complex box
260 int _idConnectionInCreation;
264 vtkTextActor3D *_textActor;
266 vtkActor *_fillObjectActor;
267 vtkDataSetMapper *_aPolygonMapper;
269 Factory::Pointer _bbtkfactory;
272 std::string LineNumber(bool withLineNumber, int &value);
273 int GetIndexInSelected(int idControler);
274 void UnSelectBlackBoxes();
275 GObjectController *GetGBlackBoxControlerPointedByMouse();
276 void CancelConnection();