]> Creatis software - bbtkGEditor.git/commitdiff
#3057 bbGEditor Feature New Normal - optimizing of vtk actors management (input...
authorEduardo DAVILA <davila@localhost.localdomain>
Thu, 19 Jan 2017 14:12:53 +0000 (15:12 +0100)
committerEduardo DAVILA <davila@localhost.localdomain>
Thu, 19 Jan 2017 14:12:53 +0000 (15:12 +0100)
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBoxModel.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.h
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.h
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGPortView.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/bbtkwxGUIEditorGraphicBBS.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h

index cb7b9116be6dac37e80c1ecefd2b6fab72c7f4dd..d924c66910983472723c2f8657bf6886a25a7c2c 100644 (file)
@@ -80,7 +80,6 @@ namespace bbtk
        void GBoxModel::setInicPoint(double& x, double& y, double& z)
        {
                GObjectModel::setInicPoint(x,y,z);
-
                double xFin=x+BOX_WIDTH,yFin=y-BOX_HEIGHT;
                setFinalPoint(xFin,yFin,z);
        }
index 5d82cbf19a48b491aae8faeab9712de99b0241e4..c9d9e70297b929fcc956196bbddf910b63367128 100644 (file)
@@ -132,6 +132,42 @@ namespace bbtk
 
                updatePorts();
 
+
+// update position for one Actor that represents all InputPorts
+               GPortModel      *portModel;
+               GBoxModel       *boxModel                       =(GBoxModel*)_model;
+               int numberOfTriangles                   = boxModel->getNumInputPorts();
+               for (int i=0;i<numberOfTriangles;i++)
+               {
+                       portModel= boxModel->getInputPort(i);
+               portModel->getInicPoint( xInic , yInic , zInic ) ;
+               portModel->getFinalPoint( xFin , yFin , zFin ) ;
+               // RaC In the actual version, zInic=zFin=GPOSITION_Z
+                       _TrianglesInputsPts->SetPoint(i*3+0, xInic                                      , yInic , zInic );
+                       _TrianglesInputsPts->SetPoint(i*3+1, ( xInic + xFin ) / 2       , yFin  , zInic );
+                       _TrianglesInputsPts->SetPoint(i*3+2, xFin                                       , yInic , zFin );
+               }
+        _TrianglesInputsPolyMapper->Modified( ) ;
+
+// update position for one Actor that represents all OutputPorts
+               numberOfTriangles                       = boxModel->getNumOutputPorts();
+               for (int i=0;i<numberOfTriangles;i++)
+               {
+                       portModel= boxModel->getOutputPort(i);
+               portModel->getInicPoint( xInic , yInic , zInic ) ;
+               portModel->getFinalPoint( xFin , yFin , zFin ) ;
+               // RaC In the actual version, zInic=zFin=GPOSITION_Z
+                       _TrianglesOutputsPts->SetPoint(i*3+0, xInic                                     , yInic , zInic );
+                       _TrianglesOutputsPts->SetPoint(i*3+1, ( xInic + xFin ) / 2      , yFin  , zInic );
+                       _TrianglesOutputsPts->SetPoint(i*3+2, xFin                                      , yInic , zFin );
+               }
+        _TrianglesOutputsPolyMapper->Modified( ) ;
+
+
+
+// update position for one Actor that represents all OutputPorts
+
+
                _borderPolyMapper->Modified();
                _fillPolyMapper->Modified();
                //-----------
@@ -188,34 +224,80 @@ namespace bbtk
 
 
                ///************************* FILL *************************
-
                vtkCellArray *strip = vtkCellArray::New();
                vtkPolyData *pdFill = vtkPolyData::New();
                _fillPolyMapper         = vtkPolyDataMapper::New();
                _fillObjectActor        = vtkActor::New();
-
                // RaC In the actual version, zInic=zFin=GPOSITION_Z
-
                strip->InsertNextCell(5);
                strip->InsertCellPoint(0);
                strip->InsertCellPoint(1);
                strip->InsertCellPoint(2);
                strip->InsertCellPoint(0);
                strip->InsertCellPoint(3);
-
                pdFill->SetPoints( _pts );
                pdFill->SetStrips( strip );
-
                _fillPolyMapper->SetInput(pdFill);
                _fillObjectActor->SetMapper(_fillPolyMapper);
                _fillPolyMapper->Modified();
-
                ///************************* FILL *************************
 
+
+//EED2017
+               ///************************* Inputs Fill (triangles) *************************
+               GBoxModel* boxModel                     =(GBoxModel*)_model;
+               int numberOfTriangles                   = boxModel->getNumInputPorts();
+               _TrianglesInputsPts                             = vtkPoints::New();
+               _TrianglesInputsPts->SetNumberOfPoints( 3*numberOfTriangles );
+               vtkCellArray *stripTrianglesInputs = vtkCellArray::New();
+               vtkPolyData *pdTrianglesInputs  = vtkPolyData::New();
+               _TrianglesInputsPolyMapper              = vtkPolyDataMapper::New();
+               _TrianglesInputsActor                   = vtkActor::New();
+               // RaC In the actual version, zInic=zFin=GPOSITION_Z
+               for (int i=0 ; i<numberOfTriangles; i++)
+               {
+                               stripTrianglesInputs->InsertNextCell( 3 );
+                               stripTrianglesInputs->InsertCellPoint(i*3+0);
+                               stripTrianglesInputs->InsertCellPoint(i*3+1);
+                               stripTrianglesInputs->InsertCellPoint(i*3+2);
+               }
+               pdTrianglesInputs->SetPoints( _TrianglesInputsPts );
+               pdTrianglesInputs->SetStrips( stripTrianglesInputs );
+               _TrianglesInputsPolyMapper->SetInput( pdTrianglesInputs );
+               _TrianglesInputsActor->SetMapper(_TrianglesInputsPolyMapper);
+               _TrianglesInputsPolyMapper->Modified();
+               ///************************* Inputs Fill (triangles) *************************
+
+               ///************************* Outputs Fill (triangles) *************************
+//             GBoxModel* boxModel                                     =(GBoxModel*)_model;
+               numberOfTriangles                                               = boxModel->getNumOutputPorts();
+               _TrianglesOutputsPts                                    = vtkPoints::New();
+               _TrianglesOutputsPts->SetNumberOfPoints( 3*numberOfTriangles );
+               vtkCellArray *stripTrianglesOutputs     = vtkCellArray::New();
+               vtkPolyData *pdTrianglesOutputs                 = vtkPolyData::New();
+               _TrianglesOutputsPolyMapper                             = vtkPolyDataMapper::New();
+               _TrianglesOutputsActor                                  = vtkActor::New();
+               // RaC In the actual version, zInic=zFin=GPOSITION_Z
+               for (int i=0 ; i<numberOfTriangles; i++)
+               {
+                               stripTrianglesOutputs->InsertNextCell( 3 );
+                               stripTrianglesOutputs->InsertCellPoint(i*3+0);
+                               stripTrianglesOutputs->InsertCellPoint(i*3+1);
+                               stripTrianglesOutputs->InsertCellPoint(i*3+2);
+               }
+               pdTrianglesOutputs->SetPoints( _TrianglesOutputsPts );
+               pdTrianglesOutputs->SetStrips( stripTrianglesOutputs );
+               _TrianglesOutputsPolyMapper->SetInput( pdTrianglesOutputs );
+               _TrianglesOutputsActor->SetMapper(_TrianglesOutputsPolyMapper);
+               _TrianglesOutputsPolyMapper->Modified();
+               ///************************* Inputs Fill (triangles) *************************
+
+
+
                //------------
 
-               _boxTextActor           = vtkTextActor3D::New();
-               vtkTextProperty *prop =  vtkTextProperty::New();
+               _boxTextActor                   = vtkTextActor3D::New();
+               vtkTextProperty *prop   =  vtkTextProperty::New();
                prop->BoldOn();
                prop->SetFontFamilyToArial();
                _boxTextActor->GetTextProperty()->BoldOn();
@@ -238,14 +320,21 @@ namespace bbtk
                _baseView->GetRenderer()->AddActor(_borderObjectActor);
                vtkGObjectView::addVtkActors();
                _baseView->GetRenderer()->AddActor(_boxTextActor);
+
+               _baseView->GetRenderer()->AddActor(_TrianglesInputsActor);
+               _baseView->GetRenderer()->AddActor(_TrianglesOutputsActor);
+
+
        }
 
        //=========================================================================
 
        void vtkGBlackBoxView::removeVtkActors()//virtual
        {
-               _baseView->GetRenderer()->RemoveActor(_borderObjectActor);
                _baseView->GetRenderer()->RemoveActor(_boxTextActor);
+               _baseView->GetRenderer()->RemoveActor(_borderObjectActor);
+               _baseView->GetRenderer()->RemoveActor(_TrianglesInputsActor);
+               _baseView->GetRenderer()->RemoveActor(_TrianglesOutputsActor);
                vtkGObjectView::removeVtkActors();
        }
 
index 9d594716820d542727069c002e454d98f6fb2815..5005261e22d4c540615e368e91fb8b7e6e435b0d 100644 (file)
@@ -111,7 +111,18 @@ namespace bbtk
        private:
 
                //Private Attributes
-               vtkTextActor3D* _boxTextActor;
+               vtkTextActor3D          *_boxTextActor;
+
+               // Input Triangles
+               vtkPoints               *_TrianglesInputsPts;
+               vtkPolyDataMapper       *_TrianglesInputsPolyMapper;
+               vtkActor                *_TrianglesInputsActor;
+
+               // Output Triangles
+               vtkPoints               *_TrianglesOutputsPts;
+               vtkPolyDataMapper       *_TrianglesOutputsPolyMapper;
+               vtkActor                *_TrianglesOutputsActor;
+
 
                //Private Methods
                void updatePositionTextActor(double xInic, double yInic, double zInic);
index 50ca906694be2d90850ee69812c91d4c46b307e0..abd696c59ca0a53e4fa940251d19a50a50fb53a7 100644 (file)
@@ -129,7 +129,7 @@ namespace bbtk
        void vtkGObjectView::addVtkActors()//virtual
        {               
                _baseView->GetRenderer()->AddActor(_fillObjectActor);
-               _baseView->GetRenderer()->Render();
+//EED2017              _baseView->GetRenderer()->Render();
        }
 
        //=========================================================================
@@ -137,7 +137,7 @@ namespace bbtk
        void vtkGObjectView::removeVtkActors()//virtual
        {
                _baseView->GetRenderer()->RemoveActor(_fillObjectActor);
-               _baseView->GetRenderer()->Render();
+//EED2017              _baseView->GetRenderer()->Render();
        }
 
        //=========================================================================
index 9124a20761f85585aac4e27faef471d36d73fb68..50221435891afed5790f081e9eba8f68f6f0529a 100644 (file)
@@ -122,6 +122,11 @@ namespace bbtk
                virtual void removeFromScene();
 
                virtual void update(int idController,int command);              
+
+//protected
+               virtual void createVtkObjects();
+               virtual void addVtkActors();
+
                
        private:
 
@@ -152,8 +157,6 @@ namespace bbtk
                int  _state;
                
                //Protected Methods
-               virtual void createVtkObjects();
-               virtual void addVtkActors();
                virtual void removeVtkActors();
                virtual void updateColors();
        };
index c7ee91f0db8960c72b3a0887f706243de869290d..b0ef338bd65eda4de2ab9c4294462e530adc1cc0 100644 (file)
@@ -77,25 +77,19 @@ namespace bbtk {
 
     //=========================================================================
 
-    void vtkGPortView::update( int idController , int command ) {
-
+    void vtkGPortView::update( int idController , int command ) 
+{
         updateColors( ) ;
 
         double xInic , yInic , zInic , xFin , yFin , zFin ;
-
         _model->getInicPoint( xInic , yInic , zInic ) ;
         _model->getFinalPoint( xFin , yFin , zFin ) ;
-
         // RaC In the actual version, zInic=zFin=GPOSITION_Z
-
         double mid = ( xInic + xFin ) / 2 ;
-
         _pts->SetPoint( 0 , xInic , yInic , zInic ) ;
         _pts->SetPoint( 1 , mid , yFin , zInic ) ;
         _pts->SetPoint( 2 , xFin , yInic , zFin ) ;
-
         _fillPolyMapper->Modified( ) ;
-
         //-----------
         setRefreshWaiting( ) ;
     }
@@ -104,8 +98,6 @@ namespace bbtk {
 
     void vtkGPortView::createVtkObjects( ) //virtual
     {
-        _pts = vtkPoints::New( ) ;
-        _pts->SetNumberOfPoints( 3 ) ;
 
         double xInic , yInic , zInic , xFin , yFin , zFin ;
 
@@ -120,6 +112,9 @@ namespace bbtk {
         //EED          _pts->SetPoint(1, mid, yFin, zInic );
         //EED          _pts->SetPoint(2, xFin, yInic, zFin );                          
 
+        _pts = vtkPoints::New( ) ;
+        _pts->SetNumberOfPoints( 3 ) ;
+
         _pts->SetPoint( 0 , -1000 , -1000 , -1000 ) ;
         _pts->SetPoint( 1 , mid , yFin , zInic ) ;
         _pts->SetPoint( 2 , 1000 , 1000 , 1000 ) ;
index c53529c0af34e17f98e8303549d020368382666f..1376327ad2bea388f833aa242751243f2d530bec 100644 (file)
@@ -1090,6 +1090,7 @@ void wxGUIEditorGraphicBBS::OpenDiagram(std::string filePathName, std::string fi
        }
        _tabsMgr->addNewTab( crea::std2wx(fileName) );
        _tabsMgr->loadDiagram(inputStream, filePathName);
+
        _tabsMgr->saveTempActualDiagram("load diagram");
        GetToolBar()->EnableTool(ID_UNDO, false);
        GetToolBar()->EnableTool(ID_UNDO, false);
index 599a26214478143bcc477bcf45d5b0cb87c0f804..95a2454c22ff447cf2ec8b5e21ee29bede39abf0 100644 (file)
@@ -280,6 +280,7 @@ int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName,std
 
 //EED 15 oct 2012      BlackBoxDescriptor::Pointer descriptor = GObjectsMVCFactory::getInstance()->getBlackBoxDescriptor(packageName, boxType);
        
+
        Package::Pointer k;
        std::map< std::string, BlackBoxDescriptor::Pointer> mapDesc;
        try{
@@ -332,7 +333,6 @@ int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName,std
        std::map<std::string, BlackBoxInputDescriptor*> descriptorInMap =
                        descriptor->GetInputDescriptorMap();
        std::map<std::string, BlackBoxInputDescriptor*>::iterator itInput;
-
        int i = 0;
        for (itInput = descriptorInMap.begin(); itInput != descriptorInMap.end(); ++itInput) {
                BlackBoxInputDescriptor *desc = itInput->second;
@@ -344,7 +344,6 @@ int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName,std
        std::map<std::string, BlackBoxOutputDescriptor*> descriptorOutMap =
                        descriptor->GetOutputDescriptorMap();
        std::map<std::string, BlackBoxOutputDescriptor*>::iterator itOutput;
-
        i = 0;
        for (itOutput = descriptorOutMap.begin(); itOutput
                        != descriptorOutMap.end(); ++itOutput) {
@@ -357,6 +356,7 @@ int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName,std
        //(NOTE: Refresh is only made by the view)
        view->setModel(model);
        view->setBaseView(_baseView);
+
        view->initVtkObjects();
 
        //Associates the controller with the correspondent model and view
@@ -526,7 +526,11 @@ GPortController* wxVtkSceneManager::createGPort(int portType,std::string bbtkNam
        //(NOTE: Refresh is only made by the view)
        view->setModel(model);
        view->setBaseView(_baseView);
-       view->initVtkObjects();
+
+//EED017       view->initVtkObjects();
+       view->createVtkObjects();
+//  view->addVtkActors();
+
 
        //Associates the controller with the correspondent model and view
        controller->setModelAndView(model, view);
@@ -536,6 +540,7 @@ GPortController* wxVtkSceneManager::createGPort(int portType,std::string bbtkNam
        addObjectController(controller);
 
        return (GPortController*) controller;
+
 }
 
 //=========================================================================
@@ -570,7 +575,8 @@ int wxVtkSceneManager::createGConnector(GPortModel* startPort)
          * JGRR AND CM
          * Width increased from 2 to 3, it simplifies line handling and spline control :P
          * @param WidthLine  
-         */ 
+         */
+ //EED2017
         manContourView->SetWidthLine( 3 ) ;
        manContourView->SetShowText(false);
 
@@ -2182,7 +2188,8 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
                std::istringstream is(result);
                is >> numBoxes;
 
-               for (int i = 0; i < numBoxes; i++) {
+               for (int i = 0; i < numBoxes; i++) 
+               {
                        //----------
                        getCleanLine(inputStream, line);//BOX
                        getCleanLine(inputStream, line);//package:type:name
@@ -2254,7 +2261,8 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
                        
                        
                        bool boxExecutable = false;
-                       if (isExec == "TRUE") {
+                       if (isExec == "TRUE") 
+                       {
                                boxExecutable = true;
                        }
 
@@ -2311,7 +2319,8 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
                isCons >> numConns;
                
                
-               for (int i = 0; i < numConns; i++) {
+               for (int i = 0; i < numConns; i++) 
+               {
                        //----------
                        getCleanLine(inputStream, line);//CONNECTION
                        getCleanLine(inputStream, line);//Startbox.PortName:EndBox.PortName
@@ -2327,7 +2336,6 @@ void wxVtkSceneManager::loadDiagram(stringstream &inputStream)
                        result = strtok(NULL, delims);
                        std::string nameEndPort(result);
 
-
                        int idCon = configGConnetion(nameStartBox, nameStartPort,nameEndBox, nameEndPort);
 
                        if (version != "1.0") {
index 4bad6682421d5113b925e6efae088a18e430370f..000b62e2e10d03e97d7f2e53642626d5187cbadd 100644 (file)
@@ -136,8 +136,8 @@ namespace bbtk
                virtual bool OnLeftButtonUp();
                virtual bool OnRightButtonUp();
                virtual bool OnLeftDClick();
-                virtual bool OnMiddleButtonDown(); ///JLGR 21-05-2012
-                virtual bool OnMiddleButtonUp(); ///JLGR 21-05-2012
+        virtual bool OnMiddleButtonDown(); ///JLGR 21-05-2012
+        virtual bool OnMiddleButtonUp(); ///JLGR 21-05-2012
 
                //-------
                int createGBlackBox(int x, int y, std::string packageName, std::string boxType );
@@ -189,8 +189,8 @@ namespace bbtk
                //Add a map of object controllers
                void addObjects(std::map<int,GObjectController*> objectsMap);
 
-                /// Duplicates Objects to current a diagram
-                void DuplicateObjects(std::map<int,GObjectController*> objectsMap);///JLGR 21-05-2012
+               /// Duplicates Objects to current a diagram
+       void DuplicateObjects(std::map<int,GObjectController*> objectsMap);///JLGR 21-05-2012
 
                //-------
                // Makes a BlackBox Executable
@@ -259,8 +259,8 @@ namespace bbtk
         std::string                         _Author;
         std::string                         _Category;
         std::string                         _Description;
-                               std::string                         _MessageKind;
-                               std::string                         _MessageLevel;
+               std::string                                     _MessageKind;
+               std::string                                     _MessageLevel;
 
                //wxPanel that uses the manager
                wxGEditorTabPanel                                       *_parent;
@@ -294,11 +294,11 @@ namespace bbtk
                int _contLastId;
 
                vtkTextActor3D                                          *_textActor;
-               std::string                                             _bugTextActor_text;
-               int                                                     _bugTextActor_status;
+               std::string                                                     _bugTextActor_text;
+               int                                                                     _bugTextActor_status;
 
-               vtkPoints                                               *_pts;
-               vtkActor                                                *_fillObjectActor;
+               vtkPoints                                                       *_pts;
+               vtkActor                                                        *_fillObjectActor;
                vtkDataSetMapper                                        *_aPolygonMapper;
 
                Factory::Pointer                                        _bbtkfactory;