]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx
#3132 bbGEditor Feature New Normal - branch changeWx28to30 compilation with wxWidgets3
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsVtkGUIEditorGraphic / GBlackBoxController.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::GBlackBoxController
59 */
60
61
62 #include "GBlackBoxController.h"
63
64 #ifdef _DEBUG
65 #define new DEBUG_NEW
66 #endif
67 namespace bbtk
68 {
69
70
71         //=========================================================================
72         GBlackBoxController::GBlackBoxController()
73         {
74
75         }
76
77         //=========================================================================
78         GBlackBoxController::~GBlackBoxController()
79         {
80         }
81         //=========================================================================
82
83         bool GBlackBoxController::OnMouseMove()
84         {
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
93                         int state  = _view->getState();
94
95                         //Evaluate new state
96
97                         if(state == NOTHING_HAPPENS)
98                         {
99                                 if(_view->isPointInside(X,Y))
100                                 {
101                                         _view->setState(HIGHLIGHTED);
102                                 }
103                                                 return true; // to avoid to redraw all if nothing
104                         } // state
105
106                         if( state==HIGHLIGHTED)
107                         {
108                                 if(!_view->isPointInside(X,Y))
109                                 {
110                                         _view->setState(NOTHING_HAPPENS);
111                                 }
112                         } // state
113
114
115                         if ((state==DRAG) && (_isLeftClickDown==true) )
116                         {
117                             _objHasBeenMoved=true;
118                         } // state
119
120                         _model->notifyObservers(getId());
121
122                 }
123                 return true;
124         }
125
126         //=========================================================================
127
128         bool GBlackBoxController::OnLeftButtonDown()
129         {
130                 _objHasBeenMoved = false;
131                 _isLeftClickDown = true;
132         bool ok=true;
133                 
134                 int X,Y;
135                 crea::wxVTKRenderWindowInteractor *_wxVTKiren;
136                 _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
137                 _wxVTKiren->GetEventPosition( X , Y );
138                 
139                 
140                 
141                 int state  = _view->getState();
142                 //Evaluate new state
143                 
144                 if(_view->isPointInside(X,Y))
145                 
146 //              if(state == HIGHLIGHTED)
147 //EED3oct2010           if ( (state == HIGHLIGHTED) && (ctrlkey==1  ) )
148                         
149                 if(state == SELECTED)
150                 {
151                         _view->setState(NOTHING_HAPPENS);
152                         _model->notifyObservers(getId(),REMOVE_FROM_SELECTED);
153                 } else {
154                     ok=false;
155                         _view->setState(SELECTED);
156                         _model->notifyObservers(getId(),ADD_TO_SELECTED);
157                 }
158                 
159                 
160                 int shiftkey            = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey();
161                 int ctrlkey             = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
162                 ctrlkey = ctrlkey + shiftkey;
163                 
164                 
165                 if ( (state==DRAG) && (ctrlkey==1) &&  (_view->isPointInside(X,Y)==true) )
166                 {
167                         _view->setState(NOTHING_HAPPENS);
168                         _model->notifyObservers(getId(),REMOVE_FROM_SELECTED);
169                 }
170
171                 return ok;
172         }
173
174         //=========================================================================
175         bool GBlackBoxController::OnLeftButtonUp()
176         {
177         _isLeftClickDown    = false;
178                 int state           = _view->getState();
179                 int shiftkey        = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey();
180                 int ctrlkey         = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
181                 ctrlkey = ctrlkey + shiftkey;
182 //EED 12/07/2012                
183 //              if ( (state==SELECTED) && (ctrlkey==0) && (_objHasBeenMoved==false))
184 //              {
185 //                      _view->setState(NOTHING_HAPPENS);
186 //                      _model->notifyObservers(getId(),REMOVE_FROM_SELECTED);
187 //              }
188                 return true;
189         }
190
191         //=========================================================================
192         bool GBlackBoxController::OnRightButtonUp()
193         {
194                 return true;
195         }
196
197         //=========================================================================
198         bool GBlackBoxController::OnMiddleButtonDown()
199         {
200                 int X,Y;
201                 crea::wxVTKRenderWindowInteractor *wxVTKiren;
202                 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
203                 wxVTKiren->GetEventPosition(X,Y);
204 //              int state  = _view->getState();
205                 //Evaluate new state
206                 if(_view->isPointInside(X,Y))
207                 {
208                         GBlackBoxModel *bbmodel = (GBlackBoxModel*)_model;
209                         _view->setState(HIGHLIGHTED);
210                         if(bbmodel->isExecutable())
211                         {
212                                 bbmodel->setExecutable(false);
213                         } else {
214                                 bbmodel->setExecutable(true);
215                         }
216                         bbmodel->notifyObservers(getId());
217                 }
218                 return true;
219         }
220
221         //=========================================================================
222
223 }  // EO namespace bbtk
224
225 // EOF
226