2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
8 # This software is governed by the CeCILL-B license under French law and
9 # abiding by the rules of distribution of free software. You can use,
10 # modify and/ or redistribute the software under the terms of the CeCILL-B
11 # license as circulated by CEA, CNRS and INRIA at the following URL
12 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
13 # or in the file LICENSE.txt.
15 # As a counterpart to the access to the source code and rights to copy,
16 # modify and redistribute granted by the license, users are provided only
17 # with a limited warranty and the software's author, the holder of the
18 # economic rights, and the successive licensors have only limited
21 # The fact that you are presently reading this means that you have had
22 # knowledge of the CeCILL-B license and that you accept its terms.
23 # ------------------------------------------------------------------------
26 /*=========================================================================
32 =========================================================================*/
34 /* ---------------------------------------------------------------------
36 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
37 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
39 * This software is governed by the CeCILL-B license under French law and
40 * abiding by the rules of distribution of free software. You can use,
41 * modify and/ or redistribute the software under the terms of the CeCILL-B
42 * license as circulated by CEA, CNRS and INRIA at the following URL
43 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
44 * or in the file LICENSE.txt.
46 * As a counterpart to the access to the source code and rights to copy,
47 * modify and redistribute granted by the license, users are provided only
48 * with a limited warranty and the software's author, the holder of the
49 * economic rights, and the successive licensors have only limited
52 * The fact that you are presently reading this means that you have had
53 * knowledge of the CeCILL-B license and that you accept its terms.
54 * ------------------------------------------------------------------------ */
58 * \brief Class bbtk::GBoxController
62 #include "GBoxController.h"
71 //=========================================================================
72 GBoxController::GBoxController()
77 //=========================================================================
78 GBoxController::~GBoxController()
81 //=========================================================================
84 bool GBoxController::OnMouseMove()
86 if ( _vtkInteractorStyleBaseView!=NULL)
89 crea::wxVTKRenderWindowInteractor *_wxVTKiren;
90 _wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
91 _wxVTKiren->GetEventPosition( X , Y );
92 int state = _view->getState();
94 if(state == NOTHING_HAPPENS)
96 if(_view->isPointInside(X,Y))
98 _view->setState(HIGHLIGHTED);
101 if( state==HIGHLIGHTED)
103 if(!_view->isPointInside(X,Y))
105 _view->setState(NOTHING_HAPPENS);
108 _model->notifyObservers(getId());
114 //=========================================================================
115 bool GBoxController::OnMouseMove()
117 if ( _vtkInteractorStyleBaseView!=NULL)
120 crea::wxVTKRenderWindowInteractor *_wxVTKiren;
121 _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
122 _wxVTKiren->GetEventPosition( X , Y );
123 int state = _view->getState();
125 if(state == NOTHING_HAPPENS)
127 if(_view->isPointInside(X,Y))
129 _view->setState(HIGHLIGHTED);
131 return true; // to avoid to redraw all if nothing
133 if( state==HIGHLIGHTED)
135 if(!_view->isPointInside(X,Y))
137 _view->setState(NOTHING_HAPPENS);
140 // if ((state==DRAG) && (_isLeftClickDown==true) )
142 // _objHasBeenMoved=true;
144 _model->notifyObservers(getId());
153 //=========================================================================
156 bool GBoxController::OnLeftButtonDown()
159 int state = _view->getState();
161 if(state == HIGHLIGHTED)
164 _isLeftClickDown = true;
165 _view->setState(SELECTED);
166 _model->notifyObservers(getId(),ADD_TO_SELECTED);
172 bool GBoxController::OnLeftButtonDown()
174 // _objHasBeenMoved = false;
175 _isLeftClickDown = true;
178 crea::wxVTKRenderWindowInteractor *_wxVTKiren;
179 _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
180 _wxVTKiren->GetEventPosition( X , Y );
181 int state = _view->getState();
183 if(_view->isPointInside(X,Y))
185 // if(state == HIGHLIGHTED)
186 //EED3oct2010 if ( (state == HIGHLIGHTED) && (ctrlkey==1 ) )
187 if(state == SELECTED)
189 _view->setState(NOTHING_HAPPENS);
190 _model->notifyObservers(getId(),REMOVE_FROM_SELECTED);
193 _view->setState(SELECTED);
194 _model->notifyObservers(getId(),ADD_TO_SELECTED);
197 int shiftkey = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey();
198 int ctrlkey = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
199 ctrlkey = ctrlkey + shiftkey;
200 if ( (state==DRAG) && (ctrlkey==1) && (_view->isPointInside(X,Y)==true) )
202 _view->setState(NOTHING_HAPPENS);
203 _model->notifyObservers(getId(),REMOVE_FROM_SELECTED);
210 //=========================================================================
212 bool GBoxController::OnLeftButtonUp()
215 crea::wxVTKRenderWindowInteractor *wxVTKiren;
216 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
217 wxVTKiren->GetEventPosition(X,Y);
220 int state = _view->getState();
224 _isLeftClickDown=false;
225 if(_view->isPointInside(X,Y))
227 // It is supposed that I'm always inside even if the box is in drag
228 _view->setState(SELECTED);
229 _model->notifyObservers(getId());
237 //=========================================================================
239 bool GBoxController::OnRightButtonUp()
244 //=========================================================================
246 bool GBoxController::OnMiddleButtonDown()
251 //=========================================================================
253 } // EO namespace bbtk