]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.cxx
*** empty log 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 printf ("GConnectorController::OnRightButtonDown 1 \n"  );
141                 if( _vtkInteractorStyleBaseView!= NULL )
142                 {
143                         int X,Y;
144                         wxVTKRenderWindowInteractor *wxVTKiren;
145                         wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
146                         wxVTKiren->GetEventPosition(X, Y);
147
148                         _controller->MouseClickRight(X,Y);
149
150                 }
151 printf ("GConnectorController::OnRightButtonDown 2 \n"  );
152                 return true;
153         }
154
155         //=========================================================================
156
157         bool GConnectorController::OnRightButtonUp()
158         {
159                 return true;
160         }
161
162         //=========================================================================
163
164         bool GConnectorController::OnMiddleButtonDown()
165         {
166                 if ( _vtkInteractorStyleBaseView!=NULL )
167                 {
168                         int X,Y,Z=900;
169                         wxVTKRenderWindowInteractor *wxVTKiren;
170                         wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
171                         wxVTKiren->GetEventPosition(X, Y);
172                         _controller->GetManualViewBaseContour()->InitMove( X, Y,Z);
173                 }
174                 return true;
175         }
176         //=========================================================================
177         bool GConnectorController::OnMiddleButtonUp()
178         {
179                 return true;
180         }
181
182         //=========================================================================
183
184         manualConnectorContourController* GConnectorController::getManualContourController()
185         {
186                 return _controller;
187         }
188
189         //=========================================================================
190
191         void GConnectorController::setManualContourController(manualConnectorContourController* controller)
192         {
193                 _controller = controller;
194                 _controller->SetVtkInteractorStyleBaseView(_vtkInteractorStyleBaseView);
195         }
196
197         //=========================================================================
198
199         void GConnectorController::removeFromScene()
200         {
201                 GConnectorModel *conMod = (GConnectorModel*)_model;
202                 conMod->disconnectConnection();
203
204                 _controller->SetEditable(false);
205                 _controller->DeleteContour();
206         }
207
208         //=========================================================================
209
210         void GConnectorController::endContourCreation()
211         {
212                 _controller->endContourCreation();
213         }
214
215         //=========================================================================
216
217 }  // EO namespace bbtk
218
219 // EOF
220