]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx
Stable version ... The connection is correctly painted :)
[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  = _view->getState();
66                         
67                         //Evaluate new state
68                         if( state == DRAG)
69                         {
70                                 moveObject(X,Y);
71                         }
72
73                         if(state == NOTHING_HAPPENS)
74                         {
75                                 if(_view->isPointInside(X,Y))
76                                 {
77                                         _view->setState(HIGHLIGHTED);           
78                                 }                       
79                         }
80                         if( state==HIGHLIGHTED)
81                         {
82                                 if(!_view->isPointInside(X,Y))
83                                 {
84                                         _view->setState(NOTHING_HAPPENS);
85                                 }
86                         }
87                         
88                         _model->notifyObservers(_id);
89                         
90                 }
91                 return true;
92         }
93
94         //=========================================================================
95         
96         bool GBlackBoxController::OnLeftButtonDown()
97         {
98                 
99                 if ( _vtkInteractorStyleBaseView!=NULL )
100                 {
101                         int X,Y;
102                         wxVTKRenderWindowInteractor *wxVTKiren;
103                         wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
104                         wxVTKiren->GetEventPosition(X,Y);
105
106                         int state  = _view->getState();
107                         
108                         //Evaluate new state
109                         if( state==HIGHLIGHTED)
110                         {
111                                 _view->isStartDragging(true);
112                                 _view->setState(DRAG);
113                         }
114
115                         if(  state == SELECTED)
116                         {
117                                 if(_view->isPointInside(X,Y))
118                                 {
119                                         _view->isStartDragging(true);
120                                         _view->setState(DRAG);
121                                 }       
122                         }
123                         
124                         _model->notifyObservers(_id);
125                 }
126                 return true;
127         }
128
129         //=========================================================================
130         
131         bool GBlackBoxController::OnLeftButtonUp()
132         {
133                 if ( _vtkInteractorStyleBaseView!=NULL )
134                 {
135                         int X,Y;
136                         wxVTKRenderWindowInteractor *wxVTKiren;
137                         wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
138                         wxVTKiren->GetEventPosition(X,Y);
139
140                         int state  = _view->getState();
141                         
142                         //Evaluate new state
143                         if(state==CLICKED)
144                         {
145                                 _view->setState(SELECTED);
146                         }
147
148                         if( state == DRAG)
149                         {
150                                 _view->setState(SELECTED);
151                         }
152
153                         _model->notifyObservers(_id);
154
155                 }
156                 return true;
157         }
158         
159         //=========================================================================
160         
161         bool GBlackBoxController::OnLeftDClick()
162         {
163                 if ( _vtkInteractorStyleBaseView!=NULL )
164                 {
165                         int X,Y;
166                         wxVTKRenderWindowInteractor *wxVTKiren;
167                         wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
168                         wxVTKiren->GetEventPosition(X,Y);
169
170                         _model->notifyObservers(_id);
171                 }
172                 return true;
173         }
174         
175         //=========================================================================
176         
177         bool GBlackBoxController::OnRightButtonDown()
178         {
179                 if( _vtkInteractorStyleBaseView!= NULL )
180                 {
181                         int X,Y;
182                         wxVTKRenderWindowInteractor *wxVTKiren;
183                         wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
184                         wxVTKiren->GetEventPosition(X, Y);
185                         
186                         int state  = _view->getState();
187                         
188                         //Evaluate new state
189                         if(  state == SELECTED)
190                         {
191                                 _view->setState(NOTHING_HAPPENS);
192                         }
193
194                         _model->notifyObservers(_id);
195                 }
196                 return true;
197         }
198
199         //=========================================================================
200
201 }  // EO namespace bbtk
202
203 // EOF
204