]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx
histogram BUG
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / ThresholdImageView / ColorLayerImageViewPanel.cxx
index 963a51c222ec7ab2c888be502b3a19bc616cfc33..50ee4ff5a8e7843a76e9e76c56c8bf2400b96639 100644 (file)
@@ -48,7 +48,7 @@ wxDlgTransformByDimensionBySpacingByPixel::~wxDlgTransformByDimensionBySpacingBy
 
 void wxDlgTransformByDimensionBySpacingByPixel::GetTransformType(wxWindow *parent , 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(590,190));
        wxSizer* buttonsSizer   = dial->CreateSeparatedButtonSizer(wxOK|wxCANCEL);
        wxBoxSizer *dialSizer   = new wxBoxSizer(wxVERTICAL);
 
@@ -59,7 +59,6 @@ void wxDlgTransformByDimensionBySpacingByPixel::GetTransformType(wxWindow *paren
        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 );
        dialSizer->Add(radioOpts,0,wxGROW);
        dialSizer->Add( new wxStaticText(dial,-1,_T(" "))  , 0, wxGROW );
@@ -88,14 +87,12 @@ void wxDlgTransformByDimensionBySpacingByPixel::GetTransformType(wxWindow *paren
  ** Begin of the threshold panel
  **/
 ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, int max, int type)
-: wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_SUNKEN)
+: wxPanel(parent, -1, wxDefaultPosition, wxSize(600,100), wxBORDER_SUNKEN)
 {
-       printf("EED ColorLayerImageViewPanel::ColorLayerImageViewPanel start \n");
 
        _spcBase[0] = _spcBase[1] = _spcBase[2] = 0;
        _dimBase[0] = _dimBase[1] = _dimBase[2] = 0;
 
-//EED01        _colorLayerImageView            = new ColorLayerImageView();
        _colorLayerImageViewManager     = new ColorLayerImageViewManager();
 
        _btn_ReadImage                  = new wxButton(this, wxID_ANY, _T("Read Image") );
@@ -112,11 +109,16 @@ ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, in
        _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);
 
+       _histogram=NULL;
+       _histogramMinMaxLevel=NULL;
+
+//     _histogram                                      = new Histogram(  this , -1, wxPoint(0,0), wxSize(400,400), /*wxNO_BORDER*/ wxBORDER_DEFAULT ); 
+//     _histogramMinMaxLevel   = new HistogramMinMaxLevel( (HistogramBase*)_histogram );
+
        if (type==0)
        {
        }
@@ -127,7 +129,7 @@ ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, in
 
 
        Connect( _btn_ReadImage->GetId(), wxEVT_COMMAND_BUTTON_CLICKED  , (wxObjectEventFunction) &ColorLayerImageViewPanel::onReadImage );
-       Connect( _cb_ShowHide->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED , (wxObjectEventFunction) &ColorLayerImageViewPanel::onThresholdShow );
+       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 );
@@ -150,28 +152,27 @@ ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, in
        Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_PAGEUP          , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
        Connect( _sl_SliceImageZ->GetId(), wxEVT_SCROLL_PAGEDOWN                , (wxObjectEventFunction) &ColorLayerImageViewPanel::onSliceImage );
 
-
-
        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("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( 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 );
@@ -188,26 +189,14 @@ ColorLayerImageViewPanel::~ColorLayerImageViewPanel()
 }
 
 
-//EED01  
-//EED01  //----------------------------------------------------------------------------
-//EED01  void ColorLayerImageViewPanel::SetColorLayerImageView(ColorLayerImageView* colorLayerImageView)
-//EED01  {
-//EED01        _colorLayerImageView = colorLayerImageView;
-//EED01  }
-//EED01  
-//EED01  //----------------------------------------------------------------------------
-//EED01  ColorLayerImageView* ColorLayerImageViewPanel::GetColorLayerImageView()
-//EED01  {
-//EED01        return _colorLayerImageView;
-//EED01  }
-
-
+//----------------------------------------------------------------------------
 ColorLayerImageViewManager* ColorLayerImageViewPanel::GetColorLayerImageViewManager()
 {
    return _colorLayerImageViewManager;
 }
 
 
+//----------------------------------------------------------------------------
 // This is the new spacing of the background image  (1,1,1)
 void ColorLayerImageViewPanel::SetBaseSpacing(double spc[3])
 {
@@ -220,6 +209,7 @@ void ColorLayerImageViewPanel::SetBaseSpacing(double spc[3])
        _spcBase[2] = 1;
 }
 
+//----------------------------------------------------------------------------
 // This is the Original spacing of the background image
 void ColorLayerImageViewPanel::SetOriginalSpacing(double spc[3])
 {
@@ -228,6 +218,7 @@ void ColorLayerImageViewPanel::SetOriginalSpacing(double spc[3])
        _spcOrg[2] = spc[2];
 }
 
+//----------------------------------------------------------------------------
 // This is the size in pixels of the background image
 void ColorLayerImageViewPanel::SetBaseDimension(int dim[3])
 {
@@ -241,6 +232,10 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img)
 {
     if (img!=NULL)
     {
+               if (_histogramMinMaxLevel!=NULL) 
+               {
+                       _histogramMinMaxLevel->Configure( img );
+               }
         _colorLayerImageViewManager->SetImage( img );
 
         double spc[3];
@@ -276,9 +271,6 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img)
          else
            typeOfTransformation = _fitting_mode;
          //EO CM
-
-         printf("EED ColorLayerImageViewPanel::onReadImage call dialog spc size,dim...???\n");
-
             if (typeOfTransformation==1)  // make dimensions equals
             {
                 printf("EED ColorLayerImageViewPanel::onReadImage ...WARNNING.... dif size image spc*dim ofnew image ...???\n");
@@ -303,16 +295,16 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img)
 
             img->SetSpacing(spc);
         } // spc !_spcBase   dim!__dimBase
+    } // _firsttime_mode
 
-//EED01        if (_colorLayerImageView!=NULL)
-//EED01        {
-//EED01            _colorLayerImageView->onThreshold();
-               _colorLayerImageViewManager->onThreshold();
-               RefreshView();
-//EED01        }
-
+printf("EED ColorLayerImageViewPanel::SetImage\n");
+       if (_active==true)
+       {
+printf("EED ColorLayerImageViewPanel::SetImage _active=true \n");
+           _colorLayerImageViewManager->onThreshold();
+               RefreshView();
+       } // _ative 
 
-    }
 }
 
 
@@ -357,72 +349,52 @@ 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());
+          _colorLayerImageViewManager->onThresholdInterpolation(_interpolationCheckBox->GetValue());
                RefreshView();
-//EED01        }//_colorLayerImageView
 }
 
 //----------------------------------------------------------------------------
 void ColorLayerImageViewPanel::onSliceFixDinamic(wxCommandEvent& event)
 {
-//EED01        if (_colorLayerImageView!=NULL)
-//EED01        {
         bool fixdin = _cb_SliceFixDinamic->GetValue();
-//EED01        _colorLayerImageView->SetSliceFixDynamic( fixdin );
         _colorLayerImageViewManager->SetSliceFixDynamic( fixdin );
         if (fixdin==false)
         {
-//EED01            _colorLayerImageView->SetZ2( _sl_SliceImage->GetValue() );
             _colorLayerImageViewManager->SetX2( _sl_SliceImageX->GetValue() );
             _colorLayerImageViewManager->SetY2( _sl_SliceImageY->GetValue() );
             _colorLayerImageViewManager->SetZ2( _sl_SliceImageZ->GetValue() );
@@ -430,38 +402,26 @@ void ColorLayerImageViewPanel::onSliceFixDinamic(wxCommandEvent& event)
         _sl_SliceImageX->Enable(!fixdin);
         _sl_SliceImageY->Enable(!fixdin);
         _sl_SliceImageZ->Enable(!fixdin);
-//EED01        _colorLayerImageView->onThreshold();
         _colorLayerImageViewManager->onThreshold();
        RefreshView();
-//EED01        }//_colorLayerImageView
 }
 
 //----------------------------------------------------------------------------
 void ColorLayerImageViewPanel::onSliceImage(wxScrollEvent& event)
 {
-//EED01        if (_colorLayerImageView!=NULL)
-//EED01        {
-//EED01        _colorLayerImageView->SetZ2( _sl_SliceImage->GetValue() );
-//EED01        _colorLayerImageView->onThreshold();
-//EED01        RefreshView();
-         _colorLayerImageViewManager->SetX2( _sl_SliceImageX->GetValue() );
-         _colorLayerImageViewManager->SetY2( _sl_SliceImageY->GetValue() );
-         _colorLayerImageViewManager->SetZ2( _sl_SliceImageZ->GetValue() );
-         _colorLayerImageViewManager->onThreshold();
+   _colorLayerImageViewManager->SetX2( _sl_SliceImageX->GetValue() );
+   _colorLayerImageViewManager->SetY2( _sl_SliceImageY->GetValue() );
+   _colorLayerImageViewManager->SetZ2( _sl_SliceImageZ->GetValue() );
+   _colorLayerImageViewManager->onThreshold();
        RefreshView();
-//EED01        }//_colorLayerImageView
 }
 
 //----------------------------------------------------------------------------
 void ColorLayerImageViewPanel::onChangeOpacity(wxScrollEvent& event)
 {
-//EED01        if (_colorLayerImageView!=NULL)
-//EED01        {
-        int opacity = _opacity->GetValue();
-//EED01        _colorLayerImageView->onThresholdChangeOpacity(opacity);
-        _colorLayerImageViewManager->onThresholdChangeOpacity(opacity);
+       int opacity = _opacity->GetValue();
+       _colorLayerImageViewManager->onThresholdChangeOpacity(opacity);
        RefreshView();
-//EED01        }//_colorLayerImageView
 }
 
 
@@ -471,6 +431,12 @@ bool ColorLayerImageViewPanel::IsVisible()
        return _thresholdGo;
 }
 
+//----------------------------------------------------------------------------
+void ColorLayerImageViewPanel::SetActive(bool active)
+{
+      _active=active;
+      _cb_ShowHide->SetValue( _active );
+}
 
 
 // EOF