From 92a55a7bc8ace3f27e6ebdaf56fb47938c97cced Mon Sep 17 00:00:00 2001 From: davila <> Date: Thu, 12 Jul 2012 13:53:51 +0000 Subject: [PATCH] BUG 1504 Erase wrong connections Simple selection of a box not possible --- .../GBlackBoxController.cxx | 18 ++-- .../bbsVtkGUIEditorGraphic/GBoxController.cxx | 4 +- .../GConnectorController.cxx | 7 ++ .../wxVtkSceneManager.cxx | 82 +++++++++++-------- 4 files changed, 69 insertions(+), 42 deletions(-) diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx index 8c73675..99c7d07 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx @@ -120,13 +120,18 @@ namespace bbtk // if(state == HIGHLIGHTED) //EED3oct2010 if ( (state == HIGHLIGHTED) && (ctrlkey==1 ) ) + + if(state == SELECTED) { + _view->setState(NOTHING_HAPPENS); + _model->notifyObservers(getId(),REMOVE_FROM_SELECTED); + } else { ok=false; _view->setState(SELECTED); _model->notifyObservers(getId(),ADD_TO_SELECTED); } - + int shiftkey = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey(); int ctrlkey = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey(); ctrlkey = ctrlkey + shiftkey; @@ -173,11 +178,12 @@ namespace bbtk ctrlkey = ctrlkey + shiftkey; - if ( (state==SELECTED) && (ctrlkey==0) && (_objHasBeenMoved==false)) - { - _view->setState(NOTHING_HAPPENS); - _model->notifyObservers(getId(),REMOVE_FROM_SELECTED); - } +//EED 12/07/2012 +// if ( (state==SELECTED) && (ctrlkey==0) && (_objHasBeenMoved==false)) +// { +// _view->setState(NOTHING_HAPPENS); +// _model->notifyObservers(getId(),REMOVE_FROM_SELECTED); +// } diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBoxController.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBoxController.cxx index b0175e6..da33363 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBoxController.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBoxController.cxx @@ -95,7 +95,6 @@ namespace bbtk bool GBoxController::OnLeftButtonDown() { bool ok=true; -printf("EED GBoxController::OnLeftButtonDown \n"); int state = _view->getState(); //Evaluate new state @@ -104,7 +103,8 @@ printf("EED GBoxController::OnLeftButtonDown \n"); ok=false; _isLeftClickDown=true; _view->setState(SELECTED); - _model->notifyObservers(getId(),ADD_TO_SELECTED); +// _model->notifyObservers(getId(),ADD_TO_SELECTED); + _model->notifyObservers(getId()); } return ok; diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.cxx index 924bd62..1d07ba8 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.cxx @@ -60,6 +60,13 @@ namespace bbtk bool GConnectorController::OnMouseMove() { + printf("EED GConnectorController::OnMouseMove state%d\n", _view->getState() ); + + if (_view->getState() ==SELECTED) + { + _controller->GetManualViewBaseContour()->SetSelected(true); + } + if ( _vtkInteractorStyleBaseView!=NULL) { int X,Y; diff --git a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx index 6c8acf0..de910b7 100644 --- a/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx +++ b/lib/EditorGraphicBBS/bbsWxGUIEditorGraphic/wxVtkSceneManager.cxx @@ -755,7 +755,8 @@ void wxVtkSceneManager::update(int idController, int command) { //========================================================================= -bool wxVtkSceneManager::OnMouseMove() { +bool wxVtkSceneManager::OnMouseMove() +{ int X, Y; bool okStatusMessage = false; bool okPortMessage = false; @@ -797,16 +798,18 @@ bool wxVtkSceneManager::OnMouseMove() { desc->getModel()->getCenter(px, py, pz); // JGRR & CM - if ((state == HIGHLIGHTED) || (state == SELECTED_POSSIBLE_CONNECTION )) { + if ((state == HIGHLIGHTED) || (state == SELECTED_POSSIBLE_CONNECTION )) + { // EO JGRR & CM okStatusMessage = true; updateStatusBar(desc->getStatusText()); - if (type == GBLACKBOX) { + if (type == GBLACKBOX) + { GBlackBoxModel *mod = (GBlackBoxModel*) desc->getModel(); - _parent->displayBlackBoxInfo(mod->getBBTKPackage(), - mod->getBBTKType()); + _parent->displayBlackBoxInfo(mod->getBBTKPackage(),mod->getBBTKType()); } // if GBLACKBOX - if (type == GPORT) { + if (type == GPORT) + { // PortText okPortMessage = true; py = py + 5; @@ -826,11 +829,13 @@ bool wxVtkSceneManager::OnMouseMove() { } // for controllers it } } - if (okStatusMessage == false) { + if (okStatusMessage == false) + { updateStatusBar(""); } - if (okPortMessage == false) { + if (okPortMessage == false) + { _textActor->SetScale(0.0001); _fillObjectActor->SetScale(0.0001); } @@ -839,32 +844,35 @@ bool wxVtkSceneManager::OnMouseMove() { //========================================================================= -bool wxVtkSceneManager::OnLeftButtonDown() { - - if (_worldState == INIT_CREATION_CONTOUR) { +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) { + for (it = _controllers.begin(); it != _controllers.end() && isOverPort== false; ++it) + { GObjectController *desc = it->second; - if (desc->getGObjectType() == GPORT) { + if (desc->getGObjectType() == GPORT) + { GPortModel *portmod = (GPortModel*) desc->getModel(); vtkGObjectView *portView = desc->getView(); - if (portmod->getPortType() == GINPUTPORT - && portView->getState() == HIGHLIGHTED) { + if (portmod->getPortType() == GINPUTPORT && portView->getState() == HIGHLIGHTED) + { isOverPort = true; - } // if - // JGRR & CM - if ( portmod->getPortType( ) == GINPUTPORT && portView->getState( ) == SELECTED_POSSIBLE_CONNECTION ) { - isOverPort = true ; - portView->setState( HIGHLIGHTED); - } - // EO JGRR & CM - - } // if + } // if + // JGRR & CM + if ( portmod->getPortType( ) == GINPUTPORT && portView->getState( ) == SELECTED_POSSIBLE_CONNECTION ) { + isOverPort = true ; + portView->setState( HIGHLIGHTED); + } + // EO JGRR & CM + + } // if } // for - if (isOverPort == false) { + if (isOverPort == false) + { CancelConnection(); UnSelectBlackBoxes(); } // isOverPort @@ -881,19 +889,20 @@ bool wxVtkSceneManager::OnLeftButtonDown() { GObjectController *cont = GetGBlackBoxControlerPointedByMouse(); - if (GetGBlackBoxControlerPointedByMouse() != NULL) { + if (cont != NULL) { int state = cont->getView()->getState(); if ((ctrlkey == 0) && (state == HIGHLIGHTED)) { UnSelectBlackBoxes(); } + } else { + UnSelectBlackBoxes(); // EED 12/07/2012 } for (int i = 0; i < (int) _selectedObjects.size(); i++) { int id = _selectedObjects[i]; - GObjectController* cont = _controllers[id]; + GObjectController *cont = _controllers[id]; cont->getView()->setState(DRAG); cont->getModel()->notifyObservers(_idManager); } // for - } // if _selectedObjects.size @@ -902,7 +911,8 @@ bool wxVtkSceneManager::OnLeftButtonDown() { //========================================================================= -bool wxVtkSceneManager::OnLeftButtonUp() { +bool wxVtkSceneManager::OnLeftButtonUp() +{ if (_worldState == DRAG_OBJECTS) { _worldState = NOTHING_HAPPENS; @@ -917,8 +927,10 @@ bool wxVtkSceneManager::OnLeftButtonUp() { } //========================================================================= -void wxVtkSceneManager::CancelConnection() { - if (_worldState == INIT_CREATION_CONTOUR) { +void wxVtkSceneManager::CancelConnection() +{ + if (_worldState == INIT_CREATION_CONTOUR) + { _worldState = NOTHING_HAPPENS; //int lastId = _controllers.size()-1; @@ -929,7 +941,8 @@ void wxVtkSceneManager::CancelConnection() { _controllers.erase(_idConnectionInCreation); std::map::iterator it; - for (it = _controllers.begin(); it != _controllers.end(); ++it) { + for (it = _controllers.begin(); it != _controllers.end(); ++it) + { GObjectController *desc = it->second; desc->SetActive(true); desc->getView()->setState(NOTHING_HAPPENS); @@ -1092,7 +1105,8 @@ bool wxVtkSceneManager::OnChar() #endif if(_selectedObjects.size()){ std::cout<<"objects to copy :"; - for(int i=0;i<_selectedObjects.size();i++){ + for(int i=0;i<_selectedObjects.size();i++) + { std::cout<<_selectedObjects.at(i)<<" "; } DuplicateObjects(getSelectedObjects()); -- 2.45.0