]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GBlackBoxController.cxx
Implemented deleting of boxes from the scene....
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsVtkGUIEditorGraphic / GBlackBoxController.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::GBlackBoxController 
34 */
35
36
37 #include "GBlackBoxController.h"
38
39 namespace bbtk
40 {
41
42
43         //=========================================================================
44         GBlackBoxController::GBlackBoxController()
45         {
46                 
47         }
48
49         //=========================================================================
50         GBlackBoxController::~GBlackBoxController()
51         {
52         }
53         //=========================================================================
54
55         bool GBlackBoxController::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 GBlackBoxController::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 GBlackBoxController::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                         
118                 //Evaluate new state
119                 if(_isLeftClickDown)
120                 {
121                         _isLeftClickDown=false;
122                         if(_view->isPointInside(X,Y))
123                         {
124                                 // It is supposed that I'm always inside even if the box is in drag
125                                 _view->setState(SELECTED);
126                                 _model->notifyObservers(getId());
127                         }
128                 }
129                 return true;
130                 
131         }
132         
133         //=========================================================================
134         
135         bool GBlackBoxController::OnLeftDClick()
136         {
137                 
138                 return true;
139         }
140         
141         //=========================================================================
142         
143         bool GBlackBoxController::OnRightButtonUp()
144         {
145                 GBlackBoxModel *bbmodel = (GBlackBoxModel*)_model;
146                 if(bbmodel->isExecutable())
147                 {
148                         bbmodel->setExecutable(false);
149                 }
150                 
151                 return true;
152         }
153
154         //=========================================================================
155
156         bool GBlackBoxController::OnMiddleButtonDown()
157         {
158                 int X,Y;
159                 wxVTKRenderWindowInteractor *wxVTKiren;
160                 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
161                 wxVTKiren->GetEventPosition(X,Y);
162
163                 int state  = _view->getState();
164
165                 //Evaluate new state
166                 if(_view->isPointInside(X,Y))
167                 {
168                         GBlackBoxModel *bbmodel = (GBlackBoxModel*)_model;
169                         _view->setState(HIGHLIGHTED);
170                         bbmodel->setExecutable(true);
171                         bbmodel->notifyObservers(getId());
172                 }
173                         
174                 return true;
175         }
176
177         //=========================================================================
178
179 }  // EO namespace bbtk
180
181 // EOF
182