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 "manualCircleControler.h"
28 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
34 // _state = 0 // ..nothing..
35 // _state = 5 // move point
36 // _state = 6 // move all
37 // _state = 7 // Empty mouse drag
39 manualCircleControler::manualCircleControler()
42 // ----------------------------------------------------------------------------
43 manualCircleControler::~manualCircleControler()
46 // ----------------------------------------------------------------------------
47 manualCircleControler * manualCircleControler :: Clone() // virtual
49 manualCircleControler * clone = new manualCircleControler();
50 CopyAttributesTo(clone);
54 // ---------------------------------------------------------------------------
55 void manualCircleControler::CopyAttributesTo( manualCircleControler * cloneObject)
58 manualContourBaseControler::CopyAttributesTo(cloneObject);
61 // ----------------------------------------------------------------------------
62 void manualCircleControler::Configure() //virtual
64 // this->GetManualContourModel()->SetNumberOfPointsSpline(5);
67 // ----------------------------------------------------------------------------
68 void manualCircleControler::MouseClickLeft(int x, int y){
72 { // move control point
73 if ( (GetState()==0) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)!=-1 ) ){
74 bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
80 if ((GetState()==0) && (GetManualViewBaseContour()->GetPosibleSelected()==true)) {
81 GetManualViewBaseContour()->InitMove(x,y,z);
85 // firstime create 2 control points and move one control point
86 int size=GetManualViewBaseContour()->GetNumberOfPoints();
91 bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
105 bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
110 GetManualViewBaseContour()->Refresh();
112 // ----------------------------------------------------------------------------
114 void manualCircleControler::MouseMove(int x, int y) // virtual
117 // this->_vtkInteractorStyleBaseView->
119 GetManualViewBaseContour()->SelectPosibleContour(x,y,z);
120 GetManualViewBaseContour()->SelectPosiblePoint(x,y,z);
122 if (GetState()==1){ SetPoint( bakIdPoint , x , y ,z); }
123 if (GetState()==5){ SetPoint( bakIdPoint , x , y ,z); }
126 GetManualViewBaseContour()->MoveContour(x,y,z);
128 GetManualViewBaseContour()->Refresh();
132 // ----------------------------------------------------------------------------
133 void manualCircleControler::DeleteActualMousePoint(int x, int y) // virtual
136 // ----------------------------------------------------------------------------
138 void manualCircleControler::InitRoi(int ww, int hh, double porcentage)
143 if (GetManualContourModel()->GetSizeLstPoints() ==0)
152 double pp1=porcentage;
153 double pp2=1-porcentage;
155 // mp = GetManualContourModel()->GetManualPoint(2);
156 // zz=(int)mp->GetZ();
157 // mp->SetPoint(ww*pp1,hh*pp1,zz);
159 mp = GetManualContourModel()->GetManualPoint(1);
161 mp->SetPoint(ww*pp2,hh*pp1,zz);
163 mp = GetManualContourModel()->GetManualPoint(0);
165 mp->SetPoint(ww*pp2,hh*pp2,zz);
167 // mp = GetManualContourModel()->GetManualPoint(3);
168 // zz=(int)mp->GetZ();
169 // mp->SetPoint(ww*pp1,hh*pp2,zz);
171 GetManualViewBaseContour() ->UpdateViewPoint(0);
172 GetManualViewBaseContour() ->UpdateViewPoint(1);
173 // GetManualViewBaseContour() ->UpdateViewPoint(2);
174 // GetManualViewBaseContour() ->UpdateViewPoint(3);
177 GetManualViewBaseContour()->Refresh();
180 // ----------------------------------------------------------------------------
182 void manualCircleControler::SetRoi(int x1, int y1,int x2, int y2)
185 InitRoi( 0 , 0 , 0.2 );
186 mp = GetManualContourModel()->GetManualPoint(2);
190 mp = GetManualContourModel()->GetManualPoint(1);
194 mp = GetManualContourModel()->GetManualPoint(0);
198 mp = GetManualContourModel()->GetManualPoint(3);
202 GetManualViewBaseContour() ->UpdateViewPoint(0);
203 GetManualViewBaseContour() ->UpdateViewPoint(1);
204 GetManualViewBaseContour() ->UpdateViewPoint(2);
205 GetManualViewBaseContour() ->UpdateViewPoint(3);