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 "manualViewRoi.h"
28 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
32 manualViewRoi::manualViewRoi()
36 // ----------------------------------------------------------------------------
37 manualViewRoi::~manualViewRoi()
42 // ----------------------------------------------------------------------------
43 manualViewRoi * manualViewRoi :: Clone()
45 manualViewRoi * clone = new manualViewRoi();
46 CopyAttributesTo(clone);
50 // ---------------------------------------------------------------------------
52 void manualViewRoi::CopyAttributesTo( manualViewRoi * cloneObject)
55 manualViewBaseContour::CopyAttributesTo(cloneObject);
58 // ----------------------------------------------------------------------------
59 void manualViewRoi::RefreshContour() // virtual
61 unsigned int i,ii, np;
62 np = GetNumberOfPoints( );
69 for( i = 0; i < np+1; i++ ) {
71 mp = _manContModel->GetManualPoint(ii);
74 double XX=mp->GetX(),YY=mp->GetY(),ZZ=mp->GetZ();
75 // wxVtk2DBaseView *wxvtk2Dbasevie = (wxVtk2DBaseView*)this->GetWxVtkBaseView();
76 // wxvtk2Dbasevie->TransformCoordinate_spacing_ModelToView(XX,YY,ZZ);
79 // _pts->SetPoint(i, XX,YY,ZZ );
80 _pts->SetPoint(i, XX*_spc[0] , YY*_spc[1] , ZZ*_spc[2] );
84 _pts->SetPoint(0, 0 , 0 , 0);
85 _pts->SetPoint(1, 0 , 0 , 0);
94 // ----------------------------------------------------------------------------
95 int manualViewRoi::GetType() // virtual
100 // ----------------------------------------------------------------------------
102 void manualViewRoi::GetMinMax(double &minX,double &minY, double &maxX, double &maxY)
113 unsigned int size=(unsigned int) _manContModel->GetSizeLstPoints();
115 for( i = 0; i < size; i++ )
118 mp=_manContModel->GetManualPoint(i);
153 // ----------------------------------------------------------------------------
156 bool manualViewRoi::ifTouchContour(int x,int y, int z) // virtual
159 double px1=99999,py1=99999,px2=-99999,py2=-99999;
161 GetMinMax(px1,py1, px2, py2);
166 TransfromCoordViewWorld(xx,yy,zz);
170 double ddx=GetRange();
171 double ddy=GetRange();
173 if ((xx>px1-ddx)&&(xx<px2+ddx) && (yy>py1-ddy)&&(yy<py2+ddy))
178 if ((xx>px1+ddx)&&(xx<px2-ddx) && (yy>py1+ddy)&&(yy<py2-ddy))
183 if ((ok1==true) && (ok2==false))
191 // ----------------------------------------------------------------------------
193 void manualViewRoi::InitMove(int x, int y, int z) // virtual
199 TransfromCoordViewWorld(XX,YY,ZZ);
201 if (_manContModel->GetSizeLstPoints()==4){
202 mp = _manContModel->GetManualPoint(0);
203 _dp0[0]= mp->GetX() - XX;
204 _dp0[1]= mp->GetY() - YY;
207 mp = _manContModel->GetManualPoint(1);
208 _dp1[0]= mp->GetX() - XX;
209 _dp1[1]= mp->GetY() - YY;
212 mp = _manContModel->GetManualPoint(2);
213 _dp2[0]= mp->GetX() - XX;
214 _dp2[1]= mp->GetY() - YY;
217 mp = _manContModel->GetManualPoint(3);
218 _dp3[0]= mp->GetX() - XX;
219 _dp3[1]= mp->GetY() - YY;
224 // ----------------------------------------------------------------------------
226 void manualViewRoi::MoveContour(int x, int y, int z) // virtual
232 TransfromCoordViewWorld(XX,YY,ZZ);
234 mp = _manContModel->GetManualPoint(0);
235 mp->SetPoint(_dp0[0]+XX,_dp0[1]+YY,_dp0[2]);
237 mp = _manContModel->GetManualPoint(1);
238 mp->SetPoint(_dp1[0]+XX,_dp1[1]+YY,_dp0[2]);
240 mp = _manContModel->GetManualPoint(2);
241 mp->SetPoint(_dp2[0]+XX,_dp2[1]+YY,_dp0[2]);
243 mp = _manContModel->GetManualPoint(3);
244 mp->SetPoint(_dp3[0]+XX,_dp3[1]+YY,_dp0[2]);