]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx
*** empty log message ***
[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 printf("EED GBlackBoxController::OnMouseMove START \n");
59
60                 if ( _vtkInteractorStyleBaseView!=NULL)
61                 {
62                         int X,Y;
63                         wxVTKRenderWindowInteractor *_wxVTKiren;
64                         _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
65                         _wxVTKiren->GetEventPosition( X , Y );
66
67                         int state  = _view->getState();
68
69                         //Evaluate new state
70
71                         if(state == NOTHING_HAPPENS)
72                         {
73                                 if(_view->isPointInside(X,Y))
74                                 {
75                                         _view->setState(HIGHLIGHTED);
76                                 }
77                         } // state
78
79                         if( state==HIGHLIGHTED)
80                         {
81                                 if(!_view->isPointInside(X,Y))
82                                 {
83                                         _view->setState(NOTHING_HAPPENS);
84                                 }
85                         } // state
86
87
88                         if ((state==DRAG) && (_isLeftClickDown==true) )
89                         {
90                             _objHasBeenMoved=true;
91                         } // state
92
93 printf("EED GBlackBoxController::OnMouseMove state=%d\n", state);
94                         _model->notifyObservers(getId());
95
96                 }
97                 return true;
98         }
99
100         //=========================================================================
101
102         bool GBlackBoxController::OnLeftButtonDown()
103         {
104                 _objHasBeenMoved = false;
105                 _isLeftClickDown = true;
106         bool ok=true;
107                 int state  = _view->getState();
108 printf("EED GBlackBoxController::OnLeftButtonDown state=%d \n", state);
109                 //Evaluate new state
110                 if(state == HIGHLIGHTED)
111 //EED3oct2010           if ( (state == HIGHLIGHTED) && (ctrlkey==1  ) )
112                 {
113                     ok=false;
114                         _view->setState(SELECTED);
115                         _model->notifyObservers(getId(),ADD_TO_SELECTED);
116                 }
117
118
119
120                 int X,Y;
121                 wxVTKRenderWindowInteractor *wxVTKiren;
122                 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
123                 wxVTKiren->GetEventPosition(X,Y);
124         int ctrlkey=_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
125                 if ( (state==DRAG) && (ctrlkey==1) &&  (_view->isPointInside(X,Y)==true) )
126                 {
127                         _view->setState(NOTHING_HAPPENS);
128                         _model->notifyObservers(getId(),REMOVE_FROM_SELECTED);
129                 }
130
131 printf("EED GBlackBoxController::OnLeftButtonDown END\n" );
132
133                 return ok;
134
135         }
136
137         //=========================================================================
138
139         bool GBlackBoxController::OnLeftButtonUp()
140         {
141         _isLeftClickDown    = false;
142                 int state           = _view->getState();
143 printf("EED GBlackBoxController::OnLeftButtonUp START state=%d \n", state);
144
145                 //Evaluate new state
146
147 //EED Borrame
148 //              int X,Y;
149 //              wxVTKRenderWindowInteractor *wxVTKiren;
150 //              wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
151 //              wxVTKiren->GetEventPosition(X,Y);
152 //              if(_isLeftClickDown)
153 //              {
154 //                      _isLeftClickDown=false;
155 //                      if(_view->isPointInside(X,Y))
156 //                      {
157                                 // It is supposed that I'm always inside even if the box is in drag
158 //                              _view->setState(SELECTED);
159 //                              _model->notifyObservers(getId());
160 //                      }
161 //              }
162
163
164
165         int ctrlkey=_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey();
166
167                 if ( (state==SELECTED) && (ctrlkey==0) && (_objHasBeenMoved==false))
168                 {
169                         _view->setState(NOTHING_HAPPENS);
170                         _model->notifyObservers(getId(),REMOVE_FROM_SELECTED);
171                 }
172
173
174 printf("EED GBlackBoxController::OnLeftButtonUp END state=%d \n", state);
175
176                 return true;
177
178         }
179
180         //=========================================================================
181
182         bool GBlackBoxController::OnRightButtonUp()
183         {
184                 return true;
185         }
186
187         //=========================================================================
188
189         bool GBlackBoxController::OnMiddleButtonDown()
190         {
191                 int X,Y;
192                 wxVTKRenderWindowInteractor *wxVTKiren;
193                 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
194                 wxVTKiren->GetEventPosition(X,Y);
195
196                 int state  = _view->getState();
197
198                 //Evaluate new state
199                 if(_view->isPointInside(X,Y))
200                 {
201                         GBlackBoxModel *bbmodel = (GBlackBoxModel*)_model;
202                         _view->setState(HIGHLIGHTED);
203                         if(bbmodel->isExecutable())
204                         {
205                                 bbmodel->setExecutable(false);
206                         }
207                         else
208                         {
209                                 bbmodel->setExecutable(true);
210                         }
211                         bbmodel->notifyObservers(getId());
212                 }
213
214                 return true;
215         }
216
217         //=========================================================================
218
219 }  // EO namespace bbtk
220
221 // EOF
222