]> Creatis software - bbtkGEditor.git/blobdiff - lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h
Feature #1366 Increased the line width of bbEditor connections.
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsWxGUIEditorGraphic / wxVtkSceneManager.h
index fe5889c831a0ec357c4f3a2694a05dba54ee992e..fadb8ba819ca0428be5046fd71d3bbc0f43ea870 100644 (file)
@@ -8,38 +8,38 @@ Version:   $Revision$
 
 /* ---------------------------------------------------------------------
 
-* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
-* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
-*
-*  This software is governed by the CeCILL-B license under French law and
-*  abiding by the rules of distribution of free software. You can  use,
-*  modify and/ or redistribute the software under the terms of the CeCILL-B
-*  license as circulated by CEA, CNRS and INRIA at the following URL
-*  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
-*  or in the file LICENSE.txt.
-*
-*  As a counterpart to the access to the source code and  rights to copy,
-*  modify and redistribute granted by the license, users are provided only
-*  with a limited warranty  and the software's author,  the holder of the
-*  economic rights,  and the successive licensors  have only  limited
-*  liability.
-*
-*  The fact that you are presently reading this means that you have had
-*  knowledge of the CeCILL-B license and that you accept its terms.
-* ------------------------------------------------------------------------ */
+ * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
+ * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
+ *
+ *  This software is governed by the CeCILL-B license under French law and
+ *  abiding by the rules of distribution of free software. You can  use,
+ *  modify and/ or redistribute the software under the terms of the CeCILL-B
+ *  license as circulated by CEA, CNRS and INRIA at the following URL
+ *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+ *  or in the file LICENSE.txt.
+ *
+ *  As a counterpart to the access to the source code and  rights to copy,
+ *  modify and redistribute granted by the license, users are provided only
+ *  with a limited warranty  and the software's author,  the holder of the
+ *  economic rights,  and the successive licensors  have only  limited
+ *  liability.
+ *
+ *  The fact that you are presently reading this means that you have had
+ *  knowledge of the CeCILL-B license and that you accept its terms.
+ * ------------------------------------------------------------------------ */
 
 
 
 /**
-*  \file
-*  \brief Class bbtk::BlackBox : abstract black-box interface.
-*/
+ *  \file
+ *  \brief Class bbtk::BlackBox : abstract black-box interface.
+ */
 
 /****
-* Design and Developpement of BBTK GEditor
-* Ricardo A Corredor J <ra.corredor67@uniandes.edu.co>
-* RaC - 2010
-****/
+ * Design and Developpement of BBTK GEditor
+ * Ricardo A Corredor J <ra.corredor67@uniandes.edu.co>
+ * RaC - 2010
+ ****/
 
 #ifndef __wxVtkSceneManager_h__
 #define __wxVtkSceneManager_h__
@@ -77,7 +77,7 @@ Version:   $Revision$
 #include <vtkActor.h>
 #include <vtkPoints.h>
 #include <vtkTextActor3D.h>
- #include <vtkDataSetMapper.h>
+#include <vtkDataSetMapper.h>
 
 
 //Includes std
@@ -86,6 +86,7 @@ Version:   $Revision$
 #include <sstream>
 #include <map>
 
+
 namespace bbtk
 {
        class wxGEditorTabPanel;
@@ -127,6 +128,78 @@ namespace bbtk
                void configGComBoxInputOutputPort(bool inputoutput, std::string inputPortName, double xIn, double yIn,double zIn);
                GBoxModel* findGBox(std::string boxname);
 
+    class wxVtkSceneManager : public InteractorStyleMaracas, public Observer {
+    public:
+
+        wxVtkSceneManager( wxGEditorTabPanel *parent, wxVtk3DBaseView *baseView, int idManager );
+        ~ wxVtkSceneManager( );
+        void disconnectDrop( );
+
+        //-------
+        void configureBaseView( );
+        void registerController( InteractorStyleMaracas *param );
+        void unregisterController( InteractorStyleMaracas *param );
+
+        virtual bool OnChar( );
+        virtual bool OnMouseMove( );
+        virtual bool OnLeftButtonDown( );
+        virtual bool OnLeftButtonUp( );
+        virtual bool OnRightButtonUp( );
+        virtual bool OnLeftDClick( );
+
+        //-------
+        int createGBlackBox( int x, int y, std::string packageName, std::string boxType );
+        int createGComplexBoxInputPort( std::string inputName );
+        int createGComplexBoxOutputPort( std::string outputName );
+        GPortController* createGPort( int portType, std::string bbtkName, std::string bbtkType, int posinBox, GBoxModel *blackBox );
+        int createGInputPort( int portType, int posinBox, GBoxModel *blackBox, BlackBoxInputDescriptor *desc );
+        int createGOutputPort( int portType, int posinBox, GBoxModel *blackBox, BlackBoxOutputDescriptor *desc );
+        int createGConnector( GPortModel* startPort );
+
+        void configGBlackBox( int idBox, double xIn, double yIn, double zIn, std::string name, bool boxExecutable, double xEn, double yEn, double zEn );
+        int configGConnetion( std::string nameStartBox, std::string nameStartPort, std::string
+        nameEndBox, std::string nameEndPort );
+        void configGComBoxInputOutputPort( bool inputoutput, std::string inputPortName, double xIn, double yIn, double zIn );
+        GBoxModel* findGBox( std::string boxname );
+
+        vtkRenderWindow* getRenderWindow( );
+        vtkRenderer* getRenderer( );
+
+        virtual void update( int idController, int command );
+
+        void refresh( );
+        void refreshScene( );
+        void displayBlackBoxInfo( std::string packageName, std::string boxName );
+        void updateStatusBar( std::string textStatus );
+
+        //-------
+        //Get a collection of object ids
+        std::vector<int> getBlackBoxes( );
+        std::vector<int> getConnections( );
+        std::vector<int> getComplexInputPorts( );
+        std::vector<int> getComplexOutputPorts( );
+
+        //Get the map of selected objects (id, controller)
+        std::map<int, GObjectController*> getSelectedObjects( );
+
+        //Get size of selected objects map
+        int getNumSelectedObjects( );
+
+        //Complex box edition mode
+        bool isComplexBox( );
+        void setComplexBox( bool val );
+
+        //-------
+        //Add an object to the list of controllers
+        int addObjectController( GObjectController* objController );
+
+        //Add a map of object controllers
+        void addObjects( std::map<int, GObjectController*> objectsMap );
+
+
+        //-------
+        //Returns a string with the BBS script of the current diagram.
+        std::string getDiagramBBS( bool wln = false );
 
 
                vtkRenderWindow* getRenderWindow();
@@ -173,96 +246,97 @@ namespace bbtk
                //Returns a string with the BBS script of the current diagram.
                std::string getDiagramBBS(bool wln=false);
 
-               //Returns a string with the BBS script of the complex box.
-               std::string saveComplexBoxBBS();
 
-               //Delete the object in the list of controllers with the id given by parameter.
-               void deleteObject(int id);
+        void AddControlerToBeRemove( std::vector<int> *controllersToRemove, int id );
+
+        //Clear list of controllers and refresh
+        void deleteAllBoxes( );
 
-               void AddControlerToBeRemove(std::vector<int> *controllersToRemove, int id);
+        //Save the diagram in the BBG format, in the string given by param.
+        void saveDiagram( std::string &content );
 
-               //Clear list of controllers and refresh
-               void deleteAllBoxes();
+        //Load the diagram
+        void loadDiagram( ifstream &inputStream );
 
-               //Save the diagram in the BBG format, in the string given by param.
-               void saveDiagram(std::string &content);
+        //Center the view of the camera in the initial position
+        void centerView( );
 
                //Load the diagram
                void loadDiagram(std::stringstream &inputStream);
 
-               //Center the view of the camera in the initial position
-               void centerView();
 
-               bool boxExist(std::string boxname);
-               std::string generateANewNameForABox();
-               std::string findANewNameForABox();
-               //-------
+        void SetCbName( std::string cbNane );
+        void SetCbPackageName( std::string packagename );
+        void SetAuthor( std::string author );
+        void SetCategory( std::string category );
+        void SetDescription( std::string description );
+
+        std::string GetCbName( );
+        std::string GetCbPackageName( );
+        std::string GetAuthor( );
+        std::string GetCategory( );
+        std::string GetDescription( );
+        
+        
 
-        void SetCbName(std::string cbNane);
-        void SetCbPackageName(std::string packagename);
-        void SetAuthor(std::string author);
-        void SetCategory(std::string category);
-        void SetDescription(std::string description);
+        // JGRR & CM
+        void printAll( int com, int sta );
 
-        std::string GetCbName();
-        std::string GetCbPackageName();
-        std::string GetAuthor();
-        std::string GetCategory();
-        std::string GetDescription();
+        
 
-       private:
+    private:
 
-        std::string                         _cbName;
-        std::string                         _cbPackageName;
-        std::string                         _Author;
-        std::string                         _Category;
-        std::string                         _Description;
+        std::string _cbName;
+        std::string _cbPackageName;
+        std::string _Author;
+        std::string _Category;
+        std::string _Description;
 
-               //wxPanel that uses the manager
-               wxGEditorTabPanel                                       *_parent;
+        //wxPanel that uses the manager
+        wxGEditorTabPanel *_parent;
 
-               // Id of the manager, the same of the panel
-               int                                                                     _idManager;
+        // Id of the manager, the same of the panel
+        int _idManager;
 
-               // Boxes number in the scene
-               int                                                                     _numBoxes;
+        // Boxes number in the scene
+        int _numBoxes;
 
-               // StartDragging
-               bool                                                            _startDragging;
+        // StartDragging
+        bool _startDragging;
 
-               // creaMaracasVisu viewer
-               wxVtk3DBaseView                                         *_baseView;
+        // creaMaracasVisu viewer
+        wxVtk3DBaseView *_baseView;
 
-               // State of the 3D Scene or the virtual world
-               int _worldState;
+        // State of the 3D Scene or the virtual world
+        int _worldState;
 
-               //Map of id - objectController
-               std::map<int,GObjectController*>        _controllers;
+        //Map of id - objectController
+        std::map<int, GObjectController*> _controllers;
 
-               //Saves the id's of the selected objects in the controllers map
-               std::vector<int>                                        _selectedObjects;
+        //Saves the id's of the selected objects in the controllers map
+        std::vector<int> _selectedObjects;
 
-               //Is the diagram in state complex box
-               bool                                                            _isComplexBox;
+        //Is the diagram in state complex box
+        bool _isComplexBox;
 
-               int                                                                     _idConnectionInCreation;
+        int _idConnectionInCreation;
 
-               int _contLastId;
+        int _contLastId;
 
-               vtkTextActor3D                                          *_textActor;
-               vtkPoints                                                       *_pts;
-               vtkActor                                                        *_fillObjectActor;
-               vtkDataSetMapper                                        *_aPolygonMapper;
+        vtkTextActor3D *_textActor;
+        vtkPoints *_pts;
+        vtkActor *_fillObjectActor;
+        vtkDataSetMapper *_aPolygonMapper;
 
-        std::string LineNumber(bool withLineNumber, int &value);
-        int GetIndexInSelected(int idControler);
-        void UnSelectBlackBoxes();
-        GObjectController *GetGBlackBoxControlerPointedByMouse();
-               void CancelConnection();
+        std::string LineNumber( bool withLineNumber, int &value );
+        int GetIndexInSelected( int idControler );
+        void UnSelectBlackBoxes( );
+        GObjectController *GetGBlackBoxControlerPointedByMouse( );
+        void CancelConnection( );
 
-       protected:
+    protected:
 
-       };
+    };
 
 
 }