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();
85 if( state == NOTHING_HAPPENS)
87 if(_view->isPointInside(X,Y))
89 _view->setState(HIGHLIGHTED);
92 if( state==HIGHLIGHTED)
94 if(!_view->isPointInside(X,Y))
96 _view->setState(NOTHING_HAPPENS);
100 _model->notifyObservers(_id);
109 //=========================================================================
111 bool GObjectController::OnLeftButtonDown()
113 /********************** VIRTUAL *************************
115 if ( _vtkInteractorStyleBaseView!=NULL )
118 wxVTKRenderWindowInteractor *wxVTKiren;
119 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
120 wxVTKiren->GetEventPosition(X,Y);
122 int state = _model->getState();
125 if(!_model->hasChanged() && state==HIGHLIGHTED)
127 _view->isStartDragging(true);
128 _model->setState(DRAG);
131 if( !_model->hasChanged() && state == SELECTED)
133 if(_view->isPointInside(X,Y))
135 _view->isStartDragging(true);
136 _model->setState(DRAG);
140 _model->notifyObservers();
148 //=========================================================================
150 bool GObjectController::OnLeftButtonUp()
153 /********************** VIRTUAL *************************
155 if ( _vtkInteractorStyleBaseView!=NULL )
158 wxVTKRenderWindowInteractor *wxVTKiren;
159 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
160 wxVTKiren->GetEventPosition(X,Y);
162 int state = _model->getState();
165 if(!_model->hasChanged() && state==CLICKED)
167 _model->setState(SELECTED);
170 if( !_model->hasChanged() && state == DRAG)
172 _model->setState(SELECTED);
175 _model->notifyObservers();
183 //=========================================================================
185 bool GObjectController::OnLeftDClick()
187 /********************** VIRTUAL *************************
189 if ( _vtkInteractorStyleBaseView!=NULL )
192 wxVTKRenderWindowInteractor *wxVTKiren;
193 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
194 wxVTKiren->GetEventPosition(X,Y);
196 _model->notifyObservers();
203 //=========================================================================
205 bool GObjectController::OnRightButtonDown()
207 /********************** VIRTUAL *************************/
209 if( _vtkInteractorStyleBaseView!= NULL )
212 wxVTKRenderWindowInteractor *wxVTKiren;
213 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
214 wxVTKiren->GetEventPosition(X, Y);
216 int state = _view->getState();
219 if( state == SELECTED)
221 _view->setState(NOTHING_HAPPENS);
224 _model->notifyObservers(_id);
233 //=========================================================================
235 void GObjectController::moveObject(int X,int Y)
237 _view->moveObject(X,Y);
240 //=========================================================================
242 int GObjectController::getGObjectType()
244 return _model->getGObjectType();
247 //=========================================================================
249 GObjectModel* GObjectController::getModel()
254 //=========================================================================
256 vtkGObjectView* GObjectController::getView()
261 //=========================================================================
263 int GObjectController::getId()
268 //=========================================================================
270 void GObjectController::setId(int id)
275 //=========================================================================
277 } // EO namespace bbtk