From 7b751cdb5f4ee2fd8c86a4f257f30f401de0f78c Mon Sep 17 00:00:00 2001 From: corredor <> Date: Wed, 23 Jun 2010 17:49:28 +0000 Subject: [PATCH] Just the last repairs and it works the problem of delete objects. Works with the latest version of creaMaracasVisu --- .../wxVtkSceneManager.cxx | 49 ++++++++++++------- .../bbsWxGUIEditorGraphic/wxVtkSceneManager.h | 4 ++ 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx index dae6833..dc1ad5a 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx @@ -61,6 +61,8 @@ namespace bbtk registerController(this); } + _idConnectionInCreation=-1; + _contLastId=0; } @@ -107,6 +109,7 @@ namespace bbtk int wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName, std::string boxType) { + _worldState = NOTHING_HAPPENS; int windowWidth=_baseView->GetRenWin()->GetSize()[0]; int windowHeight=_baseView->GetRenWin()->GetSize()[1]; @@ -488,9 +491,11 @@ namespace bbtk // The last one is the controller of the connector - for(int i=0;i<_controllers.size();i++) + std::map::iterator it2; + + for(it2 = _controllers.begin(); it2 != _controllers.end(); ++it2) { - GObjectController* cont = _controllers[i]; + GObjectController *cont = it2->second; if(cont->getGObjectType() == GPORT ) { GPortModel* port = (GPortModel*)cont->getModel(); @@ -515,14 +520,14 @@ namespace bbtk _selectedObjects.clear(); - createGConnector(startOutputPort); + _idConnectionInCreation=createGConnector(startOutputPort); } else if(command == FIN_CREATION_CONTOUR && _worldState == INIT_CREATION_CONTOUR) { _worldState = NOTHING_HAPPENS; - int id = _controllers.size()-1; - GObjectController* cont = _controllers[id]; + //int id = _controllers.size()-1; + GObjectController* cont = _controllers[_idConnectionInCreation]; GConnectorModel* modelContour = (GConnectorModel*)cont->getModel(); GObjectController* finPort = _controllers[idController]; @@ -536,9 +541,11 @@ namespace bbtk manualConnectorContourView* connView = (manualConnectorContourView*)manCont->GetManualViewBaseContour(); connView->Refresh(); - for(int i=0;i<_controllers.size();i++) + std::map::iterator it2; + + for(it2 = _controllers.begin(); it2 != _controllers.end(); ++it2) { - GObjectController* cont = _controllers[i]; + GObjectController *cont = it2->second; if(cont->getView()!=NULL) { cont->getView()->setState(NOTHING_HAPPENS); @@ -641,11 +648,11 @@ namespace bbtk if(isOverPort==false) { _worldState=NOTHING_HAPPENS; - int lastId = _controllers.size()-1; - GConnectorController *connector = (GConnectorController*)_controllers[lastId]; + //int lastId = _controllers.size()-1; + GConnectorController *connector = (GConnectorController*)_controllers[_controllers.size()-1]; connector->removeFromScene(); unregisterController(connector); - _controllers.erase(lastId); + _controllers.erase(_controllers.size()-1); for(it = _controllers.begin(); it != _controllers.end(); ++it) { @@ -702,11 +709,11 @@ namespace bbtk if(_worldState==INIT_CREATION_CONTOUR) { _worldState=NOTHING_HAPPENS; - int lastId = _controllers.size()-1; - GConnectorController *connector = (GConnectorController*)_controllers[lastId]; + //int lastId = _controllers.size()-1; + GConnectorController *connector = (GConnectorController*)_controllers[_idConnectionInCreation]; connector->removeFromScene(); unregisterController(connector); - _controllers.erase(lastId); + _controllers.erase(_idConnectionInCreation); std::map::iterator it; for(it = _controllers.begin(); it != _controllers.end(); ++it) @@ -870,10 +877,13 @@ namespace bbtk for(int i = 0;iremoveFromScene(); - unregisterController((InteractorStyleMaracas*)cont); - _controllers.erase(id); + GObjectController *cont = _controllers[id]; + if(cont!=NULL) + { + cont->removeFromScene(); + unregisterController((InteractorStyleMaracas*)cont); + _controllers.erase(id); + } } @@ -1760,7 +1770,7 @@ namespace bbtk { _isComplexBox=val; } - + //========================================================================= int wxVtkSceneManager::addObjectController(GObjectController* objController) @@ -1769,9 +1779,10 @@ namespace bbtk registerController((InteractorStyleMaracas*) objController); //Add the object to the objects list - int newId = _controllers.size(); + int newId = _contLastId;//_controllers.size(); objController->setId(newId); _controllers[newId] = objController; + _contLastId++; return newId; } diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h index 47b4e11..14e1a1d 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h @@ -202,6 +202,10 @@ namespace bbtk //Is the diagram in state complex box bool _isComplexBox; + int _idConnectionInCreation; + + int _contLastId; + protected: }; -- 2.47.1