]> Creatis software - bbtkGEditor.git/blobdiff - lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx
Necessary changes to manage the basic action . First prototype totally completed...
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsVtkGUIEditorGraphic / GBlackBoxController.cxx
index 7cdf253320c15db89d9aa4bf4d1a2149e2091aad..cf4037ed249cf742a07c863e7117953f1cb5d9ae 100644 (file)
@@ -52,6 +52,156 @@ namespace bbtk
        }
        //=========================================================================
 
+       bool GBlackBoxController::OnMouseMove()
+       {
+               
+               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 == DRAG)
+                       {
+                               moveObject(X,Y);
+                               _model->setChanged();
+                       }
+
+                       if(!_model->hasChanged() && state == NOTHING_HAPPENS)
+                       {
+                               if(_view->isPointInside(X,Y))
+                               {
+                                       _model->setState(HIGHLIGHTED);
+                                       _model->setChanged();                           
+                               }                       
+                       }
+                       if(!_model->hasChanged() && state==HIGHLIGHTED)
+                       {
+                               if(!_view->isPointInside(X,Y))
+                               {
+                                       _model->setState(NOTHING_HAPPENS);
+                                       _model->setChanged();
+                               }
+                       }
+                       
+                       _model->notifyObservers();
+               }
+               return true;
+       }
+
+       //=========================================================================
+       
+       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();
+                               }       
+                       }
+                       
+                       _model->notifyObservers();
+               }
+               return true;
+       }
+
+       //=========================================================================
+       
+       bool GBlackBoxController::OnLeftButtonUp()
+       {
+               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==CLICKED)
+                       {
+                               _model->setState(SELECTED);
+                               _model->setChanged();
+                       }
+
+                       if( !_model->hasChanged() && state == DRAG)
+                       {
+                               _model->setState(SELECTED);
+                               _model->setChanged();
+                       }
+
+                       _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();
+               }
+               return true;
+       }
+       
+       //=========================================================================
+       
+       bool GBlackBoxController::OnRightButtonDown()
+       {
+               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 == SELECTED)
+                       {
+                               _model->setState(NOTHING_HAPPENS);
+                               _model->setChanged();                   
+                       }
+
+                       _model->notifyObservers();
+               }
+               return true;
+}
 
        //=========================================================================