1 #include "manualRoiControler.h"
3 // ----------------------------------------------------------------------------
4 // ----------------------------------------------------------------------------
5 // ----------------------------------------------------------------------------
7 // _state = 0 // ..nothing..
8 // _state = 5 // move point
9 // _state = 6 // move all
10 // _state = 7 // Empty mouse drag
12 manualRoiControler::manualRoiControler()
15 // ----------------------------------------------------------------------------
16 manualRoiControler::~manualRoiControler()
19 // ----------------------------------------------------------------------------
20 manualRoiControler * manualRoiControler :: Clone() // virtual
22 manualRoiControler * clone = new manualRoiControler();
23 CopyAttributesTo(clone);
27 // ---------------------------------------------------------------------------
28 void manualRoiControler::CopyAttributesTo( manualRoiControler * cloneObject)
31 manualContourBaseControler::CopyAttributesTo(cloneObject);
34 // ----------------------------------------------------------------------------
35 void manualRoiControler::Configure() //virtual
37 this->GetManualContourModel()->SetNumberOfPointsSpline(5);
40 // ----------------------------------------------------------------------------
42 void manualRoiControler::MouseClickLeft(int x, int y){
46 { // move control point
47 if ( (GetState()==0) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)!=-1 ) ){
48 bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
54 if ((GetState()==0) && (GetManualViewBaseContour()->GetPosibleSelected()==true)) {
55 GetManualViewBaseContour()->InitMove(x,y,z);
59 // if the firs time create 4 control points and move one point
60 int size=GetManualViewBaseContour()->GetNumberOfPoints();
67 bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
85 bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
90 GetManualViewBaseContour()->Refresh();
93 // ----------------------------------------------------------------------------
94 void manualRoiControler::MouseMove(int x, int y) // virtual
97 printf("manualRoiControler::MouseClickLeft %d %d\n",x ,y);
101 // this->_vtkInteractorStyleBaseView->
104 GetManualViewBaseContour()->SelectPosibleContour(x,y,z);
105 GetManualViewBaseContour()->SelectPosiblePoint(x,y,z);
108 if ( (GetState()==5) || (GetState()==1) ){
109 SetPoint( bakIdPoint , x , y ,z);
132 GetManualViewBaseContour()->MoveContour(x,y,z);
134 GetManualViewBaseContour()->Refresh();
136 // ----------------------------------------------------------------------------
137 void manualRoiControler::DeleteActualMousePoint(int x, int y) // virtual
140 // ----------------------------------------------------------------------------
141 void manualRoiControler::InitRoi(int ww, int hh, double porcentage)
146 if (GetManualContourModel()->GetSizeLstPoints() ==0)
155 double pp1=porcentage;
156 double pp2=1-porcentage;
158 mp = GetManualContourModel()->GetManualPoint(2);
160 mp->SetPoint(ww*pp1,hh*pp1,zz);
162 mp = GetManualContourModel()->GetManualPoint(1);
164 mp->SetPoint(ww*pp2,hh*pp1,zz);
166 mp = GetManualContourModel()->GetManualPoint(0);
168 mp->SetPoint(ww*pp2,hh*pp2,zz);
170 mp = GetManualContourModel()->GetManualPoint(3);
172 mp->SetPoint(ww*pp1,hh*pp2,zz);
174 GetManualViewBaseContour() ->UpdateViewPoint(0);
175 GetManualViewBaseContour() ->UpdateViewPoint(1);
176 GetManualViewBaseContour() ->UpdateViewPoint(2);
177 GetManualViewBaseContour() ->UpdateViewPoint(3);
180 GetManualViewBaseContour()->Refresh();
183 // ----------------------------------------------------------------------------
184 void manualRoiControler::SetRoi(int x1, int y1,int x2, int y2)
187 InitRoi( 0 , 0 , 0.2 );
188 mp = GetManualContourModel()->GetManualPoint(2);
192 mp = GetManualContourModel()->GetManualPoint(1);
196 mp = GetManualContourModel()->GetManualPoint(0);
200 mp = GetManualContourModel()->GetManualPoint(3);
204 GetManualViewBaseContour() ->UpdateViewPoint(0);
205 GetManualViewBaseContour() ->UpdateViewPoint(1);
206 GetManualViewBaseContour() ->UpdateViewPoint(2);
207 GetManualViewBaseContour() ->UpdateViewPoint(3);