X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FEditorGraphicBBS%2FbbsVtkGUIEditorGraphic%2FGBlackBoxController.cxx;h=93e06fa2fe1eec7e4595764be469d77281f2db6f;hb=6bb706f241008994b08baa2e44fe414f2277c5ab;hp=cf4037ed249cf742a07c863e7117953f1cb5d9ae;hpb=5df5effdcd9f09c81c68fd63b1f0359593a823bd;p=bbtkGEditor.git diff --git a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx index cf4037e..93e06fa 100644 --- a/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx +++ b/lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx @@ -62,33 +62,27 @@ namespace bbtk _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); _wxVTKiren->GetEventPosition( X , Y ); - int state = _model->getState(); + int state = _view->getState(); //Evaluate new state - if(!_model->hasChanged() && state == DRAG) - { - moveObject(X,Y); - _model->setChanged(); - } - - if(!_model->hasChanged() && state == NOTHING_HAPPENS) + + if(state == NOTHING_HAPPENS) { if(_view->isPointInside(X,Y)) { - _model->setState(HIGHLIGHTED); - _model->setChanged(); + _view->setState(HIGHLIGHTED); } } - if(!_model->hasChanged() && state==HIGHLIGHTED) + if( state==HIGHLIGHTED) { if(!_view->isPointInside(X,Y)) { - _model->setState(NOTHING_HAPPENS); - _model->setChanged(); + _view->setState(NOTHING_HAPPENS); } } - _model->notifyObservers(); + _model->notifyObservers(getId()); + } return true; } @@ -97,111 +91,81 @@ namespace bbtk bool GBlackBoxController::OnLeftButtonDown() { - - if ( _vtkInteractorStyleBaseView!=NULL ) - { - int X,Y; - wxVTKRenderWindowInteractor *wxVTKiren; - wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); - wxVTKiren->GetEventPosition(X,Y); - - int state = _model->getState(); - - //Evaluate new state - if(!_model->hasChanged() && state==HIGHLIGHTED) - { - _view->isStartDragging(true); - _model->setState(DRAG); - _model->setChanged(); - } - - if( !_model->hasChanged() && state == SELECTED) - { - if(_view->isPointInside(X,Y)) - { - _view->isStartDragging(true); - _model->setState(DRAG); - _model->setChanged(); - } - } + int state = _view->getState(); - _model->notifyObservers(); + //Evaluate new state + if(state == HIGHLIGHTED) + { + _isLeftClickDown=true; + _view->setState(SELECTED); + _model->notifyObservers(getId(),ADD_TO_SELECTED); } return true; + } //========================================================================= bool GBlackBoxController::OnLeftButtonUp() { - if ( _vtkInteractorStyleBaseView!=NULL ) - { - int X,Y; - wxVTKRenderWindowInteractor *wxVTKiren; - wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); - wxVTKiren->GetEventPosition(X,Y); + int X,Y; + wxVTKRenderWindowInteractor *wxVTKiren; + wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); + wxVTKiren->GetEventPosition(X,Y); - int state = _model->getState(); + int state = _view->getState(); - //Evaluate new state - if(!_model->hasChanged() && state==CLICKED) - { - _model->setState(SELECTED); - _model->setChanged(); - } - - if( !_model->hasChanged() && state == DRAG) + //Evaluate new state + if(_isLeftClickDown) + { + _isLeftClickDown=false; + if(_view->isPointInside(X,Y)) { - _model->setState(SELECTED); - _model->setChanged(); + // It is supposed that I'm always inside even if the box is in drag + _view->setState(SELECTED); + _model->notifyObservers(getId()); } - - _model->notifyObservers(); - } return true; + } //========================================================================= - - bool GBlackBoxController::OnLeftDClick() - { - if ( _vtkInteractorStyleBaseView!=NULL ) - { - int X,Y; - wxVTKRenderWindowInteractor *wxVTKiren; - wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); - wxVTKiren->GetEventPosition(X,Y); - _model->notifyObservers(); - } + bool GBlackBoxController::OnRightButtonUp() + { return true; } - + //========================================================================= - - bool GBlackBoxController::OnRightButtonDown() + + bool GBlackBoxController::OnMiddleButtonDown() { - if( _vtkInteractorStyleBaseView!= NULL ) + 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)) { - int X,Y; - wxVTKRenderWindowInteractor *wxVTKiren; - wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor(); - wxVTKiren->GetEventPosition(X, Y); - - int state = _model->getState(); - - //Evaluate new state - if( !_model->hasChanged() && state == SELECTED) + GBlackBoxModel *bbmodel = (GBlackBoxModel*)_model; + _view->setState(HIGHLIGHTED); + if(bbmodel->isExecutable()) { - _model->setState(NOTHING_HAPPENS); - _model->setChanged(); + bbmodel->setExecutable(false); } - - _model->notifyObservers(); + else + { + bbmodel->setExecutable(true); + } + bbmodel->notifyObservers(getId()); } + return true; -} + } //=========================================================================