]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewManager.cxx
2e5b403247f113bab6b143bce9b1baf49402698e
[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 double ColorLayerImageViewManager::GetBaseColors(unsigned int index)
180 {
181   double result;
182   int i, size=_colorLayerImageViewLst.size();
183   for (i=0;i<size;i++)
184   {
185         if (_colorLayerImageViewLst[i]!=NULL)
186         {
187            result = _colorLayerImageViewLst[i]->GetBaseColors( index );
188         } // if 
189   } // for 
190   return result;
191 }
192
193 //----------------------------------------------------------------------------
194 void ColorLayerImageViewManager::SetGreyLevelBoundaries(std::vector<double> & grey_level_boundary)
195 {
196   int i, size=_colorLayerImageViewLst.size();
197   for (i=0;i<size;i++)
198   {
199         if (_colorLayerImageViewLst[i]!=NULL)
200         {
201            _colorLayerImageViewLst[i]->SetGreyLevelBoundaries( grey_level_boundary );
202         } // if 
203   } // for 
204 }
205
206 //----------------------------------------------------------------------------
207 double ColorLayerImageViewManager::GetGreyLevelBoundaries(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]->GetGreyLevelBoundaries( index );
216         } // if 
217   } // for 
218   return result;
219 }
220
221 //----------------------------------------------------------------------------
222 void ColorLayerImageViewManager::SetPlainOrGradientColor(bool color_type)
223 {
224   int i, size=_colorLayerImageViewLst.size();
225   for (i=0;i<size;i++)
226   {
227         if (_colorLayerImageViewLst[i]!=NULL)
228         {
229            _colorLayerImageViewLst[i]->SetPlainOrGradientColor( color_type );
230         } // if 
231   } // for 
232
233
234 //----------------------------------------------------------------------------
235 int ColorLayerImageViewManager::GetBaseColorNb()
236 {
237   int 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]->GetBaseColorNb();
244         } // if 
245   } // for 
246   return result;
247 }
248
249 //----------------------------------------------------------------------------
250 void ColorLayerImageViewManager::Refresh()
251 {
252   int i, size=_colorLayerImageViewLst.size();
253   for (i=0;i<size;i++)
254   {
255         if (_colorLayerImageViewLst[i]!=NULL)
256         {
257            _colorLayerImageViewLst[i]->Refresh();
258         } // if 
259   } // for 
260 }
261
262 //----------------------------------------------------------------------------
263 void ColorLayerImageViewManager::onThreshold()
264 {
265   int i, size=_colorLayerImageViewLst.size();
266   for (i=0;i<size;i++)
267   {
268         if (_colorLayerImageViewLst[i]!=NULL)
269         {
270            _colorLayerImageViewLst[i]->onThreshold();
271         } // if 
272   } // for 
273 }
274
275 //----------------------------------------------------------------------------
276 void ColorLayerImageViewManager::onThresholdChange()
277 {
278   int i, size=_colorLayerImageViewLst.size();
279   for (i=0;i<size;i++)
280   {
281         if (_colorLayerImageViewLst[i]!=NULL)
282         {
283            _colorLayerImageViewLst[i]->onThresholdChange();
284         } // if 
285   } // for 
286 }
287
288 //----------------------------------------------------------------------------
289 void ColorLayerImageViewManager::onThresholdRemove()
290 {
291   int i, size=_colorLayerImageViewLst.size();
292   for (i=0;i<size;i++)
293   {
294         if (_colorLayerImageViewLst[i]!=NULL)
295         {
296            _colorLayerImageViewLst[i]->onThresholdRemove();
297         } // if 
298   } // for 
299 }
300
301 //----------------------------------------------------------------------------
302 void ColorLayerImageViewManager::onThresholdInterpolation(bool interpolation)
303 {
304   int i, size=_colorLayerImageViewLst.size();
305   for (i=0;i<size;i++)
306   {
307         if (_colorLayerImageViewLst[i]!=NULL)
308         {
309            _colorLayerImageViewLst[i]->onThresholdInterpolation( interpolation );
310         } // if 
311   } // for 
312 }
313
314 //----------------------------------------------------------------------------
315 void ColorLayerImageViewManager::SetSliceFixDynamic( bool fixdyn )
316 {
317   int i, size=_colorLayerImageViewLst.size();
318   for (i=0;i<size;i++)
319   {
320         if (_colorLayerImageViewLst[i]!=NULL)
321         {
322            _colorLayerImageViewLst[i]->SetSliceFixDynamic( fixdyn );
323         } // if 
324   } // for 
325 }
326
327 //----------------------------------------------------------------------------
328 void ColorLayerImageViewManager::onThresholdChangeOpacity( int opacity)
329 {
330   int i, size=_colorLayerImageViewLst.size();
331   for (i=0;i<size;i++)
332   {
333         if (_colorLayerImageViewLst[i]!=NULL)
334         {
335            _colorLayerImageViewLst[i]->onThresholdChangeOpacity( opacity );
336         } // if 
337   } // for 
338 }
339
340 //----------------------------------------------------------------------------
341 void ColorLayerImageViewManager::SetImage(  vtkImageData* img  )
342 {
343   int i, size=_colorLayerImageViewLst.size();
344   for (i=0;i<size;i++)
345   {
346         if (_colorLayerImageViewLst[i]!=NULL)
347         {
348            _colorLayerImageViewLst[i]->SetImage( img );
349         } // if 
350   } // for 
351 }
352
353 // EOF
354