X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvReadState.cxx;h=6a248b2b82b23d456146fb79687c8212ddf1902b;hb=1c6241402b25efea0052f0464be9a494e761b19e;hp=13bb083867ab6e6a008fecba941c92e154b6525b;hpb=f1cebc71809c5218578a58486f829980eeb29ab3;p=clitk.git diff --git a/vv/vvReadState.cxx b/vv/vvReadState.cxx index 13bb083..6a248b2 100644 --- a/vv/vvReadState.cxx +++ b/vv/vvReadState.cxx @@ -73,6 +73,7 @@ void vvReadState::ReadTree() { std::string value; + // read images while (!m_XmlReader->isEndElement() || value != "Images") { m_XmlReader->readNext(); value = m_XmlReader->qualifiedName().toString().toStdString(); @@ -81,6 +82,15 @@ void vvReadState::ReadTree() } } + // read links + while (!m_XmlReader->isEndElement() || value != "Links") { + m_XmlReader->readNext(); + value = m_XmlReader->qualifiedName().toString().toStdString(); + if (m_XmlReader->isStartElement()) { + if (value == "LinkedFrom") value = ReadLink(); + } + } + if (m_XmlReader->hasError()) std::cout << "Error " << m_XmlReader->error() << " XML " << std::endl; } @@ -158,8 +168,12 @@ std::string vvReadState::ReadFusion(int index) if (m_XmlReader->isStartElement()) { if (value == "FileName") { file = m_XmlReader->readElementText().toStdString(); - if (!m_XmlReader->hasError()) - m_Window->AddFusionImage(index, file.c_str()); + if (!m_XmlReader->hasError()) { + // TODO: manage sequence of images + std::vector vec; + vec.push_back(file.c_str()); + m_Window->AddFusionImage(index, vec, vvImageReader::IMAGE); + } } if (value == "FusionOpacity") { vali = m_XmlReader->readElementText().toInt(); @@ -262,6 +276,33 @@ std::string vvReadState::ReadVector(int index) //------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ +std::string vvReadState::ReadLink() +{ + std::string id_from, id_to, value; + + QXmlStreamAttributes attributes = m_XmlReader->attributes(); + if (!m_XmlReader->hasError()) { + id_from = attributes.value("Id").toString().toStdString(); + } + + while (!m_XmlReader->isEndElement() || value != "LinkedFrom") { + m_XmlReader->readNext(); + value = m_XmlReader->qualifiedName().toString().toStdString(); + if (m_XmlReader->isStartElement()) { + if (value == "LinkedTo") { + id_to = m_XmlReader->readElementText().toStdString(); + if (!m_XmlReader->hasError()) { + m_Window->AddLink(id_from.c_str(), id_to.c_str(), false); + } + } + } + } + + return value; +} +//------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvReadState::ReadGUI() {