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::GBlackBoxController
62 #include "GBlackBoxController.h"
71 //=========================================================================
72 GBlackBoxController::GBlackBoxController()
77 //=========================================================================
78 GBlackBoxController::~GBlackBoxController()
81 //=========================================================================
83 bool GBlackBoxController::OnMouseMove()
86 if ( _vtkInteractorStyleBaseView!=NULL)
89 wxVTKRenderWindowInteractor *_wxVTKiren;
90 _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
91 _wxVTKiren->GetEventPosition( X , Y );
93 int state = _view->getState();
97 if(state == NOTHING_HAPPENS)
99 if(_view->isPointInside(X,Y))
101 _view->setState(HIGHLIGHTED);
103 return true; // to avoid to redraw all if nothing
106 if( state==HIGHLIGHTED)
108 if(!_view->isPointInside(X,Y))
110 _view->setState(NOTHING_HAPPENS);
115 if ((state==DRAG) && (_isLeftClickDown==true) )
117 _objHasBeenMoved=true;
120 _model->notifyObservers(getId());
126 //=========================================================================
128 bool GBlackBoxController::OnLeftButtonDown()
130 _objHasBeenMoved = false;
131 _isLeftClickDown = true;
135 wxVTKRenderWindowInteractor *_wxVTKiren;
136 _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
137 _wxVTKiren->GetEventPosition( X , Y );
141 int state = _view->getState();
144 if(_view->isPointInside(X,Y))
146 // if(state == HIGHLIGHTED)
147 //EED3oct2010 if ( (state == HIGHLIGHTED) && (ctrlkey==1 ) )
149 if(state == SELECTED)
151 _view->setState(NOTHING_HAPPENS);
152 _model->notifyObservers(getId(),REMOVE_FROM_SELECTED);
155 _view->setState(SELECTED);
156 _model->notifyObservers(getId(),ADD_TO_SELECTED);
160 int shiftkey = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey();
161 int ctrlkey = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
162 ctrlkey = ctrlkey + shiftkey;
165 if ( (state==DRAG) && (ctrlkey==1) && (_view->isPointInside(X,Y)==true) )
167 _view->setState(NOTHING_HAPPENS);
168 _model->notifyObservers(getId(),REMOVE_FROM_SELECTED);
174 //=========================================================================
176 bool GBlackBoxController::OnLeftButtonUp()
178 _isLeftClickDown = false;
179 int state = _view->getState();
185 // wxVTKRenderWindowInteractor *wxVTKiren;
186 // wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
187 // wxVTKiren->GetEventPosition(X,Y);
188 // if(_isLeftClickDown)
190 // _isLeftClickDown=false;
191 // if(_view->isPointInside(X,Y))
193 // It is supposed that I'm always inside even if the box is in drag
194 // _view->setState(SELECTED);
195 // _model->notifyObservers(getId());
201 int shiftkey = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey();
202 int ctrlkey = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
203 ctrlkey = ctrlkey + shiftkey;
207 // if ( (state==SELECTED) && (ctrlkey==0) && (_objHasBeenMoved==false))
209 // _view->setState(NOTHING_HAPPENS);
210 // _model->notifyObservers(getId(),REMOVE_FROM_SELECTED);
219 //=========================================================================
221 bool GBlackBoxController::OnRightButtonUp()
226 //=========================================================================
228 bool GBlackBoxController::OnMiddleButtonDown()
231 wxVTKRenderWindowInteractor *wxVTKiren;
232 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
233 wxVTKiren->GetEventPosition(X,Y);
235 // int state = _view->getState();
238 if(_view->isPointInside(X,Y))
240 GBlackBoxModel *bbmodel = (GBlackBoxModel*)_model;
241 _view->setState(HIGHLIGHTED);
242 if(bbmodel->isExecutable())
244 bbmodel->setExecutable(false);
248 bbmodel->setExecutable(true);
250 bbmodel->notifyObservers(getId());
256 //=========================================================================
258 } // EO namespace bbtk