From 84bab4239e494e3553b042e67a6e9978ad639cf8 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Wed, 2 Dec 2020 16:16:16 +0100 Subject: [PATCH] Color Layer update --- .../ColorLayerImageViewPanel.cxx | 38 ++++--------------- .../ThresholdImageView/LayerImageBase.cxx | 1 - .../ThresholdImageView/ThresholdImageView.cxx | 38 ++++++++++++------- 3 files changed, 33 insertions(+), 44 deletions(-) diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx index 46c2aae..251df88 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ColorLayerImageViewPanel.cxx @@ -124,25 +124,18 @@ printf("EED wxDlgTransformByDimensionBySpacingByPixel::GetTransformType BBB %d\n **/ 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) - - { - _spcBase[0] = _spcBase[1] = _spcBase[2] = 0; _dimBase[0] = _dimBase[1] = _dimBase[2] = 0; - _cb_ShowHide = NULL; _sl_SliceImageX = NULL; _sl_SliceImageY = NULL; _sl_SliceImageZ = NULL; _histogram = NULL; _histogramMinMaxLevel = NULL; - wxFlexGridSizer * sizer = NULL; _colorLayerImageViewManager = new ColorLayerImageViewManager(); - if (type==1) { sizer = new wxFlexGridSizer(1); @@ -212,14 +205,12 @@ ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, in } // type==1 - if (type==2) { sizer = new wxFlexGridSizer(2); _interpolationCheckBox = new wxCheckBox(this, -1, _T("Interpolate") ); _interpolationCheckBox->SetValue(true); _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 ); // sizer -> Add( new wxStaticText(this,-1,_T("Opacity Level")) , 1, wxEXPAND ); @@ -229,7 +220,6 @@ ColorLayerImageViewPanel::ColorLayerImageViewPanel(wxWindow* parent, int min, in } // type==2 - this->SetSizer( sizer ); // this->SetAutoLayout( true ); // this->Layout(); @@ -244,40 +234,31 @@ ColorLayerImageViewPanel::~ColorLayerImageViewPanel() { } - //---------------------------------------------------------------------------- ColorLayerImageViewManager* ColorLayerImageViewPanel::GetColorLayerImageViewManager() { return _colorLayerImageViewManager; } - //---------------------------------------------------------------------------- void ColorLayerImageViewPanel::SetImage(vtkImageData *img) { if (img!=NULL) - { - + { if (_histogramMinMaxLevel!=NULL) { _histogramMinMaxLevel->Configure( img ); } _colorLayerImageViewManager->SetImage( img ); - double spcOriginalLayer[3]; int dimensionOriginalLayer[3]; - double spcBase[3]; int dimensionBase[3]; - double newSpc[3]; - GetColorLayerImageViewManager()->GetSpcOriginalLayer(0,spcOriginalLayer); GetColorLayerImageViewManager()->GetDimensionOriginalLayer(0,dimensionOriginalLayer); - GetColorLayerImageViewManager()->GetSpcBase(0,spcBase); GetColorLayerImageViewManager()->GetDimensionBase(0,dimensionBase); - if (_sl_SliceImageX!=NULL) { _sl_SliceImageX->SetRange( 0 , dimensionOriginalLayer[0] ); @@ -285,7 +266,6 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img) _sl_SliceImageZ->SetRange( 0 , dimensionOriginalLayer[2] ); } - if ( (spcOriginalLayer[0]!=spcBase[0]) || (spcOriginalLayer[1]!=spcBase[1]) || (spcOriginalLayer[2]!=spcBase[2]) || @@ -349,10 +329,8 @@ void ColorLayerImageViewPanel::SetImage(vtkImageData *img) _colorLayerImageViewManager->onThreshold(); RefreshView(); } // _ative - } - void ColorLayerImageViewPanel::RefreshView() { //EED01 _colorLayerImageView->Refresh(); @@ -387,19 +365,19 @@ void ColorLayerImageViewPanel::onReadImage(wxCommandEvent& event) // w.ShowModal(); printf("EED ColorLayerImageViewPanel::onReadImage ....WARNING... Read dlg. all images creaImageIO ... ???\n"); - creaMaracasVisuKernel::OpenImageDialog diag = creaMaracasVisuKernel::OpenImageDialog(); - - vtkImageChangeInformation *change = vtkImageChangeInformation::New(); - vtkImageData *img = diag.getImageData(); int ext[6]; double spc[6]; double origin[3]; + origin[0] = 0; + origin[1] = 0; + origin[2] = 0; + + creaMaracasVisuKernel::OpenImageDialog diag = creaMaracasVisuKernel::OpenImageDialog(); + vtkImageChangeInformation *change = vtkImageChangeInformation::New(); + vtkImageData *img = diag.getImageData(); 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 ); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx index c295169..cbf55cf 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/LayerImageBase.cxx @@ -547,7 +547,6 @@ void LayerImageBase::onThreshold() #else _thresholdMapper->SetInputData( img ); #endif - _thresholdMapper->SetLookupTable( _thresholdTable ); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageView.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageView.cxx index f20eefc..0ab4c87 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageView.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/ThresholdImageView/ThresholdImageView.cxx @@ -81,9 +81,8 @@ void ThresholdImageView::ConfigLookupTable() // virtual int minVal = floor (_minValue); int maxVal = floor (_maxValue); - vtkLookupTable* thresholdTable = GetThresholdTable(); - thresholdTable->SetNumberOfTableValues(maxTot+1); - thresholdTable->SetTableRange(range); + vtkLookupTable *thresholdTable = GetThresholdTable(); + thresholdTable->SetNumberOfTableValues( (maxTot-minTot) ); thresholdTable->SetAlphaRange(0, 1); thresholdTable->SetValueRange(0, 1); thresholdTable->SetSaturationRange(0, 0); @@ -91,27 +90,40 @@ void ThresholdImageView::ConfigLookupTable() // virtual //Assign a fake color for the upper image, and set the white as transparent int i; - for(i = minTot; i <= maxTot; i++) + int minVal2; + int maxVal2; + int minTot2; + int maxTot2; + + minVal2=minVal-minTot; + maxVal2=maxVal-minTot; + minTot2=minTot-minTot; + maxTot2=maxTot-minTot; + +// thresholdTable->SetTableRange(minVal,maxVal); +//EED You need to do this loop just the first time +// for(i = minTot2; i <= maxTot2; i++) +// { +// thresholdTable->SetTableValue(i,_baseColorR,_baseColorG,_baseColorB, 1); +// } // for + + thresholdTable->SetTableRange(range); + for(i = minTot2; i <= maxTot2; i++) { - if( i >= minVal && i <= maxVal ) + if( i >= minVal2 && i <= maxVal2 ) { thresholdTable->SetTableValue(i,_baseColorR,_baseColorG,_baseColorB, 1); - } - else if( i >= minTot && i < minVal ) + } else if( i >= minTot2 && i < minVal2 ) { thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent - } - else if( i > maxVal && i < maxTot ) + } else if( i > maxVal2 && i < maxTot2 ) { thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent - } - else - { + } else { thresholdTable->SetTableValue(i, 1.0, 1.0, 1.0, 0); //transparent } } // for thresholdTable->Build( ); - } -- 2.47.1