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
61 printf("EED MACHETE con int z=-GetZ(); en manualConnectorContourController::MouseMove z=%d\n", z );
64 GetManualViewBaseContour()->SelectPosiblePoint(x,y,z);
65 GetManualViewBaseContour()->SelectPosibleContour(x,y,z);
66 if (GetState()==1){ SetPoint( _bakIdPoint , x , y ,z); }
67 if (GetState()==5){ SetPoint( _bakIdPoint , x , y ,z); }
68 if ( GetState()==6 && !IsEditable() && GetPosibleToMove() &&IsMoving() )
70 //GetManualViewBaseContour()->MoveContour(x,y,z);
72 if (GetState()!=7 || GetManualViewBaseContour()->GetPosibleSelected() ){
73 GetManualViewBaseContour()->Refresh();
74 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
78 GetManualViewBaseContour()->RemoveControlPoints();
79 GetManualViewBaseContour()->Refresh();
80 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
85 //=========================================================================
87 void manualConnectorContourController::MouseClickRight(int x, int y)
89 SetCompleteCreation( true );
90 SetKeyBoardMoving( false );
91 GetManualContourModel()->SetCloseContour(false);
94 SetPosibleToMove( false );
99 //=========================================================================
101 void manualConnectorContourController::MouseClickLeft(int x, int y)
106 int size= GetManualViewBaseContour()->GetNumberOfPoints();
109 printf("\nEED manualConnectorContourController::MouseClickLeft z=%d estado=%d\n", z,GetState());
112 printf(" Editable\n");
114 printf(" NO Editable\n");
118 if (GetManualViewBaseContour()->GetPosibleSelected())
120 printf(" PosibleSelected\n");
122 printf(" NO PosibleSelected\n");
126 // Insert a Control Point with shift+ClickLeft
127 vtkRenderWindowInteractor *vtkrenderwindowinteractor = _vtkInteractorStyleBaseView->GetInteractor();
130 if ( (_vtkInteractorStyleBaseView!=NULL) && (GetState()==0) && ( (vtkrenderwindowinteractor!=NULL) && (vtkrenderwindowinteractor->GetShiftKey()==1) ) )
136 // Start to Insert Control Points with ClickLeft (Empty contour)
137 if ((GetState()==0) && (size==0) && (_easyCreation==true) )
141 GetManualContourModel()->SetCloseContour(false);
145 // RaC Just create 2 points
146 if ((GetState()==1) && (_easyCreation==true) && GetNumberOfPointsManualContour()==2)
149 endContourCreation();
152 // Continue to Insert Control Points with ClickLeft (After being empty the contour)
153 if ((GetState()==1) && (_easyCreation==true) )
157 _bakIdPoint=GetNumberOfPointsManualContour() - 1;
160 // Insert Control Points IF Contour si Selected
161 if ((GetState()==0) && GetManualViewBaseContour()->GetPosibleSelected() )
165 _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
168 // Chose id of Control Point to be move
169 if ( (GetState()==0 || GetState()==6) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)!=-1 ) )
172 _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
173 if(_bakIdPoint!=0 && _bakIdPoint!=GetManualViewBaseContour()->GetNumberOfPoints()-1)
178 // If nothing selected _state=7
179 if ( (GetState()==0) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)==-1 ) )
182 _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
186 SetPosibleToMove( true );
187 GetManualViewBaseContour()->SetSelected( GetManualViewBaseContour()->GetPosibleSelected() );
190 if ( GetState() == 0 && GetManualViewBaseContour()->GetPosibleSelected() )
194 GetManualViewBaseContour()->InitMove(x,y,z);
200 GetManualViewBaseContour()->Refresh();
205 //=========================================================================
207 void manualConnectorContourController::endContourCreation()
209 SetCompleteCreation( true );
210 SetKeyBoardMoving( false );
211 GetManualContourModel()->SetCloseContour(false);
213 SetEditable( false );
214 SetPosibleToMove( false );
219 //=========================================================================
221 } // EO namespace bbtk