]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h
Documentation of the wxLibrary
[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 * \class bbtk::wxVtkSceneManager
40 * \brief 
41 */
42
43 #ifndef __wxVtkSceneManager_h__
44 #define __wxVtkSceneManager_h__
45
46 //Includes same project
47 #include "GObjectsMVCFactory.h"
48 #include "Observer.h"
49 #include "GBoxModel.h"
50 #include "GComplexBoxPortModel.h"
51 #include "GPortModel.h"
52 #include "vtkGConnectorView.h"
53 #include "GConnectorModel.h"
54 #include "GConnectorController.h"
55 #include "vtkGPortView.h"
56 #include "manualConnectorContourView.h"
57 #include "manualConnectorContourController.h"
58 #include "wxGEditorTabPanel.h"
59
60 //Includes bbtk
61 #include <bbtkBlackBoxInputDescriptor.h>
62 #include <bbtkBlackBoxDescriptor.h>
63
64 //Includes creaMaracasVisu
65 #include <wxVtk3DBaseView.h>
66 #include <InteractorStyleMaracas.h>
67 #include <vtkInteractorStyleBaseView2D.h>
68 #include <manualContourControler.h>
69 #include <manualContourModel.h>
70
71 //Includes vtk
72 #include <vtkRenderWindow.h>
73 #include <vtkRenderWindowInteractor.h>
74 #include <vtkRenderer.h>
75 #include <vtkInteractorStyleImage.h>
76
77
78 //Includes std
79 #include <iostream>
80 #include <map>
81
82
83 namespace bbtk
84 {
85         class wxGEditorTabPanel;
86
87         class wxVtkSceneManager : public InteractorStyleMaracas , public Observer
88         {
89         public: 
90
91                 wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView *baseView, int idManager);
92                 ~wxVtkSceneManager();
93                 void disconnectDrop();
94
95                 //-------
96                 void configureBaseView();
97                 void registerController(InteractorStyleMaracas *param);
98                 void unregisterController(InteractorStyleMaracas *param);
99
100                 virtual bool OnChar();
101                 virtual bool OnMouseMove();
102                 virtual bool  OnLeftButtonDown(); 
103                 virtual bool  OnLeftButtonUp();
104                 virtual bool OnRightButtonUp();
105                 virtual bool OnLeftDClick();
106
107                 //-------
108                 int createGBlackBox(int x, int y,std::string packageName, std::string boxType);
109                 int createGComplexBoxInputPort(std::string inputName);
110                 int createGComplexBoxOutputPort(std::string outputName);
111                 GPortController* createGPort(int portType, std::string bbtkName, std::string bbtkType, int posinBox,GBoxModel *blackBox);
112                 int createGInputPort(int portType, int posinBox,GBoxModel *blackBox, BlackBoxInputDescriptor *desc);
113                 int createGOutputPort(int portType, int posinBox,GBoxModel *blackBox, BlackBoxOutputDescriptor *desc);
114                 int createGConnector(GPortModel* startPort);
115
116                 vtkRenderWindow* getRenderWindow();
117                 vtkRenderer* getRenderer();             
118
119                 virtual void update(int idController,int command);
120
121                 void refreshScene();
122                 void displayBlackBoxInfo(std::string packageName, std::string boxName);
123                 void updateStatusBar(std::string textStatus);
124
125                 //-------
126                 //Get a collection of object ids
127                 std::vector<int> getBlackBoxes();
128                 std::vector<int> getConnections();
129                 std::vector<int> getComplexInputPorts();
130                 std::vector<int> getComplexOutputPorts();
131
132                 //Get the map of selected objects (id, controller)
133                 std::map<int,GObjectController*> getSelectedObjects();
134
135                 //Get size of selected objects map
136                 int getNumSelectedObjects();
137
138                 //Complex box edition mode
139                 bool isComplexBox();
140                 void setComplexBox(bool val);
141
142                 //-------
143                 //Add an object to the list of controllers
144                 int addObjectController(GObjectController* objController);
145
146                 //Add a map of object controllers
147                 void addObjects(std::map<int,GObjectController*> objectsMap);
148
149
150                 //-------
151                 //Returns a string with the BBS script of the current diagram.
152                 std::string getDiagramBBS();
153
154                 //Returns a string with the BBS script of the complex box.
155                 std::string saveComplexBoxBBS(std::string cbName,std::string cbAuthor="",std::string cbCategory="",std::string cbDescription="");
156
157                 //Delete the object in the list of controllers with the id given by parameter.
158                 void deleteObject(int id);
159
160                 //Clear list of controllers and refresh
161                 void deleteAllBoxes();
162
163                 //Save the diagram in the BBG format, in the string given by param.
164                 void saveDiagram(std::string &content);
165
166                 //Load the diagram 
167                 void loadDiagram(ifstream &inputStream);
168
169                 //Center the view of the camera in the initial position
170                 void centerView();
171
172                 //-------
173                 
174
175         private:
176
177                 //wxPanel that uses the manager
178                 wxGEditorTabPanel *_parent;
179
180                 // Id of the manager, the same of the panel
181                 int _idManager;
182
183                 // Boxes number in the scene
184                 int _numBoxes;
185
186                 // StartDragging
187                 bool _startDragging;
188
189                 // creaMaracasVisu viewer
190                 wxVtk3DBaseView *_baseView;
191
192                 // State of the 3D Scene or the virtual world
193                 int _worldState;
194
195                 //Map of id - objectController
196                 std::map<int,GObjectController*> _controllers;
197
198                 //Saves the id's of the selected objects in the controllers map
199                 std::vector<int> _selectedObjects;
200
201                 //Is the diagram in state complex box 
202                 bool _isComplexBox;
203
204         protected:
205
206         };
207
208
209 }
210 // namespace bbtk
211 #endif
212