1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
26 #include "manualContourControler.h"
28 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
32 // _state = 0 // ..nothing..
33 // _state = 1 // move with add point
35 // _state = 6 // move with insert point
36 // _state = 7 // move with non selection
38 manualContourControler::manualContourControler()
43 // ----------------------------------------------------------------------------
44 manualContourControler::~manualContourControler()
47 // ----------------------------------------------------------------------------
48 manualContourControler * manualContourControler :: Clone() // virtual
50 manualContourControler * clone = new manualContourControler();
51 CopyAttributesTo(clone);
54 // ---------------------------------------------------------------------------
55 void manualContourControler::CopyAttributesTo( manualContourControler * cloneObject)
58 manualContourBaseControler::CopyAttributesTo(cloneObject);
59 cloneObject->SetEasyCreation( this->GetEasyCreation() );
62 // ----------------------------------------------------------------------------
63 void manualContourControler::Configure() //virtual
65 // this->_manContModel->SetNumberOfPointsSpline(100);
68 // ----------------------------------------------------------------------------
69 void manualContourControler::MouseClickLeft(int x, int y)
74 int size= GetManualViewBaseContour()->GetNumberOfPoints();
76 // Insert a Control Point with shift+ClickLeft
77 vtkRenderWindowInteractor *vtkrenderwindowinteractor = _vtkInteractorStyleBaseView->GetInteractor();
81 if ( (_vtkInteractorStyleBaseView!=NULL) && (GetState()==0) && ( (vtkrenderwindowinteractor!=NULL) && (vtkrenderwindowinteractor->GetShiftKey()==1) ) )
87 // Start to Insert Control Points with ClickLeft (Empty contour)
88 if ((GetState()==0) && (size==0) && (_easyCreation==true) )
92 GetManualContourModel()->SetCloseContour(false);
95 // Continuie to Insert Control Points with ClickLeft (After being empty the contour)
96 if ((GetState()==1) && (_easyCreation==true) )
100 _bakIdPoint=GetNumberOfPointsManualContour() - 1;
102 // Insert Control Points IF Contour si Selected
103 if ((GetState()==0) && GetManualViewBaseContour()->GetPosibleSelected() )
107 _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
110 // Chose id of Control Point to be move
111 if ( (GetState()==0 || GetState()==6) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)!=-1 ) )
114 _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
117 // If nothing selected _state=7
118 if ( (GetState()==0) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)==-1 ) )
121 _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
125 SetPosibleToMove( true );
126 GetManualViewBaseContour()->SetSelected( GetManualViewBaseContour()->GetPosibleSelected() );
129 if ( GetState() == 0 && GetManualViewBaseContour()->GetPosibleSelected() )
133 GetManualViewBaseContour()->InitMove(x,y,z);
138 GetManualViewBaseContour()->Refresh();
141 // ----------------------------------------------------------------------------
142 void manualContourControler::MouseMove(int x, int y) // virtual
145 GetManualViewBaseContour()->SelectPosiblePoint(x,y,z);
146 GetManualViewBaseContour()->SelectPosibleContour(x,y,z);
147 if (GetState()==1){ SetPoint( _bakIdPoint , x , y ,z); }
148 if (GetState()==5){ SetPoint( _bakIdPoint , x , y ,z); }
149 if ( GetState()==6 && !IsEditable() && GetPosibleToMove() &&IsMoving() )
151 GetManualViewBaseContour()->MoveContour(x,y,z);
153 if (GetState()!=7 || GetManualViewBaseContour()->GetPosibleSelected() ){
154 GetManualViewBaseContour()->Refresh();
155 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
159 GetManualViewBaseContour()->RemoveControlPoints();
160 // GetManualViewBaseContour()->RemoveTextActor();
161 GetManualViewBaseContour()->Refresh();
162 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
167 // ----------------------------------------------------------------------------
168 void manualContourControler::MouseDLeft( int x, int y)//virtual
170 manualContourBaseControler::MouseDLeft( x, y);
174 GetManualViewBaseContour()->AddControlPoints();
175 GetManualViewBaseContour()->AddTextActor();
176 GetManualViewBaseContour()->Refresh();
177 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
180 // ----------------------------------------------------------------------------
181 void manualContourControler::SetEasyCreation(bool easyCreation)
183 _easyCreation=easyCreation;
185 // ----------------------------------------------------------------------------
186 bool manualContourControler::GetEasyCreation()
188 return _easyCreation;