]> 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 8fc721c2b78c87082e5ac8b529349562a2e58a4e..b053cbac0f419623328def98691cb4ff3bb0d86e 100644 (file)
@@ -61,7 +61,7 @@ namespace bbtk
 
 bool GObjectController::OnMouseMove()
 {
-       cout<<"RaC GObjectController::OnMouseMove "<<endl;
+       
        if ( _vtkInteractorStyleBaseView!=NULL)
        {
                int X,Y;
@@ -72,33 +72,30 @@ bool GObjectController::OnMouseMove()
                int state  = _model->getState();
                
                //Evaluate new state
-               if(state == CLICKED)
-               {
-                       _model->setState(DRAG);
-                       //MoveObject(X,Y);
-                       
-               }
-               if(state == DRAG)
+               if(!_model->hasChanged() && state == DRAG)
                {
                        //MoveObject(X,Y);
                        
                }
-               if(state == NOTHING_HAPPENS)
+
+               if(!_model->hasChanged() && state == NOTHING_HAPPENS)
                {
                        if(_view->isPointInside(X,Y))
                        {
-                               _model->setState(HIGHLIGHTED);                  
+                               _model->setState(HIGHLIGHTED);
+                               _model->setChanged();                           
                        }                       
                }
-               if(state==HIGHLIGHTED)
+               if(!_model->hasChanged() && state==HIGHLIGHTED)
                {
                        if(!_view->isPointInside(X,Y))
                        {
-                               _model->setState(NOTHING_HAPPENS);                      
+                               _model->setState(NOTHING_HAPPENS);
+                               _model->setChanged();
                        }
                }
                
-               _view->update();
+               _model->notifyObservers();
        }
        return true;
 }
@@ -113,7 +110,25 @@ bool GObjectController::OnLeftButtonDown()
                wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
                wxVTKiren->GetEventPosition(X,Y);
 
-               //MouseClickLeft(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;
 }
@@ -124,9 +139,26 @@ bool GObjectController::OnLeftButtonUp()
        {
                int X,Y;
                wxVTKRenderWindowInteractor *wxVTKiren;
-               wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
+               wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
                wxVTKiren->GetEventPosition(X,Y);
-               //MouseReleaseLeft(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;
 }
@@ -137,54 +169,38 @@ bool GObjectController::OnLeftDClick()
        {
                int X,Y;
                wxVTKRenderWindowInteractor *wxVTKiren;
-               wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
+               wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
                wxVTKiren->GetEventPosition(X,Y);
 
-               //this->MouseDLeft(X,Y);
+               _model->notifyObservers();
        }
        return true;
 }
 //=========================================================================
-bool GObjectController::OnMiddleButtonDown()
-{
-       if ( _vtkInteractorStyleBaseView!=NULL )
-       {
-               int X,Y;
-               wxVTKRenderWindowInteractor *wxVTKiren;
-               wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
-               wxVTKiren->GetEventPosition(X,Y);
-               //GetManualViewBaseContour()->InitMove( X, Y,GetZ());
-       }
-       return true;
-}
-//=========================================================================
-bool GObjectController::OnMiddleButtonUp()
-{
-       return true;
-}
-//=========================================================================
 bool GObjectController::OnRightButtonDown()
 {
        if( _vtkInteractorStyleBaseView!= NULL )
        {
                int X,Y;
                wxVTKRenderWindowInteractor *wxVTKiren;
-               wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
+               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();                   
+               }
 
-               //SetCompleteCreation( true );
-               //SetKeyBoardMoving( false );
-               //this->GetManualContourModel()->SetCloseContour(true);
-               //MouseClickRight(X,Y);
+               _model->notifyObservers();
        }
        return true;
 }
 //=========================================================================
-bool GObjectController::OnRightButtonUp()
-{
-       return true;
-}
-//=========================================================================
+
 
 }  // EO namespace bbtk