]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/manualContour.cpp
BUG MacOs
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / manualContour.cpp
index 1e211963c23697acf53f6bcb3ce1864e2a152d7f..af53c28d5423b09f7d35251b4315d741e82f71e7 100644 (file)
@@ -610,6 +610,10 @@ manualContourModel::~manualContourModel()
        }
        _lstPoints.clear();
 
+       _cntSplineX->RemoveAllPoints();
+       _cntSplineY->RemoveAllPoints();
+       _cntSplineZ->RemoveAllPoints();
+       
        _cntSplineX->Delete();
        _cntSplineY->Delete();
        _cntSplineZ->Delete();
@@ -1315,15 +1319,16 @@ vtkActor* manualViewPoint::CreateVtkPointActor()
 
        _pts = vtkPoints::New();
        _pts->SetNumberOfPoints(8);
+
        _pts->SetPoint(0, -1000 , -1000 , 0 );
-       _pts->SetPoint(1,  1000 , -1000 , 0     );
+       _pts->SetPoint(1,  1000 , -1000 , 0 );
        _pts->SetPoint(2,  1000 ,  1000 , 0 );
        _pts->SetPoint(3, -1000 ,  1000 , 0 );
        _pts->SetPoint(4, -1000 ,  1000 , 0 );
        _pts->SetPoint(5, -1000 ,  1000 , 0 );
        _pts->SetPoint(6, -1000 ,  1000 , 0 );
        _pts->SetPoint(7, -1000 ,  1000 , 0 );
-
+       
        vtkCellArray *lines = vtkCellArray::New();
        lines->InsertNextCell(17);
        lines->InsertCellPoint(0);
@@ -1347,17 +1352,17 @@ vtkActor* manualViewPoint::CreateVtkPointActor()
        _pd = vtkPolyData::New();
        _pd->SetPoints( _pts );
        _pd->SetLines( lines );
-       lines->Delete();  //do not delete lines ??
+//     lines->Delete();  //do not delete lines ??
 
        _pointVtkActor  =       vtkActor::New();
     _bboxMapper                =       vtkPolyDataMapper::New();
 
        _bboxMapper->SetInput(_pd);
-       _bboxMapper->ImmediateModeRenderingOn();
+//     _bboxMapper->ImmediateModeRenderingOn();
        _pointVtkActor->SetMapper(_bboxMapper);
-       _pointVtkActor->GetProperty()->BackfaceCullingOn();
+//     _pointVtkActor->GetProperty()->BackfaceCullingOn();
        UpdateColorActor();
-       _pd->ComputeBounds();
+//     _pd->ComputeBounds();
 
        return _pointVtkActor;
 }
@@ -1494,7 +1499,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 )
        {
@@ -1510,10 +1514,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
@@ -1529,7 +1529,6 @@ void manualViewContour::RefreshContour() // virtual
 // ----------------------------------------------------------------------------
 void manualViewContour::RefreshText()  // virtual
 {
-
        if ((_textActor!=NULL) && ( _textActor->GetProperty()->GetOpacity()!=0 )){
                int size = GetNumberOfPoints();
                char text[50];
@@ -1558,8 +1557,8 @@ void manualViewContour::RefreshText()  // virtual
                        }
                }
 
-               _textActor -> SetInput(resultText);
-
+               _textActor->SetInput(resultText);
+               
                if (size>=1){
 
                        int i;
@@ -2258,7 +2257,7 @@ bool manualViewRoi::ifTouchContour(int x,int y, int z) // virtual
        {
                result=true;
        }
-
+               
        return result;
 }
 
@@ -2790,7 +2789,7 @@ void manualViewBaseContour :: RemoveControlPoints()
        SetIfViewControlPoints( false );
 }
 // ----------------------------------------------------------------------------
-void manualViewBaseContour :: AddControlPoints()
+void manualViewBaseContour::AddControlPoints()
 {
        vtkRenderer * theRenderer = _wxvtkbaseview->GetRenderer();
        SetIfViewControlPoints( true );
@@ -2900,7 +2899,7 @@ void manualViewBaseContour::ConstructVTKObjects()
        //      Text
        _textActor = vtkTextActor::New();
 //     _textActor->SetDisplayPosition(200, 200);
-       _textActor->SetInput("");
+       _textActor->SetInput("00");
        // Set coordinates to match the old vtkScaledTextActor default value
 //     _textActor->GetPosition2Coordinate()->SetCoordinateSystemToNormalizedViewport();
 //     _textActor->GetPosition2Coordinate()->SetValue( 0.2 , 0.2 );
@@ -2935,7 +2934,7 @@ void manualViewBaseContour::UpdateViewPoint(int id) // virtual
 }
 
 // ----------------------------------------------------------------------------
-void manualViewBaseContour :: UpdateViewPoints()
+void manualViewBaseContour::UpdateViewPoints()
 {
        int id, size = _lstViewPoints.size();
        for( id=0; id<size; id++)
@@ -2959,7 +2958,7 @@ void manualViewBaseContour::AddPoint( manualViewPoint * manualViewPoint )
        manualViewPoint->SetSpacing(_spc);
 
        vtkActor *actor = manualViewPoint->CreateVtkPointActor();
-       _wxvtkbaseview->GetRenderer()->AddActor( actor );
+       _wxvtkbaseview->GetRenderer()->AddActor( actor );       
 }
 
 // ----------------------------------------------------------------------------
@@ -3244,7 +3243,7 @@ void manualViewBaseContour::Refresh() // virtual
 void manualViewBaseContour::RefreshText()  // virtual
 {
        if( _textActor!=NULL)
-               _textActor -> SetInput(" ");
+               _textActor -> SetInput("00");
 }
 // ----------------------------------------------------------------------------
 void manualViewBaseContour::SetColorNormalContour(double r, double g, double b)
@@ -3486,9 +3485,8 @@ void manualViewBaseContour::SetVisible(bool ok)
        {
                opacity=1;
        } else {
-               opacity=0;
+               opacity=0.5;
        }
-
        vtkActor *actor;
        int i,size=_lstViewPoints.size();
        for (i=0;i<size;i++){
@@ -3497,7 +3495,7 @@ void manualViewBaseContour::SetVisible(bool ok)
        }
        _contourVtkActor->GetProperty()->SetOpacity( opacity );
        _textActor->GetProperty()->SetOpacity( opacity );
-       _textActor->SetInput(" ");
+       _textActor->SetInput("00");
 
 }
 // ----------------------------------------------------------------------------
@@ -3506,7 +3504,7 @@ void manualViewBaseContour::SetShowText(bool ok)
        _show_text = ok;
        if (_show_text==false)
        {
-               _textActor->SetInput(" ");
+               _textActor->SetInput("00");
        }
 }
 // ----------------------------------------------------------------------------
@@ -4164,12 +4162,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 );
@@ -4201,7 +4198,7 @@ void manualContourControler::MouseMove(int x, int y) // virtual
        if (!IsEditable())
        {
                GetManualViewBaseContour()->RemoveControlPoints();
-               GetManualViewBaseContour()->RemoveTextActor();
+//             GetManualViewBaseContour()->RemoveTextActor();
                GetManualViewBaseContour()->Refresh();
                this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
        }
@@ -4439,16 +4436,22 @@ 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){
@@ -4457,7 +4460,7 @@ void manualRoiControler::MouseClickLeft(int x, int y){
                        AddPoint(x,y,z);
                        AddPoint(x,y,z);
                        bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
-                       SetState(5);
+                       SetState(1);
                }
        }
        
@@ -4489,10 +4492,12 @@ void manualRoiControler::MouseMove(int x, int y) // virtual
 
 //     this->_vtkInteractorStyleBaseView->
 
+                  
        GetManualViewBaseContour()->SelectPosibleContour(x,y,z);
        GetManualViewBaseContour()->SelectPosiblePoint(x,y,z);
 
-       if (GetState()==5){
+
+       if ( (GetState()==5) || (GetState()==1) ){
                SetPoint( bakIdPoint , x , y ,z);
                if (bakIdPoint==0)
                {
@@ -4637,21 +4642,29 @@ 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);
                        bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
-                       SetState(5);
+                       SetState(1);
                }
        }       
        
@@ -4676,38 +4689,14 @@ 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);
        GetManualViewBaseContour()->SelectPosiblePoint(x,y,z);
 
-       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()==1){     SetPoint( bakIdPoint , x , y ,z); }
+       if (GetState()==5){     SetPoint( bakIdPoint , x , y ,z); }
+       
        if (GetState()==6){
                GetManualViewBaseContour()->MoveContour(x,y,z);
        }
@@ -4830,22 +4819,29 @@ void manualLineControler::CopyAttributesTo( manualLineControler * 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);
+                       SetState(1);
                }
        }
        
@@ -4875,10 +4871,9 @@ void manualLineControler::MouseMove(int x, int y) // virtual
        GetManualViewBaseContour()->SelectPosibleContour(x,y,z);
        GetManualViewBaseContour()->SelectPosiblePoint(x,y,z);
 
-       if (GetState()==5)
-       {       
-               SetPoint( bakIdPoint , x , y ,z); 
-       }
+       if (GetState()==1) { SetPoint( bakIdPoint , x , y ,z); }
+       if (GetState()==5) { SetPoint( bakIdPoint , x , y ,z); }
+       
        if (GetState()==6)
        {       
                GetManualViewBaseContour()->MoveContour(x,y,z);
@@ -5060,6 +5055,7 @@ bool manualContourBaseControler::OnChar()
 // ----------------------------------------------------------------------------
 bool manualContourBaseControler::OnMouseMove()
 {
+       
        if ( _vtkInteractorStyleBaseView!=NULL)
        {
                int X,Y;
@@ -5181,14 +5177,15 @@ void manualContourBaseControler::MouseClickLeft(int x, int y) // virtual
 // ----------------------------------------------------------------------------
 void manualContourBaseControler::MouseClickRight(int x, int y)
 {
-       if (_state==1)
-       {
-               _state=0;
-       }
+//     if (_state==1)
+//     {
+//             _state=0;
+//     }
        SetEditable( false );
        SetPosibleToMove( false );
-       //_state = 0;
-       _state=7;
+       _state = 0;
+
+//EED 24Avril2009      _state=7;
 }
 // ----------------------------------------------------------------------------
 void manualContourBaseControler::MouseReleaseLeft(int x, int y)