]> Creatis software - clitk.git/commitdiff
Add Fusion properties to SaveState / ReadState
authorVivien Delmon <vivien.delmon@creatis.insa-lyon.fr>
Tue, 27 Dec 2011 14:35:44 +0000 (15:35 +0100)
committerVivien Delmon <vivien.delmon@creatis.insa-lyon.fr>
Tue, 27 Dec 2011 14:44:42 +0000 (15:44 +0100)
- Add constness on QTreeWidgetItem.
- Use vvSlicerManagers to Get/Set Fusion properties.

vv/vvReadState.cxx
vv/vvSaveState.cxx
vv/vvSaveState.h

index 83a7c5e17e4194e4c1474d519f5310da8db55969..62d8b5911ca12b504d6fcd268786657d8d55363f 100644 (file)
@@ -1,5 +1,6 @@
 #include "vvReadState.h"
 #include "vvMainWindow.h"
+#include "vvSlicerManager.h"
 
 #include <qtreewidget.h>
 
@@ -75,7 +76,7 @@ std::string  vvReadState::ReadImage()
         }
       }
       else if (current_index >= 0) {
-        if (value == "Fusion") 
+        if (value == "Fusion")
           value = ReadFusion(current_index);
         else if (value == "Overlay")
           value = ReadOverlay(current_index);
@@ -94,6 +95,9 @@ std::string  vvReadState::ReadImage()
 std::string vvReadState::ReadFusion(int index)
 {
   std::string file, value;
+  int vali;
+  double vald;
+  vvSlicerManager* slicerManager = m_Window->GetSlicerManagers()[index];
   while (!m_XmlReader->isEndElement() || value != "Fusion") {
     m_XmlReader->readNext();
     value = m_XmlReader->qualifiedName().toString().toStdString();
@@ -103,8 +107,34 @@ std::string vvReadState::ReadFusion(int index)
         if (!m_XmlReader->hasError())
           m_Window->AddFusionImage(index, file.c_str());
       }
+      if (value == "FusionOpacity") {
+        vali = m_XmlReader->readElementText().toInt();
+        if (!m_XmlReader->hasError())
+          slicerManager->SetFusionOpacity(vali);
+      }
+      if (value == "FusionThresholdOpacity") {
+        vali = m_XmlReader->readElementText().toInt();
+        if (!m_XmlReader->hasError())
+          slicerManager->SetFusionThresholdOpacity(vali);
+      }
+      if (value == "FusionColorMap") {
+        vali = m_XmlReader->readElementText().toInt();
+        if (!m_XmlReader->hasError())
+          slicerManager->SetFusionColorMap(vali);
+      }
+      if (value == "FusionWindow") {
+        vald = m_XmlReader->readElementText().toDouble();
+        if (!m_XmlReader->hasError())
+          slicerManager->SetFusionWindow(vald);
+      }
+      if (value == "FusionLevel") {
+        vald = m_XmlReader->readElementText().toDouble();
+        if (!m_XmlReader->hasError())
+          slicerManager->SetFusionLevel(vald);
+      }
     }
   }
+  m_Window->ImageInfoChanged();
   return value;
 }
 
index e573bb9e0f9bcb940c5863f7a6dd5a6ab8b447dd..e7b6193df155720990debc2b51b61f966ffa75ac 100644 (file)
@@ -59,10 +59,11 @@ void vvSaveState::SaveTree()
   m_XmlWriter->writeEndElement();
 }
 
-void vvSaveState::SaveImage(QTreeWidgetItem* item, int index)
+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;
@@ -70,28 +71,33 @@ void vvSaveState::SaveImage(QTreeWidgetItem* item, int index)
 
   std::string filename = item->data(0, Qt::UserRole).toString().toStdString();
   m_XmlWriter->writeTextElement("FileName", QDir::current().absoluteFilePath(filename.c_str()));
-  
+
   QTreeWidgetItem* item_child;
   std::string role;
   for (int i = 0; i < item->childCount(); i++) {
     item_child = item->child(i);
     role = item_child->data(1,Qt::UserRole).toString().toStdString();
     if (role == "fusion")
-      SaveFusion(item_child);
+      SaveFusion(item_child, slicerManager);
     else if (role == "overlay")
       SaveOverlay(item_child);
     else if (role == "vector")
       SaveVector(item_child);
   }
-  
+
   m_XmlWriter->writeEndElement();
 }
 
-void vvSaveState::SaveFusion(QTreeWidgetItem* item)
+void vvSaveState::SaveFusion(const QTreeWidgetItem* item, const vvSlicerManager* vvManager)
 {
   m_XmlWriter->writeStartElement("Fusion");
   std::string filename = item->data(0, Qt::UserRole).toString().toStdString();
   m_XmlWriter->writeTextElement("FileName", QDir::current().absoluteFilePath(filename.c_str()));
+  m_XmlWriter->writeTextElement("FusionOpacity", QString::number(vvManager->GetFusionOpacity()));
+  m_XmlWriter->writeTextElement("FusionThresholdOpacity", QString::number(vvManager->GetFusionThresholdOpacity()));
+  m_XmlWriter->writeTextElement("FusionColorMap", QString::number(vvManager->GetFusionColorMap()));
+  m_XmlWriter->writeTextElement("FusionWindow", QString::number(vvManager->GetFusionWindow()));
+  m_XmlWriter->writeTextElement("FusionLevel", QString::number(vvManager->GetFusionLevel()));
   m_XmlWriter->writeEndElement();
 }
 
@@ -103,7 +109,7 @@ void vvSaveState::SaveOverlay(QTreeWidgetItem* item)
   m_XmlWriter->writeEndElement();
 }
 
-void vvSaveState::SaveVector(QTreeWidgetItem* item)
+void vvSaveState::SaveVector(const QTreeWidgetItem* item)
 {
   m_XmlWriter->writeStartElement("Vector");
   std::string filename = item->data(0, Qt::UserRole).toString().toStdString();
index 7a7cda97bd9ce3a18ec3b4356f6de99fc9da3647..9d236edff3a85820592588b5b7ab8bb3c911c205 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <string>
 #include <memory>
+#include "vvSlicerManager.h"
 
 class vvMainWindow;
 class QXmlStreamWriter;
@@ -22,10 +23,10 @@ protected:
   void SaveGlobals();
   void SaveGUI();
   void SaveTree();
-  void SaveImage(QTreeWidgetItem* item, int index);
-  void SaveFusion(QTreeWidgetItem* item);
-  void SaveOverlay(QTreeWidgetItem* item);
-  void SaveVector(QTreeWidgetItem* item);
+  void SaveImage(const QTreeWidgetItem* item, int index);
+  void SaveFusion(const QTreeWidgetItem* item, const vvSlicerManager* slicerManager);
+  void SaveOverlay(const QTreeWidgetItem* item);
+  void SaveVector(const QTreeWidgetItem* item);
 
   std::auto_ptr<QXmlStreamWriter> m_XmlWriter;
   std::auto_ptr<QFile> m_File;