X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FEditorGraphicBBS%2FbbsVtkGUIEditorGraphic%2FGBlackBoxController.cxx;h=b8d884e12b7e8b3664e32ba3780f03594ff667d9;hb=a6d479881eeb637cd06afa3b2177e430fa05571e;hp=7cdf253320c15db89d9aa4bf4d1a2149e2091aad;hpb=64fc9f949ff91d6e9d448ca0567e6205ee4d5be4;p=bbtkGEditor.git diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx index 7cdf253..b8d884e 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx @@ -52,6 +52,127 @@ namespace bbtk } //========================================================================= + bool GBlackBoxController::OnMouseMove() + { + + if ( _vtkInteractorStyleBaseView!=NULL) + { + int X,Y; + wxVTKRenderWindowInteractor *_wxVTKiren; + _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); + _wxVTKiren->GetEventPosition( X , Y ); + + int state = _view->getState(); + + //Evaluate new state + + if(state == NOTHING_HAPPENS) + { + if(_view->isPointInside(X,Y)) + { + _view->setState(HIGHLIGHTED); + } + } + if( state==HIGHLIGHTED) + { + if(!_view->isPointInside(X,Y)) + { + _view->setState(NOTHING_HAPPENS); + } + } + + _model->notifyObservers(getId()); + + } + return true; + } + + //========================================================================= + + bool GBlackBoxController::OnLeftButtonDown() + { + int state = _view->getState(); + + //Evaluate new state + if(state == HIGHLIGHTED) + { + _isLeftClickDown=true; + _view->setState(SELECTED); + _model->notifyObservers(getId(),ADD_TO_SELECTED); + } + return true; + + } + + //========================================================================= + + bool GBlackBoxController::OnLeftButtonUp() + { + int X,Y; + wxVTKRenderWindowInteractor *wxVTKiren; + wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); + wxVTKiren->GetEventPosition(X,Y); + + int state = _view->getState(); + + //Evaluate new state + if(_isLeftClickDown) + { + _isLeftClickDown=false; + if(_view->isPointInside(X,Y)) + { + // It is supposed that I'm always inside even if the box is in drag + _view->setState(SELECTED); + _model->notifyObservers(getId()); + } + } + return true; + + } + + //========================================================================= + + bool GBlackBoxController::OnLeftDClick() + { + + return true; + } + + //========================================================================= + + bool GBlackBoxController::OnRightButtonUp() + { + GBlackBoxModel *bbmodel = (GBlackBoxModel*)_model; + if(bbmodel->isExecutable()) + { + bbmodel->setExecutable(false); + } + + return true; + } + + //========================================================================= + + bool GBlackBoxController::OnMiddleButtonDown() + { + int X,Y; + wxVTKRenderWindowInteractor *wxVTKiren; + wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); + wxVTKiren->GetEventPosition(X,Y); + + int state = _view->getState(); + + //Evaluate new state + if(_view->isPointInside(X,Y)) + { + GBlackBoxModel *bbmodel = (GBlackBoxModel*)_model; + _view->setState(HIGHLIGHTED); + bbmodel->setExecutable(true); + bbmodel->notifyObservers(getId()); + } + + return true; + } //=========================================================================