]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx
#3555 ColorLayer box input Interpolation
[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         wxRadioBox * radioOpts = new wxRadioBox(dial, -1, _T("Type of spacing transformation"), wxDefaultPosition, wxSize(250,160), 3 , lstOptOperation,  1, wxRA_SPECIFY_COLS);
73
74         wxString str;
75         wxString strBaseSpc(str);
76         wxString strLayerSpc;
77         wxString strBaseDim;
78         wxString strLayerDim;
79
80         strBaseSpc.Printf(wxT("Base spacing: %f %f %f")         , baseSpc[0],baseSpc[1],baseSpc[2]              );
81         strLayerSpc.Printf(wxT("Layer spacing: %f %f %f")       , layerSpc[0],layerSpc[1],layerSpc[2]   );
82         strBaseDim.Printf(wxT("Base dimension: %d %d %d")       , baseDim[0],baseDim[1],baseDim[2]              );
83         strLayerDim.Printf(wxT("Layer dimension: %d %d %d")     , layerDim[0],layerDim[1],layerDim[2]   );
84
85         dialSizer->Add( new wxStaticText(dial,-1,_T(" ")                )       , 0, wxGROW );
86         dialSizer->Add( new wxStaticText(dial,-1, strBaseSpc    )       , 0, wxGROW );
87         dialSizer->Add( new wxStaticText(dial,-1, strLayerSpc   )       , 0, wxGROW );
88         dialSizer->Add( new wxStaticText(dial,-1,_T(" ")                )       , 0, wxGROW );
89         dialSizer->Add( new wxStaticText(dial,-1, strBaseDim    )       , 0, wxGROW );
90         dialSizer->Add( new wxStaticText(dial,-1, strLayerDim   )       , 0, wxGROW );
91         dialSizer->Add( new wxStaticText(dial,-1,_T(" ")                )       , 0, wxGROW );
92         dialSizer->Add( new wxStaticText(dial,-1,message                )       , 0, wxGROW );
93         dialSizer->Add( new wxStaticText(dial,-1,_T(" ")                )       , 0, wxGROW );
94         dialSizer->Add(radioOpts,0,wxGROW);
95         dialSizer->Add( new wxStaticText(dial,-1,_T(" ")                )       , 0, wxGROW );
96         dialSizer->Add(buttonsSizer,0,wxGROW);
97         dial->SetSizer(dialSizer, true);
98         dial->Layout();
99         dial->ShowModal();
100
101         typeOfTransformation    = -1;
102         dlgWxOK                                 = false;
103
104 printf("EED wxDlgTransformByDimensionBySpacingByPixel::GetTransformType AAA\n");
105
106         if (dial->GetReturnCode() == wxID_OK)
107         {
108                 typeOfTransformation    = radioOpts->GetSelection() + 1;
109 printf("EED wxDlgTransformByDimensionBySpacingByPixel::GetTransformType BBB %d\n",typeOfTransformation);
110                 dlgWxOK                                 = true;
111         }
112 }
113
114
115 //---------------------------------------------------------
116 //---------------------------------------------------------
117 //---------------------------------------------------------
118
119
120 /**
121  ** Begin of the threshold panel
122  **/
123 ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, int max,int opacity, int type)
124 //: wxPanel(parent, -1, wxDefaultPosition, wxSize(600,100), wxBORDER_SUNKEN)
125 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
126 {
127     _interpolationCheckBox=NULL;
128         _spcBase[0] = _spcBase[1] = _spcBase[2] = 0;
129         _dimBase[0] = _dimBase[1] = _dimBase[2] = 0;
130         _cb_ShowHide                            = NULL;
131         _sl_SliceImageX                         = NULL;
132         _sl_SliceImageY                         = NULL;
133         _sl_SliceImageZ                         = NULL;
134         _histogram                                      = NULL;
135         _histogramMinMaxLevel           = NULL;
136         wxFlexGridSizer * sizer         = NULL;
137         _colorLayerImageViewManager     = new ColorLayerImageViewManager();
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, opacity, 0, 100, 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         if (type==2)
208         {
209                 sizer                                                   = new wxFlexGridSizer(2);
210                 _interpolationCheckBox = new wxCheckBox(this, -1, _T("Interpolate") );
211                 _interpolationCheckBox->SetValue(true);
212                 _opacity = new wxSlider(this, wxID_ANY, opacity, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
213                 Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ColorLayerImageViewPanel::onThresholdInterpolation );
214                 Connect( _opacity->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction) &ColorLayerImageViewPanel::onChangeOpacity );
215 //              sizer -> Add( new wxStaticText(this,-1,_T("Opacity Level"))                     , 1, wxEXPAND );
216                 sizer -> Add( _opacity                                  , 1, wxGROW );
217                 sizer -> Add( _interpolationCheckBox    , 1, wxGROW );
218                 sizer->AddGrowableCol(0);
219
220         } // type==2
221
222         this->SetSizer( sizer );
223 //      this->SetAutoLayout( true );
224 //      this->Layout();
225      
226         //CM Sets the default fitting mode to Pixel mode.
227         _fitting_mode = 3;
228         // EO CM  EED
229 }
230
231 //----------------------------------------------------------------------------
232 ColorLayerImageViewPanel::~ColorLayerImageViewPanel()
233 {
234 }
235
236 //----------------------------------------------------------------------------
237 ColorLayerImageViewManager* ColorLayerImageViewPanel::GetColorLayerImageViewManager()
238 {
239    return _colorLayerImageViewManager;
240 }
241
242 /*
243 //----------------------------------------------------------------------------
244 void ColorLayerImageViewPanel::SetImage(vtkImageData *img)
245 {
246     if (img!=NULL)
247     {           
248                 if (_histogramMinMaxLevel!=NULL) 
249                 {
250                         _histogramMinMaxLevel->Configure( img );
251                 }
252  
253         _colorLayerImageViewManager->SetImage( img );
254  
255         double  spcOriginalLayer[3];
256         int     dimensionOriginalLayer[3];
257         double  spcBase[3];
258         int     dimensionBase[3];
259         double  newSpc[3];
260                 GetColorLayerImageViewManager()->GetSpcOriginalLayer(0,spcOriginalLayer);               
261                 GetColorLayerImageViewManager()->GetDimensionOriginalLayer(0,dimensionOriginalLayer);           
262                 GetColorLayerImageViewManager()->GetSpcBase(0,spcBase);         
263                 GetColorLayerImageViewManager()->GetDimensionBase(0,dimensionBase);             
264                 if (_sl_SliceImageX!=NULL)
265                 {
266                     _sl_SliceImageX->SetRange( 0 , dimensionOriginalLayer[0] );
267                     _sl_SliceImageY->SetRange( 0 , dimensionOriginalLayer[1] );
268                     _sl_SliceImageZ->SetRange( 0 , dimensionOriginalLayer[2] );
269                 }
270
271         if (    (spcOriginalLayer[0]!=spcBase[0]) || 
272                                 (spcOriginalLayer[1]!=spcBase[1]) || 
273                                 (spcOriginalLayer[2]!=spcBase[2]) ||
274                 (dimensionOriginalLayer[0]!=dimensionBase[0]) || 
275                                 (dimensionOriginalLayer[1]!=dimensionBase[1]) || 
276                                 (dimensionOriginalLayer[2]!=dimensionBase[2])
277             )
278         {
279                         // CM
280                         int typeOfTransformation;       
281                         // In case of the option is set to create a dialog box.
282                         if (_fitting_mode == -1)
283                         {
284                                 bool transformOkDlg;
285                         wxString msg = _T("The image resolution of both images are not compatible. How do you want to tranform it? ");
286                         wxDlgTransformByDimensionBySpacingByPixel dlg;
287                         dlg.GetTransformType(this , spcBase , spcOriginalLayer , dimensionBase ,dimensionOriginalLayer ,msg,typeOfTransformation,transformOkDlg);
288                         // CM Reset the default value (Pixel i.e. 3) if the dialog box returned an inappropriate value.
289                         if (transformOkDlg == false)
290                                 {
291                                 typeOfTransformation = 3;
292                                 } 
293                         } else {
294                         typeOfTransformation = _fitting_mode;
295                         } // _fitting_mode -1
296
297                         //EO CM
298             if (typeOfTransformation==1)  // Adapt spacing 
299             {
300                 newSpc[0] = spcBase[0] * dimensionBase[0] / dimensionOriginalLayer[0];
301                 newSpc[1] = spcBase[1] * dimensionBase[1] / dimensionOriginalLayer[1];
302                 newSpc[2] = spcBase[2] * dimensionBase[2] / dimensionOriginalLayer[2];
303             }
304
305             if (typeOfTransformation==2)  // keep spacing of the Layer Image
306             {
307                 newSpc[0] = spcOriginalLayer[0];
308                 newSpc[1] = spcOriginalLayer[1];
309                 newSpc[2] = spcOriginalLayer[2];
310             }
311
312             if (typeOfTransformation==3)  // Use the spacing of the Base Image
313             {
314                 newSpc[0] = spcBase[0];
315                 newSpc[1] = spcBase[1];
316                 newSpc[2] = spcBase[2];
317             }
318                         GetColorLayerImageViewManager()->SetNewSpacingLayer(newSpc);
319         } else {
320                 newSpc[0] = spcOriginalLayer[0];
321                 newSpc[1] = spcOriginalLayer[1];
322                 newSpc[2] = spcOriginalLayer[2];
323                 } // spc !_spcBase   dim!__dimBase
324                 GetColorLayerImageViewManager()->SetNewSpacingLayer(newSpc);
325
326     } // img
327
328         if (_active==true)
329         {
330             _colorLayerImageViewManager->onThreshold();
331         if (img==NULL)        _colorLayerImageViewManager->onThresholdRemove( );
332                 RefreshView();
333         } // _active
334 }
335 */
336
337 //----------------------------------------------------------------------------
338 void ColorLayerImageViewPanel::SetImage(vtkImageData *img)
339 {
340 //    if (img!=NULL)
341 //    {
342         if (_histogramMinMaxLevel!=NULL)
343         {
344             _histogramMinMaxLevel->Configure( img );
345         }
346
347         _colorLayerImageViewManager->SetImageStep1( img );
348
349         double      spcBase[3];
350         double      spcOriginalLayer[3];
351         int         dimensionBase[3];
352         int         dimensionOriginalLayer[3];
353   //      double      newSpc[3];
354         GetColorLayerImageViewManager()->GetSpcOriginalLayer(0,spcOriginalLayer);
355         GetColorLayerImageViewManager()->GetDimensionOriginalLayer(0,dimensionOriginalLayer);
356         GetColorLayerImageViewManager()->GetSpcBase(0,spcBase);
357         GetColorLayerImageViewManager()->GetDimensionBase(0,dimensionBase);
358         GetColorLayerImageViewManager()->GetDimensionOriginalLayer(0,dimensionOriginalLayer);
359         if (_sl_SliceImageX!=NULL)
360         {
361             _sl_SliceImageX->SetRange( 0 , dimensionOriginalLayer[0] );
362             _sl_SliceImageY->SetRange( 0 , dimensionOriginalLayer[1] );
363             _sl_SliceImageZ->SetRange( 0 , dimensionOriginalLayer[2] );
364         }
365
366     int typeOfTransformation;
367     if (_fitting_mode == -1)
368     {
369         bool transformOkDlg;
370         wxString msg = _T("The image resolution of both images are not compatible. How do you want to tranform it? ");
371         wxDlgTransformByDimensionBySpacingByPixel dlg;
372         dlg.GetTransformType(this , spcBase , spcOriginalLayer , dimensionBase ,dimensionOriginalLayer ,msg,typeOfTransformation,transformOkDlg);
373         // CM Reset the default value (Pixel i.e. 3) if the dialog box returned an inappropriate value.
374         if (transformOkDlg == false)
375         {
376             typeOfTransformation = 3;
377         }
378      } else {
379          typeOfTransformation = _fitting_mode;
380     } // _fitting_mode -1
381     
382     _colorLayerImageViewManager->SetFittingMode( typeOfTransformation );
383     _colorLayerImageViewManager->SetImageStep2( img );
384
385 //    } // img
386 }
387
388 //----------------------------------------------------------------------------
389 void ColorLayerImageViewPanel::RefreshView()
390 {
391 //EED01         _colorLayerImageView->Refresh();
392         _colorLayerImageViewManager->Refresh();
393 }
394
395 //----------------------------------------------------------------------------
396 void ColorLayerImageViewPanel::SetFittingMode(int fitting_mode)
397 {
398   // CM Sets the fitting mode if an appropriate value is provided.
399   if (fitting_mode == -1 || fitting_mode == 1 || fitting_mode == 2 || fitting_mode == 3)
400     {
401       _fitting_mode = fitting_mode;
402     }
403   //Otherwise, an exception should be thrown (value 0 is fine, it corresponds to an empty field i.e. the default value is kept).
404   else if (fitting_mode != 0)
405     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;
406   //EO CM
407 }
408
409 //----------------------------------------------------------------------------
410 int ColorLayerImageViewPanel::GetFittingMode()
411 {
412   return _fitting_mode;
413 }
414
415 //----------------------------------------------------------------------------
416 void ColorLayerImageViewPanel::onReadImage(wxCommandEvent& event)
417 {
418 // EED ???
419 //      creaImageIO::WxSimpleDlg w(0,_T("Select your image"),"creaContours_Descriptor.dscp","creatisContours DB");
420 //      w.ShowModal();
421         printf("EED ColorLayerImageViewPanel::onReadImage ....WARNING... Read dlg. all images creaImageIO ... ???\n");
422
423         int         ext[6];
424         double      spc[6];
425         double      origin[3];
426         origin[0]       = 0;
427         origin[1]       = 0;
428         origin[2]       = 0;
429
430         creaMaracasVisuKernel::OpenImageDialog  diag    = creaMaracasVisuKernel::OpenImageDialog();
431         vtkImageChangeInformation                               *change = vtkImageChangeInformation::New();
432         vtkImageData                                                    *img    = diag.getImageData();
433         img             -> GetExtent( ext );    
434         img             -> GetSpacing( spc );   
435         change  -> SetInputData( img );
436         change  -> SetOutputSpacing( spc[0] , spc[1] , spc [2] );
437         change  -> SetOutputExtentStart(0,0,0);
438         change  -> SetOutputOrigin( origin );
439         change  -> Modified();          //important
440         change  -> Update();            //important
441         SetImage( change->GetOutput() );
442     GetColorLayerImageViewManager()->onThreshold();
443         RefreshView();
444 }
445
446 //----------------------------------------------------------------------------
447 void ColorLayerImageViewPanel::onThresholdChange(wxCommandEvent& event)
448 {
449                 if (_thresholdGo)
450                 {
451                 GetColorLayerImageViewManager()->onThresholdChange();
452                          RefreshView();
453                 //std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal  << std::endl;
454           } // _thresholdGo
455 }
456
457 //----------------------------------------------------------------------------
458 void ColorLayerImageViewPanel::onThresholdShow(wxCommandEvent& event)
459 {
460         _thresholdGo = _cb_ShowHide->GetValue();
461                         _active = _thresholdGo;
462         if (_thresholdGo)
463         {
464             GetColorLayerImageViewManager()->onThreshold();
465         }else{
466             GetColorLayerImageViewManager()->onThresholdRemove( );
467         }
468              RefreshView();
469 }
470
471 //----------------------------------------------------------------------------
472 void ColorLayerImageViewPanel::onThresholdStop()
473 {
474     if (_thresholdGo)
475     {
476         GetColorLayerImageViewManager()->onThresholdRemove( );
477         _thresholdGo = false;
478         }
479 }
480
481 //----------------------------------------------------------------------------
482 void ColorLayerImageViewPanel::onThresholdInterpolation(wxCommandEvent& event)
483 {
484     GetColorLayerImageViewManager()->onThresholdInterpolation(_interpolationCheckBox->GetValue());
485     RefreshView();
486 }
487
488 //----------------------------------------------------------------------------
489 void ColorLayerImageViewPanel::onSliceFixDinamic(wxCommandEvent& event)
490 {
491         bool fixdin = _cb_SliceFixDinamic->GetValue();
492         _colorLayerImageViewManager->SetSliceFixDynamic( fixdin );
493         if (fixdin==false)
494         {
495             GetColorLayerImageViewManager()->SetX2( _sl_SliceImageX->GetValue() );
496             GetColorLayerImageViewManager()->SetY2( _sl_SliceImageY->GetValue() );
497             GetColorLayerImageViewManager()->SetZ2( _sl_SliceImageZ->GetValue() );
498         }
499         _sl_SliceImageX->Enable(!fixdin);
500         _sl_SliceImageY->Enable(!fixdin);
501         _sl_SliceImageZ->Enable(!fixdin);
502         _colorLayerImageViewManager->onThreshold();
503         RefreshView();
504 }
505
506 //----------------------------------------------------------------------------
507 void ColorLayerImageViewPanel::onSliceImage(wxScrollEvent& event)
508 {
509     GetColorLayerImageViewManager()->SetX2( _sl_SliceImageX->GetValue() );
510     GetColorLayerImageViewManager()->SetY2( _sl_SliceImageY->GetValue() );
511     GetColorLayerImageViewManager()->SetZ2( _sl_SliceImageZ->GetValue() );
512     GetColorLayerImageViewManager()->onThreshold();
513         RefreshView();
514 }
515
516 //----------------------------------------------------------------------------
517 int ColorLayerImageViewPanel::GetOpacity()
518 {
519         return _opacity->GetValue();
520 }
521
522 //----------------------------------------------------------------------------
523 bool ColorLayerImageViewPanel::GetInterpolation()
524 {
525     if (_interpolationCheckBox!=NULL)
526     {
527         return _interpolationCheckBox->GetValue();
528     } else {
529         return false;
530     } // if _interpolationCheckBox
531 }
532
533
534 //----------------------------------------------------------------------------
535 void ColorLayerImageViewPanel::ChangeOpacity()
536 {
537         int opacity = _opacity->GetValue();
538     GetColorLayerImageViewManager()->onThresholdChangeOpacity(opacity);
539         RefreshView();
540 }
541
542 //----------------------------------------------------------------------------
543 void ColorLayerImageViewPanel::onChangeOpacity(wxScrollEvent& event)
544 {
545         ChangeOpacity();
546 //      int opacity = _opacity->GetValue();
547 //      _colorLayerImageViewManager->onThresholdChangeOpacity(opacity);
548 //      RefreshView();
549 }
550
551
552 //----------------------------------------------------------------------------
553 bool ColorLayerImageViewPanel::IsVisible()
554 {
555         return _thresholdGo;
556 }
557
558 //----------------------------------------------------------------------------
559 void ColorLayerImageViewPanel::SetActive(bool active)
560 {
561         _active=active;
562         if (_cb_ShowHide!=NULL)
563         {
564                 _cb_ShowHide->SetValue( _active );
565         }
566     GetColorLayerImageViewManager()->SetActive( _active );
567 }
568
569
570 // EOF
571