]> Creatis software - creaMaracasVisu.git/blobdiff - 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
index 1477a0c5d0bd27b1faf1af123535693227b63593..7763924fdad8c41fcf58465913689da140dc1997 100644 (file)
@@ -31,7 +31,7 @@
 
 #include "ColorLayerImageViewPanel.h"
 #include "OpenImageDialog.h"
-
+#include <wx/string.h>
 
 //---------------------------------------------------------
 //---------------------------------------------------------
@@ -46,9 +46,17 @@ wxDlgTransformByDimensionBySpacingByPixel::~wxDlgTransformByDimensionBySpacingBy
 }
 
 
-void wxDlgTransformByDimensionBySpacingByPixel::GetTransformType(wxWindow *parent , wxString message,int &typeOfTransformation,bool &dlgWxOK)
+void wxDlgTransformByDimensionBySpacingByPixel::GetTransformType(
+                                                                       wxWindow *parent , 
+                                                                       double baseSpc[3],
+                                                                       double layerSpc[3],
+                                                                       int baseDim[3],
+                                                                       int layerDim[3],
+                                                                       wxString message,
+                                                                       int &typeOfTransformation,
+                                                                       bool &dlgWxOK)
 {
-       wxDialog* dial                          = new wxDialog (parent,-1,_T("Tools"),wxDefaultPosition, wxSize(590,190));
+       wxDialog* dial                  = new wxDialog (parent,-1,_T("Tools"),wxDefaultPosition, wxSize(500,550),wxRESIZE_BORDER);
        wxSizer* buttonsSizer   = dial->CreateSeparatedButtonSizer(wxOK|wxCANCEL);
        wxBoxSizer *dialSizer   = new wxBoxSizer(wxVERTICAL);
 
@@ -56,25 +64,43 @@ void wxDlgTransformByDimensionBySpacingByPixel::GetTransformType(wxWindow *paren
        lstOptOperation[0]=_T("By Dimension");
        lstOptOperation[1]=_T("By Spacing");
        lstOptOperation[2]=_T("By Pixel");
-       wxRadioBox * radioOpts = new wxRadioBox(dial, -1, _T("Type of Transformation"), wxDefaultPosition, wxSize(270,45), 3 , lstOptOperation,  3, wxRA_SPECIFY_COLS);
-
-       dialSizer->Add( new wxStaticText(dial,-1,message)  , 0, wxGROW );
-       //      dialSizer->Add( new wxStaticText(dial,-1,_T("selected Roi file. Do you want to tranform it?"))  , 0, wxGROW );
-       dialSizer->Add( new wxStaticText(dial,-1,_T(" "))  , 0, wxGROW );
+       wxRadioBox * radioOpts = new wxRadioBox(dial, -1, _T("Type of Transformation"), wxDefaultPosition, wxSize(250,90), 3 , lstOptOperation,  3, wxRA_SPECIFY_COLS);
+
+       wxString str;
+       wxString strBaseSpc(str);
+       wxString strLayerSpc;
+       wxString strBaseDim;
+       wxString strLayerDim;
+
+       strBaseSpc.Printf(wxT("Base spacing: %f %f %f"), baseSpc[0],baseSpc[1],baseSpc[2] );
+       strLayerSpc.Printf(wxT("Layer spacing: %f %f %f"), layerSpc[0],layerSpc[1],layerSpc[2] );
+       strBaseDim.Printf(wxT("Base dimension: %d %d %d"), baseDim[0],baseDim[1],baseDim[2] );
+       strLayerDim.Printf(wxT("Layer dimension: %d %d %d"), layerDim[0],layerDim[1],layerDim[2] );
+
+       dialSizer->Add( new wxStaticText(dial,-1,message                )       , 0, wxGROW );
+       dialSizer->Add( new wxStaticText(dial,-1,_T(" ")                )       , 0, wxGROW );
+       dialSizer->Add( new wxStaticText(dial,-1, strBaseSpc    )       , 0, wxGROW );
+       dialSizer->Add( new wxStaticText(dial,-1, strLayerSpc   )       , 0, wxGROW );
+       dialSizer->Add( new wxStaticText(dial,-1,_T(" ")                )       , 0, wxGROW );
+       dialSizer->Add( new wxStaticText(dial,-1, strBaseDim    )       , 0, wxGROW );
+       dialSizer->Add( new wxStaticText(dial,-1, strLayerDim   )       , 0, wxGROW );
+       dialSizer->Add( new wxStaticText(dial,-1,_T(" ")                )       , 0, wxGROW );
+       dialSizer->Add( new wxStaticText(dial,-1,message                )       , 0, wxGROW );
+       dialSizer->Add( new wxStaticText(dial,-1,_T(" ")                )       , 0, wxGROW );
        dialSizer->Add(radioOpts,0,wxGROW);
-       dialSizer->Add( new wxStaticText(dial,-1,_T(" "))  , 0, wxGROW );
+       dialSizer->Add( new wxStaticText(dial,-1,_T(" ")                )       , 0, wxGROW );
        dialSizer->Add(buttonsSizer,0,wxGROW);
        dial->SetSizer(dialSizer, true);
        dial->Layout();
        dial->ShowModal();
 
        typeOfTransformation    = -1;
-       dlgWxOK                 = false;
+       dlgWxOK                                 = false;
 
        if (dial->GetReturnCode() == wxID_OK)
        {
                typeOfTransformation    = radioOpts->GetSelection() + 1;
-               dlgWxOK                 = true;
+               dlgWxOK                                 = true;
        }
 }
 
@@ -88,99 +114,121 @@ void wxDlgTransformByDimensionBySpacingByPixel::GetTransformType(wxWindow *paren
  ** Begin of the threshold panel
  **/
 ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, int max, int type)
-: wxPanel(parent, -1, wxDefaultPosition, wxSize(600,100), wxBORDER_SUNKEN)
-{
-       printf("EED ColorLayerImageViewPanel::ColorLayerImageViewPanel start \n");
+//: wxPanel(parent, -1, wxDefaultPosition, wxSize(600,100), wxBORDER_SUNKEN)
 
-       _spcBase[0] = _spcBase[1] = _spcBase[2] = 0;
-       _dimBase[0] = _dimBase[1] = _dimBase[2] = 0;
+: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
 
-//EED01        _colorLayerImageView            = new ColorLayerImageView();
-       _colorLayerImageViewManager     = new ColorLayerImageViewManager();
 
-       _btn_ReadImage                  = new wxButton(this, wxID_ANY, _T("Read Image") );
-       _thresholdGo                    = true;
-       _cb_ShowHide                    = new wxCheckBox(this, wxID_ANY, _T("Show/Hide Layer") );
-       _cb_ShowHide->SetValue(_thresholdGo);
-
-       _cb_SliceFixDinamic = new wxCheckBox(this, wxID_ANY, _T("Fixed/Dynamic Slice") );
-       _cb_SliceFixDinamic->SetValue(true);
+{
+printf("EED ColorLayerImageViewPanel::ColorLayerImageViewPanel Start\n");
 
-       _sl_SliceImageX = new wxSlider(this, wxID_ANY, 0, 1000, 1000, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
-       _sl_SliceImageY = new wxSlider(this, wxID_ANY, 0, 1000, 1000, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
-       _sl_SliceImageZ = new wxSlider(this, wxID_ANY, 0, 1000, 1000, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
-       _sl_SliceImageX->Enable(false);
-       _sl_SliceImageY->Enable(false);
-       _sl_SliceImageZ->Enable(false);
-       _interpolationCheckBox = new wxCheckBox(this, -1, _T("Image Interpolation") );
-       _interpolationCheckBox->SetValue(true);
-       _opacity = new wxSlider(this, wxID_ANY, 6, 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+       _spcBase[0] = _spcBase[1] = _spcBase[2] = 0;
+       _dimBase[0] = _dimBase[1] = _dimBase[2] = 0;
 
-       _histogram                                      = new Histogram(  this , -1, wxPoint(0,0), wxSize(400,400), /*wxNO_BORDER*/ wxBORDER_DEFAULT ); 
-       _histogramMinMaxLevel   = new HistogramMinMaxLevel( (HistogramBase*)_histogram );
+       _cb_ShowHide                    = NULL;
+       _sl_SliceImageX                 = NULL;
+       _sl_SliceImageY                 = NULL;
+       _sl_SliceImageZ                 = NULL;
+       _histogram                              = NULL;
+       _histogramMinMaxLevel   = NULL;
 
-       if (type==0)
-       {
-       }
+       wxFlexGridSizer * sizer         = NULL;
+       _colorLayerImageViewManager     = new ColorLayerImageViewManager();
 
        if (type==1)
        {
-       }
+               sizer                                                   = new wxFlexGridSizer(1);
+               _btn_ReadImage                                  = new wxButton(this, wxID_ANY, _T("Read Image") );
+               _thresholdGo                                    = true;
+               _cb_ShowHide                                    = new wxCheckBox(this, wxID_ANY, _T("Show/Hide Layer") );
+               _cb_ShowHide->SetValue(_thresholdGo);
+               _cb_SliceFixDinamic                     = new wxCheckBox(this, wxID_ANY, _T("Fixed/Dynamic Slice") );
+               _cb_SliceFixDinamic->SetValue(true);
+               _sl_SliceImageX = new wxSlider(this, wxID_ANY, 0, 1000, 1000, 
+                                                                                       wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+               _sl_SliceImageY = new wxSlider(this, wxID_ANY, 0, 1000, 1000, 
+                                                                                       wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+               _sl_SliceImageZ = new wxSlider(this, wxID_ANY, 0, 1000, 1000, 
+                                                                                       wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+               _sl_SliceImageX->Enable(false);
+               _sl_SliceImageY->Enable(false);
+               _sl_SliceImageZ->Enable(false);
+               _interpolationCheckBox = new wxCheckBox(this, -1, _T("Interpole") );
+               _interpolationCheckBox->SetValue(true);
+               _opacity = new wxSlider(this, wxID_ANY, 6, 1, 10, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
+
+       //      _histogram                                      = new Histogram(  this , -1, wxPoint(0,0), wxSize(400,400), /*wxNO_BORDER*/ wxBORDER_DEFAULT ); 
+       //      _histogramMinMaxLevel   = new HistogramMinMaxLevel( (HistogramBase*)_histogram );
+
+               Connect( _btn_ReadImage->GetId(), wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &ColorLayerImageViewPanel::onReadImage );
+               Connect( _cb_ShowHide->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED  , (wxObjectEventFunction) &ColorLayerImageViewPanel::onThresholdShow );
+               Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ColorLayerImageViewPanel::onThresholdInterpolation );
+               Connect( _opacity->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction) &ColorLayerImageViewPanel::onChangeOpacity );
+               Connect( _cb_SliceFixDinamic->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceFixDinamic );
+
+               Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_THUMBTRACK      , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+               Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_LINEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+               Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_LINEDOWN        , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+               Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_PAGEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+               Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_PAGEDOWN        , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+
+               Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_THUMBTRACK      , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+               Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_LINEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+               Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_LINEDOWN        , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+               Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_PAGEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+               Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_PAGEDOWN        , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+
+               Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_THUMBTRACK      , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+               Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_LINEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+               Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_LINEDOWN        , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+               Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_PAGEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+               Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_PAGEDOWN        , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+
+               sizer -> Add( new wxStaticText(this,-1,_T("Color Image Layer"))                 , 1, wxGROW );
+               sizer -> Add( _btn_ReadImage                                                                                    , 1, wxGROW );
+               sizer -> Add( new wxStaticText(this,-1,_T(" "))                                                 , 1, wxGROW );
+               sizer -> Add( new wxStaticText(this,-1,_T("Opacity Level"))                     , 1, wxGROW );
+               sizer -> Add( _opacity                                                                                                  , 1, wxGROW );
+               sizer -> Add( new wxStaticText(this,-1,_T(" "))                                                 , 1, wxGROW );
+               sizer -> Add( _cb_ShowHide                                                                                              , 1, wxGROW );
+               sizer -> Add( new wxStaticText(this,-1,_T(" "))                                                 , 1, wxGROW );
+               sizer -> Add( _interpolationCheckBox                                                                    , 1, wxGROW );
 
+               sizer -> Add( new wxStaticText(this,-1,_T(" "))                                                 , 1, wxGROW );
+               sizer -> Add( new wxStaticText(this,-1,_T("Slice "))                                    , 1, wxGROW );
+               sizer -> Add( _sl_SliceImageX                                                                                   , 1, wxGROW );
+               sizer -> Add( _sl_SliceImageY                                                                                   , 1, wxGROW );
+               sizer -> Add( _sl_SliceImageZ                                                                                   , 1, wxGROW );
+               sizer -> Add( _cb_SliceFixDinamic                                                                               , 1, wxGROW );
+       //      sizer -> Add( _histogramMinMaxLevel->GetWindow()                                                , 1, wxGROW );
 
-       Connect( _btn_ReadImage->GetId(), wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &ColorLayerImageViewPanel::onReadImage );
-       Connect( _cb_ShowHide->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED  , (wxObjectEventFunction) &ColorLayerImageViewPanel::onThresholdShow );
-       Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ColorLayerImageViewPanel::onThresholdInterpolation );
-       Connect( _opacity->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction) &ColorLayerImageViewPanel::onChangeOpacity );
-       Connect( _cb_SliceFixDinamic->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceFixDinamic );
+       } // type==1
 
-       Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_THUMBTRACK      , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
-       Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_LINEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
-       Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_LINEDOWN                , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
-       Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_PAGEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
-       Connect( _sl_SliceImageX->GetId(), wxEVT_SCROLL_PAGEDOWN                , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
 
-       Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_THUMBTRACK      , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
-       Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_LINEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
-       Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_LINEDOWN                , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
-       Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_PAGEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
-       Connect( _sl_SliceImageY->GetId(), wxEVT_SCROLL_PAGEDOWN                , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+       if (type==2)
+       {
+               sizer                                                   = new wxFlexGridSizer(2);
+               _interpolationCheckBox = new wxCheckBox(this, -1, _T("Interpolate") );
+               _interpolationCheckBox->SetValue(true);
+               _opacity = new wxSlider(this, wxID_ANY, 6, 0, 10, wxDefaultPosition, wxSize(2,40), wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
 
-       Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_THUMBTRACK      , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
-       Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_LINEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
-       Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_LINEDOWN                , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
-       Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_PAGEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
-       Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_PAGEDOWN                , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
+               Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ColorLayerImageViewPanel::onThresholdInterpolation );
+               Connect( _opacity->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction) &ColorLayerImageViewPanel::onChangeOpacity );
+//             sizer -> Add( new wxStaticText(this,-1,_T("Opacity Level"))                     , 1, wxEXPAND );
+               sizer -> Add( _opacity                                  , 1, wxGROW );
+               sizer -> Add( _interpolationCheckBox    , 1, wxGROW );
+               sizer->AddGrowableCol(0);
+
+       } // type==2
 
-       wxFlexGridSizer * sizer         = new wxFlexGridSizer(1);
-       if (type==1)
-       {
-               sizer -> Add( new wxStaticText(this,-1,_T("Color Image Layer"))         , 1, wxGROW );
-               sizer -> Add( _btn_ReadImage                                                                                                    , 1, wxGROW );
-               sizer -> Add( new wxStaticText(this,-1,_T(" "))                                                 , 1, wxGROW );
-       }
-       sizer -> Add( new wxStaticText(this,-1,_T("Opacity Level"))                     , 1, wxGROW );
-       sizer -> Add( _opacity                                                                                                                          , 1, wxGROW );
-       sizer -> Add( new wxStaticText(this,-1,_T(" "))                                                         , 1, wxGROW );
-       sizer -> Add( _cb_ShowHide                                                                                                                      , 1, wxGROW );
-       sizer -> Add( new wxStaticText(this,-1,_T(" "))                                                         , 1, wxGROW );
-       sizer -> Add( _interpolationCheckBox                                                                                    , 1, wxGROW );
-
-       sizer -> Add( new wxStaticText(this,-1,_T(" "))                                                         , 1, wxGROW );
-       sizer -> Add( new wxStaticText(this,-1,_T("Slice "))                                    , 1, wxGROW );
-       sizer -> Add( _sl_SliceImageX                                                                                                           , 1, wxGROW );
-       sizer -> Add( _sl_SliceImageY                                                                                                           , 1, wxGROW );
-       sizer -> Add( _sl_SliceImageZ                                                                                                           , 1, wxGROW );
-       sizer -> Add( _cb_SliceFixDinamic                                                                                               , 1, wxGROW );
-       sizer -> Add( _histogramMinMaxLevel->GetWindow()                                                        , 1, wxGROW );
 
        this->SetSizer( sizer );
-       this->SetAutoLayout( true );
-       this->Layout();
+//     this->SetAutoLayout( true );
+//     this->Layout();
      
        //CM Sets the default fitting mode to Pixel mode.
        _fitting_mode = 3;
-       // EO CM
+       // EO CM  EED
 }
 
 //----------------------------------------------------------------------------
@@ -232,7 +280,10 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img)
 {
     if (img!=NULL)
     {
+               if (_histogramMinMaxLevel!=NULL) 
+               {
                        _histogramMinMaxLevel->Configure( img );
+               }
         _colorLayerImageViewManager->SetImage( img );
 
         double spc[3];
@@ -244,33 +295,40 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img)
         dim[0] = ext[1]-ext[0];
         dim[1] = ext[3]-ext[2];
         dim[2] = ext[5]-ext[4];
-        _sl_SliceImageX->SetRange( 0 , dim[0] );
-        _sl_SliceImageY->SetRange( 0 , dim[1] );
-        _sl_SliceImageZ->SetRange( 0 , dim[2] );
+
+
+               if (_sl_SliceImageX!=NULL)
+               {
+                   _sl_SliceImageX->SetRange( 0 , dim[0] );
+                   _sl_SliceImageY->SetRange( 0 , dim[1] );
+                   _sl_SliceImageZ->SetRange( 0 , dim[2] );
+               }
 
         if ( (spc[0]!=_spcBase[0]) || (spc[1]!=_spcBase[1]) || (spc[2]!=_spcBase[2]) ||
              (dim[0]!=_dimBase[0]) || (spc[1]!=_spcBase[1]) || (spc[2]!=_spcBase[2])
             )
         {
-         // CM
-         int typeOfTransformation;     
-         // In case of the option is set to create a dialog box.
-         if (_fitting_mode == -1)
-           {
-             bool transformOkDlg;
-             wxString msg = _T("The image resolution of both images are not compatible. Do you want to tranform it? ");
-             wxDlgTransformByDimensionBySpacingByPixel dlg;
-             dlg.GetTransformType(this,msg,typeOfTransformation,transformOkDlg);
-             // CM Reset the default value (Pixel i.e. 3) if the dialog box returned an inappropriate value.
-             if (transformOkDlg == false)
-               typeOfTransformation = 3;
-           }
-         else
-           typeOfTransformation = _fitting_mode;
-         //EO CM
-
-         printf("EED ColorLayerImageViewPanel::onReadImage call dialog spc size,dim...???\n");
-
+                       // CM
+                       int typeOfTransformation;       
+                       // In case of the option is set to create a dialog box.
+                       if (_fitting_mode == -1)
+                       {
+                               bool transformOkDlg;
+                       wxString msg = _T("The image resolution of both images are not compatible. Do you want to tranform it? ");
+                       wxDlgTransformByDimensionBySpacingByPixel dlg;
+                       dlg.GetTransformType(this,spc,spc,dim,dim,msg,typeOfTransformation,transformOkDlg);
+                       // CM Reset the default value (Pixel i.e. 3) if the dialog box returned an inappropriate value.
+                       if (transformOkDlg == false)
+                               {
+                               typeOfTransformation = 3;
+                               } 
+                       } else {
+                       typeOfTransformation = _fitting_mode;
+                       } // _fitting_mode -1
+
+printf("EED ColorLayerImageViewPanel::SetImage %d\n", typeOfTransformation );
+
+                       //EO CM
             if (typeOfTransformation==1)  // make dimensions equals
             {
                 printf("EED ColorLayerImageViewPanel::onReadImage ...WARNNING.... dif size image spc*dim ofnew image ...???\n");
@@ -295,19 +353,14 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img)
 
             img->SetSpacing(spc);
         } // spc !_spcBase   dim!__dimBase
+    } // _firsttime_mode
 
-//EED01        if (_colorLayerImageView!=NULL)
-//EED01        {
-//EED01            _colorLayerImageView->onThreshold();
-               if (_active==true)
-               {
-                   _colorLayerImageViewManager->onThreshold();
-                RefreshView();
-               }
-//EED01        }
-
+       if (_active==true)
+       {
+           _colorLayerImageViewManager->onThreshold();
+               RefreshView();
+       } // _ative 
 
-    }
 }
 
 
@@ -352,59 +405,43 @@ void ColorLayerImageViewPanel::onReadImage(wxCommandEvent& event)
 //----------------------------------------------------------------------------
 void ColorLayerImageViewPanel::onThresholdChange(wxCommandEvent& event)
 {
-//EED01        if (_colorLayerImageView!=NULL)
-//EED01        {
                if (_thresholdGo)
                {
-//EED01                 _colorLayerImageView->onThresholdChange();
                 _colorLayerImageViewManager->onThresholdChange();
                 RefreshView();
                //std::cout<< "Valor Min: " << minVal << " & Valor Max: " << maxVal  << std::endl;
           } // _thresholdGo
-//EED01        }//_colorLayerImageView
 }
 
 //----------------------------------------------------------------------------
 void ColorLayerImageViewPanel::onThresholdShow(wxCommandEvent& event)
 {
-//EED01        if (_colorLayerImageView!=NULL)
-//EED01        {
         _thresholdGo = _cb_ShowHide->GetValue();
+                       _active = _thresholdGo;
         if (_thresholdGo)
         {
-//EED01            _colorLayerImageView->onThreshold();
                    _colorLayerImageViewManager->onThreshold();
         }else{
-//EED01            _colorLayerImageView->onThresholdRemove( );
                    _colorLayerImageViewManager->onThresholdRemove( );
         }
             RefreshView();
-//EED01        }//_colorLayerImageView
 }
 
 //----------------------------------------------------------------------------
 void ColorLayerImageViewPanel::onThresholdStop()
 {
-//EED01        if (_colorLayerImageView!=NULL)
-//EED01        {
                if (_thresholdGo)
                {
-//EED01                    _colorLayerImageView->onThresholdRemove( );
                    _colorLayerImageViewManager->onThresholdRemove( );
                    _thresholdGo=false;
                }
-//EED01        }//_colorLayerImageView
 }
 
 //----------------------------------------------------------------------------
 void ColorLayerImageViewPanel::onThresholdInterpolation(wxCommandEvent& event)
 {
-//EED01        if (_colorLayerImageView!=NULL)
-//EED01        {
-//EED01                _colorLayerImageView->onThresholdInterpolation(_interpolationCheckBox->GetValue());
           _colorLayerImageViewManager->onThresholdInterpolation(_interpolationCheckBox->GetValue());
                RefreshView();
-//EED01        }//_colorLayerImageView
 }
 
 //----------------------------------------------------------------------------
@@ -438,8 +475,8 @@ void ColorLayerImageViewPanel::onSliceImage(wxScrollEvent& event)
 //----------------------------------------------------------------------------
 void ColorLayerImageViewPanel::onChangeOpacity(wxScrollEvent& event)
 {
-        int opacity = _opacity->GetValue();
-        _colorLayerImageViewManager->onThresholdChangeOpacity(opacity);
+       int opacity = _opacity->GetValue();
+       _colorLayerImageViewManager->onThresholdChangeOpacity(opacity);
        RefreshView();
 }
 
@@ -453,8 +490,11 @@ bool ColorLayerImageViewPanel::IsVisible()
 //----------------------------------------------------------------------------
 void ColorLayerImageViewPanel::SetActive(bool active)
 {
-      _active=active;
-      _cb_ShowHide->SetValue( _active );
+       _active=active;
+       if (_cb_ShowHide!=NULL)
+       {
+               _cb_ShowHide->SetValue( _active );
+       }
 }