registerController(this);
}
+ _idConnectionInCreation=-1;
+ _contLastId=0;
}
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];
// 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();
_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];
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);
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)
{
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)
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);
+ }
}
{
_isComplexBox=val;
}
-
+
//=========================================================================
int wxVtkSceneManager::addObjectController(GObjectController* objController)
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;
}