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 printf("EED GBlackBoxController::OnMouseMove START \n");
60 if ( _vtkInteractorStyleBaseView!=NULL)
63 wxVTKRenderWindowInteractor *_wxVTKiren;
64 _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
65 _wxVTKiren->GetEventPosition( X , Y );
67 int state = _view->getState();
71 if(state == NOTHING_HAPPENS)
73 if(_view->isPointInside(X,Y))
75 _view->setState(HIGHLIGHTED);
79 if( state==HIGHLIGHTED)
81 if(!_view->isPointInside(X,Y))
83 _view->setState(NOTHING_HAPPENS);
88 if ((state==DRAG) && (_isLeftClickDown==true) )
90 _objHasBeenMoved=true;
93 printf("EED GBlackBoxController::OnMouseMove state=%d\n", state);
94 _model->notifyObservers(getId());
100 //=========================================================================
102 bool GBlackBoxController::OnLeftButtonDown()
104 _objHasBeenMoved = false;
105 _isLeftClickDown = true;
107 int state = _view->getState();
108 printf("EED GBlackBoxController::OnLeftButtonDown state=%d \n", state);
110 if(state == HIGHLIGHTED)
111 //EED3oct2010 if ( (state == HIGHLIGHTED) && (ctrlkey==1 ) )
114 _view->setState(SELECTED);
115 _model->notifyObservers(getId(),ADD_TO_SELECTED);
121 wxVTKRenderWindowInteractor *wxVTKiren;
122 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
123 wxVTKiren->GetEventPosition(X,Y);
124 int ctrlkey=_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
125 if ( (state==DRAG) && (ctrlkey==1) && (_view->isPointInside(X,Y)==true) )
127 _view->setState(NOTHING_HAPPENS);
128 _model->notifyObservers(getId(),REMOVE_FROM_SELECTED);
131 printf("EED GBlackBoxController::OnLeftButtonDown END\n" );
137 //=========================================================================
139 bool GBlackBoxController::OnLeftButtonUp()
141 _isLeftClickDown = false;
142 int state = _view->getState();
143 printf("EED GBlackBoxController::OnLeftButtonUp START state=%d \n", state);
149 // wxVTKRenderWindowInteractor *wxVTKiren;
150 // wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
151 // wxVTKiren->GetEventPosition(X,Y);
152 // if(_isLeftClickDown)
154 // _isLeftClickDown=false;
155 // if(_view->isPointInside(X,Y))
157 // It is supposed that I'm always inside even if the box is in drag
158 // _view->setState(SELECTED);
159 // _model->notifyObservers(getId());
165 int ctrlkey=_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
167 if ( (state==SELECTED) && (ctrlkey==0) && (_objHasBeenMoved==false))
169 _view->setState(NOTHING_HAPPENS);
170 _model->notifyObservers(getId(),REMOVE_FROM_SELECTED);
174 printf("EED GBlackBoxController::OnLeftButtonUp END state=%d \n", state);
180 //=========================================================================
182 bool GBlackBoxController::OnRightButtonUp()
187 //=========================================================================
189 bool GBlackBoxController::OnMiddleButtonDown()
192 wxVTKRenderWindowInteractor *wxVTKiren;
193 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
194 wxVTKiren->GetEventPosition(X,Y);
196 int state = _view->getState();
199 if(_view->isPointInside(X,Y))
201 GBlackBoxModel *bbmodel = (GBlackBoxModel*)_model;
202 _view->setState(HIGHLIGHTED);
203 if(bbmodel->isExecutable())
205 bbmodel->setExecutable(false);
209 bbmodel->setExecutable(true);
211 bbmodel->notifyObservers(getId());
217 //=========================================================================
219 } // EO namespace bbtk