]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualRotationToolControler.cpp
7785b975cfe3921db408e32df379aad9c7298033
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualContour / manualRotationToolControler.cpp
1 #include "manualRotationToolControler.h"
2
3 // ----------------------------------------------------------------------------
4 // ----------------------------------------------------------------------------
5 // ----------------------------------------------------------------------------
6
7 // _state = 0  // ..nothing..
8 // _state = 5  // move point
9 // _state = 6  // move all
10 // _state = 7  // Empty mouse drag
11
12 manualRotationToolControler::manualRotationToolControler()
13 {
14
15 }
16
17 // ----------------------------------------------------------------------------
18 manualRotationToolControler::~manualRotationToolControler()
19 {
20
21 }
22
23 // ----------------------------------------------------------------------------
24 manualRotationToolControler * manualRotationToolControler :: Clone()  // virtual
25 {
26         manualRotationToolControler * clone = new manualRotationToolControler();
27         CopyAttributesTo(clone);
28         return clone;
29 }
30
31 // ---------------------------------------------------------------------------
32 void manualRotationToolControler::CopyAttributesTo( manualRotationToolControler * cloneObject)
33 {
34         // Fathers object
35         manualContourBaseControler::CopyAttributesTo(cloneObject);
36 }
37
38 // ----------------------------------------------------------------------------
39 void manualRotationToolControler::Configure() //virtual
40 {
41
42 }
43
44 // ----------------------------------------------------------------------------
45 void manualRotationToolControler::MouseClickLeft(int x, int y)
46 {
47         int z = GetZ();
48         
49         if( IsEditable() )
50         {       // move control point
51           if ( (GetState()==0) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)!=-1 ) ){
52                   bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
53                   SetState(5);
54           }
55         }// IsEditable
56         
57         // move contour
58         if ((GetState()==0) && (GetManualViewBaseContour()->GetPosibleSelected()==true))        {
59                 GetManualViewBaseContour()->InitMove(x,y,z);
60                 SetState(6);
61         }
62         
63         // firstime create 3 control points and move one control point
64         int size=GetManualViewBaseContour()->GetNumberOfPoints();
65         if (GetState()==0) {
66                 if (size==0){
67                         AddPoint(x,y,z);
68                         AddPoint(x,y,z);
69                         bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
70                         AddPoint(x,y,z);
71                         SetState(1);
72                 }
73         }       
74         
75         GetManualViewBaseContour()->Refresh();
76 }
77
78 // ----------------------------------------------------------------------------
79 void manualRotationToolControler::MouseMove(int x, int y) // virtual
80 {
81         int z=GetZ();
82
83         GetManualViewBaseContour()->SelectPosibleContour(x,y,z);
84         GetManualViewBaseContour()->SelectPosiblePoint(x,y,z);
85
86         if (GetState()==1){     SetPoint( bakIdPoint , x , y ,z); }
87         if (GetState()==5){     SetPoint( bakIdPoint , x , y ,z); }
88         
89         if (GetState()==6){
90                 GetManualViewBaseContour()->MoveContour(x,y,z);
91         }
92         GetManualViewBaseContour()->Refresh();
93 }
94
95 // ----------------------------------------------------------------------------
96 void manualRotationToolControler::DeleteActualMousePoint(int x, int y)  // virtual
97 {
98 }
99
100 // ----------------------------------------------------------------------------
101 void manualRotationToolControler::InitRoi(int ww, int hh, double porcentage)
102 {
103         int zz;
104         manualPoint *mp;
105
106         if (GetManualContourModel()->GetSizeLstPoints() ==0)
107         {
108                 zz = GetZ();
109                 AddPoint(0,0,zz);
110                 AddPoint(0,0,zz);
111                 AddPoint(0,0,zz);
112         }
113
114         double pp1=porcentage;
115         double pp2=1-porcentage;
116
117         mp = GetManualContourModel()->GetManualPoint(2);
118         zz=(int)mp->GetZ();
119         mp->SetPoint(ww*pp1,hh*pp1,zz);
120
121         mp = GetManualContourModel()->GetManualPoint(1);
122         zz=(int)mp->GetZ();
123         cout <<  ww*pp2 <<hh*pp1 << zz<<endl;
124         mp->SetPoint(ww*pp2,hh*pp1,zz);
125
126         mp = GetManualContourModel()->GetManualPoint(0);
127         zz=(int)mp->GetZ();
128         cout <<  ww*pp2 <<hh*pp2 << zz<<endl;
129         mp->SetPoint(ww*pp2,hh*pp2,zz);
130
131         GetManualViewBaseContour() ->UpdateViewPoint(0);
132         GetManualViewBaseContour() ->UpdateViewPoint(1);
133         GetManualViewBaseContour() ->UpdateViewPoint(2);
134
135         SetState(0);
136         GetManualViewBaseContour()->Refresh();
137 }