]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.cxx
no message
[bbtkGEditor.git] / lib / EditorGraphicBBS / bbsVtkGUIEditorGraphic / GConnectorController.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::GConnectorController
34 */
35
36
37 #include "GConnectorController.h"
38
39 namespace bbtk
40 {
41
42
43         //=========================================================================
44         GConnectorController::GConnectorController()
45         {
46
47         }
48
49         //=========================================================================
50
51         GConnectorController::~GConnectorController()
52         {
53         }
54
55         //=========================================================================
56
57         bool GConnectorController::OnMouseMove()
58         {
59
60                 if ( _vtkInteractorStyleBaseView!=NULL)
61                 {
62                         int X,Y;
63                         wxVTKRenderWindowInteractor *_wxVTKiren;
64                         _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
65                         _wxVTKiren->GetEventPosition( X , Y );
66
67                         if ( (_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==0) &&(_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==0) )
68                         {
69                                 _controller->MouseMove(X,Y);
70                         }
71
72                 }
73                 return true;
74         }
75
76         //=========================================================================
77
78         bool GConnectorController::OnLeftButtonDown()
79         {
80
81                 if ( _vtkInteractorStyleBaseView!=NULL )
82                 {
83                         int X,Y;
84                         wxVTKRenderWindowInteractor *wxVTKiren;
85                         wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
86                         wxVTKiren->GetEventPosition(X,Y);
87
88                         _controller->SetKeyBoardMoving( false );
89                         _controller->MouseClickLeft(X,Y);
90
91                 }
92                 return true;
93         }
94
95         //=========================================================================
96
97         bool GConnectorController::OnLeftButtonUp()
98         {
99                 if( _vtkInteractorStyleBaseView!= NULL )
100                 {
101                         int X,Y;
102                         wxVTKRenderWindowInteractor *wxVTKiren;
103                         wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
104                         wxVTKiren->GetEventPosition(X, Y);
105
106                         _controller->MouseReleaseLeft(X,Y);
107                         if(_controller->GetManualViewBaseContour()->GetSelected()==true)
108                         {
109                                 _view->setState(SELECTED);
110                                 _model->notifyObservers(getId(),ADD_TO_SELECTED);
111                         }
112
113                 }
114                 return true;
115
116         }
117
118         //=========================================================================
119
120         bool GConnectorController::OnLeftDClick()
121         {
122
123                 if ( _vtkInteractorStyleBaseView!=NULL )
124                 {
125                         int X,Y;
126                         wxVTKRenderWindowInteractor *wxVTKiren;
127                         wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
128                         wxVTKiren->GetEventPosition(X,Y);
129
130                         _controller->MouseDLeft(X,Y);
131
132                 }
133                 return true;
134         }
135
136         //=========================================================================
137
138         bool GConnectorController::OnRightButtonDown()
139         {
140                 if( _vtkInteractorStyleBaseView!= NULL )
141                 {
142                         int X,Y;
143                         wxVTKRenderWindowInteractor *wxVTKiren;
144                         wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
145                         wxVTKiren->GetEventPosition(X, Y);
146
147                         _controller->MouseClickRight(X,Y);
148
149                 }
150                 return true;
151         }
152
153         //=========================================================================
154
155         bool GConnectorController::OnRightButtonUp()
156         {
157                 return true;
158         }
159
160         //=========================================================================
161
162         bool GConnectorController::OnMiddleButtonDown()
163         {
164                 if ( _vtkInteractorStyleBaseView!=NULL )
165                 {
166                         int X,Y,Z=900;
167                         wxVTKRenderWindowInteractor *wxVTKiren;
168                         wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
169                         wxVTKiren->GetEventPosition(X, Y);
170                         _controller->GetManualViewBaseContour()->InitMove( X, Y,Z);
171                 }
172                 return true;
173         }
174         //=========================================================================
175         bool GConnectorController::OnMiddleButtonUp()
176         {
177                 return true;
178         }
179
180         //=========================================================================
181
182         manualConnectorContourController* GConnectorController::getManualContourController()
183         {
184                 return _controller;
185         }
186
187         //=========================================================================
188
189         void GConnectorController::setManualContourController(manualConnectorContourController* controller)
190         {
191                 _controller = controller;
192                 _controller->SetVtkInteractorStyleBaseView(_vtkInteractorStyleBaseView);
193         }
194
195         //=========================================================================
196
197         void GConnectorController::removeFromScene()
198         {
199                 GConnectorModel *conMod = (GConnectorModel*)_model;
200                 conMod->disconnectConnection();
201
202                 _controller->SetEditable(false);
203                 _controller->DeleteContour();
204         }
205
206         //=========================================================================
207
208         void GConnectorController::endContourCreation()
209         {
210                 _controller->endContourCreation();
211         }
212
213         //=========================================================================
214
215 }  // EO namespace bbtk
216
217 // EOF
218