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 ( _vtkInteractorStyleBaseView!=NULL)
66 wxVTKRenderWindowInteractor *_wxVTKiren;
67 _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
68 _wxVTKiren->GetEventPosition( X , Y );
70 if ( (_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==0) &&(_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==0) )
72 _controller->MouseMove(X,Y);
79 //=========================================================================
81 bool GConnectorController::OnLeftButtonDown()
84 if ( _vtkInteractorStyleBaseView!=NULL )
87 wxVTKRenderWindowInteractor *wxVTKiren;
88 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
89 wxVTKiren->GetEventPosition(X,Y);
91 _controller->SetKeyBoardMoving( false );
92 _controller->MouseClickLeft(X,Y);
98 //=========================================================================
100 bool GConnectorController::OnLeftButtonUp()
102 if( _vtkInteractorStyleBaseView!= NULL )
105 wxVTKRenderWindowInteractor *wxVTKiren;
106 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
107 wxVTKiren->GetEventPosition(X, Y);
109 _controller->MouseReleaseLeft(X,Y);
110 if(_controller->GetManualViewBaseContour()->GetSelected()==true)
112 _view->setState(SELECTED);
113 _model->notifyObservers(getId(),ADD_TO_SELECTED);
121 //=========================================================================
123 bool GConnectorController::OnLeftDClick()
126 if ( _vtkInteractorStyleBaseView!=NULL )
129 wxVTKRenderWindowInteractor *wxVTKiren;
130 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
131 wxVTKiren->GetEventPosition(X,Y);
133 _controller->MouseDLeft(X,Y);
139 //=========================================================================
141 bool GConnectorController::OnRightButtonDown()
143 if( _vtkInteractorStyleBaseView!= NULL )
146 wxVTKRenderWindowInteractor *wxVTKiren;
147 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
148 wxVTKiren->GetEventPosition(X, Y);
150 _controller->MouseClickRight(X,Y);
156 //=========================================================================
158 bool GConnectorController::OnRightButtonUp()
163 //=========================================================================
165 bool GConnectorController::OnMiddleButtonDown()
167 if ( _vtkInteractorStyleBaseView!=NULL )
170 wxVTKRenderWindowInteractor *wxVTKiren;
171 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
172 wxVTKiren->GetEventPosition(X, Y);
173 _controller->GetManualViewBaseContour()->InitMove( X, Y,Z);
177 //=========================================================================
178 bool GConnectorController::OnMiddleButtonUp()
183 //=========================================================================
185 manualConnectorContourController* GConnectorController::getManualContourController()
190 //=========================================================================
192 void GConnectorController::setManualContourController(manualConnectorContourController* controller)
194 _controller = controller;
195 _controller->SetVtkInteractorStyleBaseView(_vtkInteractorStyleBaseView);
198 //=========================================================================
200 void GConnectorController::removeFromScene()
202 GConnectorModel *conMod = (GConnectorModel*)_model;
203 conMod->disconnectConnection();
205 _controller->SetEditable(false);
206 _controller->DeleteContour();
209 //=========================================================================
211 void GConnectorController::endContourCreation()
213 _controller->endContourCreation();
216 //=========================================================================
218 } // EO namespace bbtk