]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx
#2864 creaMaracasVisu Feature New Normal - Manual Paint , modifies external image...
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / ThresholdImageView / ColorLayerImageViewPanel.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  *  \brief ClassThresholdImageViewPanel .
29  */
30
31
32 #include "ColorLayerImageViewPanel.h"
33 #include "OpenImageDialog.h"
34 #include <wx/string.h>
35
36 //---------------------------------------------------------
37 //---------------------------------------------------------
38 //---------------------------------------------------------
39
40 wxDlgTransformByDimensionBySpacingByPixel::wxDlgTransformByDimensionBySpacingByPixel()
41 {
42 }
43
44 wxDlgTransformByDimensionBySpacingByPixel::~wxDlgTransformByDimensionBySpacingByPixel()
45 {
46 }
47
48
49 void wxDlgTransformByDimensionBySpacingByPixel::GetTransformType(
50                                                                         wxWindow *parent , 
51                                                                         double baseSpc[3],
52                                                                         double layerSpc[3],
53                                                                         int baseDim[3],
54                                                                         int layerDim[3],
55                                                                         wxString message,
56                                                                         int &typeOfTransformation,
57                                                                         bool &dlgWxOK)
58 {
59         wxDialog* dial                  = new wxDialog (parent,-1,_T("Tools"),wxDefaultPosition, wxSize(500,550),wxRESIZE_BORDER);
60         wxSizer* buttonsSizer   = dial->CreateSeparatedButtonSizer(wxOK|wxCANCEL);
61         wxBoxSizer *dialSizer   = new wxBoxSizer(wxVERTICAL);
62
63         wxString lstOptOperation[3];
64         lstOptOperation[0]=_T("By Dimension");
65         lstOptOperation[1]=_T("By Spacing");
66         lstOptOperation[2]=_T("By Pixel");
67         wxRadioBox * radioOpts = new wxRadioBox(dial, -1, _T("Type of Transformation"), wxDefaultPosition, wxSize(250,90), 3 , lstOptOperation,  3, wxRA_SPECIFY_COLS);
68
69         wxString str;
70         wxString strBaseSpc(str);
71         wxString strLayerSpc;
72         wxString strBaseDim;
73         wxString strLayerDim;
74
75         strBaseSpc.Printf(wxT("Base spacing: %f %f %f"), baseSpc[0],baseSpc[1],baseSpc[2] );
76         strLayerSpc.Printf(wxT("Layer spacing: %f %f %f"), layerSpc[0],layerSpc[1],layerSpc[2] );
77         strBaseDim.Printf(wxT("Base dimension: %d %d %d"), baseDim[0],baseDim[1],baseDim[2] );
78         strLayerDim.Printf(wxT("Layer dimension: %d %d %d"), layerDim[0],layerDim[1],layerDim[2] );
79
80         dialSizer->Add( new wxStaticText(dial,-1,message                )       , 0, wxGROW );
81         dialSizer->Add( new wxStaticText(dial,-1,_T(" ")                )       , 0, wxGROW );
82         dialSizer->Add( new wxStaticText(dial,-1, strBaseSpc    )       , 0, wxGROW );
83         dialSizer->Add( new wxStaticText(dial,-1, strLayerSpc   )       , 0, wxGROW );
84         dialSizer->Add( new wxStaticText(dial,-1,_T(" ")                )       , 0, wxGROW );
85         dialSizer->Add( new wxStaticText(dial,-1, strBaseDim    )       , 0, wxGROW );
86         dialSizer->Add( new wxStaticText(dial,-1, strLayerDim   )       , 0, wxGROW );
87         dialSizer->Add( new wxStaticText(dial,-1,_T(" ")                )       , 0, wxGROW );
88         dialSizer->Add( new wxStaticText(dial,-1,message                )       , 0, wxGROW );
89         dialSizer->Add( new wxStaticText(dial,-1,_T(" ")                )       , 0, wxGROW );
90         dialSizer->Add(radioOpts,0,wxGROW);
91         dialSizer->Add( new wxStaticText(dial,-1,_T(" ")                )       , 0, wxGROW );
92         dialSizer->Add(buttonsSizer,0,wxGROW);
93         dial->SetSizer(dialSizer, true);
94         dial->Layout();
95         dial->ShowModal();
96
97         typeOfTransformation    = -1;
98         dlgWxOK                                 = false;
99
100         if (dial->GetReturnCode() == wxID_OK)
101         {
102                 typeOfTransformation    = radioOpts->GetSelection() + 1;
103                 dlgWxOK                                 = true;
104         }
105 }
106
107
108 //---------------------------------------------------------
109 //---------------------------------------------------------
110 //---------------------------------------------------------
111
112
113 /**
114  ** Begin of the threshold panel
115  **/
116 ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, int max, int type)
117 //: wxPanel(parent, -1, wxDefaultPosition, wxSize(600,100), wxBORDER_SUNKEN)
118
119 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
120
121
122 {
123 printf("EED ColorLayerImageViewPanel::ColorLayerImageViewPanel Start\n");
124
125         _spcBase[0] = _spcBase[1] = _spcBase[2] = 0;
126         _dimBase[0] = _dimBase[1] = _dimBase[2] = 0;
127
128         _cb_ShowHide                    = NULL;
129         _sl_SliceImageX                 = NULL;
130         _sl_SliceImageY                 = NULL;
131         _sl_SliceImageZ                 = NULL;
132         _histogram                              = NULL;
133         _histogramMinMaxLevel   = NULL;
134
135         wxFlexGridSizer * sizer         = NULL;
136         _colorLayerImageViewManager     = new ColorLayerImageViewManager();
137
138         if (type==1)
139         {
140                 sizer                                                   = new wxFlexGridSizer(1);
141                 _btn_ReadImage                                  = new wxButton(this, wxID_ANY, _T("Read Image") );
142                 _thresholdGo                                    = true;
143                 _cb_ShowHide                                    = new wxCheckBox(this, wxID_ANY, _T("Show/Hide Layer") );
144                 _cb_ShowHide->SetValue(_thresholdGo);
145                 _cb_SliceFixDinamic                     = new wxCheckBox(this, wxID_ANY, _T("Fixed/Dynamic Slice") );
146                 _cb_SliceFixDinamic->SetValue(true);
147                 _sl_SliceImageX = new wxSlider(this, wxID_ANY, 0, 1000, 1000, 
148                                                                                         wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
149                 _sl_SliceImageY = new wxSlider(this, wxID_ANY, 0, 1000, 1000, 
150                                                                                         wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
151                 _sl_SliceImageZ = new wxSlider(this, wxID_ANY, 0, 1000, 1000, 
152                                                                                         wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
153                 _sl_SliceImageX->Enable(false);
154                 _sl_SliceImageY->Enable(false);
155                 _sl_SliceImageZ->Enable(false);
156                 _interpolationCheckBox = new wxCheckBox(this, -1, _T("Interpole") );
157                 _interpolationCheckBox->SetValue(true);
158                 _opacity = new wxSlider(this, wxID_ANY, 6, 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
159
160         //      _histogram                                      = new Histogram(  this , -1, wxPoint(0,0), wxSize(400,400), /*wxNO_BORDER*/ wxBORDER_DEFAULT ); 
161         //      _histogramMinMaxLevel   = new HistogramMinMaxLevel( (HistogramBase*)_histogram );
162
163                 Connect( _btn_ReadImage->GetId(), wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &ColorLayerImageViewPanel::onReadImage );
164                 Connect( _cb_ShowHide->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED  , (wxObjectEventFunction) &ColorLayerImageViewPanel::onThresholdShow );
165                 Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ColorLayerImageViewPanel::onThresholdInterpolation );
166                 Connect( _opacity->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction) &ColorLayerImageViewPanel::onChangeOpacity );
167                 Connect( _cb_SliceFixDinamic->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceFixDinamic );
168
169                 Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_THUMBTRACK      , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
170                 Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_LINEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
171                 Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_LINEDOWN        , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
172                 Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_PAGEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
173                 Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_PAGEDOWN        , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
174
175                 Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_THUMBTRACK      , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
176                 Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_LINEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
177                 Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_LINEDOWN        , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
178                 Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_PAGEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
179                 Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_PAGEDOWN        , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
180
181                 Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_THUMBTRACK      , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
182                 Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_LINEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
183                 Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_LINEDOWN        , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
184                 Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_PAGEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
185                 Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_PAGEDOWN        , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
186
187                 sizer -> Add( new wxStaticText(this,-1,_T("Color Image Layer"))                 , 1, wxGROW );
188                 sizer -> Add( _btn_ReadImage                                                                                    , 1, wxGROW );
189                 sizer -> Add( new wxStaticText(this,-1,_T(" "))                                                 , 1, wxGROW );
190                 sizer -> Add( new wxStaticText(this,-1,_T("Opacity Level"))                     , 1, wxGROW );
191                 sizer -> Add( _opacity                                                                                                  , 1, wxGROW );
192                 sizer -> Add( new wxStaticText(this,-1,_T(" "))                                                 , 1, wxGROW );
193                 sizer -> Add( _cb_ShowHide                                                                                              , 1, wxGROW );
194                 sizer -> Add( new wxStaticText(this,-1,_T(" "))                                                 , 1, wxGROW );
195                 sizer -> Add( _interpolationCheckBox                                                                    , 1, wxGROW );
196
197                 sizer -> Add( new wxStaticText(this,-1,_T(" "))                                                 , 1, wxGROW );
198                 sizer -> Add( new wxStaticText(this,-1,_T("Slice "))                                    , 1, wxGROW );
199                 sizer -> Add( _sl_SliceImageX                                                                                   , 1, wxGROW );
200                 sizer -> Add( _sl_SliceImageY                                                                                   , 1, wxGROW );
201                 sizer -> Add( _sl_SliceImageZ                                                                                   , 1, wxGROW );
202                 sizer -> Add( _cb_SliceFixDinamic                                                                               , 1, wxGROW );
203         //      sizer -> Add( _histogramMinMaxLevel->GetWindow()                                                , 1, wxGROW );
204
205         } // type==1
206
207
208         if (type==2)
209         {
210                 sizer                                                   = new wxFlexGridSizer(2);
211                 _interpolationCheckBox = new wxCheckBox(this, -1, _T("Interpolate") );
212                 _interpolationCheckBox->SetValue(true);
213                 _opacity = new wxSlider(this, wxID_ANY, 6, 0, 10, wxDefaultPosition, wxSize(2,40), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
214
215                 Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ColorLayerImageViewPanel::onThresholdInterpolation );
216                 Connect( _opacity->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction) &ColorLayerImageViewPanel::onChangeOpacity );
217 //              sizer -> Add( new wxStaticText(this,-1,_T("Opacity Level"))                     , 1, wxEXPAND );
218                 sizer -> Add( _opacity                                  , 1, wxGROW );
219                 sizer -> Add( _interpolationCheckBox    , 1, wxGROW );
220                 sizer->AddGrowableCol(0);
221
222         } // type==2
223
224
225         this->SetSizer( sizer );
226 //      this->SetAutoLayout( true );
227 //      this->Layout();
228      
229         //CM Sets the default fitting mode to Pixel mode.
230         _fitting_mode = 3;
231         // EO CM  EED
232 }
233
234 //----------------------------------------------------------------------------
235 ColorLayerImageViewPanel::~ColorLayerImageViewPanel()
236 {
237 }
238
239
240 //----------------------------------------------------------------------------
241 ColorLayerImageViewManager* ColorLayerImageViewPanel::GetColorLayerImageViewManager()
242 {
243    return _colorLayerImageViewManager;
244 }
245
246
247 //----------------------------------------------------------------------------
248 // This is the new spacing of the background image  (1,1,1)
249 void ColorLayerImageViewPanel::SetBaseSpacing(double spc[3])
250 {
251         _spcBase[0] = spc[0];
252         _spcBase[1] = spc[1];
253         _spcBase[2] = spc[2];
254
255         _spcBase[0] = 1;
256         _spcBase[1] = 1;
257         _spcBase[2] = 1;
258 }
259
260 //----------------------------------------------------------------------------
261 // This is the Original spacing of the background image
262 void ColorLayerImageViewPanel::SetOriginalSpacing(double spc[3])
263 {
264         _spcOrg[0] = spc[0];
265         _spcOrg[1] = spc[1];
266         _spcOrg[2] = spc[2];
267 }
268
269 //----------------------------------------------------------------------------
270 // This is the size in pixels of the background image
271 void ColorLayerImageViewPanel::SetBaseDimension(int dim[3])
272 {
273         _dimBase[0] = dim[0];
274         _dimBase[1] = dim[1];
275         _dimBase[2] = dim[2];
276 }
277
278 //----------------------------------------------------------------------------
279 void ColorLayerImageViewPanel::SetImage(vtkImageData *img)
280 {
281     if (img!=NULL)
282     {
283                 if (_histogramMinMaxLevel!=NULL) 
284                 {
285                         _histogramMinMaxLevel->Configure( img );
286                 }
287         _colorLayerImageViewManager->SetImage( img );
288
289         double spc[3];
290         img->GetSpacing(spc);
291
292         int dim[3];
293         int ext[6];
294         img->GetWholeExtent(ext);
295         dim[0] = ext[1]-ext[0];
296         dim[1] = ext[3]-ext[2];
297         dim[2] = ext[5]-ext[4];
298
299
300                 if (_sl_SliceImageX!=NULL)
301                 {
302                     _sl_SliceImageX->SetRange( 0 , dim[0] );
303                     _sl_SliceImageY->SetRange( 0 , dim[1] );
304                     _sl_SliceImageZ->SetRange( 0 , dim[2] );
305                 }
306
307 printf("EED ColorLayerImageViewPanel::SetImage  UUPPSS----------------------\n"  );
308 printf("EED ColorLayerImageViewPanel::SetImage  UUPPSS----------------------\n"  );
309 printf("EED ColorLayerImageViewPanel::SetImage  UUPPSS----------------------\n"  );
310 printf("EED ColorLayerImageViewPanel::SetImage  UUPPSS----------------------\n"  );
311 printf("  Here I have to analyse the spacing and size image to calculate new spacingvv\n"  );
312 printf("  I need the caracteristics of the base image\n"  );
313 //                      GetColorLayerImageViewManager()->GetwxVtkBaseView(0);
314
315
316         if ( (spc[0]!=_spcBase[0]) || (spc[1]!=_spcBase[1]) || (spc[2]!=_spcBase[2]) ||
317              (dim[0]!=_dimBase[0]) || (spc[1]!=_spcBase[1]) || (spc[2]!=_spcBase[2])
318             )
319         {
320                         // CM
321                         int typeOfTransformation;       
322                         // In case of the option is set to create a dialog box.
323                         if (_fitting_mode == -1)
324                         {
325                                 bool transformOkDlg;
326                         wxString msg = _T("The image resolution of both images are not compatible. Do you want to tranform it? ");
327                         wxDlgTransformByDimensionBySpacingByPixel dlg;
328                         dlg.GetTransformType(this,_spcBase,spc,_dimBase,dim,msg,typeOfTransformation,transformOkDlg);
329                         // CM Reset the default value (Pixel i.e. 3) if the dialog box returned an inappropriate value.
330                         if (transformOkDlg == false)
331                                 {
332                                 typeOfTransformation = 3;
333                                 } 
334                         } else {
335                         typeOfTransformation = _fitting_mode;
336                         } // _fitting_mode -1
337
338 printf("EED ColorLayerImageViewPanel::SetImage %d\n", typeOfTransformation );
339
340                         //EO CM
341             if (typeOfTransformation==1)  // make dimensions equals
342             {
343                 printf("EED ColorLayerImageViewPanel::onReadImage ...WARNNING.... dif size image spc*dim ofnew image ...???\n");
344                 spc[0]=_spcBase[0]*_dimBase[0]/dim[0];
345                 spc[1]=_spcBase[1]*_dimBase[1]/dim[1];
346                 spc[2] = 1;
347             }
348
349             if (typeOfTransformation==2)  // make spacing equals
350             {
351                 spc[0] = ( _spcBase[0]/spc[0] ) * _spcOrg[0];
352                 spc[1] = ( _spcBase[1]/spc[1] ) * _spcOrg[1];
353                 spc[2] = ( _spcBase[2]/spc[2] ) * _spcOrg[2];
354             }
355
356             if (typeOfTransformation==3)  // make spacing = 1
357             {
358                 spc[0] = 1;
359                 spc[1] = 1;
360                 spc[2] = 1;
361             }
362
363             img->SetSpacing(spc);
364         } // spc !_spcBase   dim!__dimBase
365     } // _firsttime_mode
366
367         if (_active==true)
368         {
369             _colorLayerImageViewManager->onThreshold();
370                 RefreshView();
371         } // _ative 
372
373 }
374
375
376 void ColorLayerImageViewPanel::RefreshView()
377 {
378 //EED01         _colorLayerImageView->Refresh();
379         _colorLayerImageViewManager->Refresh();
380 }
381
382 //----------------------------------------------------------------------------
383 void ColorLayerImageViewPanel::SetFittingMode(int fitting_mode)
384 {
385   // CM Sets the fitting mode if an appropriate value is provided.
386   if (fitting_mode == -1 || fitting_mode == 1 || fitting_mode == 2 || fitting_mode == 3)
387     {
388       _fitting_mode = fitting_mode;
389     }
390   //Otherwise, an exception should be thrown (value 0 is fine, it corresponds to an empty field i.e. the default value is kept).
391   else if (fitting_mode != 0)
392     std::cout << "CM ERROR!!! The fitting mode provided has an inappropriate value. It should be an int between -1 ; 1 ; 2 ; 3, but its value is :" << fitting_mode << ". The default value will be set instead, i.e. Pixel transformation (3)." <<  std::endl;
393   //EO CM
394 }
395
396 //----------------------------------------------------------------------------
397 int ColorLayerImageViewPanel::GetFittingMode()
398 {
399   return _fitting_mode;
400 }
401
402 //----------------------------------------------------------------------------
403 void ColorLayerImageViewPanel::onReadImage(wxCommandEvent& event)
404 {
405 // EED ???
406 //      creaImageIO::WxSimpleDlg w(0,_T("Select your image"),"creaContours_Descriptor.dscp","creatisContours DB");
407 //      w.ShowModal();
408         printf("EED ColorLayerImageViewPanel::onReadImage ....WARNING... Read dlg. all images creaImageIO ... ???\n");
409
410         creaMaracasVisuKernel::OpenImageDialog diag = creaMaracasVisuKernel::OpenImageDialog();
411         SetImage( diag.getImageData() );
412 }
413
414 //----------------------------------------------------------------------------
415 void ColorLayerImageViewPanel::onThresholdChange(wxCommandEvent& event)
416 {
417                 if (_thresholdGo)
418                 {
419                  _colorLayerImageViewManager->onThresholdChange();
420                  RefreshView();
421                 //std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal  << std::endl;
422           } // _thresholdGo
423 }
424
425 //----------------------------------------------------------------------------
426 void ColorLayerImageViewPanel::onThresholdShow(wxCommandEvent& event)
427 {
428         _thresholdGo = _cb_ShowHide->GetValue();
429                         _active = _thresholdGo;
430         if (_thresholdGo)
431         {
432                     _colorLayerImageViewManager->onThreshold();
433         }else{
434                     _colorLayerImageViewManager->onThresholdRemove( );
435         }
436              RefreshView();
437 }
438
439 //----------------------------------------------------------------------------
440 void ColorLayerImageViewPanel::onThresholdStop()
441 {
442                 if (_thresholdGo)
443                 {
444                     _colorLayerImageViewManager->onThresholdRemove( );
445                     _thresholdGo=false;
446                 }
447 }
448
449 //----------------------------------------------------------------------------
450 void ColorLayerImageViewPanel::onThresholdInterpolation(wxCommandEvent& event)
451 {
452            _colorLayerImageViewManager->onThresholdInterpolation(_interpolationCheckBox->GetValue());
453                 RefreshView();
454 }
455
456 //----------------------------------------------------------------------------
457 void ColorLayerImageViewPanel::onSliceFixDinamic(wxCommandEvent& event)
458 {
459         bool fixdin = _cb_SliceFixDinamic->GetValue();
460         _colorLayerImageViewManager->SetSliceFixDynamic( fixdin );
461         if (fixdin==false)
462         {
463             _colorLayerImageViewManager->SetX2( _sl_SliceImageX->GetValue() );
464             _colorLayerImageViewManager->SetY2( _sl_SliceImageY->GetValue() );
465             _colorLayerImageViewManager->SetZ2( _sl_SliceImageZ->GetValue() );
466         }
467         _sl_SliceImageX->Enable(!fixdin);
468         _sl_SliceImageY->Enable(!fixdin);
469         _sl_SliceImageZ->Enable(!fixdin);
470         _colorLayerImageViewManager->onThreshold();
471         RefreshView();
472 }
473
474 //----------------------------------------------------------------------------
475 void ColorLayerImageViewPanel::onSliceImage(wxScrollEvent& event)
476 {
477    _colorLayerImageViewManager->SetX2( _sl_SliceImageX->GetValue() );
478    _colorLayerImageViewManager->SetY2( _sl_SliceImageY->GetValue() );
479    _colorLayerImageViewManager->SetZ2( _sl_SliceImageZ->GetValue() );
480    _colorLayerImageViewManager->onThreshold();
481         RefreshView();
482 }
483
484 //----------------------------------------------------------------------------
485 void ColorLayerImageViewPanel::onChangeOpacity(wxScrollEvent& event)
486 {
487         int opacity = _opacity->GetValue();
488         _colorLayerImageViewManager->onThresholdChangeOpacity(opacity);
489         RefreshView();
490 }
491
492
493 //----------------------------------------------------------------------------
494 bool ColorLayerImageViewPanel::IsVisible()
495 {
496         return _thresholdGo;
497 }
498
499 //----------------------------------------------------------------------------
500 void ColorLayerImageViewPanel::SetActive(bool active)
501 {
502         _active=active;
503         if (_cb_ShowHide!=NULL)
504         {
505                 _cb_ShowHide->SetValue( _active );
506         }
507 }
508
509
510 // EOF
511