]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourModelRotationTool.cpp
*** empty log message ***
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualContour / manualContourModelRotationTool.cpp
1 #include "manualContourModelRotationTool.h"
2
3 // ----------------------------------------------------------------------------
4 // ----------------------------------------------------------------------------
5 // ----------------------------------------------------------------------------
6
7 manualContourModelRotationTool::manualContourModelRotationTool()
8 {
9 }
10
11 //----------------------------------------------------------------
12
13 manualContourModelRotationTool::~manualContourModelRotationTool()
14 {
15 }
16
17
18 // ----------------------------------------------------------------------------
19 manualContourModelRotationTool * manualContourModelRotationTool :: Clone()  // virtual
20 {
21         manualContourModelRotationTool * clone = new manualContourModelRotationTool();
22         CopyAttributesTo(clone);
23         return clone;
24 }
25
26 // ---------------------------------------------------------------------------
27 void manualContourModelRotationTool::CopyAttributesTo( manualContourModelRotationTool * cloneObject)
28 {
29         // Fathers object
30         manualContourModelRotationTool::CopyAttributesTo(cloneObject);
31 }
32
33 //----------------------------------------------------------------
34 int manualContourModelRotationTool::GetTypeModel() //virtual
35 {
36         return 8;
37 }
38
39 //----------------------------------------------------------------
40 void manualContourModelRotationTool::GetSpline_i_Point(int i, double *x, double *y, double *z) // virtal
41 {
42         int nps = GetNumberOfPointsSpline();
43         //Spline points of the circle
44         if(i<nps-2)
45         {
46                 double angle = _deltaAngle*i;
47                 *x = _radio*cos(angle) + _centerX;
48                 *y = _radio*sin(angle) + _centerY;
49                 *z = _centerZ;
50         }
51         //Spline points of the reference line
52         if(i==nps-2)
53         {
54                 *x = _centerX;
55                 *y = _centerY;
56                 *z = _centerZ;
57         }
58         //Spline points of the movable line
59         if(i==nps-1)
60         {
61                 manualPoint *mpA= GetManualPoint(2);
62                 *x = mpA->GetX();
63                 *y = mpA->GetY();
64                 *z = _centerZ;
65         }
66         
67 }
68
69 // ---------------------------------------------------------------------------
70 void manualContourModelRotationTool:: UpdateSpline()
71 {       
72         manualPoint     *mpA,*mpB,*mpC;
73         double difX,difY;
74         double x, y; 
75     int np      = GetSizeLstPoints( );
76         int nps = GetNumberOfPointsSpline();
77         _deltaAngle=(3.14159265*2)/(nps-1-2);
78
79         if (np==3)
80         {
81                 mpA                     = GetManualPoint(0);
82                 mpB                     = GetManualPoint(1);
83                 mpC                     = GetManualPoint(2);
84                 difX            = mpA->GetX() - mpB->GetX();
85                 difY            = mpA->GetY() - mpB->GetY();
86                 _radio          = sqrt( difX*difX + difY*difY );
87                 _centerX        = mpA->GetX();
88                 _centerY        = mpA->GetY();
89                 _centerZ        = mpA->GetZ();
90
91                 x= mpC->GetX() - mpA->GetX();
92                 y= mpC->GetY() - mpA->GetY();
93                 _angle= atan(y/x)*180/(3.14159265);
94                 //cout << "Scale" <<_radio <<endl;
95                 //cout << "Angle" <<_angle <<endl;
96         } 
97         else 
98         {
99                 _radio          = -1;
100                 _centerX        = -1;
101                 _centerY        = -1;
102                 _centerZ        = -1;
103                 _angle          = -1;
104         }
105 }
106
107 //----------------------------------------------------------------
108 double manualContourModelRotationTool::getRadio()
109 {
110         return _radio;
111 }
112
113 //----------------------------------------------------------------
114 double manualContourModelRotationTool::getAngle()
115 {
116         return _angle;
117 }