]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualCircleControler.cpp
DFCH: imageUndoRedo + Manual Paint: It doesn't works :s :s
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualContour / manualCircleControler.cpp
1 #include "manualCircleControler.h"
2
3 // ----------------------------------------------------------------------------
4 // ----------------------------------------------------------------------------
5 // ----------------------------------------------------------------------------
6
7 // EED08
8
9 // _state = 0  // ..nothing..
10 // _state = 5  // move point
11 // _state = 6  // move all
12 // _state = 7  // Empty mouse drag
13
14 manualCircleControler::manualCircleControler()
15 {
16 }
17 // ----------------------------------------------------------------------------
18 manualCircleControler::~manualCircleControler()
19 {
20 }
21 // ----------------------------------------------------------------------------
22 manualCircleControler * manualCircleControler :: Clone()  // virtual
23 {
24         manualCircleControler * clone = new manualCircleControler();
25         CopyAttributesTo(clone);
26         return clone;
27 }
28
29 // ---------------------------------------------------------------------------
30 void manualCircleControler::CopyAttributesTo( manualCircleControler * cloneObject)
31 {
32         // Fathers object
33         manualContourBaseControler::CopyAttributesTo(cloneObject);
34 }
35
36 // ----------------------------------------------------------------------------
37 void manualCircleControler::Configure() //virtual
38 {
39 //      this->GetManualContourModel()->SetNumberOfPointsSpline(5);
40 }
41
42 // ----------------------------------------------------------------------------
43 void manualCircleControler::MouseClickLeft(int x, int y){
44         int z = GetZ();
45         
46         if( IsEditable() )
47         {       // move control point
48           if ( (GetState()==0) && (GetManualViewBaseContour()->GetIdPoint(x,y,z)!=-1 ) ){
49                   bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
50                   SetState(5);
51           }
52         }// IsEditable
53         
54         // move contour
55         if ((GetState()==0) && (GetManualViewBaseContour()->GetPosibleSelected()==true))        {
56                 GetManualViewBaseContour()->InitMove(x,y,z);
57                 SetState(6);
58         }
59         
60         // firstime create 2 control points and move one control point
61         int size=GetManualViewBaseContour()->GetNumberOfPoints();
62         if (GetState()==0) {
63                 if (size==0){
64                         AddPoint(x,y,z);
65                         AddPoint(x,y,z);
66                         bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
67                         SetState(1);
68                 }
69         }       
70         
71 /*EED 21 Avril 2009     
72         if (GetState()==0) {
73                 if (size==0){
74                         AddPoint(x,y,z);
75                         AddPoint(x,y,z);
76                 } else {
77                         SetPoint(0,x,y,z);
78                         SetPoint(1,x,y,z);
79                 }
80                 bakIdPoint = GetManualViewBaseContour()->GetIdPoint(x,y,z);
81                 SetState(5);
82         }
83 */
84         
85         GetManualViewBaseContour()->Refresh();
86 }
87 // ----------------------------------------------------------------------------
88
89 void manualCircleControler::MouseMove(int x, int y) // virtual
90 {
91         int z=GetZ();
92 //      this->_vtkInteractorStyleBaseView->
93
94         GetManualViewBaseContour()->SelectPosibleContour(x,y,z);
95         GetManualViewBaseContour()->SelectPosiblePoint(x,y,z);
96
97         if (GetState()==1){     SetPoint( bakIdPoint , x , y ,z); }
98         if (GetState()==5){     SetPoint( bakIdPoint , x , y ,z); }
99         
100         if (GetState()==6){
101                 GetManualViewBaseContour()->MoveContour(x,y,z);
102         }
103         GetManualViewBaseContour()->Refresh();
104 }
105
106
107 // ----------------------------------------------------------------------------
108 void manualCircleControler::DeleteActualMousePoint(int x, int y)  // virtual
109 {
110 }
111 // ----------------------------------------------------------------------------
112
113 void manualCircleControler::InitRoi(int ww, int hh, double porcentage)
114 {
115         int zz;
116         manualPoint *mp;
117
118         if (GetManualContourModel()->GetSizeLstPoints() ==0)
119         {
120                 zz = GetZ();
121                 AddPoint(0,0,zz);
122                 AddPoint(0,0,zz);
123 //              AddPoint(0,0,zz);
124 //              AddPoint(0,0,zz);
125         }
126
127         double pp1=porcentage;
128         double pp2=1-porcentage;
129
130 //      mp = GetManualContourModel()->GetManualPoint(2);
131 //      zz=(int)mp->GetZ();
132 //      mp->SetPoint(ww*pp1,hh*pp1,zz);
133
134         mp = GetManualContourModel()->GetManualPoint(1);
135         zz=(int)mp->GetZ();
136         mp->SetPoint(ww*pp2,hh*pp1,zz);
137
138         mp = GetManualContourModel()->GetManualPoint(0);
139         zz=(int)mp->GetZ();
140         mp->SetPoint(ww*pp2,hh*pp2,zz);
141
142 //      mp = GetManualContourModel()->GetManualPoint(3);
143 //      zz=(int)mp->GetZ();
144 //      mp->SetPoint(ww*pp1,hh*pp2,zz);
145
146         GetManualViewBaseContour() ->UpdateViewPoint(0);
147         GetManualViewBaseContour() ->UpdateViewPoint(1);
148 //      GetManualViewBaseContour() ->UpdateViewPoint(2);
149 //      GetManualViewBaseContour() ->UpdateViewPoint(3);
150
151         SetState(0);
152         GetManualViewBaseContour()->Refresh();
153 }
154
155 // ----------------------------------------------------------------------------
156 /*
157 void manualCircleControler::SetRoi(int x1, int y1,int x2, int y2)
158 {
159         manualPoint *mp;
160         InitRoi( 0 , 0 , 0.2 );
161         mp = GetManualContourModel()->GetManualPoint(2);
162         mp->SetPointX(x1);
163         mp->SetPointY(y1);
164
165         mp = GetManualContourModel()->GetManualPoint(1);
166         mp->SetPointX(x2);
167         mp->SetPointY(y1);
168
169         mp = GetManualContourModel()->GetManualPoint(0);
170         mp->SetPointX(x2);
171         mp->SetPointY(y2);
172
173         mp = GetManualContourModel()->GetManualPoint(3);
174         mp->SetPointX(x1);
175         mp->SetPointY(y2);
176
177         GetManualViewBaseContour() ->UpdateViewPoint(0);
178         GetManualViewBaseContour() ->UpdateViewPoint(1);
179         GetManualViewBaseContour() ->UpdateViewPoint(2);
180         GetManualViewBaseContour() ->UpdateViewPoint(3);
181 }
182 */