]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContour3VControler.cpp
0f50090a1a89980095442dab2fabe08a5c31eb63
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualContour / manualContour3VControler.cpp
1 #include "manualContour3VControler.h"
2
3 // ----------------------------------------------------------------------------
4 // ----------------------------------------------------------------------------
5 // ----------------------------------------------------------------------------
6
7 // _type = 0  Sagital
8 // _type = 1  Coronal
9 // _type = 2  Axial
10 // _type = -1 View 3D
11
12 manualContour3VControler::manualContour3VControler(int type)
13 {
14         _type=type;
15
16 //EEDhh
17 //      _manViewBaseCont1 = NULL;
18 //      _manViewBaseCont2 = NULL;
19 //      _manViewBaseCont3 = NULL;
20 }
21 //----------------------------------------------------------------------------
22 manualContour3VControler::~manualContour3VControler()
23 {
24 }
25
26 // ----------------------------------------------------------------------------
27 manualContour3VControler * manualContour3VControler :: Clone()  // virtual
28 {
29         manualContour3VControler * clone = new manualContour3VControler( this->GetType() );
30         CopyAttributesTo(clone);
31         return clone;
32 }
33
34 // ---------------------------------------------------------------------------
35 void manualContour3VControler::CopyAttributesTo( manualContour3VControler * cloneObject)
36 {
37         // Fathers object
38         manualContourControler::CopyAttributesTo(cloneObject);
39
40         cloneObject->SetVtkMPRBaseData( this->GetVtkMPRBaseData() );
41
42         // Remember to add ManualViewBaseContour with "AddManualViewBaseContour"
43
44 }
45 // ----------------------------------------------------------------------------
46 int manualContour3VControler::GetType()
47 {
48         return _type;
49 }
50
51 // ----------------------------------------------------------------------------
52 void manualContour3VControler::AddPoint_Others()
53 {
54         manualViewBaseContour *mvbc;
55         int i,size=this->_lstManualViewBaseContour.size();
56         for ( i = 0 ; i < size ; i++ )
57         {
58                 mvbc = _lstManualViewBaseContour[i];
59                 mvbc->AddPoint();
60         }
61
62 // EEDhh
63 //      if (_manViewBaseCont1!=NULL){
64 //              _manViewBaseCont1->AddPoint();
65 //              _manViewBaseCont2->AddPoint();
66 //              _manViewBaseCont3->AddPoint();
67 //              this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
68 //      }
69
70         this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
71 }
72 // ----------------------------------------------------------------------------
73 void manualContour3VControler::AddPoint( int x, int y, int z ) // virtual
74 {
75
76         z=(int)_vtkmprbasedata->GetZ();
77         if (GetManualContourModel()!=NULL){
78                 double  xx      = x;
79                 double  yy      = y;
80                 double  zz      = z;
81                 GetManualViewBaseContour()->TransfromCoordViewWorld(xx,yy,zz,_type);
82
83                 if (_type==0)
84                 {
85                         xx=_vtkmprbasedata->GetX();
86                 }
87
88                 if (_type==1)
89                 {
90                         yy=_vtkmprbasedata->GetY();
91                 }
92
93
94                 /*int   id              = */ GetManualContourModel()->AddPoint(xx,yy,zz);  // JPRx
95                 GetManualViewBaseContour()->AddPoint();
96                 AddPoint_Others();
97
98         }
99 }
100
101 // ----------------------------------------------------------------------------
102 void manualContour3VControler::InsertPoint_Others(int id)
103 {
104
105         manualViewBaseContour *mvbc;
106         int i,size=this->_lstManualViewBaseContour.size();
107         for ( i = 0 ; i < size ; i++ )
108         {
109                 mvbc = _lstManualViewBaseContour[i];
110                 mvbc->InsertPoint(id);
111         }
112
113 /*EEDhh
114         if (_manViewBaseCont1!=NULL){
115                 _manViewBaseCont1->InsertPoint(id);
116                 _manViewBaseCont2->InsertPoint(id);
117                 _manViewBaseCont3->InsertPoint(id);
118                 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
119         }
120 */
121
122         this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
123
124 }
125 // ----------------------------------------------------------------------------
126 void manualContour3VControler::InsertPoint(int x, int y, int z)
127 {
128         int id=-1;
129         if (GetManualContourModel()!=NULL){
130                 if (GetManualContourModel()->GetSizeLstPoints()>1){
131                         z=(int)_vtkmprbasedata->GetZ();
132                         double                          xx              = x;
133                         double                          yy              = y;
134                         double                          zz              = z;
135                         GetManualViewBaseContour()->TransfromCoordViewWorld(xx,yy,zz,_type);
136                         if (_type==0)
137                         {
138                                 xx=_vtkmprbasedata->GetX();
139                         }
140
141                         if (_type==1)
142                         {
143                                 yy=_vtkmprbasedata->GetY();
144                         }
145
146                         id      = GetManualContourModel()->InsertPoint(xx,yy,zz);
147
148                         GetManualViewBaseContour()->InsertPoint(id);
149                         InsertPoint_Others(0);
150
151                 } else {
152                         AddPoint(x,y,z);
153                 }
154         }
155 }
156 // ----------------------------------------------------------------------------
157
158 // EEDhh
159 /*
160 void manualContour3VControler::SetModelView (   manualContourModel *manContModel,
161                                                                                                 manualViewBaseContour *manViewBaseCont0,
162                                                                                                 manualViewBaseContour *manViewBaseCont1,
163                                                                                                 manualViewBaseContour *manViewBaseCont2,
164                                                                                                 manualViewBaseContour *manViewBaseCont3)
165 {
166         manualContourControler::SetModelView(manContModel,manViewBaseCont0);
167         _manViewBaseCont1 = manViewBaseCont1;
168         _manViewBaseCont2 = manViewBaseCont2;
169         _manViewBaseCont3 = manViewBaseCont3;
170 }
171 */
172
173 // ----------------------------------------------------------------------------
174 void manualContour3VControler::AddManualViewBaseContour( manualViewBaseContour *manViewBaseCont )
175 {
176         _lstManualViewBaseContour.push_back( manViewBaseCont );
177 }
178
179 // ----------------------------------------------------------------------------
180 void manualContour3VControler::SetVtkMPRBaseData (vtkMPRBaseData *vtkmprbasedata )
181 {
182         _vtkmprbasedata=vtkmprbasedata;
183 }
184 // ----------------------------------------------------------------------------
185 vtkMPRBaseData *manualContour3VControler::GetVtkMPRBaseData()
186 {
187         return _vtkmprbasedata;
188 }
189 // ----------------------------------------------------------------------------
190 void manualContour3VControler::SetPoint( int id ,int x ,int y ,int z ) // virtual
191 {
192         z=(int)_vtkmprbasedata->GetZ();
193         if ((GetManualViewBaseContour()!=NULL) && (id>=0)){
194                 double xx = x;
195                 double yy = y;
196                 double zz = z;
197                 GetManualViewBaseContour()->TransfromCoordViewWorld(xx,yy,zz,_type);
198
199                 if (_type==0)
200                 {
201                         xx=_vtkmprbasedata->GetX();
202                 }
203                 if (_type==1)
204                 {
205                         yy=_vtkmprbasedata->GetY();
206                 }
207
208                 manualPoint     *mp     = GetManualContourModel()->GetManualPoint(id);
209                 mp->SetPoint(xx,yy,zz);
210
211         }
212 }
213 // ----------------------------------------------------------------------------
214 void manualContour3VControler::DeleteActualMousePoint_Others(int id)
215 {
216         manualViewBaseContour *mvbc;
217         int i,size=this->_lstManualViewBaseContour.size();
218         for ( i = 0 ; i < size ; i++ )
219         {
220                 mvbc = _lstManualViewBaseContour[i];
221                 mvbc->DeletePoint(id);
222                 mvbc->Refresh();
223         }
224
225 /*
226         if (_manViewBaseCont1!=NULL){
227                 _manViewBaseCont1->DeletePoint(id);
228                 _manViewBaseCont2->DeletePoint(id);
229                 _manViewBaseCont3->DeletePoint(id);
230
231                 _manViewBaseCont1->Refresh();
232                 _manViewBaseCont2->Refresh();
233                 _manViewBaseCont3->Refresh();
234
235                 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
236         }
237 */
238         this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
239 }
240 // ----------------------------------------------------------------------------
241 void manualContour3VControler::DeleteActualMousePoint(int x, int y)// virtual
242 {
243         int id=GetManualViewBaseContour()->GetIdPoint ( x , y , GetZ() );
244         if (id!=-1){
245                 manualContourBaseControler::DeleteActualMousePoint( x , y );
246                 DeleteActualMousePoint_Others( id );
247         }
248 }
249 // ----------------------------------------------------------------------------
250 void manualContour3VControler::MouseMove_Others(int id) // virtual
251 {
252         manualViewBaseContour *mvbc;
253         int i,size=this->_lstManualViewBaseContour.size();
254         for ( i = 0 ; i < size ; i++ )
255         {
256                 mvbc = _lstManualViewBaseContour[i];
257                 mvbc->SelectAllPossibleSelected(false);
258                 if (id!=-1)
259                 {
260                         mvbc->SetPointPosibleSelected(id,true);
261                 }
262                 mvbc->SetPosibleSelected  (  GetManualViewBaseContour()->GetPosibleSelected()  );
263                 mvbc->Refresh();
264         }
265
266 // EEDhh
267 /*
268         if (_manViewBaseCont1!=NULL){
269                 _manViewBaseCont1->SelectAllPossibleSelected(false);
270                 _manViewBaseCont2->SelectAllPossibleSelected(false);
271                 _manViewBaseCont3->SelectAllPossibleSelected(false);
272                 if (id!=-1){
273                         _manViewBaseCont1->SetPointPosibleSelected(id,true);
274                         _manViewBaseCont2->SetPointPosibleSelected(id,true);
275                         _manViewBaseCont3->SetPointPosibleSelected(id,true);
276                 }
277                 _manViewBaseCont1->SetPosibleSelected  (  GetManualViewBaseContour()->GetPosibleSelected()  );
278                 _manViewBaseCont2->SetPosibleSelected  (  GetManualViewBaseContour()->GetPosibleSelected()  );
279                 _manViewBaseCont3->SetPosibleSelected  (  GetManualViewBaseContour()->GetPosibleSelected()  );
280
281                 _manViewBaseCont1->Refresh();
282                 _manViewBaseCont2->Refresh();
283                 _manViewBaseCont3->Refresh();
284
285                 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
286         }
287 */
288         this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
289
290 }
291
292 // ----------------------------------------------------------------------------
293 void manualContour3VControler::MouseMove(int x, int y) // virtual
294 {
295         manualContourControler::MouseMove( x , y );
296         int id=GetManualViewBaseContour()->GetIdPoint(x,y,GetZ());
297         MouseMove_Others( id );
298 }
299
300 // ----------------------------------------------------------------------------
301 void manualContour3VControler::OnChar_Others()
302 {
303         manualViewBaseContour *mvbc;
304         int i,size=this->_lstManualViewBaseContour.size();
305         for ( i = 0 ; i < size ; i++ )
306         {
307                 mvbc = _lstManualViewBaseContour[i];
308                 mvbc->Refresh();
309         }
310 // EEDhh
311 /*
312                 _manViewBaseCont1->Refresh();
313                 _manViewBaseCont2->Refresh();
314                 _manViewBaseCont3->Refresh();
315 */
316         this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
317 }
318 // ----------------------------------------------------------------------------
319 bool manualContour3VControler::OnChar()
320 {
321         manualContourControler::OnChar();
322         OnChar_Others();
323         return true;
324 }
325 // ----------------------------------------------------------------------------
326 void manualContour3VControler::ResetContour() // virtual
327 {
328         manualContourControler::ResetContour();
329         ResetContour_Others();
330 }
331
332 // ----------------------------------------------------------------------------
333 void manualContour3VControler::ResetContour_Others()
334 {
335         manualViewBaseContour *mvbc;
336         int i,size=this->_lstManualViewBaseContour.size();
337         for ( i = 0 ; i < size ; i++ )
338         {
339                 mvbc = _lstManualViewBaseContour[i];
340                 mvbc->DeleteContour();
341                 mvbc->CreateNewContour();
342         }
343
344 // EEDhh
345 /*
346         _manViewBaseCont1->DeleteContour();
347         _manViewBaseCont2->DeleteContour();
348         _manViewBaseCont3->DeleteContour();
349         _manViewBaseCont1->CreateNewContour();
350         _manViewBaseCont2->CreateNewContour();
351         _manViewBaseCont3->CreateNewContour();
352 */
353 }
354