]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBoxController.cxx
Feature #1771 Add licence terms for all files.
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsVtkGUIEditorGraphic / GBoxController.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::GBoxController
59 */
60
61
62 #include "GBoxController.h"
63
64 #ifdef _DEBUG
65 #define new DEBUG_NEW
66 #endif
67 namespace bbtk
68 {
69
70
71         //=========================================================================
72         GBoxController::GBoxController()
73         {
74
75         }
76
77         //=========================================================================
78         GBoxController::~GBoxController()
79         {
80         }
81         //=========================================================================
82
83         bool GBoxController::OnMouseMove()
84         {
85
86                 if ( _vtkInteractorStyleBaseView!=NULL)
87                 {
88                         int X,Y;
89                         wxVTKRenderWindowInteractor *_wxVTKiren;
90                         _wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
91                         _wxVTKiren->GetEventPosition( X , Y );
92
93                         int state  = _view->getState();
94
95                         //Evaluate new state
96
97                         if(state == NOTHING_HAPPENS)
98                         {
99                                 if(_view->isPointInside(X,Y))
100                                 {
101                                         _view->setState(HIGHLIGHTED);
102                                 }
103                         }
104                         if( state==HIGHLIGHTED)
105                         {
106                                 if(!_view->isPointInside(X,Y))
107                                 {
108                                         _view->setState(NOTHING_HAPPENS);
109                                 }
110                         }
111
112                         _model->notifyObservers(getId());
113
114                 }
115                 return true;
116         }
117
118         //=========================================================================
119
120         bool GBoxController::OnLeftButtonDown()
121         {
122             bool ok=true;
123                 int state  = _view->getState();
124
125                 //Evaluate new state
126                 if(state == HIGHLIGHTED)
127                 {
128                     ok=false;
129                         _isLeftClickDown=true;
130                         _view->setState(SELECTED);
131                         _model->notifyObservers(getId(),ADD_TO_SELECTED);
132                 }
133                 return ok;
134
135         }
136
137         //=========================================================================
138
139         bool GBoxController::OnLeftButtonUp()
140         {
141                 int X,Y;
142                 wxVTKRenderWindowInteractor *wxVTKiren;
143                 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
144                 wxVTKiren->GetEventPosition(X,Y);
145
146                 int state  = _view->getState();
147                 //Evaluate new state
148                 if(_isLeftClickDown)
149                 {
150                         _isLeftClickDown=false;
151                         if(_view->isPointInside(X,Y))
152                         {
153                                 // It is supposed that I'm always inside even if the box is in drag
154                                 _view->setState(SELECTED);
155                                 _model->notifyObservers(getId());
156                         }
157                 }
158         return true;
159
160         }
161
162         //=========================================================================
163
164         bool GBoxController::OnRightButtonUp()
165         {
166                 return true;
167         }
168
169         //=========================================================================
170
171         bool GBoxController::OnMiddleButtonDown()
172         {
173                 return true;
174         }
175
176         //=========================================================================
177
178 }  // EO namespace bbtk
179
180 // EOF
181