X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FmaracasVisuLib%2Fsrc%2Finterface%2FwxWindows%2FmanualContour.cpp;h=af53c28d5423b09f7d35251b4315d741e82f71e7;hb=8b75d0d7ee7c2aed68f1663282127c8e9932e705;hp=de7d18f196b66fc9b06b0e96c54d83ae3dfa9090;hpb=bd3d13602a749b74d531c24bdc36a9cc1e47d189;p=creaMaracasVisu.git diff --git a/lib/maracasVisuLib/src/interface/wxWindows/manualContour.cpp b/lib/maracasVisuLib/src/interface/wxWindows/manualContour.cpp index de7d18f..af53c28 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/manualContour.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/manualContour.cpp @@ -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; } //---------------------------------------------------------------- @@ -633,6 +610,10 @@ manualContourModel::~manualContourModel() } _lstPoints.clear(); + _cntSplineX->RemoveAllPoints(); + _cntSplineY->RemoveAllPoints(); + _cntSplineZ->RemoveAllPoints(); + _cntSplineX->Delete(); _cntSplineY->Delete(); _cntSplineZ->Delete(); @@ -893,7 +874,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 } //----------------------------------------------------------------------------------------------------------- } @@ -1337,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); @@ -1369,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; } @@ -1516,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 ) { @@ -1532,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 @@ -1551,7 +1529,6 @@ void manualViewContour::RefreshContour() // virtual // ---------------------------------------------------------------------------- void manualViewContour::RefreshText() // virtual { - if ((_textActor!=NULL) && ( _textActor->GetProperty()->GetOpacity()!=0 )){ int size = GetNumberOfPoints(); char text[50]; @@ -1580,8 +1557,8 @@ void manualViewContour::RefreshText() // virtual } } - _textActor -> SetInput(resultText); - + _textActor->SetInput(resultText); + if (size>=1){ int i; @@ -1625,6 +1602,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 +1610,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 +1619,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 +1626,7 @@ bool manualViewContour::ifTouchContour(int x,int y,int z){ i=nps; } } + return result; } @@ -2163,7 +2138,6 @@ void manualViewRoi::RefreshContour() // virtual unsigned int i,ii, np; np = GetNumberOfPoints( ); //EED01 - printf("EED manualViewRoi::RefreshContour np %d \n", np); if ( np > 0) { if (np>=2) @@ -2180,7 +2154,6 @@ void manualViewRoi::RefreshContour() // virtual //EED 27 sep 2007 // _pts->SetPoint(i, XX,YY,ZZ ); -printf("EED manualViewRoi::RefreshContour ZZ %f _spc%f \n", ZZ, _spc[2] ); _pts->SetPoint(i, XX*_spc[0] , YY*_spc[1] , ZZ*_spc[2] ); } // rof @@ -2252,10 +2225,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); @@ -2283,11 +2257,10 @@ bool manualViewRoi::ifTouchContour(int x,int y, int z) // virtual { result=true; } - + return result; } - // ---------------------------------------------------------------------------- void manualViewRoi::InitMove(int x, int y, int z) // virtual @@ -2570,6 +2543,7 @@ void manualViewCircle::MoveContour(int x, int y, int z) // virtual manualViewLine::manualViewLine() { + _sizePointsContour=20; } // ---------------------------------------------------------------------------- manualViewLine::~manualViewLine() @@ -2815,7 +2789,7 @@ void manualViewBaseContour :: RemoveControlPoints() SetIfViewControlPoints( false ); } // ---------------------------------------------------------------------------- -void manualViewBaseContour :: AddControlPoints() +void manualViewBaseContour::AddControlPoints() { vtkRenderer * theRenderer = _wxvtkbaseview->GetRenderer(); SetIfViewControlPoints( true ); @@ -2881,7 +2855,6 @@ void manualViewBaseContour::ConstructVTKObjects() //int i , nps = _sizePointsContour; int i; int nps = _manContModel->GetNumberOfPointsSpline(); -printf("EED01 manualViewBaseContour::ConstructVTKObjects nps %d\n ",nps); //------------------------------------------------------------- DeleteVtkObjects(); _pts = vtkPoints::New(); @@ -2891,11 +2864,13 @@ printf("EED01 manualViewBaseContour::ConstructVTKObjects nps %d\n ",nps); _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 */ ); @@ -2924,7 +2899,7 @@ printf("EED01 manualViewBaseContour::ConstructVTKObjects nps %d\n ",nps); // 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 ); @@ -2959,7 +2934,7 @@ void manualViewBaseContour::UpdateViewPoint(int id) // virtual } // ---------------------------------------------------------------------------- -void manualViewBaseContour :: UpdateViewPoints() +void manualViewBaseContour::UpdateViewPoints() { int id, size = _lstViewPoints.size(); for( id=0; idSetSpacing(_spc); vtkActor *actor = manualViewPoint->CreateVtkPointActor(); - _wxvtkbaseview->GetRenderer()->AddActor( actor ); + _wxvtkbaseview->GetRenderer()->AddActor( actor ); } // ---------------------------------------------------------------------------- @@ -3268,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) @@ -3510,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;iGetProperty()->SetOpacity( opacity ); _textActor->GetProperty()->SetOpacity( opacity ); - _textActor->SetInput(" "); + _textActor->SetInput("00"); } // ---------------------------------------------------------------------------- @@ -3530,7 +3504,7 @@ void manualViewBaseContour::SetShowText(bool ok) _show_text = ok; if (_show_text==false) { - _textActor->SetInput(" "); + _textActor->SetInput("00"); } } // ---------------------------------------------------------------------------- @@ -4188,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 ); @@ -4225,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(); } @@ -4460,17 +4433,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(1); + } + } + +/*EED 21 Avril 2009 if (GetState()==0) { if (size==0){ AddPoint(x,y,z); @@ -4486,8 +4480,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 { @@ -4495,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) { @@ -4643,30 +4642,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(1); + } + } + +/*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(); } // ---------------------------------------------------------------------------- @@ -4674,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); } @@ -4824,18 +4815,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(1); + } + } + + +/*EED 21 Avril 2009 if (GetState()==0) { if (size==0){ AddPoint(x,y,z); @@ -4847,6 +4858,8 @@ void manualLineControler::MouseClickLeft(int x, int y){ bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z); SetState(5); } +*/ + GetManualViewBaseContour()->Refresh(); } // ---------------------------------------------------------------------------- @@ -4858,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); @@ -4916,7 +4928,7 @@ manualContourBaseControler::manualContourBaseControler() _manViewBaseCont = NULL; _manContModel = NULL; _state = 0; - _z = -900; + _z = 900; _editable = true; _posibleToMove = true; _moving = false; @@ -5043,6 +5055,7 @@ bool manualContourBaseControler::OnChar() // ---------------------------------------------------------------------------- bool manualContourBaseControler::OnMouseMove() { + if ( _vtkInteractorStyleBaseView!=NULL) { int X,Y; @@ -5164,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)