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::GBlackBoxController
37 #include "GBlackBoxController.h"
43 //=========================================================================
44 GBlackBoxController::GBlackBoxController()
49 //=========================================================================
50 GBlackBoxController::~GBlackBoxController()
53 //=========================================================================
55 bool GBlackBoxController::OnMouseMove()
58 if ( _vtkInteractorStyleBaseView!=NULL)
61 wxVTKRenderWindowInteractor *_wxVTKiren;
62 _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
63 _wxVTKiren->GetEventPosition( X , Y );
65 int state = _view->getState();
69 if(state == NOTHING_HAPPENS)
71 if(_view->isPointInside(X,Y))
73 _view->setState(HIGHLIGHTED);
77 if( state==HIGHLIGHTED)
79 if(!_view->isPointInside(X,Y))
81 _view->setState(NOTHING_HAPPENS);
86 if ((state==DRAG) && (_isLeftClickDown==true) )
88 _objHasBeenMoved=true;
91 _model->notifyObservers(getId());
97 //=========================================================================
99 bool GBlackBoxController::OnLeftButtonDown()
101 _objHasBeenMoved = false;
102 _isLeftClickDown = true;
106 wxVTKRenderWindowInteractor *_wxVTKiren;
107 _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
108 _wxVTKiren->GetEventPosition( X , Y );
112 int state = _view->getState();
115 if(_view->isPointInside(X,Y))
117 // if(state == HIGHLIGHTED)
118 //EED3oct2010 if ( (state == HIGHLIGHTED) && (ctrlkey==1 ) )
121 _view->setState(SELECTED);
122 _model->notifyObservers(getId(),ADD_TO_SELECTED);
126 int shiftkey = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey();
127 int ctrlkey = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
128 ctrlkey = ctrlkey + shiftkey;
131 if ( (state==DRAG) && (ctrlkey==1) && (_view->isPointInside(X,Y)==true) )
133 _view->setState(NOTHING_HAPPENS);
134 _model->notifyObservers(getId(),REMOVE_FROM_SELECTED);
140 //=========================================================================
142 bool GBlackBoxController::OnLeftButtonUp()
144 _isLeftClickDown = false;
145 int state = _view->getState();
151 // wxVTKRenderWindowInteractor *wxVTKiren;
152 // wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
153 // wxVTKiren->GetEventPosition(X,Y);
154 // if(_isLeftClickDown)
156 // _isLeftClickDown=false;
157 // if(_view->isPointInside(X,Y))
159 // It is supposed that I'm always inside even if the box is in drag
160 // _view->setState(SELECTED);
161 // _model->notifyObservers(getId());
167 int shiftkey = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey();
168 int ctrlkey = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
169 ctrlkey = ctrlkey + shiftkey;
172 if ( (state==SELECTED) && (ctrlkey==0) && (_objHasBeenMoved==false))
174 _view->setState(NOTHING_HAPPENS);
175 _model->notifyObservers(getId(),REMOVE_FROM_SELECTED);
184 //=========================================================================
186 bool GBlackBoxController::OnRightButtonUp()
191 //=========================================================================
193 bool GBlackBoxController::OnMiddleButtonDown()
196 wxVTKRenderWindowInteractor *wxVTKiren;
197 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
198 wxVTKiren->GetEventPosition(X,Y);
200 // int state = _view->getState();
203 if(_view->isPointInside(X,Y))
205 GBlackBoxModel *bbmodel = (GBlackBoxModel*)_model;
206 _view->setState(HIGHLIGHTED);
207 if(bbmodel->isExecutable())
209 bbmodel->setExecutable(false);
213 bbmodel->setExecutable(true);
215 bbmodel->notifyObservers(getId());
221 //=========================================================================
223 } // EO namespace bbtk