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();
68 if(!_model->hasChanged() && state == DRAG)
74 if(!_model->hasChanged() && state == NOTHING_HAPPENS)
76 if(_view->isPointInside(X,Y))
78 _view->setState(HIGHLIGHTED);
82 if(!_model->hasChanged() && state==HIGHLIGHTED)
84 if(!_view->isPointInside(X,Y))
86 _view->setState(NOTHING_HAPPENS);
91 _model->notifyObservers(_id);
97 //=========================================================================
99 bool GBlackBoxController::OnLeftButtonDown()
102 if ( _vtkInteractorStyleBaseView!=NULL )
105 wxVTKRenderWindowInteractor *wxVTKiren;
106 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
107 wxVTKiren->GetEventPosition(X,Y);
109 int state = _view->getState();
112 if(!_model->hasChanged() && state==HIGHLIGHTED)
114 _view->isStartDragging(true);
115 _view->setState(DRAG);
116 _model->setChanged();
119 if( !_model->hasChanged() && state == SELECTED)
121 if(_view->isPointInside(X,Y))
123 _view->isStartDragging(true);
124 _view->setState(DRAG);
125 _model->setChanged();
129 _model->notifyObservers(_id);
134 //=========================================================================
136 bool GBlackBoxController::OnLeftButtonUp()
138 if ( _vtkInteractorStyleBaseView!=NULL )
141 wxVTKRenderWindowInteractor *wxVTKiren;
142 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
143 wxVTKiren->GetEventPosition(X,Y);
145 int state = _view->getState();
148 if(!_model->hasChanged() && state==CLICKED)
150 _view->setState(SELECTED);
151 _model->setChanged();
154 if( !_model->hasChanged() && state == DRAG)
156 _view->setState(SELECTED);
157 _model->setChanged();
160 _model->notifyObservers(_id);
166 //=========================================================================
168 bool GBlackBoxController::OnLeftDClick()
170 if ( _vtkInteractorStyleBaseView!=NULL )
173 wxVTKRenderWindowInteractor *wxVTKiren;
174 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
175 wxVTKiren->GetEventPosition(X,Y);
177 _model->notifyObservers(_id);
182 //=========================================================================
184 bool GBlackBoxController::OnRightButtonDown()
186 if( _vtkInteractorStyleBaseView!= NULL )
189 wxVTKRenderWindowInteractor *wxVTKiren;
190 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
191 wxVTKiren->GetEventPosition(X, Y);
193 int state = _view->getState();
196 if( !_model->hasChanged() && state == SELECTED)
198 _view->setState(NOTHING_HAPPENS);
199 _model->setChanged();
202 _model->notifyObservers(_id);
207 //=========================================================================
209 } // EO namespace bbtk