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 //=========================================================================
51 GObjectController::~GObjectController()
55 //=========================================================================
57 void GObjectController::setModelAndView(GObjectModel* model, vtkGObjectView* view)
63 //=========================================================================
65 bool GObjectController::OnMouseMove()
68 /********************** VIRTUAL *************************/
70 if ( _vtkInteractorStyleBaseView!=NULL)
73 wxVTKRenderWindowInteractor *_wxVTKiren;
74 _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
75 _wxVTKiren->GetEventPosition( X , Y );
77 int state = _view->getState();
80 if(!_model->hasChanged() && state == DRAG)
86 if(!_model->hasChanged() && state == NOTHING_HAPPENS)
88 if(_view->isPointInside(X,Y))
90 _view->setState(HIGHLIGHTED);
94 if(!_model->hasChanged() && state==HIGHLIGHTED)
96 if(!_view->isPointInside(X,Y))
98 _view->setState(NOTHING_HAPPENS);
103 _model->notifyObservers(_id);
112 //=========================================================================
114 bool GObjectController::OnLeftButtonDown()
116 /********************** VIRTUAL *************************
118 if ( _vtkInteractorStyleBaseView!=NULL )
121 wxVTKRenderWindowInteractor *wxVTKiren;
122 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
123 wxVTKiren->GetEventPosition(X,Y);
125 int state = _model->getState();
128 if(!_model->hasChanged() && state==HIGHLIGHTED)
130 _view->isStartDragging(true);
131 _model->setState(DRAG);
132 _model->setChanged();
135 if( !_model->hasChanged() && state == SELECTED)
137 if(_view->isPointInside(X,Y))
139 _view->isStartDragging(true);
140 _model->setState(DRAG);
141 _model->setChanged();
145 _model->notifyObservers();
153 //=========================================================================
155 bool GObjectController::OnLeftButtonUp()
158 /********************** VIRTUAL *************************
160 if ( _vtkInteractorStyleBaseView!=NULL )
163 wxVTKRenderWindowInteractor *wxVTKiren;
164 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
165 wxVTKiren->GetEventPosition(X,Y);
167 int state = _model->getState();
170 if(!_model->hasChanged() && state==CLICKED)
172 _model->setState(SELECTED);
173 _model->setChanged();
176 if( !_model->hasChanged() && state == DRAG)
178 _model->setState(SELECTED);
179 _model->setChanged();
182 _model->notifyObservers();
190 //=========================================================================
192 bool GObjectController::OnLeftDClick()
194 /********************** VIRTUAL *************************
196 if ( _vtkInteractorStyleBaseView!=NULL )
199 wxVTKRenderWindowInteractor *wxVTKiren;
200 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
201 wxVTKiren->GetEventPosition(X,Y);
203 _model->notifyObservers();
210 //=========================================================================
212 bool GObjectController::OnRightButtonDown()
214 /********************** VIRTUAL *************************/
216 if( _vtkInteractorStyleBaseView!= NULL )
219 wxVTKRenderWindowInteractor *wxVTKiren;
220 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
221 wxVTKiren->GetEventPosition(X, Y);
223 int state = _view->getState();
226 if( !_model->hasChanged() && state == SELECTED)
228 _view->setState(NOTHING_HAPPENS);
229 _model->setChanged();
232 _model->notifyObservers(_id);
241 //=========================================================================
243 void GObjectController::moveObject(int X,int Y)
245 _view->moveObject(X,Y);
248 //=========================================================================
250 int GObjectController::getGObjectType()
252 return _model->getGObjectType();
255 //=========================================================================
257 GObjectModel* GObjectController::getModel()
262 //=========================================================================
264 vtkGObjectView* GObjectController::getView()
269 //=========================================================================
271 int GObjectController::getId()
276 //=========================================================================
278 void GObjectController::setId(int id)
283 //=========================================================================
285 } // EO namespace bbtk