]> Creatis software - clitk.git/commitdiff
fix long-standing colormap bug
authorschaerer <schaerer>
Fri, 5 Feb 2010 12:42:49 +0000 (12:42 +0000)
committerschaerer <schaerer>
Fri, 5 Feb 2010 12:42:49 +0000 (12:42 +0000)
common/clitkCommon.cxx
vv/vvSlicer.cxx
vv/vvSlicer.h
vv/vvSlicerManager.cxx

index 4ccceb2761da9eb8b70b64f8074983442b3e04e1..0ee9a74e0bd8fab9c27dc4f177874aadeb265286 100644 (file)
@@ -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<oss.str().length(); ++i) 
+  for (unsigned int i=0; i<oss.str().length(); ++i) 
        std::cout << "\b" << std::flush;
 }
 //------------------------------------------------------------------
index 93ce4182d9f92f84534473c59f3280e3b581c264..2b29e2f96e4660a46b4da6aa9fd54bbf0e94d593 100644 (file)
@@ -973,6 +973,28 @@ void vvSlicer::FlipVerticalView()
     }
 }
 
+void vvSlicer::SetColorWindow(double window)
+{
+    vtkLookupTable* LUT = static_cast<vtkLookupTable*>(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<vtkLookupTable*>(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)
index a25748a95b6ea3c1e7cc6e02cf912ef518a6f75d..7060b25318288300308e9ad9324fda653f76baf5 100644 (file)
@@ -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();
index 7618bf2ceb7825ae70be3b560d2af2e76acc586b..4aa48cf562d8d92e36ec2aacbce888062bb0a6dd 100644 (file)
@@ -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())
     {