]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBoxController.cxx
#3252Select mechanism of boxes
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsVtkGUIEditorGraphic / GBoxController.cxx
1 /*
2 # ---------------------------------------------------------------------
3 #
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
5 #                        pour la Santé)
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 #
8 #  This software is governed by the CeCILL-B license under French law and 
9 #  abiding by the rules of distribution of free software. You can  use, 
10 #  modify and/ or redistribute the software under the terms of the CeCILL-B 
11 #  license as circulated by CEA, CNRS and INRIA at the following URL 
12 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
13 #  or in the file LICENSE.txt.
14 #
15 #  As a counterpart to the access to the source code and  rights to copy,
16 #  modify and redistribute granted by the license, users are provided only
17 #  with a limited warranty  and the software's author,  the holder of the
18 #  economic rights,  and the successive licensors  have only  limited
19 #  liability. 
20 #
21 #  The fact that you are presently reading this means that you have had
22 #  knowledge of the CeCILL-B license and that you accept its terms.
23 # ------------------------------------------------------------------------  
24 */
25
26 /*=========================================================================
27 Program:   bbtk
28 Module:    $RCSfile$
29 Language:  C++
30 Date:      $Date$
31 Version:   $Revision$
32 =========================================================================*/
33
34 /* ---------------------------------------------------------------------
35
36 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
37 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
38 *
39 *  This software is governed by the CeCILL-B license under French law and
40 *  abiding by the rules of distribution of free software. You can  use,
41 *  modify and/ or redistribute the software under the terms of the CeCILL-B
42 *  license as circulated by CEA, CNRS and INRIA at the following URL
43 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
44 *  or in the file LICENSE.txt.
45 *
46 *  As a counterpart to the access to the source code and  rights to copy,
47 *  modify and redistribute granted by the license, users are provided only
48 *  with a limited warranty  and the software's author,  the holder of the
49 *  economic rights,  and the successive licensors  have only  limited
50 *  liability.
51 *
52 *  The fact that you are presently reading this means that you have had
53 *  knowledge of the CeCILL-B license and that you accept its terms.
54 * ------------------------------------------------------------------------ */
55
56 /**
57 *  \file
58 *  \brief Class bbtk::GBoxController
59 */
60
61
62 #include "GBoxController.h"
63
64 #ifdef _DEBUG
65 #define new DEBUG_NEW
66 #endif
67 namespace bbtk
68 {
69
70
71         //=========================================================================
72         GBoxController::GBoxController()
73         {
74
75         }
76
77         //=========================================================================
78         GBoxController::~GBoxController()
79         {
80         }
81         //=========================================================================
82
83 /*
84         bool GBoxController::OnMouseMove()
85         {
86                 if ( _vtkInteractorStyleBaseView!=NULL)
87                 {
88                         int X,Y;
89                         crea::wxVTKRenderWindowInteractor *_wxVTKiren;
90                         _wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
91                         _wxVTKiren->GetEventPosition( X , Y );
92                         int state  = _view->getState();
93                         //Evaluate new state
94                         if(state == NOTHING_HAPPENS)
95                         {
96                                 if(_view->isPointInside(X,Y))
97                                 {
98                                         _view->setState(HIGHLIGHTED);
99                                 }
100                         }
101                         if( state==HIGHLIGHTED)
102                         {
103                                 if(!_view->isPointInside(X,Y))
104                                 {
105                                         _view->setState(NOTHING_HAPPENS);
106                                 }
107                         }
108                         _model->notifyObservers(getId());
109                 }
110                 return true;
111         }
112  */
113
114 //=========================================================================
115 bool GBoxController::OnMouseMove()
116 {
117     if ( _vtkInteractorStyleBaseView!=NULL)
118     {
119         int X,Y;
120         crea::wxVTKRenderWindowInteractor *_wxVTKiren;
121         _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
122         _wxVTKiren->GetEventPosition( X , Y );
123         int state  = _view->getState();
124         //Evaluate new state
125         if(state == NOTHING_HAPPENS)
126         {
127             if(_view->isPointInside(X,Y))
128             {
129                 _view->setState(HIGHLIGHTED);
130             }
131                     return true; // to avoid to redraw all if nothing
132         } // state
133         if( state==HIGHLIGHTED)
134         {
135             if(!_view->isPointInside(X,Y))
136             {
137                 _view->setState(NOTHING_HAPPENS);
138             }
139         } // state
140 //            if ((state==DRAG) && (_isLeftClickDown==true) )
141 //            {
142 //                _objHasBeenMoved=true;
143 //            } // state
144         _model->notifyObservers(getId());
145     }
146     return true;
147 }
148
149
150
151
152
153         //=========================================================================
154
155 /*
156         bool GBoxController::OnLeftButtonDown()
157         {
158             bool ok=true;
159                 int state  = _view->getState();
160                 //Evaluate new state
161                 if(state == HIGHLIGHTED)
162                 {
163                     ok               = false;
164                         _isLeftClickDown = true;
165                         _view->setState(SELECTED);
166                         _model->notifyObservers(getId(),ADD_TO_SELECTED);
167                 }
168                 return ok;
169         }
170 */
171
172 bool GBoxController::OnLeftButtonDown()
173 {
174 //        _objHasBeenMoved = false;
175     _isLeftClickDown = true;
176     bool ok=true;
177     int X,Y;
178     crea::wxVTKRenderWindowInteractor *_wxVTKiren;
179     _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
180     _wxVTKiren->GetEventPosition( X , Y );
181     int state  = _view->getState();
182     //Evaluate new state
183     if(_view->isPointInside(X,Y))
184     {
185 //        if(state == HIGHLIGHTED)
186 //EED3oct2010        if ( (state == HIGHLIGHTED) && (ctrlkey==1  ) )
187         if(state == SELECTED)
188         {
189             _view->setState(NOTHING_HAPPENS);
190             _model->notifyObservers(getId(),REMOVE_FROM_SELECTED);
191         } else {
192             ok=false;
193             _view->setState(SELECTED);
194             _model->notifyObservers(getId(),ADD_TO_SELECTED);
195         }
196     } // EED 2022-09-16
197     int shiftkey            = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey();
198     int ctrlkey             = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
199     ctrlkey = ctrlkey + shiftkey;
200     if ( (state==DRAG) && (ctrlkey==1) &&  (_view->isPointInside(X,Y)==true) )
201     {
202         _view->setState(NOTHING_HAPPENS);
203         _model->notifyObservers(getId(),REMOVE_FROM_SELECTED);
204     }
205     return ok;
206 }
207
208
209
210         //=========================================================================
211
212         bool GBoxController::OnLeftButtonUp()
213         {
214                 int X,Y;
215                 crea::wxVTKRenderWindowInteractor *wxVTKiren;
216                 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
217                 wxVTKiren->GetEventPosition(X,Y);
218
219  /*
220                 int state  = _view->getState();
221                 //Evaluate new state
222                 if(_isLeftClickDown)
223                 {
224                         _isLeftClickDown=false;
225                         if(_view->isPointInside(X,Y))
226                         {
227                                 // It is supposed that I'm always inside even if the box is in drag
228                                 _view->setState(SELECTED);
229                                 _model->notifyObservers(getId());
230                         }
231                 }
232 */
233         return true;
234
235         }
236
237         //=========================================================================
238
239         bool GBoxController::OnRightButtonUp()
240         {
241                 return true;
242         }
243
244         //=========================================================================
245
246         bool GBoxController::OnMiddleButtonDown()
247         {
248                 return true;
249         }
250
251         //=========================================================================
252
253 }  // EO namespace bbtk
254
255 // EOF
256