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 printf ("GConnectorController::OnRightButtonDown 1 \n" );
141 if( _vtkInteractorStyleBaseView!= NULL )
144 wxVTKRenderWindowInteractor *wxVTKiren;
145 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
146 wxVTKiren->GetEventPosition(X, Y);
148 _controller->MouseClickRight(X,Y);
151 printf ("GConnectorController::OnRightButtonDown 2 \n" );
155 //=========================================================================
157 bool GConnectorController::OnRightButtonUp()
162 //=========================================================================
164 bool GConnectorController::OnMiddleButtonDown()
166 if ( _vtkInteractorStyleBaseView!=NULL )
169 wxVTKRenderWindowInteractor *wxVTKiren;
170 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
171 wxVTKiren->GetEventPosition(X, Y);
172 _controller->GetManualViewBaseContour()->InitMove( X, Y,Z);
176 //=========================================================================
177 bool GConnectorController::OnMiddleButtonUp()
182 //=========================================================================
184 manualConnectorContourController* GConnectorController::getManualContourController()
189 //=========================================================================
191 void GConnectorController::setManualContourController(manualConnectorContourController* controller)
193 _controller = controller;
194 _controller->SetVtkInteractorStyleBaseView(_vtkInteractorStyleBaseView);
197 //=========================================================================
199 void GConnectorController::removeFromScene()
201 GConnectorModel *conMod = (GConnectorModel*)_model;
202 conMod->disconnectConnection();
204 _controller->SetEditable(false);
205 _controller->DeleteContour();
208 //=========================================================================
210 void GConnectorController::endContourCreation()
212 _controller->endContourCreation();
215 //=========================================================================
217 } // EO namespace bbtk