]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h
no message
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsWxGUIEditorGraphic / wxVtkSceneManager.h
1 /*=========================================================================                                                                               
2 Program:   bbtk
3 Module:    $RCSfile$
4 Language:  C++
5 Date:      $Date$
6 Version:   $Revision$
7 =========================================================================*/
8
9 /* ---------------------------------------------------------------------
10
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
13 *
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.
20 *
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
25 *  liability. 
26 *
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 * ------------------------------------------------------------------------ */                                                                         
30
31
32
33 /**
34 *  \file 
35 *  \brief Class bbtk::BlackBox : abstract black-box interface. 
36 */
37
38 /****
39 * Design and Developpement of BBTK GEditor
40 * Ricardo A Corredor J <ra.corredor67@uniandes.edu.co>
41 * RaC - 2010
42 ****/
43
44 #ifndef __wxVtkSceneManager_h__
45 #define __wxVtkSceneManager_h__
46
47 //Includes same project
48 #include "GObjectsMVCFactory.h"
49 #include "Observer.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"
60
61 //Includes bbtk
62 #include <bbtkBlackBoxInputDescriptor.h>
63 #include <bbtkBlackBoxDescriptor.h>
64
65 //Includes creaMaracasVisu
66 #include <wxVtk3DBaseView.h>
67 #include <InteractorStyleMaracas.h>
68 #include <vtkInteractorStyleBaseView2D.h>
69 #include <manualContourControler.h>
70 #include <manualContourModel.h>
71
72 //Includes vtk
73 #include <vtkRenderWindow.h>
74 #include <vtkRenderWindowInteractor.h>
75 #include <vtkRenderer.h>
76 #include <vtkInteractorStyleImage.h>
77
78
79 //Includes std
80 #include <iostream>
81 #include <map>
82
83
84 namespace bbtk
85 {
86         class wxGEditorTabPanel;
87
88         class wxVtkSceneManager : public InteractorStyleMaracas , public Observer
89         {
90         public: 
91
92                 wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView *baseView, int idManager);
93                 ~wxVtkSceneManager();
94                 void disconnectDrop();
95
96                 //-------
97                 void configureBaseView();
98                 void registerController(InteractorStyleMaracas *param);
99                 void unregisterController(InteractorStyleMaracas *param);
100
101                 virtual bool OnChar();
102                 virtual bool OnMouseMove();
103                 virtual bool OnLeftButtonDown(); 
104                 virtual bool OnLeftButtonUp();
105                 virtual bool OnRightButtonUp();
106                 virtual bool OnLeftDClick();
107
108                 //-------
109                 int createGBlackBox(int x, int y, std::string packageName, std::string boxType );
110                 int createGComplexBoxInputPort(std::string inputName);
111                 int createGComplexBoxOutputPort(std::string outputName);
112                 GPortController* createGPort(int portType, std::string bbtkName, std::string bbtkType, int posinBox,GBoxModel *blackBox);
113                 int createGInputPort(int portType, int posinBox,GBoxModel *blackBox, BlackBoxInputDescriptor *desc);
114                 int createGOutputPort(int portType, int posinBox,GBoxModel *blackBox, BlackBoxOutputDescriptor *desc);
115                 int createGConnector(GPortModel* startPort);
116
117                 void configGBlackBox(int idBox, double xIn, double yIn, double zIn, std::string name, bool boxExecutable,double xEn,double yEn,double zEn);
118                 void configGConnetion(bool _isComplexBox, 
119                                                           std::string nameStartBox, std::string  nameStartPort, std::string  
120                                                           nameEndBox, std::string  nameEndPort);
121                 GBlackBoxModel* findGBox(std::string boxname);
122
123                 
124                 
125                 vtkRenderWindow* getRenderWindow();
126                 vtkRenderer* getRenderer();             
127
128                 virtual void update(int idController,int command);
129
130                 void refreshScene();
131                 void displayBlackBoxInfo(std::string packageName, std::string boxName);
132                 void updateStatusBar(std::string textStatus);
133
134                 //-------
135                 //Get a collection of object ids
136                 std::vector<int> getBlackBoxes();
137                 std::vector<int> getConnections();
138                 std::vector<int> getComplexInputPorts();
139                 std::vector<int> getComplexOutputPorts();
140
141                 //Get the map of selected objects (id, controller)
142                 std::map<int,GObjectController*> getSelectedObjects();
143
144                 //Get size of selected objects map
145                 int getNumSelectedObjects();
146
147                 //Complex box edition mode
148                 bool isComplexBox();
149                 void setComplexBox(bool val);
150
151                 //-------
152                 //Add an object to the list of controllers
153                 int addObjectController(GObjectController* objController);
154
155                 //Add a map of object controllers
156                 void addObjects(std::map<int,GObjectController*> objectsMap);
157
158
159                 //-------
160                 //Returns a string with the BBS script of the current diagram.
161                 std::string getDiagramBBS();
162
163                 //Returns a string with the BBS script of the complex box.
164                 std::string saveComplexBoxBBS(std::string cbName,std::string cbAuthor="",std::string cbCategory="",std::string cbDescription="");
165
166                 //Delete the object in the list of controllers with the id given by parameter.
167                 void deleteObject(int id);
168                 
169                 void AddControlerToBeRemove(std::vector<int> *controllersToRemove, int id);
170
171                 //Clear list of controllers and refresh
172                 void deleteAllBoxes();
173
174                 //Save the diagram in the BBG format, in the string given by param.
175                 void saveDiagram(std::string &content);
176
177                 //Load the diagram 
178                 void loadDiagram(ifstream &inputStream);
179
180                 //Center the view of the camera in the initial position
181                 void centerView();
182
183                 bool boxExist(std::string boxname);
184                 std::string generateANewNameForABox();
185                 std::string findANewNameForABox();
186                 //-------
187
188
189         private:
190
191                 //wxPanel that uses the manager
192                 wxGEditorTabPanel *_parent;
193
194                 // Id of the manager, the same of the panel
195                 int _idManager;
196
197                 // Boxes number in the scene
198                 int _numBoxes;
199
200                 // StartDragging
201                 bool _startDragging;
202
203                 // creaMaracasVisu viewer
204                 wxVtk3DBaseView *_baseView;
205
206                 // State of the 3D Scene or the virtual world
207                 int _worldState;
208
209                 //Map of id - objectController
210                 std::map<int,GObjectController*> _controllers;
211
212                 //Saves the id's of the selected objects in the controllers map
213                 std::vector<int> _selectedObjects;
214
215                 //Is the diagram in state complex box 
216                 bool _isComplexBox;
217
218                 int _idConnectionInCreation;
219
220                 int _contLastId;
221
222         protected:
223
224         };
225
226
227 }
228 // namespace bbtk
229 #endif
230