From b723c3573a7b923bda4a8113159870b9fadabad2 Mon Sep 17 00:00:00 2001 From: Vivien Delmon Date: Tue, 27 Dec 2011 15:49:12 +0100 Subject: [PATCH] Add Overlay properties to SaveState / ReadState - Use vvSlicerManagers to Get/Set Overlay properties. --- vv/vvReadState.cxx | 24 ++++++++++++++++++++++++ vv/vvSaveState.cxx | 8 ++++++-- vv/vvSaveState.h | 2 +- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/vv/vvReadState.cxx b/vv/vvReadState.cxx index 62d8b59..dafcf3f 100644 --- a/vv/vvReadState.cxx +++ b/vv/vvReadState.cxx @@ -141,6 +141,9 @@ std::string vvReadState::ReadFusion(int index) std::string vvReadState::ReadOverlay(int index) { std::string file, value; + int vali; + double vald; + vvSlicerManager* slicerManager = m_Window->GetSlicerManagers()[index]; while (!m_XmlReader->isEndElement() || value != "Overlay") { m_XmlReader->readNext(); value = m_XmlReader->qualifiedName().toString().toStdString(); @@ -150,8 +153,29 @@ std::string vvReadState::ReadOverlay(int index) if (!m_XmlReader->hasError()) m_Window->AddOverlayImage(index, file.c_str()); } + if (value == "OverlayColorWindow") { + vald = m_XmlReader->readElementText().toDouble(); + if (!m_XmlReader->hasError()) + slicerManager->SetOverlayColorWindow(vald); + } + if (value == "OverlayColorLevel") { + vald = m_XmlReader->readElementText().toDouble(); + if (!m_XmlReader->hasError()) + slicerManager->SetOverlayColorLevel(vald); + } + if (value == "LinkOverlayWindowLevel") { + vali = m_XmlReader->readElementText().toInt(); + if (!m_XmlReader->hasError()) + slicerManager->SetLinkOverlayWindowLevel(vali); + } + if (value == "OverlayColor") { + vali = m_XmlReader->readElementText().toInt(); + if (!m_XmlReader->hasError()) + slicerManager->SetOverlayColor(vali); + } } } + m_Window->ImageInfoChanged(); return value; } diff --git a/vv/vvSaveState.cxx b/vv/vvSaveState.cxx index e7b6193..c1a7e49 100644 --- a/vv/vvSaveState.cxx +++ b/vv/vvSaveState.cxx @@ -80,7 +80,7 @@ void vvSaveState::SaveImage(const QTreeWidgetItem* item, int index) if (role == "fusion") SaveFusion(item_child, slicerManager); else if (role == "overlay") - SaveOverlay(item_child); + SaveOverlay(item_child, slicerManager); else if (role == "vector") SaveVector(item_child); } @@ -101,11 +101,15 @@ void vvSaveState::SaveFusion(const QTreeWidgetItem* item, const vvSlicerManager* m_XmlWriter->writeEndElement(); } -void vvSaveState::SaveOverlay(QTreeWidgetItem* item) +void vvSaveState::SaveOverlay(const QTreeWidgetItem* item, const vvSlicerManager* vvManager) { m_XmlWriter->writeStartElement("Overlay"); std::string filename = item->data(0, Qt::UserRole).toString().toStdString(); m_XmlWriter->writeTextElement("FileName", QDir::current().absoluteFilePath(filename.c_str())); + m_XmlWriter->writeTextElement("OverlayColorWindow", QString::number(vvManager->GetOverlayColorWindow())); + m_XmlWriter->writeTextElement("OverlayColorLevel", QString::number(vvManager->GetOverlayColorLevel())); + m_XmlWriter->writeTextElement("LinkOverlayWindowLevel", QString::number(vvManager->GetLinkOverlayWindowLevel())); + m_XmlWriter->writeTextElement("OverlayColor", QString::number(vvManager->GetOverlayColor())); m_XmlWriter->writeEndElement(); } diff --git a/vv/vvSaveState.h b/vv/vvSaveState.h index 9d236ed..2991580 100644 --- a/vv/vvSaveState.h +++ b/vv/vvSaveState.h @@ -25,7 +25,7 @@ protected: void SaveTree(); void SaveImage(const QTreeWidgetItem* item, int index); void SaveFusion(const QTreeWidgetItem* item, const vvSlicerManager* slicerManager); - void SaveOverlay(const QTreeWidgetItem* item); + void SaveOverlay(const QTreeWidgetItem* item, const vvSlicerManager* slicerManager); void SaveVector(const QTreeWidgetItem* item); std::auto_ptr m_XmlWriter; -- 2.47.1