#include "manualRoiControler.h" // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // _state = 0 // ..nothing.. // _state = 5 // move point // _state = 6 // move all // _state = 7 // Empty mouse drag manualRoiControler::manualRoiControler() { } // ---------------------------------------------------------------------------- manualRoiControler::~manualRoiControler() { } // ---------------------------------------------------------------------------- manualRoiControler * manualRoiControler :: Clone() // virtual { manualRoiControler * clone = new manualRoiControler(); CopyAttributesTo(clone); return clone; } // --------------------------------------------------------------------------- void manualRoiControler::CopyAttributesTo( manualRoiControler * cloneObject) { // Fathers object manualContourBaseControler::CopyAttributesTo(cloneObject); } // ---------------------------------------------------------------------------- void manualRoiControler::Configure() //virtual { this->GetManualContourModel()->SetNumberOfPointsSpline(5); } // ---------------------------------------------------------------------------- void manualRoiControler::MouseClickLeft(int x, int y){ int z = GetZ(); if( IsEditable() ) { // move control point if ( (GetState()==0) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)!=-1 ) ){ bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z); SetState(5); } } // IsEditable // Move contour if ((GetState()==0) && (GetManualViewBaseContour()->GetPosibleSelected()==true)) { GetManualViewBaseContour()->InitMove(x,y,z); SetState(6); } // if the firs time create 4 control points and move one point int size=GetManualViewBaseContour()->GetNumberOfPoints(); if (GetState()==0) { if (size==0){ AddPoint(x,y,z); AddPoint(x,y,z); AddPoint(x,y,z); AddPoint(x,y,z); bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z); SetState(1); } } /*EED 21 Avril 2009 if (GetState()==0) { if (size==0){ AddPoint(x,y,z); AddPoint(x,y,z); AddPoint(x,y,z); AddPoint(x,y,z); } else { SetPoint(0,x,y,z); SetPoint(1,x,y,z); SetPoint(2,x,y,z); SetPoint(3,x,y,z); } bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z); SetState(5); } */ GetManualViewBaseContour()->Refresh(); } // ---------------------------------------------------------------------------- void manualRoiControler::MouseMove(int x, int y) // virtual { int z=GetZ(); // this->_vtkInteractorStyleBaseView-> GetManualViewBaseContour()->SelectPosibleContour(x,y,z); GetManualViewBaseContour()->SelectPosiblePoint(x,y,z); if ( (GetState()==5) || (GetState()==1) ){ SetPoint( bakIdPoint , x , y ,z); if (bakIdPoint==0) { SetPointX( 1 , x ); SetPointY( 3 , y ); } if (bakIdPoint==1) { SetPointX( 0 , x ); SetPointY( 2 , y ); } if (bakIdPoint==2) { SetPointX( 3 , x ); SetPointY( 1 , y ); } if (bakIdPoint==3) { SetPointX( 2 , x ); SetPointY( 0 , y ); } } if (GetState()==6){ GetManualViewBaseContour()->MoveContour(x,y,z); } GetManualViewBaseContour()->Refresh(); } // ---------------------------------------------------------------------------- void manualRoiControler::DeleteActualMousePoint(int x, int y) // virtual { } // ---------------------------------------------------------------------------- void manualRoiControler::InitRoi(int ww, int hh, double porcentage) { int zz; manualPoint *mp; if (GetManualContourModel()->GetSizeLstPoints() ==0) { zz = GetZ(); AddPoint(0,0,zz); AddPoint(0,0,zz); AddPoint(0,0,zz); AddPoint(0,0,zz); } double pp1=porcentage; double pp2=1-porcentage; mp = GetManualContourModel()->GetManualPoint(2); zz=(int)mp->GetZ(); mp->SetPoint(ww*pp1,hh*pp1,zz); mp = GetManualContourModel()->GetManualPoint(1); zz=(int)mp->GetZ(); mp->SetPoint(ww*pp2,hh*pp1,zz); mp = GetManualContourModel()->GetManualPoint(0); zz=(int)mp->GetZ(); mp->SetPoint(ww*pp2,hh*pp2,zz); mp = GetManualContourModel()->GetManualPoint(3); zz=(int)mp->GetZ(); mp->SetPoint(ww*pp1,hh*pp2,zz); GetManualViewBaseContour() ->UpdateViewPoint(0); GetManualViewBaseContour() ->UpdateViewPoint(1); GetManualViewBaseContour() ->UpdateViewPoint(2); GetManualViewBaseContour() ->UpdateViewPoint(3); SetState(0); GetManualViewBaseContour()->Refresh(); } // ---------------------------------------------------------------------------- void manualRoiControler::SetRoi(int x1, int y1,int x2, int y2) { manualPoint *mp; InitRoi( 0 , 0 , 0.2 ); mp = GetManualContourModel()->GetManualPoint(2); mp->SetPointX(x1); mp->SetPointY(y1); mp = GetManualContourModel()->GetManualPoint(1); mp->SetPointX(x2); mp->SetPointY(y1); mp = GetManualContourModel()->GetManualPoint(0); mp->SetPointX(x2); mp->SetPointY(y2); mp = GetManualContourModel()->GetManualPoint(3); mp->SetPointX(x1); mp->SetPointY(y2); GetManualViewBaseContour() ->UpdateViewPoint(0); GetManualViewBaseContour() ->UpdateViewPoint(1); GetManualViewBaseContour() ->UpdateViewPoint(2); GetManualViewBaseContour() ->UpdateViewPoint(3); }