2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
8 # This software is governed by the CeCILL-B license under French law and
9 # abiding by the rules of distribution of free software. You can use,
10 # modify and/ or redistribute the software under the terms of the CeCILL-B
11 # license as circulated by CEA, CNRS and INRIA at the following URL
12 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
13 # or in the file LICENSE.txt.
15 # As a counterpart to the access to the source code and rights to copy,
16 # modify and redistribute granted by the license, users are provided only
17 # with a limited warranty and the software's author, the holder of the
18 # economic rights, and the successive licensors have only limited
21 # The fact that you are presently reading this means that you have had
22 # knowledge of the CeCILL-B license and that you accept its terms.
23 # ------------------------------------------------------------------------
26 /*=========================================================================
32 =========================================================================*/
34 /* ---------------------------------------------------------------------
36 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
37 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
39 * This software is governed by the CeCILL-B license under French law and
40 * abiding by the rules of distribution of free software. You can use,
41 * modify and/ or redistribute the software under the terms of the CeCILL-B
42 * license as circulated by CEA, CNRS and INRIA at the following URL
43 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
44 * or in the file LICENSE.txt.
46 * As a counterpart to the access to the source code and rights to copy,
47 * modify and redistribute granted by the license, users are provided only
48 * with a limited warranty and the software's author, the holder of the
49 * economic rights, and the successive licensors have only limited
52 * The fact that you are presently reading this means that you have had
53 * knowledge of the CeCILL-B license and that you accept its terms.
54 * ------------------------------------------------------------------------ */
58 * \brief Class bbtk::manualConnectorContourController
62 #include "manualConnectorContourController.h"
68 //=========================================================================
69 manualConnectorContourController::manualConnectorContourController()
73 //=========================================================================
75 manualConnectorContourController::~manualConnectorContourController()
79 //=========================================================================
81 void manualConnectorContourController::MouseMove(int x, int y) // virtual
86 GetManualViewBaseContour()->SelectPosiblePoint(x,y,z);
87 GetManualViewBaseContour()->SelectPosibleContour(x,y,z);
88 if (GetState()==1){ SetPoint( _bakIdPoint , x , y ,z); }
89 if (GetState()==5){ SetPoint( _bakIdPoint , x , y ,z); }
90 if ( GetState()==6 && !IsEditable() && GetPosibleToMove() &&IsMoving() )
92 //GetManualViewBaseContour()->MoveContour(x,y,z);
94 if (GetState()!=7 || GetManualViewBaseContour()->GetPosibleSelected() ){
95 GetManualViewBaseContour()->Refresh();
96 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
100 GetManualViewBaseContour()->RemoveControlPoints();
101 GetManualViewBaseContour()->Refresh();
102 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
107 //=========================================================================
109 void manualConnectorContourController::MouseClickRight(int x, int y)
111 SetCompleteCreation( true );
112 SetKeyBoardMoving( false );
113 GetManualContourModel()->SetCloseContour(false);
115 SetEditable( false );
116 SetPosibleToMove( false );
121 //=========================================================================
123 void manualConnectorContourController::MouseClickLeft(int x, int y)
128 int size= GetManualViewBaseContour()->GetNumberOfPoints();
131 // Insert a Control Point with shift+ClickLeft
132 vtkRenderWindowInteractor *vtkrenderwindowinteractor = _vtkInteractorStyleBaseView->GetInteractor();
135 if ( (_vtkInteractorStyleBaseView!=NULL) && (GetState()==0) && ( (vtkrenderwindowinteractor!=NULL) && (vtkrenderwindowinteractor->GetShiftKey()==1) ) )
141 // Start to Insert Control Points with ClickLeft (Empty contour)
142 if ((GetState()==0) && (size==0) && (_easyCreation==true) )
146 GetManualContourModel()->SetCloseContour(false);
150 // RaC Just create 2 points
151 if ((GetState()==1) && (_easyCreation==true) && GetNumberOfPointsManualContour()==2)
154 endContourCreation();
157 // Continue to Insert Control Points with ClickLeft (After being empty the contour)
158 if ((GetState()==1) && (_easyCreation==true) )
162 _bakIdPoint=GetNumberOfPointsManualContour() - 1;
165 // Insert Control Points IF Contour si Selected
166 if ((GetState()==0) && GetManualViewBaseContour()->GetPosibleSelected() )
170 _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
173 // Chose id of Control Point to be move
174 if ( (GetState()==0 || GetState()==6) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)!=-1 ) )
177 _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
178 if(_bakIdPoint!=0 && _bakIdPoint!=GetManualViewBaseContour()->GetNumberOfPoints()-1)
183 // If nothing selected _state=7
184 if ( (GetState()==0) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)==-1 ) )
187 _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
191 SetPosibleToMove( true );
192 GetManualViewBaseContour()->SetSelected( GetManualViewBaseContour()->GetPosibleSelected() );
195 if ( GetState() == 0 && GetManualViewBaseContour()->GetPosibleSelected() )
199 GetManualViewBaseContour()->InitMove(x,y,z);
205 GetManualViewBaseContour()->Refresh();
210 //=========================================================================
212 void manualConnectorContourController::endContourCreation()
214 SetCompleteCreation( true );
215 SetKeyBoardMoving( false );
216 GetManualContourModel()->SetCloseContour(false);
218 SetEditable( false );
219 SetPosibleToMove( false );
224 //=========================================================================
226 } // EO namespace bbtk