]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.cxx
8fdaa7c2b4a53befbf1fc84cdeac8e8ea0bfef25
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / ThresholdImageView / ColorLayerImageViewManager.cxx
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 /**
27  *  \file 
28  *  \author Eduardo Davila and Claire Mouton.
29  *  \brief Class bbtk::ThresholdImageView. 
30  *  \date September 2012
31  */
32
33 #include "ColorLayerImageViewManager.h"
34
35
36
37 //=========================================================================
38 //=========================================================================
39 //=========================================================================
40 //=========================================================================
41 ColorLayerImageViewManager::ColorLayerImageViewManager( )
42 {
43         _colorLayerImageViewLst.push_back(NULL);  // 0
44         _colorLayerImageViewLst.push_back(NULL);  // 1
45         _colorLayerImageViewLst.push_back(NULL);  // 2
46 }
47
48 //=========================================================================
49 ColorLayerImageViewManager::~ColorLayerImageViewManager()
50 {
51 }
52 //=========================================================================
53
54
55
56 //----------------------------------------------------------------------------
57 void ColorLayerImageViewManager::SetwxVtkBaseView(int id, wxVtkBaseView *baseview)
58 {
59   if (baseview!=NULL)
60   {     
61         int size =_colorLayerImageViewLst.size();
62         if (   (id>=0) && (id<=size) )
63         {
64             if (_colorLayerImageViewLst[id]==NULL)
65             {
66                         _colorLayerImageViewLst[id] = new ColorLayerImageView();
67             }
68                 _colorLayerImageViewLst[id]->SetwxVtkBaseView(baseview);
69         
70         } // if id
71   } // baseview
72 }
73
74
75 wxVtkBaseView*  ColorLayerImageViewManager::GetwxVtkBaseView(int id)
76 {
77         return _colorLayerImageViewLst[id]->GetwxVtkBaseView();
78 }
79
80
81 //----------------------------------------------------------------------------
82 void ColorLayerImageViewManager::SetX2(int x2)  
83 {
84   int i, size=_colorLayerImageViewLst.size();
85   for (i=0;i<size;i++)
86   {
87         if (_colorLayerImageViewLst[i]!=NULL)
88         {
89            _colorLayerImageViewLst[i]->SetX2( x2 );
90         } // if 
91   } // for 
92 }
93
94 //----------------------------------------------------------------------------
95 void ColorLayerImageViewManager::SetY2(int y2)  
96 {
97   int i, size=_colorLayerImageViewLst.size();
98   for (i=0;i<size;i++)
99   {
100         if (_colorLayerImageViewLst[i]!=NULL)
101         {
102            _colorLayerImageViewLst[i]->SetY2( y2 );
103         } // if 
104   } // for 
105
106 }
107
108 //----------------------------------------------------------------------------
109 void ColorLayerImageViewManager::SetZ2(int z2)  
110 {
111   int i, size=_colorLayerImageViewLst.size();
112   for (i=0;i<size;i++)
113   {
114         if (_colorLayerImageViewLst[i]!=NULL)
115         {
116            _colorLayerImageViewLst[i]->SetZ2( z2 );
117         } // if 
118   } // for 
119
120 }
121
122
123
124 //----------------------------------------------------------------------------
125 int ColorLayerImageViewManager::GetX()
126 {
127   int result;
128   int i, size=_colorLayerImageViewLst.size();
129   for (i=0;i<size;i++)
130   {
131         if (_colorLayerImageViewLst[i]!=NULL)
132         {
133            result = _colorLayerImageViewLst[i]->GetX();
134         } // if 
135   } // for 
136   return result;
137 }
138
139 //----------------------------------------------------------------------------
140 int ColorLayerImageViewManager::GetY()
141 {
142   int result;
143   int i, size=_colorLayerImageViewLst.size();
144   for (i=0;i<size;i++)
145   {
146         if (_colorLayerImageViewLst[i]!=NULL)
147         {
148            result = _colorLayerImageViewLst[i]->GetY();
149         } // if 
150   } // for 
151   return result;
152 }
153
154
155
156 //----------------------------------------------------------------------------
157 int ColorLayerImageViewManager::GetZ() // virtual 
158 {
159   int result;
160   int i, size=_colorLayerImageViewLst.size();
161   for (i=0;i<size;i++)
162   {
163         if (_colorLayerImageViewLst[i]!=NULL)
164         {
165            result = _colorLayerImageViewLst[i]->GetZ();
166         } // if 
167   } // for 
168   return result;
169 }
170
171 //----------------------------------------------------------------------------
172 void ColorLayerImageViewManager::SetBaseColors(std::vector<double> & base_color)
173 {
174   int i, size=_colorLayerImageViewLst.size();
175   for (i=0;i<size;i++)
176   {
177         if (_colorLayerImageViewLst[i]!=NULL)
178         {
179            _colorLayerImageViewLst[i]->SetBaseColors( base_color );
180         } // if 
181   } // for 
182 }
183
184 //----------------------------------------------------------------------------
185 void ColorLayerImageViewManager::SetBaseTransparence(std::vector<double> & base_transparence)
186 {
187   int i, size=_colorLayerImageViewLst.size();
188   for (i=0;i<size;i++)
189   {
190         if (_colorLayerImageViewLst[i]!=NULL)
191         {
192            _colorLayerImageViewLst[i]->SetBaseTransparence( base_transparence );
193         } // if 
194   } // for 
195 }
196
197 //----------------------------------------------------------------------------
198 void ColorLayerImageViewManager::SetRangeForColorBar(std::vector<double> &range)
199 {
200   int i, size=_colorLayerImageViewLst.size();
201   for (i=0;i<size;i++)
202   {
203         if (_colorLayerImageViewLst[i]!=NULL)
204         {
205            _colorLayerImageViewLst[i]->SetRangeForColorBar( range );
206         } // if 
207   } // for 
208 }
209
210 //----------------------------------------------------------------------------
211 void ColorLayerImageViewManager::SetColorBarPosition(std::vector<int> &colorbarposition)
212 {
213   int i, size=_colorLayerImageViewLst.size();
214   for (i=0;i<size;i++)
215   {
216         if (_colorLayerImageViewLst[i]!=NULL)
217         {
218            _colorLayerImageViewLst[i]->SetColorBarPosition( colorbarposition );
219         } // if 
220   } // for 
221 }
222
223
224
225
226 //----------------------------------------------------------------------------
227 double ColorLayerImageViewManager::GetBaseColors(unsigned int index)
228 {
229   double result;
230   int i, size=_colorLayerImageViewLst.size();
231   for (i=0;i<size;i++)
232   {
233         if (_colorLayerImageViewLst[i]!=NULL)
234         {
235            result = _colorLayerImageViewLst[i]->GetBaseColors( index );
236         } // if 
237   } // for 
238   return result;
239 }
240
241 //----------------------------------------------------------------------------
242 void ColorLayerImageViewManager::SetGreyLevelBoundaries(std::vector<double> & grey_level_boundary)
243 {
244   int i, size=_colorLayerImageViewLst.size();
245   for (i=0;i<size;i++)
246   {
247         if (_colorLayerImageViewLst[i]!=NULL)
248         {
249            _colorLayerImageViewLst[i]->SetGreyLevelBoundaries( grey_level_boundary );
250         } // if 
251   } // for 
252 }
253
254 //----------------------------------------------------------------------------
255 double ColorLayerImageViewManager::GetGreyLevelBoundaries(unsigned int index)
256 {  
257   double result;
258   int i, size=_colorLayerImageViewLst.size();
259   for (i=0;i<size;i++)
260   {
261         if (_colorLayerImageViewLst[i]!=NULL)
262         {
263            result = _colorLayerImageViewLst[i]->GetGreyLevelBoundaries( index );
264         } // if 
265   } // for 
266   return result;
267 }
268
269 //----------------------------------------------------------------------------
270 void ColorLayerImageViewManager::SetPlainOrGradientColor(bool color_type)
271 {
272   int i, size=_colorLayerImageViewLst.size();
273   for (i=0;i<size;i++)
274   {
275         if (_colorLayerImageViewLst[i]!=NULL)
276         {
277            _colorLayerImageViewLst[i]->SetPlainOrGradientColor( color_type );
278         } // if 
279   } // for 
280
281
282 //----------------------------------------------------------------------------
283 int ColorLayerImageViewManager::GetBaseColorNb()
284 {
285   int result;
286   int i, size=_colorLayerImageViewLst.size();
287   for (i=0;i<size;i++)
288   {
289         if (_colorLayerImageViewLst[i]!=NULL)
290         {
291            result = _colorLayerImageViewLst[i]->GetBaseColorNb();
292         } // if 
293   } // for 
294   return result;
295 }
296
297 //----------------------------------------------------------------------------
298 void ColorLayerImageViewManager::Refresh()
299 {
300   int i, size=_colorLayerImageViewLst.size();
301   for (i=0;i<size;i++)
302   {
303         if (_colorLayerImageViewLst[i]!=NULL)
304         {
305            _colorLayerImageViewLst[i]->Refresh();
306         } // if 
307   } // for 
308 }
309
310 //----------------------------------------------------------------------------
311 void ColorLayerImageViewManager::onThreshold()
312 {
313   int i, size=_colorLayerImageViewLst.size();
314   for (i=0;i<size;i++)
315   {
316         if (_colorLayerImageViewLst[i]!=NULL)
317         {
318            _colorLayerImageViewLst[i]->onThreshold();
319         } // if 
320   } // for 
321 }
322
323 //----------------------------------------------------------------------------
324 void ColorLayerImageViewManager::onThresholdChange()
325 {
326   int i, size=_colorLayerImageViewLst.size();
327   for (i=0;i<size;i++)
328   {
329         if (_colorLayerImageViewLst[i]!=NULL)
330         {
331            _colorLayerImageViewLst[i]->onThresholdChange();
332         } // if 
333   } // for 
334 }
335
336 //----------------------------------------------------------------------------
337 void ColorLayerImageViewManager::onThresholdRemove()
338 {
339   int i, size=_colorLayerImageViewLst.size();
340   for (i=0;i<size;i++)
341   {
342         if (_colorLayerImageViewLst[i]!=NULL)
343         {
344            _colorLayerImageViewLst[i]->onThresholdRemove();
345         } // if 
346   } // for 
347 }
348
349 //----------------------------------------------------------------------------
350 void ColorLayerImageViewManager::onThresholdInterpolation(bool interpolation)
351 {
352   int i, size=_colorLayerImageViewLst.size();
353   for (i=0;i<size;i++)
354   {
355         if (_colorLayerImageViewLst[i]!=NULL)
356         {
357            _colorLayerImageViewLst[i]->onThresholdInterpolation( interpolation );
358         } // if 
359   } // for 
360 }
361
362 //----------------------------------------------------------------------------
363 void ColorLayerImageViewManager::SetSliceFixDynamic( bool fixdyn )
364 {
365   int i, size=_colorLayerImageViewLst.size();
366   for (i=0;i<size;i++)
367   {
368         if (_colorLayerImageViewLst[i]!=NULL)
369         {
370            _colorLayerImageViewLst[i]->SetSliceFixDynamic( fixdyn );
371         } // if 
372   } // for 
373 }
374
375 //----------------------------------------------------------------------------
376 void ColorLayerImageViewManager::onThresholdChangeOpacity( int opacity)
377 {
378   int i, size=_colorLayerImageViewLst.size();
379   for (i=0;i<size;i++)
380   {
381         if (_colorLayerImageViewLst[i]!=NULL)
382         {
383            _colorLayerImageViewLst[i]->onThresholdChangeOpacity( opacity );
384         } // if 
385   } // for 
386 }
387
388 //----------------------------------------------------------------------------
389 void ColorLayerImageViewManager::SetImage(  vtkImageData* img  )
390 {
391   int i, size=_colorLayerImageViewLst.size();
392   for (i=0;i<size;i++)
393   {
394         if (_colorLayerImageViewLst[i]!=NULL)
395         {
396            _colorLayerImageViewLst[i]->SetImage( img );
397         } // if 
398   } // for 
399 }
400
401 //----------------------------------------------------------------------------
402 vtkImageData* ColorLayerImageViewManager::GetImageChangeInformation(int id)
403 {
404         if (_colorLayerImageViewLst[id]!=NULL)
405         {
406            return _colorLayerImageViewLst[id]->GetImage( );
407         } // if 
408         return NULL;
409 }
410
411 //----------------------------------------------------------------------------
412 void ColorLayerImageViewManager::GetDimensionBase(int id,int *dim)
413 {
414         if (_colorLayerImageViewLst[id]!=NULL)
415         {
416            _colorLayerImageViewLst[id]->GetDimensionBase( dim );
417         } // if 
418 }
419
420 //----------------------------------------------------------------------------
421 void ColorLayerImageViewManager::GetSpcBase(int id,double *spc)
422 {
423         if (_colorLayerImageViewLst[id]!=NULL)
424         {
425            _colorLayerImageViewLst[id]->GetSpcBase( spc );
426         } // if 
427 }
428
429 //----------------------------------------------------------------------------
430 void ColorLayerImageViewManager::GetDimensionOriginalLayer(int id,int *dim)
431 {
432         if (_colorLayerImageViewLst[id]!=NULL)
433         {
434            _colorLayerImageViewLst[id]->GetDimensionOriginalLayer( dim );
435         } // if 
436 }
437
438 //----------------------------------------------------------------------------
439 void ColorLayerImageViewManager::GetSpcOriginalLayer(int id,double *spc)
440 {
441         if (_colorLayerImageViewLst[id]!=NULL)
442         {
443            _colorLayerImageViewLst[id]->GetSpcOriginalLayer( spc );
444         } // if 
445 }
446
447 //----------------------------------------------------------------------------
448 //----------------------------------------------------------------------------
449 void ColorLayerImageViewManager::SetNewSpacingLayer(double *spc)
450 {
451   int i, size=_colorLayerImageViewLst.size();
452   for (i=0;i<size;i++)
453   {
454         if (_colorLayerImageViewLst[i]!=NULL)
455         {
456            _colorLayerImageViewLst[i]->SetNewSpacingLayer( spc );
457         } // if 
458   } // for 
459 }
460
461
462
463 // EOF
464