]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.cxx
#3252Select mechanism of boxes
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsVtkGUIEditorGraphic / GObjectController.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::GObjectController
59  */
60
61
62 #include "GObjectController.h"
63
64
65 #ifdef _DEBUG
66 #define new DEBUG_NEW
67 #endif
68 namespace bbtk
69 {
70     //=========================================================================
71
72     GObjectController::GObjectController( ) {
73
74     }
75
76     //=========================================================================
77
78     GObjectController::~GObjectController( ) {
79     }
80
81     //=========================================================================
82
83     void GObjectController::setModelAndView( GObjectModel* model , vtkGObjectView* view ) {
84         _model = model ;
85         _view = view ;
86     }
87
88     //=========================================================================
89
90     bool GObjectController::OnMouseMove( )
91     {
92         int X , Y ;
93         crea::wxVTKRenderWindowInteractor *_wxVTKiren ;
94         _wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView( )->GetWxVTKRenderWindowInteractor( ) ;
95         _wxVTKiren->GetEventPosition( X , Y ) ;
96         int state = _view->getState( ) ;
97
98         //Evaluate new state
99         if ( state == NOTHING_HAPPENS )
100         {
101             if ( _view->isPointInside( X , Y ) )
102             {
103                 _view->setState( HIGHLIGHTED ) ;
104             }
105         }
106         if ( state == HIGHLIGHTED )
107         {
108             if ( !_view->isPointInside( X , Y ) )
109             {
110                 _view->setState( NOTHING_HAPPENS ) ;
111             }
112         }
113
114         // JGRR & CM WH
115
116         if ( state == POSSIBLE_CONNECTION )
117         {
118             if ( _view->isPointInside( X , Y ) )
119             {
120                 _view->setState( SELECTED_POSSIBLE_CONNECTION ) ;
121             }
122         }
123
124         if ( state == SELECTED_POSSIBLE_CONNECTION )
125         {
126             if ( !_view->isPointInside( X , Y ) )
127             {
128                 _view->setState( POSSIBLE_CONNECTION ) ;
129             }
130         }
131
132         // EO JGRR & CM WH
133
134         _model->notifyObservers( getId( ) ) ;
135
136
137         return true ;
138     }
139
140     //=========================================================================
141
142     bool GObjectController::OnLeftButtonDown( )//virtual
143     {
144         int state = _view->getState( ) ;
145
146         //Evaluate new state
147         if ( state == HIGHLIGHTED ) {
148             _isLeftClickDown = true ;
149             _view->setState( SELECTED ) ;
150         }
151         return true ;
152     }
153
154     //=========================================================================
155
156     bool GObjectController::OnLeftButtonUp( )//virtual
157     {
158         return true ;
159     }
160
161     //=========================================================================
162
163     bool GObjectController::OnLeftDClick( )//virtual
164     {
165
166         return true ;
167     }
168
169     //=========================================================================
170
171     bool GObjectController::OnMiddleButtonDown( )//virtual
172     {
173         return true ;
174     }
175
176     //=========================================================================
177
178     void GObjectController::moveObject( int X , int Y ) {
179         _view->moveObject( X , Y ) ;
180     }
181
182     //=========================================================================
183
184     int GObjectController::getGObjectType( ) {
185         return _model->getGObjectType( ) ;
186     }
187
188     //=========================================================================
189
190     GObjectModel* GObjectController::getModel( ) {
191         return _model ;
192     }
193
194     //=========================================================================
195
196     vtkGObjectView* GObjectController::getView( ) {
197         return _view ;
198     }
199
200     //=========================================================================
201
202     int GObjectController::getId( ) {
203         return _model->getObjectId( ) ;
204     }
205
206     //=========================================================================
207
208     void GObjectController::setId( int id ) {
209         _model->setObjectId( id ) ;
210     }
211
212     //=========================================================================
213
214     std::string GObjectController::getStatusText( ) {
215         return _model->getStatusText( ) ;
216     }
217
218     //=========================================================================
219
220     void GObjectController::removeFromScene( ) {
221         _view->removeFromScene( ) ;
222     }
223
224     //=========================================================================
225
226 } // EO namespace bbtk
227
228 // EOF
229