]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualViewRotationTool.cpp
c5b28215395e0f3ca58e95f2a12a91fc2167e36e
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualContour / manualViewRotationTool.cpp
1 #include "manualViewRotationTool.h"
2
3 // ----------------------------------------------------------------------------
4 // ----------------------------------------------------------------------------
5 // ----------------------------------------------------------------------------
6
7 manualViewRotationTool::manualViewRotationTool()
8 {       
9
10 }
11 // ----------------------------------------------------------------------------
12 manualViewRotationTool::~manualViewRotationTool()
13 {
14
15 }
16
17 // ----------------------------------------------------------------------------
18 manualViewRotationTool * manualViewRotationTool :: Clone()
19 {
20         manualViewRotationTool * clone = new manualViewRotationTool();
21         CopyAttributesTo(clone);
22         return clone;
23 }
24
25 // ---------------------------------------------------------------------------
26 void manualViewRotationTool::CopyAttributesTo( manualViewRotationTool * cloneObject)
27 {
28         manualViewBaseContour::CopyAttributesTo(cloneObject);
29 }
30
31 // ----------------------------------------------------------------------------
32 int manualViewRotationTool::GetType() // virtual
33 {
34         return 8;
35 }
36
37 // ----------------------------------------------------------------------------
38 void manualViewRotationTool::GetMinMax(double &minX,double &minY, double &maxX, double &maxY)
39 {
40         manualPoint     *mpA,*mpB;
41     unsigned int  np;
42         double radio;
43         double difX,difY;
44     np  = GetNumberOfPoints( );
45         
46         if (np==3)
47         {
48                 mpA             = _manContModel->GetManualPoint(0);
49                 mpB             = _manContModel->GetManualPoint(1);
50                 difX    = mpA->GetX() - mpB->GetX();
51                 difY    = mpA->GetY() - mpB->GetY();
52                 radio   = sqrt( difX*difX + difY*difY );
53                 minX=mpA->GetX()-radio;
54                 minY=mpA->GetY()-radio;
55                 maxX=mpA->GetX()+radio;
56                 maxY=mpA->GetY()+radio;
57         } 
58         else 
59         {
60                 minX=0;
61                 maxX=0;
62                 minY=0;
63                 maxY=0;
64         }
65 }
66
67 // ----------------------------------------------------------------------------
68
69 void manualViewRotationTool::InitMove(int x, int y, int z)  // virtual
70 {
71         manualPoint *mp;
72         double XX=x;
73         double YY=y;
74         double ZZ=z;
75         TransfromCoordViewWorld(XX,YY,ZZ);
76
77         if (_manContModel->GetSizeLstPoints()==3)
78         {
79                 mp = _manContModel->GetManualPoint(0);
80                 _dp0[0]= mp->GetX() - XX;
81                 _dp0[1]= mp->GetY() - YY;
82                 _dp0[2]= mp->GetZ();
83
84                 mp = _manContModel->GetManualPoint(1);
85                 _dp1[0]= mp->GetX() - XX;
86                 _dp1[1]= mp->GetY() - YY;
87                 _dp1[2]= mp->GetZ();
88
89                 mp = _manContModel->GetManualPoint(2);
90                 _dp2[0]= mp->GetX() - XX;
91                 _dp2[1]= mp->GetY() - YY;
92                 _dp2[2]= mp->GetZ();
93
94         }
95 }
96
97 // ----------------------------------------------------------------------------
98 void manualViewRotationTool::MoveContour(int x, int y, int z) // virtual
99 {
100         manualPoint *mp;
101         double XX=x;
102         double YY=y;
103         double ZZ=z;
104         TransfromCoordViewWorld(XX,YY,ZZ);
105
106         mp = _manContModel->GetManualPoint(0);
107         mp->SetPoint(_dp0[0]+XX,_dp0[1]+YY,_dp0[2]);
108
109         mp = _manContModel->GetManualPoint(1);
110         mp->SetPoint(_dp1[0]+XX,_dp1[1]+YY,_dp0[2]);
111
112         mp = _manContModel->GetManualPoint(2);
113         mp->SetPoint(_dp2[0]+XX,_dp2[1]+YY,_dp0[2]);
114
115         UpdateViewPoint(0);
116         UpdateViewPoint(1);
117         UpdateViewPoint(2);
118 }