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>
90 class wxGEditorTabPanel;
92 class wxVtkSceneManager : public InteractorStyleMaracas , public Observer
96 wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView *baseView, int idManager);
98 void disconnectDrop();
101 void configureBaseView();
102 void registerController(InteractorStyleMaracas *param);
103 void unregisterController(InteractorStyleMaracas *param);
105 virtual bool OnChar();
106 virtual bool OnMouseMove();
107 virtual bool OnLeftButtonDown();
108 virtual bool OnLeftButtonUp();
109 virtual bool OnRightButtonUp();
110 virtual bool OnLeftDClick();
113 int createGBlackBox(int x, int y, std::string packageName, std::string boxType );
114 int createGComplexBoxInputPort(std::string inputName);
115 int createGComplexBoxOutputPort(std::string outputName);
116 GPortController* createGPort(int portType, std::string bbtkName, std::string bbtkType, int posinBox,GBoxModel *blackBox);
117 int createGInputPort(int portType, int posinBox,GBoxModel *blackBox, BlackBoxInputDescriptor *desc);
118 int createGOutputPort(int portType, int posinBox,GBoxModel *blackBox, BlackBoxOutputDescriptor *desc);
119 int createGConnector(GPortModel* startPort);
121 void configGBlackBox(int idBox, double xIn, double yIn, double zIn, std::string name, bool boxExecutable,double xEn,double yEn,double zEn);
122 void configGConnetion( std::string nameStartBox, std::string nameStartPort, std::string
123 nameEndBox, std::string nameEndPort);
124 void configGComBoxInputOutputPort(bool inputoutput, std::string inputPortName, double xIn, double yIn,double zIn);
125 GBoxModel* findGBox(std::string boxname);
129 vtkRenderWindow* getRenderWindow();
130 vtkRenderer* getRenderer();
132 virtual void update(int idController,int command);
135 void displayBlackBoxInfo(std::string packageName, std::string boxName);
136 void updateStatusBar(std::string textStatus);
139 //Get a collection of object ids
140 std::vector<int> getBlackBoxes();
141 std::vector<int> getConnections();
142 std::vector<int> getComplexInputPorts();
143 std::vector<int> getComplexOutputPorts();
145 //Get the map of selected objects (id, controller)
146 std::map<int,GObjectController*> getSelectedObjects();
148 //Get size of selected objects map
149 int getNumSelectedObjects();
151 //Complex box edition mode
153 void setComplexBox(bool val);
156 //Add an object to the list of controllers
157 int addObjectController(GObjectController* objController);
159 //Add a map of object controllers
160 void addObjects(std::map<int,GObjectController*> objectsMap);
164 //Returns a string with the BBS script of the current diagram.
165 std::string getDiagramBBS();
167 //Returns a string with the BBS script of the complex box.
168 std::string saveComplexBoxBBS(std::string cbName,std::string cbAuthor="",std::string cbCategory="",std::string cbDescription="");
170 //Delete the object in the list of controllers with the id given by parameter.
171 void deleteObject(int id);
173 void AddControlerToBeRemove(std::vector<int> *controllersToRemove, int id);
175 //Clear list of controllers and refresh
176 void deleteAllBoxes();
178 //Save the diagram in the BBG format, in the string given by param.
179 void saveDiagram(std::string &content);
182 void loadDiagram(ifstream &inputStream);
184 //Center the view of the camera in the initial position
187 bool boxExist(std::string boxname);
188 std::string generateANewNameForABox();
189 std::string findANewNameForABox();
195 //wxPanel that uses the manager
196 wxGEditorTabPanel *_parent;
198 // Id of the manager, the same of the panel
201 // Boxes number in the scene
207 // creaMaracasVisu viewer
208 wxVtk3DBaseView *_baseView;
210 // State of the 3D Scene or the virtual world
213 //Map of id - objectController
214 std::map<int,GObjectController*> _controllers;
216 //Saves the id's of the selected objects in the controllers map
217 std::vector<int> _selectedObjects;
219 //Is the diagram in state complex box
222 int _idConnectionInCreation;
226 vtkTextActor3D *_textActor;
228 vtkActor *_fillObjectActor;
229 //EED Borrame vtkPolyDataMapper *_fillPolyMapper;
230 vtkDataSetMapper *_aPolygonMapper;