1 /*=========================================================================
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 * This software is governed by the CeCILL-B license under French law and
15 * abiding by the rules of distribution of free software. You can use,
16 * modify and/ or redistribute the software under the terms of the CeCILL-B
17 * license as circulated by CEA, CNRS and INRIA at the following URL
18 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19 * or in the file LICENSE.txt.
21 * As a counterpart to the access to the source code and rights to copy,
22 * modify and redistribute granted by the license, users are provided only
23 * with a limited warranty and the software's author, the holder of the
24 * economic rights, and the successive licensors have only limited
27 * The fact that you are presently reading this means that you have had
28 * knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */
33 * \brief Class bbtk::GObjectController
37 #include "GObjectController.h"
43 //=========================================================================
44 GObjectController::GObjectController()
49 //=========================================================================
50 GObjectController::~GObjectController()
53 //=========================================================================
55 void GObjectController::setModelAndView(GObjectModel* model, vtkGObjectView* view)
60 //=========================================================================
62 bool GObjectController::OnMouseMove()
65 /********************** VIRTUAL *************************/
67 if ( _vtkInteractorStyleBaseView!=NULL)
70 wxVTKRenderWindowInteractor *_wxVTKiren;
71 _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
72 _wxVTKiren->GetEventPosition( X , Y );
74 int state = _model->getState();
77 if(!_model->hasChanged() && state == DRAG)
83 if(!_model->hasChanged() && state == NOTHING_HAPPENS)
85 if(_view->isPointInside(X,Y))
87 _model->setState(HIGHLIGHTED);
91 if(!_model->hasChanged() && state==HIGHLIGHTED)
93 if(!_view->isPointInside(X,Y))
95 _model->setState(NOTHING_HAPPENS);
100 _model->notifyObservers();
107 //=========================================================================
108 bool GObjectController::OnLeftButtonDown()
110 /********************** VIRTUAL *************************
112 if ( _vtkInteractorStyleBaseView!=NULL )
115 wxVTKRenderWindowInteractor *wxVTKiren;
116 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
117 wxVTKiren->GetEventPosition(X,Y);
119 int state = _model->getState();
122 if(!_model->hasChanged() && state==HIGHLIGHTED)
124 _view->isStartDragging(true);
125 _model->setState(DRAG);
126 _model->setChanged();
129 if( !_model->hasChanged() && state == SELECTED)
131 if(_view->isPointInside(X,Y))
133 _view->isStartDragging(true);
134 _model->setState(DRAG);
135 _model->setChanged();
139 _model->notifyObservers();
146 //=========================================================================
147 bool GObjectController::OnLeftButtonUp()
150 /********************** VIRTUAL *************************
152 if ( _vtkInteractorStyleBaseView!=NULL )
155 wxVTKRenderWindowInteractor *wxVTKiren;
156 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
157 wxVTKiren->GetEventPosition(X,Y);
159 int state = _model->getState();
162 if(!_model->hasChanged() && state==CLICKED)
164 _model->setState(SELECTED);
165 _model->setChanged();
168 if( !_model->hasChanged() && state == DRAG)
170 _model->setState(SELECTED);
171 _model->setChanged();
174 _model->notifyObservers();
181 //=========================================================================
182 bool GObjectController::OnLeftDClick()
184 /********************** VIRTUAL *************************
186 if ( _vtkInteractorStyleBaseView!=NULL )
189 wxVTKRenderWindowInteractor *wxVTKiren;
190 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
191 wxVTKiren->GetEventPosition(X,Y);
193 _model->notifyObservers();
199 //=========================================================================
200 bool GObjectController::OnRightButtonDown()
202 /********************** VIRTUAL *************************/
204 if( _vtkInteractorStyleBaseView!= NULL )
207 wxVTKRenderWindowInteractor *wxVTKiren;
208 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
209 wxVTKiren->GetEventPosition(X, Y);
211 int state = _model->getState();
214 if( !_model->hasChanged() && state == SELECTED)
216 _model->setState(NOTHING_HAPPENS);
217 _model->setChanged();
220 _model->notifyObservers();
229 //=========================================================================
231 void GObjectController::moveObject(int X,int Y)
233 _view->moveObject(X,Y);
236 //=========================================================================
238 } // EO namespace bbtk