From: Vivien Delmon Date: Tue, 27 Dec 2011 14:35:44 +0000 (+0100) Subject: Add Fusion properties to SaveState / ReadState X-Git-Tag: v1.3.0~127 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=13048c1469b7421804addb724efe87d7e1313a80;p=clitk.git Add Fusion properties to SaveState / ReadState - Add constness on QTreeWidgetItem. - Use vvSlicerManagers to Get/Set Fusion properties. --- diff --git a/vv/vvReadState.cxx b/vv/vvReadState.cxx index 83a7c5e..62d8b59 100644 --- a/vv/vvReadState.cxx +++ b/vv/vvReadState.cxx @@ -1,5 +1,6 @@ #include "vvReadState.h" #include "vvMainWindow.h" +#include "vvSlicerManager.h" #include @@ -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; } diff --git a/vv/vvSaveState.cxx b/vv/vvSaveState.cxx index e573bb9..e7b6193 100644 --- a/vv/vvSaveState.cxx +++ b/vv/vvSaveState.cxx @@ -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(); diff --git a/vv/vvSaveState.h b/vv/vvSaveState.h index 7a7cda9..9d236ed 100644 --- a/vv/vvSaveState.h +++ b/vv/vvSaveState.h @@ -3,6 +3,7 @@ #include #include +#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 m_XmlWriter; std::auto_ptr m_File;