00001 #include "manualRoiControler.h"
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 manualRoiControler::manualRoiControler()
00013 {
00014 }
00015
00016 manualRoiControler::~manualRoiControler()
00017 {
00018 }
00019
00020 manualRoiControler * manualRoiControler :: Clone()
00021 {
00022 manualRoiControler * clone = new manualRoiControler();
00023 CopyAttributesTo(clone);
00024 return clone;
00025 }
00026
00027
00028 void manualRoiControler::CopyAttributesTo( manualRoiControler * cloneObject)
00029 {
00030
00031 manualContourBaseControler::CopyAttributesTo(cloneObject);
00032 }
00033
00034
00035 void manualRoiControler::Configure()
00036 {
00037 this->GetManualContourModel()->SetNumberOfPointsSpline(5);
00038 }
00039
00040
00041
00042 void manualRoiControler::MouseClickLeft(int x, int y){
00043 int z = GetZ();
00044
00045 if( IsEditable() )
00046 {
00047 if ( (GetState()==0) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)!=-1 ) ){
00048 bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
00049 SetState(5);
00050 }
00051 }
00052
00053
00054 if ((GetState()==0) && (GetManualViewBaseContour()->GetPosibleSelected()==true)) {
00055 GetManualViewBaseContour()->InitMove(x,y,z);
00056 SetState(6);
00057 }
00058
00059
00060 int size=GetManualViewBaseContour()->GetNumberOfPoints();
00061 if (GetState()==0) {
00062 if (size==0){
00063 AddPoint(x,y,z);
00064 AddPoint(x,y,z);
00065 AddPoint(x,y,z);
00066 AddPoint(x,y,z);
00067 bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
00068 SetState(1);
00069 }
00070 }
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090 GetManualViewBaseContour()->Refresh();
00091 }
00092
00093
00094 void manualRoiControler::MouseMove(int x, int y)
00095 {
00096 int z=GetZ();
00097
00098
00099
00100
00101 GetManualViewBaseContour()->SelectPosibleContour(x,y,z);
00102 GetManualViewBaseContour()->SelectPosiblePoint(x,y,z);
00103
00104
00105 if ( (GetState()==5) || (GetState()==1) ){
00106 SetPoint( bakIdPoint , x , y ,z);
00107 if (bakIdPoint==0)
00108 {
00109 SetPointX( 1 , x );
00110 SetPointY( 3 , y );
00111 }
00112 if (bakIdPoint==1)
00113 {
00114 SetPointX( 0 , x );
00115 SetPointY( 2 , y );
00116 }
00117 if (bakIdPoint==2)
00118 {
00119 SetPointX( 3 , x );
00120 SetPointY( 1 , y );
00121 }
00122 if (bakIdPoint==3)
00123 {
00124 SetPointX( 2 , x );
00125 SetPointY( 0 , y );
00126 }
00127 }
00128 if (GetState()==6){
00129 GetManualViewBaseContour()->MoveContour(x,y,z);
00130 }
00131 GetManualViewBaseContour()->Refresh();
00132 }
00133
00134 void manualRoiControler::DeleteActualMousePoint(int x, int y)
00135 {
00136 }
00137
00138 void manualRoiControler::InitRoi(int ww, int hh, double porcentage)
00139 {
00140 int zz;
00141 manualPoint *mp;
00142
00143 if (GetManualContourModel()->GetSizeLstPoints() ==0)
00144 {
00145 zz = GetZ();
00146 AddPoint(0,0,zz);
00147 AddPoint(0,0,zz);
00148 AddPoint(0,0,zz);
00149 AddPoint(0,0,zz);
00150 }
00151
00152 double pp1=porcentage;
00153 double pp2=1-porcentage;
00154
00155 mp = GetManualContourModel()->GetManualPoint(2);
00156 zz=(int)mp->GetZ();
00157 mp->SetPoint(ww*pp1,hh*pp1,zz);
00158
00159 mp = GetManualContourModel()->GetManualPoint(1);
00160 zz=(int)mp->GetZ();
00161 mp->SetPoint(ww*pp2,hh*pp1,zz);
00162
00163 mp = GetManualContourModel()->GetManualPoint(0);
00164 zz=(int)mp->GetZ();
00165 mp->SetPoint(ww*pp2,hh*pp2,zz);
00166
00167 mp = GetManualContourModel()->GetManualPoint(3);
00168 zz=(int)mp->GetZ();
00169 mp->SetPoint(ww*pp1,hh*pp2,zz);
00170
00171 GetManualViewBaseContour() ->UpdateViewPoint(0);
00172 GetManualViewBaseContour() ->UpdateViewPoint(1);
00173 GetManualViewBaseContour() ->UpdateViewPoint(2);
00174 GetManualViewBaseContour() ->UpdateViewPoint(3);
00175
00176 SetState(0);
00177 GetManualViewBaseContour()->Refresh();
00178 }
00179
00180
00181 void manualRoiControler::SetRoi(int x1, int y1,int x2, int y2)
00182 {
00183 manualPoint *mp;
00184 InitRoi( 0 , 0 , 0.2 );
00185 mp = GetManualContourModel()->GetManualPoint(2);
00186 mp->SetPointX(x1);
00187 mp->SetPointY(y1);
00188
00189 mp = GetManualContourModel()->GetManualPoint(1);
00190 mp->SetPointX(x2);
00191 mp->SetPointY(y1);
00192
00193 mp = GetManualContourModel()->GetManualPoint(0);
00194 mp->SetPointX(x2);
00195 mp->SetPointY(y2);
00196
00197 mp = GetManualContourModel()->GetManualPoint(3);
00198 mp->SetPointX(x1);
00199 mp->SetPointY(y2);
00200
00201 GetManualViewBaseContour() ->UpdateViewPoint(0);
00202 GetManualViewBaseContour() ->UpdateViewPoint(1);
00203 GetManualViewBaseContour() ->UpdateViewPoint(2);
00204 GetManualViewBaseContour() ->UpdateViewPoint(3);
00205 }
00206