]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContour3VControler.cpp
#3262 creaMaracasVisu Feature New Normal - Export LookupTable fron ColorLayerImageV...
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualContour / manualContour3VControler.cpp
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and
10 #  abiding by the rules of distribution of free software. You can  use,
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B
12 #  license as circulated by CEA, CNRS and INRIA at the following URL
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability.
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
25
26 #include "manualContour3VControler.h"
27
28 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
31
32 // _type = 0  Sagital
33 // _type = 1  Coronal
34 // _type = 2  Axial
35 // _type = -1 View 3D
36
37 manualContour3VControler::manualContour3VControler(int type)
38 {
39         _type=type;
40
41 //EEDhh
42 //      _manViewBaseCont1 = NULL;
43 //      _manViewBaseCont2 = NULL;
44 //      _manViewBaseCont3 = NULL;
45 }
46 //----------------------------------------------------------------------------
47 manualContour3VControler::~manualContour3VControler()
48 {
49 }
50
51 // ----------------------------------------------------------------------------
52 manualContour3VControler * manualContour3VControler :: Clone()  // virtual
53 {
54         manualContour3VControler * clone = new manualContour3VControler( this->GetType() );
55         CopyAttributesTo(clone);
56         return clone;
57 }
58
59 // ---------------------------------------------------------------------------
60 void manualContour3VControler::CopyAttributesTo( manualContour3VControler * cloneObject)
61 {
62         // Fathers object
63         manualContourControler::CopyAttributesTo(cloneObject);
64
65         cloneObject->SetVtkMPRBaseData( this->GetVtkMPRBaseData() );
66
67         // Remember to add ManualViewBaseContour with "AddManualViewBaseContour"
68
69 }
70 // ----------------------------------------------------------------------------
71 int manualContour3VControler::GetType()
72 {
73         return _type;
74 }
75
76 // ----------------------------------------------------------------------------
77 void manualContour3VControler::AddPoint_Others()
78 {
79         manualViewBaseContour *mvbc;
80         int i,size=this->_lstManualViewBaseContour.size();
81         for ( i = 0 ; i < size ; i++ )
82         {
83                 mvbc = _lstManualViewBaseContour[i];
84                 mvbc->AddPoint();
85         }
86
87 // EEDhh
88 //      if (_manViewBaseCont1!=NULL){
89 //              _manViewBaseCont1->AddPoint();
90 //              _manViewBaseCont2->AddPoint();
91 //              _manViewBaseCont3->AddPoint();
92 //              this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
93 //      }
94
95         this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
96 }
97 // ----------------------------------------------------------------------------
98 void manualContour3VControler::AddPoint( int x, int y, int z ) // virtual
99 {
100
101         z=(int)_vtkmprbasedata->GetZ();
102         if (GetManualContourModel()!=NULL){
103                 double  xx      = x;
104                 double  yy      = y;
105                 double  zz      = z;
106                 GetManualViewBaseContour()->TransfromCoordViewWorld(xx,yy,zz,_type);
107
108                 if (_type==0)
109                 {
110                         xx=_vtkmprbasedata->GetX();
111                 }
112
113                 if (_type==1)
114                 {
115                         yy=_vtkmprbasedata->GetY();
116                 }
117
118
119                 /*int   id              = */ GetManualContourModel()->AddPoint(xx,yy,zz);  // JPRx
120                 GetManualViewBaseContour()->AddPoint();
121                 AddPoint_Others();
122
123         }
124 }
125
126 // ----------------------------------------------------------------------------
127 void manualContour3VControler::InsertPoint_Others(int id)
128 {
129
130         manualViewBaseContour *mvbc;
131         int i,size=this->_lstManualViewBaseContour.size();
132         for ( i = 0 ; i < size ; i++ )
133         {
134                 mvbc = _lstManualViewBaseContour[i];
135                 mvbc->InsertPoint(id);
136         }
137
138 /*EEDhh
139         if (_manViewBaseCont1!=NULL){
140                 _manViewBaseCont1->InsertPoint(id);
141                 _manViewBaseCont2->InsertPoint(id);
142                 _manViewBaseCont3->InsertPoint(id);
143                 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
144         }
145 */
146
147         this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
148
149 }
150 // ----------------------------------------------------------------------------
151 void manualContour3VControler::InsertPoint(int x, int y, int z)
152 {
153         int id=-1;
154         if (GetManualContourModel()!=NULL){
155                 if (GetManualContourModel()->GetSizeLstPoints()>1){
156                         z=(int)_vtkmprbasedata->GetZ();
157                         double                          xx              = x;
158                         double                          yy              = y;
159                         double                          zz              = z;
160                         GetManualViewBaseContour()->TransfromCoordViewWorld(xx,yy,zz,_type);
161                         if (_type==0)
162                         {
163                                 xx=_vtkmprbasedata->GetX();
164                         }
165
166                         if (_type==1)
167                         {
168                                 yy=_vtkmprbasedata->GetY();
169                         }
170
171                         id      = GetManualContourModel()->InsertPoint(xx,yy,zz);
172
173                         GetManualViewBaseContour()->InsertPoint(id);
174                         InsertPoint_Others(0);
175
176                 } else {
177                         AddPoint(x,y,z);
178                 }
179         }
180 }
181 // ----------------------------------------------------------------------------
182
183 // EEDhh
184 /*
185 void manualContour3VControler::SetModelView (   manualContourModel *manContModel,
186                                                                                                 manualViewBaseContour *manViewBaseCont0,
187                                                                                                 manualViewBaseContour *manViewBaseCont1,
188                                                                                                 manualViewBaseContour *manViewBaseCont2,
189                                                                                                 manualViewBaseContour *manViewBaseCont3)
190 {
191         manualContourControler::SetModelView(manContModel,manViewBaseCont0);
192         _manViewBaseCont1 = manViewBaseCont1;
193         _manViewBaseCont2 = manViewBaseCont2;
194         _manViewBaseCont3 = manViewBaseCont3;
195 }
196 */
197
198 // ----------------------------------------------------------------------------
199 void manualContour3VControler::AddManualViewBaseContour( manualViewBaseContour *manViewBaseCont )
200 {
201         _lstManualViewBaseContour.push_back( manViewBaseCont );
202 }
203
204 // ----------------------------------------------------------------------------
205 void manualContour3VControler::SetVtkMPRBaseData (vtkMPRBaseData *vtkmprbasedata )
206 {
207         _vtkmprbasedata=vtkmprbasedata;
208 }
209 // ----------------------------------------------------------------------------
210 vtkMPRBaseData *manualContour3VControler::GetVtkMPRBaseData()
211 {
212         return _vtkmprbasedata;
213 }
214 // ----------------------------------------------------------------------------
215 void manualContour3VControler::SetPoint( int id ,int x ,int y ,int z ) // virtual
216 {
217         z=(int)_vtkmprbasedata->GetZ();
218         if ((GetManualViewBaseContour()!=NULL) && (id>=0)){
219                 double xx = x;
220                 double yy = y;
221                 double zz = z;
222                 GetManualViewBaseContour()->TransfromCoordViewWorld(xx,yy,zz,_type);
223
224                 if (_type==0)
225                 {
226                         xx=_vtkmprbasedata->GetX();
227                 }
228                 if (_type==1)
229                 {
230                         yy=_vtkmprbasedata->GetY();
231                 }
232
233                 manualPoint     *mp     = GetManualContourModel()->GetManualPoint(id);
234                 mp->SetPoint(xx,yy,zz);
235
236         }
237 }
238 // ----------------------------------------------------------------------------
239 void manualContour3VControler::DeleteActualMousePoint_Others(int id)
240 {
241         manualViewBaseContour *mvbc;
242         int i,size=this->_lstManualViewBaseContour.size();
243         for ( i = 0 ; i < size ; i++ )
244         {
245                 mvbc = _lstManualViewBaseContour[i];
246                 mvbc->DeletePoint(id);
247                 mvbc->Refresh();
248         }
249
250 /*
251         if (_manViewBaseCont1!=NULL){
252                 _manViewBaseCont1->DeletePoint(id);
253                 _manViewBaseCont2->DeletePoint(id);
254                 _manViewBaseCont3->DeletePoint(id);
255
256                 _manViewBaseCont1->Refresh();
257                 _manViewBaseCont2->Refresh();
258                 _manViewBaseCont3->Refresh();
259
260                 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
261         }
262 */
263         this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
264 }
265 // ----------------------------------------------------------------------------
266 void manualContour3VControler::DeleteActualMousePoint(int x, int y)// virtual
267 {
268         int id=GetManualViewBaseContour()->GetIdPoint ( x , y , GetZ() );
269         if (id!=-1){
270                 manualContourBaseControler::DeleteActualMousePoint( x , y );
271                 DeleteActualMousePoint_Others( id );
272         }
273 }
274 // ----------------------------------------------------------------------------
275 void manualContour3VControler::MouseMove_Others(int id) // virtual
276 {
277         manualViewBaseContour *mvbc;
278         int i,size=this->_lstManualViewBaseContour.size();
279         for ( i = 0 ; i < size ; i++ )
280         {
281                 mvbc = _lstManualViewBaseContour[i];
282                 mvbc->SelectAllPossibleSelected(false);
283                 if (id!=-1)
284                 {
285                         mvbc->SetPointPosibleSelected(id,true);
286                 }
287                 mvbc->SetPosibleSelected  (  GetManualViewBaseContour()->GetPosibleSelected()  );
288                 mvbc->Refresh();
289         }
290
291 // EEDhh
292 /*
293         if (_manViewBaseCont1!=NULL){
294                 _manViewBaseCont1->SelectAllPossibleSelected(false);
295                 _manViewBaseCont2->SelectAllPossibleSelected(false);
296                 _manViewBaseCont3->SelectAllPossibleSelected(false);
297                 if (id!=-1){
298                         _manViewBaseCont1->SetPointPosibleSelected(id,true);
299                         _manViewBaseCont2->SetPointPosibleSelected(id,true);
300                         _manViewBaseCont3->SetPointPosibleSelected(id,true);
301                 }
302                 _manViewBaseCont1->SetPosibleSelected  (  GetManualViewBaseContour()->GetPosibleSelected()  );
303                 _manViewBaseCont2->SetPosibleSelected  (  GetManualViewBaseContour()->GetPosibleSelected()  );
304                 _manViewBaseCont3->SetPosibleSelected  (  GetManualViewBaseContour()->GetPosibleSelected()  );
305
306                 _manViewBaseCont1->Refresh();
307                 _manViewBaseCont2->Refresh();
308                 _manViewBaseCont3->Refresh();
309
310                 this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
311         }
312 */
313         this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
314
315 }
316
317 // ----------------------------------------------------------------------------
318 void manualContour3VControler::MouseMove(int x, int y) // virtual
319 {
320         manualContourControler::MouseMove( x , y );
321         int id=GetManualViewBaseContour()->GetIdPoint(x,y,GetZ());
322         MouseMove_Others( id );
323 }
324
325 // ----------------------------------------------------------------------------
326 void manualContour3VControler::OnChar_Others()
327 {
328         manualViewBaseContour *mvbc;
329         int i,size=this->_lstManualViewBaseContour.size();
330         for ( i = 0 ; i < size ; i++ )
331         {
332                 mvbc = _lstManualViewBaseContour[i];
333                 mvbc->Refresh();
334         }
335 // EEDhh
336 /*
337                 _manViewBaseCont1->Refresh();
338                 _manViewBaseCont2->Refresh();
339                 _manViewBaseCont3->Refresh();
340 */
341         this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
342 }
343 // ----------------------------------------------------------------------------
344 bool manualContour3VControler::OnChar()
345 {
346         manualContourControler::OnChar();
347         OnChar_Others();
348         return true;
349 }
350 // ----------------------------------------------------------------------------
351 void manualContour3VControler::ResetContour() // virtual
352 {
353         manualContourControler::ResetContour();
354         ResetContour_Others();
355 }
356
357 // ----------------------------------------------------------------------------
358 void manualContour3VControler::ResetContour_Others()
359 {
360         manualViewBaseContour *mvbc;
361         int i,size=this->_lstManualViewBaseContour.size();
362         for ( i = 0 ; i < size ; i++ )
363         {
364                 mvbc = _lstManualViewBaseContour[i];
365                 mvbc->DeleteContour();
366                 mvbc->CreateNewContour();
367         }
368
369 // EEDhh
370 /*
371         _manViewBaseCont1->DeleteContour();
372         _manViewBaseCont2->DeleteContour();
373         _manViewBaseCont3->DeleteContour();
374         _manViewBaseCont1->CreateNewContour();
375         _manViewBaseCont2->CreateNewContour();
376         _manViewBaseCont3->CreateNewContour();
377 */
378 }
379