]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.cxx
b478c254c48bb109c184e5798fddb794cccf214b
[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
212 //----------------------------------------------------------------------------
213 double ColorLayerImageViewManager::GetBaseColors(unsigned int index)
214 {
215   double result;
216   int i, size=_colorLayerImageViewLst.size();
217   for (i=0;i<size;i++)
218   {
219         if (_colorLayerImageViewLst[i]!=NULL)
220         {
221            result = _colorLayerImageViewLst[i]->GetBaseColors( index );
222         } // if 
223   } // for 
224   return result;
225 }
226
227 //----------------------------------------------------------------------------
228 void ColorLayerImageViewManager::SetGreyLevelBoundaries(std::vector<double> & grey_level_boundary)
229 {
230   int i, size=_colorLayerImageViewLst.size();
231   for (i=0;i<size;i++)
232   {
233         if (_colorLayerImageViewLst[i]!=NULL)
234         {
235            _colorLayerImageViewLst[i]->SetGreyLevelBoundaries( grey_level_boundary );
236         } // if 
237   } // for 
238 }
239
240 //----------------------------------------------------------------------------
241 double ColorLayerImageViewManager::GetGreyLevelBoundaries(unsigned int index)
242 {  
243   double result;
244   int i, size=_colorLayerImageViewLst.size();
245   for (i=0;i<size;i++)
246   {
247         if (_colorLayerImageViewLst[i]!=NULL)
248         {
249            result = _colorLayerImageViewLst[i]->GetGreyLevelBoundaries( index );
250         } // if 
251   } // for 
252   return result;
253 }
254
255 //----------------------------------------------------------------------------
256 void ColorLayerImageViewManager::SetPlainOrGradientColor(bool color_type)
257 {
258   int i, size=_colorLayerImageViewLst.size();
259   for (i=0;i<size;i++)
260   {
261         if (_colorLayerImageViewLst[i]!=NULL)
262         {
263            _colorLayerImageViewLst[i]->SetPlainOrGradientColor( color_type );
264         } // if 
265   } // for 
266
267
268 //----------------------------------------------------------------------------
269 int ColorLayerImageViewManager::GetBaseColorNb()
270 {
271   int result;
272   int i, size=_colorLayerImageViewLst.size();
273   for (i=0;i<size;i++)
274   {
275         if (_colorLayerImageViewLst[i]!=NULL)
276         {
277            result = _colorLayerImageViewLst[i]->GetBaseColorNb();
278         } // if 
279   } // for 
280   return result;
281 }
282
283 //----------------------------------------------------------------------------
284 void ColorLayerImageViewManager::Refresh()
285 {
286   int i, size=_colorLayerImageViewLst.size();
287   for (i=0;i<size;i++)
288   {
289         if (_colorLayerImageViewLst[i]!=NULL)
290         {
291            _colorLayerImageViewLst[i]->Refresh();
292         } // if 
293   } // for 
294 }
295
296 //----------------------------------------------------------------------------
297 void ColorLayerImageViewManager::onThreshold()
298 {
299   int i, size=_colorLayerImageViewLst.size();
300   for (i=0;i<size;i++)
301   {
302         if (_colorLayerImageViewLst[i]!=NULL)
303         {
304            _colorLayerImageViewLst[i]->onThreshold();
305         } // if 
306   } // for 
307 }
308
309 //----------------------------------------------------------------------------
310 void ColorLayerImageViewManager::onThresholdChange()
311 {
312   int i, size=_colorLayerImageViewLst.size();
313   for (i=0;i<size;i++)
314   {
315         if (_colorLayerImageViewLst[i]!=NULL)
316         {
317            _colorLayerImageViewLst[i]->onThresholdChange();
318         } // if 
319   } // for 
320 }
321
322 //----------------------------------------------------------------------------
323 void ColorLayerImageViewManager::onThresholdRemove()
324 {
325   int i, size=_colorLayerImageViewLst.size();
326   for (i=0;i<size;i++)
327   {
328         if (_colorLayerImageViewLst[i]!=NULL)
329         {
330            _colorLayerImageViewLst[i]->onThresholdRemove();
331         } // if 
332   } // for 
333 }
334
335 //----------------------------------------------------------------------------
336 void ColorLayerImageViewManager::onThresholdInterpolation(bool interpolation)
337 {
338   int i, size=_colorLayerImageViewLst.size();
339   for (i=0;i<size;i++)
340   {
341         if (_colorLayerImageViewLst[i]!=NULL)
342         {
343            _colorLayerImageViewLst[i]->onThresholdInterpolation( interpolation );
344         } // if 
345   } // for 
346 }
347
348 //----------------------------------------------------------------------------
349 void ColorLayerImageViewManager::SetSliceFixDynamic( bool fixdyn )
350 {
351   int i, size=_colorLayerImageViewLst.size();
352   for (i=0;i<size;i++)
353   {
354         if (_colorLayerImageViewLst[i]!=NULL)
355         {
356            _colorLayerImageViewLst[i]->SetSliceFixDynamic( fixdyn );
357         } // if 
358   } // for 
359 }
360
361 //----------------------------------------------------------------------------
362 void ColorLayerImageViewManager::onThresholdChangeOpacity( int opacity)
363 {
364   int i, size=_colorLayerImageViewLst.size();
365   for (i=0;i<size;i++)
366   {
367         if (_colorLayerImageViewLst[i]!=NULL)
368         {
369            _colorLayerImageViewLst[i]->onThresholdChangeOpacity( opacity );
370         } // if 
371   } // for 
372 }
373
374 //----------------------------------------------------------------------------
375 void ColorLayerImageViewManager::SetImage(  vtkImageData* img  )
376 {
377   int i, size=_colorLayerImageViewLst.size();
378   for (i=0;i<size;i++)
379   {
380         if (_colorLayerImageViewLst[i]!=NULL)
381         {
382            _colorLayerImageViewLst[i]->SetImage( img );
383         } // if 
384   } // for 
385 }
386
387 // EOF
388