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 "manualRoiControler.h"
28 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
32 // _state = 0 // ..nothing..
33 // _state = 5 // move point
34 // _state = 6 // move all
35 // _state = 7 // Empty mouse drag
37 manualRoiControler::manualRoiControler()
40 // ----------------------------------------------------------------------------
41 manualRoiControler::~manualRoiControler()
44 // ----------------------------------------------------------------------------
45 manualRoiControler * manualRoiControler :: Clone() // virtual
47 manualRoiControler * clone = new manualRoiControler();
48 CopyAttributesTo(clone);
52 // ---------------------------------------------------------------------------
53 void manualRoiControler::CopyAttributesTo( manualRoiControler * cloneObject)
56 manualContourBaseControler::CopyAttributesTo(cloneObject);
59 // ----------------------------------------------------------------------------
60 void manualRoiControler::Configure() //virtual
62 this->GetManualContourModel()->SetNumberOfPointsSpline(5);
65 // ----------------------------------------------------------------------------
67 void manualRoiControler::MouseClickLeft(int x, int y){
71 { // move control point
72 if ( (GetState()==0) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)!=-1 ) ){
73 bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
79 if ((GetState()==0) && (GetManualViewBaseContour()->GetPosibleSelected()==true)) {
80 GetManualViewBaseContour()->InitMove(x,y,z);
84 // if the firs time create 4 control points and move one point
85 int size=GetManualViewBaseContour()->GetNumberOfPoints();
92 bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
110 bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
115 GetManualViewBaseContour()->Refresh();
118 // ----------------------------------------------------------------------------
119 void manualRoiControler::MouseMove(int x, int y) // virtual
125 // this->_vtkInteractorStyleBaseView->
128 GetManualViewBaseContour()->SelectPosibleContour(x,y,z);
129 GetManualViewBaseContour()->SelectPosiblePoint(x,y,z);
132 if ( (GetState()==5) || (GetState()==1) ){
133 SetPoint( bakIdPoint , x , y ,z);
156 GetManualViewBaseContour()->MoveContour(x,y,z);
158 GetManualViewBaseContour()->Refresh();
160 // ----------------------------------------------------------------------------
161 void manualRoiControler::DeleteActualMousePoint(int x, int y) // virtual
164 // ----------------------------------------------------------------------------
165 void manualRoiControler::InitRoi(int ww, int hh, double porcentage)
170 if (GetManualContourModel()->GetSizeLstPoints() ==0)
179 double pp1=porcentage;
180 double pp2=1-porcentage;
182 mp = GetManualContourModel()->GetManualPoint(2);
184 mp->SetPoint(ww*pp1,hh*pp1,zz);
186 mp = GetManualContourModel()->GetManualPoint(1);
188 mp->SetPoint(ww*pp2,hh*pp1,zz);
190 mp = GetManualContourModel()->GetManualPoint(0);
192 mp->SetPoint(ww*pp2,hh*pp2,zz);
194 mp = GetManualContourModel()->GetManualPoint(3);
196 mp->SetPoint(ww*pp1,hh*pp2,zz);
198 GetManualViewBaseContour() ->UpdateViewPoint(0);
199 GetManualViewBaseContour() ->UpdateViewPoint(1);
200 GetManualViewBaseContour() ->UpdateViewPoint(2);
201 GetManualViewBaseContour() ->UpdateViewPoint(3);
204 GetManualViewBaseContour()->Refresh();
207 // ----------------------------------------------------------------------------
208 void manualRoiControler::SetRoi(int x1, int y1,int x2, int y2)
211 InitRoi( 0 , 0 , 0.2 );
212 mp = GetManualContourModel()->GetManualPoint(2);
216 mp = GetManualContourModel()->GetManualPoint(1);
220 mp = GetManualContourModel()->GetManualPoint(0);
224 mp = GetManualContourModel()->GetManualPoint(3);
228 GetManualViewBaseContour() ->UpdateViewPoint(0);
229 GetManualViewBaseContour() ->UpdateViewPoint(1);
230 GetManualViewBaseContour() ->UpdateViewPoint(2);
231 GetManualViewBaseContour() ->UpdateViewPoint(3);