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 = _model->getState();
68 if(!_model->hasChanged() && state == DRAG)
74 if(!_model->hasChanged() && state == NOTHING_HAPPENS)
76 if(_view->isPointInside(X,Y))
78 _model->setState(HIGHLIGHTED);
82 if(!_model->hasChanged() && state==HIGHLIGHTED)
84 if(!_view->isPointInside(X,Y))
86 _model->setState(NOTHING_HAPPENS);
91 _model->notifyObservers();
96 //=========================================================================
98 bool GBlackBoxController::OnLeftButtonDown()
101 if ( _vtkInteractorStyleBaseView!=NULL )
104 wxVTKRenderWindowInteractor *wxVTKiren;
105 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
106 wxVTKiren->GetEventPosition(X,Y);
108 int state = _model->getState();
111 if(!_model->hasChanged() && state==HIGHLIGHTED)
113 _view->isStartDragging(true);
114 _model->setState(DRAG);
115 _model->setChanged();
118 if( !_model->hasChanged() && state == SELECTED)
120 if(_view->isPointInside(X,Y))
122 _view->isStartDragging(true);
123 _model->setState(DRAG);
124 _model->setChanged();
128 _model->notifyObservers();
133 //=========================================================================
135 bool GBlackBoxController::OnLeftButtonUp()
137 if ( _vtkInteractorStyleBaseView!=NULL )
140 wxVTKRenderWindowInteractor *wxVTKiren;
141 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
142 wxVTKiren->GetEventPosition(X,Y);
144 int state = _model->getState();
147 if(!_model->hasChanged() && state==CLICKED)
149 _model->setState(SELECTED);
150 _model->setChanged();
153 if( !_model->hasChanged() && state == DRAG)
155 _model->setState(SELECTED);
156 _model->setChanged();
159 _model->notifyObservers();
165 //=========================================================================
167 bool GBlackBoxController::OnLeftDClick()
169 if ( _vtkInteractorStyleBaseView!=NULL )
172 wxVTKRenderWindowInteractor *wxVTKiren;
173 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
174 wxVTKiren->GetEventPosition(X,Y);
176 _model->notifyObservers();
181 //=========================================================================
183 bool GBlackBoxController::OnRightButtonDown()
185 if( _vtkInteractorStyleBaseView!= NULL )
188 wxVTKRenderWindowInteractor *wxVTKiren;
189 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
190 wxVTKiren->GetEventPosition(X, Y);
192 int state = _model->getState();
195 if( !_model->hasChanged() && state == SELECTED)
197 _model->setState(NOTHING_HAPPENS);
198 _model->setChanged();
201 _model->notifyObservers();
206 //=========================================================================
208 } // EO namespace bbtk