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