]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBoxController.cxx
Feature #1347
[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 printf("EED GBoxController::OnLeftButtonDown \n");
99                 int state  = _view->getState();
100
101                 //Evaluate new state
102                 if(state == HIGHLIGHTED)
103                 {
104                     ok=false;
105                         _isLeftClickDown=true;
106                         _view->setState(SELECTED);
107                         _model->notifyObservers(getId(),ADD_TO_SELECTED);
108                 }
109                 return ok;
110
111         }
112
113         //=========================================================================
114
115         bool GBoxController::OnLeftButtonUp()
116         {
117                 int X,Y;
118                 wxVTKRenderWindowInteractor *wxVTKiren;
119                 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
120                 wxVTKiren->GetEventPosition(X,Y);
121
122                 int state  = _view->getState();
123                 //Evaluate new state
124                 if(_isLeftClickDown)
125                 {
126                         _isLeftClickDown=false;
127                         if(_view->isPointInside(X,Y))
128                         {
129                                 // It is supposed that I'm always inside even if the box is in drag
130                                 _view->setState(SELECTED);
131                                 _model->notifyObservers(getId());
132                         }
133                 }
134         return true;
135
136         }
137
138         //=========================================================================
139
140         bool GBoxController::OnRightButtonUp()
141         {
142                 return true;
143         }
144
145         //=========================================================================
146
147         bool GBoxController::OnMiddleButtonDown()
148         {
149                 return true;
150         }
151
152         //=========================================================================
153
154 }  // EO namespace bbtk
155
156 // EOF
157