manualViewRoi.cpp
Go to the documentation of this file.00001 #include "manualViewRoi.h"
00002
00003
00004
00005
00006
00007 manualViewRoi::manualViewRoi()
00008 {
00009 _sizePointsContour=5;
00010 }
00011
00012 manualViewRoi::~manualViewRoi()
00013 {
00014 }
00015
00016
00017
00018 manualViewRoi * manualViewRoi :: Clone()
00019 {
00020 manualViewRoi * clone = new manualViewRoi();
00021 CopyAttributesTo(clone);
00022 return clone;
00023 }
00024
00025
00026
00027 void manualViewRoi::CopyAttributesTo( manualViewRoi * cloneObject)
00028 {
00029
00030 manualViewBaseContour::CopyAttributesTo(cloneObject);
00031 }
00032
00033
00034 void manualViewRoi::RefreshContour()
00035 {
00036 unsigned int i,ii, np;
00037 np = GetNumberOfPoints( );
00038
00039 if ( np > 0)
00040 {
00041 if (np>=2)
00042 {
00043 manualPoint *mp;
00044 for( i = 0; i < np+1; i++ ) {
00045 ii=i%np;
00046 mp = _manContModel->GetManualPoint(ii);
00047
00048
00049 double XX=mp->GetX(),YY=mp->GetY(),ZZ=mp->GetZ();
00050
00051
00052
00053
00054
00055 _pts->SetPoint(i, XX*_spc[0] , YY*_spc[1] , ZZ*_spc[2] );
00056 }
00057
00058 } else {
00059 _pts->SetPoint(0, 0 , 0 , 0);
00060 _pts->SetPoint(1, 0 , 0 , 0);
00061 }
00062 }
00063 }
00064
00065
00066 int manualViewRoi::GetType()
00067 {
00068 return 2;
00069 }
00070
00071
00072
00073 void manualViewRoi::GetMinMax(double &minX,double &minY, double &maxX, double &maxY)
00074 {
00075 double pp[3];
00076 manualPoint *mp;
00077 unsigned int i;
00078
00079 minX=99999;
00080 minY=99999;
00081 maxX=-99999;
00082 maxY=-99999;
00083
00084 unsigned int size=(unsigned int) _manContModel->GetSizeLstPoints();
00085
00086 for( i = 0; i < size; i++ )
00087 {
00088
00089 mp=_manContModel->GetManualPoint(i);
00090 pp[0]=mp->GetX();
00091 pp[1]=mp->GetY();
00092
00093
00094 if (pp[0]<minX)
00095 {
00096 minX=pp[0];
00097 }
00098
00099 if (pp[1]<minY)
00100 {
00101 minY=pp[1];
00102 }
00103
00104 if (pp[0]>maxX)
00105 {
00106 maxX=pp[0];
00107 }
00108
00109 if (pp[1]>maxY)
00110 {
00111 maxY=pp[1];
00112 }
00113 }
00114
00115 if ( size<1 )
00116 {
00117 minX=0;
00118 maxX=0;
00119 minY=0;
00120 maxY=0;
00121 }
00122 }
00123
00124
00125
00126
00127 bool manualViewRoi::ifTouchContour(int x,int y, int z)
00128 {
00129 bool result=false;
00130 double px1=99999,py1=99999,px2=-99999,py2=-99999;
00131
00132 GetMinMax(px1,py1, px2, py2);
00133
00134 double xx=x;
00135 double yy=y;
00136 double zz=z;
00137 TransfromCoordViewWorld(xx,yy,zz);
00138
00139 bool ok1=false;
00140 bool ok2=false;
00141 double ddx=GetRange();
00142 double ddy=GetRange();
00143
00144 if ((xx>px1-ddx)&&(xx<px2+ddx) && (yy>py1-ddy)&&(yy<py2+ddy))
00145 {
00146 ok1=true;
00147 }
00148
00149 if ((xx>px1+ddx)&&(xx<px2-ddx) && (yy>py1+ddy)&&(yy<py2-ddy))
00150 {
00151 ok2=true;
00152 }
00153
00154 if ((ok1==true) && (ok2==false))
00155 {
00156 result=true;
00157 }
00158
00159 return result;
00160 }
00161
00162
00163
00164 void manualViewRoi::InitMove(int x, int y, int z)
00165 {
00166 manualPoint *mp;
00167 double XX=x;
00168 double YY=y;
00169 double ZZ=z;
00170 TransfromCoordViewWorld(XX,YY,ZZ);
00171
00172 if (_manContModel->GetSizeLstPoints()==4){
00173 mp = _manContModel->GetManualPoint(0);
00174 _dp0[0]= mp->GetX() - XX;
00175 _dp0[1]= mp->GetY() - YY;
00176 _dp0[2]= mp->GetZ();
00177
00178 mp = _manContModel->GetManualPoint(1);
00179 _dp1[0]= mp->GetX() - XX;
00180 _dp1[1]= mp->GetY() - YY;
00181 _dp1[2]= mp->GetZ();
00182
00183 mp = _manContModel->GetManualPoint(2);
00184 _dp2[0]= mp->GetX() - XX;
00185 _dp2[1]= mp->GetY() - YY;
00186 _dp2[2]= mp->GetZ();
00187
00188 mp = _manContModel->GetManualPoint(3);
00189 _dp3[0]= mp->GetX() - XX;
00190 _dp3[1]= mp->GetY() - YY;
00191 _dp3[2]= mp->GetZ();
00192 }
00193 }
00194
00195
00196
00197 void manualViewRoi::MoveContour(int x, int y, int z)
00198 {
00199 manualPoint *mp;
00200 double XX=x;
00201 double YY=y;
00202 double ZZ=z;
00203 TransfromCoordViewWorld(XX,YY,ZZ);
00204
00205 mp = _manContModel->GetManualPoint(0);
00206 mp->SetPoint(_dp0[0]+XX,_dp0[1]+YY,_dp0[2]);
00207
00208 mp = _manContModel->GetManualPoint(1);
00209 mp->SetPoint(_dp1[0]+XX,_dp1[1]+YY,_dp0[2]);
00210
00211 mp = _manContModel->GetManualPoint(2);
00212 mp->SetPoint(_dp2[0]+XX,_dp2[1]+YY,_dp0[2]);
00213
00214 mp = _manContModel->GetManualPoint(3);
00215 mp->SetPoint(_dp3[0]+XX,_dp3[1]+YY,_dp0[2]);
00216
00217 UpdateViewPoint(0);
00218 UpdateViewPoint(1);
00219 UpdateViewPoint(2);
00220 UpdateViewPoint(3);
00221
00222 }