]> Creatis software - bbtkGEditor.git/blob - lib/EditorGraphicBBS/bbsVtkGUIEditorGraphic/GConnectorController.cxx
It is possible to delete connections !!!
[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                                 cout<<"RaC GConnectorController::OnLeftButtonUp GetSelected():"<<_controller->GetManualViewBaseContour()->GetSelected() <<endl;
110                                 _view->setState(SELECTED);
111                                 _model->notifyObservers(getId(),ADD_TO_SELECTED);
112                         }
113                         
114                 }
115                 return true;
116
117         }
118         
119         //=========================================================================
120         
121         bool GConnectorController::OnLeftDClick()
122         {
123
124                 if ( _vtkInteractorStyleBaseView!=NULL )
125                 {
126                         int X,Y;
127                         wxVTKRenderWindowInteractor *wxVTKiren;
128                         wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
129                         wxVTKiren->GetEventPosition(X,Y);
130
131                         _controller->MouseDLeft(X,Y);
132
133                 }
134                 return true;
135         }
136         
137         //=========================================================================
138         
139         bool GConnectorController::OnRightButtonDown()
140         {
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                 return true;
152         }
153                 
154         //=========================================================================
155
156         bool GConnectorController::OnRightButtonUp()
157         {
158                 return true;
159         }
160
161         //=========================================================================
162
163         bool GConnectorController::OnMiddleButtonDown()
164         {
165                 if ( _vtkInteractorStyleBaseView!=NULL )
166                 {
167                         int X,Y,Z=900;
168                         wxVTKRenderWindowInteractor *wxVTKiren;
169                         wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
170                         wxVTKiren->GetEventPosition(X, Y);
171                         _controller->GetManualViewBaseContour()->InitMove( X, Y,Z);
172                 }
173                 return true;
174         }
175         //=========================================================================
176         bool GConnectorController::OnMiddleButtonUp()
177         {
178                 return true;
179         }
180
181         //=========================================================================
182
183         manualConnectorContourController* GConnectorController::getManualContourController()
184         {
185                 return _controller;
186         }
187
188         //=========================================================================
189         
190         void GConnectorController::setManualContourController(manualConnectorContourController* controller)
191         {
192                 _controller = controller;
193                 _controller->SetVtkInteractorStyleBaseView(_vtkInteractorStyleBaseView);
194         }
195
196         //=========================================================================
197         
198         void GConnectorController::removeFromScene()
199         {
200                 GConnectorModel *conMod = (GConnectorModel*)_model;
201                 conMod->disconnectConnection();
202
203                 _controller->SetEditable(false);
204                 _controller->DeleteContour();
205         }
206
207         //=========================================================================
208
209 }  // EO namespace bbtk
210
211 // EOF
212