]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/manualContour.cpp
BUG manaualROIControler
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / manualContour.cpp
index a2b89d7dea2e27b51f790f7608d30ba22c3d698d..7b424d2ad1660517757fc1e1661c14432f2db2f1 100644 (file)
@@ -144,8 +144,8 @@ void manualContourModelCircle::UpdateSpline() // virtal
 manualContourModelLine::manualContourModelLine()
 : manualContourModel()
 {
-       SetNumberOfPointsSpline(2);
-       SetNumberOfPointsSpline(2);
+       SetNumberOfPointsSpline(20);
+       this->SetCloseContour(false);
 }
 
 manualContourModelLine::~manualContourModelLine()
@@ -174,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)
@@ -210,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;
-       }
-*/
 }
-
+*/
 
 
 // ----------------------------------------------------------------------------
@@ -511,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;
 }
 
 //----------------------------------------------------------------
@@ -894,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
        }
 //-----------------------------------------------------------------------------------------------------------
 }
@@ -1517,7 +1494,6 @@ void manualViewContour::RefreshContour() // virtual
     nps = _manContModel->GetNumberOfPointsSpline();
        //delta=( double ) ( np  ) / ( double ) ( nps-1  );             //JSTG 25-02-08
 
-//printf ("EED manualViewContour::RefreshContour>> %d %d \n", np,nps);
 
        if ( _pts!=NULL )
        {
@@ -1533,10 +1509,6 @@ void manualViewContour::RefreshContour() // virtual
        // EED 27 sep 2006
        //                      _pts->SetPoint(i, x,y,z );
                                _pts->SetPoint(i , x*_spc[0] , y*_spc[1] , z*_spc[2] );
-//if (i%15==0)
-//{
-//     printf ("EED manualViewContour::RefreshContour>> %d : %f %f %f \n", i,x,y,z);
-//}
 
 
                        }// for
@@ -1634,9 +1606,7 @@ bool manualViewContour::ifTouchContour(int x,int y,int z){
                nps_t = nps-1;
        }
 
-       //ED
-       //printf("\n Number of points %d ",nps_t);
-
+       
        for( i = 0; i < nps_t; i++ ) 
        {
                _pts->GetPoint(i%nps, ppA);
@@ -1645,8 +1615,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("\n Dist1 %f Dist2 %f Dist3 %f PT %d", d1,d2,d3,i);    
 
                if (  ((d1+d2)>=d3) &&  ((d1+d2)<=d3*1.3) ) 
                {
@@ -1654,6 +1622,7 @@ bool manualViewContour::ifTouchContour(int x,int y,int z){
                        i=nps;
                }
        }
+       
        return result;
 }
 
@@ -2284,7 +2253,7 @@ bool manualViewRoi::ifTouchContour(int x,int y, int z) // virtual
        {
                result=true;
        }
-
+               
        return result;
 }
 
@@ -2570,6 +2539,7 @@ void manualViewCircle::MoveContour(int x, int y, int z) // virtual
 
 manualViewLine::manualViewLine()
 {
+       _sizePointsContour=20;
 }
 // ----------------------------------------------------------------------------
 manualViewLine::~manualViewLine()
@@ -2815,7 +2785,7 @@ void manualViewBaseContour :: RemoveControlPoints()
        SetIfViewControlPoints( false );
 }
 // ----------------------------------------------------------------------------
-void manualViewBaseContour :: AddControlPoints()
+void manualViewBaseContour::AddControlPoints()
 {
        vtkRenderer * theRenderer = _wxvtkbaseview->GetRenderer();
        SetIfViewControlPoints( true );
@@ -2960,7 +2930,7 @@ void manualViewBaseContour::UpdateViewPoint(int id) // virtual
 }
 
 // ----------------------------------------------------------------------------
-void manualViewBaseContour :: UpdateViewPoints()
+void manualViewBaseContour::UpdateViewPoints()
 {
        int id, size = _lstViewPoints.size();
        for( id=0; id<size; id++)
@@ -4189,12 +4159,11 @@ void manualContourControler::MouseClickLeft(int x, int y){
                        _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
                        SetState(7);
                }
-       }
-       else
-       {
+       }else{
                SetPosibleToMove( true );
                GetManualViewBaseContour()->SetSelected( GetManualViewBaseContour()->GetPosibleSelected() );
-       }
+       } // IsEditable
+       
        if ( GetState() == 0 && GetManualViewBaseContour()->GetPosibleSelected() )
        {
                SetMoving( true );
@@ -4461,17 +4430,38 @@ void manualRoiControler::Configure() //virtual
 }
 
 // ----------------------------------------------------------------------------
+
 void manualRoiControler::MouseClickLeft(int x, int y){
        int z = GetZ();
-       if ( (GetState()==0) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)!=-1 ) ){
-               bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
-               SetState(5);
-       }
+       
+       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(5);
+               }
+       }
+       
+/*EED 21 Avril 2009
        if (GetState()==0) {
                if (size==0){
                        AddPoint(x,y,z);
@@ -4487,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
 {
@@ -4496,6 +4489,7 @@ void manualRoiControler::MouseMove(int x, int y) // virtual
 
 //     this->_vtkInteractorStyleBaseView->
 
+                  
        GetManualViewBaseContour()->SelectPosibleContour(x,y,z);
        GetManualViewBaseContour()->SelectPosiblePoint(x,y,z);
 
@@ -4644,30 +4638,46 @@ void manualCircleControler::Configure() //virtual
 // ----------------------------------------------------------------------------
 void manualCircleControler::MouseClickLeft(int x, int y){
        int z = GetZ();
-       if ( (GetState()==0) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)!=-1 ) ){
-               bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
-               SetState(5);
-       }
+       
+       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);
        }
+       
+       // firstime create 2 control points and move one control 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(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();
 }
 // ----------------------------------------------------------------------------
@@ -4675,7 +4685,6 @@ void manualCircleControler::MouseClickLeft(int x, int y){
 void manualCircleControler::MouseMove(int x, int y) // virtual
 {
        int z=GetZ();
-
 //     this->_vtkInteractorStyleBaseView->
 
        GetManualViewBaseContour()->SelectPosibleContour(x,y,z);
@@ -4683,29 +4692,6 @@ void manualCircleControler::MouseMove(int x, int y) // virtual
 
        if (GetState()==5){
                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);
@@ -4825,18 +4811,38 @@ void manualLineControler::CopyAttributesTo( manualLineControler * cloneObject)
        manualContourBaseControler::CopyAttributesTo(cloneObject);
 }
 
+
 // ----------------------------------------------------------------------------
 void manualLineControler::MouseClickLeft(int x, int y){
        int z = GetZ();
-       if ( (GetState()==0) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)!=-1 ) ){
-               bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);     
-               SetState(5);
-       }
+       
+       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);
        }
+       
+       // fist time create 2 control points and move a control point
        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); 
@@ -4848,6 +4854,8 @@ void manualLineControler::MouseClickLeft(int x, int y){
                bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);     
                SetState(5);
        }
+*/
+       
        GetManualViewBaseContour()->Refresh();
 }
 // ----------------------------------------------------------------------------
@@ -4917,7 +4925,7 @@ manualContourBaseControler::manualContourBaseControler()
        _manViewBaseCont        = NULL;
        _manContModel           = NULL;
        _state                          = 0;
-       _z                                      = -900;
+       _z                                      = 900;
        _editable                       = true;
        _posibleToMove          = true;
        _moving                         = false;