manualRoiControler.cpp

Go to the documentation of this file.
00001 #include "manualRoiControler.h"
00002 
00003 // ----------------------------------------------------------------------------
00004 // ----------------------------------------------------------------------------
00005 // ----------------------------------------------------------------------------
00006 
00007 // _state = 0  // ..nothing..
00008 // _state = 5  // move point
00009 // _state = 6  // move all
00010 // _state = 7  // Empty mouse drag
00011 
00012 manualRoiControler::manualRoiControler()
00013 {
00014 }
00015 // ----------------------------------------------------------------------------
00016 manualRoiControler::~manualRoiControler()
00017 {
00018 }
00019 // ----------------------------------------------------------------------------
00020 manualRoiControler * manualRoiControler :: Clone()  // virtual
00021 {
00022         manualRoiControler * clone = new manualRoiControler();
00023         CopyAttributesTo(clone);
00024         return clone;
00025 }
00026 
00027 // ---------------------------------------------------------------------------
00028 void manualRoiControler::CopyAttributesTo( manualRoiControler * cloneObject)
00029 {
00030         // Fathers object
00031         manualContourBaseControler::CopyAttributesTo(cloneObject);
00032 }
00033 
00034 // ----------------------------------------------------------------------------
00035 void manualRoiControler::Configure() //virtual
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         {       // move control point
00047           if ( (GetState()==0) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)!=-1 ) ){
00048                   bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
00049                   SetState(5);
00050           }
00051         } // IsEditable
00052 
00053         // Move contour
00054         if ((GetState()==0) && (GetManualViewBaseContour()->GetPosibleSelected()==true))        {
00055                 GetManualViewBaseContour()->InitMove(x,y,z);
00056                 SetState(6);
00057         }
00058 
00059         // if the firs time create 4 control points and move one point
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 /*EED 21 Avril 2009
00073         if (GetState()==0) {
00074                 if (size==0){
00075                         AddPoint(x,y,z);
00076                         AddPoint(x,y,z);
00077                         AddPoint(x,y,z);
00078                         AddPoint(x,y,z);
00079                 } else {
00080                         SetPoint(0,x,y,z);
00081                         SetPoint(1,x,y,z);
00082                         SetPoint(2,x,y,z);
00083                         SetPoint(3,x,y,z);
00084                 }
00085                 bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
00086                 SetState(5);
00087         }
00088 */
00089 
00090         GetManualViewBaseContour()->Refresh();
00091 }
00092 
00093 // ----------------------------------------------------------------------------
00094 void manualRoiControler::MouseMove(int x, int y) // virtual
00095 {
00096 
00097     printf("manualRoiControler::MouseClickLeft %d %d\n",x ,y);
00098 
00099         int z=GetZ();
00100 
00101 //      this->_vtkInteractorStyleBaseView->
00102 
00103 
00104         GetManualViewBaseContour()->SelectPosibleContour(x,y,z);
00105         GetManualViewBaseContour()->SelectPosiblePoint(x,y,z);
00106 
00107 
00108         if ( (GetState()==5) || (GetState()==1) ){
00109                 SetPoint( bakIdPoint , x , y ,z);
00110                 if (bakIdPoint==0)
00111                 {
00112                         SetPointX( 1 , x );
00113                         SetPointY( 3 , y );
00114                 }
00115                 if (bakIdPoint==1)
00116                 {
00117                         SetPointX( 0 , x );
00118                         SetPointY( 2 , y );
00119                 }
00120                 if (bakIdPoint==2)
00121                 {
00122                         SetPointX( 3 , x );
00123                         SetPointY( 1 , y );
00124                 }
00125                 if (bakIdPoint==3)
00126                 {
00127                         SetPointX( 2 , x );
00128                         SetPointY( 0 , y );
00129                 }
00130         }
00131         if (GetState()==6){
00132                 GetManualViewBaseContour()->MoveContour(x,y,z);
00133         }
00134         GetManualViewBaseContour()->Refresh();
00135 }
00136 // ----------------------------------------------------------------------------
00137 void manualRoiControler::DeleteActualMousePoint(int x, int y)  // virtual
00138 {
00139 }
00140 // ----------------------------------------------------------------------------
00141 void manualRoiControler::InitRoi(int ww, int hh, double porcentage)
00142 {
00143         int zz;
00144         manualPoint *mp;
00145 
00146         if (GetManualContourModel()->GetSizeLstPoints() ==0)
00147         {
00148                 zz = GetZ();
00149                 AddPoint(0,0,zz);
00150                 AddPoint(0,0,zz);
00151                 AddPoint(0,0,zz);
00152                 AddPoint(0,0,zz);
00153         }
00154 
00155         double pp1=porcentage;
00156         double pp2=1-porcentage;
00157 
00158         mp = GetManualContourModel()->GetManualPoint(2);
00159         zz=(int)mp->GetZ();
00160         mp->SetPoint(ww*pp1,hh*pp1,zz);
00161 
00162         mp = GetManualContourModel()->GetManualPoint(1);
00163         zz=(int)mp->GetZ();
00164         mp->SetPoint(ww*pp2,hh*pp1,zz);
00165 
00166         mp = GetManualContourModel()->GetManualPoint(0);
00167         zz=(int)mp->GetZ();
00168         mp->SetPoint(ww*pp2,hh*pp2,zz);
00169 
00170         mp = GetManualContourModel()->GetManualPoint(3);
00171         zz=(int)mp->GetZ();
00172         mp->SetPoint(ww*pp1,hh*pp2,zz);
00173 
00174         GetManualViewBaseContour() ->UpdateViewPoint(0);
00175         GetManualViewBaseContour() ->UpdateViewPoint(1);
00176         GetManualViewBaseContour() ->UpdateViewPoint(2);
00177         GetManualViewBaseContour() ->UpdateViewPoint(3);
00178 
00179         SetState(0);
00180         GetManualViewBaseContour()->Refresh();
00181 }
00182 
00183 // ----------------------------------------------------------------------------
00184 void manualRoiControler::SetRoi(int x1, int y1,int x2, int y2)
00185 {
00186         manualPoint *mp;
00187         InitRoi( 0 , 0 , 0.2 );
00188         mp = GetManualContourModel()->GetManualPoint(2);
00189         mp->SetPointX(x1);
00190         mp->SetPointY(y1);
00191 
00192         mp = GetManualContourModel()->GetManualPoint(1);
00193         mp->SetPointX(x2);
00194         mp->SetPointY(y1);
00195 
00196         mp = GetManualContourModel()->GetManualPoint(0);
00197         mp->SetPointX(x2);
00198         mp->SetPointY(y2);
00199 
00200         mp = GetManualContourModel()->GetManualPoint(3);
00201         mp->SetPointX(x1);
00202         mp->SetPointY(y2);
00203 
00204         GetManualViewBaseContour() ->UpdateViewPoint(0);
00205         GetManualViewBaseContour() ->UpdateViewPoint(1);
00206         GetManualViewBaseContour() ->UpdateViewPoint(2);
00207         GetManualViewBaseContour() ->UpdateViewPoint(3);
00208 }
00209 

Generated on 20 Oct 2010 for creaMaracasVisu_lib by  doxygen 1.6.1