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