]> Creatis software - clitk.git/commitdiff
window/level in read/save state
authorRomulo Pinho <romulo.pinho@lyon.unicancer.fr>
Wed, 17 Oct 2012 10:41:40 +0000 (12:41 +0200)
committerRomulo Pinho <romulo.pinho@lyon.unicancer.fr>
Wed, 17 Oct 2012 10:41:40 +0000 (12:41 +0200)
vv/vvReadState.cxx
vv/vvSaveState.cxx
vv/vvSlicerManager.cxx
vv/vvSlicerManager.h

index 6d61ca5df6b8d0132fb75be64459bfe18bac46fe..13bb083867ab6e6a008fecba941c92e154b6525b 100644 (file)
@@ -111,7 +111,23 @@ std::string  vvReadState::ReadImage()
         }
       }
       else if (current_index >= 0) {
-        if (value == "Fusion")
+        vvSlicerManager* slicerManager = m_Window->GetSlicerManagers()[current_index];
+        if (value == "Preset") {
+          double vali = m_XmlReader->readElementText().toInt();
+          if (!m_XmlReader->hasError())
+            slicerManager->SetPreset(vali);
+        }
+        else if (value == "Window") {
+          double vald = m_XmlReader->readElementText().toDouble();
+          if (!m_XmlReader->hasError())
+            slicerManager->SetColorWindow(vald);
+        }
+        else if (value == "Level") {
+          double vald = m_XmlReader->readElementText().toDouble();
+          if (!m_XmlReader->hasError())
+            slicerManager->SetColorLevel(vald);
+        }
+        else if (value == "Fusion")
           value = ReadFusion(current_index);
         else if (value == "Overlay")
           value = ReadOverlay(current_index);
index 71e22ef0cff854e7305484255b83e23a0e0deba1..d4a76bd2d9a20010bd4e9df36f48aa651212749a 100644 (file)
@@ -82,14 +82,20 @@ void vvSaveState::SaveImage(const QTreeWidgetItem* item, int index)
   const vvSlicerManager * slicerManager = m_Window->GetSlicerManagers()[index];
   m_XmlWriter->writeStartElement("Image");
 
-  std::ostringstream indexStr;
-  indexStr.str("");
-  indexStr << index;
-  m_XmlWriter->writeAttribute("Index", indexStr.str().c_str());
+  std::ostringstream valueStr;
+  valueStr.str("");
+  valueStr << index;
+  m_XmlWriter->writeAttribute("Index", valueStr.str().c_str());
 
   std::string filename = item->data(0, Qt::UserRole).toString().toStdString();
   m_XmlWriter->writeTextElement("FileName", QDir::current().absoluteFilePath(filename.c_str()));
-
+  int preset = slicerManager->GetPreset();
+  m_XmlWriter->writeTextElement("Preset", QString::number(preset));
+  if (preset == 6) {
+    m_XmlWriter->writeTextElement("Window", QString::number(slicerManager->GetColorWindow()));
+    m_XmlWriter->writeTextElement("Level", QString::number(slicerManager->GetColorLevel()));
+  }
+  
   QTreeWidgetItem* item_child;
   std::string role;
   for (int i = 0; i < item->childCount(); i++) {
index 9ff163eb1990e519bb1a2668b80cc5c54b0539ef..9331bf1ab78a859dcfaf96c4b092c8f4ce3f7454 100644 (file)
@@ -737,7 +737,7 @@ void vvSlicerManager::UpdateLinkedNavigation(vvSlicer *refSlicer, bool bPropagat
 //----------------------------------------------------------------------------
 
 //----------------------------------------------------------------------------
-double vvSlicerManager::GetColorWindow()
+double vvSlicerManager::GetColorWindow() const
 {
   if (mSlicers.size())
     return mSlicers[0]->GetColorWindow();
@@ -747,7 +747,7 @@ double vvSlicerManager::GetColorWindow()
 
 
 //----------------------------------------------------------------------------
-double vvSlicerManager::GetColorLevel()
+double vvSlicerManager::GetColorLevel() const
 {
   if (mSlicers.size())
     return mSlicers[0]->GetColorLevel();
index 6cc9333ca8b157846236f27a75a0b549187435a9..1824524ade043e8a4fb8a74a05ade831bbfe43fa 100644 (file)
@@ -146,15 +146,15 @@ class vvSlicerManager : public QObject {
     mFusionShowLegend = show;
   }
 
-  double GetColorWindow();
-  double GetColorLevel();
+  double GetColorWindow() const;
+  double GetColorLevel() const;
   double GetOverlayColorWindow() const;
   double GetOverlayColorLevel() const;
   bool GetLinkOverlayWindowLevel() const;
   int GetColorMap() {
     return mColorMap;
   }
-  int GetPreset() {
+  int GetPreset() const {
     return mPreset;
   }
   SlicingPresetType GetSlicingPreset() {