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