]> Creatis software - bbtkGEditor.git/commitdiff
Implemented deleting of boxes from the scene....
authorcorredor <>
Tue, 27 Apr 2010 11:25:06 +0000 (11:25 +0000)
committercorredor <>
Tue, 27 Apr 2010 11:25:06 +0000 (11:25 +0000)
16 files changed:
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.h
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.h
lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx
lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.h
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GPortController.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/manualConnectorContourView.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/manualConnectorContourView.h
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.h
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx
lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.h

index deeb4900f45d2a945f3622b904daac2ee27fdb71..cffd4b8a6ffc61c9b13a2a32445f235875d24adf 100644 (file)
@@ -150,6 +150,21 @@ namespace bbtk
 
        //=========================================================================
 
+       std::vector<GPortModel*> GBlackBoxModel::getInputPorts()
+       {
+               return _inputs;
+       }
+
+       //=========================================================================
+
+       std::vector<GPortModel*> GBlackBoxModel::getOutputPorts()
+       {
+               return _outputs;
+       }
+
+       //=========================================================================
+       
+
 
 }  // EO namespace bbtk
 
index 82214a4ad29c4818c145a6d4ca81b205ca09de35..000950c93a474d250142468763fa4bd321aa788d 100644 (file)
@@ -85,6 +85,9 @@ namespace bbtk
                bool isExecutable();
                void setExecutable(bool executable);
 
+               std::vector<GPortModel*> getInputPorts();
+               std::vector<GPortModel*> getOutputPorts();
+
        private:
 
                //Private Attributes
index 46e77d4888d10e560e581121e139d7f24f11dc25..e4710a2e30ad3efc0e97aa424172c8916c873b19 100644 (file)
@@ -176,6 +176,18 @@ namespace bbtk
 
        //=========================================================================
 
+       int GObjectModel::getObjectId()
+       {
+               return _objectId;
+       }
+
+       //=========================================================================
+       
+       void GObjectModel::setObjectId(int id)
+       {
+               _objectId=id;
+       }
+
 
 }  // EO namespace bbtk
 
index d1d3ce25175cfe57c29b562b5b9e55f9ebf73cd4..a6300386d4986ac813f46198ed41624775a82abb 100644 (file)
@@ -89,6 +89,9 @@ namespace bbtk
                std::string getBBTKName();
                void setBBTKName(std::string obname);
 
+               int getObjectId();
+               void setObjectId(int id);
+
                virtual std::string getStatusText();
                
        private:
@@ -109,6 +112,7 @@ namespace bbtk
                double _zFin;
 
                int  _gObjectType;
+               int _objectId;
 
                std::string _bbtkType;
                std::string _bbtkName;
index 0420aa3356d8901b591cfa0e8f30e933055cb348..c4efe5605d986f87da642f9bbcd499ea122c47e3 100644 (file)
@@ -118,7 +118,7 @@ namespace bbtk
                //The coordinates obtained are the following. Top-Left:x=0,y=0 Bottom-Right:x=width,y=height  
 
                double xx = x;
-               double yy =  windowHeight-y;
+               double yy = windowHeight-y;
                
                //z value is not important yet, because it is only used a parallel projection
                double zz = 900;
@@ -323,6 +323,14 @@ namespace bbtk
 
        //=========================================================================
 
+       void wxVtkSceneManager::unregisterController(InteractorStyleMaracas *param)
+       {
+               vtkInteractorStyleBaseView* baseViewControlManager = (vtkInteractorStyleBaseView*)_baseView->GetInteractorStyleBaseView();
+               baseViewControlManager->RemoveInteractorStyleMaracas( param );
+       }
+
+       //=========================================================================
+
        vtkRenderer* wxVtkSceneManager::getRenderer()
        {
                return _baseView->GetRenderer();
@@ -562,6 +570,69 @@ namespace bbtk
 
        //=========================================================================
 
+       bool wxVtkSceneManager::OnChar()
+       {       
+               char keyCode = _vtkInteractorStyleBaseView->GetInteractor()-> GetKeyCode();
+               
+               // KeyCode 127 : Delete Key
+               // KeyCode 8 : Backspace Key
+               if(keyCode == 8 || keyCode == 127)
+               {
+                       if(_selectedObjects.size()>0)
+                       {
+                               for(int i=0;i<_selectedObjects.size();i++)
+                               {
+                                       int id = _selectedObjects[i];
+                                       removeObject(id);
+                               }
+                               _selectedObjects.clear();
+                       }
+               }
+
+               return true;
+       }
+
+       //=========================================================================
+
+       void wxVtkSceneManager::removeObject(int id)
+       {
+               GObjectController *control = _controllers[id];
+               std::vector<int> controllersToRemove;
+
+               if(control->getGObjectType()==GBLACKBOX)
+               {
+                       GBlackBoxModel *bbmod = (GBlackBoxModel*)control->getModel();
+                       std::vector<GPortModel*>inputs = bbmod->getInputPorts();
+                       
+                       for(int i = 0;i<inputs.size();i++)
+                       {
+                               controllersToRemove.push_back(inputs[i]->getObjectId());
+                       }
+
+                       std::vector<GPortModel*>outputs = bbmod->getOutputPorts();
+
+                       for(int i = 0;i<outputs.size();i++)
+                       {
+                               controllersToRemove.push_back(outputs[i]->getObjectId());
+                       }
+
+                       controllersToRemove.push_back(control->getId());
+               }
+
+               for(int i = 0;i<controllersToRemove.size();i++)
+               {
+                       int id = controllersToRemove[i];
+                       GObjectController *cont = _controllers[id];
+                       cont->removeFromScene();
+                       unregisterController((InteractorStyleMaracas*)cont);
+                       _controllers.erase(id);
+               }
+
+
+       }
+
+       //=========================================================================
+
        void wxVtkSceneManager::displayBlackBoxInfo(std::string packageName, std::string boxName)
        {
                _parent->displayBlackBoxInfo(packageName,boxName);
index 3c8c061cd8f8b064c6627b1408e29e1507a42338..5079fdc643307eea8b63b620d23987292a53999d 100644 (file)
@@ -96,12 +96,14 @@ namespace bbtk
                void createGConnector(GPortModel* startPort);
 
                void registerController(InteractorStyleMaracas *param);
+               void unregisterController(InteractorStyleMaracas *param);
 
                vtkRenderWindow* getRenderWindow();
                vtkRenderer* getRenderer();
 
                void disconnectDrop();
                
+               virtual bool OnChar();
                virtual bool OnMouseMove();
                virtual bool  OnLeftButtonDown(); 
                virtual bool  OnLeftButtonUp();
@@ -112,6 +114,7 @@ namespace bbtk
                void displayBlackBoxInfo(std::string packageName, std::string boxName);
                void updateStatusBar(std::string textStatus);
                std::string getDiagramScript();
+               void removeObject(int id);
 
                
        private:
index efe5ba8e6ae4df12697f7cfa3c5ac65b1bf37210..b8d884e12b7e8b3664e32ba3780f03594ff667d9 100644 (file)
@@ -81,7 +81,7 @@ namespace bbtk
                                }
                        }
                        
-                       _model->notifyObservers(_id);
+                       _model->notifyObservers(getId());
                        
                }
                return true;
@@ -98,7 +98,7 @@ namespace bbtk
                {
                        _isLeftClickDown=true;
                        _view->setState(SELECTED);
-                       _model->notifyObservers(_id,ADD_TO_SELECTED);
+                       _model->notifyObservers(getId(),ADD_TO_SELECTED);
                }
                return true;
 
@@ -123,7 +123,7 @@ namespace bbtk
                        {
                                // It is supposed that I'm always inside even if the box is in drag
                                _view->setState(SELECTED);
-                               _model->notifyObservers(_id);
+                               _model->notifyObservers(getId());
                        }
                }
                return true;
@@ -168,7 +168,7 @@ namespace bbtk
                        GBlackBoxModel *bbmodel = (GBlackBoxModel*)_model;
                        _view->setState(HIGHLIGHTED);
                        bbmodel->setExecutable(true);
-                       bbmodel->notifyObservers(_id);
+                       bbmodel->notifyObservers(getId());
                }
                        
                return true;
index 3ba353c6b689e72607f8ded1ef13d5c424fa9826..645997b25ed8c7d07df31afb2a71a25d523e5b96 100644 (file)
@@ -86,7 +86,7 @@ namespace bbtk
                        }
                }
                
-               _model->notifyObservers(_id);
+               _model->notifyObservers(getId());
                        
 
                return true;
@@ -103,7 +103,6 @@ namespace bbtk
                {
                        _isLeftClickDown=true;
                        _view->setState(SELECTED);
-                       //_model->notifyObservers(_id,
                }
                return true;
        }
@@ -163,14 +162,14 @@ namespace bbtk
 
        int GObjectController::getId()
        {
-               return _id;
+               return _model->getObjectId();
        }
 
        //=========================================================================
        
        void GObjectController::setId(int id)
        {
-               _id = id;
+               _model->setObjectId(id);
        }
 
        //=========================================================================
@@ -182,6 +181,13 @@ namespace bbtk
 
        //=========================================================================
 
+       void GObjectController::removeFromScene()
+       {
+               _view->removeFromScene();
+       }
+
+       //=========================================================================
+
 }  // EO namespace bbtk
 
 // EOF
index ed826a413633994fb7ab3718fb41c7ded057d9a8..ccbc264993b68fd6b5be0951989fd0146f7c0307 100644 (file)
@@ -76,6 +76,8 @@ namespace bbtk
 
                int getId();
                void setId(int id);
+               
+               void removeFromScene();
 
        private:
 
@@ -90,7 +92,6 @@ namespace bbtk
                //Protected Attributes 
                GObjectModel* _model;
                vtkGObjectView* _view;
-               int _id;
                bool _isLeftClickDown;
 
                //Protected Methods
index e7d1ce7c1c218db4d8dcc18d8e7d3cae969d18d1..c15a276efc67696d6fc55d0fed343ae5f1a939a9 100644 (file)
@@ -77,11 +77,11 @@ namespace bbtk
                                //Evaluate new state
                                if(portType==GOUTPUTPORT)
                                {
-                                       _model->notifyObservers(_id,INIT_CREATION_CONTOUR);
+                                       _model->notifyObservers(getId(),INIT_CREATION_CONTOUR);
                                }
                                else if (portType==GINPUTPORT)
                                {
-                                       _model->notifyObservers(_id,FIN_CREATION_CONTOUR);
+                                       _model->notifyObservers(getId(),FIN_CREATION_CONTOUR);
                                }
                        }
                        else
index 4bbaecb809fcb2ee2d40fe9653ea3ff18d39514a..1a1bbb38a63bf5bfb9e8e05204fd165c595669a2 100644 (file)
@@ -62,12 +62,28 @@ namespace bbtk
        {
                _manContModel->MovePoint(0,start[0],start[1],start[2]);
                _manContModel->MovePoint(_manContModel->GetSizeLstPoints()-1,end[0],end[1],end[2]);
-
+               
                Refresh();
        }
 
        //=========================================================================
 
+       void manualConnectorContourView::AddControlPoints()
+       {
+               vtkRenderer * theRenderer = _wxvtkbaseview->GetRenderer();
+               SetIfViewControlPoints( true );
+                if( _viewControlPoints )
+                {
+                       int i,size=_lstViewPoints.size();
+                       for (i=1;i<size-1; i++)
+                       {
+                               vtkActor * pointActor = _lstViewPoints[i]->GetVtkActor();
+                               theRenderer->AddActor( pointActor );
+                       }
+                }
+       }
+       //=========================================================================
+
 
 }  // EO namespace bbtk
 
index 43fd4286f0c2dfdae44c70bf666f02f58e31e4ce..b0ec5e255b4307c1065bc54f8a363cb9d4b8b124 100644 (file)
@@ -68,6 +68,7 @@ namespace bbtk
                //Public methods                
                virtual void TransfromCoordViewWorld(double &X, double &Y, double &Z, int type=2);
                void updateStartAndEnd(double* start , double* end);
+               virtual void    AddControlPoints();
 
        private:
 
index 34e4f90f1b591ca1b962fdc64dda45fad81a47a0..a4f6965e6cb9485084bac36b4361c6fb548767a7 100644 (file)
@@ -174,6 +174,15 @@ namespace bbtk
 
        //=========================================================================
 
+       void vtkGBlackBoxView::removeVtkActors()//virtual
+       {
+               _baseView->GetRenderer()->RemoveActor(_nameActor);
+               _baseView->GetRenderer()->RemoveActor(_typeActor);
+               vtkGObjectView::removeVtkActors();
+       }
+
+       //=========================================================================
+
        void vtkGBlackBoxView::updatePositionTextActors(double xInic, double yInic, double zInic)
        {
                _nameActor->SetPosition(xInic+4,yInic-5,zInic);
index 67b2a26fc1bbf34e3215f26260fab4e4e332ca90..466fb002cbbfd1c837ab9ed47d26f6539dd36b0d 100644 (file)
@@ -97,6 +97,7 @@ namespace bbtk
                
                //Protected Methods
                virtual void addVtkActors();
+               virtual void removeVtkActors();
                virtual void createVtkObjects();
                virtual void update(int idController,int command);
                virtual void updateColors();
index 7ed876b3b8640cc05d1cb3ff78a09e5c817e6356..964c38825ef73075dfd98672338904c0c4a778e2 100644 (file)
@@ -109,6 +109,15 @@ namespace bbtk
 
        //=========================================================================
 
+       void vtkGObjectView::removeVtkActors()//virtual
+       {
+               _baseView->GetRenderer()->RemoveActor(_borderObjectActor);
+               _baseView->GetRenderer()->RemoveActor(_fillObjectActor);
+               _baseView->GetRenderer()->Render();
+       }
+
+       //=========================================================================
+
        bool vtkGObjectView::isPointInside(int X,int Y) //virtual
        {
                // RaC In the actual version, always z=900
@@ -169,6 +178,14 @@ namespace bbtk
        }
 
        //=========================================================================
+       
+       void vtkGObjectView::removeFromScene()
+       {
+               removeVtkActors();
+               setRefreshWaiting();
+       }
+
+       //=========================================================================
 
 
 }  // EO namespace bbtk
index 691d2ef3290690c5887ebc58badc5272d261222d..5c42d0e7e791a7c9491538f2fbb7a1c3829a0b3b 100644 (file)
@@ -90,6 +90,8 @@ namespace bbtk
                int getState();
                void setRefreshWaiting();
 
+               virtual void removeFromScene();
+
        private:
 
                //Private Attributes
@@ -115,6 +117,7 @@ namespace bbtk
                //Protected Methods
                virtual void createVtkObjects();
                virtual void addVtkActors();
+               virtual void removeVtkActors();
                virtual void updateColors();
        };