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 printf("EED GConnectorController::OnMouseMove state%d\n", _view->getState() );
65 if (_view->getState() ==SELECTED)
67 _controller->GetManualViewBaseContour()->SetSelected(true);
70 if ( _vtkInteractorStyleBaseView!=NULL)
73 wxVTKRenderWindowInteractor *_wxVTKiren;
74 _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
75 _wxVTKiren->GetEventPosition( X , Y );
77 if ( (_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==0) &&(_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==0) )
79 _controller->MouseMove(X,Y);
86 //=========================================================================
88 bool GConnectorController::OnLeftButtonDown()
91 if ( _vtkInteractorStyleBaseView!=NULL )
94 wxVTKRenderWindowInteractor *wxVTKiren;
95 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
96 wxVTKiren->GetEventPosition(X,Y);
98 _controller->SetKeyBoardMoving( false );
99 _controller->MouseClickLeft(X,Y);
105 //=========================================================================
107 bool GConnectorController::OnLeftButtonUp()
109 if( _vtkInteractorStyleBaseView!= NULL )
112 wxVTKRenderWindowInteractor *wxVTKiren;
113 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
114 wxVTKiren->GetEventPosition(X, Y);
116 _controller->MouseReleaseLeft(X,Y);
117 if(_controller->GetManualViewBaseContour()->GetSelected()==true)
119 _view->setState(SELECTED);
120 _model->notifyObservers(getId(),ADD_TO_SELECTED);
128 //=========================================================================
130 bool GConnectorController::OnLeftDClick()
133 if ( _vtkInteractorStyleBaseView!=NULL )
136 wxVTKRenderWindowInteractor *wxVTKiren;
137 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
138 wxVTKiren->GetEventPosition(X,Y);
140 _controller->MouseDLeft(X,Y);
146 //=========================================================================
148 bool GConnectorController::OnRightButtonDown()
150 if( _vtkInteractorStyleBaseView!= NULL )
153 wxVTKRenderWindowInteractor *wxVTKiren;
154 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
155 wxVTKiren->GetEventPosition(X, Y);
157 _controller->MouseClickRight(X,Y);
163 //=========================================================================
165 bool GConnectorController::OnRightButtonUp()
170 //=========================================================================
172 bool GConnectorController::OnMiddleButtonDown()
174 if ( _vtkInteractorStyleBaseView!=NULL )
176 int X, Y, Z=GPOSITION_Z;
177 wxVTKRenderWindowInteractor *wxVTKiren;
178 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
179 wxVTKiren->GetEventPosition(X, Y);
180 _controller->GetManualViewBaseContour()->InitMove( X, Y,Z);
184 //=========================================================================
185 bool GConnectorController::OnMiddleButtonUp()
190 //=========================================================================
192 manualConnectorContourController* GConnectorController::getManualContourController()
197 //=========================================================================
199 void GConnectorController::setManualContourController(manualConnectorContourController* controller)
201 _controller = controller;
202 _controller->SetVtkInteractorStyleBaseView(_vtkInteractorStyleBaseView);
205 //=========================================================================
207 void GConnectorController::removeFromScene()
209 GConnectorModel *conMod = (GConnectorModel*)_model;
210 conMod->disconnectConnection();
212 _controller->SetEditable(false);
213 _controller->DeleteContour();
216 //=========================================================================
218 void GConnectorController::endContourCreation()
220 _controller->endContourCreation();
223 //=========================================================================
225 } // EO namespace bbtk