]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBoxController.cxx
f5d9e7b29881fecfd7602fdb2c14815f71103d1b
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsVtkGUIEditorGraphic / GBoxController.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::GBoxController
34 */
35
36
37 #include "GBoxController.h"
38
39 #ifdef _DEBUG
40 #define new DEBUG_NEW
41 #endif
42 namespace bbtk
43 {
44
45
46         //=========================================================================
47         GBoxController::GBoxController()
48         {
49
50         }
51
52         //=========================================================================
53         GBoxController::~GBoxController()
54         {
55         }
56         //=========================================================================
57
58         bool GBoxController::OnMouseMove()
59         {
60
61                 if ( _vtkInteractorStyleBaseView!=NULL)
62                 {
63                         int X,Y;
64                         wxVTKRenderWindowInteractor *_wxVTKiren;
65                         _wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
66                         _wxVTKiren->GetEventPosition( X , Y );
67
68                         int state  = _view->getState();
69
70                         //Evaluate new state
71
72                         if(state == NOTHING_HAPPENS)
73                         {
74                                 if(_view->isPointInside(X,Y))
75                                 {
76                                         _view->setState(HIGHLIGHTED);
77                                 }
78                         }
79                         if( state==HIGHLIGHTED)
80                         {
81                                 if(!_view->isPointInside(X,Y))
82                                 {
83                                         _view->setState(NOTHING_HAPPENS);
84                                 }
85                         }
86
87                         _model->notifyObservers(getId());
88
89                 }
90                 return true;
91         }
92
93         //=========================================================================
94
95         bool GBoxController::OnLeftButtonDown()
96         {
97             bool ok=true;
98                 int state  = _view->getState();
99
100                 //Evaluate new state
101                 if(state == HIGHLIGHTED)
102                 {
103                     ok=false;
104                         _isLeftClickDown=true;
105                         _view->setState(SELECTED);
106                         _model->notifyObservers(getId(),ADD_TO_SELECTED);
107                 }
108                 return ok;
109
110         }
111
112         //=========================================================================
113
114         bool GBoxController::OnLeftButtonUp()
115         {
116                 int X,Y;
117                 wxVTKRenderWindowInteractor *wxVTKiren;
118                 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
119                 wxVTKiren->GetEventPosition(X,Y);
120
121                 int state  = _view->getState();
122                 //Evaluate new state
123                 if(_isLeftClickDown)
124                 {
125                         _isLeftClickDown=false;
126                         if(_view->isPointInside(X,Y))
127                         {
128                                 // It is supposed that I'm always inside even if the box is in drag
129                                 _view->setState(SELECTED);
130                                 _model->notifyObservers(getId());
131                         }
132                 }
133         return true;
134
135         }
136
137         //=========================================================================
138
139         bool GBoxController::OnRightButtonUp()
140         {
141                 return true;
142         }
143
144         //=========================================================================
145
146         bool GBoxController::OnMiddleButtonDown()
147         {
148                 return true;
149         }
150
151         //=========================================================================
152
153 }  // EO namespace bbtk
154
155 // EOF
156