From: donadio Date: Wed, 25 Mar 2009 10:19:25 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: EED.02Oct2009~116 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=3870c5bc79a39a65fc8e3a57a20f159b5086f4ca;p=creaMaracasVisu.git *** empty log message *** --- diff --git a/lib/maracasVisuLib/src/interface/wxWindows/manualContour.cpp b/lib/maracasVisuLib/src/interface/wxWindows/manualContour.cpp index 9067adc..5ebf7d8 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/manualContour.cpp +++ b/lib/maracasVisuLib/src/interface/wxWindows/manualContour.cpp @@ -135,6 +135,109 @@ void manualContourModelCircle::UpdateSpline() // virtal } } +// ---------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- + +//AD: 02-09 + +manualContourModelLine::manualContourModelLine() +: manualContourModel() +{ + SetNumberOfPointsSpline(2); +} + +manualContourModelLine::~manualContourModelLine() +{ +} + + +// ---------------------------------------------------------------------------- +manualContourModelLine * manualContourModelLine :: Clone() // virtual +{ + manualContourModelLine * clone = new manualContourModelLine(); + CopyAttributesTo(clone); + return clone; +} + +// --------------------------------------------------------------------------- + +void manualContourModelLine::CopyAttributesTo( manualContourModelLine * cloneObject) +{ + manualContourModel::CopyAttributesTo(cloneObject); +} + +//---------------------------------------------------------------- +int manualContourModelLine::GetTypeModel() //virtual +{ + return 6; +} + +//---------------------------------------------------------------- +void manualContourModelLine::GetSpline_i_Point(int i, double *x, double *y, double *z) // virtal +{ + int np = GetSizeLstPoints(); + if (np==0) + { + *x = 0; + *y = 0; + *z = 0; + } + if (np==1) + { + manualPoint *mp; + mp = GetManualPoint(0); + *x = mp->GetX(); + *y = mp->GetY(); + *z = mp->GetZ(); + } + if (np==2) + { + manualPoint *mp; + + if (i==0) + { + mp = GetManualPoint(0); + } + else if (i==1) + { + mp = GetManualPoint(1); + } + + *x = mp->GetX(); + *y = mp->GetY(); + *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; + } +*/ +} + + // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- @@ -1113,6 +1216,7 @@ int manualContourModel::GetTypeModel() //virtual // 3 circle // 4 BullEye // 5 BullEyeSector + // 6 Line return 1; } @@ -1519,7 +1623,6 @@ bool manualViewContour::ifTouchContour(int x,int y,int z){ yy = yy * _spc[1]; zz = zz * _spc[2]; - unsigned int i, nps,nps_t; nps = _sizePointsContour; if (this->_manContModel->IfCloseContour()==true) @@ -1529,13 +1632,22 @@ bool manualViewContour::ifTouchContour(int x,int y,int z){ nps_t = nps-1; } - for( i = 0; i < nps_t; i++ ) { + //ED + printf("\n>%d ",nps_t); + + for( i = 0; i < nps_t; i++ ) + { _pts->GetPoint(i%nps, ppA); _pts->GetPoint((i+1)%nps, ppB); d1= sqrt( (ppA[0]-xx)*(ppA[0]-xx) + (ppA[1]-yy)*(ppA[1]-yy) + (ppA[2]-zz)*(ppA[2]-zz)); 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])); - if ( ((d1+d2)>=d3) && ((d1+d2)<=d3*1.3) ) { + + //ED + printf("%d %f %f %f - ", i,d1,d2,d3); + + if ( ((d1+d2)>=d3) && ((d1+d2)<=d3*1.3) ) + { result=true; i=nps; } @@ -2447,7 +2559,89 @@ void manualViewCircle::MoveContour(int x, int y, int z) // virtual +// ---------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- + +// AD:02-09 + +manualViewLine::manualViewLine() +{ +} +// ---------------------------------------------------------------------------- +manualViewLine::~manualViewLine() +{ +} + + +// ---------------------------------------------------------------------------- +manualViewLine * manualViewLine :: Clone() +{ + manualViewLine * clone = new manualViewLine(); + CopyAttributesTo(clone); + return clone; +} + +// --------------------------------------------------------------------------- + +void manualViewLine::CopyAttributesTo( manualViewLine * cloneObject) +{ + // Fathers object + manualViewBaseContour::CopyAttributesTo(cloneObject); +} + +// ---------------------------------------------------------------------------- +int manualViewLine::GetType() // virtual +{ + return 6; +} + + +// ---------------------------------------------------------------------------- + +void manualViewLine::InitMove(int x, int y, int z) // virtual +{ + manualPoint *mp; + double XX=x; + double YY=y; + double ZZ=z; + TransfromeCoordViewWorld(XX,YY,ZZ); + + if (_manContModel->GetSizeLstPoints()==2) + { + mp = _manContModel->GetManualPoint(0); + _dp0[0]= mp->GetX() - XX; + _dp0[1]= mp->GetY() - YY; + _dp0[2]= mp->GetZ(); + + mp = _manContModel->GetManualPoint(1); + _dp1[0]= mp->GetX() - XX; + _dp1[1]= mp->GetY() - YY; + _dp1[2]= mp->GetZ(); + + } +} + + +// ---------------------------------------------------------------------------- +void manualViewLine::MoveContour(int x, int y, int z) // virtual +{ + manualPoint *mp; + double XX=x; + double YY=y; + double ZZ=z; + TransfromeCoordViewWorld(XX,YY,ZZ); + + mp = _manContModel->GetManualPoint(0); + mp->SetPoint(_dp0[0]+XX,_dp0[1]+YY,_dp0[2]); + mp = _manContModel->GetManualPoint(1); + mp->SetPoint(_dp1[0]+XX,_dp1[1]+YY,_dp0[2]); + + + UpdateViewPoint(0); + UpdateViewPoint(1); +} // ---------------------------------------------------------------------------- @@ -2509,6 +2703,7 @@ int manualViewBaseContour::GetType() // virtual //int manualViewRoi::GetType() 2; //int manualViewCircle::GetType() 3; //int manualViewStar::GetType() 4; +//int manualViewLine::GetType() 6; return 0; @@ -4589,6 +4784,120 @@ void manualCircleControler::SetRoi(int x1, int y1,int x2, int y2) */ +// ---------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- + +// AD:02-09 + +// _state = 0 // ..nothing.. +// _state = 5 // move point +// _state = 6 // move all +// _state = 7 // Empty mouse drag + +manualLineControler::manualLineControler() +{ +} +// ---------------------------------------------------------------------------- +manualLineControler::~manualLineControler() +{ +} +// ---------------------------------------------------------------------------- +manualLineControler * manualLineControler :: Clone() // virtual +{ + manualLineControler * clone = new manualLineControler(); + CopyAttributesTo(clone); + return clone; +} + +// --------------------------------------------------------------------------- +void manualLineControler::CopyAttributesTo( manualLineControler * cloneObject) +{ + // Fathers object + 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 ((GetState()==0) && (GetManualViewBaseContour()->GetPosibleSelected()==true)) { + 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); + } else { + SetPoint(0,x,y,z); + SetPoint(1,x,y,z); + } + bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z); + SetState(5); + } + GetManualViewBaseContour()->Refresh(); +} +// ---------------------------------------------------------------------------- + +void manualLineControler::MouseMove(int x, int y) // virtual +{ + int z=GetZ(); + + GetManualViewBaseContour()->SelectPosibleContour(x,y,z); + GetManualViewBaseContour()->SelectPosiblePoint(x,y,z); + + if (GetState()==5) + { + SetPoint( bakIdPoint , x , y ,z); + } + if (GetState()==6) + { + GetManualViewBaseContour()->MoveContour(x,y,z); + } + GetManualViewBaseContour()->Refresh(); +} + + +// ---------------------------------------------------------------------------- +void manualLineControler::DeleteActualMousePoint(int x, int y) // virtual +{ +} +// ---------------------------------------------------------------------------- + +void manualLineControler::InitRoi(int ww, int hh, double porcentage) +{ + int zz; + manualPoint *mp; + + if (GetManualContourModel()->GetSizeLstPoints() ==0) + { + zz = GetZ(); + AddPoint(0,0,zz); + AddPoint(0,0,zz); + } + + double pp1=porcentage; + double pp2=1-porcentage; + + mp = GetManualContourModel()->GetManualPoint(0); + zz=(int)mp->GetZ(); + mp->SetPoint(ww*pp2,hh*pp2,zz); + + mp = GetManualContourModel()->GetManualPoint(1); + zz=(int)mp->GetZ(); + mp->SetPoint(ww*pp2,hh*pp1,zz); + + GetManualViewBaseContour() ->UpdateViewPoint(0); + GetManualViewBaseContour() ->UpdateViewPoint(1); + + SetState(0); + GetManualViewBaseContour()->Refresh(); +} // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- diff --git a/lib/maracasVisuLib/src/interface/wxWindows/manualContour.h b/lib/maracasVisuLib/src/interface/wxWindows/manualContour.h index 6cb157a..4b953a8 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/manualContour.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/manualContour.h @@ -160,6 +160,22 @@ private: virtual void UpdateSpline(); }; +//-------------------------------------------------------- + +class creaMaracasVisu_EXPORT manualContourModelLine : public manualContourModel +{ +public: + manualContourModelLine(); + virtual ~manualContourModelLine(); + virtual manualContourModelLine *Clone(); + void CopyAttributesTo( manualContourModelLine *cloneObject); + virtual void GetSpline_i_Point(int i, double *x, double *y, double *z); +private: + virtual int GetTypeModel(); +}; + +//-------------------------------------------------------- + class manualContourModelBullEyeSector : public manualContourModel { public: @@ -649,12 +665,41 @@ private: }; +// ---------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- + +// AD:02-09 +class creaMaracasVisu_EXPORT manualViewLine: public manualViewContour +{ +public: + manualViewLine(); + virtual ~manualViewLine(); + + virtual int GetType(); + virtual manualViewLine * Clone(); + void CopyAttributesTo( manualViewLine *cloneObject ); + +// void RefreshContour(); +// virtual bool ifTouchContour(int x,int y, int z); + virtual void InitMove(int x, int y, int z); + virtual void MoveContour(int x, int y, int z); + +private: + double _dp0[3]; + double _dp1[3]; +// double _dp2[3]; +// double _dp3[3]; +}; + + // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- + class creaMaracasVisu_EXPORT manualContourBaseControler: public InteractorStyleMaracas { public: @@ -971,6 +1016,30 @@ private: }; +// ---------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- + +// AD:02-09 +class creaMaracasVisu_EXPORT manualLineControler: public manualContourControler +{ +public: + manualLineControler(); + virtual ~manualLineControler(); + virtual manualLineControler * Clone(); + void CopyAttributesTo( manualLineControler *cloneObject ); + + virtual void MouseClickLeft(int x, int y); + virtual void MouseMove(int x, int y ); + virtual void DeleteActualMousePoint(int x, int y); + void InitRoi(int ww, int hh, double porcentage); + + + +private: + int bakIdPoint; +}; +