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 * \class bbtk::wxVtkSceneManager
43 #ifndef __wxVtkSceneManager_h__
44 #define __wxVtkSceneManager_h__
46 //Includes same project
47 #include "GObjectsMVCFactory.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"
61 #include <bbtkBlackBoxInputDescriptor.h>
62 #include <bbtkBlackBoxDescriptor.h>
64 //Includes creaMaracasVisu
65 #include <wxVtk3DBaseView.h>
66 #include <InteractorStyleMaracas.h>
67 #include <vtkInteractorStyleBaseView2D.h>
68 #include <manualContourControler.h>
69 #include <manualContourModel.h>
72 #include <vtkRenderWindow.h>
73 #include <vtkRenderWindowInteractor.h>
74 #include <vtkRenderer.h>
75 #include <vtkInteractorStyleImage.h>
85 class wxGEditorTabPanel;
87 class wxVtkSceneManager : public InteractorStyleMaracas , public Observer
91 wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView *baseView, int idManager);
93 void disconnectDrop();
96 void configureBaseView();
97 void registerController(InteractorStyleMaracas *param);
98 void unregisterController(InteractorStyleMaracas *param);
100 virtual bool OnChar();
101 virtual bool OnMouseMove();
102 virtual bool OnLeftButtonDown();
103 virtual bool OnLeftButtonUp();
104 virtual bool OnRightButtonUp();
105 virtual bool OnLeftDClick();
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);
116 vtkRenderWindow* getRenderWindow();
117 vtkRenderer* getRenderer();
119 virtual void update(int idController,int command);
122 void displayBlackBoxInfo(std::string packageName, std::string boxName);
123 void updateStatusBar(std::string textStatus);
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();
132 //Get the map of selected objects (id, controller)
133 std::map<int,GObjectController*> getSelectedObjects();
135 //Get size of selected objects map
136 int getNumSelectedObjects();
138 //Complex box edition mode
140 void setComplexBox(bool val);
143 //Add an object to the list of controllers
144 int addObjectController(GObjectController* objController);
146 //Add a map of object controllers
147 void addObjects(std::map<int,GObjectController*> objectsMap);
151 //Returns a string with the BBS script of the current diagram.
152 std::string getDiagramBBS();
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="");
157 //Delete the object in the list of controllers with the id given by parameter.
158 void deleteObject(int id);
160 //Clear list of controllers and refresh
161 void deleteAllBoxes();
163 //Save the diagram in the BBG format, in the string given by param.
164 void saveDiagram(std::string &content);
167 void loadDiagram(ifstream &inputStream);
169 //Center the view of the camera in the initial position
173 //Get a collection of object ids
174 std::vector<int> getBlackBoxes();
175 std::vector<int> getConnections();
176 std::vector<int> getComplexInputPorts();
177 std::vector<int> getComplexOutputPorts();
179 //Get the map of selected objects (id, controller)
180 std::map<int,GObjectController*> getSelectedObjects();
182 //Get size of selected objects map
183 int getNumSelectedObjects();
185 //Complex box edition mode
187 void setComplexBox(bool val);
193 //wxPanel that uses the manager
194 wxGEditorTabPanel *_parent;
196 // Id of the manager, the same of the panel
199 // Boxes number in the scene
205 // creaMaracasVisu viewer
206 wxVtk3DBaseView *_baseView;
208 // State of the 3D Scene or the virtual world
211 //Map of id - objectController
212 std::map<int,GObjectController*> _controllers;
214 //Saves the id's of the selected objects in the controllers map
215 std::vector<int> _selectedObjects;
217 //Is the diagram in state complex box