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::GObjectController
37 #include "GObjectController.h"
43 //=========================================================================
44 GObjectController::GObjectController()
49 //=========================================================================
50 GObjectController::~GObjectController()
53 //=========================================================================
55 void GObjectController::setModelAndView(GObjectModel* model, vtkGObjectView* view)
60 //=========================================================================
62 bool GObjectController::OnMouseMove()
65 if ( _vtkInteractorStyleBaseView!=NULL)
68 wxVTKRenderWindowInteractor *_wxVTKiren;
69 _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
70 _wxVTKiren->GetEventPosition( X , Y );
72 int state = _model->getState();
75 if(!_model->hasChanged() && state == DRAG)
81 if(!_model->hasChanged() && state == NOTHING_HAPPENS)
83 if(_view->isPointInside(X,Y))
85 _model->setState(HIGHLIGHTED);
89 if(!_model->hasChanged() && state==HIGHLIGHTED)
91 if(!_view->isPointInside(X,Y))
93 _model->setState(NOTHING_HAPPENS);
98 _model->notifyObservers();
102 //=========================================================================
103 bool GObjectController::OnLeftButtonDown()
106 if ( _vtkInteractorStyleBaseView!=NULL )
109 wxVTKRenderWindowInteractor *wxVTKiren;
110 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
111 wxVTKiren->GetEventPosition(X,Y);
113 int state = _model->getState();
116 if(!_model->hasChanged() && state==HIGHLIGHTED)
118 _model->setState(DRAG);
119 _model->setChanged();
122 if( !_model->hasChanged() && state == SELECTED)
124 if(_view->isPointInside(X,Y))
126 _model->setState(DRAG);
127 _model->setChanged();
131 _model->notifyObservers();
135 //=========================================================================
136 bool GObjectController::OnLeftButtonUp()
138 if ( _vtkInteractorStyleBaseView!=NULL )
141 wxVTKRenderWindowInteractor *wxVTKiren;
142 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
143 wxVTKiren->GetEventPosition(X,Y);
145 int state = _model->getState();
148 if(!_model->hasChanged() && state==CLICKED)
150 _model->setState(SELECTED);
151 _model->setChanged();
154 if( !_model->hasChanged() && state == DRAG)
156 _model->setState(SELECTED);
157 _model->setChanged();
160 _model->notifyObservers();
165 //=========================================================================
166 bool GObjectController::OnLeftDClick()
168 if ( _vtkInteractorStyleBaseView!=NULL )
171 wxVTKRenderWindowInteractor *wxVTKiren;
172 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
173 wxVTKiren->GetEventPosition(X,Y);
175 _model->notifyObservers();
179 //=========================================================================
180 bool GObjectController::OnRightButtonDown()
182 if( _vtkInteractorStyleBaseView!= NULL )
185 wxVTKRenderWindowInteractor *wxVTKiren;
186 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
187 wxVTKiren->GetEventPosition(X, Y);
189 int state = _model->getState();
192 if( !_model->hasChanged() && state == SELECTED)
194 _model->setState(NOTHING_HAPPENS);
195 _model->setChanged();
198 _model->notifyObservers();
202 //=========================================================================
205 } // EO namespace bbtk