]> Creatis software - bbtkGEditor.git/blobdiff - lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.cxx
First prototype works. Basic boxes construction, evenct handling and colors represent...
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsVtkGUIEditorGraphic / GObjectController.cxx
index f00541cc38624a249b5b7d4008233d6f849dc905..b053cbac0f419623328def98691cb4ff3bb0d86e 100644 (file)
@@ -59,6 +59,149 @@ namespace bbtk
        }
        //=========================================================================
 
+bool GObjectController::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);
+                       
+               }
+
+               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 GObjectController::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)
+               {
+                       _model->setState(DRAG);
+                       _model->setChanged();
+               }
+
+               if( !_model->hasChanged() && state == SELECTED)
+               {
+                       if(_view->isPointInside(X,Y))
+                       {
+                               _model->setState(DRAG);
+                               _model->setChanged();
+                       }       
+               }
+               
+               _model->notifyObservers();
+       }
+       return true;
+}
+//=========================================================================
+bool GObjectController::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 GObjectController::OnLeftDClick()
+{
+       if ( _vtkInteractorStyleBaseView!=NULL )
+       {
+               int X,Y;
+               wxVTKRenderWindowInteractor *wxVTKiren;
+               wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
+               wxVTKiren->GetEventPosition(X,Y);
+
+               _model->notifyObservers();
+       }
+       return true;
+}
+//=========================================================================
+bool GObjectController::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;
+}
+//=========================================================================
+
+
 }  // EO namespace bbtk
 
 // EOF