]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx
Necessary changes to manage the basic action . First prototype totally completed...
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsVtkGUIEditorGraphic / GBlackBoxController.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::GBlackBoxController 
34 */
35
36
37 #include "GBlackBoxController.h"
38
39 namespace bbtk
40 {
41
42
43         //=========================================================================
44         GBlackBoxController::GBlackBoxController()
45         {
46                 
47         }
48
49         //=========================================================================
50         GBlackBoxController::~GBlackBoxController()
51         {
52         }
53         //=========================================================================
54
55         bool GBlackBoxController::OnMouseMove()
56         {
57                 
58                 if ( _vtkInteractorStyleBaseView!=NULL)
59                 {
60                         int X,Y;
61                         wxVTKRenderWindowInteractor *_wxVTKiren;
62                         _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
63                         _wxVTKiren->GetEventPosition( X , Y );
64
65                         int state  = _model->getState();
66                         
67                         //Evaluate new state
68                         if(!_model->hasChanged() && state == DRAG)
69                         {
70                                 moveObject(X,Y);
71                                 _model->setChanged();
72                         }
73
74                         if(!_model->hasChanged() && state == NOTHING_HAPPENS)
75                         {
76                                 if(_view->isPointInside(X,Y))
77                                 {
78                                         _model->setState(HIGHLIGHTED);
79                                         _model->setChanged();                           
80                                 }                       
81                         }
82                         if(!_model->hasChanged() && state==HIGHLIGHTED)
83                         {
84                                 if(!_view->isPointInside(X,Y))
85                                 {
86                                         _model->setState(NOTHING_HAPPENS);
87                                         _model->setChanged();
88                                 }
89                         }
90                         
91                         _model->notifyObservers();
92                 }
93                 return true;
94         }
95
96         //=========================================================================
97         
98         bool GBlackBoxController::OnLeftButtonDown()
99         {
100                 
101                 if ( _vtkInteractorStyleBaseView!=NULL )
102                 {
103                         int X,Y;
104                         wxVTKRenderWindowInteractor *wxVTKiren;
105                         wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
106                         wxVTKiren->GetEventPosition(X,Y);
107
108                         int state  = _model->getState();
109                         
110                         //Evaluate new state
111                         if(!_model->hasChanged() && state==HIGHLIGHTED)
112                         {
113                                 _view->isStartDragging(true);
114                                 _model->setState(DRAG);
115                                 _model->setChanged();
116                         }
117
118                         if( !_model->hasChanged() && state == SELECTED)
119                         {
120                                 if(_view->isPointInside(X,Y))
121                                 {
122                                         _view->isStartDragging(true);
123                                         _model->setState(DRAG);
124                                         _model->setChanged();
125                                 }       
126                         }
127                         
128                         _model->notifyObservers();
129                 }
130                 return true;
131         }
132
133         //=========================================================================
134         
135         bool GBlackBoxController::OnLeftButtonUp()
136         {
137                 if ( _vtkInteractorStyleBaseView!=NULL )
138                 {
139                         int X,Y;
140                         wxVTKRenderWindowInteractor *wxVTKiren;
141                         wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
142                         wxVTKiren->GetEventPosition(X,Y);
143
144                         int state  = _model->getState();
145                         
146                         //Evaluate new state
147                         if(!_model->hasChanged() && state==CLICKED)
148                         {
149                                 _model->setState(SELECTED);
150                                 _model->setChanged();
151                         }
152
153                         if( !_model->hasChanged() && state == DRAG)
154                         {
155                                 _model->setState(SELECTED);
156                                 _model->setChanged();
157                         }
158
159                         _model->notifyObservers();
160
161                 }
162                 return true;
163         }
164         
165         //=========================================================================
166         
167         bool GBlackBoxController::OnLeftDClick()
168         {
169                 if ( _vtkInteractorStyleBaseView!=NULL )
170                 {
171                         int X,Y;
172                         wxVTKRenderWindowInteractor *wxVTKiren;
173                         wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
174                         wxVTKiren->GetEventPosition(X,Y);
175
176                         _model->notifyObservers();
177                 }
178                 return true;
179         }
180         
181         //=========================================================================
182         
183         bool GBlackBoxController::OnRightButtonDown()
184         {
185                 if( _vtkInteractorStyleBaseView!= NULL )
186                 {
187                         int X,Y;
188                         wxVTKRenderWindowInteractor *wxVTKiren;
189                         wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
190                         wxVTKiren->GetEventPosition(X, Y);
191                         
192                         int state  = _model->getState();
193                         
194                         //Evaluate new state
195                         if( !_model->hasChanged() && state == SELECTED)
196                         {
197                                 _model->setState(NOTHING_HAPPENS);
198                                 _model->setChanged();                   
199                         }
200
201                         _model->notifyObservers();
202                 }
203                 return true;
204 }
205
206         //=========================================================================
207
208 }  // EO namespace bbtk
209
210 // EOF
211