]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx
#3418 creaMaracasVisu Feature New Normal - ManualPaint_model with openmp
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / ThresholdImageView / ColorLayerImageViewPanel.cxx
index 5f08d62021a081d794c46d1884032c0c7265303a..46c2aae99bb70208ef1cd5729cd5dec5b0487d1b 100644 (file)
@@ -122,7 +122,7 @@ printf("EED wxDlgTransformByDimensionBySpacingByPixel::GetTransformType BBB %d\n
 /**
  ** Begin of the threshold panel
  **/
-ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, int max, int type)
+ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, int max,int opacity, int type)
 //: wxPanel(parent, -1, wxDefaultPosition, wxSize(600,100), wxBORDER_SUNKEN)
 
 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL)
@@ -163,7 +163,7 @@ ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, in
                _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);
+               _opacity = new wxSlider(this, wxID_ANY, opacity, 0, 100, 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 );
@@ -218,7 +218,7 @@ ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, in
                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);
+               _opacity = new wxSlider(this, wxID_ANY, opacity, 0, 100, wxDefaultPosition, wxDefaultSize, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
 
                Connect( _interpolationCheckBox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, (wxObjectEventFunction) &ColorLayerImageViewPanel::onThresholdInterpolation );
                Connect( _opacity->GetId(), wxEVT_SCROLL_THUMBTRACK, (wxObjectEventFunction) &ColorLayerImageViewPanel::onChangeOpacity );
@@ -388,7 +388,24 @@ void ColorLayerImageViewPanel::onReadImage(wxCommandEvent& event)
        printf("EED ColorLayerImageViewPanel::onReadImage ....WARNING... Read dlg. all images creaImageIO ... ???\n");
 
        creaMaracasVisuKernel::OpenImageDialog diag = creaMaracasVisuKernel::OpenImageDialog();
-       SetImage( diag.getImageData() );
+       
+       vtkImageChangeInformation *change = vtkImageChangeInformation::New();
+       vtkImageData *img = diag.getImageData();
+       int     ext[6];
+       double  spc[6];
+       double  origin[3];
+       img             -> GetExtent( ext );    
+       img             -> GetSpacing( spc );   
+       change  -> SetInputData( img );
+       origin[0]=0;
+       origin[1]=0;
+       origin[2]=0;
+       change  -> SetOutputSpacing( spc[0] , spc[1] , spc [2] );
+       change  -> SetOutputExtentStart(0,0,0);
+       change  -> SetOutputOrigin( origin );
+       change  -> Modified();          //important
+       change  -> Update();            //important
+       SetImage( change->GetOutput() );
 }
 
 //----------------------------------------------------------------------------
@@ -462,13 +479,22 @@ void ColorLayerImageViewPanel::onSliceImage(wxScrollEvent& event)
 }
 
 //----------------------------------------------------------------------------
-void ColorLayerImageViewPanel::onChangeOpacity(wxScrollEvent& event)
+void ColorLayerImageViewPanel::ChangeOpacity()
 {
        int opacity = _opacity->GetValue();
        _colorLayerImageViewManager->onThresholdChangeOpacity(opacity);
        RefreshView();
 }
 
+//----------------------------------------------------------------------------
+void ColorLayerImageViewPanel::onChangeOpacity(wxScrollEvent& event)
+{
+       ChangeOpacity();
+//     int opacity = _opacity->GetValue();
+//     _colorLayerImageViewManager->onThresholdChangeOpacity(opacity);
+//     RefreshView();
+}
+
 
 //----------------------------------------------------------------------------
 bool ColorLayerImageViewPanel::IsVisible()