]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx
#3252Select mechanism of boxes
[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         //=========================================================================
84         bool GBlackBoxController::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                                                 return true; // to avoid to redraw all if nothing
101                         } // state
102                         if( state==HIGHLIGHTED)
103                         {
104                                 if(!_view->isPointInside(X,Y))
105                                 {
106                                         _view->setState(NOTHING_HAPPENS);
107                                 }
108                         } // state
109 //                      if ((state==DRAG) && (_isLeftClickDown==true) )
110 //                      {
111 //                          _objHasBeenMoved=true;
112 //                      } // state
113                         _model->notifyObservers(getId());
114                 }
115                 return true;
116         }
117 */
118
119         //=========================================================================
120
121 /*
122         bool GBlackBoxController::OnLeftButtonDown()
123         {
124 //              _objHasBeenMoved = false;
125                 _isLeftClickDown = true;
126         bool ok=true;
127                 int X,Y;
128                 crea::wxVTKRenderWindowInteractor *_wxVTKiren;
129                 _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
130                 _wxVTKiren->GetEventPosition( X , Y );
131                 int state  = _view->getState();
132                 //Evaluate new state
133                 if(_view->isPointInside(X,Y))
134         {
135     //          if(state == HIGHLIGHTED)
136     //EED3oct2010               if ( (state == HIGHLIGHTED) && (ctrlkey==1  ) )
137             if(state == SELECTED)
138             {
139                 _view->setState(NOTHING_HAPPENS);
140                 _model->notifyObservers(getId(),REMOVE_FROM_SELECTED);
141             } else {
142                 ok=false;
143                 _view->setState(SELECTED);
144                 _model->notifyObservers(getId(),ADD_TO_SELECTED);
145             }
146         } // EED 2022-09-16
147                 int shiftkey            = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey();
148                 int ctrlkey             = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
149                 ctrlkey = ctrlkey + shiftkey;
150                 if ( (state==DRAG) && (ctrlkey==1) &&  (_view->isPointInside(X,Y)==true) )
151                 {
152                         _view->setState(NOTHING_HAPPENS);
153                         _model->notifyObservers(getId(),REMOVE_FROM_SELECTED);
154                 }
155                 return ok;
156         }
157 */
158
159 /*
160         //=========================================================================
161         bool GBlackBoxController::OnLeftButtonUp()
162         {
163         _isLeftClickDown    = false;
164                 int state           = _view->getState();
165                 int shiftkey        = _vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey();
166                 int ctrlkey         = _vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
167                 ctrlkey = ctrlkey + shiftkey;
168 //EED 12/07/2012                
169 //              if ( (state==SELECTED) && (ctrlkey==0) && (_objHasBeenMoved==false))
170 //              {
171 //                      _view->setState(NOTHING_HAPPENS);
172 //                      _model->notifyObservers(getId(),REMOVE_FROM_SELECTED);
173 //              }
174                 return true;
175         }
176 */
177
178         //=========================================================================
179         bool GBlackBoxController::OnRightButtonUp()
180         {
181                 return true;
182         }
183
184         //=========================================================================
185         bool GBlackBoxController::OnMiddleButtonDown()
186         {
187                 int X,Y;
188                 crea::wxVTKRenderWindowInteractor *wxVTKiren;
189                 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
190                 wxVTKiren->GetEventPosition(X,Y);
191 //              int state  = _view->getState();
192                 //Evaluate new state
193                 if(_view->isPointInside(X,Y))
194                 {
195                         GBlackBoxModel *bbmodel = (GBlackBoxModel*)_model;
196                         _view->setState(HIGHLIGHTED);
197                         if(bbmodel->isExecutable())
198                         {
199                                 bbmodel->setExecutable(false);
200                         } else {
201                                 bbmodel->setExecutable(true);
202                         }
203                         bbmodel->notifyObservers(getId());
204                 }
205                 return true;
206         }
207
208         //=========================================================================
209
210 }  // EO namespace bbtk
211
212 // EOF
213