1 /*=========================================================================
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
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.
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
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 * ------------------------------------------------------------------------ */
33 * \brief Class bbtk::GConnectorController
37 #include "GConnectorController.h"
46 //=========================================================================
47 GConnectorController::GConnectorController()
52 //=========================================================================
54 GConnectorController::~GConnectorController()
58 //=========================================================================
60 bool GConnectorController::OnMouseMove()
63 if (_view->getState() ==SELECTED)
65 _controller->GetManualViewBaseContour()->SetSelected(true);
68 if ( _vtkInteractorStyleBaseView!=NULL)
71 wxVTKRenderWindowInteractor *_wxVTKiren;
72 _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
73 _wxVTKiren->GetEventPosition( X , Y );
75 if ( (_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==0) &&(_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==0) )
77 _controller->MouseMove(X,Y);
84 //=========================================================================
86 bool GConnectorController::OnLeftButtonDown()
89 if ( _vtkInteractorStyleBaseView!=NULL )
92 wxVTKRenderWindowInteractor *wxVTKiren;
93 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
94 wxVTKiren->GetEventPosition(X,Y);
96 _controller->SetKeyBoardMoving( false );
97 _controller->MouseClickLeft(X,Y);
103 //=========================================================================
105 bool GConnectorController::OnLeftButtonUp()
107 if( _vtkInteractorStyleBaseView!= NULL )
110 wxVTKRenderWindowInteractor *wxVTKiren;
111 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
112 wxVTKiren->GetEventPosition(X, Y);
114 _controller->MouseReleaseLeft(X,Y);
115 if(_controller->GetManualViewBaseContour()->GetSelected()==true)
117 _view->setState(SELECTED);
118 _model->notifyObservers(getId(),ADD_TO_SELECTED);
126 //=========================================================================
128 bool GConnectorController::OnLeftDClick()
131 if ( _vtkInteractorStyleBaseView!=NULL )
134 wxVTKRenderWindowInteractor *wxVTKiren;
135 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
136 wxVTKiren->GetEventPosition(X,Y);
138 _controller->MouseDLeft(X,Y);
144 //=========================================================================
146 bool GConnectorController::OnRightButtonDown()
148 if( _vtkInteractorStyleBaseView!= NULL )
151 wxVTKRenderWindowInteractor *wxVTKiren;
152 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
153 wxVTKiren->GetEventPosition(X, Y);
155 _controller->MouseClickRight(X,Y);
161 //=========================================================================
163 bool GConnectorController::OnRightButtonUp()
168 //=========================================================================
170 bool GConnectorController::OnMiddleButtonDown()
172 if ( _vtkInteractorStyleBaseView!=NULL )
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);
182 //=========================================================================
183 bool GConnectorController::OnMiddleButtonUp()
188 //=========================================================================
190 manualConnectorContourController* GConnectorController::getManualContourController()
195 //=========================================================================
197 void GConnectorController::setManualContourController(manualConnectorContourController* controller)
199 _controller = controller;
200 _controller->SetVtkInteractorStyleBaseView(_vtkInteractorStyleBaseView);
203 //=========================================================================
205 void GConnectorController::removeFromScene()
207 GConnectorModel *conMod = (GConnectorModel*)_model;
208 conMod->disconnectConnection();
210 _controller->SetEditable(false);
211 _controller->DeleteContour();
214 //=========================================================================
216 void GConnectorController::endContourCreation()
218 _controller->endContourCreation();
221 //=========================================================================
223 } // EO namespace bbtk