From: corredor <> Date: Tue, 27 Apr 2010 11:25:06 +0000 (+0000) Subject: Implemented deleting of boxes from the scene.... X-Git-Tag: v1_0_0~97 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=a6d479881eeb637cd06afa3b2177e430fa05571e;p=bbtkGEditor.git Implemented deleting of boxes from the scene.... --- diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx index deeb490..cffd4b8 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.cxx @@ -150,6 +150,21 @@ namespace bbtk //========================================================================= + std::vector GBlackBoxModel::getInputPorts() + { + return _inputs; + } + + //========================================================================= + + std::vector GBlackBoxModel::getOutputPorts() + { + return _outputs; + } + + //========================================================================= + + } // EO namespace bbtk diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.h b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.h index 82214a4..000950c 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.h +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GBlackBoxModel.h @@ -85,6 +85,9 @@ namespace bbtk bool isExecutable(); void setExecutable(bool executable); + std::vector getInputPorts(); + std::vector getOutputPorts(); + private: //Private Attributes diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.cxx index 46e77d4..e4710a2 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.cxx @@ -176,6 +176,18 @@ namespace bbtk //========================================================================= + int GObjectModel::getObjectId() + { + return _objectId; + } + + //========================================================================= + + void GObjectModel::setObjectId(int id) + { + _objectId=id; + } + } // EO namespace bbtk diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.h b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.h index d1d3ce2..a630038 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.h +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/GObjectModel.h @@ -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; diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx index 0420aa3..c4efe56 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx @@ -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 controllersToRemove; + + if(control->getGObjectType()==GBLACKBOX) + { + GBlackBoxModel *bbmod = (GBlackBoxModel*)control->getModel(); + std::vectorinputs = bbmod->getInputPorts(); + + for(int i = 0;igetObjectId()); + } + + std::vectoroutputs = bbmod->getOutputPorts(); + + for(int i = 0;igetObjectId()); + } + + controllersToRemove.push_back(control->getId()); + } + + for(int i = 0;iremoveFromScene(); + unregisterController((InteractorStyleMaracas*)cont); + _controllers.erase(id); + } + + + } + + //========================================================================= + void wxVtkSceneManager::displayBlackBoxInfo(std::string packageName, std::string boxName) { _parent->displayBlackBoxInfo(packageName,boxName); diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h index 3c8c061..5079fdc 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.h @@ -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: diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx index efe5ba8..b8d884e 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx @@ -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; diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.cxx index 3ba353c..645997b 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.cxx @@ -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 diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.h index ed826a4..ccbc264 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.h +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.h @@ -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 diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GPortController.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GPortController.cxx index e7d1ce7..c15a276 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GPortController.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GPortController.cxx @@ -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 diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/manualConnectorContourView.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/manualConnectorContourView.cxx index 4bbaecb..1a1bbb3 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/manualConnectorContourView.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/manualConnectorContourView.cxx @@ -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;iGetVtkActor(); + theRenderer->AddActor( pointActor ); + } + } + } + //========================================================================= + } // EO namespace bbtk diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/manualConnectorContourView.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/manualConnectorContourView.h index 43fd428..b0ec5e2 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/manualConnectorContourView.h +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/manualConnectorContourView.h @@ -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: diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx index 34e4f90..a4f6965 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.cxx @@ -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); diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.h index 67b2a26..466fb00 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.h +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGBlackBoxView.h @@ -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(); diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx index 7ed876b..964c388 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.cxx @@ -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 diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.h b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.h index 691d2ef..5c42d0e 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.h +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/vtkGObjectView.h @@ -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(); };