]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h
Important change in the location of the classes in the libraries to follow the final...
[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                 wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView *baseView, int idManager);
91                 ~wxVtkSceneManager();
92
93                 void configureBaseView();
94                 int createGBlackBox(int x, int y,std::string packageName, std::string boxType);
95                 int createGComplexBoxInputPort(std::string inputName);
96                 int createGComplexBoxOutputPort(std::string outputName);
97                 GPortController* createGPort(int portType, std::string bbtkName, std::string bbtkType, int posinBox,GBoxModel *blackBox);
98                 int createGInputPort(int portType, int posinBox,GBoxModel *blackBox, BlackBoxInputDescriptor *desc);
99                 int createGOutputPort(int portType, int posinBox,GBoxModel *blackBox, BlackBoxOutputDescriptor *desc);
100                 int createGConnector(GPortModel* startPort);
101
102                 void registerController(InteractorStyleMaracas *param);
103                 void unregisterController(InteractorStyleMaracas *param);
104
105                 vtkRenderWindow* getRenderWindow();
106                 vtkRenderer* getRenderer();
107
108                 void disconnectDrop();
109                 
110                 virtual bool OnChar();
111                 virtual bool OnMouseMove();
112                 virtual bool  OnLeftButtonDown(); 
113                 virtual bool  OnLeftButtonUp();
114                 virtual bool OnRightButtonUp();
115                 virtual bool OnLeftDClick();
116
117                 virtual void update(int idController,int command);
118
119                 void displayBlackBoxInfo(std::string packageName, std::string boxName);
120                 void updateStatusBar(std::string textStatus);
121                 std::string getDiagramBBS();
122                 std::string saveComplexBoxBBS(std::string cbName,std::string cbAuthor="",std::string cbCategory="",std::string cbDescription="");
123                 void deleteObject(int id);
124                 void deleteAllBoxes();
125                 void saveDiagram(std::string &content);
126                 void loadDiagram(ifstream &inputStream);
127                 void centerView();
128
129                 void refreshScene();
130                 std::vector<int> getBlackBoxes();
131                 std::vector<int> getConnections();
132                 std::vector<int> getComplexInputPorts();
133                 std::vector<int> getComplexOutputPorts();
134
135                 std::map<int,GObjectController*> getSelectedObjects();
136                 int getNumSelectedObjects();
137
138                 bool isComplexBox();
139                 void setComplexBox(bool val);
140
141                 int addObjectController(GObjectController* objController);
142                 void addObjects(std::map<int,GObjectController*> objectsMap);
143
144                 
145         private:
146
147                 wxGEditorTabPanel *_parent;
148
149                 // Id of the manager, the same of the panel
150                 int _idManager;
151
152                 // Boxes number in the scene
153                 int _numBoxes;
154
155                 // StartDragging
156                 bool _startDragging;
157
158                 wxVtk3DBaseView *_baseView;
159
160                 int _worldState;
161
162                 std::map<int,GObjectController*> _controllers;
163
164                 //Saves the id's of the selected objects in the controllers map
165                 std::vector<int> _selectedObjects;
166
167                 bool _isComplexBox;
168
169         protected:
170
171         };
172
173
174 }
175 // namespace bbtk
176 #endif
177