From 921642d767beba2442dacc8fdb40dc36396e1b7d Mon Sep 17 00:00:00 2001 From: Romulo Pinho Date: Wed, 17 Oct 2012 12:41:40 +0200 Subject: [PATCH] window/level in read/save state --- vv/vvReadState.cxx | 18 +++++++++++++++++- vv/vvSaveState.cxx | 16 +++++++++++----- vv/vvSlicerManager.cxx | 4 ++-- vv/vvSlicerManager.h | 6 +++--- 4 files changed, 33 insertions(+), 11 deletions(-) diff --git a/vv/vvReadState.cxx b/vv/vvReadState.cxx index 6d61ca5..13bb083 100644 --- a/vv/vvReadState.cxx +++ b/vv/vvReadState.cxx @@ -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); diff --git a/vv/vvSaveState.cxx b/vv/vvSaveState.cxx index 71e22ef..d4a76bd 100644 --- a/vv/vvSaveState.cxx +++ b/vv/vvSaveState.cxx @@ -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++) { diff --git a/vv/vvSlicerManager.cxx b/vv/vvSlicerManager.cxx index 9ff163e..9331bf1 100644 --- a/vv/vvSlicerManager.cxx +++ b/vv/vvSlicerManager.cxx @@ -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(); diff --git a/vv/vvSlicerManager.h b/vv/vvSlicerManager.h index 6cc9333..1824524 100644 --- a/vv/vvSlicerManager.h +++ b/vv/vvSlicerManager.h @@ -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() { -- 2.47.1