]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.cxx
Feature #1771 Add licence terms for all files.
[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         int X , Y ;
92         wxVTKRenderWindowInteractor *_wxVTKiren ;
93         _wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView( )->GetWxVTKRenderWindowInteractor( ) ;
94         _wxVTKiren->GetEventPosition( X , Y ) ;
95         int state = _view->getState( ) ;
96
97
98         //Evaluate new state
99         if ( state == NOTHING_HAPPENS ) {
100             if ( _view->isPointInside( X , Y ) ) {
101                 _view->setState( HIGHLIGHTED ) ;
102             }
103         }
104         if ( state == HIGHLIGHTED ) {
105             if ( !_view->isPointInside( X , Y ) ) {
106                 _view->setState( NOTHING_HAPPENS ) ;
107             }
108         }
109
110         // JGRR & CM WH
111
112         if ( state == POSSIBLE_CONNECTION ) {
113             if ( _view->isPointInside( X , Y ) ) {
114                 _view->setState( SELECTED_POSSIBLE_CONNECTION ) ;
115             }
116         }
117
118         if ( state == SELECTED_POSSIBLE_CONNECTION ) {
119             if ( !_view->isPointInside( X , Y ) ) {
120                 _view->setState( POSSIBLE_CONNECTION ) ;
121             }
122         }
123
124         // EO JGRR & CM WH
125
126         _model->notifyObservers( getId( ) ) ;
127
128
129         return true ;
130     }
131
132     //=========================================================================
133
134     bool GObjectController::OnLeftButtonDown( )//virtual
135     {
136         int state = _view->getState( ) ;
137
138         //Evaluate new state
139         if ( state == HIGHLIGHTED ) {
140             _isLeftClickDown = true ;
141             _view->setState( SELECTED ) ;
142         }
143         return true ;
144     }
145
146     //=========================================================================
147
148     bool GObjectController::OnLeftButtonUp( )//virtual
149     {
150         return true ;
151     }
152
153     //=========================================================================
154
155     bool GObjectController::OnLeftDClick( )//virtual
156     {
157
158         return true ;
159     }
160
161     //=========================================================================
162
163     bool GObjectController::OnMiddleButtonDown( )//virtual
164     {
165         return true ;
166     }
167
168     //=========================================================================
169
170     void GObjectController::moveObject( int X , int Y ) {
171         _view->moveObject( X , Y ) ;
172     }
173
174     //=========================================================================
175
176     int GObjectController::getGObjectType( ) {
177         return _model->getGObjectType( ) ;
178     }
179
180     //=========================================================================
181
182     GObjectModel* GObjectController::getModel( ) {
183         return _model ;
184     }
185
186     //=========================================================================
187
188     vtkGObjectView* GObjectController::getView( ) {
189         return _view ;
190     }
191
192     //=========================================================================
193
194     int GObjectController::getId( ) {
195         return _model->getObjectId( ) ;
196     }
197
198     //=========================================================================
199
200     void GObjectController::setId( int id ) {
201         _model->setObjectId( id ) ;
202     }
203
204     //=========================================================================
205
206     std::string GObjectController::getStatusText( ) {
207         return _model->getStatusText( ) ;
208     }
209
210     //=========================================================================
211
212     void GObjectController::removeFromScene( ) {
213         _view->removeFromScene( ) ;
214     }
215
216     //=========================================================================
217
218 } // EO namespace bbtk
219
220 // EOF
221