wxVtkSceneManager.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 Program:   bbtk
00003 Module:    $RCSfile: wxVtkSceneManager.h,v $
00004 Language:  C++
00005 Date:      $Date: 2012/05/24 09:31:17 $
00006 Version:   $Revision: 1.28 $
00007 =========================================================================*/
00008 
00009 /* ---------------------------------------------------------------------
00010 
00011 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
00012 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
00013 *
00014 *  This software is governed by the CeCILL-B license under French law and
00015 *  abiding by the rules of distribution of free software. You can  use,
00016 *  modify and/ or redistribute the software under the terms of the CeCILL-B
00017 *  license as circulated by CEA, CNRS and INRIA at the following URL
00018 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
00019 *  or in the file LICENSE.txt.
00020 *
00021 *  As a counterpart to the access to the source code and  rights to copy,
00022 *  modify and redistribute granted by the license, users are provided only
00023 *  with a limited warranty  and the software's author,  the holder of the
00024 *  economic rights,  and the successive licensors  have only  limited
00025 *  liability.
00026 *
00027 *  The fact that you are presently reading this means that you have had
00028 *  knowledge of the CeCILL-B license and that you accept its terms.
00029 * ------------------------------------------------------------------------ */
00030 
00031 
00032 
00038 /****
00039 * Design and Developpement of BBTK GEditor
00040 * Ricardo A Corredor J <ra.corredor67@uniandes.edu.co>
00041 * RaC - 2010
00042 ****/
00043 
00044 #ifndef __wxVtkSceneManager_h__
00045 #define __wxVtkSceneManager_h__
00046 
00047 //Includes same project
00048 #include "GObjectsMVCFactory.h"
00049 #include "Observer.h"
00050 #include "GBoxModel.h"
00051 #include "GComplexBoxPortModel.h"
00052 #include "GPortModel.h"
00053 #include "vtkGConnectorView.h"
00054 #include "GConnectorModel.h"
00055 #include "GConnectorController.h"
00056 #include "vtkGPortView.h"
00057 #include "manualConnectorContourView.h"
00058 #include "manualConnectorContourController.h"
00059 #include "wxGEditorTabPanel.h"
00060 
00061 //Includes bbtk
00062 #include <bbtkBlackBoxInputDescriptor.h>
00063 #include <bbtkBlackBoxDescriptor.h>
00064 
00065 //Includes creaMaracasVisu
00066 #include <wxVtk3DBaseView.h>
00067 #include <InteractorStyleMaracas.h>
00068 #include <vtkInteractorStyleBaseView2D.h>
00069 #include <manualContourControler.h>
00070 #include <manualContourModel.h>
00071 
00072 //Includes vtk
00073 #include <vtkRenderWindow.h>
00074 #include <vtkRenderWindowInteractor.h>
00075 #include <vtkRenderer.h>
00076 #include <vtkInteractorStyleImage.h>
00077 #include <vtkActor.h>
00078 #include <vtkPoints.h>
00079 #include <vtkTextActor3D.h>
00080  #include <vtkDataSetMapper.h>
00081 
00082 
00083 //Includes std
00084 #include <iostream>
00085 #include <string>
00086 #include <sstream>
00087 #include <map>
00088 
00089 namespace bbtk
00090 {
00091         class wxGEditorTabPanel;
00092 
00093         class wxVtkSceneManager : public InteractorStyleMaracas , public Observer
00094         {
00095         public:
00096 
00097                 wxVtkSceneManager(wxGEditorTabPanel *parent, wxVtk3DBaseView *baseView, int idManager);
00098                 ~wxVtkSceneManager();
00099                 void disconnectDrop();
00100 
00101                 //-------
00102                 void configureBaseView();
00103                 void registerController(InteractorStyleMaracas *param);
00104                 void unregisterController(InteractorStyleMaracas *param);
00105 
00106                 virtual bool OnChar();
00107                 virtual bool OnMouseMove();
00108                 virtual bool OnLeftButtonDown();
00109                 virtual bool OnLeftButtonUp();
00110                 virtual bool OnRightButtonUp();
00111                 virtual bool OnLeftDClick();
00112                 virtual bool OnMiddleButtonDown(); 
00113                 virtual bool OnMiddleButtonUp(); 
00114 
00115                 //-------
00116                 int createGBlackBox(int x, int y, std::string packageName, std::string boxType );
00117                 int createGComplexBoxInputPort(std::string inputName);
00118                 int createGComplexBoxOutputPort(std::string outputName);
00119                 GPortController* createGPort(int portType, std::string bbtkName, std::string bbtkType, int posinBox,GBoxModel *blackBox);
00120                 int createGInputPort(int portType, int posinBox,GBoxModel *blackBox, BlackBoxInputDescriptor *desc);
00121                 int createGOutputPort(int portType, int posinBox,GBoxModel *blackBox, BlackBoxOutputDescriptor *desc);
00122                 int createGConnector(GPortModel* startPort);
00123 
00124                 void configGBlackBox(int idBox, double xIn, double yIn, double zIn, std::string name, bool boxExecutable,double xEn,double yEn,double zEn);
00125                 int configGConnetion( std::string nameStartBox, std::string  nameStartPort, std::string
00126                                                           nameEndBox, std::string  nameEndPort);
00127                 void configGComBoxInputOutputPort(bool inputoutput, std::string inputPortName, double xIn, double yIn,double zIn);
00128                 GBoxModel* findGBox(std::string boxname);
00129 
00130 
00131 
00132                 vtkRenderWindow* getRenderWindow();
00133                 vtkRenderer* getRenderer();
00134 
00135                 virtual void update(int idController,int command);
00136 
00137                 void refresh();
00138                 void refreshScene();
00139                 void displayBlackBoxInfo(std::string packageName, std::string boxName);
00140                 void updateStatusBar(std::string textStatus);
00141 
00142                 //-------
00143                 //Get a collection of object ids
00144                 std::vector<int> getBlackBoxes();
00145                 std::vector<int> getConnections();
00146                 std::vector<int> getComplexInputPorts();
00147                 std::vector<int> getComplexOutputPorts();
00148 
00149                 //Get the map of selected objects (id, controller)
00150                 std::map<int,GObjectController*> getSelectedObjects();
00151 
00152                 //Get size of selected objects map
00153                 int getNumSelectedObjects();
00154 
00155                 //Complex box edition mode
00156                 bool isComplexBox();
00157                 void setComplexBox(bool val);
00158 
00159                 //-------
00160                 //Add an object to the list of controllers
00161                 int addObjectController(GObjectController* objController);
00162 
00163                 //Add a map of object controllers
00164                 void addObjects(std::map<int,GObjectController*> objectsMap);
00165 
00167                 void DuplicateObjects(std::map<int,GObjectController*> objectsMap);
00168 
00169                 //-------
00170                 // Makes a BlackBox Executable
00171                 bool MakeBoxExecutable();//DFCH
00172                 //-------
00173                 //Returns a string with the BBS script of the current diagram.
00174                 std::string getDiagramBBS(bool wln=false);
00175 
00176                 //Returns a string with the BBS script of the complex box.
00177                 std::string saveComplexBoxBBS();
00178 
00179                 //Delete the object in the list of controllers with the id given by parameter.
00180                 void deleteObject(int id);
00181 
00182                 void AddControlerToBeRemove(std::vector<int> *controllersToRemove, int id);
00183 
00184                 //Clear list of controllers and refresh
00185                 void deleteAllBoxes();
00186 
00187                 //Save the diagram in the BBG format, in the string given by param.
00188                 void saveDiagram(std::string &content);
00189 
00190                 //Load the diagram
00191                 void loadDiagram(std::stringstream &inputStream);
00192 
00193                 //Center the view of the camera in the initial position
00194                 void centerView();
00195 
00196                 bool boxExist(std::string boxname);
00197                 std::string generateANewNameForABox();
00198                 std::string findANewNameForABox();
00199                 //-------
00200 
00201         void SetCbName(std::string cbNane);
00202         void SetCbPackageName(std::string packagename);
00203         void SetAuthor(std::string author);
00204         void SetCategory(std::string category);
00205         void SetDescription(std::string description);
00206 
00207         std::string GetCbName();
00208         std::string GetCbPackageName();
00209         std::string GetAuthor();
00210         std::string GetCategory();
00211         std::string GetDescription();
00212   
00213         // JGRR & CM
00214         void printAll( int com, int sta );
00215 
00216         private:
00217 
00218         std::string                         _cbName;
00219         std::string                         _cbPackageName;
00220         std::string                         _Author;
00221         std::string                         _Category;
00222         std::string                         _Description;
00223 
00224                 //wxPanel that uses the manager
00225                 wxGEditorTabPanel                                       *_parent;
00226 
00227                 // Id of the manager, the same of the panel
00228                 int                                                                     _idManager;
00229 
00230                 // Boxes number in the scene
00231                 int                                                                     _numBoxes;
00232 
00233                 // StartDragging
00234                 bool                                                            _startDragging;
00235 
00236                 // creaMaracasVisu viewer
00237                 wxVtk3DBaseView                                         *_baseView;
00238 
00239                 // State of the 3D Scene or the virtual world
00240                 int _worldState;
00241 
00242                 //Map of id - objectController
00243                 std::map<int,GObjectController*>        _controllers;
00244 
00245                 //Saves the id's of the selected objects in the controllers map
00246                 std::vector<int>                                        _selectedObjects;
00247 
00248                 //Is the diagram in state complex box
00249                 bool                                                            _isComplexBox;
00250 
00251                 int                                                                     _idConnectionInCreation;
00252 
00253                 int _contLastId;
00254 
00255                 vtkTextActor3D                                          *_textActor;
00256                 vtkPoints                                                       *_pts;
00257                 vtkActor                                                        *_fillObjectActor;
00258                 vtkDataSetMapper                                        *_aPolygonMapper;
00259 
00260         std::string LineNumber(bool withLineNumber, int &value);
00261         int GetIndexInSelected(int idControler);
00262         void UnSelectBlackBoxes();
00263         GObjectController *GetGBlackBoxControlerPointedByMouse();
00264                 void CancelConnection();
00265 
00266         protected:
00267 
00268         };
00269 
00270 
00271 }
00272 // namespace bbtk
00273 #endif
00274 

Generated on Thu May 31 15:12:20 2012 for bbtkGEditor by  doxygen 1.5.7.1