]> Creatis software - clitk.git/commitdiff
correct bugs related to new window/level option
authorRomulo Pinho <romulo.pinho@lyon.unicancer.fr>
Fri, 25 Jan 2013 13:51:47 +0000 (14:51 +0100)
committerRomulo Pinho <romulo.pinho@lyon.unicancer.fr>
Fri, 25 Jan 2013 13:51:47 +0000 (14:51 +0100)
- also refactored to avoid similar problems in the future

vv/vvMainWindow.cxx
vv/vvSlicerManager.cxx
vv/vvSlicerManager.h
vv/vvSlicerManagerCommand.cxx

index eb5fe7ec96b6ffaee4501de96ffdb27438e63925..5c7bbfd76f3ccb531c54b1ae01fe0b0d0358b33e 100644 (file)
@@ -958,7 +958,7 @@ void vvMainWindow::LoadImages(std::vector<std::string> files, vvImageReader::Loa
     double range[2];
     mSlicerManagers.back()->GetImage()->GetFirstVTKImageData()->GetScalarRange(range);
     if ((range[0] == 0) && (range[1] == 1)) {
-      presetComboBox->setCurrentIndex(5);// binary
+      presetComboBox->setCurrentIndex(WL_BINARY);// binary
     } else {
       // TODO
     }
@@ -1797,7 +1797,7 @@ void vvMainWindow::WindowLevelChanged()
 //------------------------------------------------------------------------------
 void vvMainWindow::WindowLevelEdited()
 {
-  presetComboBox->setCurrentIndex(6);
+  presetComboBox->setCurrentIndex(WL_USER);
   UpdateWindowLevel();
 }
 //------------------------------------------------------------------------------
@@ -1807,7 +1807,7 @@ void vvMainWindow::SetWindowLevel(double w, double l)
 {
   windowSpinBox->setValue(w);
   levelSpinBox->setValue(l);
-  presetComboBox->setCurrentIndex(6);
+  presetComboBox->setCurrentIndex(WL_USER);
   colorMapComboBox->setCurrentIndex(0);
   UpdateWindowLevel();
 }
@@ -1817,7 +1817,7 @@ void vvMainWindow::SetWindowLevel(double w, double l)
 void vvMainWindow::UpdateWindowLevel()
 {
   if (DataTree->selectedItems().size()) {
-    if (presetComboBox->currentIndex() == 7) //For ventilation
+    if (presetComboBox->currentIndex() == WL_VENTILATION) //For ventilation
       colorMapComboBox->setCurrentIndex(5);
     int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
     mSlicerManagers[index]->SetColorWindow(windowSpinBox->value());
@@ -1853,7 +1853,7 @@ void vvMainWindow::SwitchWindowLevel()
 {
   int index = GetSlicerIndexFromItem(DataTree->selectedItems()[0]);
   int window = mSlicerManagers[index]->GetColorWindow();
-  presetComboBox->setCurrentIndex(6);
+  presetComboBox->setCurrentIndex(WL_USER);
   windowSpinBox->setValue(-window);
   UpdateWindowLevel();
 }
@@ -1872,7 +1872,7 @@ void vvMainWindow::ApplyWindowLevelToAllImages()
       continue;
     mSlicerManagers[i]->SetColorWindow(window);
     mSlicerManagers[i]->SetColorLevel(level);
-    mSlicerManagers[i]->SetPreset(6);
+    mSlicerManagers[i]->SetPreset(WL_USER);
     mSlicerManagers[i]->Render();
   }
 }
@@ -1885,7 +1885,7 @@ void vvMainWindow::ApplyWindowToSetOfImages(double window, unsigned int indexMin
     if (mSlicerManagers[i] == NULL)
       continue;
     mSlicerManagers[i]->SetColorWindow(window);
-    mSlicerManagers[i]->SetPreset(6);
+    mSlicerManagers[i]->SetPreset(WL_USER);
     mSlicerManagers[i]->Render();
   }
 }
@@ -1898,7 +1898,7 @@ void vvMainWindow::ApplyLevelToSetOfImages(double level, unsigned int indexMin,
     if (mSlicerManagers[i] == NULL)
       continue;
     mSlicerManagers[i]->SetColorLevel(level);
-    mSlicerManagers[i]->SetPreset(6);
+    mSlicerManagers[i]->SetPreset(WL_USER);
     mSlicerManagers[i]->Render();
   }
 }
index 5e799a0e6f37421db5b79229bab9d8b5c747a4d8..e975da28babd5ee04bdb31120ccd77bd50b5412f 100644 (file)
@@ -1244,45 +1244,46 @@ void vvSlicerManager::SetSlicingPreset(SlicingPresetType preset)
 //----------------------------------------------------------------------------\r
 void vvSlicerManager::SetPreset(int preset)\r
 {\r
+\r
   //vtkLookupTable* LUT = static_cast<vtkLookupTable*>(mSlicers[0]->GetWindowLevel()->GetLookupTable());\r
   double window = mSlicers[0]->GetColorWindow();\r
   double level = mSlicers[0]->GetColorLevel();\r
 \r
   std::string component_type=mImage->GetScalarTypeAsITKString();\r
   switch (preset) {\r
-  case 0:\r
+  case WL_AUTO:\r
     double range[2];\r
     mImage->GetScalarRange(range);\r
     window = range[1] - range[0];\r
     level = (range[1] + range[0])* 0.5;\r
     break;\r
-  case 1:\r
+  case WL_HOUNSFIELD:\r
     window = 2000;\r
     level = 0;\r
     break;\r
-  case 2:\r
+  case WL_SOFTTISSUE:\r
     window = 400;\r
     level = 20;\r
     break;\r
-  case 3: // lungs (same as FOCAL)\r
+  case WL_LUNGS: // lungs (same as FOCAL)\r
     window = 1700;\r
     level = -300;\r
     break;\r
-  case 4:\r
+  case WL_BONES:\r
     window = 1000;\r
     level = 500;\r
     break;\r
-  case 5:\r
+  case WL_HEAD:\r
     window = 200;\r
     level = 70;\r
     break;\r
-  case 6:\r
+  case WL_BINARY:\r
     window = 1;\r
     level = 0.5;\r
     break;\r
-  case 7:\r
+  case WL_USER:\r
     break;\r
-  case 8:\r
+  case WL_VENTILATION:\r
     window=1.;\r
     level=0.;\r
     break;\r
@@ -1332,7 +1333,7 @@ void vvSlicerManager::SetLocalColorWindowing(const int slicer, const bool bCtrlK
                                                           this->mSlicers[slicer]->GetConcatenatedTransform());\r
     this->SetColorWindow(max-min);\r
     this->SetColorLevel(0.5*(min+max));\r
-    this->SetPreset(6);\r
+    this->SetPreset(WL_USER);\r
   }\r
   this->Render();\r
   this->UpdateWindowLevel();\r
index d634fbddafd779ecf7ae817178e5536fad5ed1fb..3479dc6c887dfc20d5ea5e844187345261f52f00 100644 (file)
@@ -47,6 +47,18 @@ class vvImageReader;
 class vvImageReader;
 class vvLandmarks;
 
+enum WindowLevelPreset {
+  WL_AUTO,
+  WL_HOUNSFIELD,
+  WL_SOFTTISSUE,
+  WL_LUNGS,
+  WL_BONES,
+  WL_HEAD,
+  WL_BINARY,
+  WL_USER,
+  WL_VENTILATION
+};
+
 //------------------------------------------------------------------------------
 class vvSlicerManager : public QObject {
   Q_OBJECT
index ad80b925a6d0b5bfc34fe6516e5f1d889bf9c003..f5d2b699bd495e881d533abaad7c20a43d511c83 100644 (file)
@@ -113,33 +113,33 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller,
           return;
         }
         if (KeyPress == "0") {
-          this->SM->SetPreset(0);
+          this->SM->SetPreset(WL_AUTO);
           this->SM->UpdateWindowLevel();
           return;
         }
         if (KeyPress == "1") {
-          this->SM->SetPreset(1);
+          this->SM->SetPreset(WL_HOUNSFIELD);
           this->SM->UpdateWindowLevel();
           return;
         }
         if (KeyPress == "2") {
-          this->SM->SetPreset(2);
+          this->SM->SetPreset(WL_SOFTTISSUE);
           this->SM->UpdateWindowLevel();
 
           return;
         }
         if (KeyPress == "3") {
-          this->SM->SetPreset(3);
+          this->SM->SetPreset(WL_LUNGS);
           this->SM->UpdateWindowLevel();
           return;
         }
         if (KeyPress == "4") {
-          this->SM->SetPreset(4);
+          this->SM->SetPreset(WL_BONES);
           this->SM->UpdateWindowLevel();
           return;
         }
         if (KeyPress == "5") {
-          this->SM->SetPreset(5);
+          this->SM->SetPreset(WL_HEAD);
           this->SM->UpdateWindowLevel();
           return;
         }
@@ -164,7 +164,7 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller,
           return;
         }
         if (KeyPress == "equal") { //keycodes are in vtkWin32RenderWindowInteractor
-          this->SM->SetPreset(7);
+          this->SM->SetPreset(WL_VENTILATION);
           //this->SM->SetColorMap(1);
           this->SM->UpdateWindowLevel();
           return;
@@ -420,7 +420,7 @@ void vvSlicerManagerCommand::Execute(vtkObject *caller,
 
       this->SM->SetColorWindow(window*dx);
       this->SM->SetColorLevel(level-dy);
-      this->SM->SetPreset(6);
+      this->SM->SetPreset(WL_USER);
       this->SM->Render();
       this->SM->UpdateWindowLevel();
       return;