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"
43 //=========================================================================
44 GConnectorController::GConnectorController()
49 //=========================================================================
51 GConnectorController::~GConnectorController()
55 //=========================================================================
57 bool GConnectorController::OnMouseMove()
60 if ( _vtkInteractorStyleBaseView!=NULL)
63 wxVTKRenderWindowInteractor *_wxVTKiren;
64 _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
65 _wxVTKiren->GetEventPosition( X , Y );
67 if ( (_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==0) &&(_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==0) )
69 _controller->MouseMove(X,Y);
76 //=========================================================================
78 bool GConnectorController::OnLeftButtonDown()
81 if ( _vtkInteractorStyleBaseView!=NULL )
84 wxVTKRenderWindowInteractor *wxVTKiren;
85 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
86 wxVTKiren->GetEventPosition(X,Y);
88 _controller->SetKeyBoardMoving( false );
89 _controller->MouseClickLeft(X,Y);
95 //=========================================================================
97 bool GConnectorController::OnLeftButtonUp()
99 if( _vtkInteractorStyleBaseView!= NULL )
102 wxVTKRenderWindowInteractor *wxVTKiren;
103 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
104 wxVTKiren->GetEventPosition(X, Y);
106 _controller->MouseReleaseLeft(X,Y);
107 if(_controller->GetManualViewBaseContour()->GetSelected()==true)
109 _view->setState(SELECTED);
110 _model->notifyObservers(getId(),ADD_TO_SELECTED);
118 //=========================================================================
120 bool GConnectorController::OnLeftDClick()
123 if ( _vtkInteractorStyleBaseView!=NULL )
126 wxVTKRenderWindowInteractor *wxVTKiren;
127 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
128 wxVTKiren->GetEventPosition(X,Y);
130 _controller->MouseDLeft(X,Y);
136 //=========================================================================
138 bool GConnectorController::OnRightButtonDown()
140 if( _vtkInteractorStyleBaseView!= NULL )
143 wxVTKRenderWindowInteractor *wxVTKiren;
144 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
145 wxVTKiren->GetEventPosition(X, Y);
147 _controller->MouseClickRight(X,Y);
153 //=========================================================================
155 bool GConnectorController::OnRightButtonUp()
160 //=========================================================================
162 bool GConnectorController::OnMiddleButtonDown()
164 if ( _vtkInteractorStyleBaseView!=NULL )
167 wxVTKRenderWindowInteractor *wxVTKiren;
168 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
169 wxVTKiren->GetEventPosition(X, Y);
170 _controller->GetManualViewBaseContour()->InitMove( X, Y,Z);
174 //=========================================================================
175 bool GConnectorController::OnMiddleButtonUp()
180 //=========================================================================
182 manualConnectorContourController* GConnectorController::getManualContourController()
187 //=========================================================================
189 void GConnectorController::setManualContourController(manualConnectorContourController* controller)
191 _controller = controller;
192 _controller->SetVtkInteractorStyleBaseView(_vtkInteractorStyleBaseView);
195 //=========================================================================
197 void GConnectorController::removeFromScene()
199 GConnectorModel *conMod = (GConnectorModel*)_model;
200 conMod->disconnectConnection();
202 _controller->SetEditable(false);
203 _controller->DeleteContour();
206 //=========================================================================
208 void GConnectorController::endContourCreation()
210 _controller->endContourCreation();
213 //=========================================================================
215 } // EO namespace bbtk