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