]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GObjectController.cxx
Feature #1347
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsVtkGUIEditorGraphic / GObjectController.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::GObjectController
34 */
35
36
37 #include "GObjectController.h"
38
39 #ifdef _DEBUG
40 #define new DEBUG_NEW
41 #endif
42 namespace bbtk
43 {
44
45
46         //=========================================================================
47         GObjectController::GObjectController()
48         {
49
50         }
51
52         //=========================================================================
53
54         GObjectController::~GObjectController()
55         {
56         }
57
58         //=========================================================================
59
60         void GObjectController::setModelAndView(GObjectModel* model, vtkGObjectView* view)
61         {
62                 _model = model;
63                 _view = view;
64         }
65
66         //=========================================================================
67
68         bool GObjectController::OnMouseMove()
69         {
70                 int X,Y;
71                 wxVTKRenderWindowInteractor *_wxVTKiren;
72                 _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
73                 _wxVTKiren->GetEventPosition( X , Y );
74                 int state  = _view->getState();
75
76                 //Evaluate new state
77                 if( state == NOTHING_HAPPENS)
78                 {
79                         if(_view->isPointInside(X,Y))
80                         {
81                                 _view->setState(HIGHLIGHTED);
82                         }
83                 }
84                 if( state==HIGHLIGHTED)
85                 {
86                         if(!_view->isPointInside(X,Y))
87                         {
88                                 _view->setState(NOTHING_HAPPENS);
89                         }
90                 }
91
92                 //_model->notifyObservers(getId());
93
94
95                 return true;
96         }
97
98         //=========================================================================
99
100         bool GObjectController::OnLeftButtonDown()//virtual
101         {
102                 int state  = _view->getState();
103
104                 //Evaluate new state
105                 if(state == HIGHLIGHTED)
106                 {
107                         _isLeftClickDown=true;
108                         _view->setState(SELECTED);
109                 }
110                 return true;
111         }
112
113         //=========================================================================
114
115         bool GObjectController::OnLeftButtonUp()//virtual
116         {
117                 return true;
118         }
119
120         //=========================================================================
121
122         bool GObjectController::OnLeftDClick()//virtual
123         {
124
125                 return true;
126         }
127
128         //=========================================================================
129
130         bool GObjectController::OnMiddleButtonDown()//virtual
131         {
132                 return true;
133         }
134
135         //=========================================================================
136
137         void GObjectController::moveObject(int X,int Y)
138         {
139                 _view->moveObject(X,Y);
140         }
141
142         //=========================================================================
143
144         int GObjectController::getGObjectType()
145         {
146                 return _model->getGObjectType();
147         }
148
149         //=========================================================================
150
151         GObjectModel* GObjectController::getModel()
152         {
153                 return _model;
154         }
155
156         //=========================================================================
157
158         vtkGObjectView* GObjectController::getView()
159         {
160                 return _view;
161         }
162
163         //=========================================================================
164
165         int GObjectController::getId()
166         {
167                 return _model->getObjectId();
168         }
169
170         //=========================================================================
171
172         void GObjectController::setId(int id)
173         {
174                 _model->setObjectId(id);
175         }
176
177         //=========================================================================
178
179         std::string GObjectController::getStatusText()
180         {
181                 return _model->getStatusText();
182         }
183
184         //=========================================================================
185
186         void GObjectController::removeFromScene()
187         {
188                 _view->removeFromScene();
189         }
190
191         //=========================================================================
192
193 }  // EO namespace bbtk
194
195 // EOF
196