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