]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/manualContour.cpp
Fix BUG interaction Line, Rectangle, Circle
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / manualContour.cpp
index eb975901ae488789cf2e5efa1e9053a5d55a36e1..1e211963c23697acf53f6bcb3ce1864e2a152d7f 100644 (file)
@@ -144,7 +144,8 @@ void manualContourModelCircle::UpdateSpline() // virtal
 manualContourModelLine::manualContourModelLine()
 : manualContourModel()
 {
-       SetNumberOfPointsSpline(2);
+       SetNumberOfPointsSpline(20);
+       this->SetCloseContour(false);
 }
 
 manualContourModelLine::~manualContourModelLine()
@@ -173,8 +174,10 @@ int manualContourModelLine::GetTypeModel() //virtual
        return 6;
 }
 
+
 //----------------------------------------------------------------
-void manualContourModelLine::GetSpline_i_Point(int i, double *x, double *y, double *z) // virtal
+/*
+void manualContourModelLine::GetSpline_i_Point(int i, double *x, double *y, double *z) // virtual
 {
        int np  = GetSizeLstPoints();
        if (np==0)
@@ -209,34 +212,8 @@ void manualContourModelLine::GetSpline_i_Point(int i, double *x, double *y, doub
                *z      = mp->GetZ();
        }
 
-/*
-       manualPoint     *mp;
-       double difX,difY;
-    int np     = GetSizeLstPoints( );
-       int nps = GetNumberOfPointsSpline();
-//     _deltaAngle=(3.14159265*2)/(nps-1);
-       _deltaAngle = 100/nps;
-
-       if (np==2){
-
-               if (i==0){
-                       mp                      = GetManualPoint(0);
-               } else {
-                       mp                      = GetManualPoint(1);
-               }
-
-               *x = mp->GetX();
-               *y = mp->GetY();
-               *z = mp->GetZ();
-
-       }else {
-               *x=-1;
-               *y=-1;
-               *z=-1;
-       }
-*/
 }
-
+*/
 
 
 // ----------------------------------------------------------------------------
@@ -510,7 +487,7 @@ void manualContourModelBullEyeSector::GetSpline_i_Point(int i, double *x, double
 
        *x = _ww*radio*angcos + _cx;
        *y = _hh*radio*angsin + _cy;
-       *z= -900;
+       *z= 900;
 }
 
 //----------------------------------------------------------------
@@ -893,7 +870,8 @@ void manualContourModel::UpdateSpline() // virtual
        {
                _delta_JSTG = (double) (np) / double (_sizePointsContour - 1);  //Without the -1 the curve is not close
        } else {
-               _delta_JSTG = (double) (np-1) / double (_sizePointsContour );  //Without the -1 the curve is not close
+//             _delta_JSTG = (double) (np-1) / double (_sizePointsContour );  //Without the -1 the curve is not close
+               _delta_JSTG = (double) (np) / double (_sizePointsContour-1 );  //Without the -1 the curve is not close
        }
 //-----------------------------------------------------------------------------------------------------------
 }
@@ -1625,6 +1603,7 @@ bool manualViewContour::ifTouchContour(int x,int y,int z){
 
     unsigned int i, nps,nps_t;
     nps          = _sizePointsContour;
+       
        if (this->_manContModel->IfCloseContour()==true)
        {
                nps_t = nps;
@@ -1632,9 +1611,7 @@ bool manualViewContour::ifTouchContour(int x,int y,int z){
                nps_t = nps-1;
        }
 
-       //ED
-       printf("\n>%d ",nps_t);
-
+       
        for( i = 0; i < nps_t; i++ ) 
        {
                _pts->GetPoint(i%nps, ppA);
@@ -1643,8 +1620,6 @@ bool manualViewContour::ifTouchContour(int x,int y,int z){
                d2= sqrt( (ppB[0]-xx)*(ppB[0]-xx) + (ppB[1]-yy)*(ppB[1]-yy) + (ppB[2]-zz)*(ppB[2]-zz));
                d3= sqrt( (ppB[0]-ppA[0])*(ppB[0]-ppA[0]) + (ppB[1]-ppA[1])*(ppB[1]-ppA[1]) + (ppB[2]-ppA[2])*(ppB[2]-ppA[2]));
 
-               //ED
-               printf("%d %f %f %f - ", i,d1,d2,d3);   
 
                if (  ((d1+d2)>=d3) &&  ((d1+d2)<=d3*1.3) ) 
                {
@@ -1652,6 +1627,7 @@ bool manualViewContour::ifTouchContour(int x,int y,int z){
                        i=nps;
                }
        }
+       
        return result;
 }
 
@@ -2250,10 +2226,11 @@ void manualViewRoi::GetMinMax(double &minX,double &minY, double &maxX, double &m
 
 // ----------------------------------------------------------------------------
 
+
 bool manualViewRoi::ifTouchContour(int x,int y, int z) // virtual
 {
        bool    result=false;
-       double  px1=99999,py1=99999,px2=-9999,py2=-99999;
+       double  px1=99999,py1=99999,px2=-99999,py2=-99999;
 
        GetMinMax(px1,py1, px2, py2);
 
@@ -2285,7 +2262,6 @@ bool manualViewRoi::ifTouchContour(int x,int y, int z) // virtual
        return result;
 }
 
-
 // ----------------------------------------------------------------------------
 
 void manualViewRoi::InitMove(int x, int y, int z)  // virtual
@@ -2568,6 +2544,7 @@ void manualViewCircle::MoveContour(int x, int y, int z) // virtual
 
 manualViewLine::manualViewLine()
 {
+       _sizePointsContour=20;
 }
 // ----------------------------------------------------------------------------
 manualViewLine::~manualViewLine()
@@ -2888,11 +2865,13 @@ void manualViewBaseContour::ConstructVTKObjects()
                _pts->SetPoint(i,       0       , 0     , 0 );
        }
        // This is for the boundaring inicialisation
+
 //EED 29Mars2009       
        _pts->SetPoint(0,       0       , 0     , -1000 );
        _pts->SetPoint(1,       0       , 0     ,  1000 );
-//     _pts->SetPoint(0, -1000 , -1000 , -1000 );
-//     _pts->SetPoint(1, 1000  , 1000  , 1000  );
+//     _pts->SetPoint(0,       -1000   , -1000 , -1000 );
+//     _pts->SetPoint(1,       1000    , 1000  , 1000  );
+
 
        vtkCellArray *lines = vtkCellArray::New();
        lines->InsertNextCell( nps /* +1 */ );
@@ -4457,6 +4436,7 @@ void manualRoiControler::Configure() //virtual
 }
 
 // ----------------------------------------------------------------------------
+
 void manualRoiControler::MouseClickLeft(int x, int y){
        int z = GetZ();
        if ( (GetState()==0) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)!=-1 ) ){
@@ -4467,7 +4447,21 @@ void manualRoiControler::MouseClickLeft(int x, int y){
                GetManualViewBaseContour()->InitMove(x,y,z);
                SetState(6);
        }
+       
+       
        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(5);
+               }
+       }
+       
+/*EED 21 Avril 2009
        if (GetState()==0) {
                if (size==0){
                        AddPoint(x,y,z);
@@ -4483,8 +4477,11 @@ void manualRoiControler::MouseClickLeft(int x, int y){
                bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
                SetState(5);
        }
+*/
+       
        GetManualViewBaseContour()->Refresh();
 }
+
 // ----------------------------------------------------------------------------
 void manualRoiControler::MouseMove(int x, int y) // virtual
 {
@@ -4653,17 +4650,25 @@ void manualCircleControler::MouseClickLeft(int x, int y){
                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(5);
+               }
+       }       
+       
+/*EED 21 Avril 2009    
+       if (GetState()==0) {
+               if (size==0){
+                       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();
 }
 // ----------------------------------------------------------------------------
@@ -4821,6 +4826,7 @@ void manualLineControler::CopyAttributesTo( manualLineControler * cloneObject)
        manualContourBaseControler::CopyAttributesTo(cloneObject);
 }
 
+
 // ----------------------------------------------------------------------------
 void manualLineControler::MouseClickLeft(int x, int y){
        int z = GetZ();
@@ -4832,7 +4838,19 @@ void manualLineControler::MouseClickLeft(int x, int y){
                GetManualViewBaseContour()->InitMove(x,y,z);
                SetState(6);
        }
+       
        int size=GetManualViewBaseContour()->GetNumberOfPoints();
+       if (GetState()==0) { 
+               if (size==0){
+                       AddPoint(x,y,z); 
+                       AddPoint(x,y,z); 
+                       bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);     
+                       SetState(5);
+               }
+       }
+       
+       
+/*EED 21 Avril 2009            
        if (GetState()==0) { 
                if (size==0){
                        AddPoint(x,y,z); 
@@ -4844,6 +4862,8 @@ void manualLineControler::MouseClickLeft(int x, int y){
                bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);     
                SetState(5);
        }
+*/
+       
        GetManualViewBaseContour()->Refresh();
 }
 // ----------------------------------------------------------------------------
@@ -4913,7 +4933,7 @@ manualContourBaseControler::manualContourBaseControler()
        _manViewBaseCont        = NULL;
        _manContModel           = NULL;
        _state                          = 0;
-       _z                                      = -900;
+       _z                                      = 900;
        _editable                       = true;
        _posibleToMove          = true;
        _moving                         = false;