manualCircleControler.cpp

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

Generated on 18 Mar 2010 for creaMaracasVisu_lib by  doxygen 1.6.1