]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.cxx
20a8c38c47c4a4376e437d61cda7e4014a99a982
[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 //----------------------------------------------------------------------------
76 void ColorLayerImageViewManager::SetX2(int x2)  
77 {
78   int i, size=_colorLayerImageViewLst.size();
79   for (i=0;i<size;i++)
80   {
81         if (_colorLayerImageViewLst[i]!=NULL)
82         {
83            _colorLayerImageViewLst[i]->SetX2( x2 );
84         } // if 
85   } // for 
86 }
87
88 //----------------------------------------------------------------------------
89 void ColorLayerImageViewManager::SetY2(int y2)  
90 {
91   int i, size=_colorLayerImageViewLst.size();
92   for (i=0;i<size;i++)
93   {
94         if (_colorLayerImageViewLst[i]!=NULL)
95         {
96            _colorLayerImageViewLst[i]->SetY2( y2 );
97         } // if 
98   } // for 
99
100 }
101
102 //----------------------------------------------------------------------------
103 void ColorLayerImageViewManager::SetZ2(int z2)  
104 {
105   int i, size=_colorLayerImageViewLst.size();
106   for (i=0;i<size;i++)
107   {
108         if (_colorLayerImageViewLst[i]!=NULL)
109         {
110            _colorLayerImageViewLst[i]->SetZ2( z2 );
111         } // if 
112   } // for 
113
114 }
115
116
117
118 //----------------------------------------------------------------------------
119 int ColorLayerImageViewManager::GetX()
120 {
121   int result;
122   int i, size=_colorLayerImageViewLst.size();
123   for (i=0;i<size;i++)
124   {
125         if (_colorLayerImageViewLst[i]!=NULL)
126         {
127            result = _colorLayerImageViewLst[i]->GetX();
128         } // if 
129   } // for 
130   return result;
131 }
132
133 //----------------------------------------------------------------------------
134 int ColorLayerImageViewManager::GetY()
135 {
136   int result;
137   int i, size=_colorLayerImageViewLst.size();
138   for (i=0;i<size;i++)
139   {
140         if (_colorLayerImageViewLst[i]!=NULL)
141         {
142            result = _colorLayerImageViewLst[i]->GetY();
143         } // if 
144   } // for 
145   return result;
146 }
147
148
149
150 //----------------------------------------------------------------------------
151 int ColorLayerImageViewManager::GetZ() // virtual 
152 {
153   int result;
154   int i, size=_colorLayerImageViewLst.size();
155   for (i=0;i<size;i++)
156   {
157         if (_colorLayerImageViewLst[i]!=NULL)
158         {
159            result = _colorLayerImageViewLst[i]->GetZ();
160         } // if 
161   } // for 
162   return result;
163 }
164
165 //----------------------------------------------------------------------------
166 void ColorLayerImageViewManager::SetBaseColors(std::vector<double> & base_color)
167 {
168   int i, size=_colorLayerImageViewLst.size();
169   for (i=0;i<size;i++)
170   {
171         if (_colorLayerImageViewLst[i]!=NULL)
172         {
173            _colorLayerImageViewLst[i]->SetBaseColors( base_color );
174         } // if 
175   } // for 
176 }
177
178 //----------------------------------------------------------------------------
179 void ColorLayerImageViewManager::SetBaseTransparence(std::vector<double> & base_transparence)
180 {
181   int i, size=_colorLayerImageViewLst.size();
182   for (i=0;i<size;i++)
183   {
184         if (_colorLayerImageViewLst[i]!=NULL)
185         {
186            _colorLayerImageViewLst[i]->SetBaseTransparence( base_transparence );
187         } // if 
188   } // for 
189 }
190
191 //----------------------------------------------------------------------------
192 void ColorLayerImageViewManager::SetRangeForColorBar(std::vector<double> &range)
193 {
194   int i, size=_colorLayerImageViewLst.size();
195   for (i=0;i<size;i++)
196   {
197         if (_colorLayerImageViewLst[i]!=NULL)
198         {
199            _colorLayerImageViewLst[i]->SetRangeForColorBar( range );
200         } // if 
201   } // for 
202 }
203
204
205
206 //----------------------------------------------------------------------------
207 double ColorLayerImageViewManager::GetBaseColors(unsigned int index)
208 {
209   double result;
210   int i, size=_colorLayerImageViewLst.size();
211   for (i=0;i<size;i++)
212   {
213         if (_colorLayerImageViewLst[i]!=NULL)
214         {
215            result = _colorLayerImageViewLst[i]->GetBaseColors( index );
216         } // if 
217   } // for 
218   return result;
219 }
220
221 //----------------------------------------------------------------------------
222 void ColorLayerImageViewManager::SetGreyLevelBoundaries(std::vector<double> & grey_level_boundary)
223 {
224   int i, size=_colorLayerImageViewLst.size();
225   for (i=0;i<size;i++)
226   {
227         if (_colorLayerImageViewLst[i]!=NULL)
228         {
229            _colorLayerImageViewLst[i]->SetGreyLevelBoundaries( grey_level_boundary );
230         } // if 
231   } // for 
232 }
233
234 //----------------------------------------------------------------------------
235 double ColorLayerImageViewManager::GetGreyLevelBoundaries(unsigned int index)
236 {  
237   double result;
238   int i, size=_colorLayerImageViewLst.size();
239   for (i=0;i<size;i++)
240   {
241         if (_colorLayerImageViewLst[i]!=NULL)
242         {
243            result = _colorLayerImageViewLst[i]->GetGreyLevelBoundaries( index );
244         } // if 
245   } // for 
246   return result;
247 }
248
249 //----------------------------------------------------------------------------
250 void ColorLayerImageViewManager::SetPlainOrGradientColor(bool color_type)
251 {
252   int i, size=_colorLayerImageViewLst.size();
253   for (i=0;i<size;i++)
254   {
255         if (_colorLayerImageViewLst[i]!=NULL)
256         {
257            _colorLayerImageViewLst[i]->SetPlainOrGradientColor( color_type );
258         } // if 
259   } // for 
260
261
262 //----------------------------------------------------------------------------
263 int ColorLayerImageViewManager::GetBaseColorNb()
264 {
265   int result;
266   int i, size=_colorLayerImageViewLst.size();
267   for (i=0;i<size;i++)
268   {
269         if (_colorLayerImageViewLst[i]!=NULL)
270         {
271            result = _colorLayerImageViewLst[i]->GetBaseColorNb();
272         } // if 
273   } // for 
274   return result;
275 }
276
277 //----------------------------------------------------------------------------
278 void ColorLayerImageViewManager::Refresh()
279 {
280   int i, size=_colorLayerImageViewLst.size();
281   for (i=0;i<size;i++)
282   {
283         if (_colorLayerImageViewLst[i]!=NULL)
284         {
285            _colorLayerImageViewLst[i]->Refresh();
286         } // if 
287   } // for 
288 }
289
290 //----------------------------------------------------------------------------
291 void ColorLayerImageViewManager::onThreshold()
292 {
293   int i, size=_colorLayerImageViewLst.size();
294   for (i=0;i<size;i++)
295   {
296         if (_colorLayerImageViewLst[i]!=NULL)
297         {
298            _colorLayerImageViewLst[i]->onThreshold();
299         } // if 
300   } // for 
301 }
302
303 //----------------------------------------------------------------------------
304 void ColorLayerImageViewManager::onThresholdChange()
305 {
306   int i, size=_colorLayerImageViewLst.size();
307   for (i=0;i<size;i++)
308   {
309         if (_colorLayerImageViewLst[i]!=NULL)
310         {
311            _colorLayerImageViewLst[i]->onThresholdChange();
312         } // if 
313   } // for 
314 }
315
316 //----------------------------------------------------------------------------
317 void ColorLayerImageViewManager::onThresholdRemove()
318 {
319   int i, size=_colorLayerImageViewLst.size();
320   for (i=0;i<size;i++)
321   {
322         if (_colorLayerImageViewLst[i]!=NULL)
323         {
324            _colorLayerImageViewLst[i]->onThresholdRemove();
325         } // if 
326   } // for 
327 }
328
329 //----------------------------------------------------------------------------
330 void ColorLayerImageViewManager::onThresholdInterpolation(bool interpolation)
331 {
332   int i, size=_colorLayerImageViewLst.size();
333   for (i=0;i<size;i++)
334   {
335         if (_colorLayerImageViewLst[i]!=NULL)
336         {
337            _colorLayerImageViewLst[i]->onThresholdInterpolation( interpolation );
338         } // if 
339   } // for 
340 }
341
342 //----------------------------------------------------------------------------
343 void ColorLayerImageViewManager::SetSliceFixDynamic( bool fixdyn )
344 {
345   int i, size=_colorLayerImageViewLst.size();
346   for (i=0;i<size;i++)
347   {
348         if (_colorLayerImageViewLst[i]!=NULL)
349         {
350            _colorLayerImageViewLst[i]->SetSliceFixDynamic( fixdyn );
351         } // if 
352   } // for 
353 }
354
355 //----------------------------------------------------------------------------
356 void ColorLayerImageViewManager::onThresholdChangeOpacity( int opacity)
357 {
358   int i, size=_colorLayerImageViewLst.size();
359   for (i=0;i<size;i++)
360   {
361         if (_colorLayerImageViewLst[i]!=NULL)
362         {
363            _colorLayerImageViewLst[i]->onThresholdChangeOpacity( opacity );
364         } // if 
365   } // for 
366 }
367
368 //----------------------------------------------------------------------------
369 void ColorLayerImageViewManager::SetImage(  vtkImageData* img  )
370 {
371   int i, size=_colorLayerImageViewLst.size();
372   for (i=0;i<size;i++)
373   {
374         if (_colorLayerImageViewLst[i]!=NULL)
375         {
376            _colorLayerImageViewLst[i]->SetImage( img );
377         } // if 
378   } // for 
379 }
380
381 // EOF
382