diff --git a/isis/src/control/objs/BundleSettings/BundleSettings.cpp b/isis/src/control/objs/BundleSettings/BundleSettings.cpp index 2db12c1aa9..3da14cb7d1 100644 --- a/isis/src/control/objs/BundleSettings/BundleSettings.cpp +++ b/isis/src/control/objs/BundleSettings/BundleSettings.cpp @@ -41,6 +41,26 @@ namespace Isis { m_observationSolveSettings.append(defaultSolveSettings); } + /** + * Construct a BundleSettings object from member data read from an XML file. + * + * @code + * FileName xmlFile("bundleSettingsFileName.xml"); + * + * QString xmlPath = xmlFile.expanded(); + * QFile file(xmlPath); + * file.open(QFile::ReadOnly); + * QXmlStreamReader reader; + * BundleSettings settings(project, reader); + * @endcode + * + * @param xmlReader The Content handler to parse the BundleSettings XML + */ + BundleSettings::BundleSettings(QXmlStreamReader *xmlReader) { + init(); + readBundleSettings(xmlReader); + } + /** * @brief Set Default vales for a BundleSettings object. * Note we call the default constructor to initialize the TargetBody information diff --git a/isis/src/control/objs/BundleSettings/BundleSettings.h b/isis/src/control/objs/BundleSettings/BundleSettings.h index e35334fa64..04ff0faf8b 100644 --- a/isis/src/control/objs/BundleSettings/BundleSettings.h +++ b/isis/src/control/objs/BundleSettings/BundleSettings.h @@ -128,6 +128,7 @@ namespace Isis { //================ constructors, destructor, operators ================// //=====================================================================// BundleSettings(); + BundleSettings(QXmlStreamReader *xmlReader); BundleSettings(const BundleSettings &other); ~BundleSettings(); BundleSettings &operator=(const BundleSettings &other); diff --git a/isis/src/control/objs/BundleSolutionInfo/BundleSolutionInfo.cpp b/isis/src/control/objs/BundleSolutionInfo/BundleSolutionInfo.cpp index 23e14fa4a5..e69cae4e2f 100755 --- a/isis/src/control/objs/BundleSolutionInfo/BundleSolutionInfo.cpp +++ b/isis/src/control/objs/BundleSolutionInfo/BundleSolutionInfo.cpp @@ -128,31 +128,56 @@ namespace Isis { } void BundleSolutionInfo::readBundleSolutionInfo(QXmlStreamReader *xmlReader) { - m_xmlHandlerCharacters = ""; - - if (xmlReader->readNextStartElement()) { - - if (xmlReader->name() == "bundleSettings") { - // m_xmlHandlerBundleSolutionInfo->m_settings = - // BundleSettingsQsp(new BundleSettings(m_xmlHandlerProject, xmlReader)); + QString projectRoot; + if (m_xmlHandlerProject) { + projectRoot = m_xmlHandlerProject->projectRoot() + "/"; + } + Q_ASSERT(xmlReader->name() == "bundleSolutionInfo"); + while(xmlReader->readNextStartElement()) { + std::cout << xmlReader->name() << std::endl; + if (xmlReader->qualifiedName() == "generalAttributes") { + while (xmlReader->readNextStartElement()) { + if (xmlReader->qualifiedName() == "id") { + m_id = new QUuid(xmlReader->readElementText()); + } + else if (xmlReader->qualifiedName() == "name") { + m_name = xmlReader->readElementText(); + } + else if (xmlReader->qualifiedName() == "runTime") { + m_runTime = xmlReader->readElementText(); + } + else if (xmlReader->qualifiedName() == "inputFileName") { + m_inputControlNetFileName = new FileName(projectRoot + xmlReader->readElementText()); + } + else if (xmlReader->qualifiedName() == "bundleOutTXT") { + m_txtBundleOutputFilename = projectRoot + xmlReader->readElementText(); + } + else if (xmlReader->qualifiedName() == "imagesCSV") { + m_csvSavedImagesFilename = projectRoot + xmlReader->readElementText(); + } + else if (xmlReader->qualifiedName() == "pointsCSV") { + m_csvSavedPointsFilename = projectRoot + xmlReader->readElementText(); + } + else if (xmlReader->qualifiedName() == "residualsCSV") { + m_csvSavedResidualsFilename = projectRoot + xmlReader->readElementText(); + } + else { + xmlReader->skipCurrentElement(); + } + } + } + else if (xmlReader->name() == "bundleSettings") { + m_settings = NULL; + m_settings = BundleSettingsQsp(new BundleSettings(xmlReader)); } else if (xmlReader->name() == "bundleResults") { + m_statisticsResults = NULL; m_statisticsResults = new BundleResults(xmlReader); } - else if (xmlReader->name() == "imageList") { - // m_xmlHandlerBundleSolutionInfo->m_adjustedImages->append( - // new ImageList(m_xmlHandlerProject, xmlReader)); - } - else if (xmlReader->name() == "outputControl") { - // FileName outputControlPath = FileName(m_xmlHandlerProject->bundleSolutionInfoRoot() + "/" - // + m_xmlHandlerBundleSolutionInfo->runTime()); - - // m_xmlHandlerBundleSolutionInfo->m_outputControl = new Control(outputControlPath, xmlReader); - } else { - xmlReader->raiseError(QObject::tr("Incorrect file")); + xmlReader->skipCurrentElement(); } - } + } } /** diff --git a/isis/tests/BundleSolutionInfoTests.cpp b/isis/tests/BundleSolutionInfoTests.cpp index c21068e003..62f2437522 100644 --- a/isis/tests/BundleSolutionInfoTests.cpp +++ b/isis/tests/BundleSolutionInfoTests.cpp @@ -38,26 +38,22 @@ namespace Isis { class BundleSolutionInfoXmlHandlerTester : public BundleSolutionInfo { public: - BundleSolutionInfoXmlHandlerTester(FileName xmlFile) : BundleSolutionInfo() { - + BundleSolutionInfoXmlHandlerTester(QXmlStreamReader *reader, FileName xmlFile) : BundleSolutionInfo() { QString xmlPath(xmlFile.expanded()); QFile file(xmlPath); if (!file.open(QFile::ReadOnly) ) { throw IException(IException::Io, - QString("Unable to open xml file, [%1], with read access").arg(xmlPath), + QString("Unable to open xml file, [%1], with read access").arg(xmlFile.expanded()), _FILEINFO_); } - - QXmlStreamReader reader(&file); - - while (!reader.atEnd()) { - reader.readNext(); - } - if (reader.hasError()) { - throw IException(IException::Unknown, - QString("Failed to parse xml file, [%1]").arg(xmlPath), - _FILEINFO_); + if (reader->readNextStartElement()) { + if (reader->name() == "bundleSolutionInfo") { + readBundleSolutionInfo(reader); + } + else { + reader->raiseError(QObject::tr("Incorrect file")); + } } } @@ -98,7 +94,15 @@ TEST_F(ThreeImageNetwork, BundleSolutionInfoSerialization) { writer.writeEndDocument(); qXmlFile.close(); - BundleSolutionInfoXmlHandlerTester newSolution(saveFile); + QFile xml(saveFile); + if(!xml.open(QFile::ReadOnly | QFile::Text)){ + throw IException(IException::Unknown, + QString("Failed to parse xml file, [%1]").arg(xml.fileName()), + _FILEINFO_); + } + + QXmlStreamReader reader(&xml); + BundleSolutionInfoXmlHandlerTester newSolution(&reader, saveFile); EXPECT_EQ(solution.adjustedImages().size(), newSolution.adjustedImages().size()); EXPECT_EQ(solution.bundleResults().numberObservations(), newSolution.bundleResults().numberObservations());