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