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::manualConnectorContourController
37 #include "manualConnectorContourController.h"
43 //=========================================================================
44 manualConnectorContourController::manualConnectorContourController()
48 //=========================================================================
50 manualConnectorContourController::~manualConnectorContourController()
54 //=========================================================================
56 void manualConnectorContourController::MouseMove(int x, int y) // virtual
59 GetManualViewBaseContour()->SelectPosiblePoint(x,y,z);
60 GetManualViewBaseContour()->SelectPosibleContour(x,y,z);
61 if (GetState()==1){ SetPoint( _bakIdPoint , x , y ,z); }
62 if (GetState()==5){ SetPoint( _bakIdPoint , x , y ,z); }
63 if ( GetState()==6 && !IsEditable() && GetPosibleToMove() &&IsMoving() )
65 //GetManualViewBaseContour()->MoveContour(x,y,z);
67 if (GetState()!=7 || GetManualViewBaseContour()->GetPosibleSelected() ){
68 GetManualViewBaseContour()->Refresh();
69 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
73 GetManualViewBaseContour()->RemoveControlPoints();
74 GetManualViewBaseContour()->Refresh();
75 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
80 //=========================================================================
82 void manualConnectorContourController::MouseClickRight(int x, int y)
84 SetCompleteCreation( true );
85 SetKeyBoardMoving( false );
86 GetManualContourModel()->SetCloseContour(false);
89 SetPosibleToMove( false );
94 //=========================================================================
95 void manualConnectorContourController::MouseClickLeft(int x, int y){
99 int size= GetManualViewBaseContour()->GetNumberOfPoints();
101 // Insert a Control Point with shift+ClickLeft
102 vtkRenderWindowInteractor *vtkrenderwindowinteractor = _vtkInteractorStyleBaseView->GetInteractor();
105 if ( (_vtkInteractorStyleBaseView!=NULL) && (GetState()==0) && ( (vtkrenderwindowinteractor!=NULL) && (vtkrenderwindowinteractor->GetShiftKey()==1) ) )
111 // Start to Insert Control Points with ClickLeft (Empty contour)
112 if ((GetState()==0) && (size==0) && (_easyCreation==true) )
116 GetManualContourModel()->SetCloseContour(false);
120 // RaC Just create 2 points
121 if ((GetState()==1) && (_easyCreation==true) && GetNumberOfPointsManualContour()==2)
125 SetCompleteCreation( true );
126 SetKeyBoardMoving( false );
127 GetManualContourModel()->SetCloseContour(false);
129 SetEditable( false );
130 SetPosibleToMove( false );
134 // Continue to Insert Control Points with ClickLeft (After being empty the contour)
135 if ((GetState()==1) && (_easyCreation==true) )
139 _bakIdPoint=GetNumberOfPointsManualContour() - 1;
142 // Insert Control Points IF Contour si Selected
143 if ((GetState()==0) && GetManualViewBaseContour()->GetPosibleSelected() )
147 _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
150 // Chose id of Control Point to be move
151 if ( (GetState()==0 || GetState()==6) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)!=-1 ) )
154 _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
155 if(_bakIdPoint!=0 && _bakIdPoint!=GetManualViewBaseContour()->GetNumberOfPoints()-1)
160 // If nothing selected _state=7
161 if ( (GetState()==0) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)==-1 ) )
164 _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
168 SetPosibleToMove( true );
169 GetManualViewBaseContour()->SetSelected( GetManualViewBaseContour()->GetPosibleSelected() );
172 if ( GetState() == 0 && GetManualViewBaseContour()->GetPosibleSelected() )
176 GetManualViewBaseContour()->InitMove(x,y,z);
181 GetManualViewBaseContour()->Refresh();
184 //=========================================================================
186 } // EO namespace bbtk