From 708c3b7aed9185a46428310d113fe59562a8d642 Mon Sep 17 00:00:00 2001 From: schaerer Date: Fri, 5 Feb 2010 12:42:49 +0000 Subject: [PATCH] fix long-standing colormap bug --- common/clitkCommon.cxx | 2 +- vv/vvSlicer.cxx | 22 ++++++++++++++++++++++ vv/vvSlicer.h | 3 +++ vv/vvSlicerManager.cxx | 10 ++++------ 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/common/clitkCommon.cxx b/common/clitkCommon.cxx index 4ccceb2..0ee9a74 100644 --- a/common/clitkCommon.cxx +++ b/common/clitkCommon.cxx @@ -82,7 +82,7 @@ void clitk::VerboseInProgress(const int nb, const int current, const int percent oss << std::setw(4) << rounded << '%'; std::cout << oss.str() << std::flush; - for (int i=0; i(this->GetWindowLevel()->GetLookupTable()); + if ( LUT ) + { + double level = this->GetWindowLevel()->GetLevel(); + LUT->SetTableRange(level-fabs(window)/4,level+fabs(window)/4); + LUT->Build(); + } + this->vtkImageViewer2::SetColorWindow(window); +} +void vvSlicer::SetColorLevel(double level) +{ + vtkLookupTable* LUT = static_cast(this->GetWindowLevel()->GetLookupTable()); + if ( LUT ) + { + double window = this->GetWindowLevel()->GetWindow(); + LUT->SetTableRange(level-fabs(window)/4,level+fabs(window)/4); + LUT->Build(); + } + this->vtkImageViewer2::SetColorLevel(level); +} void vvSlicer::Render() { if (this->GetWindowLevel()->GetLookupTable() && !this->mOverlay && !this->mFusion) diff --git a/vv/vvSlicer.h b/vv/vvSlicer.h index a25748a..7060b25 100644 --- a/vv/vvSlicer.h +++ b/vv/vvSlicer.h @@ -159,6 +159,9 @@ public: ///Toggle temporal superposition of contours void ToggleContourSuperposition(); + virtual void SetColorWindow(double s); + virtual void SetColorLevel(double s); + protected: vvSlicer(); ~vvSlicer(); diff --git a/vv/vvSlicerManager.cxx b/vv/vvSlicerManager.cxx index 7618bf2..4aa48cf 100644 --- a/vv/vvSlicerManager.cxx +++ b/vv/vvSlicerManager.cxx @@ -856,7 +856,7 @@ void vvSlicerManager::SetPreset(int preset) break; case 7: window=1.; - level=1; + level=0.; break; } mPreset = preset; @@ -886,8 +886,6 @@ void vvSlicerManager::SetColorMap(int colormap) switch (colormap) { case -1: - if (LUT) - LUT->SetTableRange(level-fabs(window)/4,level+fabs(window)/4); break; case 0: LUT = NULL; @@ -895,7 +893,6 @@ void vvSlicerManager::SetColorMap(int colormap) case 1: if (LUT == NULL) LUT = vtkLookupTable::New(); - LUT->SetTableRange(level-fabs(window)/4,level+fabs(window)/4); LUT->SetValueRange(0,1); LUT->SetSaturationRange(1,1); LUT->SetHueRange(0,0.18); @@ -903,7 +900,6 @@ void vvSlicerManager::SetColorMap(int colormap) case 2: if (LUT == NULL) LUT = vtkLookupTable::New(); - LUT->SetTableRange(level-fabs(window)/4,level+fabs(window)/4); LUT->SetValueRange(0,1); LUT->SetSaturationRange(1,1); LUT->SetHueRange(0.4,0.80); @@ -911,7 +907,6 @@ void vvSlicerManager::SetColorMap(int colormap) case 3: if (LUT == NULL) LUT = vtkLookupTable::New(); - LUT->SetTableRange(level-fabs(window)/4,level+fabs(window)/4); LUT->SetValueRange(0,1); LUT->SetSaturationRange(1,1); LUT->SetHueRange(0,1); @@ -926,7 +921,10 @@ void vvSlicerManager::SetColorMap(int colormap) break; } if (LUT) + { + LUT->SetTableRange(level-fabs(window)/4,level+fabs(window)/4); LUT->Build(); + } vtkLookupTable* fusLUT = NULL; if (mSlicers[0]->GetFusion()) { -- 2.47.1