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 if ( _vtkInteractorStyleBaseView!=NULL)
68 wxVTKRenderWindowInteractor *_wxVTKiren;
69 _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
70 _wxVTKiren->GetEventPosition( X , Y );
72 int state = _model->getState();
75 if(!_model->hasChanged() && state == DRAG)
81 if(!_model->hasChanged() && state == NOTHING_HAPPENS)
83 if(_view->isPointInside(X,Y))
85 _model->setState(HIGHLIGHTED);
89 if(!_model->hasChanged() && state==HIGHLIGHTED)
91 if(!_view->isPointInside(X,Y))
93 _model->setState(NOTHING_HAPPENS);
98 _model->notifyObservers();
102 //=========================================================================
103 bool GObjectController::OnLeftButtonDown()
106 if ( _vtkInteractorStyleBaseView!=NULL )
109 wxVTKRenderWindowInteractor *wxVTKiren;
110 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
111 wxVTKiren->GetEventPosition(X,Y);
113 int state = _model->getState();
116 if(!_model->hasChanged() && state==HIGHLIGHTED)
118 _view->isFirstDragging(true);
119 _model->setState(DRAG);
120 _model->setChanged();
123 if( !_model->hasChanged() && state == SELECTED)
125 if(_view->isPointInside(X,Y))
127 _view->isFirstDragging(true);
128 _model->setState(DRAG);
129 _model->setChanged();
133 _model->notifyObservers();
137 //=========================================================================
138 bool GObjectController::OnLeftButtonUp()
140 if ( _vtkInteractorStyleBaseView!=NULL )
143 wxVTKRenderWindowInteractor *wxVTKiren;
144 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
145 wxVTKiren->GetEventPosition(X,Y);
147 int state = _model->getState();
150 if(!_model->hasChanged() && state==CLICKED)
152 _model->setState(SELECTED);
153 _model->setChanged();
156 if( !_model->hasChanged() && state == DRAG)
158 _model->setState(SELECTED);
159 _model->setChanged();
162 _model->notifyObservers();
167 //=========================================================================
168 bool GObjectController::OnLeftDClick()
170 if ( _vtkInteractorStyleBaseView!=NULL )
173 wxVTKRenderWindowInteractor *wxVTKiren;
174 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
175 wxVTKiren->GetEventPosition(X,Y);
177 _model->notifyObservers();
181 //=========================================================================
182 bool GObjectController::OnRightButtonDown()
184 if( _vtkInteractorStyleBaseView!= NULL )
187 wxVTKRenderWindowInteractor *wxVTKiren;
188 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
189 wxVTKiren->GetEventPosition(X, Y);
191 int state = _model->getState();
194 if( !_model->hasChanged() && state == SELECTED)
196 _model->setState(NOTHING_HAPPENS);
197 _model->setChanged();
200 _model->notifyObservers();
205 //=========================================================================
207 void GObjectController::moveObject(int X,int Y)
209 _view->moveObject(X,Y);
212 //=========================================================================
214 } // EO namespace bbtk