3 #include <vtkProperty.h>
5 #include <vtkCellArray.h>
6 #include <vtkRenderer.h>
7 #include <vtkCoordinate.h>
8 #include <vtkTextProperty.h>
9 #include <vtkTextActor.h>
10 #include <vtkProperty2D.h>
11 #include <vtkPointPicker.h>
12 #include "widgets/UtilVtk3DGeometriSelection.h"
15 #include "manualContour.h"
18 // ----------------------------------------------------------------------------
19 // ----------------------------------------------------------------------------
20 // ----------------------------------------------------------------------------
22 manualPoint::manualPoint(){
24 // ----------------------------------------------------------------------------
25 manualPoint::~manualPoint(){
27 // ----------------------------------------------------------------------------
28 void manualPoint::SetPoint(double x,double y,double z){
33 // ----------------------------------------------------------------------------
34 void manualPoint::SetPointX(double x){
37 // ----------------------------------------------------------------------------
38 void manualPoint::SetPointY(double y){
41 // ----------------------------------------------------------------------------
42 void manualPoint::SetPointZ(double z){
45 // ----------------------------------------------------------------------------
46 double manualPoint::GetX(){
49 // ----------------------------------------------------------------------------
50 double manualPoint::GetY(){
53 // ----------------------------------------------------------------------------
54 double manualPoint::GetZ(){
57 // ----------------------------------------------------------------------------
58 manualPoint * manualPoint :: Clone()
60 manualPoint * clone = new manualPoint();
61 clone->SetPoint( GetX(), GetY(), GetZ());
66 // ----------------------------------------------------------------------------
67 // ----------------------------------------------------------------------------
68 // ----------------------------------------------------------------------------
70 manualContourModelCircle::manualContourModelCircle()
71 : manualContourModel()
75 manualContourModelCircle::~manualContourModelCircle()
80 // ----------------------------------------------------------------------------
81 manualContourModelCircle * manualContourModelCircle :: Clone() // virtual
83 manualContourModelCircle * clone = new manualContourModelCircle();
84 CopyAttributesTo(clone);
88 // ---------------------------------------------------------------------------
90 void manualContourModelCircle::CopyAttributesTo( manualContourModelCircle * cloneObject)
93 manualContourModel::CopyAttributesTo(cloneObject);
96 //----------------------------------------------------------------
97 int manualContourModelCircle::GetTypeModel() //virtual
102 //----------------------------------------------------------------
103 void manualContourModelCircle::GetSpline_i_Point(int i, double *x, double *y, double *z) // virtal
105 double angle = _deltaAngle*i;
106 *x = _radio*cos(angle) + _centerX;
107 *y = _radio*sin(angle) + _centerY;
112 // ---------------------------------------------------------------------------
113 void manualContourModelCircle::UpdateSpline() // virtal
115 manualPoint *mpA,*mpB;
117 int np = GetSizeLstPoints( );
118 int nps = GetNumberOfPointsSpline();
119 _deltaAngle=(3.14159265*2)/(nps-1);
122 mpA = GetManualPoint(0);
123 mpB = GetManualPoint(1);
124 difX = mpA->GetX() - mpB->GetX();
125 difY = mpA->GetY() - mpB->GetY();
126 _radio = sqrt( difX*difX + difY*difY );
127 _centerX = mpA->GetX();
128 _centerY = mpA->GetY();
129 _centerZ = mpA->GetZ();
139 // ----------------------------------------------------------------------------
140 // ----------------------------------------------------------------------------
141 // ----------------------------------------------------------------------------
142 manualContourModelBullEye::manualContourModelBullEye()
143 : manualContourModel()
145 _numberPointsSlineBySector=101; // impaire
148 manualContourModelBullEye::~manualContourModelBullEye()
153 // ----------------------------------------------------------------------------
154 manualContourModelBullEye * manualContourModelBullEye :: Clone() // virtual
156 manualContourModelBullEye * clone = new manualContourModelBullEye();
157 CopyAttributesTo(clone);
161 // ---------------------------------------------------------------------------
163 void manualContourModelBullEye::CopyAttributesTo( manualContourModelBullEye * cloneObject)
166 manualContourModel::CopyAttributesTo(cloneObject);
169 //----------------------------------------------------------------
170 int manualContourModelBullEye::GetTypeModel() //virtual
175 //----------------------------------------------------------------
176 int manualContourModelBullEye::GetNumberOfPointsSplineSectorBulleEje()
178 return _numberPointsSlineBySector;
181 //----------------------------------------------------------------
182 void manualContourModelBullEye::SetNumberOfPointsSplineSectorBulleEje(int numpoints)
184 this->_numberPointsSlineBySector = numpoints;
187 //----------------------------------------------------------------
188 void manualContourModelBullEye::AddSector( double radioA,
193 manualContourModelBullEyeSector *modelSector = new manualContourModelBullEyeSector();
194 modelSector->SetSector(radioA,radioB,ang,angDelta);
195 modelSector->SetNumberOfPointsSpline( this->GetNumberOfPointsSplineSectorBulleEje() );
196 _lstModelBullEyeSector.push_back(modelSector);
199 //----------------------------------------------------------------
200 manualContourModelBullEyeSector * manualContourModelBullEye::GetModelSector(int id)
202 return _lstModelBullEyeSector[id];
205 //----------------------------------------------------------------
206 void manualContourModelBullEye::GetSector(int id,
212 _lstModelBullEyeSector[id]->GetSector(radioA,radioB,ang,angDelta);
215 void manualContourModelBullEye::UpdateSpline() // virtual
217 manualContourModel::UpdateSpline();
219 if (this->GetSizeLstPoints()>2){
222 manualPoint *mpA = GetManualPoint(0);
223 manualPoint *mpB = GetManualPoint(2);
224 cx = (mpA->GetX() + mpB->GetX()) / 2.0;
225 cy = (mpA->GetY() + mpB->GetY()) / 2.0;
226 ww = fabs( mpA->GetX() - mpB->GetX() )/2.0;
227 hh = fabs( mpA->GetY() - mpB->GetY() )/2.0;
228 int i,size = _lstModelBullEyeSector.size();
231 _lstModelBullEyeSector[i]->SetCenter(cx,cy);
232 _lstModelBullEyeSector[i]->SetSize(ww,hh);
238 //----------------------------------------------------------------
239 void manualContourModelBullEye::ResetSectors()
241 int i,size=_lstModelBullEyeSector.size();
244 delete _lstModelBullEyeSector[i];
246 _lstModelBullEyeSector.clear();
249 //----------------------------------------------------------------
250 int manualContourModelBullEye::GetSizeOfSectorLst()
252 return _lstModelBullEyeSector.size();
255 //----------------------------------------------------------------
256 void manualContourModelBullEye::Save(FILE *ff) // virtual
258 manualContourModel::Save(ff);
259 int i,size = GetSizeOfSectorLst();
260 fprintf(ff,"numberOfSections %d \n",size);
261 for ( i=0 ; i<size ; i++ )
263 _lstModelBullEyeSector[i]->Save(ff);
267 //----------------------------------------------------------------
268 void manualContourModelBullEye::Open(FILE *ff) // virtual
270 manualContourModel::Open(ff);
276 int numberOfSections;
277 // double radioA,radioB,ang,deltaAng;
279 fscanf(ff,"%s",tmp); // NumberOfSections
280 fscanf(ff,"%s",tmp); // ##
281 numberOfSections = atoi(tmp);
282 for (i=0;i<numberOfSections;i++)
285 _lstModelBullEyeSector[i]->Open(ff);
290 // ----------------------------------------------------------------------------
291 std::vector<manualContourModel*> manualContourModelBullEye::ExploseModel( )
294 std::vector<manualContourModel*> lstTmp;
295 int i,iSize=_lstModelBullEyeSector.size();
296 for (i=0;i<iSize;i++)
298 lstTmp.push_back( _lstModelBullEyeSector[i] );
304 // ----------------------------------------------------------------------------
305 // ----------------------------------------------------------------------------
306 // ----------------------------------------------------------------------------
307 manualContourModelBullEyeSector::manualContourModelBullEyeSector()
308 : manualContourModel()
312 manualContourModelBullEyeSector::~manualContourModelBullEyeSector()
317 // ----------------------------------------------------------------------------
318 manualContourModelBullEyeSector * manualContourModelBullEyeSector :: Clone() // virtual
320 manualContourModelBullEyeSector * clone = new manualContourModelBullEyeSector();
321 CopyAttributesTo(clone);
325 // ---------------------------------------------------------------------------
327 void manualContourModelBullEyeSector::CopyAttributesTo( manualContourModelBullEyeSector * cloneObject)
330 manualContourModel::CopyAttributesTo(cloneObject);
333 //----------------------------------------------------------------
334 int manualContourModelBullEyeSector::GetTypeModel() //virtual
340 //----------------------------------------------------------------
341 void manualContourModelBullEyeSector::SetSector( double radioA,
348 _ang = ang*3.14159265/180.0;
349 _angDelta = angDelta*3.14159265/180.0;
352 //----------------------------------------------------------------
353 void manualContourModelBullEyeSector::GetSector(
362 *angDelta = _angDelta;
365 // ----------------------------------------------------------------------------
366 void manualContourModelBullEyeSector::SetCenter(double cx,double cy)
372 //----------------------------------------------------------------
373 void manualContourModelBullEyeSector::SetSize(double ww,double hh)
379 //----------------------------------------------------------------
380 void manualContourModelBullEyeSector::GetSpline_i_Point(int i, double *x, double *y, double *z)
386 double ang,angcos, angsin;
389 nps = GetNumberOfPointsSpline() - 3;
391 if (i==GetNumberOfPointsSpline()-1)
404 ang = ((double)ii/(nps/2))*_angDelta + _ang;
408 *x = _ww*radio*angcos + _cx;
409 *y = _hh*radio*angsin + _cy;
413 //----------------------------------------------------------------
414 void manualContourModelBullEyeSector::Save(FILE *ff) // virtual
416 manualContourModel::Save(ff);
417 fprintf(ff,"rA= %f rB= %f ang= %f deltaAng= %f\n", _radioA,_radioB, _ang , _angDelta);
420 //----------------------------------------------------------------
421 void manualContourModelBullEyeSector::Open(FILE *ff) // virtual
424 fscanf(ff,"%s",tmp); // TypeModel
425 fscanf(ff,"%s",tmp); // ##
427 manualContourModel::Open(ff);
430 fscanf(ff,"%s",tmp); // radioA=
431 fscanf(ff,"%s",tmp); // radioA
434 fscanf(ff,"%s",tmp); // radioB=
435 fscanf(ff,"%s",tmp); // radioB
438 fscanf(ff,"%s",tmp); // ang=
439 fscanf(ff,"%s",tmp); // ang
442 fscanf(ff,"%s",tmp); // deltaAng=
443 fscanf(ff,"%s",tmp); // deltaAng
444 _angDelta = atof(tmp);
449 // ---------------------------------------------------------------------------
450 // ---------------------------------------------------------------------------
451 // ---------------------------------------------------------------------------
452 // ---------------------------------------------------------------------------
454 //JSTG 25-02-08 --------------------------------------------------
455 manualContourModelRoi::manualContourModelRoi()
456 : manualContourModel()
458 SetNumberOfPointsSpline(5);
461 manualContourModelRoi::~manualContourModelRoi()
466 // ----------------------------------------------------------------------------
467 manualContourModelRoi * manualContourModelRoi :: Clone() // virtual
469 manualContourModelRoi * clone = new manualContourModelRoi();
470 CopyAttributesTo(clone);
474 // ---------------------------------------------------------------------------
476 void manualContourModelRoi::CopyAttributesTo( manualContourModelRoi * cloneObject)
479 manualContourModel::CopyAttributesTo(cloneObject);
482 //----------------------------------------------------------------
483 int manualContourModelRoi::GetTypeModel() //virtual
488 //----------------------------------------------------------------
491 // ----------------------------------------------------------------------------
492 // ----------------------------------------------------------------------------
493 // ----------------------------------------------------------------------------
495 manualContourModel::manualContourModel()
497 _cntSplineX = vtkKochanekSpline::New( );
498 _cntSplineY = vtkKochanekSpline::New( );
499 _cntSplineZ = vtkKochanekSpline::New( );
501 this->SetCloseContour(true);
503 _cntSplineX->SetDefaultTension( 0 );
504 _cntSplineX->SetDefaultBias( 0 );
505 _cntSplineX->SetDefaultContinuity( 0 );
507 _cntSplineY->SetDefaultTension( 0 );
508 _cntSplineY->SetDefaultBias( 0 );
509 _cntSplineY->SetDefaultContinuity( 0 );
511 _cntSplineZ->SetDefaultTension( 0 );
512 _cntSplineZ->SetDefaultBias( 0 );
513 _cntSplineZ->SetDefaultContinuity( 0 );
515 //JSTG 25-02-08 -------------------------------------------------------------------------------------------------
517 // this parameter is reset in the VIRTUAL manualContourBaseControler::Configure
518 _sizePointsContour = 100; //JSTG 25-02-08 The change in the inisialization of these variable is critical.
521 //---------------------------------------------------------------------------------------------------------------
524 // ----------------------------------------------------------------------------
525 manualContourModel::~manualContourModel()
527 int i,size=_lstPoints.size();
528 for (i=0;i<size; i++){
529 delete _lstPoints[i];
533 _cntSplineX->Delete();
534 _cntSplineY->Delete();
535 _cntSplineZ->Delete();
537 // ----------------------------------------------------------------------------
538 int manualContourModel::AddPoint(double x,double y,double z)
540 manualPoint *mp = new manualPoint();
545 return _lstPoints.size()-1;
547 // ----------------------------------------------------------------------------
548 int manualContourModel::InsertPoint(double x,double y,double z)
550 double dd,ddmin=9999999;
555 int i,ii,iii,size=_lstPoints.size();
556 double j,MaxDivisions=20,porcentage;
559 if (_closeContour==false)
566 for ( i=0 ; i<size ; i++ )
570 x1=_lstPoints[ii]->GetX();
571 y1=_lstPoints[ii]->GetY();
572 z1=_lstPoints[ii]->GetZ();
573 x2=_lstPoints[iii]->GetX();
574 y2=_lstPoints[iii]->GetY();
575 z2=_lstPoints[iii]->GetZ();
576 for (j=0; j<=MaxDivisions; j++)
578 porcentage=(j/MaxDivisions);
579 xx=(x2-x1)*porcentage+x1;
580 yy=(y2-y1)*porcentage+y1;
581 zz=(z2-z1)*porcentage+z1;
582 dd=sqrt( (xx-x)*(xx-x) + (yy-y)*(yy-y) + (zz-z)*(zz-z) );
592 if (_closeContour==false)
594 if ( (ibak==1) && (jbak==0) )
598 if ( ( ibak==size ) && ( jbak==MaxDivisions ) )
605 //JSTG - 25-04-08 ----------------------------------------------------------
606 //manualPoint *mp = new manualPoint();
607 //mp->SetPoint(x,y,z);
608 //std::vector<manualPoint*>::iterator itNum = _lstPoints.begin() + ibak;
609 //_lstPoints.insert(itNum,mp);
610 InsertPoint_id(ibak,x,y,z);
611 //----------------------------------------------------------------------------
615 // ----------------------------------------------------------------------------
616 void manualContourModel::InsertPoint_id(int id, double x, double y, double z)
618 manualPoint *mp = new manualPoint();
620 std::vector<manualPoint*>::iterator itNum = _lstPoints.begin() + id;
621 _lstPoints.insert(itNum,mp);
623 // ----------------------------------------------------------------------------
625 void manualContourModel::DeletePoint(int i)
627 std::vector<manualPoint*>::iterator itNum = _lstPoints.begin() + i;
628 _lstPoints.erase(itNum);
630 // ----------------------------------------------------------------------------
631 void manualContourModel::DeleteAllPoints()
633 int i,size=_lstPoints.size();
634 for (i=0;i<size;i++){
635 _lstPoints.erase( _lstPoints.begin() );
637 this->UpdateSpline();
639 // ----------------------------------------------------------------------------
641 void manualContourModel::MovePoint(int i,double dx,double dy,double dz)
643 manualPoint *mp=_lstPoints[i];
644 double x=mp->GetX()+dx;
645 double y=mp->GetY()+dy;
646 double z=mp->GetZ()+dz;
649 // ----------------------------------------------------------------------------
650 void manualContourModel::MoveLstPoints(double dx,double dy,double dz)
654 // ----------------------------------------------------------------------------
655 void manualContourModel::MoveAllPoints(double dx,double dy,double dz)
657 int i,size=_lstPoints.size();
658 for (i=0;i<size;i++){
659 MovePoint(i,dx,dy,dz);
664 // ----------------------------------------------------------------------------
670 int manualContourModel::GetIdPoint(double x, double y, double z, int i_range,int type)
672 double range = i_range+1;
674 double xx,yy,zz,dd,ddmin=9999999;
676 int i,size=_lstPoints.size();
677 for (i=0;i<size;i++){
678 manualPoint *mp=_lstPoints[i];
685 if ((fabs(xx-x)<range) && (fabs(yy-y)<range) && (fabs(zz-z)<range)) {
686 dd=sqrt( (xx-x)*(xx-x) + (yy-y)*(yy-y) + (zz-z)*(zz-z) );
695 if ((fabs(yy-y)<range) && (fabs(zz-z)<range)) {
696 dd=sqrt( (yy-y)*(yy-y) + (zz-z)*(zz-z) );
705 if ((fabs(xx-x)<range) && (fabs(zz-z)<range)) {
706 dd=sqrt( (xx-x)*(xx-x) + (zz-z)*(zz-z) );
715 if ((fabs(xx-x)<range) && (fabs(yy-y)<range) ) {
716 dd=sqrt( (xx-x)*(xx-x) + (yy-y)*(yy-y) );
726 // ----------------------------------------------------------------------------
727 manualPoint* manualContourModel::GetManualPoint(int id)
729 return _lstPoints[id];
731 // ----------------------------------------------------------------------------
732 int manualContourModel::GetSizeLstPoints()
734 return _lstPoints.size();
736 //----------------------------------------------------------------------------
737 int manualContourModel::GetNumberOfPointsSpline()
739 return _sizePointsContour;
741 //----------------------------------------------------------------------------
742 void manualContourModel::SetNumberOfPointsSpline(int size)
744 _sizePointsContour = size;
748 // ----------------------------------------------------------------------------
750 void manualContourModel::SetCloseContour(bool closeContour)
752 _closeContour = closeContour;
753 if (_closeContour==true)
755 _cntSplineX->ClosedOn();
756 _cntSplineY->ClosedOn();
757 _cntSplineZ->ClosedOn();
759 _cntSplineX->ClosedOff();
760 _cntSplineY->ClosedOff();
761 _cntSplineZ->ClosedOff();
765 // ----------------------------------------------------------------------------
766 bool manualContourModel::IfCloseContour()
768 return _closeContour;
771 // ----------------------------------------------------------------------------
773 void manualContourModel::UpdateSpline() // virtual
776 np = _lstPoints.size();
778 _cntSplineX->RemoveAllPoints();
779 _cntSplineY->RemoveAllPoints();
780 _cntSplineZ->RemoveAllPoints();
781 for( i = 0; i < np; i++ ) {
782 mp = GetManualPoint(i);
783 _cntSplineX->AddPoint( i, mp->GetX() );
784 _cntSplineY->AddPoint( i, mp->GetY() );
785 _cntSplineZ->AddPoint( i, mp->GetZ() );
788 //JSTG 25-02-08 ---------------------------------------------------------------------------------------------
789 if (this->_closeContour==true)
791 _delta_JSTG = (double) (np) / double (_sizePointsContour - 1); //Without the -1 the curve is not close
793 _delta_JSTG = (double) (np-1) / double (_sizePointsContour ); //Without the -1 the curve is not close
795 //-----------------------------------------------------------------------------------------------------------
798 //---------------------------------------------------------------------------------
800 /*void manualContourModel::GetSplineiPoint(int i, double &x, double &y, double &z)
802 double delta=(double)(_lstPoints.size()) / (double)(_sizePointsContour);
803 double t = delta*(double)i;
804 GetSplinePoint(t, x, y, z);
807 //-----------------------------------------------------------------------------
809 //JSTG 25-02-08 ---------------------------------------------------------------
810 void manualContourModel::GetSpline_i_Point(int i, double *x, double *y, double *z) // virtal
812 GetSpline_t_Point(i*_delta_JSTG,x,y,z);
815 // ----------------------------------------------------------------------------
817 //JSTG 25-02-08 ---------------------------------------------------------------
818 void manualContourModel::GetSpline_t_Point(double t, double *x, double *y, double *z)
820 if (_lstPoints.size()==0)
826 if (_lstPoints.size()==1)
829 mp = GetManualPoint(0);
834 if (_lstPoints.size()>=2)
836 *x = _cntSplineX->Evaluate(t);
837 *y = _cntSplineY->Evaluate(t);
838 *z = _cntSplineZ->Evaluate(t);
842 // ----------------------------------------------------------------------------
845 /*void manualContourModel::GetSplinePoint(double t, double &x, double &y, double &z)
847 if (_lstPoints.size()==0)
853 if (_lstPoints.size()==1)
856 mp = GetManualPoint(0);
861 if (_lstPoints.size()>=2)
863 x = _cntSplineX->Evaluate(t);
864 y = _cntSplineY->Evaluate(t);
865 z = _cntSplineZ->Evaluate(t);
868 // ----------------------------------------------------------------------------
869 double manualContourModel::GetPathSize()
875 // JSTG 25-02-08 -----------------------------
879 //--------------------------------------------
881 if (_lstPoints.size()==2)
883 x1=_lstPoints[0]->GetX();
884 y1=_lstPoints[0]->GetY();
885 z1=_lstPoints[0]->GetZ();
886 x2=_lstPoints[1]->GetX();
887 y2=_lstPoints[1]->GetY();
888 z2=_lstPoints[1]->GetZ();
889 result = sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) + (z2-z1)*(z2-z1) );
891 if (_lstPoints.size()>2)
894 // JSTG 25-02-08 ------------------------------------------
895 //np = _lstPoints.size( );
897 //delta=( double ) ( np ) / ( double ) ( nps );
899 //GetSplinePoint(0,x1,y1,z1);
900 GetSpline_i_Point(0,&x1,&y1,&z1);
902 //for( i = 1; i < nps; i++ )
903 for( i = 1; i < GetNumberOfPointsSpline(); i++ )
905 //t = delta * (double)i;
906 //GetSplinePoint(t,x2,y2,z2);
907 GetSpline_i_Point(i,&x2,&y2,&z2);
908 //---------------------------------------------------------
909 result=result + sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) + (z2-z1)*(z2-z1) );
918 // ----------------------------------------------------------------------------
919 double manualContourModel::GetPathArea()
922 if ((_lstPoints.size()>=3) && IfCloseContour()==true )
925 //JSTG 25-02-08 ---------------------------------------------
927 //-----------------------------------------------------------
933 // This uses Green's theorem:
934 // A = 1/2 * sum( xiyi+1 - xi+1yi); pO == pN
935 // A < 0 -> A = |A| (a negative value could raise because points are
936 // given in clockwise order).
938 //JSTG 25-02-08 -------------------------------------------------
939 //int np = _lstPoints.size( );
941 int nps = GetNumberOfPointsSpline();
942 //double delta=( double ) ( np ) / ( double ) ( nps );
944 for( i = 0, area = 0.0; i < nps; i++ )
947 //ti = delta * (double)i;
948 //tj = delta * (double)j;
949 //GetSplinePoint(ti,x1,y1,z1);
950 //GetSplinePoint(tj,x2,y2,z2);
951 GetSpline_i_Point(i,&x1,&y1,&z1);
952 GetSpline_i_Point(j,&x2,&y2,&z2);
953 //----------------------------------------------------------------
966 for( i = 0, area = 0.0; i < _lstPoints.size(); i++ )
968 j = ( i + 1 ) % _lstPoints.size();
971 (_lstPoints[i]->GetX() * _lstPoints[j]->GetY() ) -
972 ( _lstPoints[j]->GetX() * _lstPoints[i]->GetY() );
973 if (_lstPoints[0]->GetZ()!=_lstPoints[i]->GetZ())
995 // ----------------------------------------------------------------------------
996 // p[x,y,z] : data in
997 // rp[x,y,z] : data out result point
998 // rn[x,y,z] : data out result normal
1000 void manualContourModel::GetNearestPointAndNormal(double *p, double *rp, double *rn)
1002 double distMin=999999999;
1003 double dist,dx,dy,dz;
1008 //JSTG 25-02-08 -------------------
1012 //---------------------------------
1014 np = _lstPoints.size( );
1017 // JSTG 25-02-08 ------------------------------------------
1019 nps = GetNumberOfPointsSpline();
1020 //delta = ( double ) ( np ) / ( double ) ( nps );
1022 //GetSplinePoint(0,x1,y1,z1);
1023 GetSpline_i_Point(0,&x1,&y1,&z1);
1024 for( i = 0; i < nps; i++ )
1026 //t = delta * (double)i;
1027 //GetSplinePoint(t,x1,y1,z1);
1028 GetSpline_i_Point(i,&x1,&y1,&z1);
1029 //----------------------------------------------------------
1033 dist = sqrt( dx*dx + dy*dy + dz*dz );
1051 // JSTG 25-02-08 ------------------------------------------
1055 //t = delta * (double)1.0;
1056 //GetSplinePoint(t,x1,y1,z1);
1057 GetSpline_i_Point(i,&x1,&y1,&z1);
1058 //----------------------------------------------------------
1075 // ----------------------------------------------------------------------------
1076 manualContourModel * manualContourModel :: Clone() // virtual
1078 manualContourModel * clone = new manualContourModel();
1079 CopyAttributesTo(clone);
1083 // ----------------------------------------------------------------------------
1084 void manualContourModel::Open(FILE *ff) // virtual
1088 int numberOfControlPoints;
1091 fscanf(ff,"%s",tmp); // NumberOfControlPoints
1092 fscanf(ff,"%s",tmp); // ##
1093 numberOfControlPoints = atoi(tmp);
1094 for (i=0;i<numberOfControlPoints;i++)
1096 fscanf(ff,"%s",tmp); // X
1098 fscanf(ff,"%s",tmp); // Y
1100 fscanf(ff,"%s",tmp); // Z
1107 // ----------------------------------------------------------------------------
1108 int manualContourModel::GetTypeModel() //virtual
1119 // ----------------------------------------------------------------------------
1120 void manualContourModel::Save(FILE *ff) // virtual
1122 int i,size=_lstPoints.size();
1123 fprintf(ff,"TypeModel %d\n", GetTypeModel() );
1124 fprintf(ff,"NumberOfControlPoints %d\n",size);
1125 for (i=0;i<size;i++)
1127 manualPoint *mp=_lstPoints[i];
1128 fprintf(ff,"%f %f %f\n", mp->GetX(), mp->GetY(), mp->GetZ() );
1133 // ---------------------------------------------------------------------------
1135 void manualContourModel::CopyAttributesTo( manualContourModel * cloneObject)
1138 //XXXX::CopyAttributesTo(cloneObject);
1140 cloneObject->SetCloseContour( this->IfCloseContour() );
1141 int i, size = GetSizeLstPoints();
1142 for( i=0; i<size; i++ )
1144 cloneObject->AddManualPoint( GetManualPoint( i )->Clone() );
1146 cloneObject->SetNumberOfPointsSpline( GetNumberOfPointsSpline () );
1147 cloneObject->SetCloseContour( _closeContour );
1148 cloneObject->UpdateSpline();
1152 // ---------------------------------------------------------------------------
1153 void manualContourModel::AddManualPoint( manualPoint* theManualPoint )//private
1155 _lstPoints.push_back( theManualPoint );
1158 std::vector<manualContourModel*> manualContourModel::ExploseModel( )
1160 std::vector<manualContourModel*> lstTmp;
1161 lstTmp.push_back(this);
1166 // ---------------------------------------------------------------------------
1167 // ----------------------------------------------------------------------------
1168 // ----------------------------------------------------------------------------
1170 //int manualViewPoint::range=1;
1173 manualViewPoint::manualViewPoint(wxVtkBaseView *wxvtkbaseview){
1175 _posibleSelected = false;
1178 _pointVtkActor = NULL;
1180 _wxvtkbaseview = wxvtkbaseview;
1188 // ----------------------------------------------------------------------------
1189 manualViewPoint::~manualViewPoint(){
1193 // ----------------------------------------------------------------------------
1194 void manualViewPoint::SetWidthLine( double width)
1199 // ----------------------------------------------------------------------------
1200 void manualViewPoint::SetSelected(bool selected){
1203 // ----------------------------------------------------------------------------
1204 void manualViewPoint::SetPosibleSelected(bool posibleSelected){
1205 _posibleSelected=posibleSelected;
1207 // ----------------------------------------------------------------------------
1208 bool manualViewPoint::GetSelected(){
1211 // ----------------------------------------------------------------------------
1212 bool manualViewPoint::GetPosibleSelected(){
1213 return _posibleSelected;
1215 // ----------------------------------------------------------------------------
1216 void manualViewPoint::DeleteVtkObjects(){
1217 if (_pointVtkActor !=NULL) { _pointVtkActor->Delete(); }
1218 if (_bboxMapper !=NULL) { _bboxMapper ->Delete(); }
1219 if (_pts !=NULL) { _pts ->Delete(); }
1220 if (_pd !=NULL) { _pd ->Delete(); }
1221 _pointVtkActor = NULL;
1229 // ----------------------------------------------------------------------------
1230 vtkActor* manualViewPoint::CreateVtkPointActor()
1234 _pts = vtkPoints::New();
1235 _pts->SetNumberOfPoints(8);
1236 _pts->SetPoint(0, -1000 , -1000 , 0 );
1237 _pts->SetPoint(1, 1000 , -1000 , 0 );
1238 _pts->SetPoint(2, 1000 , 1000 , 0 );
1239 _pts->SetPoint(3, -1000 , 1000 , 0 );
1240 _pts->SetPoint(4, -1000 , 1000 , 0 );
1241 _pts->SetPoint(5, -1000 , 1000 , 0 );
1242 _pts->SetPoint(6, -1000 , 1000 , 0 );
1243 _pts->SetPoint(7, -1000 , 1000 , 0 );
1245 vtkCellArray *lines = vtkCellArray::New();
1246 lines->InsertNextCell(17);
1247 lines->InsertCellPoint(0);
1248 lines->InsertCellPoint(1);
1249 lines->InsertCellPoint(2);
1250 lines->InsertCellPoint(3);
1251 lines->InsertCellPoint(0);
1252 lines->InsertCellPoint(4);
1253 lines->InsertCellPoint(5);
1254 lines->InsertCellPoint(6);
1255 lines->InsertCellPoint(7);
1256 lines->InsertCellPoint(4);
1257 lines->InsertCellPoint(0);
1258 lines->InsertCellPoint(3);
1259 lines->InsertCellPoint(7);
1260 lines->InsertCellPoint(6);
1261 lines->InsertCellPoint(2);
1262 lines->InsertCellPoint(1);
1263 lines->InsertCellPoint(5);
1265 _pd = vtkPolyData::New();
1266 _pd->SetPoints( _pts );
1267 _pd->SetLines( lines );
1268 lines->Delete(); //do not delete lines ??
1270 _pointVtkActor = vtkActor::New();
1271 _bboxMapper = vtkPolyDataMapper::New();
1273 _bboxMapper->SetInput(_pd);
1274 _bboxMapper->ImmediateModeRenderingOn();
1275 _pointVtkActor->SetMapper(_bboxMapper);
1276 _pointVtkActor->GetProperty()->BackfaceCullingOn();
1278 _pd->ComputeBounds();
1280 return _pointVtkActor;
1282 // ----------------------------------------------------------------------------
1283 vtkActor* manualViewPoint::GetVtkActor(){
1284 return _pointVtkActor;
1286 // ----------------------------------------------------------------------------
1287 void manualViewPoint::SetPositionXY(double x, double y,double i_range,double posZ)
1289 // double range=0.2; // i_range;
1290 // double range=(double)manualViewPoint::range;
1292 double range=i_range;
1297 posZ = posZ * _spc[2];
1300 _pts->SetPoint(0, x-range, y+range, posZ-range);
1301 _pts->SetPoint(1, x+range, y+range, posZ-range);
1302 _pts->SetPoint(2, x+range, y-range, posZ-range);
1303 _pts->SetPoint(3, x-range, y-range, posZ-range);
1304 _pts->SetPoint(4, x-range, y+range, posZ+range);
1305 _pts->SetPoint(5, x+range, y+range, posZ+range);
1306 _pts->SetPoint(6, x+range, y-range, posZ+range);
1307 _pts->SetPoint(7, x-range, y-range, posZ+range);
1312 // ----------------------------------------------------------------------------
1313 void manualViewPoint::UpdateColorActor()
1315 if (_pointVtkActor!=NULL){
1317 _pointVtkActor->GetProperty()->SetLineWidth( _widthline );
1318 _pointVtkActor->GetProperty()->SetDiffuseColor(1,0,0);
1319 if (_posibleSelected==true){
1320 _pointVtkActor->GetProperty()->SetDiffuseColor(1,1,0);
1324 // ----------------------------------------------------------------------------
1325 void manualViewPoint::GetSpacing(double spc[3])
1331 // ----------------------------------------------------------------------------
1332 void manualViewPoint::SetSpacing(double spc[3])
1341 // ----------------------------------------------------------------------------
1342 // ----------------------------------------------------------------------------
1343 // ----------------------------------------------------------------------------
1345 manualViewContour::manualViewContour()
1347 _id_viewPoint_for_text = 0;
1349 _initialConoturModel = new manualContourModel();
1351 // ----------------------------------------------------------------------------
1352 manualViewContour::~manualViewContour()
1354 delete _initialConoturModel;
1356 // ----------------------------------------------------------------------------
1358 // ----------------------------------------------------------------------------
1359 manualViewContour * manualViewContour :: Clone()
1361 manualViewContour * clone = new manualViewContour();
1362 CopyAttributesTo(clone);
1366 // ---------------------------------------------------------------------------
1368 void manualViewContour::CopyAttributesTo( manualViewContour * cloneObject)
1370 // Call to Fathers object
1371 manualViewBaseContour::CopyAttributesTo(cloneObject);
1373 cloneObject->SetMesureScale(_mesureScale);
1376 // ---------------------------------------------------------------------------
1378 int manualViewContour::GetType() // virtual
1383 // ----------------------------------------------------------------------------
1385 void manualViewContour::Save(FILE *pFile)
1387 manualViewBaseContour::Save(pFile);
1390 // ----------------------------------------------------------------------------
1392 void manualViewContour::Open(FILE *pFile)
1398 // ----------------------------------------------------------------------------
1399 void manualViewContour::RefreshContour() // virtual
1404 //JSTG 25-02-08 --------------------
1405 //double t,delta, x,y,z;
1407 //----------------------------------
1409 _manContModel->UpdateSpline();
1410 np = GetNumberOfPoints( );
1411 //nps = GetNumberOfPointsSpline();
1412 nps = _manContModel->GetNumberOfPointsSpline();
1413 //delta=( double ) ( np ) / ( double ) ( nps-1 ); //JSTG 25-02-08
1415 //printf ("EED manualViewContour::RefreshContour>> %d %d \n", np,nps);
1421 for( i = 0; i < nps; i++ )
1423 //JSTG 25-02-08 ------------------------------------------------
1424 //t = delta * (double)i;
1425 //_manContModel->GetSplinePoint(t,x,y,z);
1426 _manContModel->GetSpline_i_Point(i,&x,&y,&z);
1427 //--------------------------------------------------------------
1429 // _pts->SetPoint(i, x,y,z );
1430 _pts->SetPoint(i , x*_spc[0] , y*_spc[1] , z*_spc[2] );
1433 // printf ("EED manualViewContour::RefreshContour>> %d : %f %f %f \n", i,x,y,z);
1441 _pts->SetPoint(0, 0 , 0 , 0);
1442 _pts->SetPoint(1, 0 , 0 , 0);
1447 // ----------------------------------------------------------------------------
1448 void manualViewContour::RefreshText() // virtual
1451 if ((_textActor!=NULL) && ( _textActor->GetProperty()->GetOpacity()!=0 )){
1452 int size = GetNumberOfPoints();
1454 char resultText[50];
1455 strcpy(resultText," ");
1458 strcpy(resultText,"L= ");
1459 gcvt ( _mesureScale * this->_manContModel->GetPathSize() , 5, text );
1460 strcat(resultText,text);
1464 if (_manContModel->IfCloseContour()==true)
1466 strcpy(resultText,"P= ");
1467 gcvt ( _mesureScale * this->_manContModel->GetPathSize() , 5, text );
1468 strcat(resultText,text);
1469 gcvt ( _mesureScale * _mesureScale * this->_manContModel->GetPathArea() , 5, text );
1470 strcat(resultText," A= ");
1471 strcat(resultText,text);
1473 strcpy(resultText,"L= ");
1474 gcvt ( _mesureScale * this->_manContModel->GetPathSize() , 5, text );
1475 strcat(resultText,text);
1479 _textActor -> SetInput(resultText);
1484 for (i=0; i<size; i++)
1486 if (_lstViewPoints[i]->GetPosibleSelected()==true)
1488 _id_viewPoint_for_text = i;
1492 int id = _id_viewPoint_for_text;
1493 double px = _manContModel->GetManualPoint(id)->GetX();
1494 double py = _manContModel->GetManualPoint(id)->GetY();
1500 _textActor->SetPosition(px+GetRange()+1,py);
1506 // ----------------------------------------------------------------------------
1507 bool manualViewContour::ifTouchContour(int x,int y,int z){
1515 TransfromeCoordViewWorld(xx,yy,zz);
1523 unsigned int i, nps,nps_t;
1524 nps = _sizePointsContour;
1525 if (this->_manContModel->IfCloseContour()==true)
1532 for( i = 0; i < nps_t; i++ ) {
1533 _pts->GetPoint(i%nps, ppA);
1534 _pts->GetPoint((i+1)%nps, ppB);
1535 d1= sqrt( (ppA[0]-xx)*(ppA[0]-xx) + (ppA[1]-yy)*(ppA[1]-yy) + (ppA[2]-zz)*(ppA[2]-zz));
1536 d2= sqrt( (ppB[0]-xx)*(ppB[0]-xx) + (ppB[1]-yy)*(ppB[1]-yy) + (ppB[2]-zz)*(ppB[2]-zz));
1537 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]));
1538 if ( ((d1+d2)>=d3) && ((d1+d2)<=d3*1.3) ) {
1546 // ----------------------------------------------------------------------------
1547 void manualViewContour::DeletePoint(int id) // virtual
1549 if (_lstViewPoints.size()>2)
1551 manualViewBaseContour::DeletePoint( id );
1554 // ----------------------------------------------------------------------------
1556 void manualViewContour::ClearPoint(int id)
1558 manualViewBaseContour::DeletePoint( id );
1561 //-------------------------------------------------------------------
1562 void manualViewContour::SetMesureScale(double mesureScale)
1564 _mesureScale = mesureScale;
1566 //-------------------------------------------------------------------
1567 void manualViewContour::InitMove(int x, int y, int z)
1569 _initialConoturModel->DeleteAllPoints();
1571 manualPoint *mp = NULL;
1575 TransfromeCoordViewWorld(XX,YY,ZZ);
1577 int i, manualPointsSZ = _manContModel->GetSizeLstPoints();
1578 for ( i=0; i<manualPointsSZ; i++ )
1580 mp = _manContModel->GetManualPoint( i );
1581 this->_initialConoturModel->AddPoint( mp->GetX() - XX, mp->GetY() - YY, mp->GetZ() );
1584 //-------------------------------------------------------------------
1585 void manualViewContour::MoveContour(int x, int y, int z)
1587 manualPoint *mpOrigin = NULL;
1588 manualPoint *mpMoving = NULL;
1593 TransfromeCoordViewWorld(XX,YY,ZZ);
1595 int i, manualPointsSZ = _manContModel->GetSizeLstPoints();
1596 for ( i=0; i<manualPointsSZ; i++ )
1598 mpOrigin = _manContModel->GetManualPoint( i );
1599 mpMoving = _initialConoturModel->GetManualPoint(i);
1600 mpOrigin->SetPoint( mpMoving->GetX()+XX, mpMoving->GetY() + YY, mpMoving->GetZ() );
1604 void manualViewContour::MoveContour(int horizontalUnits, int verticalUnits )
1606 manualPoint *mpOrigin = NULL;
1608 int i, manualPointsSZ = _manContModel->GetSizeLstPoints();
1609 for ( i=0; i<manualPointsSZ; i++ )
1611 mpOrigin = _manContModel->GetManualPoint( i );
1612 mpOrigin->SetPoint( mpOrigin->GetX()+horizontalUnits, mpOrigin->GetY()+verticalUnits, mpOrigin->GetZ() );
1616 // ----------------------------------------------------------------------------
1617 // ----------------------------------------------------------------------------
1618 // ----------------------------------------------------------------------------
1621 manualView3VContour::manualView3VContour(int type)
1624 // JSTG 25-02-08 ------------------------------
1625 //_manContModel= new manualContourModel();
1626 //---------------------------------------------
1628 // ----------------------------------------------------------------------------
1629 manualView3VContour::~manualView3VContour()
1635 // ----------------------------------------------------------------------------
1636 manualView3VContour * manualView3VContour :: Clone()
1638 manualView3VContour * clone = new manualView3VContour( GetType() );
1639 CopyAttributesTo(clone);
1643 // ---------------------------------------------------------------------------
1645 void manualView3VContour::CopyAttributesTo( manualView3VContour * cloneObject)
1648 manualViewContour::CopyAttributesTo(cloneObject);
1651 int manualView3VContour::GetType()
1656 // ----------------------------------------------------------------------------
1657 void manualView3VContour::FilterCordinateXYZ(double &x,double &y,double &z)
1672 // ----------------------------------------------------------------------------
1674 void manualView3VContour::RefreshContour() // virtula
1676 manualViewContour::RefreshContour();
1679 // JSTG 25-02-08 ----------------------------------------
1680 //int nps = GetNumberOfPointsSpline();
1681 int nps = _manContModel->GetNumberOfPointsSpline();
1682 //-------------------------------------------------------
1683 for( i = 0; i < nps; i++ )
1685 _pts->GetPoint( i, pp );
1686 FilterCordinateXYZ(pp[0],pp[1],pp[2]);
1689 _pts->SetPoint( i, pp[0] , pp[1] ,pp[2] );
1694 // ----------------------------------------------------------------------------
1696 void manualView3VContour::UpdateViewPoint(int id){ // virtual
1698 manualPoint *mp = _manContModel->GetManualPoint(id);
1703 FilterCordinateXYZ(x,y,z);
1704 _lstViewPoints[id]->SetPositionXY( x , y ,GetRange(), z );
1707 // ----------------------------------------------------------------------------
1709 int manualView3VContour::GetIdPoint(int x, int y, int z) // virtual
1712 if (_manContModel!=NULL){
1716 TransfromeCoordViewWorld(xx,yy,zz,-1);
1717 ii=_manContModel->GetIdPoint(xx,yy,zz,GetRange(),_type);
1722 // ----------------------------------------------------------------------------
1723 bool manualView3VContour::ifTouchContour(int x,int y,int z){ // virtual
1731 TransfromeCoordViewWorld(xx,yy,zz,-1);
1738 unsigned int i, nps,nps_t;
1739 nps = _sizePointsContour;
1740 if (this->_manContModel->IfCloseContour()==true)
1746 FilterCordinateXYZ(xx,yy,zz);
1748 for( i = 0; i < nps_t; i++ ) {
1749 _pts->GetPoint(i%nps, ppA);
1750 _pts->GetPoint((i+1)%nps, ppB);
1751 FilterCordinateXYZ(ppA[0],ppA[1],ppA[2]);
1752 FilterCordinateXYZ(ppB[0],ppB[1],ppB[2]);
1753 d1= sqrt( (ppA[0]-xx)*(ppA[0]-xx) + (ppA[1]-yy)*(ppA[1]-yy) + (ppA[2]-zz)*(ppA[2]-zz));
1754 d2= sqrt( (ppB[0]-xx)*(ppB[0]-xx) + (ppB[1]-yy)*(ppB[1]-yy) + (ppB[2]-zz)*(ppB[2]-zz));
1755 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]));
1756 if ( ((d1+d2)>=d3) && ((d1+d2)<=d3*1.3) ) {
1763 // ----------------------------------------------------------------------------
1764 // ----------------------------------------------------------------------------
1765 // ----------------------------------------------------------------------------
1766 manualView3DContour::manualView3DContour()
1769 // ----------------------------------------------------------------------------
1770 manualView3DContour::~manualView3DContour()
1774 // ----------------------------------------------------------------------------
1775 manualView3DContour * manualView3DContour :: Clone()
1777 manualView3DContour * clone = new manualView3DContour();
1778 CopyAttributesTo(clone);
1782 // ---------------------------------------------------------------------------
1783 void manualView3DContour::CopyAttributesTo( manualView3DContour * cloneObject)
1786 manualViewContour::CopyAttributesTo(cloneObject);
1788 cloneObject->SetDimensions ( _w , _h , _d );
1790 // ----------------------------------------------------------------------------
1791 void manualView3DContour::SetDimensions(int w, int h, int d)
1797 // ----------------------------------------------------------------------------
1798 void manualView3DContour::TransfromeCoordViewWorld(double &X, double &Y, double &Z, int type)
1800 X = _vtkmprbasedata->GetX();
1801 Y = _vtkmprbasedata->GetY();
1802 Z = _vtkmprbasedata->GetZ();
1804 // ----------------------------------------------------------------------------
1805 void manualView3DContour::SetVtkMPRBaseData(vtkMPRBaseData *vtkmprbasedata)
1807 _vtkmprbasedata = vtkmprbasedata;
1809 // ----------------------------------------------------------------------------
1810 int manualView3DContour::GetIdPoint2(int x, int y)
1813 double p[3],pA[3],pB[3];
1815 double pickPoint[ 3 ], cameraPos[ 3 ];
1816 vtkPointPicker* picker = vtkPointPicker::New( );
1817 vtkRenderer *pRenderer = this->GetWxVtkBaseView()->GetRenderer();
1818 picker->Pick( x, y, 0.0, pRenderer );
1819 pRenderer->GetActiveCamera( )->GetPosition( cameraPos );
1820 picker->GetPickPosition( pickPoint );
1823 UtilVtk3DGeometriSelection utilVtk3Dgeometriselection;
1824 utilVtk3Dgeometriselection.SetDimentions(_w,_h,_d);
1826 if( utilVtk3Dgeometriselection.FindCubePointsFromPoints( pA, pB, pickPoint, cameraPos ) )
1828 double dist,distMin=999999999;
1829 int i,size=this->_manContModel->GetSizeLstPoints();
1830 for (i=0;i<size;i++)
1832 manualPoint *mp = this->_manContModel->GetManualPoint(i);
1836 dist=utilVtk3Dgeometriselection.DistanceMinPointToLine(p,pA,pB);
1837 if ( (dist<=2*GetRange()) && (dist<distMin) )
1846 // ----------------------------------------------------------------------------
1847 int manualView3DContour::SelectPosiblePoint ( int x, int y, int z )// virtual
1849 SelectAllPossibleSelected(false);
1850 int id=GetIdPoint2(x,y);
1853 SetPointPosibleSelected(id,true);
1861 // ----------------------------------------------------------------------------
1862 // ----------------------------------------------------------------------------
1863 // ----------------------------------------------------------------------------
1868 // ----------------------------------------------------------------------------
1869 // ----------------------------------------------------------------------------
1870 // ----------------------------------------------------------------------------
1871 manualViewBullEyeSector::manualViewBullEyeSector()
1875 // ----------------------------------------------------------------------------
1876 void manualViewBullEyeSector::RefreshContour()
1881 //----------------------------------
1883 _manContModel->UpdateSpline();
1884 nps = _manContModel->GetNumberOfPointsSpline();
1888 for( i = 0; i < nps; i++ )
1890 _manContModel->GetSpline_i_Point(i,&x,&y,&z);
1891 _pts->SetPoint(i , x*_spc[0] , y*_spc[1] , z*_spc[2] );
1897 // ----------------------------------------------------------------------------
1898 // ----------------------------------------------------------------------------
1899 // ----------------------------------------------------------------------------
1902 manualViewBullEye::manualViewBullEye()
1906 // ----------------------------------------------------------------------------
1907 manualViewBullEye::~manualViewBullEye()
1910 int i,size=lstSectorBullEye.size();
1911 for (i=0;i<size;i++)
1913 delete lstSectorBullEye[i];
1915 lstSectorBullEye.clear();
1919 // ----------------------------------------------------------------------------
1920 manualViewBullEye * manualViewBullEye :: Clone()
1922 manualViewBullEye * clone = new manualViewBullEye();
1923 CopyAttributesTo(clone);
1927 // ---------------------------------------------------------------------------
1929 void manualViewBullEye::CopyAttributesTo( manualViewBullEye * cloneObject)
1932 manualViewBaseContour::CopyAttributesTo(cloneObject);
1936 // ----------------------------------------------------------------------------
1937 int manualViewBullEye::GetType() // virtual
1943 // ----------------------------------------------------------------------------
1944 void manualViewBullEye::RefreshContour() // virtual
1946 // External Rectangle
1947 manualViewRoi::RefreshContour();
1949 _manContModel->UpdateSpline();
1950 int np = GetNumberOfPoints( );
1951 // Refres sectors of BullEye(s)
1955 int i,size = lstSectorBullEye.size();
1956 for (i=0;i<size;i++)
1958 lstSectorBullEye[i]->RefreshContour();
1965 // ----------------------------------------------------------------------------
1966 void manualViewBullEye::ConstructVTKObjects() // virtual
1968 manualViewRoi::ConstructVTKObjects();
1971 this->GetSpacing(spc);
1972 manualViewBullEyeSector *mvbc;
1973 manualContourModelBullEye *mcmbe = (manualContourModelBullEye*)this->_manContModel;
1974 int i,size = mcmbe->GetSizeOfSectorLst();
1975 for ( i=0 ; i<size ; i++ )
1977 mvbc = new manualViewBullEyeSector();
1978 mvbc->SetModel( mcmbe->GetModelSector(i) );
1979 mvbc->SetWxVtkBaseView( this->GetWxVtkBaseView() );
1980 mvbc->SetRange( 2 );
1982 mvbc->SetSpacing(spc);
1983 mvbc->SetColorNormalContour(1, 0, 0);
1984 // mvbc->SetColorEditContour(0.5, 0.5, 0.5);
1985 // mvbc->SetColorSelectContour(1, 0.8, 0);
1986 mvbc->SetWidthLine( this->GetWidthLine() );
1988 mvbc->ConstructVTKObjects();
1989 lstSectorBullEye.push_back( mvbc );
1995 // ----------------------------------------------------------------------------
1996 void manualViewBullEye::AddSplineActor() // virtual
1998 manualViewRoi::AddSplineActor();
1999 int i,size=lstSectorBullEye.size();
2000 for (i=0;i<size;i++)
2002 lstSectorBullEye[i]->AddSplineActor();
2006 // ----------------------------------------------------------------------------
2007 void manualViewBullEye::RemoveSplineActor() // virtual
2009 manualViewRoi::RemoveSplineActor();
2010 int i,size=lstSectorBullEye.size();
2011 for (i=0;i<size;i++)
2013 lstSectorBullEye[i]->RemoveSplineActor();
2018 // ----------------------------------------------------------------------------
2019 // ----------------------------------------------------------------------------
2020 // ----------------------------------------------------------------------------
2022 manualViewRoi::manualViewRoi()
2024 _sizePointsContour=5;
2026 // ----------------------------------------------------------------------------
2027 manualViewRoi::~manualViewRoi()
2032 // ----------------------------------------------------------------------------
2033 manualViewRoi * manualViewRoi :: Clone()
2035 manualViewRoi * clone = new manualViewRoi();
2036 CopyAttributesTo(clone);
2040 // ---------------------------------------------------------------------------
2042 void manualViewRoi::CopyAttributesTo( manualViewRoi * cloneObject)
2045 manualViewBaseContour::CopyAttributesTo(cloneObject);
2048 // ----------------------------------------------------------------------------
2049 void manualViewRoi::RefreshContour() // virtual
2051 unsigned int i,ii, np;
2052 np = GetNumberOfPoints( );
2058 for( i = 0; i < np+1; i++ ) {
2060 mp = _manContModel->GetManualPoint(ii);
2063 double XX=mp->GetX(),YY=mp->GetY(),ZZ=mp->GetZ();
2064 // wxVtk2DBaseView *wxvtk2Dbasevie = (wxVtk2DBaseView*)this->GetWxVtkBaseView();
2065 // wxvtk2Dbasevie->TransformCoordinate_spacing_ModelToView(XX,YY,ZZ);
2068 // _pts->SetPoint(i, XX,YY,ZZ );
2069 _pts->SetPoint(i, XX*_spc[0] , YY*_spc[1] , ZZ*_spc[2] );
2073 _pts->SetPoint(0, 0 , 0 , 0);
2074 _pts->SetPoint(1, 0 , 0 , 0);
2079 // ----------------------------------------------------------------------------
2080 int manualViewRoi::GetType() // virtual
2085 // ----------------------------------------------------------------------------
2087 void manualViewRoi::GetMinMax(double &minX,double &minY, double &maxX, double &maxY)
2098 unsigned int size=(unsigned int) _manContModel->GetSizeLstPoints();
2100 for( i = 0; i < size; i++ )
2103 mp=_manContModel->GetManualPoint(i);
2138 // ----------------------------------------------------------------------------
2140 bool manualViewRoi::ifTouchContour(int x,int y, int z) // virtual
2143 double px1=99999,py1=99999,px2=-9999,py2=-99999;
2145 GetMinMax(px1,py1, px2, py2);
2150 TransfromeCoordViewWorld(xx,yy,zz);
2154 double ddx=GetRange();
2155 double ddy=GetRange();
2157 if ((xx>px1-ddx)&&(xx<px2+ddx) && (yy>py1-ddy)&&(yy<py2+ddy))
2162 if ((xx>px1+ddx)&&(xx<px2-ddx) && (yy>py1+ddy)&&(yy<py2-ddy))
2167 if ((ok1==true) && (ok2==false))
2176 // ----------------------------------------------------------------------------
2178 void manualViewRoi::InitMove(int x, int y, int z) // virtual
2184 TransfromeCoordViewWorld(XX,YY,ZZ);
2186 if (_manContModel->GetSizeLstPoints()==4){
2187 mp = _manContModel->GetManualPoint(0);
2188 _dp0[0]= mp->GetX() - XX;
2189 _dp0[1]= mp->GetY() - YY;
2190 _dp0[2]= mp->GetZ();
2192 mp = _manContModel->GetManualPoint(1);
2193 _dp1[0]= mp->GetX() - XX;
2194 _dp1[1]= mp->GetY() - YY;
2195 _dp1[2]= mp->GetZ();
2197 mp = _manContModel->GetManualPoint(2);
2198 _dp2[0]= mp->GetX() - XX;
2199 _dp2[1]= mp->GetY() - YY;
2200 _dp2[2]= mp->GetZ();
2202 mp = _manContModel->GetManualPoint(3);
2203 _dp3[0]= mp->GetX() - XX;
2204 _dp3[1]= mp->GetY() - YY;
2205 _dp3[2]= mp->GetZ();
2209 // ----------------------------------------------------------------------------
2211 void manualViewRoi::MoveContour(int x, int y, int z) // virtual
2217 TransfromeCoordViewWorld(XX,YY,ZZ);
2219 mp = _manContModel->GetManualPoint(0);
2220 mp->SetPoint(_dp0[0]+XX,_dp0[1]+YY,_dp0[2]);
2222 mp = _manContModel->GetManualPoint(1);
2223 mp->SetPoint(_dp1[0]+XX,_dp1[1]+YY,_dp0[2]);
2225 mp = _manContModel->GetManualPoint(2);
2226 mp->SetPoint(_dp2[0]+XX,_dp2[1]+YY,_dp0[2]);
2228 mp = _manContModel->GetManualPoint(3);
2229 mp->SetPoint(_dp3[0]+XX,_dp3[1]+YY,_dp0[2]);
2240 // ----------------------------------------------------------------------------
2241 // ----------------------------------------------------------------------------
2242 // ----------------------------------------------------------------------------
2246 manualViewCircle::manualViewCircle()
2248 // _sizePointsContour=5; // default 100
2250 // ----------------------------------------------------------------------------
2251 manualViewCircle::~manualViewCircle()
2256 // ----------------------------------------------------------------------------
2257 manualViewCircle * manualViewCircle :: Clone()
2259 manualViewCircle * clone = new manualViewCircle();
2260 CopyAttributesTo(clone);
2264 // ---------------------------------------------------------------------------
2266 void manualViewCircle::CopyAttributesTo( manualViewCircle * cloneObject)
2269 manualViewBaseContour::CopyAttributesTo(cloneObject);
2273 // ----------------------------------------------------------------------------
2275 void manualViewCircle::RefreshContour(){ // virtual
2277 manualPoint *mpA,*mpB;
2278 unsigned int i, np,nps;
2282 np = GetNumberOfPoints( );
2283 nps = _manContModel->GetNumberOfPointsSpline();
2284 double deltaAngle=(3.14159265*2)/(nps-1);
2289 mpA = _manContModel->GetManualPoint(0);
2290 mpB = _manContModel->GetManualPoint(1);
2291 difX = mpA->GetX() - mpB->GetX();
2292 difY = mpA->GetY() - mpB->GetY();
2293 radio = sqrt( difX*difX + difY*difY );
2294 manualContourModelCircle *manContModelCir = (manualContourModelCircle*)_manContModel;
2295 manContModelCir->SetRadio(radio);
2297 for( i = 0; i < nps; i++ ) {
2298 manContModelCir->GetSpline_i_Point(i, &XX, &YY, &ZZ);
2299 // angle = deltaAngle*i;
2300 // XX = cos(angle)*radio+mpA->GetX();
2301 // YY = sin(angle)*radio+mpA->GetY();
2303 _pts->SetPoint(i, XX*_spc[0] , YY*_spc[1] , ZZ*_spc[2] );
2306 _pts->SetPoint(0, 0 , 0 , 0);
2307 _pts->SetPoint(1, 0 , 0 , 0);
2313 // ----------------------------------------------------------------------------
2314 int manualViewCircle::GetType() // virtual
2319 // ----------------------------------------------------------------------------
2321 void manualViewCircle::GetMinMax(double &minX,double &minY, double &maxX, double &maxY)
2323 manualPoint *mpA,*mpB;
2327 np = GetNumberOfPoints( );
2330 mpA = _manContModel->GetManualPoint(0);
2331 mpB = _manContModel->GetManualPoint(1);
2332 difX = mpA->GetX() - mpB->GetX();
2333 difY = mpA->GetY() - mpB->GetY();
2334 radio = sqrt( difX*difX + difY*difY );
2335 minX=mpA->GetX()-radio;
2336 minY=mpA->GetY()-radio;
2337 maxX=mpA->GetX()+radio;
2338 maxY=mpA->GetY()+radio;
2348 // ----------------------------------------------------------------------------
2349 bool manualViewCircle::ifTouchContour(int x,int y, int z) // virtual
2352 double px1=99999,py1=99999,px2=-9999,py2=-99999;
2354 GetMinMax(px1,py1, px2, py2);
2359 TransfromeCoordViewWorld(xx,yy,zz);
2363 double ddx=GetRange();
2364 double ddy=GetRange();
2366 if ((xx>px1-ddx)&&(xx<px2+ddx) && (yy>py1-ddy)&&(yy<py2+ddy))
2371 if ((xx>px1+ddx)&&(xx<px2-ddx) && (yy>py1+ddy)&&(yy<py2-ddy))
2376 if ((ok1==true) && (ok2==false))
2385 // ----------------------------------------------------------------------------
2387 void manualViewCircle::InitMove(int x, int y, int z) // virtual
2393 TransfromeCoordViewWorld(XX,YY,ZZ);
2395 if (_manContModel->GetSizeLstPoints()==2){
2396 mp = _manContModel->GetManualPoint(0);
2397 _dp0[0]= mp->GetX() - XX;
2398 _dp0[1]= mp->GetY() - YY;
2399 _dp0[2]= mp->GetZ();
2401 mp = _manContModel->GetManualPoint(1);
2402 _dp1[0]= mp->GetX() - XX;
2403 _dp1[1]= mp->GetY() - YY;
2404 _dp1[2]= mp->GetZ();
2406 mp = _manContModel->GetManualPoint(2);
2407 _dp2[0]= mp->GetX() - XX;
2408 _dp2[1]= mp->GetY() - YY;
2409 _dp2[2]= mp->GetZ();
2411 mp = _manContModel->GetManualPoint(3);
2412 _dp3[0]= mp->GetX() - XX;
2413 _dp3[1]= mp->GetY() - YY;
2414 _dp3[2]= mp->GetZ();
2420 // ----------------------------------------------------------------------------
2421 void manualViewCircle::MoveContour(int x, int y, int z) // virtual
2427 TransfromeCoordViewWorld(XX,YY,ZZ);
2429 mp = _manContModel->GetManualPoint(0);
2430 mp->SetPoint(_dp0[0]+XX,_dp0[1]+YY,_dp0[2]);
2432 mp = _manContModel->GetManualPoint(1);
2433 mp->SetPoint(_dp1[0]+XX,_dp1[1]+YY,_dp0[2]);
2435 // mp = _manContModel->GetManualPoint(2);
2436 // mp->SetPoint(_dp2[0]+XX,_dp2[1]+YY,_dp0[2]);
2438 // mp = _manContModel->GetManualPoint(3);
2439 // mp->SetPoint(_dp3[0]+XX,_dp3[1]+YY,_dp0[2]);
2443 // UpdateViewPoint(2);
2444 // UpdateViewPoint(3);
2453 // ----------------------------------------------------------------------------
2454 // ----------------------------------------------------------------------------
2455 // ----------------------------------------------------------------------------
2458 manualViewBaseContour::manualViewBaseContour()
2462 _manContModel = NULL;
2463 _wxvtkbaseview = NULL;
2465 _posibleSelected = false;
2466 _viewControlPoints = false;
2469 _contourVtkActor = NULL;
2472 _sizePointsContour = 100;
2481 _coulorNormal_r = 1;
2482 _coulorNormal_g = 0;
2483 _coulorNormal_b = 1;
2485 _coulorSelection_r = 0;
2486 _coulorSelection_g = 1;
2487 _coulorSelection_b = 0;
2492 // ----------------------------------------------------------------------------
2493 manualViewBaseContour::~manualViewBaseContour()
2495 int i,size=_lstViewPoints.size();
2496 for (i=0;i<size; i++){
2497 delete _lstViewPoints[i];
2499 _lstViewPoints.clear();
2501 // ----------------------------------------------------------------------------
2504 int manualViewBaseContour::GetType() // virtual
2507 //int manualViewBaseContour::GetType() 0;
2508 //int manualViewContour::GetType() 1;
2509 //int manualViewRoi::GetType() 2;
2510 //int manualViewCircle::GetType() 3;
2511 //int manualViewStar::GetType() 4;
2516 // ----------------------------------------------------------------------------
2518 void manualViewBaseContour::Save(FILE *pFile)
2520 fprintf(pFile,"TypeView %d\n", GetType() );
2523 // ----------------------------------------------------------------------------
2524 void manualViewBaseContour::Open(FILE *pFile)
2528 // ----------------------------------------------------------------------------
2529 void manualViewBaseContour :: AddCompleteContourActor( bool ifControlPoints )
2531 _viewControlPoints = ifControlPoints;
2532 /*vtkRenderer * theRenderer = */ _wxvtkbaseview->GetRenderer(); // JPRx ??
2537 //Adding each control point
2538 if( ifControlPoints )
2543 // ---------------------------------------------------------------------------
2545 void manualViewBaseContour :: RemoveCompleteContourActor()
2547 /*vtkRenderer * theRenderer =*/ _wxvtkbaseview->GetRenderer(); // JPRx ??
2548 //Removing the spline
2549 RemoveSplineActor();
2552 //Removing each point
2553 RemoveControlPoints();
2557 // ---------------------------------------------------------------------------
2558 manualViewBaseContour * manualViewBaseContour :: Clone( )//virtual
2560 manualViewBaseContour * clone = new manualViewBaseContour();
2561 CopyAttributesTo(clone);
2566 // ---------------------------------------------------------------------------
2568 void manualViewBaseContour::CopyAttributesTo( manualViewBaseContour * cloneObject)
2571 //XXXX::CopyAttributesTo(cloneObject);
2573 cloneObject-> SetWxVtkBaseView( this->_wxvtkbaseview );
2574 cloneObject-> SetSelected( this->GetSelected() );
2575 cloneObject-> SetPosibleSelected( this->GetPosibleSelected() );
2576 cloneObject-> SetIfViewControlPoints( this->GetIfViewControlPoints() );
2577 cloneObject-> SetRange( this->GetRange() );
2578 cloneObject-> SetZ( this->GetZ() );
2579 cloneObject-> SetSpacing( _spc );
2580 cloneObject-> SetColorNormalContour( _coulorNormal_r, _coulorNormal_g, _coulorNormal_b );
2581 cloneObject-> SetColorEditContour( _coulorEdit_r, _coulorEdit_g, _coulorEdit_b );
2582 cloneObject-> SetColorSelectContour( _coulorSelection_r, _coulorSelection_g, _coulorSelection_b );
2584 int i, size = _lstViewPoints.size();
2585 for ( i=0; i<size; i++ )
2587 cloneObject->AddPoint( );
2591 // ----------------------------------------------------------------------------
2592 void manualViewBaseContour :: AddSplineActor()
2594 vtkRenderer * theRenderer = _wxvtkbaseview->GetRenderer();
2595 if (_contourVtkActor!=NULL)
2596 theRenderer->AddActor( _contourVtkActor );
2598 // ----------------------------------------------------------------------------
2599 void manualViewBaseContour :: RemoveSplineActor() // virtual
2601 vtkRenderer * theRenderer = _wxvtkbaseview->GetRenderer();
2602 if (_contourVtkActor!=NULL)
2603 theRenderer->RemoveActor( _contourVtkActor );
2605 // ----------------------------------------------------------------------------
2606 void manualViewBaseContour :: RemoveControlPoints()
2608 if (_wxvtkbaseview!=NULL){
2609 vtkRenderer * theRenderer = _wxvtkbaseview->GetRenderer();
2610 int i,size=_lstViewPoints.size();
2611 for (i=0;i<size; i++)
2613 vtkActor * pointActor = _lstViewPoints[i]->GetVtkActor();
2614 theRenderer->RemoveActor( pointActor );
2617 SetIfViewControlPoints( false );
2619 // ----------------------------------------------------------------------------
2620 void manualViewBaseContour :: AddControlPoints()
2622 vtkRenderer * theRenderer = _wxvtkbaseview->GetRenderer();
2623 SetIfViewControlPoints( true );
2624 if( _viewControlPoints )
2626 int i,size=_lstViewPoints.size();
2627 for (i=0;i<size; i++)
2629 vtkActor * pointActor = _lstViewPoints[i]->GetVtkActor();
2630 theRenderer->AddActor( pointActor );
2634 // ----------------------------------------------------------------------------
2635 void manualViewBaseContour::AddTextActor()
2637 _wxvtkbaseview->GetRenderer()->AddActor2D( _textActor );
2639 // ----------------------------------------------------------------------------
2640 void manualViewBaseContour::RemoveTextActor()
2642 _wxvtkbaseview->GetRenderer()->RemoveActor2D( _textActor );
2644 // ----------------------------------------------------------------------------
2645 void manualViewBaseContour::DeleteVtkObjects()
2647 if ( _contourVtkActor != NULL ) { _contourVtkActor -> Delete(); }
2648 if ( _bboxMapper != NULL ) { _bboxMapper -> Delete(); }
2649 if ( _pts != NULL ) { _pts -> Delete(); }
2650 if ( _pd != NULL ) { _pd -> Delete(); }
2651 _contourVtkActor = NULL;
2658 // ----------------------------------------------------------------------------
2659 void manualViewBaseContour::SetWidthLine(double width)
2662 this->UpdateColorActor();
2664 // for the control points
2665 int id, size = _lstViewPoints.size();
2666 for( id=0; id<size; id++)
2668 this->_lstViewPoints[id]->SetWidthLine(_widthline);
2673 // ----------------------------------------------------------------------------
2674 double manualViewBaseContour::GetWidthLine()
2679 // ----------------------------------------------------------------------------
2680 void manualViewBaseContour::ConstructVTKObjects()
2682 //JSTG 29-02-08 -----------------------------------------------
2683 //int i , nps = _sizePointsContour;
2685 int nps = _manContModel->GetNumberOfPointsSpline();
2686 //-------------------------------------------------------------
2688 _pts = vtkPoints::New();
2689 _pts->SetNumberOfPoints(nps);
2691 for (i=0 ; i<nps ; i++){
2692 _pts->SetPoint(i, 0 , 0 , 0 );
2694 // This is for the boundaring inicialisation
2695 _pts->SetPoint(0, -1000 , -1000 , -1000 );
2696 _pts->SetPoint(1, 1000 , 1000 , 1000 );
2698 vtkCellArray *lines = vtkCellArray::New();
2699 lines->InsertNextCell( nps /* +1 */ );
2700 for ( i=0 ; i<nps+1 ; i++ ){
2701 lines->InsertCellPoint(i % nps );
2704 _pd = vtkPolyData::New();
2705 _pd->SetPoints( _pts );
2706 _pd->SetLines( lines );
2707 lines->Delete(); //do not delete lines ??
2709 _contourVtkActor = vtkActor::New();
2710 _bboxMapper = vtkPolyDataMapper::New();
2711 _bboxMapper->ScalarVisibilityOff( );
2713 _bboxMapper->SetInput(_pd);
2714 _bboxMapper->ImmediateModeRenderingOn();
2715 _contourVtkActor->SetMapper(_bboxMapper);
2716 _contourVtkActor->GetProperty()->BackfaceCullingOff();
2720 _pd->ComputeBounds();
2723 _textActor = vtkTextActor::New();
2724 // _textActor->SetDisplayPosition(200, 200);
2725 _textActor->SetInput("");
2726 // Set coordinates to match the old vtkScaledTextActor default value
2727 // _textActor->GetPosition2Coordinate()->SetCoordinateSystemToNormalizedViewport();
2728 // _textActor->GetPosition2Coordinate()->SetValue( 0.2 , 0.2 );
2729 _textActor->GetPositionCoordinate()->SetCoordinateSystemToWorld ();
2730 // _textActor->GetPositionCoordinate()->SetValue( 0.8 , 0.8 );
2732 vtkTextProperty *tprop = _textActor->GetTextProperty();
2733 tprop->SetFontSize(14);
2734 tprop->SetFontFamilyToArial();
2735 tprop->SetColor(0, 0, 1);
2737 // ----------------------------------------------------------------------------
2738 void manualViewBaseContour::CreateNewContour()
2740 ConstructVTKObjects();
2742 _wxvtkbaseview->GetRenderer()->AddActor( _contourVtkActor );
2743 _wxvtkbaseview->GetRenderer()->AddActor2D(_textActor);*/
2744 AddCompleteContourActor();
2746 // ----------------------------------------------------------------------------
2747 void manualViewBaseContour::UpdateViewPoint(int id) // virtual
2749 manualPoint *mp = _manContModel->GetManualPoint(id);
2752 double XX=mp->GetX(),YY=mp->GetY(),ZZ=mp->GetZ();
2753 // wxVtk2DBaseView *wxvtk2Dbasevie = (wxVtk2DBaseView*)this->GetWxVtkBaseView();
2754 // wxvtk2Dbasevie->TransformCoordinate_spacing_ModelToView(XX,YY,ZZ);
2756 _lstViewPoints[id]->SetPositionXY( XX , YY ,_range, ZZ );
2759 // ----------------------------------------------------------------------------
2760 void manualViewBaseContour :: UpdateViewPoints()
2762 int id, size = _lstViewPoints.size();
2763 for( id=0; id<size; id++)
2765 UpdateViewPoint( id );
2769 // ----------------------------------------------------------------------------
2770 void manualViewBaseContour::AddPoint()
2772 manualViewPoint *mvp = new manualViewPoint( this->GetWxVtkBaseView() );
2775 // ----------------------------------------------------------------------------
2776 void manualViewBaseContour::AddPoint( manualViewPoint * manualViewPoint )
2778 _lstViewPoints.push_back( manualViewPoint );
2781 manualViewPoint->SetSpacing(_spc);
2783 vtkActor *actor = manualViewPoint->CreateVtkPointActor();
2784 _wxvtkbaseview->GetRenderer()->AddActor( actor );
2787 // ----------------------------------------------------------------------------
2788 void manualViewBaseContour::InsertPoint(int id)
2790 manualViewPoint *mvp = new manualViewPoint( this->GetWxVtkBaseView() );
2793 mvp->SetSpacing(_spc);
2795 std::vector<manualViewPoint*>::iterator itNum = _lstViewPoints.begin() + id;
2796 _lstViewPoints.insert(itNum,mvp);
2797 _wxvtkbaseview->GetRenderer()->AddActor( mvp->CreateVtkPointActor() );
2799 // ----------------------------------------------------------------------------
2800 void manualViewBaseContour::DeleteContour()
2802 RemoveCompleteContourActor();
2803 /*if (_contourVtkActor!=NULL){
2804 _wxvtkbaseview->GetRenderer()->RemoveActor( _contourVtkActor );
2807 int i,size=_lstViewPoints.size();
2808 for (i=0;i<size;i++){
2809 manualViewBaseContour::DeletePoint(0);
2813 // ----------------------------------------------------------------------------
2814 void manualViewBaseContour::DeletePoint(int id) // virtual
2816 int size=_lstViewPoints.size();
2817 if ( (id>=0) && (id<size) ){
2818 manualViewPoint *mvp =_lstViewPoints[id];
2820 // _handlePicker->DeletePickList(mvp->GetVtkActor());
2821 _wxvtkbaseview->GetRenderer()->RemoveActor( mvp->GetVtkActor() );
2822 std::vector<manualViewPoint*>::iterator itNum = _lstViewPoints.begin() + id;
2823 _lstViewPoints.erase(itNum);
2828 // ----------------------------------------------------------------------------
2829 void manualViewBaseContour::DeletePoint(int x, int y, int z)
2831 int id=GetIdPoint(x,y,z);
2836 // ----------------------------------------------------------------------------
2837 void manualViewBaseContour::SetSelected(bool selected)
2841 // ----------------------------------------------------------------------------
2842 void manualViewBaseContour::SetPosibleSelected(bool posibleSelected)
2844 _posibleSelected=posibleSelected;
2846 // ----------------------------------------------------------------------------
2847 bool manualViewBaseContour::GetEditable()
2851 // ----------------------------------------------------------------------------
2852 void manualViewBaseContour::SetEditable( bool * condition )
2854 _editable = condition;
2856 // ----------------------------------------------------------------------------
2857 bool manualViewBaseContour::GetSelected()
2861 // ----------------------------------------------------------------------------
2862 bool manualViewBaseContour::GetPosibleSelected()
2864 return _posibleSelected;
2866 // ----------------------------------------------------------------------------
2867 void manualViewBaseContour::DeleteSelectedPoints()
2869 int i,size=_lstViewPoints.size();
2870 for (i=size-1;i>=0;i--){
2871 if (_lstViewPoints[i]->GetSelected()==true){
2877 // ----------------------------------------------------------------------------
2878 void manualViewBaseContour::SelectPoint(int i, bool select)
2880 _lstViewPoints[i]->SetSelected(select);
2882 // ----------------------------------------------------------------------------
2883 void manualViewBaseContour::SelectLstPoints()
2887 // ----------------------------------------------------------------------------
2888 void manualViewBaseContour::SelectAllPoints(bool select)
2890 int i,size=_lstViewPoints.size();
2891 for (i=0;i<size;i++){
2892 SelectPoint(i,select);
2895 //-----------------------------------------------------------------------------
2896 void manualViewBaseContour:: SetIfViewControlPoints(bool ifShow)
2898 _viewControlPoints = ifShow;
2900 // ----------------------------------------------------------------------------
2901 bool manualViewBaseContour:: GetIfViewControlPoints()
2903 return _viewControlPoints;
2906 // ----------------------------------------------------------------------------
2907 void manualViewBaseContour::SetPointPosibleSelected(int id,bool select)
2909 _lstViewPoints[id]->SetPosibleSelected(select);
2911 // ----------------------------------------------------------------------------
2912 void manualViewBaseContour::SetPointSelected(int id,bool select)
2914 _lstViewPoints[id]->SetSelected(select);
2916 // ----------------------------------------------------------------------------
2917 void manualViewBaseContour::SelectAllPossibleSelected(bool select)
2919 int i,size=_lstViewPoints.size();
2920 for (i=0;i<size;i++){
2921 SetPointPosibleSelected(i,select);
2924 // ----------------------------------------------------------------------------
2925 int manualViewBaseContour::SelectPosiblePoint(int x, int y, int z) // virtual
2927 SelectAllPossibleSelected(false);
2929 int id = GetIdPoint(x,y,z);
2932 SetPointPosibleSelected(id,true);
2936 // ----------------------------------------------------------------------------
2937 bool manualViewBaseContour::SelectPosibleContour(int x, int y, int z)
2940 SetPosibleSelected(result);
2941 int id = GetIdPoint(x,y,z);
2942 if( !GetEditable() && !_selected && id!= -1)
2945 SetPosibleSelected(result);
2949 if ( (GetEditable()==true) && (id==-1 ) && (this->_lstViewPoints.size()>=2) )
2951 if (ifTouchContour(x,y,z)==true)
2954 SetPosibleSelected(result);
2958 if (GetEditable()==false)
2960 if (ifTouchContour(x,y,z)==true)
2963 SetPosibleSelected(result);
2971 // ----------------------------------------------------------------------------
2972 bool manualViewBaseContour::ifTouchContour(int x,int y, int z) // virtual
2976 // ----------------------------------------------------------------------------
2977 void manualViewBaseContour::UnSelectPoint(int i){
2978 _lstViewPoints[i]->SetSelected(false);
2981 // ----------------------------------------------------------------------------
2982 void manualViewBaseContour::UnSelectLstPoints(){
2985 // ----------------------------------------------------------------------------
2986 void manualViewBaseContour::UnSelectAllPoints(){
2987 int i,size=_lstViewPoints.size();
2988 for (i=0;i<size;i++){
2993 // ----------------------------------------------------------------------------
2994 void manualViewBaseContour::SetModel(manualContourModel *manContModel){
2995 _manContModel=manContModel;
2997 // ----------------------------------------------------------------------------
2998 void manualViewBaseContour::SetWxVtkBaseView(wxVtkBaseView *wxvtkbaseview){
2999 _wxvtkbaseview = wxvtkbaseview;
3001 // ----------------------------------------------------------------------------
3002 void manualViewBaseContour::RefreshContour() // Virtual
3005 // ----------------------------------------------------------------------------
3006 double* manualViewBaseContour::GetVectorPointsXManualContour(){
3008 int i,size = _sizePointsContour;
3009 double *vx = (double*)malloc(sizeof(double)*size);
3010 for (i=0;i<size;i++){
3011 _pts->GetPoint(i,pp);
3016 // ----------------------------------------------------------------------------
3017 double* manualViewBaseContour::GetVectorPointsYManualContour()
3020 int i,size = _sizePointsContour;
3021 double *vy = (double*)malloc(sizeof(double)*size);
3022 for (i=0;i<size;i++){
3023 _pts->GetPoint(i,pp);
3028 // ----------------------------------------------------------------------------
3029 double* manualViewBaseContour::GetVectorPointsZManualContour()
3032 int i,size = _sizePointsContour;
3033 double *vz = (double*)malloc(sizeof(double)*size);
3034 for (i=0;i<size;i++){
3035 _pts->GetPoint(i,pp);
3040 // ----------------------------------------------------------------------------
3041 void manualViewBaseContour::Refresh() // virtual
3043 if (_contourVtkActor!=NULL){
3046 int i,size=_lstViewPoints.size();
3047 for (i=0;i<size;i++){
3049 _lstViewPoints[i]->UpdateColorActor();
3053 if (_show_text==true)
3058 vtkRenderWindowInteractor *vri = _wxvtkbaseview->GetWxVTKRenderWindowInteractor ();
3061 _wxvtkbaseview->GetRenWin()->Render();
3065 // ----------------------------------------------------------------------------
3066 void manualViewBaseContour::RefreshText() // virtual
3068 if( _textActor!=NULL)
3069 _textActor -> SetInput(" ");
3071 // ----------------------------------------------------------------------------
3072 void manualViewBaseContour::SetColorNormalContour(double r, double g, double b)
3074 _coulorNormal_r = r;
3075 _coulorNormal_g = g;
3076 _coulorNormal_b = b;
3078 // ----------------------------------------------------------------------------
3079 void manualViewBaseContour::GetColorNormalContour(double &r, double &g, double &b)
3081 r = _coulorNormal_r;
3082 g = _coulorNormal_g;
3083 b = _coulorNormal_b;
3085 // ----------------------------------------------------------------------------
3086 void manualViewBaseContour::SetColorEditContour(double r, double g, double b)
3092 // ----------------------------------------------------------------------------
3093 void manualViewBaseContour::GetColorEditContour(double &r, double &g, double &b)
3099 // ----------------------------------------------------------------------------
3100 void manualViewBaseContour::SetColorSelectContour(double r, double g, double b)
3102 _coulorSelection_r = r;
3103 _coulorSelection_g = g;
3104 _coulorSelection_b = b;
3106 // ----------------------------------------------------------------------------
3107 void manualViewBaseContour::GetColorSelectContour(double &r, double &g, double &b)
3109 r = _coulorSelection_r;
3110 g = _coulorSelection_g;
3111 b = _coulorSelection_b;
3113 // ----------------------------------------------------------------------------
3114 void manualViewBaseContour::UpdateColorActor()
3116 if (_contourVtkActor!=NULL)
3118 _contourVtkActor->GetProperty()->SetLineWidth( _widthline );
3119 _contourVtkActor->GetProperty()->SetDiffuseColor( _coulorNormal_r , _coulorNormal_g , _coulorNormal_b );
3120 if (_posibleSelected || (_posibleSelected && GetEditable() ) )
3122 _contourVtkActor->GetProperty()->SetDiffuseColor( _coulorEdit_r , _coulorEdit_g , _coulorEdit_b );
3126 _contourVtkActor->GetProperty()->SetDiffuseColor( _coulorSelection_r , _coulorSelection_g , _coulorSelection_b );
3130 // ----------------------------------------------------------------------------
3131 int manualViewBaseContour::GetIdPoint(int x, int y, int z) // virtual
3134 if (_manContModel!=NULL){
3138 TransfromeCoordViewWorld(xx,yy,zz);
3139 ii=_manContModel->GetIdPoint(xx,yy,zz,_range,-1);
3144 // ----------------------------------------------------------------------------
3147 int manualViewBaseContour::GetNumberOfPoints()
3149 return _lstViewPoints.size();
3152 // ----------------------------------------------------------------------------
3154 //JSTG 25-02-08 ---------------------------------------------------------------
3155 /*int manualViewBaseContour::GetNumberOfPointsSpline()
3157 return _sizePointsContour;
3159 //----------------------------------------------------------------------------
3161 //JSTG 25-02-08 ---------------------------------------------------------------
3162 /*void manualViewBaseContour::SetNumberOfPointsSpline(int size)
3164 _sizePointsContour = size;
3166 //----------------------------------------------------------------------------
3168 void manualViewBaseContour::TransfromeCoordViewWorld(double &X, double &Y, double &Z, int type) // Virtual
3170 _wxvtkbaseview->TransfromeCoordScreenToWorld(X, Y, Z, type);
3175 // wxVtk2DBaseView *wxvtk2Dbaseview = (wxVtk2DBaseView*)_wxvtkbaseview;
3176 // wxvtk2Dbaseview->TransformCoordinate_spacing_ModelToView(X,Y,Z);
3179 // ----------------------------------------------------------------------------
3180 void manualViewBaseContour::SetRange(int range)
3184 // ----------------------------------------------------------------------------
3185 int manualViewBaseContour::GetRange()
3189 // ----------------------------------------------------------------------------
3190 void manualViewBaseContour::SetZ(int z)
3194 // ----------------------------------------------------------------------------
3195 int manualViewBaseContour::GetZ()
3200 // ----------------------------------------------------------------------------
3201 void manualViewBaseContour::InitMove(int x, int y, int z) // virtual
3205 // ----------------------------------------------------------------------------
3206 void manualViewBaseContour::MoveContour(int x, int y, int z) // virtual
3209 // ----------------------------------------------------------------------------
3210 void manualViewBaseContour::MoveContour(int horizontalUnits, int verticalUnits )// virtual
3214 // ----------------------------------------------------------------------------
3215 void manualViewBaseContour::GetMinMax( double &minX,double &minY, double &minZ, double &maxX, double &maxY, double &maxZ )// virtual
3220 int size=_manContModel->GetSizeLstPoints();
3225 bool ifFindZ = minZ!=-1.0 && maxZ!=-1.0;
3231 for( i = 0; i < size; i++ )
3233 mp=_manContModel->GetManualPoint(i);
3285 // ----------------------------------------------------------------------------
3286 void manualViewBaseContour::ClearContour()
3288 if (_contourVtkActor!=NULL){
3289 _wxvtkbaseview->GetRenderer()->RemoveActor( _contourVtkActor );
3292 int i,size=_lstViewPoints.size();
3293 for (i=0;i<size;i++){
3298 // ----------------------------------------------------------------------------
3299 void manualViewBaseContour::ClearPoint(int id)
3303 // ----------------------------------------------------------------------------
3304 void manualViewBaseContour::SetVisible(bool ok)
3315 int i,size=_lstViewPoints.size();
3316 for (i=0;i<size;i++){
3317 actor = _lstViewPoints[i]->GetVtkActor();
3318 actor->GetProperty()->SetOpacity( opacity );
3320 _contourVtkActor->GetProperty()->SetOpacity( opacity );
3321 _textActor->GetProperty()->SetOpacity( opacity );
3322 _textActor->SetInput(" ");
3325 // ----------------------------------------------------------------------------
3326 void manualViewBaseContour::SetShowText(bool ok)
3329 if (_show_text==false)
3331 _textActor->SetInput(" ");
3334 // ----------------------------------------------------------------------------
3335 wxVtkBaseView *manualViewBaseContour::GetWxVtkBaseView()
3337 return this->_wxvtkbaseview;
3339 // ----------------------------------------------------------------------------
3340 void manualViewBaseContour::GetSpacing(double spc[3])
3346 // ----------------------------------------------------------------------------
3347 void manualViewBaseContour::SetSpacing(double spc[3])
3355 // ----------------------------------------------------------------------------
3356 // ----------------------------------------------------------------------------
3357 // ----------------------------------------------------------------------------
3359 // _type = 0 Sagital
3360 // _type = 1 Coronal
3362 // _type = -1 View 3D
3364 manualContour3VControler::manualContour3VControler(int type)
3369 // _manViewBaseCont1 = NULL;
3370 // _manViewBaseCont2 = NULL;
3371 // _manViewBaseCont3 = NULL;
3373 //----------------------------------------------------------------------------
3374 manualContour3VControler::~manualContour3VControler()
3378 // ----------------------------------------------------------------------------
3379 manualContour3VControler * manualContour3VControler :: Clone() // virtual
3381 manualContour3VControler * clone = new manualContour3VControler( this->GetType() );
3382 CopyAttributesTo(clone);
3386 // ---------------------------------------------------------------------------
3387 void manualContour3VControler::CopyAttributesTo( manualContour3VControler * cloneObject)
3390 manualContourControler::CopyAttributesTo(cloneObject);
3392 cloneObject->SetVtkMPRBaseData( this->GetVtkMPRBaseData() );
3394 // Remember to add ManualViewBaseContour with "AddManualViewBaseContour"
3397 // ----------------------------------------------------------------------------
3398 int manualContour3VControler::GetType()
3403 // ----------------------------------------------------------------------------
3404 void manualContour3VControler::AddPoint_Others()
3406 manualViewBaseContour *mvbc;
3407 int i,size=this->_lstManualViewBaseContour.size();
3408 for ( i = 0 ; i < size ; i++ )
3410 mvbc = _lstManualViewBaseContour[i];
3415 // if (_manViewBaseCont1!=NULL){
3416 // _manViewBaseCont1->AddPoint();
3417 // _manViewBaseCont2->AddPoint();
3418 // _manViewBaseCont3->AddPoint();
3419 // this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
3422 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
3424 // ----------------------------------------------------------------------------
3425 void manualContour3VControler::AddPoint( int x, int y, int z ) // virtual
3428 z=(int)_vtkmprbasedata->GetZ();
3429 if (GetManualContourModel()!=NULL){
3433 GetManualViewBaseContour()->TransfromeCoordViewWorld(xx,yy,zz,_type);
3437 xx=_vtkmprbasedata->GetX();
3442 yy=_vtkmprbasedata->GetY();
3446 /*int id = */ GetManualContourModel()->AddPoint(xx,yy,zz); // JPRx
3447 GetManualViewBaseContour()->AddPoint();
3453 // ----------------------------------------------------------------------------
3454 void manualContour3VControler::InsertPoint_Others(int id)
3457 manualViewBaseContour *mvbc;
3458 int i,size=this->_lstManualViewBaseContour.size();
3459 for ( i = 0 ; i < size ; i++ )
3461 mvbc = _lstManualViewBaseContour[i];
3462 mvbc->InsertPoint(id);
3466 if (_manViewBaseCont1!=NULL){
3467 _manViewBaseCont1->InsertPoint(id);
3468 _manViewBaseCont2->InsertPoint(id);
3469 _manViewBaseCont3->InsertPoint(id);
3470 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
3474 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
3477 // ----------------------------------------------------------------------------
3478 void manualContour3VControler::InsertPoint(int x, int y, int z)
3481 if (GetManualContourModel()!=NULL){
3482 if (GetManualContourModel()->GetSizeLstPoints()>1){
3483 z=(int)_vtkmprbasedata->GetZ();
3487 GetManualViewBaseContour()->TransfromeCoordViewWorld(xx,yy,zz,_type);
3490 xx=_vtkmprbasedata->GetX();
3495 yy=_vtkmprbasedata->GetY();
3498 id = GetManualContourModel()->InsertPoint(xx,yy,zz);
3500 GetManualViewBaseContour()->InsertPoint(id);
3501 InsertPoint_Others(0);
3508 // ----------------------------------------------------------------------------
3512 void manualContour3VControler::SetModelView ( manualContourModel *manContModel,
3513 manualViewBaseContour *manViewBaseCont0,
3514 manualViewBaseContour *manViewBaseCont1,
3515 manualViewBaseContour *manViewBaseCont2,
3516 manualViewBaseContour *manViewBaseCont3)
3518 manualContourControler::SetModelView(manContModel,manViewBaseCont0);
3519 _manViewBaseCont1 = manViewBaseCont1;
3520 _manViewBaseCont2 = manViewBaseCont2;
3521 _manViewBaseCont3 = manViewBaseCont3;
3525 // ----------------------------------------------------------------------------
3526 void manualContour3VControler::AddManualViewBaseContour( manualViewBaseContour *manViewBaseCont )
3528 _lstManualViewBaseContour.push_back( manViewBaseCont );
3531 // ----------------------------------------------------------------------------
3532 void manualContour3VControler::SetVtkMPRBaseData (vtkMPRBaseData *vtkmprbasedata )
3534 _vtkmprbasedata=vtkmprbasedata;
3536 // ----------------------------------------------------------------------------
3537 vtkMPRBaseData *manualContour3VControler::GetVtkMPRBaseData()
3539 return _vtkmprbasedata;
3541 // ----------------------------------------------------------------------------
3542 void manualContour3VControler::SetPoint( int id ,int x ,int y ,int z ) // virtual
3544 z=(int)_vtkmprbasedata->GetZ();
3545 if ((GetManualViewBaseContour()!=NULL) && (id>=0)){
3549 GetManualViewBaseContour()->TransfromeCoordViewWorld(xx,yy,zz,_type);
3553 xx=_vtkmprbasedata->GetX();
3557 yy=_vtkmprbasedata->GetY();
3560 manualPoint *mp = GetManualContourModel()->GetManualPoint(id);
3561 mp->SetPoint(xx,yy,zz);
3565 // ----------------------------------------------------------------------------
3566 void manualContour3VControler::DeleteActualMousePoint_Others(int id)
3568 manualViewBaseContour *mvbc;
3569 int i,size=this->_lstManualViewBaseContour.size();
3570 for ( i = 0 ; i < size ; i++ )
3572 mvbc = _lstManualViewBaseContour[i];
3573 mvbc->DeletePoint(id);
3578 if (_manViewBaseCont1!=NULL){
3579 _manViewBaseCont1->DeletePoint(id);
3580 _manViewBaseCont2->DeletePoint(id);
3581 _manViewBaseCont3->DeletePoint(id);
3583 _manViewBaseCont1->Refresh();
3584 _manViewBaseCont2->Refresh();
3585 _manViewBaseCont3->Refresh();
3587 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
3590 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
3592 // ----------------------------------------------------------------------------
3593 void manualContour3VControler::DeleteActualMousePoint(int x, int y)// virtual
3595 int id=GetManualViewBaseContour()->GetIdPoint ( x , y , GetZ() );
3597 manualContourBaseControler::DeleteActualMousePoint( x , y );
3598 DeleteActualMousePoint_Others( id );
3601 // ----------------------------------------------------------------------------
3602 void manualContour3VControler::MouseMove_Others(int id) // virtual
3604 manualViewBaseContour *mvbc;
3605 int i,size=this->_lstManualViewBaseContour.size();
3606 for ( i = 0 ; i < size ; i++ )
3608 mvbc = _lstManualViewBaseContour[i];
3609 mvbc->SelectAllPossibleSelected(false);
3612 mvbc->SetPointPosibleSelected(id,true);
3614 mvbc->SetPosibleSelected ( GetManualViewBaseContour()->GetPosibleSelected() );
3620 if (_manViewBaseCont1!=NULL){
3621 _manViewBaseCont1->SelectAllPossibleSelected(false);
3622 _manViewBaseCont2->SelectAllPossibleSelected(false);
3623 _manViewBaseCont3->SelectAllPossibleSelected(false);
3625 _manViewBaseCont1->SetPointPosibleSelected(id,true);
3626 _manViewBaseCont2->SetPointPosibleSelected(id,true);
3627 _manViewBaseCont3->SetPointPosibleSelected(id,true);
3629 _manViewBaseCont1->SetPosibleSelected ( GetManualViewBaseContour()->GetPosibleSelected() );
3630 _manViewBaseCont2->SetPosibleSelected ( GetManualViewBaseContour()->GetPosibleSelected() );
3631 _manViewBaseCont3->SetPosibleSelected ( GetManualViewBaseContour()->GetPosibleSelected() );
3633 _manViewBaseCont1->Refresh();
3634 _manViewBaseCont2->Refresh();
3635 _manViewBaseCont3->Refresh();
3637 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
3640 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
3644 // ----------------------------------------------------------------------------
3645 void manualContour3VControler::MouseMove(int x, int y) // virtual
3647 manualContourControler::MouseMove( x , y );
3648 int id=GetManualViewBaseContour()->GetIdPoint(x,y,GetZ());
3649 MouseMove_Others( id );
3652 // ----------------------------------------------------------------------------
3653 void manualContour3VControler::OnChar_Others()
3655 manualViewBaseContour *mvbc;
3656 int i,size=this->_lstManualViewBaseContour.size();
3657 for ( i = 0 ; i < size ; i++ )
3659 mvbc = _lstManualViewBaseContour[i];
3664 _manViewBaseCont1->Refresh();
3665 _manViewBaseCont2->Refresh();
3666 _manViewBaseCont3->Refresh();
3668 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
3670 // ----------------------------------------------------------------------------
3671 bool manualContour3VControler::OnChar()
3673 manualContourControler::OnChar();
3677 // ----------------------------------------------------------------------------
3678 void manualContour3VControler::ResetContour() // virtual
3680 manualContourControler::ResetContour();
3681 ResetContour_Others();
3684 // ----------------------------------------------------------------------------
3685 void manualContour3VControler::ResetContour_Others()
3687 manualViewBaseContour *mvbc;
3688 int i,size=this->_lstManualViewBaseContour.size();
3689 for ( i = 0 ; i < size ; i++ )
3691 mvbc = _lstManualViewBaseContour[i];
3692 mvbc->DeleteContour();
3693 mvbc->CreateNewContour();
3698 _manViewBaseCont1->DeleteContour();
3699 _manViewBaseCont2->DeleteContour();
3700 _manViewBaseCont3->DeleteContour();
3701 _manViewBaseCont1->CreateNewContour();
3702 _manViewBaseCont2->CreateNewContour();
3703 _manViewBaseCont3->CreateNewContour();
3707 // ----------------------------------------------------------------------------
3708 // ----------------------------------------------------------------------------
3709 // ----------------------------------------------------------------------------
3710 manualContour3DControler::manualContour3DControler()
3713 // ----------------------------------------------------------------------------
3714 manualContour3DControler::~manualContour3DControler()
3717 // ----------------------------------------------------------------------------
3718 manualContour3DControler * manualContour3DControler :: Clone() // virtual
3720 manualContour3DControler * clone = new manualContour3DControler();
3721 CopyAttributesTo(clone);
3725 // ---------------------------------------------------------------------------
3726 void manualContour3DControler::CopyAttributesTo( manualContour3DControler * cloneObject)
3729 manualContourControler::CopyAttributesTo(cloneObject);
3731 cloneObject->SetVtkMPRBaseData( this->GetVtkMPRBaseData() );
3734 // ----------------------------------------------------------------------------
3735 bool manualContour3DControler::OnLeftButtonDown()
3738 wxVTKRenderWindowInteractor *wxVTKiren;
3739 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk3DBaseView()->GetWxVTKRenderWindowInteractor();
3740 wxVTKiren->GetEventPosition(X,Y);
3741 MouseClickLeft(X,Y);
3744 // ----------------------------------------------------------------------------
3745 void manualContour3DControler::ResetOrientationPlane()
3747 double p[3],rp[3],rn[3];
3748 p[0] = this->GetVtkMPRBaseData()->GetX( );
3749 p[1] = this->GetVtkMPRBaseData()->GetY( );
3750 p[2] = this->GetVtkMPRBaseData()->GetZ( );
3751 this->GetManualContourModel()->GetNearestPointAndNormal(p,rp,rn);
3752 this->GetVtkMPRBaseData()->SetNormal(rn[0],rn[1],rn[2]);
3754 // ----------------------------------------------------------------------------
3755 void manualContour3DControler::MouseClickLeft(int x, int y) // virtual
3757 manualView3DContour *manualview3Dcontour=(manualView3DContour*)GetManualViewBaseContour();
3758 int id=manualview3Dcontour->GetIdPoint2(x,y);
3759 if ( (GetState()==0) && (id!=-1) )
3761 manualPoint *mp = this->GetManualContourModel()->GetManualPoint(id);
3763 this->GetVtkMPRBaseData()->SetX( mp->GetX() );
3764 this->GetVtkMPRBaseData()->SetY( mp->GetY() );
3765 this->GetVtkMPRBaseData()->SetZ( mp->GetZ() );
3766 ResetOrientationPlane();
3767 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
3771 manualContourControler::MouseClickLeft(x,y);
3774 // ----------------------------------------------------------------------------
3775 bool manualContour3DControler::OnChar()
3778 manualContourControler::OnChar();
3779 char keyCode = _vtkInteractorStyleBaseView->GetInteractor()-> GetKeyCode();
3782 ResetOrientationPlane();
3783 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
3788 // ----------------------------------------------------------------------------
3789 void manualContour3DControler::SetVtkMPRBaseData (vtkMPRBaseData *vtkmprbasedata )
3791 _vtkmprbasedata=vtkmprbasedata;
3793 // ----------------------------------------------------------------------------
3794 vtkMPRBaseData *manualContour3DControler::GetVtkMPRBaseData()
3796 return _vtkmprbasedata;
3799 // ----------------------------------------------------------------------------
3800 void manualContour3DControler::InsertPoint(int x, int y, int z ) // virtual
3802 manualContourControler::InsertPoint( x, y, z );
3803 ResetOrientationPlane();
3808 // ----------------------------------------------------------------------------
3809 // ----------------------------------------------------------------------------
3810 // ----------------------------------------------------------------------------
3812 manualContour3V3DControler::manualContour3V3DControler()
3815 // ----------------------------------------------------------------------------
3816 manualContour3V3DControler::~manualContour3V3DControler()
3820 // ----------------------------------------------------------------------------
3821 manualContour3V3DControler * manualContour3V3DControler :: Clone() // virtual
3823 manualContour3V3DControler * clone = new manualContour3V3DControler();
3824 CopyAttributesTo(clone);
3828 // ---------------------------------------------------------------------------
3829 void manualContour3V3DControler::CopyAttributesTo( manualContour3V3DControler * cloneObject)
3832 manualContour3DControler::CopyAttributesTo(cloneObject);
3834 cloneObject->SetManualContour3VControler( this->GetManualContour3VControler() );
3836 // ----------------------------------------------------------------------------
3837 void manualContour3V3DControler::InsertPoint(int x, int y, int z ) // virtual
3839 manualContour3DControler::InsertPoint( x, y, z );
3840 _manualcontour3Vcontroler->InsertPoint_Others(0);
3842 // ----------------------------------------------------------------------------
3843 void manualContour3V3DControler::AddPoint( int x, int y, int z )
3845 manualContour3DControler::AddPoint( x, y, z );
3846 _manualcontour3Vcontroler->AddPoint_Others();
3848 // ----------------------------------------------------------------------------
3849 void manualContour3V3DControler::DeleteActualMousePoint(int x, int y)
3851 int id = GetManualViewBaseContour()->GetIdPoint ( x , y , GetZ() );
3852 manualContour3DControler::DeleteActualMousePoint( x , y );
3853 _manualcontour3Vcontroler->DeleteActualMousePoint_Others(id);
3855 // ----------------------------------------------------------------------------
3856 void manualContour3V3DControler::MouseMove( int x, int y )
3858 int ss =this->_vtkInteractorStyleBaseView->vtkInteractorStyle::GetState();
3859 if ((this->GetState()!=7) && (ss!=1)){
3860 manualContour3DControler::MouseMove( x , y );
3861 int id = GetManualViewBaseContour()->GetIdPoint ( x , y , GetZ() );
3862 _manualcontour3Vcontroler->MouseMove_Others(id);
3865 // ----------------------------------------------------------------------------
3866 void manualContour3V3DControler::SetManualContour3VControler(manualContour3VControler *manualcontour3Vcontroler)
3868 _manualcontour3Vcontroler = manualcontour3Vcontroler;
3870 // ----------------------------------------------------------------------------
3871 manualContour3VControler *manualContour3V3DControler::GetManualContour3VControler()
3873 return _manualcontour3Vcontroler;
3875 // ----------------------------------------------------------------------------
3876 bool manualContour3V3DControler::OnChar() // virtual
3878 if (manualContour3DControler::OnChar()==false )
3880 _manualcontour3Vcontroler->OnChar_Others();
3885 // ----------------------------------------------------------------------------
3886 void manualContour3V3DControler::ResetContour() // virtual
3888 manualContourControler::ResetContour();
3889 _manualcontour3Vcontroler->ResetContour_Others();
3893 // ----------------------------------------------------------------------------
3894 // ----------------------------------------------------------------------------
3895 // ----------------------------------------------------------------------------
3897 // _state = 0 // ..nothing..
3898 // _state = 1 // move with add point
3899 // _state = 5 // move
3900 // _state = 6 // move with insert point
3901 // _state = 7 // move with non selection
3903 manualContourControler::manualContourControler()
3905 _easyCreation = true;
3908 // ----------------------------------------------------------------------------
3909 manualContourControler::~manualContourControler()
3912 // ----------------------------------------------------------------------------
3913 manualContourControler * manualContourControler :: Clone() // virtual
3915 manualContourControler * clone = new manualContourControler();
3916 CopyAttributesTo(clone);
3919 // ---------------------------------------------------------------------------
3920 void manualContourControler::CopyAttributesTo( manualContourControler * cloneObject)
3923 manualContourBaseControler::CopyAttributesTo(cloneObject);
3924 cloneObject->SetEasyCreation( this->GetEasyCreation() );
3927 // ----------------------------------------------------------------------------
3928 void manualContourControler::Configure() //virtual
3930 // this->_manContModel->SetNumberOfPointsSpline(100);
3933 // ----------------------------------------------------------------------------
3934 void manualContourControler::MouseClickLeft(int x, int y){
3939 int size= GetManualViewBaseContour()->GetNumberOfPoints();
3941 // Insert a Control Point with shift+ClickLeft
3942 // int tt = GetState(); // JPRx
3943 vtkRenderWindowInteractor *vtkrenderwindowinteractor = _vtkInteractorStyleBaseView->GetInteractor();
3947 if ( (_vtkInteractorStyleBaseView!=NULL) && (GetState()==0) && ( (vtkrenderwindowinteractor!=NULL) && (vtkrenderwindowinteractor->GetShiftKey()==1) ) )
3953 // Start to Insert Control Points with ClickLeft (Empty contour)
3954 if ((GetState()==0) && (size==0) && (_easyCreation==true) )
3960 // Continuie to Insert Control Points with ClickLeft (After being empty the contour)
3961 if ((GetState()==1) && (_easyCreation==true) )
3965 _bakIdPoint=GetNumberOfPointsManualContour() - 1;
3967 // Insert Control Points IF Contour si Selected
3968 if ((GetState()==0) && GetManualViewBaseContour()->GetPosibleSelected() )
3972 _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
3975 // Chose id of Control Point to be move
3976 if ( (GetState()==0 || GetState()==6) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)!=-1 ) )
3979 _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
3982 // If nothing selected _state=7
3983 if ( (GetState()==0) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)==-1 ) )
3986 _bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
3992 SetPosibleToMove( true );
3993 GetManualViewBaseContour()->SetSelected( GetManualViewBaseContour()->GetPosibleSelected() );
3995 if ( GetState() == 0 && GetManualViewBaseContour()->GetPosibleSelected() )
3999 GetManualViewBaseContour()->InitMove(x,y,z);
4004 GetManualViewBaseContour()->Refresh();
4007 // ----------------------------------------------------------------------------
4008 void manualContourControler::MouseMove(int x, int y) // virtual
4011 GetManualViewBaseContour()->SelectPosiblePoint(x,y,z);
4012 GetManualViewBaseContour()->SelectPosibleContour(x,y,z);
4013 if (GetState()==1){ SetPoint( _bakIdPoint , x , y ,z); }
4014 if (GetState()==5){ SetPoint( _bakIdPoint , x , y ,z); }
4015 if ( GetState()==6 && !IsEditable() && GetPosibleToMove() &&IsMoving() )
4017 GetManualViewBaseContour()->MoveContour(x,y,z);
4019 if (GetState()!=7 || GetManualViewBaseContour()->GetPosibleSelected() ){
4020 GetManualViewBaseContour()->Refresh();
4021 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
4025 GetManualViewBaseContour()->RemoveControlPoints();
4026 GetManualViewBaseContour()->RemoveTextActor();
4027 GetManualViewBaseContour()->Refresh();
4028 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
4033 // ----------------------------------------------------------------------------
4034 void manualContourControler::MouseDLeft( int x, int y)//virtual
4036 manualContourBaseControler::MouseDLeft( x, y);
4039 GetManualViewBaseContour()->AddControlPoints();
4040 GetManualViewBaseContour()->AddTextActor();
4041 GetManualViewBaseContour()->Refresh();
4042 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
4045 // ----------------------------------------------------------------------------
4046 void manualContourControler::SetEasyCreation(bool easyCreation)
4048 _easyCreation=easyCreation;
4050 // ----------------------------------------------------------------------------
4051 bool manualContourControler::GetEasyCreation()
4053 return _easyCreation;
4057 // ----------------------------------------------------------------------------
4058 // ----------------------------------------------------------------------------
4059 // ----------------------------------------------------------------------------
4060 manualContourPerpPlaneControler::manualContourPerpPlaneControler()
4062 _flagMouseMove = true;
4064 // ----------------------------------------------------------------------------
4065 manualContourPerpPlaneControler::~manualContourPerpPlaneControler()
4068 // ----------------------------------------------------------------------------
4069 manualContourPerpPlaneControler * manualContourPerpPlaneControler :: Clone() // virtual
4071 manualContourPerpPlaneControler * clone = new manualContourPerpPlaneControler();
4072 CopyAttributesTo(clone);
4076 // ---------------------------------------------------------------------------
4077 void manualContourPerpPlaneControler::CopyAttributesTo( manualContourPerpPlaneControler * cloneObject)
4080 manualContourControler::CopyAttributesTo(cloneObject);
4082 cloneObject->SetVtkMPRBaseData( this->GetVtkMPRBaseData() );
4083 cloneObject->SetManualContour3VControler( this->GetManualContour3VControler() );
4084 cloneObject->SetVtkInteractorStylePlane2D( this->GetVtkInteractorStylePlane2D() );
4087 // ----------------------------------------------------------------------------
4088 void manualContourPerpPlaneControler::SetVtkMPRBaseData(vtkMPRBaseData *vtkmprbasedata)
4090 _vtkmprbasedata = vtkmprbasedata;
4093 // ----------------------------------------------------------------------------
4094 vtkMPRBaseData *manualContourPerpPlaneControler::GetVtkMPRBaseData()
4096 return _vtkmprbasedata;
4100 // ----------------------------------------------------------------------------
4101 void manualContourPerpPlaneControler::InsertPoint(int x, int y, int z ) // virtual
4103 manualContourControler::InsertPoint( x, y, z );
4104 _manualcontour3Vcontroler->InsertPoint_Others(0);
4106 // ----------------------------------------------------------------------------
4107 void manualContourPerpPlaneControler::AddPoint( int x, int y, int z )
4109 manualContourControler::AddPoint( x, y, z );
4110 _manualcontour3Vcontroler->AddPoint_Others();
4112 // ----------------------------------------------------------------------------
4113 void manualContourPerpPlaneControler::DeleteActualMousePoint(int x, int y)
4115 int id = GetManualViewBaseContour()->GetIdPoint ( x , y , GetZ() );
4116 manualContourControler::DeleteActualMousePoint( x , y );
4117 _manualcontour3Vcontroler->DeleteActualMousePoint_Others(id);
4119 // ----------------------------------------------------------------------------
4120 void manualContourPerpPlaneControler::MouseMove( int x, int y )
4122 _flagMouseMove = true;
4123 int ss =this->_vtkInteractorStyleBaseView->vtkInteractorStyle::GetState();
4124 if ((this->GetState()!=7) && (ss!=1)){
4125 manualContourControler::MouseMove( x , y );
4126 int id = GetManualViewBaseContour()->GetIdPoint ( x , y , GetZ() );
4129 _manualcontour3Vcontroler->MouseMove_Others(id);
4130 _flagMouseMove = false;
4134 // ----------------------------------------------------------------------------
4135 void manualContourPerpPlaneControler::SetManualContour3VControler(manualContour3VControler *manualcontour3Vcontroler)
4137 _manualcontour3Vcontroler = manualcontour3Vcontroler;
4139 // ----------------------------------------------------------------------------
4140 manualContour3VControler * manualContourPerpPlaneControler::GetManualContour3VControler()
4142 return _manualcontour3Vcontroler;
4144 // ----------------------------------------------------------------------------
4145 bool manualContourPerpPlaneControler::OnChar() // virtual
4147 if (manualContourControler::OnChar()==false )
4149 _manualcontour3Vcontroler->OnChar_Others();
4153 // ----------------------------------------------------------------------------
4154 bool manualContourPerpPlaneControler::OnMouseMove() // virtual
4156 manualContourControler::OnMouseMove();
4157 return _flagMouseMove;
4159 // ----------------------------------------------------------------------------
4160 bool manualContourPerpPlaneControler::OnLeftDClick() // virtual
4162 manualContourControler::OnLeftDClick();
4163 return _flagMouseDClick;
4165 // ----------------------------------------------------------------------------
4166 void manualContourPerpPlaneControler::ResetContour() // virtual
4168 manualContourControler::ResetContour();
4169 _manualcontour3Vcontroler->ResetContour_Others();
4172 // ----------------------------------------------------------------------------
4173 void manualContourPerpPlaneControler::MouseDLeft( int x, int y) // virtual
4175 _flagMouseDClick=true;
4176 manualContourControler::MouseDLeft(x,y);
4178 if (GetManualViewBaseContour()->ifTouchContour(x,y,0)==true)
4180 _flagMouseDClick = false;
4181 _vtkinteractorstyleplane2D->OnLeftDClick();
4182 ResetOrientationPlane();
4183 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
4186 // int id=GetManualViewBaseContour()->GetIdPoint(x,y,GetZ());
4187 // if ( (GetState()==0) && (id!=-1) )
4189 // manualPoint *mp = this->GetManualContourModel()->GetManualPoint(id);
4190 // _vtkmprbasedata->SetX( mp->GetX() );
4191 // _vtkmprbasedata->SetY( mp->GetY() );
4192 // _vtkmprbasedata->SetZ( mp->GetZ() );
4193 // ResetOrientationPlane();
4194 // this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
4200 // ----------------------------------------------------------------------------
4201 void manualContourPerpPlaneControler::ResetOrientationPlane()
4203 double p[3],rp[3],rn[3];
4204 p[0] = _vtkmprbasedata->GetX( );
4205 p[1] = _vtkmprbasedata->GetY( );
4206 p[2] = _vtkmprbasedata->GetZ( );
4207 this->GetManualContourModel()->GetNearestPointAndNormal(p,rp,rn);
4209 _vtkmprbasedata->SetNormal(rn[0],rn[1],rn[2]);
4212 // ----------------------------------------------------------------------------
4213 void manualContourPerpPlaneControler::SetVtkInteractorStylePlane2D(InteractorStyleMaracas *vtkinteractorstyleplane2D)
4215 _vtkinteractorstyleplane2D = vtkinteractorstyleplane2D;
4217 // ----------------------------------------------------------------------------
4218 InteractorStyleMaracas * manualContourPerpPlaneControler::GetVtkInteractorStylePlane2D()
4220 return _vtkinteractorstyleplane2D;
4223 // ----------------------------------------------------------------------------
4224 // ----------------------------------------------------------------------------
4225 // ----------------------------------------------------------------------------
4227 // _state = 0 // ..nothing..
4228 // _state = 5 // move point
4229 // _state = 6 // move all
4230 // _state = 7 // Empty mouse drag
4232 manualRoiControler::manualRoiControler()
4235 // ----------------------------------------------------------------------------
4236 manualRoiControler::~manualRoiControler()
4239 // ----------------------------------------------------------------------------
4240 manualRoiControler * manualRoiControler :: Clone() // virtual
4242 manualRoiControler * clone = new manualRoiControler();
4243 CopyAttributesTo(clone);
4247 // ---------------------------------------------------------------------------
4248 void manualRoiControler::CopyAttributesTo( manualRoiControler * cloneObject)
4251 manualContourBaseControler::CopyAttributesTo(cloneObject);
4254 // ----------------------------------------------------------------------------
4255 void manualRoiControler::Configure() //virtual
4257 this->GetManualContourModel()->SetNumberOfPointsSpline(5);
4260 // ----------------------------------------------------------------------------
4261 void manualRoiControler::MouseClickLeft(int x, int y){
4263 if ( (GetState()==0) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)!=-1 ) ){
4264 bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
4267 if ((GetState()==0) && (GetManualViewBaseContour()->GetPosibleSelected()==true)) {
4268 GetManualViewBaseContour()->InitMove(x,y,z);
4271 int size=GetManualViewBaseContour()->GetNumberOfPoints();
4272 if (GetState()==0) {
4284 bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
4287 GetManualViewBaseContour()->Refresh();
4289 // ----------------------------------------------------------------------------
4290 void manualRoiControler::MouseMove(int x, int y) // virtual
4294 // this->_vtkInteractorStyleBaseView->
4296 GetManualViewBaseContour()->SelectPosibleContour(x,y,z);
4297 GetManualViewBaseContour()->SelectPosiblePoint(x,y,z);
4300 SetPoint( bakIdPoint , x , y ,z);
4323 GetManualViewBaseContour()->MoveContour(x,y,z);
4325 GetManualViewBaseContour()->Refresh();
4327 // ----------------------------------------------------------------------------
4328 void manualRoiControler::DeleteActualMousePoint(int x, int y) // virtual
4331 // ----------------------------------------------------------------------------
4332 void manualRoiControler::InitRoi(int ww, int hh, double porcentage)
4337 if (GetManualContourModel()->GetSizeLstPoints() ==0)
4346 double pp1=porcentage;
4347 double pp2=1-porcentage;
4349 mp = GetManualContourModel()->GetManualPoint(2);
4351 mp->SetPoint(ww*pp1,hh*pp1,zz);
4353 mp = GetManualContourModel()->GetManualPoint(1);
4355 mp->SetPoint(ww*pp2,hh*pp1,zz);
4357 mp = GetManualContourModel()->GetManualPoint(0);
4359 mp->SetPoint(ww*pp2,hh*pp2,zz);
4361 mp = GetManualContourModel()->GetManualPoint(3);
4363 mp->SetPoint(ww*pp1,hh*pp2,zz);
4365 GetManualViewBaseContour() ->UpdateViewPoint(0);
4366 GetManualViewBaseContour() ->UpdateViewPoint(1);
4367 GetManualViewBaseContour() ->UpdateViewPoint(2);
4368 GetManualViewBaseContour() ->UpdateViewPoint(3);
4371 GetManualViewBaseContour()->Refresh();
4374 // ----------------------------------------------------------------------------
4375 void manualRoiControler::SetRoi(int x1, int y1,int x2, int y2)
4378 InitRoi( 0 , 0 , 0.2 );
4379 mp = GetManualContourModel()->GetManualPoint(2);
4383 mp = GetManualContourModel()->GetManualPoint(1);
4387 mp = GetManualContourModel()->GetManualPoint(0);
4391 mp = GetManualContourModel()->GetManualPoint(3);
4395 GetManualViewBaseContour() ->UpdateViewPoint(0);
4396 GetManualViewBaseContour() ->UpdateViewPoint(1);
4397 GetManualViewBaseContour() ->UpdateViewPoint(2);
4398 GetManualViewBaseContour() ->UpdateViewPoint(3);
4402 // ----------------------------------------------------------------------------
4403 // ----------------------------------------------------------------------------
4404 // ----------------------------------------------------------------------------
4408 // _state = 0 // ..nothing..
4409 // _state = 5 // move point
4410 // _state = 6 // move all
4411 // _state = 7 // Empty mouse drag
4413 manualCircleControler::manualCircleControler()
4416 // ----------------------------------------------------------------------------
4417 manualCircleControler::~manualCircleControler()
4420 // ----------------------------------------------------------------------------
4421 manualCircleControler * manualCircleControler :: Clone() // virtual
4423 manualCircleControler * clone = new manualCircleControler();
4424 CopyAttributesTo(clone);
4428 // ---------------------------------------------------------------------------
4429 void manualCircleControler::CopyAttributesTo( manualCircleControler * cloneObject)
4432 manualContourBaseControler::CopyAttributesTo(cloneObject);
4435 // ----------------------------------------------------------------------------
4436 void manualCircleControler::Configure() //virtual
4438 // this->GetManualContourModel()->SetNumberOfPointsSpline(5);
4441 // ----------------------------------------------------------------------------
4442 void manualCircleControler::MouseClickLeft(int x, int y){
4444 if ( (GetState()==0) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)!=-1 ) ){
4445 bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
4448 if ((GetState()==0) && (GetManualViewBaseContour()->GetPosibleSelected()==true)) {
4449 GetManualViewBaseContour()->InitMove(x,y,z);
4452 int size=GetManualViewBaseContour()->GetNumberOfPoints();
4453 if (GetState()==0) {
4462 // SetPoint(2,x,y,z);
4463 // SetPoint(3,x,y,z);
4465 bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
4468 GetManualViewBaseContour()->Refresh();
4470 // ----------------------------------------------------------------------------
4472 void manualCircleControler::MouseMove(int x, int y) // virtual
4476 // this->_vtkInteractorStyleBaseView->
4478 GetManualViewBaseContour()->SelectPosibleContour(x,y,z);
4479 GetManualViewBaseContour()->SelectPosiblePoint(x,y,z);
4482 SetPoint( bakIdPoint , x , y ,z);
4508 GetManualViewBaseContour()->MoveContour(x,y,z);
4510 GetManualViewBaseContour()->Refresh();
4514 // ----------------------------------------------------------------------------
4515 void manualCircleControler::DeleteActualMousePoint(int x, int y) // virtual
4518 // ----------------------------------------------------------------------------
4520 void manualCircleControler::InitRoi(int ww, int hh, double porcentage)
4525 if (GetManualContourModel()->GetSizeLstPoints() ==0)
4530 // AddPoint(0,0,zz);
4531 // AddPoint(0,0,zz);
4534 double pp1=porcentage;
4535 double pp2=1-porcentage;
4537 // mp = GetManualContourModel()->GetManualPoint(2);
4538 // zz=(int)mp->GetZ();
4539 // mp->SetPoint(ww*pp1,hh*pp1,zz);
4541 mp = GetManualContourModel()->GetManualPoint(1);
4543 mp->SetPoint(ww*pp2,hh*pp1,zz);
4545 mp = GetManualContourModel()->GetManualPoint(0);
4547 mp->SetPoint(ww*pp2,hh*pp2,zz);
4549 // mp = GetManualContourModel()->GetManualPoint(3);
4550 // zz=(int)mp->GetZ();
4551 // mp->SetPoint(ww*pp1,hh*pp2,zz);
4553 GetManualViewBaseContour() ->UpdateViewPoint(0);
4554 GetManualViewBaseContour() ->UpdateViewPoint(1);
4555 // GetManualViewBaseContour() ->UpdateViewPoint(2);
4556 // GetManualViewBaseContour() ->UpdateViewPoint(3);
4559 GetManualViewBaseContour()->Refresh();
4562 // ----------------------------------------------------------------------------
4564 void manualCircleControler::SetRoi(int x1, int y1,int x2, int y2)
4567 InitRoi( 0 , 0 , 0.2 );
4568 mp = GetManualContourModel()->GetManualPoint(2);
4572 mp = GetManualContourModel()->GetManualPoint(1);
4576 mp = GetManualContourModel()->GetManualPoint(0);
4580 mp = GetManualContourModel()->GetManualPoint(3);
4584 GetManualViewBaseContour() ->UpdateViewPoint(0);
4585 GetManualViewBaseContour() ->UpdateViewPoint(1);
4586 GetManualViewBaseContour() ->UpdateViewPoint(2);
4587 GetManualViewBaseContour() ->UpdateViewPoint(3);
4593 // ----------------------------------------------------------------------------
4594 // ----------------------------------------------------------------------------
4595 // ----------------------------------------------------------------------------
4598 manualContourBaseControler::manualContourBaseControler()
4600 _manViewBaseCont = NULL;
4601 _manContModel = NULL;
4605 _posibleToMove = true;
4608 _keyBoardMoving = false;
4610 // ----------------------------------------------------------------------------
4611 manualContourBaseControler::~manualContourBaseControler()
4615 // ----------------------------------------------------------------------------
4616 manualContourBaseControler * manualContourBaseControler :: Clone() // virtual
4618 manualContourBaseControler * clone = new manualContourBaseControler();
4619 CopyAttributesTo(clone);
4623 // ---------------------------------------------------------------------------
4625 void manualContourBaseControler::CopyAttributesTo( manualContourBaseControler * cloneObject)
4628 InteractorStyleMaracas::CopyAttributesTo(cloneObject);
4629 cloneObject->SetZ( this->GetZ() );
4630 cloneObject->SetState( this->GetState() );
4631 cloneObject->SetEditable( this->IsEditable() );
4632 cloneObject->SetPosibleToMove( this->GetPosibleToMove() );
4633 cloneObject->SetMoving( this->IsMoving() );
4634 cloneObject->SetCompleteCreation( this->GetIfCompleteCreation() );
4635 cloneObject->SetKeyBoardMoving( this->GetKeyBoardMoving() );
4638 // ----------------------------------------------------------------------------
4639 void manualContourBaseControler::Configure() //virtual
4643 // ----------------------------------------------------------------------------
4644 bool manualContourBaseControler::OnChar()
4646 if ( _vtkInteractorStyleBaseView!=NULL )
4648 char keyCode = _vtkInteractorStyleBaseView->GetInteractor()-> GetKeyCode();
4651 wxVTKRenderWindowInteractor *_wxVTKiren;
4652 _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
4653 _wxVTKiren->GetEventPosition(X, Y);
4654 //int Z = GetZ(); // JPRx
4656 if ((keyCode==8) || (keyCode==127))
4659 if (!GetManualViewBaseContour()->GetPosibleSelected()==true)
4661 DeleteActualMousePoint(X,Y);
4663 GetManualViewBaseContour()->Refresh();
4664 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
4672 GetManualViewBaseContour()->Refresh();
4673 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
4675 else if( !IsEditable() )
4677 if ( keyCode == 'L' )
4679 GetManualViewBaseContour()->MoveContour( -1, 0 );
4680 SetKeyBoardMoving( true );
4682 else if ( keyCode == 'R' )
4684 GetManualViewBaseContour()->MoveContour( 1, 0 );
4685 SetKeyBoardMoving( true );
4687 else if ( keyCode == 'U' )
4689 GetManualViewBaseContour()->MoveContour( 0, -1 );
4690 SetKeyBoardMoving( true );
4692 else if ( keyCode == 'D' )
4694 GetManualViewBaseContour()->MoveContour( 0, 1 );
4695 SetKeyBoardMoving( true );
4697 else if ( keyCode == 'W' )//Diagonal left down
4699 GetManualViewBaseContour()->MoveContour( -1, 1 );
4700 SetKeyBoardMoving( true );
4702 else if ( keyCode == 'Q' )//Diagonal left up
4704 GetManualViewBaseContour()->MoveContour( -1, -1 );
4705 SetKeyBoardMoving( true );
4707 else if( keyCode == 'P' )//Diagonal right up
4709 GetManualViewBaseContour()->MoveContour( 1, -1 );
4710 SetKeyBoardMoving( true );
4712 else if( keyCode == 'M' )//Diagonal right down
4714 GetManualViewBaseContour()->MoveContour( 1, 1 );
4715 SetKeyBoardMoving( true );
4717 if( GetKeyBoardMoving() )
4719 GetManualViewBaseContour()->Refresh();
4720 this->_vtkInteractorStyleBaseView->SetRefresh_waiting();
4727 // ----------------------------------------------------------------------------
4728 bool manualContourBaseControler::OnMouseMove()
4730 if ( _vtkInteractorStyleBaseView!=NULL)
4733 wxVTKRenderWindowInteractor *_wxVTKiren;
4734 _wxVTKiren= _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
4735 _wxVTKiren->GetEventPosition( X , Y );
4738 if ( (_vtkInteractorStyleBaseView->GetInteractor()->GetControlKey()==0) &&
4739 (_vtkInteractorStyleBaseView->GetInteractor()->GetShiftKey()==0) ) {
4745 // ----------------------------------------------------------------------------
4746 bool manualContourBaseControler::OnLeftButtonDown()
4748 SetKeyBoardMoving( false );
4749 if ( _vtkInteractorStyleBaseView!=NULL )
4752 wxVTKRenderWindowInteractor *wxVTKiren;
4753 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
4754 wxVTKiren->GetEventPosition(X,Y);
4756 MouseClickLeft(X,Y);
4760 // ----------------------------------------------------------------------------
4761 bool manualContourBaseControler::OnLeftButtonUp()
4763 if ( _vtkInteractorStyleBaseView!=NULL )
4766 wxVTKRenderWindowInteractor *wxVTKiren;
4767 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
4768 wxVTKiren->GetEventPosition(X,Y);
4769 MouseReleaseLeft(X,Y);
4773 // ----------------------------------------------------------------------------
4774 bool manualContourBaseControler::OnLeftDClick()
4776 if ( _vtkInteractorStyleBaseView!=NULL )
4779 wxVTKRenderWindowInteractor *wxVTKiren;
4780 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
4781 wxVTKiren->GetEventPosition(X,Y);
4783 this->MouseDLeft(X,Y);
4787 // ----------------------------------------------------------------------------
4788 bool manualContourBaseControler::OnMiddleButtonDown()
4790 // SetKeyBoardMoving( false );
4791 if ( _vtkInteractorStyleBaseView!=NULL )
4794 wxVTKRenderWindowInteractor *wxVTKiren;
4795 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
4796 wxVTKiren->GetEventPosition(X,Y);
4797 GetManualViewBaseContour()->InitMove( X, Y,GetZ());
4801 // ----------------------------------------------------------------------------
4802 bool manualContourBaseControler::OnMiddleButtonUp()
4806 // ----------------------------------------------------------------------------
4807 bool manualContourBaseControler::OnRightButtonDown()
4809 if( _vtkInteractorStyleBaseView!= NULL )
4812 wxVTKRenderWindowInteractor *wxVTKiren;
4813 wxVTKiren = _vtkInteractorStyleBaseView->GetWxVtk2DBaseView()->GetWxVTKRenderWindowInteractor();
4814 wxVTKiren->GetEventPosition(X, Y);
4816 SetCompleteCreation( true );
4817 SetKeyBoardMoving( false );
4818 MouseClickRight(X,Y);
4822 // ----------------------------------------------------------------------------
4823 bool manualContourBaseControler::OnRightButtonUp()
4827 // ----------------------------------------------------------------------------
4828 void manualContourBaseControler::SetModelView(manualContourModel *manContModel, manualViewBaseContour *manViewBaseCont){
4829 _manContModel = manContModel;
4830 _manViewBaseCont = manViewBaseCont;
4831 _manViewBaseCont->SetEditable( &_editable );
4833 // ----------------------------------------------------------------------------
4834 manualContourModel* manualContourBaseControler::GetManualContourModel()
4836 return _manContModel;
4838 // ----------------------------------------------------------------------------
4839 manualViewBaseContour* manualContourBaseControler::GetManualViewBaseContour()
4841 return _manViewBaseCont;
4843 // ----------------------------------------------------------------------------
4844 void manualContourBaseControler::MouseClickLeft(int x, int y) // virtual
4848 // ----------------------------------------------------------------------------
4849 void manualContourBaseControler::MouseClickRight(int x, int y)
4855 SetEditable( false );
4856 SetPosibleToMove( false );
4860 // ----------------------------------------------------------------------------
4861 void manualContourBaseControler::MouseReleaseLeft(int x, int y)
4863 if (_state==5){ _state = 0; }
4864 if (_state==6){ _state = 0; }
4865 if (_state==7){ _state = 0; }
4867 GetManualViewBaseContour()->SelectPosibleContour(x,y,GetZ());
4868 if( GetIfCompleteCreation() && IsEditable() && !GetManualViewBaseContour()->GetPosibleSelected() && (GetManualViewBaseContour()->GetIdPoint(x,y,GetZ())==-1) )
4870 SetEditable( false );
4871 SetPosibleToMove( false );
4874 // ----------------------------------------------------------------------------
4875 void manualContourBaseControler::MouseDLeft(int x, int y )
4880 GetManualViewBaseContour()->SelectPosibleContour(x,y,z);
4881 GetManualViewBaseContour()->SelectPosiblePoint(x,y,z);
4882 if ( GetManualViewBaseContour()->GetPosibleSelected() )
4888 // ----------------------------------------------------------------------------
4889 void manualContourBaseControler::MouseMove(int x, int y) // virtual
4892 // ----------------------------------------------------------------------------
4893 void manualContourBaseControler::SetState(int state)
4897 // ----------------------------------------------------------------------------
4898 int manualContourBaseControler::GetState()
4902 // ----------------------------------------------------------------------------
4903 bool manualContourBaseControler::IsEditable( )
4907 // ----------------------------------------------------------------------------
4908 void manualContourBaseControler::SetEditable( bool condition )
4910 if (GetManualViewBaseContour()!=NULL) {
4913 GetManualViewBaseContour()->RemoveControlPoints();
4915 GetManualViewBaseContour()->SetSelected( condition );
4917 _editable = condition;
4920 // ----------------------------------------------------------------------------
4921 bool manualContourBaseControler::GetPosibleToMove()
4923 return _posibleToMove;
4925 // ----------------------------------------------------------------------------
4926 void manualContourBaseControler::SetPosibleToMove( bool condition )
4928 _posibleToMove = condition;
4930 // ----------------------------------------------------------------------------
4931 bool manualContourBaseControler::IsMoving()
4935 // ----------------------------------------------------------------------------
4936 void manualContourBaseControler::SetMoving( bool condition )
4938 _moving = condition;
4940 // ----------------------------------------------------------------------------
4941 void manualContourBaseControler::SetCompleteCreation( bool condition )
4943 _created = condition;
4945 // ----------------------------------------------------------------------------
4946 bool manualContourBaseControler::GetIfCompleteCreation ( )
4950 // ----------------------------------------------------------------------------
4951 void manualContourBaseControler::SetKeyBoardMoving( bool condition )
4953 _keyBoardMoving = condition;
4955 // ----------------------------------------------------------------------------
4956 bool manualContourBaseControler::GetKeyBoardMoving( )
4958 return _keyBoardMoving;
4960 // ----------------------------------------------------------------------------
4961 void manualContourBaseControler::CreateNewManualContour(){
4962 _manViewBaseCont->CreateNewContour();
4964 // ----------------------------------------------------------------------------
4965 int manualContourBaseControler::GetNumberOfPointsManualContour(){
4966 return _manViewBaseCont->GetNumberOfPoints();
4968 // ----------------------------------------------------------------------------
4970 //JSTG - 25-02-08 -------------------------------------------------------------
4971 int manualContourBaseControler::GetNumberOfPointsSplineManualContour(){
4972 //return _manViewBaseCont->GetNumberOfPointsSpline();
4973 return _manContModel->GetNumberOfPointsSpline();
4975 // ----------------------------------------------------------------------------
4977 double* manualContourBaseControler::GetVectorPointsXManualContour(){
4978 return _manViewBaseCont->GetVectorPointsXManualContour();
4980 // ----------------------------------------------------------------------------
4981 double* manualContourBaseControler::GetVectorPointsYManualContour(){
4982 return _manViewBaseCont->GetVectorPointsYManualContour();
4984 // ----------------------------------------------------------------------------
4985 void manualContourBaseControler::DeleteContour(){
4986 _manViewBaseCont->DeleteContour();
4987 _manContModel->DeleteAllPoints();
4989 // ----------------------------------------------------------------------------
4990 void manualContourBaseControler::DeleteActualMousePoint(int x, int y)// virtual
4992 if ((_manContModel!=NULL) && (_manViewBaseCont!=NULL) )
4994 int id=_manViewBaseCont->GetIdPoint(x,y,GetZ());
4995 if ((id!=-1) && (_manContModel->GetSizeLstPoints()>2) ){
4996 _manContModel->DeletePoint(id);
4997 _manViewBaseCont->DeletePoint(id);
5003 // ----------------------------------------------------------------------------
5004 void manualContourBaseControler::Magnet(int x, int y)
5008 /*int id= */ _manViewBaseCont->GetIdPoint(x,y,GetZ()); // JPRx
5009 if (GetManualContourModel()!=NULL){
5013 GetManualViewBaseContour()->TransfromeCoordViewWorld(xx,yy,zz);
5014 int id = GetManualContourModel()->GetIdPoint(xx,yy,zz,32000,-1);
5017 manualPoint *mp = GetManualContourModel()->GetManualPoint(id);
5018 mp->SetPoint(xx,yy,zz);
5020 // GetManualViewBaseContour()->UpdateViewPoint(id);
5026 // ----------------------------------------------------------------------------
5027 void manualContourBaseControler::SetZ(int z)
5031 // ----------------------------------------------------------------------------
5032 int manualContourBaseControler::GetZ()
5036 // ----------------------------------------------------------------------------
5037 void manualContourBaseControler::AddPoint(int x, int y, int z) // virtual
5039 if (GetManualContourModel()!=NULL){
5043 GetManualViewBaseContour()->TransfromeCoordViewWorld(xx,yy,zz);
5044 /*int id =*/ GetManualContourModel()->AddPoint(xx,yy,zz); // JPRx
5045 GetManualViewBaseContour()->AddPoint();
5046 // GetManualViewBaseContour()->UpdateViewPoint(id);
5049 // ----------------------------------------------------------------------------
5050 void manualContourBaseControler::InsertPoint(int x,int y,int z) // virtual
5054 if (GetManualContourModel()!=NULL){
5058 GetManualViewBaseContour()->TransfromeCoordViewWorld(xx,yy,zz);
5059 if (GetManualContourModel()->GetSizeLstPoints()>1){
5060 id = GetManualContourModel()->InsertPoint(xx,yy,zz);
5061 GetManualViewBaseContour()->InsertPoint(id);
5062 // GetManualViewBaseContour()->UpdateViewPoint(id);
5064 GetManualContourModel()->AddPoint(xx,yy,zz);
5065 GetManualViewBaseContour()->AddPoint();
5067 // GetManualViewBaseContour()->UpdateViewPoint(id);
5072 // ----------------------------------------------------------------------------
5073 void manualContourBaseControler::SetPoint( int id ,int x , int y , int z){ // virtual
5074 if ((GetManualViewBaseContour()!=NULL) && (id>=0)){
5078 GetManualViewBaseContour()->TransfromeCoordViewWorld(xx,yy,zz);
5079 manualPoint *mp = _manContModel->GetManualPoint(id);
5080 mp->SetPoint(xx,yy,zz);
5081 GetManualViewBaseContour()->UpdateViewPoint(id);
5084 // ----------------------------------------------------------------------------
5085 void manualContourBaseControler::SetPointX( int id ,int x ){
5086 if ((GetManualViewBaseContour()!=NULL) && (id>=0)){
5090 GetManualViewBaseContour()->TransfromeCoordViewWorld(xx,yy,zz);
5091 manualPoint *mp = _manContModel->GetManualPoint(id);
5093 GetManualViewBaseContour()->UpdateViewPoint(id);
5096 // ----------------------------------------------------------------------------
5097 void manualContourBaseControler::SetPointY( int id ,int y ){
5098 if ((GetManualViewBaseContour()!=NULL) && (id>=0)){
5102 GetManualViewBaseContour()->TransfromeCoordViewWorld(xx,yy,zz);
5103 manualPoint *mp = _manContModel->GetManualPoint(id);
5105 GetManualViewBaseContour()->UpdateViewPoint(id);
5108 // ----------------------------------------------------------------------------
5109 void manualContourBaseControler::SetPointZ( int id ,int z ){
5110 if ((GetManualViewBaseContour()!=NULL) && (id>=0)){
5114 GetManualViewBaseContour()->TransfromeCoordViewWorld(xx,yy,zz);
5115 manualPoint *mp = _manContModel->GetManualPoint(id);
5117 GetManualViewBaseContour()->UpdateViewPoint(id);
5120 // ----------------------------------------------------------------------------
5121 void manualContourBaseControler::ResetContour() // virtual
5123 this->DeleteContour();
5124 GetManualViewBaseContour()->CreateNewContour();