]> Creatis software - bbtkGEditor.git/commitdiff
Just the last repairs and it works the problem of delete objects. Works with the...
authorcorredor <>
Wed, 23 Jun 2010 17:49:28 +0000 (17:49 +0000)
committercorredor <>
Wed, 23 Jun 2010 17:49:28 +0000 (17:49 +0000)
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx
lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.h

index dae6833dea58c02ae75a5e1959ac2fef70f076f2..dc1ad5a483bb4dc8c2fe8b3fb565e58dae90e615 100644 (file)
@@ -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<int, GObjectController*>::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<int, GObjectController*>::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<int, GObjectController*>::iterator it;
                        for(it = _controllers.begin(); it != _controllers.end(); ++it)
@@ -870,10 +877,13 @@ namespace bbtk
                for(int i = 0;i<controllersToRemove.size();i++)
                {
                        int id = controllersToRemove[i];
-                       GObjectController *cont = _controllers[id];                     
-                       cont->removeFromScene();
-                       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;
        }
 
index 47b4e113ef5349a637dfd63e41f7c6009d520ecd..14e1a1dc00663e52b70fe6aa0d5c75af6468053b 100644 (file)
@@ -202,6 +202,10 @@ namespace bbtk
                //Is the diagram in state complex box 
                bool _isComplexBox;
 
+               int _idConnectionInCreation;
+
+               int _contLastId;
+
        protected:
 
        };