]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.cxx
6b1174ff43faa6425f71f49d1a29e053ceaa1fbc
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsVtkGUIEditorGraphic / GObjectController.cxx
1 /*=========================================================================                                                                               
2 Program:   bbtk
3 Module:    $RCSfile$
4 Language:  C++
5 Date:      $Date$
6 Version:   $Revision$
7 =========================================================================*/
8
9 /* ---------------------------------------------------------------------
10
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
13 *
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.
20 *
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
25 *  liability. 
26 *
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 * ------------------------------------------------------------------------ */                                                                         
30
31 /**
32 *  \file 
33 *  \brief Class bbtk::GObjectController 
34 */
35
36
37 #include "GObjectController.h"
38
39 namespace bbtk
40 {
41
42
43         //=========================================================================
44         GObjectController::GObjectController()
45         {
46                 
47         }
48
49         //=========================================================================
50         GObjectController::~GObjectController()
51         {
52         }
53         //=========================================================================
54
55         void GObjectController::setModelAndView(GObjectModel* model, vtkGObjectView* view)
56         {
57                 _model = model;
58                 _view = view;
59         }
60         //=========================================================================
61
62 bool GObjectController::OnMouseMove()
63 {
64         
65         /**********************   VIRTUAL *************************/
66
67         if ( _vtkInteractorStyleBaseView!=NULL)
68         {
69                 int X,Y;
70                 wxVTKRenderWindowInteractor *_wxVTKiren;
71                 _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
72                 _wxVTKiren->GetEventPosition( X , Y );
73
74                 int state  = _model->getState();
75                 
76                 //Evaluate new state
77                 if(!_model->hasChanged() && state == DRAG)
78                 {
79                         moveObject(X,Y);
80                         _model->setChanged();
81                 }
82
83                 if(!_model->hasChanged() && state == NOTHING_HAPPENS)
84                 {
85                         if(_view->isPointInside(X,Y))
86                         {
87                                 _model->setState(HIGHLIGHTED);
88                                 _model->setChanged();                           
89                         }                       
90                 }
91                 if(!_model->hasChanged() && state==HIGHLIGHTED)
92                 {
93                         if(!_view->isPointInside(X,Y))
94                         {
95                                 _model->setState(NOTHING_HAPPENS);
96                                 _model->setChanged();
97                         }
98                 }
99                 
100                 _model->notifyObservers();
101         }
102
103         /**/
104
105         return true;
106 }
107 //=========================================================================
108 bool GObjectController::OnLeftButtonDown()
109 {
110         /**********************   VIRTUAL *************************
111         
112         if ( _vtkInteractorStyleBaseView!=NULL )
113         {
114                 int X,Y;
115                 wxVTKRenderWindowInteractor *wxVTKiren;
116                 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
117                 wxVTKiren->GetEventPosition(X,Y);
118
119                 int state  = _model->getState();
120                 
121                 //Evaluate new state
122                 if(!_model->hasChanged() && state==HIGHLIGHTED)
123                 {
124                         _view->isStartDragging(true);
125                         _model->setState(DRAG);
126                         _model->setChanged();
127                 }
128
129                 if( !_model->hasChanged() && state == SELECTED)
130                 {
131                         if(_view->isPointInside(X,Y))
132                         {
133                                 _view->isStartDragging(true);
134                                 _model->setState(DRAG);
135                                 _model->setChanged();
136                         }       
137                 }
138                 
139                 _model->notifyObservers();
140         }
141
142         */
143
144         return true;
145 }
146 //=========================================================================
147 bool GObjectController::OnLeftButtonUp()
148 {
149
150         /**********************   VIRTUAL *************************
151
152         if ( _vtkInteractorStyleBaseView!=NULL )
153         {
154                 int X,Y;
155                 wxVTKRenderWindowInteractor *wxVTKiren;
156                 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
157                 wxVTKiren->GetEventPosition(X,Y);
158
159                 int state  = _model->getState();
160                 
161                 //Evaluate new state
162                 if(!_model->hasChanged() && state==CLICKED)
163                 {
164                         _model->setState(SELECTED);
165                         _model->setChanged();
166                 }
167
168                 if( !_model->hasChanged() && state == DRAG)
169                 {
170                         _model->setState(SELECTED);
171                         _model->setChanged();
172                 }
173
174                 _model->notifyObservers();
175
176         }
177
178         */
179         return true;
180 }
181 //=========================================================================
182 bool GObjectController::OnLeftDClick()
183 {
184         /**********************   VIRTUAL *************************
185
186         if ( _vtkInteractorStyleBaseView!=NULL )
187         {
188                 int X,Y;
189                 wxVTKRenderWindowInteractor *wxVTKiren;
190                 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
191                 wxVTKiren->GetEventPosition(X,Y);
192
193                 _model->notifyObservers();
194         }
195
196         */
197         return true;
198 }
199 //=========================================================================
200 bool GObjectController::OnRightButtonDown()
201 {
202         /**********************   VIRTUAL *************************/
203
204         if( _vtkInteractorStyleBaseView!= NULL )
205         {
206                 int X,Y;
207                 wxVTKRenderWindowInteractor *wxVTKiren;
208                 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
209                 wxVTKiren->GetEventPosition(X, Y);
210                 
211                 int state  = _model->getState();
212                 
213                 //Evaluate new state
214                 if( !_model->hasChanged() && state == SELECTED)
215                 {
216                         _model->setState(NOTHING_HAPPENS);
217                         _model->setChanged();                   
218                 }
219
220                 _model->notifyObservers();
221         }
222         
223         /**/
224
225         return true;
226
227 }
228
229 //=========================================================================
230
231 void GObjectController::moveObject(int X,int Y)
232 {
233         _view->moveObject(X,Y); 
234 }
235
236 //=========================================================================
237
238 }  // EO namespace bbtk
239
240 // EOF
241