X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FEditorGraphicBBS%2FbbsKernelEditorGraphic%2FwxVtkSceneManager.cxx;fp=lib%2FEditorGraphicBBS%2FbbsKernelEditorGraphic%2FwxVtkSceneManager.cxx;h=cab3936f7976ff5f98d0e03977c28e1a31aa6af1;hb=638f2cd85948ec10d3b30e1f68805ee0153c8813;hp=77da812bdd22ef2b73ce6aadc0f0b39db3733761;hpb=1b304ebdcfbe1c3bcd0a060ee3d193d81a8047f0;p=bbtkGEditor.git diff --git a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx index 77da812..cab3936 100644 --- a/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsKernelEditorGraphic/wxVtkSceneManager.cxx @@ -47,7 +47,6 @@ namespace bbtk _numBoxes=0; _idManager=idManager; _baseView=baseView; - _idLastController=0; _startDragging=false; if( _baseView!=NULL ) @@ -515,6 +514,42 @@ namespace bbtk bool wxVtkSceneManager::OnLeftButtonDown() { + if(_worldState==INIT_CREATION_CONTOUR) + { + bool isOverPort=false; + std::map::iterator it; + for(it = _controllers.begin(); it != _controllers.end() && isOverPort==false; ++it) + { + GObjectController *desc = it->second; + if(desc->getGObjectType()==GPORT) + { + GPortModel* portmod=(GPortModel*)desc->getModel(); + vtkGObjectView* portView=desc->getView(); + if(portmod->getPortType()==GINPUTPORT && portView->getState()==HIGHLIGHTED) + { + isOverPort=true; + } + } + } + + if(isOverPort==false) + { + _worldState=NOTHING_HAPPENS; + int lastId = _controllers.size()-1; + GConnectorController *connector = (GConnectorController*)_controllers[lastId]; + connector->removeFromScene(); + unregisterController(connector); + _controllers.erase(lastId); + + for(it = _controllers.begin(); it != _controllers.end(); ++it) + { + GObjectController *desc = it->second; + desc->SetActive(true); + desc->getView()->setState(NOTHING_HAPPENS); + desc->getModel()->notifyObservers(_idManager); + } + } + } if(_selectedObjects.size()!=0) { @@ -558,6 +593,26 @@ namespace bbtk bool wxVtkSceneManager::OnRightButtonUp() { + if(_worldState==INIT_CREATION_CONTOUR) + { + _worldState=NOTHING_HAPPENS; + int lastId = _controllers.size()-1; + GConnectorController *connector = (GConnectorController*)_controllers[lastId]; + connector->removeFromScene(); + unregisterController(connector); + _controllers.erase(lastId); + + std::map::iterator it; + for(it = _controllers.begin(); it != _controllers.end(); ++it) + { + GObjectController *desc = it->second; + desc->SetActive(true); + desc->getView()->setState(NOTHING_HAPPENS); + desc->getModel()->notifyObservers(_idManager); + } + } + + for (int i = 0; i < _selectedObjects.size(); i++) { int id = _selectedObjects[i]; @@ -590,9 +645,9 @@ namespace bbtk GObjectController *cont = it->second; int type = cont->getGObjectType(); - if(cont->getView()->isPointInside(X,Y)) + if(type==GBLACKBOX) { - if(type==GBLACKBOX) + if(cont->getView()->isPointInside(X,Y)) { for (int i=0; i<_selectedObjects.size(); i++) { @@ -653,18 +708,51 @@ namespace bbtk GBlackBoxModel *bbmod = (GBlackBoxModel*)control->getModel(); std::vector inputs = bbmod->getInputPorts(); + bool boxConnected = false; + + // Add box input controllers to be removed for(int i = 0;igetObjectId()); + controllersToRemove.push_back(inputs[i]->getObjectId()); + if(inputs[i]->isConnected()) + { + boxConnected = true; + } } std::vector outputs = bbmod->getOutputPorts(); + // Add box output controllers to be removed for(int i = 0;igetObjectId()); + if(outputs[i]->isConnected()) + { + boxConnected = true; + } + } + + // Add connection controllers to be removed + std::map::iterator it; + for(it = _controllers.begin(); it != _controllers.end(); ++it) + { + GObjectController *cont = it->second; + int type = cont->getGObjectType(); + if(type==GCONNECTOR) + { + GConnectorModel *conMod = (GConnectorModel*)cont->getModel(); + if(conMod->getStartPort()!=NULL && conMod->getStartPort()->getParentBox()->getObjectId() == bbmod->getObjectId()) + { + controllersToRemove.push_back(conMod->getObjectId()); + } + if(conMod->getEndPort()!=NULL && conMod->getEndPort()->getParentBox()->getObjectId() == bbmod->getObjectId()) + { + controllersToRemove.push_back(conMod->getObjectId()); + } + } } + // Add box controller to be removed controllersToRemove.push_back(bbmod->getObjectId()); }