diff --git a/isis/src/base/apps/mosrange/mosrange.cpp b/isis/src/base/apps/mosrange/mosrange.cpp index df876e85b1..221ea38987 100644 --- a/isis/src/base/apps/mosrange/mosrange.cpp +++ b/isis/src/base/apps/mosrange/mosrange.cpp @@ -11,6 +11,7 @@ find files of those names at the top level of this repository. **/ #include #include +#include #include "Camera.h" #include "Cube.h" diff --git a/isis/src/base/objs/StatCumProbDistDynCalc/StatCumProbDistDynCalc.cpp b/isis/src/base/objs/StatCumProbDistDynCalc/StatCumProbDistDynCalc.cpp index 1bf722a823..ba7ed6e55f 100644 --- a/isis/src/base/objs/StatCumProbDistDynCalc/StatCumProbDistDynCalc.cpp +++ b/isis/src/base/objs/StatCumProbDistDynCalc/StatCumProbDistDynCalc.cpp @@ -12,6 +12,7 @@ find files of those names at the top level of this repository. **/ #include #include #include +#include #include #include @@ -20,7 +21,6 @@ find files of those names at the top level of this repository. **/ #include "IException.h" #include "IString.h" #include "Project.h" -#include "XmlStackedHandlerReader.h" #include "Pvl.h" #include @@ -41,14 +41,75 @@ namespace Isis { } -// TODO: should project be const ??? - StatCumProbDistDynCalc::StatCumProbDistDynCalc(Project *project, - XmlStackedHandlerReader *xmlReader, - QObject *parent) { // TODO: does xml stuff need project??? + StatCumProbDistDynCalc::StatCumProbDistDynCalc(QXmlStreamReader *xmlReader, QObject *parent) { initialize(); - xmlReader->pushContentHandler(new XmlHandler(this, project)); // TODO: does xml stuff need project??? + readStatistics(xmlReader); } + void StatCumProbDistDynCalc::readStatistics(QXmlStreamReader *xmlReader) { + Q_ASSERT(xmlReader->name() == "statCumProbDistDynCalc"); + while (xmlReader->readNextStartElement()) { + if (xmlReader->qualifiedName() == "numberCells") { + try { + m_numberCells = toDouble(xmlReader->readElementText()); + } + catch (IException &e) { + m_numberCells = 0.0; + } + } + else if (xmlReader->qualifiedName() == "numberQuantiles") { + try { + m_numberQuantiles = toDouble(xmlReader->readElementText()); + } + catch (IException &e) { + m_numberQuantiles = 0.0; + } + } + else if (xmlReader->qualifiedName() == "numberObservations") { + try { + m_numberObservations = toDouble(xmlReader->readElementText()); + } + catch (IException &e) { + m_numberObservations = 0.0; + } + } + else if (xmlReader->qualifiedName() == "distributionData") { + m_quantiles.clear(); + m_observationValues.clear(); + m_idealNumObsBelowQuantile.clear(); + m_numObsBelowQuantile.clear(); + for (unsigned int i = 0; i < m_numberQuantiles; i++) { + while (xmlReader->readNextStartElement()) { + if (xmlReader->qualifiedName() == "quantileInfo") { + QStringRef quantile = xmlReader->attributes().value("quantile"); + if (!quantile.isEmpty()) { + m_quantiles.append(quantile.toDouble()); + } + QStringRef dataValue = xmlReader->attributes().value("dataValue"); + if (!dataValue.isEmpty()) { + m_observationValues.append(dataValue.toDouble()); + } + QStringRef idealNumObsBelowQuantile = xmlReader->attributes().value("idealNumObsBelowQuantile"); + if (!idealNumObsBelowQuantile.isEmpty()) { + m_idealNumObsBelowQuantile.append(idealNumObsBelowQuantile.toDouble()); + } + QStringRef actualNumObsBelowQuantile = xmlReader->attributes().value("actualNumObsBelowQuantile"); + + if (!actualNumObsBelowQuantile.isEmpty()) { + m_numObsBelowQuantile.append(actualNumObsBelowQuantile.toInt()); + } + } + else { + xmlReader->skipCurrentElement(); + } + } + } + } + else { + xmlReader->skipCurrentElement(); + } + } + } StatCumProbDistDynCalc::StatCumProbDistDynCalc(const StatCumProbDistDynCalc &other) @@ -512,83 +573,6 @@ namespace Isis { } - - -// TODO: should project be const ??? - StatCumProbDistDynCalc::XmlHandler::XmlHandler(StatCumProbDistDynCalc *probabilityCalc, - Project *project) { // TODO: does xml stuff need project??? - m_xmlHandlerCumProbCalc = probabilityCalc; - m_xmlHandlerProject = project; // TODO: does xml stuff need project??? - m_xmlHandlerCharacters = ""; - } - - - - StatCumProbDistDynCalc::XmlHandler::~XmlHandler() { - // do not delete this pointer... we don't own it, do we??? passed into StatCumProbDistDynCalc constructor as pointer -// delete m_xmlHandlerProject; // TODO: does xml stuff need project??? - m_xmlHandlerProject = NULL; - } - - - - bool StatCumProbDistDynCalc::XmlHandler::startElement(const QString &namespaceURI, - const QString &localName, - const QString &qName, - const QXmlAttributes &atts) { - - m_xmlHandlerCharacters = ""; - if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) { - if (qName == "quantileInfo") { - - QString quantile = atts.value("quantile"); - QString obsValue = atts.value("dataValue"); - QString idealObs = atts.value("idealNumObsBelowQuantile"); - QString actualObs = atts.value("actualNumObsBelowQuantile"); - - if (!quantile.isEmpty() && !obsValue.isEmpty() - && !idealObs.isEmpty() && !actualObs.isEmpty()) { - m_xmlHandlerCumProbCalc->m_quantiles.append(toDouble(quantile)); - m_xmlHandlerCumProbCalc->m_observationValues.append(toDouble(obsValue)); - m_xmlHandlerCumProbCalc->m_idealNumObsBelowQuantile.append(toDouble(idealObs)); - m_xmlHandlerCumProbCalc->m_numObsBelowQuantile.append(toDouble(actualObs)); - } - } - - } - return true; - } - - - - bool StatCumProbDistDynCalc::XmlHandler::characters(const QString &ch) { - m_xmlHandlerCharacters += ch; - return XmlStackedHandler::characters(ch); - } - - - - bool StatCumProbDistDynCalc::XmlHandler::endElement(const QString &namespaceURI, - const QString &localName, - const QString &qName) { - if (!m_xmlHandlerCharacters.isEmpty()) { - if (qName == "numberCells") { - m_xmlHandlerCumProbCalc->m_numberCells = toInt(m_xmlHandlerCharacters); - } - else if (qName == "numberQuantiles") { - m_xmlHandlerCumProbCalc->m_numberQuantiles = toInt(m_xmlHandlerCharacters); - } - else if (qName == "numberObservations") { - m_xmlHandlerCumProbCalc->m_numberObservations = toInt(m_xmlHandlerCharacters); - } - - m_xmlHandlerCharacters = ""; - } - return XmlStackedHandler::endElement(namespaceURI, localName, qName); - } - - - QDataStream &StatCumProbDistDynCalc::write(QDataStream &stream) const { stream << (qint32)m_numberCells << (qint32)m_numberQuantiles @@ -600,8 +584,6 @@ namespace Isis { return stream; } - - QDataStream &StatCumProbDistDynCalc::read(QDataStream &stream) { QString id; qint32 numCells, numQuantiles, numObservations; diff --git a/isis/src/base/objs/StatCumProbDistDynCalc/StatCumProbDistDynCalc.h b/isis/src/base/objs/StatCumProbDistDynCalc/StatCumProbDistDynCalc.h index d91448ff73..fb3480d220 100644 --- a/isis/src/base/objs/StatCumProbDistDynCalc/StatCumProbDistDynCalc.h +++ b/isis/src/base/objs/StatCumProbDistDynCalc/StatCumProbDistDynCalc.h @@ -11,15 +11,13 @@ find files of those names at the top level of this repository. **/ #include #include -#include "XmlStackedHandler.h" - class QDataStream; class QUuid; class QXmlStreamWriter; +class QXmlStreamReader; namespace Isis { class Project;// ??? does xml stuff need project??? - class XmlStackedHandlerReader; /** * @brief This class is used to approximate cumulative probibility distributions of a stream of @@ -70,8 +68,8 @@ namespace Isis { // Observations" public: StatCumProbDistDynCalc(unsigned int nodes=20, QObject *parent = 0); //individual qunatile value to be calculated - StatCumProbDistDynCalc(Project *project, XmlStackedHandlerReader *xmlReader, - QObject *parent = 0); // TODO: does xml stuff need project??? + StatCumProbDistDynCalc(QXmlStreamReader *xmlReader, QObject *parent = 0); + void readStatistics(QXmlStreamReader *xmlReader); StatCumProbDistDynCalc(const StatCumProbDistDynCalc &other); ~StatCumProbDistDynCalc(); StatCumProbDistDynCalc &operator=(const StatCumProbDistDynCalc &other); @@ -92,32 +90,6 @@ namespace Isis { QDataStream &write(QDataStream &stream) const; QDataStream &read(QDataStream &stream); - private: - /** - * - * @author 2014-07-28 Jeannie Backer - * - * @internal - */ - class XmlHandler : public XmlStackedHandler { - public: - XmlHandler(StatCumProbDistDynCalc *probabilityCalc, Project *project); // TODO: does xml stuff need project??? - ~XmlHandler(); - - virtual bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts); - virtual bool characters(const QString &ch); - virtual bool endElement(const QString &namespaceURI, const QString &localName, - const QString &qName); - - private: - Q_DISABLE_COPY(XmlHandler); - - StatCumProbDistDynCalc *m_xmlHandlerCumProbCalc; - Project *m_xmlHandlerProject; // TODO: does xml stuff need project??? - QString m_xmlHandlerCharacters; - }; - unsigned int m_numberCells; /**< The number of cells or histogram bins that are being used to model the probility density function.*/ diff --git a/isis/src/base/objs/StatCumProbDistDynCalc/unitTest.cpp b/isis/src/base/objs/StatCumProbDistDynCalc/unitTest.cpp index 9b2cf5b1c3..efd1a82700 100644 --- a/isis/src/base/objs/StatCumProbDistDynCalc/unitTest.cpp +++ b/isis/src/base/objs/StatCumProbDistDynCalc/unitTest.cpp @@ -7,7 +7,8 @@ find files of those names at the top level of this repository. **/ #include #include #include -#include +#include +#include #include @@ -15,7 +16,7 @@ find files of those names at the top level of this repository. **/ #include "IException.h" #include "Preference.h" #include "StatCumProbDistDynCalc.h" -#include "XmlStackedHandlerReader.h" +#include "Statistics.h" using namespace std; using namespace Isis; @@ -38,8 +39,7 @@ using namespace Isis; namespace Isis { class StatisticsXmlHandlerTester : public StatCumProbDistDynCalc { public: - StatisticsXmlHandlerTester(Project *project, XmlStackedHandlerReader *reader, - FileName xmlFile) : StatCumProbDistDynCalc(project, reader) { + StatisticsXmlHandlerTester(QXmlStreamReader *reader, FileName xmlFile) : StatCumProbDistDynCalc() { QString xmlPath(xmlFile.expanded()); QFile file(xmlPath); @@ -50,16 +50,16 @@ namespace Isis { _FILEINFO_); } - QXmlInputSource xmlInputSource(&file); - bool success = reader->parse(xmlInputSource); - if (!success) { - throw IException(IException::Unknown, - QString("Failed to parse xml file, [%1]").arg(xmlPath), - _FILEINFO_); + if (reader->readNextStartElement()) { + if (reader->name() == "statCumProbDistDynCalc") { + readStatistics(reader); + } + else { + reader->raiseError(QObject::tr("Incorrect file")); + } + } } - } - ~StatisticsXmlHandlerTester() { } @@ -174,8 +174,15 @@ int main(int argc, char *argv[]) { // read xml with no attributes or values FileName emptyXmlFile("./unitTest_NoElementValues.xml"); Project *project = NULL; - XmlStackedHandlerReader reader; - StatisticsXmlHandlerTester statsFromEmptyXml(project, &reader, emptyXmlFile); + QFile xml(emptyXmlFile.expanded()); + 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); + StatisticsXmlHandlerTester statsFromEmptyXml(&reader, emptyXmlFile); qDebug() << "Testing XML: read XML with no attributes or values " "to StatCumProbDistDynCalc object... Then try to get " "min from object with no observations."; @@ -470,7 +477,7 @@ int main(int argc, char *argv[]) { qDebug() << "percent error: " << (temp-1.0)/100 << "%"; qDebug() << ""; qDebug() << ""; - StatCumProbDistDynCalc assignedStats(0); + StatCumProbDistDynCalc assignedStats; assignedStats = copyStats; qDebug() << "Min = " << assignedStats.min(); qDebug() << "Max = " << assignedStats.max(); @@ -633,7 +640,15 @@ int main(int argc, char *argv[]) { qXmlFile.close(); // read xml qDebug() << "Testing XML: read XML to StatCumProbDistDynCalc object..."; - StatisticsXmlHandlerTester statsFromXml(project, &reader, xmlFile); + QFile xml2(xmlFile.expanded()); + if(!xml2.open(QFile::ReadOnly | QFile::Text)){ + throw IException(IException::Unknown, + QString("Failed to parse xml file, [%1]").arg(xml2.fileName()), + _FILEINFO_); + } + + QXmlStreamReader reader2(&xml2); + StatisticsXmlHandlerTester statsFromXml(&reader2, xmlFile); qDebug() << "Min = " << statsFromXml.min(); qDebug() << "Max = " << statsFromXml.max(); qDebug() << ""; diff --git a/isis/src/base/objs/Statistics/Statistics.cpp b/isis/src/base/objs/Statistics/Statistics.cpp index d6e7be9fcd..d3afb9c444 100644 --- a/isis/src/base/objs/Statistics/Statistics.cpp +++ b/isis/src/base/objs/Statistics/Statistics.cpp @@ -11,6 +11,7 @@ find files of those names at the top level of this repository. **/ #include #include #include +#include #include @@ -19,7 +20,6 @@ find files of those names at the top level of this repository. **/ #include "Project.h" #include "PvlGroup.h" #include "PvlKeyword.h" -#include "XmlStackedHandlerReader.h" using namespace std; @@ -32,12 +32,163 @@ namespace Isis { Reset(); // initialize } - - Statistics::Statistics(Project *project, XmlStackedHandlerReader *xmlReader, QObject *parent) { // TODO: does xml stuff need project??? + Statistics::Statistics(QXmlStreamReader *xmlReader, QObject *parent) { // TODO: does xml stuff need project??? // m_id = NULL; SetValidRange(); Reset(); // initialize - xmlReader->pushContentHandler(new XmlHandler(this, project)); // TODO: does xml stuff need project??? + readStatistics(xmlReader); + } + + void Statistics::readStatistics(QXmlStreamReader *xmlReader) { + Q_ASSERT(xmlReader->name() == "statistics"); + while (xmlReader->readNextStartElement()) { + if (xmlReader->qualifiedName() == "sum") { + try { + m_sum = toDouble(xmlReader->readElementText()); + } + catch (IException &e) { + m_sum = 0.0; + } + } + else if (xmlReader->qualifiedName() == "sumSquares") { + try { + m_sumsum = toDouble(xmlReader->readElementText()); + } + catch (IException &e) { + m_sumsum = 0.0; + } + } + else if (xmlReader->qualifiedName() == "range") { + while (xmlReader->readNextStartElement()) { + if (xmlReader->qualifiedName() == "minimum") { + try { + m_minimum = toDouble(xmlReader->readElementText()); + } + catch (IException &e) { + m_minimum = DBL_MAX; + } + } + else if (xmlReader->qualifiedName() == "maximum") { + try { + m_maximum = toDouble(xmlReader->readElementText()); + } + catch (IException &e) { + m_maximum = -DBL_MAX; + } + } + else if (xmlReader->qualifiedName() == "validMinimum") { + try { + m_validMinimum = toDouble(xmlReader->readElementText()); + } + catch (IException &e) { + m_validMinimum = Isis::ValidMinimum; + } + } + else if (xmlReader->qualifiedName() == "validMaximum") { + try { + m_validMaximum = toDouble(xmlReader->readElementText()); + } + catch (IException &e) { + m_validMaximum = Isis::ValidMaximum; + } + } + else { + xmlReader->skipCurrentElement(); + } + } + } + else if (xmlReader->qualifiedName() == "pixelCounts") { + while (xmlReader->readNextStartElement()) { + if (xmlReader->qualifiedName() == "totalPixels") { + try { + m_totalPixels = toBigInt(xmlReader->readElementText()); + } + catch (IException &e) { + m_totalPixels = 0.0; + } + } + else if (xmlReader->qualifiedName() == "validPixels") { + try { + m_validPixels = toBigInt(xmlReader->readElementText()); + } + catch (IException &e) { + m_validPixels = 0.0; + } + } + else if (xmlReader->qualifiedName() == "nullPixels") { + try { + m_nullPixels = toBigInt(xmlReader->readElementText()); + } + catch (IException &e) { + m_nullPixels = 0.0; + } + + } + else if (xmlReader->qualifiedName() == "lisPixels") { + try { + m_lisPixels = toBigInt(xmlReader->readElementText()); + } + catch (IException &e) { + m_lisPixels = 0.0; + } + } + else if (xmlReader->qualifiedName() == "lrsPixels") { + try { + m_lrsPixels = toBigInt(xmlReader->readElementText()); + } + catch (IException &e) { + m_lrsPixels = 0.0; + } + } + else if (xmlReader->qualifiedName() == "hisPixels") { + try { + m_hisPixels = toBigInt(xmlReader->readElementText()); + } + catch (IException &e) { + m_hisPixels = 0.0; + } + } + else if (xmlReader->qualifiedName() == "hrsPixels") { + try { + m_hrsPixels = toBigInt(xmlReader->readElementText()); + } + catch (IException &e) { + m_hrsPixels = 0.0; + } + } + else if (xmlReader->qualifiedName() == "underRangePixels") { + try { + m_underRangePixels = toBigInt(xmlReader->readElementText()); + } + catch (IException &e) { + m_underRangePixels = 0.0; + } + } + else if (xmlReader->qualifiedName() == "overRangePixels") { + try { + m_overRangePixels = toBigInt(xmlReader->readElementText()); + } + catch (IException &e) { + m_overRangePixels = 0.0; + } + } + else { + xmlReader->skipCurrentElement(); + } + } + } + else if (xmlReader->qualifiedName() == "removedData") { + try { + m_removedData = toBool(xmlReader->readElementText()); + } + catch (IException &e) { + m_removedData = false; + } + } + else { + xmlReader->skipCurrentElement(); + } + } } /** @@ -756,99 +907,6 @@ namespace Isis { } - Statistics::XmlHandler::XmlHandler(Statistics *statistics, Project *project) { // TODO: does xml stuff need project??? - m_xmlHandlerStatistics = statistics; - m_xmlHandlerProject = project; // TODO: does xml stuff need project??? - m_xmlHandlerCharacters = ""; - } - - - Statistics::XmlHandler::~XmlHandler() { - // do not delete this pointer... we don't own it, do we??? passed into StatCumProbDistDynCalc constructor as pointer - // delete m_xmlHandlerProject; // TODO: does xml stuff need project??? - m_xmlHandlerProject = NULL; - } - - - bool Statistics::XmlHandler::startElement(const QString &namespaceURI, - const QString &localName, - const QString &qName, - const QXmlAttributes &atts) { - m_xmlHandlerCharacters = ""; - if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) { - // no element attibutes to evaluate - } - return true; - } - - - bool Statistics::XmlHandler::characters(const QString &ch) { - m_xmlHandlerCharacters += ch; - return XmlStackedHandler::characters(ch); - } - - - bool Statistics::XmlHandler::endElement(const QString &namespaceURI, const QString &localName, - const QString &qName) { - if (!m_xmlHandlerCharacters.isEmpty()) { - if (localName == "id") { -// m_xmlHandlerStatistics->m_id = NULL; -// m_xmlHandlerStatistics->m_id = new QUuid(m_xmlHandlerCharacters); - } - if (localName == "sum") { - m_xmlHandlerStatistics->m_sum = toDouble(m_xmlHandlerCharacters); - } - if (localName == "sumSquares") { - m_xmlHandlerStatistics->m_sumsum = toDouble(m_xmlHandlerCharacters); - } - if (localName == "minimum") { - m_xmlHandlerStatistics->m_minimum = toDouble(m_xmlHandlerCharacters); - } - if (localName == "maximum") { - m_xmlHandlerStatistics->m_maximum = toDouble(m_xmlHandlerCharacters); - } - if (localName == "validMinimum") { - m_xmlHandlerStatistics->m_validMinimum = toDouble(m_xmlHandlerCharacters); - } - if (localName == "validMaximum") { - m_xmlHandlerStatistics->m_validMaximum = toDouble(m_xmlHandlerCharacters); - } - if (localName == "totalPixels") { - m_xmlHandlerStatistics->m_totalPixels = toBigInt(m_xmlHandlerCharacters); - } - if (localName == "validPixels") { - m_xmlHandlerStatistics->m_validPixels = toBigInt(m_xmlHandlerCharacters); - } - if (localName == "nullPixels") { - m_xmlHandlerStatistics->m_nullPixels = toBigInt(m_xmlHandlerCharacters); - } - if (localName == "lisPixels") { - m_xmlHandlerStatistics->m_lisPixels = toBigInt(m_xmlHandlerCharacters); - } - if (localName == "lrsPixels") { - m_xmlHandlerStatistics->m_lrsPixels = toBigInt(m_xmlHandlerCharacters); - } - if (localName == "hisPixels") { - m_xmlHandlerStatistics->m_hisPixels = toBigInt(m_xmlHandlerCharacters); - } - if (localName == "hrsPixels") { - m_xmlHandlerStatistics->m_hrsPixels = toBigInt(m_xmlHandlerCharacters); - } - if (localName == "underRangePixels") { - m_xmlHandlerStatistics->m_underRangePixels = toBigInt(m_xmlHandlerCharacters); - } - if (localName == "overRangePixels") { - m_xmlHandlerStatistics->m_overRangePixels = toBigInt(m_xmlHandlerCharacters); - } - if (localName == "removedData") { - m_xmlHandlerStatistics->m_removedData = toBool(m_xmlHandlerCharacters); - } - m_xmlHandlerCharacters = ""; - } - return XmlStackedHandler::endElement(namespaceURI, localName, qName); - } - - /** * Order saved must match the offsets in the static compoundH5DataType() * method. @@ -930,4 +988,4 @@ namespace Isis { return statistics.read(stream); } -} // end namespace isis +} // end namespace isis \ No newline at end of file diff --git a/isis/src/base/objs/Statistics/Statistics.h b/isis/src/base/objs/Statistics/Statistics.h index 08d5b8aaca..de4be2a196 100644 --- a/isis/src/base/objs/Statistics/Statistics.h +++ b/isis/src/base/objs/Statistics/Statistics.h @@ -13,15 +13,14 @@ find files of those names at the top level of this repository. **/ #include "Constants.h" #include "PvlGroup.h" #include "SpecialPixel.h" -#include "XmlStackedHandler.h" class QDataStream; class QUuid; class QXmlStreamWriter; +class QXmlStreamReader; namespace Isis { class Project;// ??? does xml stuff need project??? - class XmlStackedHandlerReader; /** * @brief This class is used to accumulate statistics on double arrays. * @@ -95,7 +94,8 @@ namespace Isis { Q_OBJECT public: Statistics(QObject *parent = 0); - Statistics(Project *project, XmlStackedHandlerReader *xmlReader, QObject *parent = 0); + Statistics(QXmlStreamReader *xmlReader, QObject *parent = 0); + void readStatistics(QXmlStreamReader *xmlReader); Statistics(const PvlGroup &inStats, QObject *parent = 0); // TODO: does xml read/write stuff need Project input??? Statistics(const Statistics &other); @@ -157,34 +157,7 @@ namespace Isis { private: void fromPvl(const PvlGroup &inStats); - - /** - * - * @author 2014-07-28 Jeannie Backer - * - * @internal - */ - class XmlHandler : public XmlStackedHandler { - public: - XmlHandler(Statistics *statistics, Project *project); - // TODO: does xml stuff need project??? - ~XmlHandler(); - - virtual bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts); - virtual bool characters(const QString &ch); - virtual bool endElement(const QString &namespaceURI, const QString &localName, - const QString &qName); - - private: - Q_DISABLE_COPY(XmlHandler); - - Statistics *m_xmlHandlerStatistics; - Project *m_xmlHandlerProject; - // TODO: does xml stuff need project??? - QString m_xmlHandlerCharacters; - }; - + // QUuid *m_id; /**< A unique ID for this object (useful for others to reference // this object when saving to disk).*/ double m_sum; //!< The sum accumulator, i.e. the sum of added data values. @@ -214,4 +187,3 @@ namespace Isis { } // end namespace isis #endif - diff --git a/isis/src/base/objs/Statistics/unitTest.cpp b/isis/src/base/objs/Statistics/unitTest.cpp index ca993cbf88..7783652406 100644 --- a/isis/src/base/objs/Statistics/unitTest.cpp +++ b/isis/src/base/objs/Statistics/unitTest.cpp @@ -7,7 +7,8 @@ find files of those names at the top level of this repository. **/ #include #include #include -#include +#include +#include #include @@ -15,7 +16,6 @@ find files of those names at the top level of this repository. **/ #include "IException.h" #include "Preference.h" #include "Statistics.h" -#include "XmlStackedHandlerReader.h" using namespace std; using namespace Isis; @@ -33,8 +33,7 @@ using namespace Isis; namespace Isis { class StatisticsXmlHandlerTester : public Statistics { public: - StatisticsXmlHandlerTester(Project *project, XmlStackedHandlerReader *reader, - FileName xmlFile) : Statistics(project, reader) { + StatisticsXmlHandlerTester(QXmlStreamReader *reader, FileName xmlFile) : Statistics() { QString xmlPath(xmlFile.expanded()); QFile file(xmlPath); @@ -45,16 +44,16 @@ namespace Isis { _FILEINFO_); } - QXmlInputSource xmlInputSource(&file); - bool success = reader->parse(xmlInputSource); - if (!success) { - throw IException(IException::Unknown, - QString("Failed to parse xml file, [%1]").arg(xmlPath), - _FILEINFO_); + if (reader->readNextStartElement()) { + if (reader->name() == "statistics") { + readStatistics(reader); + } + else { + reader->raiseError(QObject::tr("Incorrect file")); + } + } } - } - ~StatisticsXmlHandlerTester() { } @@ -388,8 +387,15 @@ int main(int argc, char *argv[]) { qXmlFile.close(); // read xml qDebug() << "Testing XML: read XML to Statistics object..."; - XmlStackedHandlerReader reader; - StatisticsXmlHandlerTester statsFromXml(project, &reader, xmlFile); + + if(!qXmlFile.open(QFile::ReadOnly | QFile::Text)){ + throw IException(IException::Unknown, + QString("Failed to parse xml file, [%1]").arg(qXmlFile.fileName()), + _FILEINFO_); + } + + QXmlStreamReader reader(&qXmlFile); + StatisticsXmlHandlerTester statsFromXml(&reader, xmlFile); qDebug() << "Average: " << statsFromXml.Average(); qDebug() << "Variance: " << statsFromXml.Variance(); qDebug() << "Rms: " << statsFromXml.Rms(); @@ -421,7 +427,15 @@ int main(int argc, char *argv[]) { // read xml with no attributes or values qDebug() << "Testing XML: read XML with no attributes or values to Statistics object..."; FileName emptyXmlFile("./unitTest_NoElementValues.xml"); - StatisticsXmlHandlerTester statsFromEmptyXml(project, &reader, emptyXmlFile); + + QFile xml(emptyXmlFile.expanded()); + if(!xml.open(QFile::ReadOnly | QFile::Text)){ + throw IException(IException::Unknown, + QString("Failed to parse xml file, [%1]").arg(xml.fileName()), + _FILEINFO_); + } + QXmlStreamReader reader2(&xml); + StatisticsXmlHandlerTester statsFromEmptyXml(&reader2, emptyXmlFile); qDebug() << "Average: " << statsFromEmptyXml.Average(); qDebug() << "Variance: " << statsFromEmptyXml.Variance(); qDebug() << "Rms: " << statsFromEmptyXml.Rms(); @@ -539,4 +553,4 @@ int main(int argc, char *argv[]) { #if 0 need test coverage for BelowRange(value) -#endif +#endif \ No newline at end of file diff --git a/isis/src/base/objs/XmlStackedHandler/Makefile b/isis/src/base/objs/XmlStackedHandler/Makefile deleted file mode 100644 index f122bc8822..0000000000 --- a/isis/src/base/objs/XmlStackedHandler/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -ifeq ($(ISISROOT), $(BLANK)) -.SILENT: -error: - echo "Please set ISISROOT"; -else - include $(ISISROOT)/make/isismake.objs -endif \ No newline at end of file diff --git a/isis/src/base/objs/XmlStackedHandler/XmlStackedHandler.cpp b/isis/src/base/objs/XmlStackedHandler/XmlStackedHandler.cpp deleted file mode 100644 index b5c3e20e61..0000000000 --- a/isis/src/base/objs/XmlStackedHandler/XmlStackedHandler.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/** This is free and unencumbered software released into the public domain. -The authors of ISIS do not claim copyright on the contents of this file. -For more details about the LICENSE terms and the AUTHORS, you will -find files of those names at the top level of this repository. **/ - -/* SPDX-License-Identifier: CC0-1.0 */ -#include "XmlStackedHandler.h" - -#include -#include -#include - -#include "XmlStackedHandlerReader.h" - -namespace Isis { - XmlStackedHandler::XmlStackedHandler() { - m_reader = NULL; - m_depth = 0; - } - - - XmlStackedHandler::~XmlStackedHandler() { - m_reader = NULL; - m_depth = 0; - } - - - void XmlStackedHandler::setReader(XmlStackedHandlerReader *reader) { - m_reader = reader; - } - - - /** - * @brief Switch to a new content handler and continue processing using the new handler. - * - */ - void XmlStackedHandler::switchToNewHandler(XmlStackedHandler *nextHandler) { - nextHandler->startElement(m_lastStartNamespaceURI, m_lastStartLocalName, - m_lastStartQName, m_lastStartAtts); - } - - - bool XmlStackedHandler::startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts) { - m_lastStartNamespaceURI = namespaceURI; - m_lastStartLocalName = localName; - m_lastStartQName = qName; - m_lastStartAtts = atts; - m_depth++; - - return true; - } - - bool XmlStackedHandler::endElement(const QString &namespaceURI, const QString &localName, - const QString &qName) { - m_depth--; - - if (m_depth == 0 && reader()) { - reader()->popContentHandler(); - - if (reader()->topContentHandler()) - reader()->topContentHandler()->endElement(namespaceURI, localName, qName); - } - - return true; - } - - XmlStackedHandlerReader *XmlStackedHandler::reader() { - return m_reader; - } - - - const XmlStackedHandlerReader *XmlStackedHandler::reader() const { - return m_reader; - } - - - bool XmlStackedHandler::fatalError(const QXmlParseException &exception) { - qDebug() << "Parse error at line " << exception.lineNumber() - << ", " << "column " << exception.columnNumber() << ": " - << qPrintable(exception.message()); - return false; - } - -} diff --git a/isis/src/base/objs/XmlStackedHandler/XmlStackedHandler.h b/isis/src/base/objs/XmlStackedHandler/XmlStackedHandler.h deleted file mode 100644 index ab5e69ff37..0000000000 --- a/isis/src/base/objs/XmlStackedHandler/XmlStackedHandler.h +++ /dev/null @@ -1,150 +0,0 @@ -#ifndef XmlStackedHandler_H -#define XmlStackedHandler_H -/** This is free and unencumbered software released into the public domain. -The authors of ISIS do not claim copyright on the contents of this file. -For more details about the LICENSE terms and the AUTHORS, you will -find files of those names at the top level of this repository. **/ - -/* SPDX-License-Identifier: CC0-1.0 */ - -#include - -template class QStack; - -class QXmlParseException; -namespace Isis { - class XmlStackedHandlerReader; - - /** - * @brief XML Handler that parses XMLs in a stack-oriented way - * - * IPCE does not have a single XML file for the whole project - * but breaks the project into multiple XML files with the Project.xml file - * being the top level. @see Project - * - * **Serialization Basics** - * - * IPCE mostly follows the standard convention of each object being responsible for - * serializing itself. Each Object to be serialized must have a "save" method to - * write the object out as XML. The first thing the save method does is write an XML element - * indicating what type of object is being serialized. This allows the deserialization to know - * how to parse the data (in our case what type of XmlHandler to push). If the object being - * serialized contains another object the save method of the contained object is called. This - * results in a XML file hierarchy as shown below. - * - * For deserialization each serialized object implements an XmlHandler class. The - * XmlHandler::startElement method handles reading of the XML file and initializing the - * member variables for the object. The class must also define a constructor that takes a - * XmlStackedHandlerReader as a parameter (Note the IPCE signatures vary on this method). - * The constructor pushes it's own content handler (the XmlHandler class) on the reader - * to allow parsing to continue with this object. Note the push of the content handler - * does not return until the XML is parsed, specifically the push of the content handler - * calls XmlHandler::startElement() for the handler just pushed. (Actually the behavior - * of XmlStackedHandlerReader::pushContentHandler() varies - if there are no contentHandlers - * on the content handler stack when it is called it returns immediately and parse() - * must be called to start parsing. If there is a content handler already on the stack - * the push results in a call to startElement() and it does not return until the - * corresponding end element.) - * - * If a contained object - * is found while parsing the XML, the constructor for the contained object that takes a - * XmlStackedHandlerReader as a parameter is called. This will result in the contained - * object pushing it's content handler and parsing the relevant XML. When the constructor - * returns, XML parsing can continue for this object. - * - * *Potential issue* - * There appears to be no support for cycles or joins in the object graph when serializing - * or deserializing. This means that if multiple pointers point to the same object ensure - * the object is only serialized once and that all pointers are properly restored on - * deserialization. Currently many of the ISIS objects have unique IDs and IPCE encapsulates - * the underlying ISIS object. One option would be to use the ISIS ids to uniquely identify - * the objects during serialization. - * - * *Versioning* - * To ensure backwards compatibility versioning is done per object. This keeps version - * information for a class within a single source file with no need to know Project file - * structure and where Project level file information is saved. The version number - * for a class should be incremented by 1 each time the XML for that object changes. - * When reading old version XML, files the class should choose a sensible default for the - * missing XML elements and write out the XML in the newest format. - * - * This XML handler is designed to work with the XmlStackedHandlerReader. This XML handler class - * handles passing off parsing to another handler. For example, if your XML is: - * - *
-   *     
-   *        
-   *        
-   *             
-   *             
-   *                
-   *             
-   *             
-   *        
-   *        
-   *     
-   *   
- * - * To start the processing of the XML, an initial XML content handler is pushed onto the - * stack of content handlers. In the example above this initial content handler only - * processes elements associated with xmlTag1. In IPCE the xmlTag1 elements will be the - * member variables associated with a class. The xmlTag2 contains XML for an object - * contained within the first class. When the xmlTag2 element is encountered the - * XML content handler (the xmlTag2::XmlHandler class) will be pushed and take over - * parsing. - * - * If this handler is pushed onto the reader (which is the parser stack) when the startElement - * of xmlTag2 is seen, then this XML handler will see all of the xml data up to and including - * the xmlTag2 close tag. This handler would never see xmlTag1. Here is an example of how - * this works: - * - *
-   *   --> Push initial XML content handler for xmlTag1 (Handler1)
-   *    -- Handler1::startElement
-   *      -- Handler1::startElement: calls reader()->pushContentHandler(HandlerForXmlTag2)
-   *               -- HandlerForXmlTag2::startElement
-   *        -- HandlerForXmlTag3::startElement
-   *                   -- HandlerForXmlTag3::endElement
-   *      -- HandlerForXmlTag2::endElement
-   *    -- Handler1::endElement
-   * 
- * - * - * - * @author 2012-??-?? Steven Lambright - * - * @internal - */ - class XmlStackedHandler : public QXmlDefaultHandler { - public: - XmlStackedHandler(); - ~XmlStackedHandler(); - - virtual void setReader(XmlStackedHandlerReader *); - void switchToNewHandler(XmlStackedHandler *nextHandler); - - virtual bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts); - - virtual bool endElement(const QString &namespaceURI, const QString &localName, - const QString &qName); - - protected: - XmlStackedHandlerReader *reader(); - const XmlStackedHandlerReader *reader() const; - bool fatalError(const QXmlParseException &exception); - - private: - Q_DISABLE_COPY(XmlStackedHandler); - - XmlStackedHandlerReader *m_reader; - int m_depth; - - QString m_lastStartNamespaceURI; - QString m_lastStartLocalName; - QString m_lastStartQName; - QXmlAttributes m_lastStartAtts; - }; -} - -#endif diff --git a/isis/src/base/objs/XmlStackedHandler/XmlStackedHandler.truth b/isis/src/base/objs/XmlStackedHandler/XmlStackedHandler.truth deleted file mode 100644 index 264584b648..0000000000 --- a/isis/src/base/objs/XmlStackedHandler/XmlStackedHandler.truth +++ /dev/null @@ -1,32 +0,0 @@ -project: Start Element [project] -project: Start Element [controlNets] -controlNets: Start Element [controlNets] -controlNets: Start Element [controlNet] - path = /some/path/to/a/network/FileName.net -controlNet: Start Element [controlNet] - path = /some/path/to/a/network/FileName.net -controlNet: End Element [controlNet] -controlNets: End Element [controlNet] -controlNets: Start Element [controlNet] - path = /some/path/to/a/network/FileName2.net -controlNet: Start Element [controlNet] - path = /some/path/to/a/network/FileName2.net -controlNet: End Element [controlNet] -controlNets: End Element [controlNet] -controlNets: Start Element [controlNet] - path = /some/path/to/a/network/FileName3.net -controlNet: Start Element [controlNet] - path = /some/path/to/a/network/FileName3.net -controlNet: End Element [controlNet] -controlNets: End Element [controlNet] -controlNets: End Element [controlNets] -project: End Element [controlNets] -project: Start Element [anotherTag] - name = a - path = b -anotherTag: Start Element [anotherTag] - name = a - path = b -anotherTag: End Element [anotherTag] -project: End Element [anotherTag] -project: End Element [project] diff --git a/isis/src/base/objs/XmlStackedHandler/testFile.xml b/isis/src/base/objs/XmlStackedHandler/testFile.xml deleted file mode 100644 index e3c3178a3c..0000000000 --- a/isis/src/base/objs/XmlStackedHandler/testFile.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/isis/src/base/objs/XmlStackedHandler/unitTest.cpp b/isis/src/base/objs/XmlStackedHandler/unitTest.cpp deleted file mode 100644 index 3cfdf3f8de..0000000000 --- a/isis/src/base/objs/XmlStackedHandler/unitTest.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/** This is free and unencumbered software released into the public domain. -The authors of ISIS do not claim copyright on the contents of this file. -For more details about the LICENSE terms and the AUTHORS, you will -find files of those names at the top level of this repository. **/ - -/* SPDX-License-Identifier: CC0-1.0 */ -#include - -#include - -#include "IException.h" -#include "IString.h" -#include "XmlStackedHandler.h" -#include "XmlStackedHandlerReader.h" - -using namespace Isis; -using namespace std; - -namespace Isis { - class XmlHandlerTester : public XmlStackedHandler { - public: - XmlHandlerTester(QString name) { - m_name = name; - } - - ~XmlHandlerTester() { - } - - - bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts) { - cerr << m_name.toStdString() << ": Start Element [" - << localName.toStdString() << "]" << endl; - - if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) { - - for (int attIndex = 0; attIndex < atts.count(); attIndex++) { - cerr << "\t" << atts.localName(attIndex).toStdString() - << " = " << atts.value(attIndex).toStdString() << endl; - } - - if (localName != m_name) { - reader()->pushContentHandler(new XmlHandlerTester(localName)); - } - } - - return true; - } - - bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName) { - cerr << m_name.toStdString() << ": End Element [" - << localName.toStdString() << "]" << endl; - - return XmlStackedHandler::endElement(namespaceURI, localName, qName); - } - - private: - QString m_name; - }; -} - -// XmlStackedHandlerReader's unit test is relying on this test to adequetly test its functionality. -int main(int argc, char **argv) { - XmlHandlerTester handler("project"); - - XmlStackedHandlerReader reader; - reader.pushContentHandler(&handler); - reader.setErrorHandler(&handler); - - QString xmlPath("./testFile.xml"); - QFile file(xmlPath); - - if (!file.open(QFile::ReadOnly)) { - throw IException(IException::Unknown, - QString("Unable to open [%1] with read access") - .arg(xmlPath), - _FILEINFO_); - } - - QXmlInputSource xmlInputSource(&file); - if (!reader.parse(xmlInputSource)) - cerr << QString("Failed to read [%1]").arg(xmlPath).toStdString(); - - return 0; -} diff --git a/isis/src/base/objs/XmlStackedHandlerReader/Makefile b/isis/src/base/objs/XmlStackedHandlerReader/Makefile deleted file mode 100644 index f122bc8822..0000000000 --- a/isis/src/base/objs/XmlStackedHandlerReader/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -ifeq ($(ISISROOT), $(BLANK)) -.SILENT: -error: - echo "Please set ISISROOT"; -else - include $(ISISROOT)/make/isismake.objs -endif \ No newline at end of file diff --git a/isis/src/base/objs/XmlStackedHandlerReader/XmlStackedHandlerReader.cpp b/isis/src/base/objs/XmlStackedHandlerReader/XmlStackedHandlerReader.cpp deleted file mode 100644 index 2d50250314..0000000000 --- a/isis/src/base/objs/XmlStackedHandlerReader/XmlStackedHandlerReader.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/** This is free and unencumbered software released into the public domain. -The authors of ISIS do not claim copyright on the contents of this file. -For more details about the LICENSE terms and the AUTHORS, you will -find files of those names at the top level of this repository. **/ - -/* SPDX-License-Identifier: CC0-1.0 */ -#include "XmlStackedHandlerReader.h" - -#include -#include - -#include "XmlStackedHandler.h" - -namespace Isis { - XmlStackedHandlerReader::XmlStackedHandlerReader() { - m_contentHandlers = NULL; - m_contentHandlers = new QStack; - } - - - XmlStackedHandlerReader::~XmlStackedHandlerReader() { - delete m_contentHandlers; - m_contentHandlers = NULL; - } - - - void XmlStackedHandlerReader::popContentHandler() { - m_contentHandlers->pop(); - - if (m_contentHandlers->size()) { - m_contentHandlers->top()->setReader(this); - setContentHandler(m_contentHandlers->top()); - } - else { - setContentHandler(NULL); - } - } - - - /** - * @brief Push a contentHandler and maybe continue parsing... - * - * Push a contentHadler on the content handler stack. If there are currently - * no other handlers on the stack that is all that happens. - * - * If there are other content handlers on the stack it is assumed that - * a XML file is being processed and processing continues by calling - * startElement() of the newly pushed handler. In this case - * pushContentHandler() will not return until the element has been - * fully processed. - * - * @see XmlStackedHandler - * - */ - void XmlStackedHandlerReader::pushContentHandler(XmlStackedHandler *newHandler) { - XmlStackedHandler *old = topContentHandler(); - - newHandler->setReader(this); - m_contentHandlers->push(newHandler); - - setContentHandler(m_contentHandlers->top()); - - if (old) { - // Switch to newHandler and continue parsing - // This will call newHandler->startElement(...) - old->switchToNewHandler(topContentHandler()); - } - } - - - XmlStackedHandler *XmlStackedHandlerReader::topContentHandler() { - XmlStackedHandler *result = NULL; - - if (m_contentHandlers->size()) - result = m_contentHandlers->top(); - - return result; - } -} - diff --git a/isis/src/base/objs/XmlStackedHandlerReader/XmlStackedHandlerReader.h b/isis/src/base/objs/XmlStackedHandlerReader/XmlStackedHandlerReader.h deleted file mode 100644 index f26cfdcdc2..0000000000 --- a/isis/src/base/objs/XmlStackedHandlerReader/XmlStackedHandlerReader.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef XmlStackedHandlerReader_H -#define XmlStackedHandlerReader_H -/** This is free and unencumbered software released into the public domain. -The authors of ISIS do not claim copyright on the contents of this file. -For more details about the LICENSE terms and the AUTHORS, you will -find files of those names at the top level of this repository. **/ - -/* SPDX-License-Identifier: CC0-1.0 */ -#include - -template class QStack; - -namespace Isis { - class XmlStackedHandler; - - /** - * - * @brief Manage a stack of content handlers for reading XML files. - * - * This class is designed to work with the XmlStackedHandler class. Use this - * in-place of a QXmlSimpleReader if you want to use stack-based Xml parsing. The - * XmlStackedHandler class has an explanation as to how this is designed to work. - * - * @see XmlStackedHandler - * - * @author 2012-??-?? Steven Lambright - * - * @internal - */ - class XmlStackedHandlerReader : public QXmlSimpleReader { - public: - XmlStackedHandlerReader(); - ~XmlStackedHandlerReader(); - - virtual void popContentHandler(); - virtual void pushContentHandler(XmlStackedHandler *newHandler); - XmlStackedHandler *topContentHandler(); - - private: - Q_DISABLE_COPY(XmlStackedHandlerReader); - - QStack *m_contentHandlers; - }; -} - -#endif diff --git a/isis/src/base/objs/XmlStackedHandlerReader/XmlStackedHandlerReader.truth b/isis/src/base/objs/XmlStackedHandlerReader/XmlStackedHandlerReader.truth deleted file mode 100644 index 5614d66e7e..0000000000 --- a/isis/src/base/objs/XmlStackedHandlerReader/XmlStackedHandlerReader.truth +++ /dev/null @@ -1 +0,0 @@ -This is tested by XmlStackedHandler's unit test diff --git a/isis/src/base/objs/XmlStackedHandlerReader/unitTest.cpp b/isis/src/base/objs/XmlStackedHandlerReader/unitTest.cpp deleted file mode 100644 index e63979b566..0000000000 --- a/isis/src/base/objs/XmlStackedHandlerReader/unitTest.cpp +++ /dev/null @@ -1,13 +0,0 @@ -/** This is free and unencumbered software released into the public domain. -The authors of ISIS do not claim copyright on the contents of this file. -For more details about the LICENSE terms and the AUTHORS, you will -find files of those names at the top level of this repository. **/ - -/* SPDX-License-Identifier: CC0-1.0 */ -#include - -using namespace std; - -int main(int argc, char **argv) { - cerr << "This is tested by XmlStackedHandler's unit test" << endl; -} \ No newline at end of file diff --git a/isis/src/control/objs/BundleResults/BundleResults.cpp b/isis/src/control/objs/BundleResults/BundleResults.cpp index eb06fb23cf..5e377e6b79 100644 --- a/isis/src/control/objs/BundleResults/BundleResults.cpp +++ b/isis/src/control/objs/BundleResults/BundleResults.cpp @@ -11,9 +11,11 @@ find files of those names at the top level of this repository. **/ #include #include #include +#include #include // qMax() #include #include +#include #include #include @@ -34,7 +36,8 @@ find files of those names at the top level of this repository. **/ #include "SerialNumberList.h" #include "StatCumProbDistDynCalc.h" #include "Statistics.h" -#include "XmlStackedHandlerReader.h" + +#include using namespace boost::numeric::ublas; @@ -59,7 +62,6 @@ namespace Isis { } - /** * Construct this BundleResults object from XML. * @@ -68,17 +70,401 @@ namespace Isis { * @param xmlReader An XML reader that's up to a tag. * @param parent The Qt-relationship parent. */ - BundleResults::BundleResults(Project *project, XmlStackedHandlerReader *xmlReader, - QObject *parent) : QObject(parent) { - // TODO: does xml stuff need project??? + BundleResults::BundleResults(QXmlStreamReader *xmlReader, + QObject *parent) : QObject(parent) + { + // TODO: does xml stuff need project??? initialize(); - xmlReader->pushContentHandler(new XmlHandler(this, project)); - xmlReader->setErrorHandler(new XmlHandler(this, project)); + readBundleResults(xmlReader); + } + + void BundleResults::readBundleResults(QXmlStreamReader *xmlReader) { + Q_ASSERT(xmlReader->name() == "bundleResults"); + while(xmlReader->readNextStartElement()) { + if (xmlReader->qualifiedName() == "correlationMatrix") { + readCorrelationMatrix(xmlReader); + } + else if (xmlReader->qualifiedName() == "generalStatisticsValues") { + readGenStatsValues(xmlReader); + } + else if (xmlReader->qualifiedName() == "rms") { + readRms(xmlReader); + } + else if (xmlReader->qualifiedName() == "elapsedTime") { + + QStringRef time = xmlReader->attributes().value("time"); + if (!time.isEmpty()) { + m_elapsedTime = time.toDouble(); + } + + QStringRef errorProp = xmlReader->attributes().value("errorProp"); + if (!errorProp.isEmpty()) { + m_elapsedTimeErrorProp = errorProp.toDouble(); + } + xmlReader->skipCurrentElement(); + } + else if (xmlReader->qualifiedName() == "minMaxSigmas") { + readMinMaxSigmas(xmlReader); + } + else if (xmlReader->qualifiedName() == "maximumLikelihoodEstimation") { + readMaxLikelihoodEstimation(xmlReader); + } + + // ??? else if (xmlReader->qualifiedName() == "minMaxSigmaDistances") { + // ??? QStringRef units = xmlReader->attributes().value("units"); + // ??? if (!QStringRef::compare(units, "meters", Qt::CaseInsensitive)) { + // ??? QStringRef msg = "Unable to read BundleResults xml. Sigma distances must be " + // ??? "provided in meters."; + // ??? throw IException(IException::Io, msg, _FILEINFO_); + // ??? } + // ??? } + else { + xmlReader->skipCurrentElement(); + } + } + } + + void BundleResults::readCorrelationMatrix(QXmlStreamReader *xmlReader) { + Q_ASSERT(xmlReader->name() == "correlationMatrix"); + m_correlationMatrix = NULL; + m_correlationMatrix = new CorrelationMatrix(); + + QString correlationFileName = *(xmlReader->attributes().value("correlationFileName").string()); + if (!correlationFileName.isEmpty()) { + FileName correlationFile(correlationFileName); + m_correlationMatrix->setCorrelationFileName(correlationFile); + } + + QString covarianceFileName = *(xmlReader->attributes().value("covarianceFileName").string()); + if (!covarianceFileName.isEmpty()) { + FileName covarianceFile(covarianceFileName); + m_correlationMatrix->setCovarianceFileName(covarianceFile); + } + while (xmlReader->readNextStartElement()) { + if (xmlReader->qualifiedName() == "image") { + QString correlationMatrixImageId = *(xmlReader->attributes().value("id").string()); + if (!correlationMatrixImageId.isEmpty()) { + m_xmlHandlerCorrelationImageId = correlationMatrixImageId; + } + } + else { + xmlReader->skipCurrentElement(); + } + } + } + + void BundleResults::readGenStatsValues(QXmlStreamReader *xmlReader) { + Q_ASSERT(xmlReader->name() == "generalStatisticsValues"); + while (xmlReader->readNextStartElement()) { + if (xmlReader->qualifiedName() == "numberFixedPoints") { + m_numberFixedPoints = toInt(xmlReader->readElementText()); + } + else if (xmlReader->qualifiedName() == "numberIgnoredPoints") { + m_numberIgnoredPoints = xmlReader->readElementText().toInt(); + } + else if (xmlReader->qualifiedName() == "numberHeldImages") { + m_numberHeldImages = xmlReader->readElementText().toInt(); + } + else if (xmlReader->qualifiedName() == "rejectionLimit") { + m_rejectionLimit = xmlReader->readElementText().toDouble(); + } + else if (xmlReader->qualifiedName() == "numberRejectedObservations") { + m_numberRejectedObservations = xmlReader->readElementText().toInt(); + } + else if (xmlReader->qualifiedName() == "numberLidarRangeConstraintEquations") { + m_numberLidarRangeConstraintEquations = xmlReader->readElementText().toInt(); + } + else if (xmlReader->qualifiedName() == "numberObservations") { + m_numberObservations = xmlReader->readElementText().toInt(); + } + else if (xmlReader->qualifiedName() == "numberImageObservations") { + m_numberImageObservations = xmlReader->readElementText().toInt(); + } + else if (xmlReader->qualifiedName() == "numberLidarImageObservations") { + m_numberLidarImageObservations = xmlReader->readElementText().toInt(); + } + else if (xmlReader->qualifiedName() == "numberImageParameters") { + m_numberImageParameters = xmlReader->readElementText().toInt(); + } + else if (xmlReader->qualifiedName() == "numberConstrainedPointParameters") { + m_numberConstrainedPointParameters = + xmlReader->readElementText().toInt(); + } + else if (xmlReader->qualifiedName() == "numberConstrainedImageParameters") { + m_numberConstrainedImageParameters = + xmlReader->readElementText().toInt(); + } + else if (xmlReader->qualifiedName() == "numberConstrainedTargetParameters") { + m_numberConstrainedTargetParameters = + xmlReader->readElementText().toInt(); + } + else if (xmlReader->qualifiedName() == "numberUnknownParameters") { + m_numberUnknownParameters = xmlReader->readElementText().toInt(); + } + else if (xmlReader->qualifiedName() == "degreesOfFreedom") { + m_degreesOfFreedom = xmlReader->readElementText().toInt(); + } + else if (xmlReader->qualifiedName() == "sigma0") { + m_sigma0 = xmlReader->readElementText().toDouble(); + } + else if (xmlReader->qualifiedName() == "converged") { + m_converged = toBool(xmlReader->readElementText()); + } + else if (xmlReader->qualifiedName() == "iterations") { + m_iterations = xmlReader->readElementText().toInt(); + } + else { + xmlReader->skipCurrentElement(); + } + } + } + + void BundleResults::readRms(QXmlStreamReader *xmlReader) { + Q_ASSERT(xmlReader->name() == "rms"); + while (xmlReader->readNextStartElement()) { + if (xmlReader->qualifiedName() == "residuals") { + QStringRef rx = xmlReader->attributes().value("x"); + if (!rx.isEmpty()) { + m_rmsXResiduals = rx.toDouble(); + } + + QStringRef ry = xmlReader->attributes().value("y"); + if (!ry.isEmpty()) { + m_rmsYResiduals = ry.toDouble(); + } + + QStringRef rxy = xmlReader->attributes().value("xy"); + if (!rxy.isEmpty()) { + m_rmsXYResiduals = rxy.toDouble(); + } + xmlReader->skipCurrentElement(); + } + else if (xmlReader->qualifiedName() == "sigmas") + { + QStringRef lat = xmlReader->attributes().value("lat"); + if (!lat.isEmpty()){ + m_rmsSigmaCoord1Stats = lat.toDouble(); + } + + QStringRef lon = xmlReader->attributes().value("lon"); + if (!lon.isEmpty()){ + m_rmsSigmaCoord2Stats = lon.toDouble(); + } + + QStringRef rad = xmlReader->attributes().value("rad"); + if (!rad.isEmpty()){ + m_rmsSigmaCoord3Stats = rad.toDouble(); + } + + QStringRef x = xmlReader->attributes().value("x"); + if (!x.isEmpty()){ + m_rmsSigmaCoord1Stats = x.toDouble(); + } + + QStringRef y = xmlReader->attributes().value("y"); + if (!y.isEmpty()){ + m_rmsSigmaCoord2Stats = y.toDouble(); + } + + QStringRef z = xmlReader->attributes().value("z"); + if (!z.isEmpty()){ + m_rmsSigmaCoord3Stats = z.toDouble(); + } + xmlReader->skipCurrentElement(); + } + else if (xmlReader->qualifiedName() == "imageResidualsLists") { + readImageResidualsLists(xmlReader); + } + else if (xmlReader->qualifiedName() == "imageSigmasLists") { + readSigmasLists(xmlReader); + } + else { + xmlReader->skipCurrentElement(); + } + } + } + + void BundleResults::readImageResidualsLists(QXmlStreamReader *xmlReader) { + Q_ASSERT(xmlReader->name() == "imageResidualsLists"); + while (xmlReader->readNextStartElement()) { + if (xmlReader->qualifiedName() == "residualsList") { + readStatsToList(m_rmsImageResiduals, xmlReader); + } + else if (xmlReader->qualifiedName() == "sampleList") { + readStatsToList(m_rmsImageSampleResiduals, xmlReader); + } + else if (xmlReader->qualifiedName() == "lineList") { + readStatsToList(m_rmsImageLineResiduals, xmlReader); + } + else if (xmlReader->qualifiedName() == "lidarResidualsList") { + readStatsToList(m_rmsLidarImageResiduals, xmlReader); + } + else if (xmlReader->qualifiedName() == "lidarSampleList") { + readStatsToList(m_rmsLidarImageSampleResiduals, xmlReader); + } + else if (xmlReader->qualifiedName() == "lidarLineList") { + readStatsToList(m_rmsLidarImageLineResiduals, xmlReader); + } + else { + xmlReader->skipCurrentElement(); + } + } + } + + void BundleResults::readSigmasLists(QXmlStreamReader *xmlReader) { + Q_ASSERT(xmlReader->name() == "imageSigmasLists"); + while (xmlReader->readNextStartElement()) { + if (xmlReader->qualifiedName() == "xSigmas") { + readStatsToVector(m_rmsImageXSigmas, xmlReader); + } + else if (xmlReader->qualifiedName() == "ySigmas") { + readStatsToVector(m_rmsImageYSigmas, xmlReader); + } + else if (xmlReader->qualifiedName() == "zSigmas") { + readStatsToVector(m_rmsImageZSigmas, xmlReader); + } + else if (xmlReader->qualifiedName() == "raSigmas") { + readStatsToVector(m_rmsImageRASigmas, xmlReader); + } + else if (xmlReader->qualifiedName() == "decSigmas") { + readStatsToVector(m_rmsImageDECSigmas, xmlReader); + } + else if (xmlReader->qualifiedName() == "twistSigmas") { + readStatsToVector(m_rmsImageTWISTSigmas, xmlReader); + } + else { + xmlReader->skipCurrentElement(); + } + } + } + + void BundleResults::readStatsToList(QList &list, QXmlStreamReader *xmlReader) { + Q_ASSERT(xmlReader->attributes().hasAttribute("listSize")); + int listSize = xmlReader->attributes().value("listSize").toInt(); + for (int i = 0; i < listSize; i++) { + xmlReader->readNextStartElement(); + Q_ASSERT(xmlReader->name() == "statisticsItem"); + xmlReader->readNextStartElement(); + Q_ASSERT(xmlReader->name() == "statistics"); + list.append(new Statistics(xmlReader)); + xmlReader->readNextStartElement(); + } + xmlReader->readNextStartElement(); + } + + void BundleResults::readStatsToVector(QVector &vec, QXmlStreamReader *xmlReader) { + Q_ASSERT(xmlReader->attributes().hasAttribute("listSize")); + int listSize = xmlReader->attributes().value("listSize").toInt(); + for (int i = 0; i < listSize; i++) { + xmlReader->readNextStartElement(); + Q_ASSERT(xmlReader->name() == "statisticsItem"); + xmlReader->readNextStartElement(); + Q_ASSERT(xmlReader->name() == "statistics"); + vec.append(new Statistics(xmlReader)); + xmlReader->readNextStartElement(); + } + xmlReader->readNextStartElement(); + } + + void BundleResults::readMinMaxSigmas(QXmlStreamReader *xmlReader) { + Q_ASSERT(xmlReader->name() == "minMaxSigmas"); + while (xmlReader->readNextStartElement()) { + if (xmlReader->qualifiedName() == "minLat" || + xmlReader->qualifiedName() == "minX") { + readSigma(m_minSigmaCoord1Distance, m_minSigmaCoord1PointId, xmlReader); + } + else if (xmlReader->qualifiedName() == "maxLat" || + xmlReader->qualifiedName() == "maxX") { + readSigma(m_maxSigmaCoord1Distance, m_maxSigmaCoord1PointId, xmlReader); + } + else if (xmlReader->qualifiedName() == "minLon" || + xmlReader->qualifiedName() == "minY") { + readSigma(m_minSigmaCoord2Distance, m_minSigmaCoord2PointId, xmlReader); + } + else if (xmlReader->qualifiedName() == "maxLon" || + xmlReader->qualifiedName() == "maxY") { + readSigma(m_maxSigmaCoord2Distance, m_maxSigmaCoord2PointId, xmlReader); + } + else if (xmlReader->qualifiedName() == "minRad" || + xmlReader->qualifiedName() == "minZ") { + readSigma(m_minSigmaCoord3Distance, m_minSigmaCoord3PointId, xmlReader); + } + else if (xmlReader->qualifiedName() == "maxRad" || + xmlReader->qualifiedName() == "maxZ") { + readSigma(m_maxSigmaCoord3Distance, m_maxSigmaCoord3PointId, xmlReader); + } + else { + xmlReader->skipCurrentElement(); + } + } + } + + void BundleResults::readSigma(Distance &dist, QString &pointId, QXmlStreamReader *xmlReader) { + Q_ASSERT(xmlReader->attributes().hasAttribute("value")); + Q_ASSERT(xmlReader->attributes().hasAttribute("pointId")); + QStringRef sigmaValue = xmlReader->attributes().value("value"); + if (!sigmaValue.isEmpty()) { + dist.setMeters(sigmaValue.toDouble()); + } + QString sigmaPointId = xmlReader->attributes().value("pointId").toString(); + if (!sigmaPointId.isEmpty()) { + pointId = sigmaPointId; + } + xmlReader->skipCurrentElement(); } + void BundleResults::readMaxLikelihoodEstimation(QXmlStreamReader *xmlReader) { + Q_ASSERT(xmlReader->name() == "maximumLikelihoodEstimation"); + QStringRef maximumLikelihoodIndex = xmlReader->attributes().value("maximumLikelihoodIndex"); + if (!maximumLikelihoodIndex.isEmpty()) { + m_maximumLikelihoodIndex = maximumLikelihoodIndex.toInt(); + } + + QStringRef maximumLikelihoodMedianR2Residuals = + xmlReader->attributes().value("maximumLikelihoodMedianR2Residuals"); + if (!maximumLikelihoodMedianR2Residuals.isEmpty()) { + m_maximumLikelihoodMedianR2Residuals = + maximumLikelihoodMedianR2Residuals.toDouble(); + } + while (xmlReader->readNextStartElement()) { + if (xmlReader->qualifiedName() == "cumulativeProbabilityCalculator") { + m_cumPro = NULL; + m_cumPro = new StatCumProbDistDynCalc(xmlReader); + } + else if (xmlReader->qualifiedName() == "residualsCumulativeProbabilityCalculator") { + m_cumProRes = NULL; + m_cumProRes = new StatCumProbDistDynCalc(); + m_cumProRes->readStatistics(xmlReader); + } + else if (xmlReader->qualifiedName() == "model") { + QString model = xmlReader->attributes().value("modelSelection").toString(); + QStringRef tweakingConstant = xmlReader->attributes().value("tweakingConstant"); + QStringRef quantile = xmlReader->attributes().value("quantile"); + bool validModel = true; + if (model.isEmpty()) + validModel = false; + if (tweakingConstant.isEmpty()) + validModel = false; + if (quantile.isEmpty()) + validModel = false; + if (validModel) + { + m_maximumLikelihoodFunctions.append( + qMakePair(MaximumLikelihoodWFunctions( + MaximumLikelihoodWFunctions::stringToModel(model), + tweakingConstant.toDouble()), + quantile.toDouble())); + } + xmlReader->skipCurrentElement(); + } + else { + xmlReader->skipCurrentElement(); + } + } + } /** * Copy constructor for BundleResults. Creates this BundleResults object as a copy @@ -148,10 +534,10 @@ namespace Isis { m_maximumLikelihoodIndex(src.m_maximumLikelihoodIndex), m_cumPro(new StatCumProbDistDynCalc(*src.m_cumPro)), m_cumProRes(new StatCumProbDistDynCalc(*src.m_cumProRes)), - m_maximumLikelihoodMedianR2Residuals(src.m_maximumLikelihoodMedianR2Residuals) { + m_maximumLikelihoodMedianR2Residuals(src.m_maximumLikelihoodMedianR2Residuals) + { } - /** * Destroys this BundleResults object. */ @@ -1947,639 +2333,4 @@ namespace Isis { stream.writeEndElement(); // end maximumLikelihoodEstimation stream.writeEndElement(); // end bundleResults } - - - /** - * Constructs an XmlHandler used to save a BundleResults object. - * - * @param statistics The BundleResults that the XmlHandler will save. - * @param project The project that the BundleResults object belongs to. - */ - BundleResults::XmlHandler::XmlHandler(BundleResults *statistics, Project *project) { - // TODO: does xml stuff need project??? - m_xmlHandlerCumProCalc = NULL; - m_xmlHandlerBundleResults = NULL; - m_xmlHandlerProject = NULL; - - m_xmlHandlerBundleResults = statistics; - m_xmlHandlerProject = project; // TODO: does xml stuff need project??? - m_xmlHandlerCharacters = ""; - - m_xmlHandlerResidualsListSize = 0; - m_xmlHandlerSampleResidualsListSize = 0; - m_xmlHandlerLineResidualsListSize = 0; - m_xmlHandlerXSigmasListSize = 0; - m_xmlHandlerYSigmasListSize = 0; - m_xmlHandlerZSigmasListSize = 0; - m_xmlHandlerRASigmasListSize = 0; - m_xmlHandlerDECSigmasListSize = 0; - m_xmlHandlerTWISTSigmasListSize = 0; - m_xmlHandlerStatisticsList.clear(); - - } - - - /** - * Destroys an XmlHandler. - */ - BundleResults::XmlHandler::~XmlHandler() { - // do not delete this pointer... we don't own it, do we??? - // passed into StatCumProbDistDynCalc constructor as pointer - // delete m_xmlHandlerProject; // TODO: does xml stuff need project??? - m_xmlHandlerProject = NULL; - - // delete m_xmlHandlerBundleResults; - // m_xmlHandlerBundleResults = NULL; - - } - - - /** - * Handle an XML start element. This method is called when the reader finds an open tag. - * handle the read when the startElement with the name localName has been found. - * - * @param qName SAX namespace for this tag - * @param localName SAX local name - * @param qName SAX qualified name of the tag. - * @param attributes The list of attributes for the tag. - * - * @return @b bool Indicates whether to continue reading the XML (usually true). - */ - bool BundleResults::XmlHandler::startElement(const QString &namespaceURI, - const QString &localName, - const QString &qName, - const QXmlAttributes &atts) { - m_xmlHandlerCharacters = ""; - - if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) { - - if (qName == "correlationMatrix") { - m_xmlHandlerBundleResults->m_correlationMatrix = NULL; - m_xmlHandlerBundleResults->m_correlationMatrix = new CorrelationMatrix(); - - QString correlationFileName = atts.value("correlationFileName"); - if (!correlationFileName.isEmpty()) { - FileName correlationFile(correlationFileName); - m_xmlHandlerBundleResults->m_correlationMatrix->setCorrelationFileName(correlationFile); - } - - QString covarianceFileName = atts.value("covarianceFileName"); - if (!covarianceFileName.isEmpty()) { - FileName covarianceFile(covarianceFileName); - m_xmlHandlerBundleResults->m_correlationMatrix->setCovarianceFileName(covarianceFile); - } - } - else if (qName == "image") { - QString correlationMatrixImageId = atts.value("id"); - if (!correlationMatrixImageId.isEmpty()) { - m_xmlHandlerCorrelationImageId = correlationMatrixImageId; - } - } - else if (qName == "residuals") { - QString rx = atts.value("x"); - if (!rx.isEmpty()) { - m_xmlHandlerBundleResults->m_rmsXResiduals = toDouble(rx); - } - - QString ry = atts.value("y"); - if (!ry.isEmpty()) { - m_xmlHandlerBundleResults->m_rmsYResiduals = toDouble(ry); - } - - QString rxy = atts.value("xy"); - if (!rxy.isEmpty()) { - m_xmlHandlerBundleResults->m_rmsXYResiduals = toDouble(rxy); - } - } - else if (qName == "sigmas") { - QString lat = atts.value("lat"); - if (!lat.isEmpty()) { - m_xmlHandlerBundleResults->m_rmsSigmaCoord1Stats = toDouble(lat); - } - QString lon = atts.value("lon"); - if (!lon.isEmpty()) { - m_xmlHandlerBundleResults->m_rmsSigmaCoord2Stats = toDouble(lon); - } - QString rad = atts.value("rad"); - if (!rad.isEmpty()) { - m_xmlHandlerBundleResults->m_rmsSigmaCoord3Stats = toDouble(rad); - } - QString x = atts.value("x"); - if (!x.isEmpty()) { - m_xmlHandlerBundleResults->m_rmsSigmaCoord1Stats = toDouble(x); - } - QString y = atts.value("y"); - if (!y.isEmpty()) { - m_xmlHandlerBundleResults->m_rmsSigmaCoord2Stats = toDouble(y); - } - QString z = atts.value("z"); - if (!z.isEmpty()) { - m_xmlHandlerBundleResults->m_rmsSigmaCoord3Stats = toDouble(z); - } - } - else if (qName == "residualsList") { - QString listSizeStr = atts.value("listSize"); - if (!listSizeStr.isEmpty()) { - m_xmlHandlerResidualsListSize = toInt(listSizeStr); - } - } - else if (qName == "sampleList") { - QString listSizeStr = atts.value("listSize"); - if (!listSizeStr.isEmpty()) { - m_xmlHandlerSampleResidualsListSize = toInt(listSizeStr); - } - } - else if (qName == "lineList") { - QString listSizeStr = atts.value("listSize"); - if (!listSizeStr.isEmpty()) { - m_xmlHandlerLineResidualsListSize = toInt(listSizeStr); - } - } - else if (qName == "xSigmas") { - QString listSizeStr = atts.value("listSize"); - if (!listSizeStr.isEmpty()) { - m_xmlHandlerXSigmasListSize = toInt(listSizeStr); - } - } - else if (qName == "ySigmas") { - QString listSizeStr = atts.value("listSize"); - if (!listSizeStr.isEmpty()) { - m_xmlHandlerYSigmasListSize = toInt(listSizeStr); - } - } - else if (qName == "zSigmas") { - QString listSizeStr = atts.value("listSize"); - if (!listSizeStr.isEmpty()) { - m_xmlHandlerZSigmasListSize = toInt(listSizeStr); - } - } - else if (qName == "raSigmas") { - QString listSizeStr = atts.value("listSize"); - if (!listSizeStr.isEmpty()) { - m_xmlHandlerRASigmasListSize = toInt(listSizeStr); - } - - } - else if (qName == "decSigmas") { - QString listSizeStr = atts.value("listSize"); - if (!listSizeStr.isEmpty()) { - m_xmlHandlerDECSigmasListSize = toInt(listSizeStr); - } - } - else if (qName == "twistSigmas") { - QString listSizeStr = atts.value("listSize"); - if (!listSizeStr.isEmpty()) { - m_xmlHandlerTWISTSigmasListSize = toInt(listSizeStr); - } - } - else if (qName == "statisticsItem") { - // add statistics object to the xml handler's current statistics list. - m_xmlHandlerStatisticsList.append( - new Statistics(m_xmlHandlerProject, reader())); - } - else if (qName == "elapsedTime") { - QString time = atts.value("time"); - if (!time.isEmpty()) { - m_xmlHandlerBundleResults->m_elapsedTime = toDouble(time); - } - - QString errorProp = atts.value("errorProp"); - if (!errorProp.isEmpty()) { - m_xmlHandlerBundleResults->m_elapsedTimeErrorProp = toDouble(errorProp); - } - - } -// ??? else if (qName == "minMaxSigmaDistances") { -// ??? QString units = atts.value("units"); -// ??? if (!QString::compare(units, "meters", Qt::CaseInsensitive)) { -// ??? QString msg = "Unable to read BundleResults xml. Sigma distances must be " -// ??? "provided in meters."; -// ??? throw IException(IException::Io, msg, _FILEINFO_); -// ??? } -// ??? } - else if (qName == "minLat") { - QString minLat = atts.value("value"); - if (!minLat.isEmpty()) { - m_xmlHandlerBundleResults->m_minSigmaCoord1Distance.setMeters(toDouble(minLat)); - } - - QString minLatPointId = atts.value("pointId"); - if (!minLatPointId.isEmpty()) { - m_xmlHandlerBundleResults->m_minSigmaCoord1PointId = minLatPointId; - } - - } - else if (qName == "minX") { - QString minX = atts.value("value"); - if (!minX.isEmpty()) { - m_xmlHandlerBundleResults->m_minSigmaCoord1Distance.setMeters(toDouble(minX)); - } - - QString minXPointId = atts.value("pointId"); - if (!minXPointId.isEmpty()) { - m_xmlHandlerBundleResults->m_minSigmaCoord1PointId = minXPointId; - } - } - else if (qName == "maxLat") { - QString maxLat = atts.value("value"); - if (!maxLat.isEmpty()) { - m_xmlHandlerBundleResults->m_maxSigmaCoord1Distance.setMeters(toDouble(maxLat)); - } - - QString maxLatPointId = atts.value("pointId"); - if (!maxLatPointId.isEmpty()) { - m_xmlHandlerBundleResults->m_maxSigmaCoord1PointId = maxLatPointId; - } - - } - else if (qName == "maxX") { - - QString maxX = atts.value("value"); - if (!maxX.isEmpty()) { - m_xmlHandlerBundleResults->m_maxSigmaCoord1Distance.setMeters(toDouble(maxX)); - } - - QString maxXPointId = atts.value("pointId"); - if (!maxXPointId.isEmpty()) { - m_xmlHandlerBundleResults->m_maxSigmaCoord1PointId = maxXPointId; - } - - } - else if (qName == "minLon") { - - QString minLon = atts.value("value"); - if (!minLon.isEmpty()) { - m_xmlHandlerBundleResults->m_minSigmaCoord2Distance.setMeters(toDouble(minLon)); - } - - QString minLonPointId = atts.value("pointId"); - if (!minLonPointId.isEmpty()) { - m_xmlHandlerBundleResults->m_minSigmaCoord2PointId = minLonPointId; - } - - } - else if (qName == "minY") { - - QString minY = atts.value("value"); - if (!minY.isEmpty()) { - m_xmlHandlerBundleResults->m_minSigmaCoord2Distance.setMeters(toDouble(minY)); - } - - QString minYPointId = atts.value("pointId"); - if (!minYPointId.isEmpty()) { - m_xmlHandlerBundleResults->m_minSigmaCoord2PointId = minYPointId; - } - - } - else if (qName == "maxLon") { - - QString maxLon = atts.value("value"); - if (!maxLon.isEmpty()) { - m_xmlHandlerBundleResults->m_maxSigmaCoord2Distance.setMeters(toDouble(maxLon)); - } - - QString maxLonPointId = atts.value("pointId"); - if (!maxLonPointId.isEmpty()) { - m_xmlHandlerBundleResults->m_maxSigmaCoord2PointId = maxLonPointId; - } - - } - else if (qName == "maxY") { - QString maxY = atts.value("value"); - if (!maxY.isEmpty()) { - m_xmlHandlerBundleResults->m_maxSigmaCoord2Distance.setMeters(toDouble(maxY)); - } - - QString maxYPointId = atts.value("pointId"); - if (!maxYPointId.isEmpty()) { - m_xmlHandlerBundleResults->m_maxSigmaCoord2PointId = maxYPointId; - } - - } - else if (qName == "minRad") { - - QString minRad = atts.value("value"); - if (!minRad.isEmpty()) { - m_xmlHandlerBundleResults->m_minSigmaCoord3Distance.setMeters(toDouble(minRad)); - } - - QString minRadPointId = atts.value("pointId"); - if (!minRadPointId.isEmpty()) { - m_xmlHandlerBundleResults->m_minSigmaCoord3PointId = minRadPointId; - } - - } - else if (qName == "minZ") { - - QString minZ = atts.value("value"); - if (!minZ.isEmpty()) { - m_xmlHandlerBundleResults->m_minSigmaCoord3Distance.setMeters(toDouble(minZ)); - } - - QString minZPointId = atts.value("pointId"); - if (!minZPointId.isEmpty()) { - m_xmlHandlerBundleResults->m_minSigmaCoord3PointId = minZPointId; - } - - } - else if (qName == "maxRad") { - - QString maxRad = atts.value("value"); - if (!maxRad.isEmpty()) { - m_xmlHandlerBundleResults->m_maxSigmaCoord3Distance.setMeters(toDouble(maxRad)); - } - - QString maxRadPointId = atts.value("pointId"); - if (!maxRadPointId.isEmpty()) { - m_xmlHandlerBundleResults->m_maxSigmaCoord3PointId = maxRadPointId; - } - - } - else if (qName == "maxZ") { - - QString maxZ = atts.value("value"); - if (!maxZ.isEmpty()) { - m_xmlHandlerBundleResults->m_maxSigmaCoord3Distance.setMeters(toDouble(maxZ)); - } - - QString maxZPointId = atts.value("pointId"); - if (!maxZPointId.isEmpty()) { - m_xmlHandlerBundleResults->m_maxSigmaCoord3PointId = maxZPointId; - } - - } - else if (qName == "maximumLikelihoodEstimation") { - QString maximumLikelihoodIndex = atts.value("maximumLikelihoodIndex"); - if (!maximumLikelihoodIndex.isEmpty()) { - m_xmlHandlerBundleResults->m_maximumLikelihoodIndex = toInt(maximumLikelihoodIndex); - } - - QString maximumLikelihoodMedianR2Residuals = - atts.value("maximumLikelihoodMedianR2Residuals"); - if (!maximumLikelihoodMedianR2Residuals.isEmpty()) { - m_xmlHandlerBundleResults->m_maximumLikelihoodMedianR2Residuals = - toDouble(maximumLikelihoodMedianR2Residuals); - } - } - else if (qName == "model") { - QString model = atts.value("modelSelection"); - QString tweakingConstant = atts.value("tweakingConstant"); - QString quantile = atts.value("quantile"); - bool validModel = true; - if (model.isEmpty()) validModel = false; - if (tweakingConstant.isEmpty()) validModel = false; - if (quantile.isEmpty()) validModel = false; - if (validModel) { - m_xmlHandlerBundleResults->m_maximumLikelihoodFunctions.append( - qMakePair(MaximumLikelihoodWFunctions( - MaximumLikelihoodWFunctions::stringToModel(model), - toDouble(tweakingConstant)), - toDouble(quantile))); - } - } - else if (qName == "cumulativeProbabilityCalculator") { - m_xmlHandlerBundleResults->m_cumPro = NULL; - m_xmlHandlerBundleResults->m_cumPro = - new StatCumProbDistDynCalc(m_xmlHandlerProject, reader()); - } - else if (qName == "residualsCumulativeProbabilityCalculator") { - m_xmlHandlerBundleResults->m_cumProRes = NULL; - m_xmlHandlerBundleResults->m_cumProRes = new StatCumProbDistDynCalc(m_xmlHandlerProject, - reader()); - } - } - return true; - } - - - /** - * Adds a QString to the XmlHandler's internal character data. - * - * @param ch The data to be added. - * - * @return @b bool true - */ - bool BundleResults::XmlHandler::characters(const QString &ch) { - m_xmlHandlerCharacters += ch; - return XmlStackedHandler::characters(ch); - } - - - /** - * @brief Handle end tags for the BundleResults serialized XML. - * - * @param namespaceURI URI of the specified tags namespce - * @param localName SAX localName - * @param qName SAX qualified name - * - * @return true - */ - bool BundleResults::XmlHandler::endElement(const QString &namespaceURI, const QString &localName, - const QString &qName) { - - if (!m_xmlHandlerCharacters.isEmpty()) { - if (qName == "parameter") { - // add the parameter to the current list - m_xmlHandlerCorrelationParameterList.append(m_xmlHandlerCharacters); - } - if (qName == "image") { - // add this image and its parameters to the map - if (m_xmlHandlerCorrelationImageId != "") { - m_xmlHandlerCorrelationMap.insert(m_xmlHandlerCorrelationImageId, - m_xmlHandlerCorrelationParameterList); - } - m_xmlHandlerCorrelationImageId = ""; - m_xmlHandlerCorrelationParameterList.clear(); - - } - if (qName == "imagesAndParameters") { - // set the map after all images and parameters have been added - if (!m_xmlHandlerCorrelationMap.isEmpty()) { - m_xmlHandlerBundleResults->setCorrMatImgsAndParams(m_xmlHandlerCorrelationMap); - } - } - else if (qName == "numberFixedPoints") { - m_xmlHandlerBundleResults->m_numberFixedPoints = toInt(m_xmlHandlerCharacters); - } - else if (qName == "numberIgnoredPoints") { - m_xmlHandlerBundleResults->m_numberIgnoredPoints = toInt(m_xmlHandlerCharacters); - } - else if (qName == "numberHeldImages") { - m_xmlHandlerBundleResults->m_numberHeldImages = toInt(m_xmlHandlerCharacters); - } - else if (qName == "rejectionLimit") { - m_xmlHandlerBundleResults->m_rejectionLimit = toDouble(m_xmlHandlerCharacters); - } - else if (qName == "numberRejectedObservations") { - m_xmlHandlerBundleResults->m_numberRejectedObservations = toInt(m_xmlHandlerCharacters); - } - else if (qName == "numberLidarRangeConstraintEquations") { - m_xmlHandlerBundleResults->m_numberLidarRangeConstraintEquations = toInt(m_xmlHandlerCharacters); - } - else if (qName == "numberObservations") { - m_xmlHandlerBundleResults->m_numberObservations = toInt(m_xmlHandlerCharacters); - } - else if (qName == "numberImageObservations") { - m_xmlHandlerBundleResults->m_numberImageObservations = toInt(m_xmlHandlerCharacters); - } - else if (qName == "numberLidarImageObservations") { - m_xmlHandlerBundleResults->m_numberLidarImageObservations = toInt(m_xmlHandlerCharacters); - } - else if (qName == "numberImageParameters") { - m_xmlHandlerBundleResults->m_numberImageParameters = toInt(m_xmlHandlerCharacters); - } - else if (qName == "numberConstrainedPointParameters") { - m_xmlHandlerBundleResults->m_numberConstrainedPointParameters = - toInt(m_xmlHandlerCharacters); - } - else if (qName == "numberConstrainedImageParameters") { - m_xmlHandlerBundleResults->m_numberConstrainedImageParameters = - toInt(m_xmlHandlerCharacters); - } - else if (qName == "numberConstrainedTargetParameters") { - m_xmlHandlerBundleResults->m_numberConstrainedTargetParameters = - toInt(m_xmlHandlerCharacters); - } - else if (qName == "numberUnknownParameters") { - m_xmlHandlerBundleResults->m_numberUnknownParameters = toInt(m_xmlHandlerCharacters); - } - else if (qName == "degreesOfFreedom") { - m_xmlHandlerBundleResults->m_degreesOfFreedom = toInt(m_xmlHandlerCharacters); - } - else if (qName == "sigma0") { - m_xmlHandlerBundleResults->m_sigma0 = toDouble(m_xmlHandlerCharacters); - } - else if (qName == "converged") { - m_xmlHandlerBundleResults->m_converged = toBool(m_xmlHandlerCharacters); - } - else if (qName == "iterations") { - m_xmlHandlerBundleResults->m_iterations = toInt(m_xmlHandlerCharacters); - } - // copy the xml handler's statistics list to the appropriate bundle statistics list - else if (qName == "residualsList") { - if (m_xmlHandlerResidualsListSize != m_xmlHandlerStatisticsList.size()) { - throw IException(IException::Unknown, - "Unable to read xml file. Invalid residualsList", _FILEINFO_); - } - for (int i = 0; i < m_xmlHandlerStatisticsList.size(); i++) { - m_xmlHandlerBundleResults->m_rmsImageResiduals.append(m_xmlHandlerStatisticsList[i]); - } - m_xmlHandlerStatisticsList.clear(); - } - else if (qName == "sampleList") { - if (m_xmlHandlerSampleResidualsListSize != m_xmlHandlerStatisticsList.size()) { - throw IException(IException::Unknown, - "Unable to read xml file. Invalid sampleList", _FILEINFO_); - } - for (int i = 0; i < m_xmlHandlerStatisticsList.size(); i++) { - m_xmlHandlerBundleResults->m_rmsImageSampleResiduals.append( - m_xmlHandlerStatisticsList[i]); - } - m_xmlHandlerStatisticsList.clear(); - } - else if (qName == "lineList") { - if (m_xmlHandlerLineResidualsListSize != m_xmlHandlerStatisticsList.size()) { - throw IException(IException::Unknown, - "Unable to read xml file. Invalid lineList", _FILEINFO_); - } - for (int i = 0; i < m_xmlHandlerStatisticsList.size(); i++) { - m_xmlHandlerBundleResults->m_rmsImageLineResiduals.append(m_xmlHandlerStatisticsList[i]); - } - m_xmlHandlerStatisticsList.clear(); - } - else if (qName == "lidarResidualsList") { - if (m_xmlHandlerResidualsListSize != m_xmlHandlerStatisticsList.size()) { - throw IException(IException::Unknown, - "Unable to read xml file. Invalid residualsList", _FILEINFO_); - } - for (int i = 0; i < m_xmlHandlerStatisticsList.size(); i++) { - m_xmlHandlerBundleResults->m_rmsLidarImageResiduals.append(m_xmlHandlerStatisticsList[i]); - } - m_xmlHandlerStatisticsList.clear(); - } - else if (qName == "lidarSampleList") { - if (m_xmlHandlerSampleResidualsListSize != m_xmlHandlerStatisticsList.size()) { - throw IException(IException::Unknown, - "Unable to read xml file. Invalid sampleList", _FILEINFO_); - } - for (int i = 0; i < m_xmlHandlerStatisticsList.size(); i++) { - m_xmlHandlerBundleResults->m_rmsLidarImageSampleResiduals.append( - m_xmlHandlerStatisticsList[i]); - } - m_xmlHandlerStatisticsList.clear(); - } - else if (qName == "lidarLineList") { - if (m_xmlHandlerLineResidualsListSize != m_xmlHandlerStatisticsList.size()) { - throw IException(IException::Unknown, - "Unable to read xml file. Invalid lineList", _FILEINFO_); - } - for (int i = 0; i < m_xmlHandlerStatisticsList.size(); i++) { - m_xmlHandlerBundleResults->m_rmsLidarImageLineResiduals.append(m_xmlHandlerStatisticsList[i]); - } - m_xmlHandlerStatisticsList.clear(); - } - else if (qName == "xSigmas") { - if (m_xmlHandlerXSigmasListSize != m_xmlHandlerStatisticsList.size()) { - throw IException(IException::Unknown, - "Unable to read xml file. Invalid xSigmas", _FILEINFO_); - } - for (int i = 0; i < m_xmlHandlerStatisticsList.size(); i++) { - m_xmlHandlerBundleResults->m_rmsImageXSigmas.append(m_xmlHandlerStatisticsList[i]); - } - m_xmlHandlerStatisticsList.clear(); - } - else if (qName == "ySigmas") { - if (m_xmlHandlerYSigmasListSize != m_xmlHandlerStatisticsList.size()) { - throw IException(IException::Unknown, - "Unable to read xml file. Invalid ySigmas", _FILEINFO_); - } - for (int i = 0; i < m_xmlHandlerStatisticsList.size(); i++) { - m_xmlHandlerBundleResults->m_rmsImageYSigmas.append(m_xmlHandlerStatisticsList[i]); - } - m_xmlHandlerStatisticsList.clear(); - } - else if (qName == "zSigmas") { - if (m_xmlHandlerZSigmasListSize != m_xmlHandlerStatisticsList.size()) { - throw IException(IException::Unknown, - "Unable to read xml file. Invalid zSigmas", _FILEINFO_); - } - for (int i = 0; i < m_xmlHandlerStatisticsList.size(); i++) { - m_xmlHandlerBundleResults->m_rmsImageZSigmas.append(m_xmlHandlerStatisticsList[i]); - } - m_xmlHandlerStatisticsList.clear(); - } - else if (qName == "raSigmas") { - if (m_xmlHandlerRASigmasListSize != m_xmlHandlerStatisticsList.size()) { - throw IException(IException::Unknown, - "Unable to read xml file. Invalid raSigmas", _FILEINFO_); - } - for (int i = 0; i < m_xmlHandlerStatisticsList.size(); i++) { - m_xmlHandlerBundleResults->m_rmsImageRASigmas.append(m_xmlHandlerStatisticsList[i]); - } - m_xmlHandlerStatisticsList.clear(); - } - else if (qName == "decSigmas") { - if (m_xmlHandlerDECSigmasListSize != m_xmlHandlerStatisticsList.size()) { - throw IException(IException::Unknown, - "Unable to read xml file. Invalid decSigmas", _FILEINFO_); - } - for (int i = 0; i < m_xmlHandlerStatisticsList.size(); i++) { - m_xmlHandlerBundleResults->m_rmsImageDECSigmas.append(m_xmlHandlerStatisticsList[i]); - } - m_xmlHandlerStatisticsList.clear(); - } - else if (qName == "twistSigmas") { - if (m_xmlHandlerTWISTSigmasListSize != m_xmlHandlerStatisticsList.size()) { - throw IException(IException::Unknown, - "Unable to read xml file. Invalid twistSigmas", _FILEINFO_); - } - for (int i = 0; i < m_xmlHandlerStatisticsList.size(); i++) { - m_xmlHandlerBundleResults->m_rmsImageTWISTSigmas.append(m_xmlHandlerStatisticsList[i]); - } - m_xmlHandlerStatisticsList.clear(); - } - } - m_xmlHandlerCharacters = ""; - return XmlStackedHandler::endElement(namespaceURI, localName, qName); - } -} +} \ No newline at end of file diff --git a/isis/src/control/objs/BundleResults/BundleResults.h b/isis/src/control/objs/BundleResults/BundleResults.h index 219dd89301..8afd1dfe8d 100644 --- a/isis/src/control/objs/BundleResults/BundleResults.h +++ b/isis/src/control/objs/BundleResults/BundleResults.h @@ -28,12 +28,12 @@ find files of those names at the top level of this repository. **/ #include "PvlObject.h" #include "Statistics.h" // ??? #include "SurfacePoint.h" -#include "XmlStackedHandler.h" // Qt Library class QDataStream; class QUuid; class QXmlStreamWriter; +class QXmlStreamReader; namespace Isis { // Isis Library @@ -44,7 +44,6 @@ namespace Isis { class PvlObject; class SerialNumberList; class StatCumProbDistDynCalc; - class XmlStackedHandlerReader; /** * A container class for statistical results from a BundleAdjust solution. @@ -92,8 +91,19 @@ namespace Isis { Q_OBJECT public: BundleResults(QObject *parent = 0); - // TODO: does xml stuff need project??? - BundleResults(Project *project, XmlStackedHandlerReader *xmlReader, QObject *parent = 0); + BundleResults(QXmlStreamReader *xmlReader, + QObject *parent = 0); + void readBundleResults(QXmlStreamReader *xmlReader); + void readCorrelationMatrix(QXmlStreamReader *xmlReader); + void readGenStatsValues(QXmlStreamReader *xmlReader); + void readRms(QXmlStreamReader *xmlReader); + void readImageResidualsLists(QXmlStreamReader *xmlReader); + void readSigmasLists(QXmlStreamReader *xmlReader); + void readStatsToList(QList &list, QXmlStreamReader *xmlReader); + void readStatsToVector(QVector &vec, QXmlStreamReader *xmlReader); + void readMinMaxSigmas(QXmlStreamReader *xmlReader); + void readSigma(Distance &dist, QString &pointId, QXmlStreamReader *xmlReader); + void readMaxLikelihoodEstimation(QXmlStreamReader *xmlReader); BundleResults(const BundleResults &src); ~BundleResults(); BundleResults &operator=(const BundleResults &src); @@ -265,52 +275,6 @@ namespace Isis { // TODO: does xml stuff need project??? void save(QXmlStreamWriter &stream, const Project *project) const; - - private: - /** - * This class is an XmlHandler used to read and write BundleResults objects - * from and to XML files. Documentation will be updated when it is decided - * if XML support will remain. - * - * @author 2014-07-28 Jeannie Backer - * - * @internal - */ - class XmlHandler : public XmlStackedHandler { - public: - // TODO: does xml stuff need project??? - XmlHandler(BundleResults *statistics, Project *project); - ~XmlHandler(); - - virtual bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts); - virtual bool characters(const QString &ch); - virtual bool endElement(const QString &namespaceURI, const QString &localName, - const QString &qName); - - private: - Q_DISABLE_COPY(XmlHandler); - - BundleResults *m_xmlHandlerBundleResults; - Project *m_xmlHandlerProject; // TODO: does xml stuff need project??? - QString m_xmlHandlerCharacters; - int m_xmlHandlerResidualsListSize; - int m_xmlHandlerSampleResidualsListSize; - int m_xmlHandlerLineResidualsListSize; - int m_xmlHandlerXSigmasListSize; - int m_xmlHandlerYSigmasListSize; - int m_xmlHandlerZSigmasListSize; - int m_xmlHandlerRASigmasListSize; - int m_xmlHandlerDECSigmasListSize; - int m_xmlHandlerTWISTSigmasListSize; - QList m_xmlHandlerStatisticsList; - StatCumProbDistDynCalc *m_xmlHandlerCumProCalc; - - QString m_xmlHandlerCorrelationImageId; - QStringList m_xmlHandlerCorrelationParameterList; - QMap m_xmlHandlerCorrelationMap; - }; - CorrelationMatrix *m_correlationMatrix; //!< The correlation matrix from the BundleAdjust. int m_numberFixedPoints; //!< number of 'fixed' (ground) points (define) @@ -383,7 +347,7 @@ namespace Isis { stats for each image in the bundle */ //!< The root mean square image x sigmas. - QVector m_rmsImageXSigmas; // unset and unused ??? + QVector m_rmsImageXSigmas; // unset and unused ??? //!< The root mean square image y sigmas. QVector m_rmsImageYSigmas; // unset and unused ??? //!< The root mean square image z sigmas. @@ -445,10 +409,28 @@ namespace Isis { reporting, and not for computation.*/ double m_maximumLikelihoodMedianR2Residuals; /**< Median of R^2 residuals.*/ - }; + private: + BundleResults *m_xmlHandlerBundleResults; + QString m_xmlHandlerCharacters; + int m_xmlHandlerResidualsListSize; + int m_xmlHandlerSampleResidualsListSize; + int m_xmlHandlerLineResidualsListSize; + int m_xmlHandlerXSigmasListSize; + int m_xmlHandlerYSigmasListSize; + int m_xmlHandlerZSigmasListSize; + int m_xmlHandlerRASigmasListSize; + int m_xmlHandlerDECSigmasListSize; + int m_xmlHandlerTWISTSigmasListSize; + QList m_xmlHandlerStatisticsList; + StatCumProbDistDynCalc *m_xmlHandlerCumProCalc; + + QString m_xmlHandlerCorrelationImageId; + QStringList m_xmlHandlerCorrelationParameterList; + QMap m_xmlHandlerCorrelationMap; +}; }; Q_DECLARE_METATYPE(Isis::BundleResults); -#endif // BundleResults_h +#endif // BundleResults_h \ No newline at end of file diff --git a/isis/src/control/objs/BundleSettings/BundleSettings.cpp b/isis/src/control/objs/BundleSettings/BundleSettings.cpp index 87100ff498..2db12c1aa9 100644 --- a/isis/src/control/objs/BundleSettings/BundleSettings.cpp +++ b/isis/src/control/objs/BundleSettings/BundleSettings.cpp @@ -24,7 +24,6 @@ find files of those names at the top level of this repository. **/ #include "PvlKeyword.h" #include "PvlObject.h" #include "SpecialPixel.h" -#include "XmlStackedHandlerReader.h" namespace Isis { @@ -91,30 +90,6 @@ namespace Isis { } - /** - * 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); - * XmlStackedHandlerReader reader; - * BundleSettings settings(project, reader); - * @endcode - * - * @param project A pointer to the project where the Settings will be saved. - * @param xmlReader The Content handler to parse the BundleSettings XML - */ - BundleSettings::BundleSettings(Project *project, - XmlStackedHandlerReader *xmlReader) { - init(); - xmlReader->setErrorHandler(new XmlHandler(this, project)); - xmlReader->pushContentHandler(new XmlHandler(this, project)); - } - - /** * This copy constructor sets this BundleSettings' member data to match * that of the 'other' given BundleSettings. @@ -1133,241 +1108,162 @@ namespace Isis { stream.writeEndElement(); } - - /** - * @brief Create an XML Handler (reader) that can populate the BundleSettings class data. - * See BundleSettings::save() for the expected format. This contructor is called - * inside the BundleSettings constructor that takes an XmlStackedHandlerReader. - * - * @param bundleSettings The BundleSettings we're going to be initializing - * @param project The project that contains the settings - */ - BundleSettings::XmlHandler::XmlHandler(BundleSettings *bundleSettings, Project *project) { - m_xmlHandlerBundleSettings = bundleSettings; - m_xmlHandlerProject = project; - m_xmlHandlerCharacters = ""; - m_xmlHandlerObservationSettings.clear(); - } - - - /** - * @brief Destroys BundleSettings::XmlHandler object. - */ - BundleSettings::XmlHandler::~XmlHandler() { - } - - - /** - * Handle an XML start element. This method is called when the reader finds an open tag. - * handle the read when the startElement with the name localName has been found. - * - * @param qName SAX namespace for this tag - * @param localName SAX local name - * @param qName SAX qualified name of the tag. - * @param attributes The list of attributes for the tag. - * - * @return @b bool Indicates whether to continue reading the XML (usually true). - * - * @internal - * @history 2017-05-30 Debbie A. Cook - Added controlPointCoordTypes to the pvl - * and made global coordinate names generic. - */ - bool BundleSettings::XmlHandler::startElement(const QString &namespaceURI, - const QString &localName, - const QString &qName, - const QXmlAttributes &attributes) { - m_xmlHandlerCharacters = ""; - - if (XmlStackedHandler::startElement(namespaceURI, localName, qName, attributes)) { - - if (localName == "solveOptions") { - - QString solveObservationModeStr = attributes.value("solveObservationMode"); - if (!solveObservationModeStr.isEmpty()) { - m_xmlHandlerBundleSettings->m_solveObservationMode = toBool(solveObservationModeStr); - } - - QString solveRadiusStr = attributes.value("solveRadius"); - if (!solveRadiusStr.isEmpty()) { - m_xmlHandlerBundleSettings->m_solveRadius = toBool(solveRadiusStr); - } - - QString coordTypeReportsStr = attributes.value("controlPointCoordinateTypeReports"); - if (!coordTypeReportsStr.isEmpty()) { - m_xmlHandlerBundleSettings->m_cpCoordTypeReports = - SurfacePoint::stringToCoordinateType(coordTypeReportsStr); - } - - QString coordTypeBundleStr = attributes.value("controlPointCoordinateTypeBundle"); - if (!coordTypeBundleStr.isEmpty()) { - m_xmlHandlerBundleSettings->m_cpCoordTypeBundle = - SurfacePoint::stringToCoordinateType(coordTypeBundleStr); - } - - QString updateCubeLabelStr = attributes.value("updateCubeLabel"); - if (!updateCubeLabelStr.isEmpty()) { - m_xmlHandlerBundleSettings->m_updateCubeLabel = toBool(updateCubeLabelStr); - } - - QString errorPropagationStr = attributes.value("errorPropagation"); - if (!errorPropagationStr.isEmpty()) { - m_xmlHandlerBundleSettings->m_errorPropagation = toBool(errorPropagationStr); - } - - QString createInverseMatrixStr = attributes.value("createInverseMatrix"); - if (!createInverseMatrixStr.isEmpty()) { - m_xmlHandlerBundleSettings->m_createInverseMatrix = toBool(createInverseMatrixStr); - } - } - else if (localName == "aprioriSigmas") { - - QString globalPointCoord1AprioriSigmaStr = attributes.value("pointCoord1"); - m_xmlHandlerBundleSettings->m_globalPointCoord1AprioriSigma = Isis::Null; - // TODO: why do I need to init this one and not other sigmas??? - if (!globalPointCoord1AprioriSigmaStr.isEmpty()) { - if (globalPointCoord1AprioriSigmaStr == "N/A") { - m_xmlHandlerBundleSettings->m_globalPointCoord1AprioriSigma = Isis::Null; + void BundleSettings::readBundleSettings(QXmlStreamReader *xmlReader) { + init(); + Q_ASSERT(xmlReader->name() == "bundleSettings"); + while (xmlReader->readNextStartElement()) { + if (xmlReader->qualifiedName() == "globalSettings") { + while (xmlReader->readNextStartElement()) { + if (xmlReader->qualifiedName() == "validateNetwork") { + QString validateNetwork = xmlReader->readElementText(); + if (!validateNetwork.isEmpty()) { + m_validateNetwork = toBool(validateNetwork); + } } - else { - m_xmlHandlerBundleSettings->m_globalPointCoord1AprioriSigma - = toDouble(globalPointCoord1AprioriSigmaStr); + else if (xmlReader->qualifiedName() == "solveOptions") { + QStringRef solveObservationMode = xmlReader->attributes().value("solveObservationMode"); + if (!solveObservationMode.isEmpty()) { + m_solveObservationMode = toBool(solveObservationMode.toString()); + } + QStringRef solveRadius = xmlReader->attributes().value("solveRadius"); + if (!solveRadius.isEmpty()) { + m_solveRadius = toBool(solveRadius.toString()); + } + QStringRef controlPointCoordTypeReports = xmlReader->attributes().value("controlPointCoordTypeReports"); + if (!controlPointCoordTypeReports.isEmpty()) { + if (controlPointCoordTypeReports == "0") { + m_cpCoordTypeReports = SurfacePoint::Latitudinal; + } + else if (controlPointCoordTypeReports == "1") { + m_cpCoordTypeReports = SurfacePoint::Rectangular; + } + } + QStringRef controlPointCoordTypeBundle = xmlReader->attributes().value("controlPointCoordTypeBundle"); + if (!controlPointCoordTypeBundle.isEmpty()) { + if (controlPointCoordTypeBundle == "0") { + m_cpCoordTypeBundle = SurfacePoint::Latitudinal; + } + else if (controlPointCoordTypeBundle == "1") { + m_cpCoordTypeBundle = SurfacePoint::Rectangular; + } + } + QStringRef updateCubeLabel = xmlReader->attributes().value("updateCubeLabel"); + if (!updateCubeLabel.isEmpty()) { + m_updateCubeLabel = toBool(updateCubeLabel.toString()); + } + QStringRef errorPropagation = xmlReader->attributes().value("errorPropagation"); + if (!errorPropagation.isEmpty()) { + m_errorPropagation = toBool(errorPropagation.toString()); + } + QStringRef createInverseMatrix = xmlReader->attributes().value("createInverseMatrix"); + if (!createInverseMatrix.isEmpty()) { + m_createInverseMatrix = toBool(createInverseMatrix.toString()); + } + xmlReader->skipCurrentElement(); } - } - - QString globalPointCoord2AprioriSigmaStr = attributes.value("pointCoord2"); - if (!globalPointCoord2AprioriSigmaStr.isEmpty()) { - if (globalPointCoord2AprioriSigmaStr == "N/A") { - m_xmlHandlerBundleSettings->m_globalPointCoord2AprioriSigma = Isis::Null; + else if (xmlReader->qualifiedName() == "aprioriSigmas") { + QStringRef globalPointCoord1AprioriSigma = xmlReader->attributes().value("pointCoord1"); + if (!globalPointCoord1AprioriSigma.isEmpty()) { + if (globalPointCoord1AprioriSigma == "N/A") { + m_globalPointCoord1AprioriSigma = Isis::Null; + } + else { + m_globalPointCoord1AprioriSigma = globalPointCoord1AprioriSigma.toDouble(); + } + } + QStringRef globalPointCoord2AprioriSigma = xmlReader->attributes().value("pointCoord2"); + if (!globalPointCoord2AprioriSigma.isEmpty()) { + if (globalPointCoord2AprioriSigma == "N/A") { + m_globalPointCoord2AprioriSigma = Isis::Null; + } + else { + m_globalPointCoord2AprioriSigma = globalPointCoord2AprioriSigma.toDouble(); + } + } + QStringRef globalPointCoord3AprioriSigma = xmlReader->attributes().value("radius"); + if (!globalPointCoord3AprioriSigma.isEmpty()) { + if (globalPointCoord3AprioriSigma == "N/A") { + m_globalPointCoord3AprioriSigma = Isis::Null; + } + else { + m_globalPointCoord3AprioriSigma = globalPointCoord3AprioriSigma.toDouble(); + } + } + xmlReader->skipCurrentElement(); } - else { - m_xmlHandlerBundleSettings->m_globalPointCoord2AprioriSigma - = toDouble(globalPointCoord2AprioriSigmaStr); + else if (xmlReader->qualifiedName() == "outlierRejectionOptions") { + QStringRef outlierRejection = xmlReader->attributes().value("rejection"); + if (!outlierRejection.isEmpty()) { + m_outlierRejection = toBool(outlierRejection.toString()); + } + QStringRef outlierRejectionMultiplier = xmlReader->attributes().value("multiplier"); + if (!outlierRejectionMultiplier.isEmpty()) { + if (outlierRejectionMultiplier != "N/A") { + m_outlierRejectionMultiplier = outlierRejectionMultiplier.toDouble(); + } + else { + m_outlierRejectionMultiplier = 3.0; + } + } + xmlReader->skipCurrentElement(); } - } - - QString globalPointCoord3AprioriSigmaStr = attributes.value("radius"); - if (!globalPointCoord3AprioriSigmaStr.isEmpty()) { - if (globalPointCoord3AprioriSigmaStr == "N/A") { - m_xmlHandlerBundleSettings->m_globalPointCoord3AprioriSigma = Isis::Null; + else if (xmlReader->qualifiedName() == "convergenceCriteriaOptions") { + QStringRef convergenceCriteria = xmlReader->attributes().value("convergenceCriteria"); + if (!convergenceCriteria.isEmpty()) { + m_convergenceCriteria = stringToConvergenceCriteria(convergenceCriteria.toString()); + } + QStringRef threshold = xmlReader->attributes().value("threshold"); + if (!threshold.isEmpty()) { + m_convergenceCriteriaThreshold = threshold.toDouble(); + } + QStringRef maximumIterations = xmlReader->attributes().value("maximumIterations"); + if (!maximumIterations.isEmpty()) { + m_convergenceCriteriaMaximumIterations = maximumIterations.toInt(); + } + xmlReader->skipCurrentElement(); + } + else if (xmlReader->qualifiedName() == "maximumLikelihoodEstimation") { + while (xmlReader->readNextStartElement()) { + if (xmlReader->qualifiedName() == "model") { + QStringRef type = xmlReader->attributes().value("type"); + QStringRef quantile = xmlReader->attributes().value("quantile"); + if (!type.isEmpty() && !quantile.isEmpty()) { + m_maximumLikelihood.append(qMakePair(MaximumLikelihoodWFunctions::stringToModel(type.toString()), quantile.toDouble())); + } + xmlReader->skipCurrentElement(); + } + else { + xmlReader->skipCurrentElement(); + } + } + } + else if (xmlReader->qualifiedName() == "outputFileOptions") { + QStringRef fileNamePrefix = xmlReader->attributes().value("fileNamePrefix"); + if (!fileNamePrefix.isEmpty()) { + m_outputFilePrefix = fileNamePrefix.toString(); + } + xmlReader->skipCurrentElement(); } else { - m_xmlHandlerBundleSettings->m_globalPointCoord3AprioriSigma - = toDouble(globalPointCoord3AprioriSigmaStr); + xmlReader->skipCurrentElement(); } } } - else if (localName == "outlierRejectionOptions") { - QString outlierRejectionStr = attributes.value("rejection"); - if (!outlierRejectionStr.isEmpty()) { - m_xmlHandlerBundleSettings->m_outlierRejection = toBool(outlierRejectionStr); - } - - QString outlierRejectionMultiplierStr = attributes.value("multiplier"); - if (!outlierRejectionMultiplierStr.isEmpty()) { - if (outlierRejectionMultiplierStr != "N/A") { - m_xmlHandlerBundleSettings->m_outlierRejectionMultiplier - = toDouble(outlierRejectionMultiplierStr); + else if (xmlReader->qualifiedName() == "observationSolveSettingsList") { + m_observationSolveSettings.clear(); + while (xmlReader->readNextStartElement()) { + if (xmlReader->qualifiedName() == "bundleObservationSolveSettings") { + BundleObservationSolveSettings *settings = new BundleObservationSolveSettings(xmlReader); + m_observationSolveSettings.append(*settings); } else { - m_xmlHandlerBundleSettings->m_outlierRejectionMultiplier = 3.0; + xmlReader->skipCurrentElement(); } } } - else if (localName == "convergenceCriteriaOptions") { - - QString convergenceCriteriaStr = attributes.value("convergenceCriteria"); - if (!convergenceCriteriaStr.isEmpty()) { - m_xmlHandlerBundleSettings->m_convergenceCriteria - = stringToConvergenceCriteria(convergenceCriteriaStr); - } - - QString convergenceCriteriaThresholdStr = attributes.value("threshold"); - if (!convergenceCriteriaThresholdStr.isEmpty()) { - m_xmlHandlerBundleSettings->m_convergenceCriteriaThreshold - = toDouble(convergenceCriteriaThresholdStr); - } - - QString convergenceCriteriaMaximumIterationsStr = attributes.value("maximumIterations"); - if (!convergenceCriteriaMaximumIterationsStr.isEmpty()) { - m_xmlHandlerBundleSettings->m_convergenceCriteriaMaximumIterations - = toInt(convergenceCriteriaMaximumIterationsStr); - } - } - else if (localName == "model") { - QString type = attributes.value("type"); - QString quantile = attributes.value("quantile"); - if (!type.isEmpty() && !quantile.isEmpty()) { - m_xmlHandlerBundleSettings->m_maximumLikelihood.append( - qMakePair(MaximumLikelihoodWFunctions::stringToModel(type), - toDouble(quantile))); - } - } - else if (localName == "outputFileOptions") { - QString outputFilePrefixStr = attributes.value("fileNamePrefix"); - if (!outputFilePrefixStr.isEmpty()) { - m_xmlHandlerBundleSettings->m_outputFilePrefix = outputFilePrefixStr; - } - } - else if (localName == "bundleObservationSolveSettings") { - m_xmlHandlerObservationSettings.append( - new BundleObservationSolveSettings(m_xmlHandlerProject, reader())); - } - } - return true; - } - - - /** - * @brief Add a character from an XML element to the content handler. - * - * @param ch charater from XML element - * @return true - */ - bool BundleSettings::XmlHandler::characters(const QString &ch) { - m_xmlHandlerCharacters += ch; - return XmlStackedHandler::characters(ch); - } - - - /** - * @brief Handle end tags for the BundleSettings serialized XML. - * - * @param namespaceURI URI of the specified tags namespce - * @param localName SAX localName - * @param qName SAX qualified name - * - * @return true - */ - bool BundleSettings::XmlHandler::endElement(const QString &namespaceURI, const QString &localName, - const QString &qName) { - if (!m_xmlHandlerCharacters.isEmpty()) { - if (localName == "validateNetwork") { - m_xmlHandlerBundleSettings->m_validateNetwork = toBool(m_xmlHandlerCharacters); - } - else if (localName == "observationSolveSettingsList") { - for (int i = 0; i < m_xmlHandlerObservationSettings.size(); i++) { - m_xmlHandlerBundleSettings->m_observationSolveSettings.append( - *m_xmlHandlerObservationSettings[i]); - } - m_xmlHandlerObservationSettings.clear(); + else { + xmlReader->skipCurrentElement(); } - - m_xmlHandlerCharacters = ""; } - return XmlStackedHandler::endElement(namespaceURI, localName, qName); - } - - - /** - * @brief Format an error message indicating a problem with BundleSettings. - * - * @param QXmlParseException Execption thrown by parser. - * @return false - */ - bool BundleSettings::XmlHandler::fatalError(const QXmlParseException &exception) { - qDebug() << "Parse error with BundleSettings at line " << exception.lineNumber() - << ", " << "column " << exception.columnNumber() << ": " - << qPrintable(exception.message()); - return false; } } diff --git a/isis/src/control/objs/BundleSettings/BundleSettings.h b/isis/src/control/objs/BundleSettings/BundleSettings.h index 7757d5feb2..e35334fa64 100644 --- a/isis/src/control/objs/BundleSettings/BundleSettings.h +++ b/isis/src/control/objs/BundleSettings/BundleSettings.h @@ -14,6 +14,7 @@ find files of those names at the top level of this repository. **/ #include #include #include +#include @@ -23,7 +24,6 @@ find files of those names at the top level of this repository. **/ #include "MaximumLikelihoodWFunctions.h" #include "SpecialPixel.h" #include "SurfacePoint.h" -#include "XmlStackedHandler.h" class QDataStream; class QUuid; @@ -36,7 +36,6 @@ namespace Isis { class FileName; class Project; class PvlObject; - class XmlStackedHandlerReader; /** * @brief Container class for BundleAdjustment settings. @@ -130,16 +129,6 @@ namespace Isis { //=====================================================================// BundleSettings(); BundleSettings(const BundleSettings &other); - BundleSettings(Project *project, - XmlStackedHandlerReader *xmlReader); -#if 0 - BundleSettings(FileName xmlFile, - Project *project, - XmlStackedHandlerReader *xmlReader, - QObject *parent = NULL); - BundleSettings(XmlStackedHandlerReader *xmlReader, - QObject *parent = NULL); -#endif ~BundleSettings(); BundleSettings &operator=(const BundleSettings &other); @@ -289,49 +278,11 @@ namespace Isis { void save(QXmlStreamWriter &stream, const Project *project) const; + void readBundleSettings(QXmlStreamReader *xmlReader); + private: void init(); - //=====================================================================// - //============= Saving/Restoring a BundleSettings object ==============// - //=====================================================================// - - /** - * This class is needed to read/write BundleSettings from/to an XML - * formateed file. - * - * @author 2014-07-21 Ken Edmundson - * - * @internal - * @history 2014-07-21 Ken Edmundson - Original version. - */ - class XmlHandler : public XmlStackedHandler { - public: - XmlHandler(BundleSettings *bundleSettings, - Project *project); - XmlHandler(BundleSettings *bundleSettings); - ~XmlHandler(); - - virtual bool startElement(const QString &namespaceURI, - const QString &localName, - const QString &qName, - const QXmlAttributes &atts); - virtual bool characters(const QString &ch); - virtual bool endElement(const QString &namespaceURI, - const QString &localName, - const QString &qName); - bool fatalError(const QXmlParseException &exception); - - private: - Q_DISABLE_COPY(XmlHandler); - - BundleSettings *m_xmlHandlerBundleSettings ; - Project *m_xmlHandlerProject; // TODO: does xml stuff need project??? - QString m_xmlHandlerCharacters; - QList m_xmlHandlerObservationSettings; - }; - - /** * This struct is needed to write the m_maximumLikelihood variable as an * HDF5 table. Each table record has 3 field values: index, name, and diff --git a/isis/src/control/objs/BundleSettings/BundleSettings.truth b/isis/src/control/objs/BundleSettings/BundleSettings.truth index 687aba81b7..443fa90b2b 100644 --- a/isis/src/control/objs/BundleSettings/BundleSettings.truth +++ b/isis/src/control/objs/BundleSettings/BundleSettings.truth @@ -385,7 +385,7 @@ Testing XML: Object deserialized as (should match object above): Yes - + @@ -402,9 +402,7 @@ Testing XML: Object deserialized as (should match object above): - - N/A - + diff --git a/isis/src/control/objs/BundleSettings/unitTest.cpp b/isis/src/control/objs/BundleSettings/unitTest.cpp index 21e890ce14..44a206033d 100755 --- a/isis/src/control/objs/BundleSettings/unitTest.cpp +++ b/isis/src/control/objs/BundleSettings/unitTest.cpp @@ -24,7 +24,6 @@ find files of those names at the top level of this repository. **/ #include "MaximumLikelihoodWFunctions.h" #include "Preference.h" #include "PvlObject.h" -#include "XmlStackedHandlerReader.h" using namespace std; @@ -83,8 +82,7 @@ namespace Isis { /** * Constructs BundleSettings using XML handler. * - * @param project A pointer to the project. - * @param reader A pointer to a XmlStackedHandlerReader. + * @param reader A pointer to a QXmlStreamReader. * @param xmlFile The name of the XML file to be used to create a * BundleSettings object. * @@ -92,8 +90,8 @@ namespace Isis { * @throw Isis::Exception::Io "Unable to open XML file with read access." * @throw Isis::Exception::Unknown "Failed to parse XML file." */ - BundleSettingsXmlHandlerTester(Project *project, XmlStackedHandlerReader *reader, - FileName xmlFile) : BundleSettings(project, reader) { + BundleSettingsXmlHandlerTester(QXmlStreamReader *reader, + FileName xmlFile) : BundleSettings() { QString xmlPath(xmlFile.expanded()); QFile file(xmlPath); @@ -104,12 +102,13 @@ namespace Isis { _FILEINFO_); } - QXmlInputSource xmlInputSource(&file); - bool success = reader->parse(xmlInputSource); - if (!success) { - throw IException(IException::Unknown, - QString("Failed to parse xml file, [%1]").arg(xmlPath), - _FILEINFO_); + if (reader->readNextStartElement()) { + if (reader->name() == "bundleSettings") { + readBundleSettings(reader); + } + else { + reader->raiseError(QObject::tr("Incorrect file")); + } } } @@ -276,11 +275,18 @@ int main(int argc, char *argv[]) { writer.writeEndDocument(); qXmlFile.close(); + if(!qXmlFile.open(QFile::ReadOnly | QFile::Text)){ + throw IException(IException::Unknown, + QString("Failed to parse xml file, [%1]").arg(qXmlFile.fileName()), + _FILEINFO_); + } + // read serialized xml into object and then write object to log file qDebug() << "Testing XML: Object deserialized as (should match object above):"; - XmlStackedHandlerReader reader; - BundleSettingsXmlHandlerTester bsFromXml(project, &reader, xmlFile); + QXmlStreamReader reader(&qXmlFile); + BundleSettingsXmlHandlerTester bsFromXml(&reader, xmlFile); printXml(bsFromXml); + qXmlFile.close(); qDebug() << "Testing XML serialization 2: write XML from BundleSettings object..."; // for test coverage, read/write the copySettings object with @@ -300,10 +306,18 @@ int main(int argc, char *argv[]) { writer.writeEndDocument(); qXmlFile.close(); + if(!qXmlFile.open(QFile::ReadOnly | QFile::Text)){ + throw IException(IException::Unknown, + QString("Failed to parse xml file, [%1]").arg(qXmlFile.fileName()), + _FILEINFO_); + } + // read serialized xml into object and then write object to log file qDebug() << "Testing XML: Object deserialized as (should match object above):"; - BundleSettingsXmlHandlerTester bsFromXml2(project, &reader, xmlFile); + QXmlStreamReader reader2(&qXmlFile); + BundleSettingsXmlHandlerTester bsFromXml2(&reader2, xmlFile); printXml(bsFromXml2); + qXmlFile.close(); qXmlFile.remove(); diff --git a/isis/src/control/objs/BundleSolutionInfo/BundleSolutionInfo.cpp b/isis/src/control/objs/BundleSolutionInfo/BundleSolutionInfo.cpp index d4dd439892..29245fe798 100755 --- a/isis/src/control/objs/BundleSolutionInfo/BundleSolutionInfo.cpp +++ b/isis/src/control/objs/BundleSolutionInfo/BundleSolutionInfo.cpp @@ -16,6 +16,7 @@ find files of those names at the top level of this repository. **/ #include #include #include +#include #include "BundleLidarRangeConstraint.h" #include "BundleResults.h" @@ -33,7 +34,6 @@ find files of those names at the top level of this repository. **/ #include "PvlObject.h" #include "StatCumProbDistDynCalc.h" #include "Statistics.h" -#include "XmlStackedHandlerReader.h" namespace Isis { @@ -95,22 +95,25 @@ namespace Isis { /** - * Constructor. Creates a BundleSolutionInfo from disk. + * Handle an XML start element. This expects and elements. * - * @param project The current project - * @param xmlReader An XML reader that's up to an tag. - * @param parent The Qt-relationship parent + * @param namespaceURI ??? + * @param localName The keyword name given to the member variable in the XML. + * @param qName ??? + * @param atts The attribute containing the keyword value for the given local name. + * + * @return @b bool True if we should continue reading the XML. */ BundleSolutionInfo::BundleSolutionInfo(Project *project, - XmlStackedHandlerReader *xmlReader, - QObject *parent) : QObject(parent) { - //TODO does xml stuff need project??? + QXmlStreamReader *xmlReader, + QObject *parent) : QObject(parent) + { m_id = new QUuid(QUuid::createUuid()); m_runTime = ""; m_name = m_runTime; m_inputControlNetFileName = NULL; m_outputControl = NULL; - m_outputControlName=""; + m_outputControlName = ""; m_inputLidarDataFileName = NULL; m_outputLidarDataSet = NULL; m_statisticsResults = NULL; @@ -118,10 +121,69 @@ namespace Isis { m_images = new QList; m_adjustedImages = new QList; - xmlReader->setErrorHandler(new XmlHandler(this, project)); - xmlReader->pushContentHandler(new XmlHandler(this, project)); + m_xmlHandlerProject = project; + m_xmlHandlerCharacters = ""; + + readBundleSolutionInfo(xmlReader); } + void BundleSolutionInfo::readBundleSolutionInfo(QXmlStreamReader *xmlReader) { + QString projectRoot; + if (m_xmlHandlerProject) { + projectRoot = m_xmlHandlerProject->projectRoot() + "/"; + } + if (!m_adjustedImages){ + m_adjustedImages = new QList; + } + Q_ASSERT(xmlReader->name() == "bundleSolutionInfo"); + while(xmlReader->readNextStartElement()) { + 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; + BundleSettings *settings = new BundleSettings(); + settings->readBundleSettings(xmlReader); + m_settings = BundleSettingsQsp(settings); + } + else if (xmlReader->name() == "bundleResults") { + m_statisticsResults = NULL; + m_statisticsResults = new BundleResults(); + m_statisticsResults->readBundleResults(xmlReader); + } + else { + xmlReader->skipCurrentElement(); + } + } + } /** * Destructor @@ -1969,139 +2031,6 @@ namespace Isis { } - /** - * Create an XML Handler (reader) that can populate the BundleSolutionInfo class data. See - * BundleSolutionInfo::save() for the expected format. - * - * @param bundleSolutionInfo The bundle solution we're going to be initializing - * @param project The project we are working in - */ - BundleSolutionInfo::XmlHandler::XmlHandler(BundleSolutionInfo *bundleSolutionInfo, - Project *project) { - m_xmlHandlerBundleSolutionInfo = bundleSolutionInfo; - m_xmlHandlerProject = project; - m_xmlHandlerCharacters = ""; - } - - - /** - * Destructor - */ - BundleSolutionInfo::XmlHandler::~XmlHandler() { - } - - - /** - * Adds characters to m_xmlHandlerCharacters - * - * @param ch QString of characters to add - * - * @return @b bool Almost always true. Only false if the characters cannot be read - */ - bool BundleSolutionInfo::XmlHandler::characters(const QString &ch) { - m_xmlHandlerCharacters += ch; - return XmlStackedHandler::characters(ch); - } - - - /** - * Handle an XML start element. This expects and elements. - * - * @param namespaceURI ??? - * @param localName The keyword name given to the member variable in the XML. - * @param qName ??? - * @param atts The attribute containing the keyword value for the given local name. - * - * @return @b bool True if we should continue reading the XML. - */ - bool BundleSolutionInfo::XmlHandler::startElement(const QString &namespaceURI, - const QString &localName, - const QString &qName, - const QXmlAttributes &atts) { - m_xmlHandlerCharacters = ""; - - if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) { - - if (localName == "bundleSettings") { - m_xmlHandlerBundleSolutionInfo->m_settings = - BundleSettingsQsp(new BundleSettings(m_xmlHandlerProject, reader())); - } - else if (localName == "bundleResults") { - m_xmlHandlerBundleSolutionInfo->m_statisticsResults = new BundleResults(m_xmlHandlerProject, - reader()); - } - else if (localName == "imageList") { - m_xmlHandlerBundleSolutionInfo->m_adjustedImages->append( - new ImageList(m_xmlHandlerProject, reader())); - } - else if (localName == "outputControl") { - FileName outputControlPath = FileName(m_xmlHandlerProject->bundleSolutionInfoRoot() + "/" - + m_xmlHandlerBundleSolutionInfo->runTime()); - - m_xmlHandlerBundleSolutionInfo->m_outputControl = new Control(outputControlPath, reader()); - } - } - return true; - } - - - /** - * Handle an XML end element. - * - * @param namespaceURI ??? - * @param localName The keyword name given to the member variable in the XML. - * @param qName ??? - * - * @return @b bool Returns XmlStackedHandler's endElement() - */ - bool BundleSolutionInfo::XmlHandler::endElement(const QString &namespaceURI, - const QString &localName, - const QString &qName) { - // This is done for unitTest which has no Project - QString projectRoot; - if (m_xmlHandlerProject) { - projectRoot = m_xmlHandlerProject->projectRoot() + "/"; - } - - if (localName == "id") { - // all constructors assign a Uuid - we need to give it a one from the XML - assert(m_xmlHandlerBundleSolutionInfo->m_id); - delete m_xmlHandlerBundleSolutionInfo->m_id; - m_xmlHandlerBundleSolutionInfo->m_id = new QUuid(m_xmlHandlerCharacters); - } - else if (localName == "name") { - m_xmlHandlerBundleSolutionInfo->m_name = m_xmlHandlerCharacters; - } - else if (localName == "runTime") { - m_xmlHandlerBundleSolutionInfo->m_runTime = m_xmlHandlerCharacters; - } - else if (localName == "inputFileName") { - assert(m_xmlHandlerBundleSolutionInfo->m_inputControlNetFileName == NULL); - m_xmlHandlerBundleSolutionInfo->m_inputControlNetFileName = new FileName( - projectRoot + m_xmlHandlerCharacters); - } - else if (localName == "bundleOutTXT") { - m_xmlHandlerBundleSolutionInfo->m_txtBundleOutputFilename = - projectRoot + m_xmlHandlerCharacters; - } - else if (localName == "imagesCSV") { - m_xmlHandlerBundleSolutionInfo->m_csvSavedImagesFilename = - projectRoot + m_xmlHandlerCharacters; - } - else if (localName == "pointsCSV") { - m_xmlHandlerBundleSolutionInfo->m_csvSavedPointsFilename = - projectRoot + m_xmlHandlerCharacters; - } - else if (localName == "residualsCSV") { - m_xmlHandlerBundleSolutionInfo->m_csvSavedResidualsFilename = - projectRoot + m_xmlHandlerCharacters; - } - - m_xmlHandlerCharacters = ""; - return XmlStackedHandler::endElement(namespaceURI, localName, qName); - } - - /** * Determine the control point coordinate name. * @@ -2158,4 +2087,4 @@ namespace Isis { } return coordName; } -} +} \ No newline at end of file diff --git a/isis/src/control/objs/BundleSolutionInfo/BundleSolutionInfo.h b/isis/src/control/objs/BundleSolutionInfo/BundleSolutionInfo.h index b0c3895a30..d5ef9eafb5 100755 --- a/isis/src/control/objs/BundleSolutionInfo/BundleSolutionInfo.h +++ b/isis/src/control/objs/BundleSolutionInfo/BundleSolutionInfo.h @@ -18,11 +18,10 @@ find files of those names at the top level of this repository. **/ #include "LidarData.h" #include "SurfacePoint.h" -#include "XmlStackedHandler.h" - class QDataStream; class QUuid; class QXmlStreamWriter; +class QXmlStreamReader; namespace Isis { class BundleResults; @@ -31,7 +30,6 @@ namespace Isis { class ImageList; class Project; //TODO does xml stuff need project??? class PvlObject; - class XmlStackedHandlerReader; /** * @brief Container class for BundleAdjustment results. @@ -174,8 +172,9 @@ namespace Isis { QList imgList, QObject *parent = 0); BundleSolutionInfo(Project *project, - XmlStackedHandlerReader *xmlReader, - QObject *parent = 0); //TODO does xml stuff need project??? + QXmlStreamReader *xmlReader, + QObject *parent = 0); + void readBundleSolutionInfo(QXmlStreamReader *xmlReader); BundleSolutionInfo() = default; ~BundleSolutionInfo(); @@ -222,39 +221,6 @@ namespace Isis { public slots: void updateFileName(Project *); - private: - /** - * This class is used to read an images.xml file into an image list - * - * @see QXmlDefaultHandler documentation - * @author 2014-07-21 Ken Edmundson - * - * @internal - * @history 2016-06-13 Makayla Shepherd - Added updateFileName() and updated documentation. - * Fixes #2298. - */ - class XmlHandler : public XmlStackedHandler { - public: - //TODO does xml stuff need project??? - XmlHandler(BundleSolutionInfo *bundleSolutionInfo, Project *project); - ~XmlHandler(); - - virtual bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts); - virtual bool characters(const QString &ch); - virtual bool endElement(const QString &namespaceURI, const QString &localName, - const QString &qName); - QString surfacePointCoordName(SurfacePoint::CoordinateType type, - SurfacePoint::CoordIndex coordIdx) const; - - private: - Q_DISABLE_COPY(XmlHandler); - - BundleSolutionInfo *m_xmlHandlerBundleSolutionInfo; //!< The bundleSolutionInfo object - Project *m_xmlHandlerProject; //TODO does xml stuff need project??? - QString m_xmlHandlerCharacters; //!< List of characters that have been handled - }; - private: //! A unique ID for this BundleSolutionInfo object (useful for others to reference this @@ -279,6 +245,10 @@ namespace Isis { QString m_csvSavedPointsFilename; QString m_csvSavedResidualsFilename; + // BundleSolutionInfo *m_xmlHandlerBundleSolutionInfo; //!< The bundleSolutionInfo object + Project *m_xmlHandlerProject; // TODO does xml stuff need project??? + QString m_xmlHandlerCharacters; //!< List of characters that have been handled + }; // end BundleSolutionInfo class void setStringAttribute(int locationId, QString locationName, @@ -288,4 +258,4 @@ namespace Isis { Q_DECLARE_METATYPE(Isis::BundleSolutionInfo *); -#endif // BundleSolutionInfo_h +#endif // BundleSolutionInfo_h \ No newline at end of file diff --git a/isis/src/control/objs/BundleUtilities/BundleObservationSolveSettings.cpp b/isis/src/control/objs/BundleUtilities/BundleObservationSolveSettings.cpp index 63dc77cc50..9e7cd768ce 100644 --- a/isis/src/control/objs/BundleUtilities/BundleObservationSolveSettings.cpp +++ b/isis/src/control/objs/BundleUtilities/BundleObservationSolveSettings.cpp @@ -26,7 +26,6 @@ find files of those names at the top level of this repository. **/ #include "Project.h" #include "PvlKeyword.h" #include "PvlObject.h" -#include "XmlStackedHandlerReader.h" namespace Isis { @@ -46,12 +45,9 @@ namespace Isis { * /work/.../projectRoot/images/import1 * @param xmlReader An XML reader that's up to an tag. */ - BundleObservationSolveSettings::BundleObservationSolveSettings( - Project *project, - XmlStackedHandlerReader *xmlReader) { + BundleObservationSolveSettings::BundleObservationSolveSettings(QXmlStreamReader *xmlReader) { initialize(); - xmlReader->pushContentHandler(new XmlHandler(this, project)); - xmlReader->setErrorHandler(new XmlHandler(this, project)); + readSolveSettings(xmlReader); } @@ -1267,207 +1263,134 @@ namespace Isis { } - - /** - * Constructs an XmlHandler for serialization. - * - * @param settings Pointer to the BundleObservationSolveSettings to handle - * @param project Pointer to the current project - * - * @internal - * @todo Does xml stuff need project??? - */ - BundleObservationSolveSettings::XmlHandler::XmlHandler(BundleObservationSolveSettings *settings, - Project *project) { - m_xmlHandlerObservationSettings = settings; - m_xmlHandlerProject = project; // TODO: does xml stuff need project??? - m_xmlHandlerCharacters = ""; - } - - - /** - * XmlHandler destructor. - */ - BundleObservationSolveSettings::XmlHandler::~XmlHandler() { - // do not delete this pointer... we don't own it, do we??? - // passed into StatCumProbDistDynCalc constructor as pointer - // delete m_xmlHandlerProject; // TODO: does xml stuff need project??? - m_xmlHandlerProject = NULL; - } - - - /** - * @param namespaceURI - * @param localName - * @param qName - * @param atts - * - * @return @b bool - * - * @internal - * @todo Document if we decide to use Xml handlers for serialization - */ - bool BundleObservationSolveSettings::XmlHandler::startElement(const QString &namespaceURI, - const QString &localName, - const QString &qName, - const QXmlAttributes &atts) { - m_xmlHandlerCharacters = ""; - if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) { - if (localName == "instrumentPointingOptions") { - - QString pointingSolveOption = atts.value("solveOption"); - if (!pointingSolveOption.isEmpty()) { - m_xmlHandlerObservationSettings->m_instrumentPointingSolveOption - = stringToInstrumentPointingSolveOption(pointingSolveOption); + void BundleObservationSolveSettings::readSolveSettings(QXmlStreamReader *xmlReader) { + initialize(); + Q_ASSERT(xmlReader->name() == "bundleObservationSolveSettings"); + while (xmlReader->readNextStartElement()) { + if (xmlReader->qualifiedName() == "instrumentId") { + QString instrumentId = xmlReader->readElementText(); + if (!instrumentId.isEmpty()){ + setInstrumentId(instrumentId); } - - QString numberCoefSolved = atts.value("numberCoefSolved"); + } + else if (xmlReader->qualifiedName() == "instrumentPointingOptions") { + QStringRef solveOption = xmlReader->attributes().value("solveOption"); + if (!solveOption.isEmpty()) { + m_instrumentPointingSolveOption = stringToInstrumentPointingSolveOption(solveOption.toString()); + } + QStringRef numberCoefSolved = xmlReader->attributes().value("numberCoefSolved"); if (!numberCoefSolved.isEmpty()) { - m_xmlHandlerObservationSettings->m_numberCamAngleCoefSolved = toInt(numberCoefSolved); + m_numberCamAngleCoefSolved = numberCoefSolved.toInt(); } - - QString ckDegree = atts.value("degree"); - if (!ckDegree.isEmpty()) { - m_xmlHandlerObservationSettings->m_ckDegree = toInt(ckDegree); + QStringRef degree = xmlReader->attributes().value("degree"); + if (!degree.isEmpty()) { + m_ckDegree = degree.toInt(); } - - QString ckSolveDegree = atts.value("solveDegree"); - if (!ckSolveDegree.isEmpty()) { - m_xmlHandlerObservationSettings->m_ckSolveDegree = toInt(ckSolveDegree); + QStringRef solveDegree = xmlReader->attributes().value("solveDegree"); + if (!solveDegree.isEmpty()) { + m_ckSolveDegree = solveDegree.toInt(); } - - QString solveTwist = atts.value("solveTwist"); + QStringRef solveTwist = xmlReader->attributes().value("solveTwist"); if (!solveTwist.isEmpty()) { - m_xmlHandlerObservationSettings->m_solveTwist = toBool(solveTwist); + m_solveTwist = toBool(solveTwist.toString()); } - - QString solveOverExisting = atts.value("solveOverExisting"); + QStringRef solveOverExisting = xmlReader->attributes().value("solveOverExisting"); if (!solveOverExisting.isEmpty()) { - m_xmlHandlerObservationSettings->m_solvePointingPolynomialOverExisting = - toBool(solveOverExisting); + m_solvePointingPolynomialOverExisting = toBool(solveOverExisting.toString()); } - - QString interpolationType = atts.value("interpolationType"); + QStringRef interpolationType = xmlReader->attributes().value("interpolationType"); if (!interpolationType.isEmpty()) { - m_xmlHandlerObservationSettings->m_pointingInterpolationType = - SpiceRotation::Source(toInt(interpolationType)); + if (interpolationType == "3") { + m_pointingInterpolationType = SpiceRotation::PolyFunction; + } + else if (interpolationType == "4") { + m_pointingInterpolationType = SpiceRotation::PolyFunctionOverSpice; + } + } + while (xmlReader->readNextStartElement()) { + if (xmlReader->qualifiedName() == "aprioriPointingSigmas") { + m_anglesAprioriSigma.clear(); + while (xmlReader->readNextStartElement()) { + if (xmlReader->qualifiedName() == "sigma") { + QString sigma = xmlReader->readElementText(); + if (!sigma.isEmpty()){ + if (sigma == "N/A") { + m_anglesAprioriSigma.append(Isis::Null); + } + else { + m_anglesAprioriSigma.append(sigma.toDouble()); + } + } + } + else { + xmlReader->skipCurrentElement(); + } + } + } + else { + xmlReader->skipCurrentElement(); + } } - - } - else if (localName == "aprioriPointingSigmas") { - m_xmlHandlerAprioriSigmas.clear(); } - else if (localName == "instrumentPositionOptions") { - - QString positionSolveOption = atts.value("solveOption"); - if (!positionSolveOption.isEmpty()) { - m_xmlHandlerObservationSettings->m_instrumentPositionSolveOption - = stringToInstrumentPositionSolveOption(positionSolveOption); + else if (xmlReader->qualifiedName() == "instrumentPositionOptions") { + QStringRef solveOption = xmlReader->attributes().value("solveOption"); + if (!solveOption.isEmpty()) { + m_instrumentPositionSolveOption = stringToInstrumentPositionSolveOption(solveOption.toString()); } - - QString numberCoefSolved = atts.value("numberCoefSolved"); + QStringRef numberCoefSolved = xmlReader->attributes().value("numberCoefSolved"); if (!numberCoefSolved.isEmpty()) { - m_xmlHandlerObservationSettings->m_numberCamPosCoefSolved = toInt(numberCoefSolved); + m_numberCamPosCoefSolved = numberCoefSolved.toInt(); } - - QString spkDegree = atts.value("degree"); - if (!spkDegree.isEmpty()) { - m_xmlHandlerObservationSettings->m_spkDegree = toInt(spkDegree); + QStringRef degree = xmlReader->attributes().value("degree"); + if (!degree.isEmpty()) { + m_spkDegree = degree.toInt(); } - - QString spkSolveDegree = atts.value("solveDegree"); - if (!spkSolveDegree.isEmpty()) { - m_xmlHandlerObservationSettings->m_spkSolveDegree = toInt(spkSolveDegree); + QStringRef solveDegree = xmlReader->attributes().value("solveDegree"); + if (!solveDegree.isEmpty()) { + m_spkSolveDegree = solveDegree.toInt(); } - - QString solveOverHermiteSpline = atts.value("solveOverHermiteSpline"); + QStringRef solveOverHermiteSpline = xmlReader->attributes().value("solveOverHermiteSpline"); if (!solveOverHermiteSpline.isEmpty()) { - m_xmlHandlerObservationSettings->m_solvePositionOverHermiteSpline = - toBool(solveOverHermiteSpline); + m_solvePositionOverHermiteSpline = toBool(solveOverHermiteSpline.toString()); } - - QString interpolationType = atts.value("interpolationType"); + QStringRef interpolationType = xmlReader->attributes().value("interpolationType"); if (!interpolationType.isEmpty()) { - m_xmlHandlerObservationSettings->m_positionInterpolationType = - SpicePosition::Source(toInt(interpolationType)); - } - } - else if (localName == "aprioriPositionSigmas") { - m_xmlHandlerAprioriSigmas.clear(); - } - } - return true; - } - - - /** - * @param ch - * - * @return @b bool - * - * @internal - * @todo Document if we use Xml handlers for serialization. - */ - bool BundleObservationSolveSettings::XmlHandler::characters(const QString &ch) { - m_xmlHandlerCharacters += ch; - return XmlStackedHandler::characters(ch); - } - - - /** - * @param namespaceURI - * @param localName - * @param qName - * - * @return @b bool - * - * @internal - * @todo Document if we use Xml handlers for serialization. - */ - bool BundleObservationSolveSettings::XmlHandler::endElement(const QString &namespaceURI, - const QString &localName, - const QString &qName) { - if (!m_xmlHandlerCharacters.isEmpty()) { - if (localName == "id") { - m_xmlHandlerObservationSettings->m_id = NULL; - m_xmlHandlerObservationSettings->m_id = new QUuid(m_xmlHandlerCharacters); - } - else if (localName == "instrumentId") { - m_xmlHandlerObservationSettings->setInstrumentId(m_xmlHandlerCharacters); - } -// else if (localName == "bundleObservationSolveSettings") { -// // end tag for this entire class... how to get out??? -// // call parse, as in Control List??? -// } - else if (localName == "sigma") { - m_xmlHandlerAprioriSigmas.append(m_xmlHandlerCharacters); - } - else if (localName == "aprioriPointingSigmas") { - m_xmlHandlerObservationSettings->m_anglesAprioriSigma.clear(); - for (int i = 0; i < m_xmlHandlerAprioriSigmas.size(); i++) { - if (m_xmlHandlerAprioriSigmas[i] == "N/A") { - m_xmlHandlerObservationSettings->m_anglesAprioriSigma.append(Isis::Null); + if (interpolationType == "3") { + m_positionInterpolationType = SpicePosition::PolyFunction; } - else { - m_xmlHandlerObservationSettings->m_anglesAprioriSigma.append( - toDouble(m_xmlHandlerAprioriSigmas[i])); + else if (interpolationType == "4") { + m_positionInterpolationType = SpicePosition::PolyFunctionOverHermiteConstant; } } - } - else if (localName == "aprioriPositionSigmas") { - m_xmlHandlerObservationSettings->m_positionAprioriSigma.clear(); - for (int i = 0; i < m_xmlHandlerAprioriSigmas.size(); i++) { - if (m_xmlHandlerAprioriSigmas[i] == "N/A") { - m_xmlHandlerObservationSettings->m_positionAprioriSigma.append(Isis::Null); + while (xmlReader->readNextStartElement()) { + if (xmlReader->qualifiedName() == "aprioriPositionSigmas") { + m_positionAprioriSigma.clear(); + while (xmlReader->readNextStartElement()) { + if (xmlReader->qualifiedName() == "sigma") { + QString sigma = xmlReader->readElementText(); + if (!sigma.isEmpty()){ + if (sigma == "N/A") { + m_positionAprioriSigma.append(Isis::Null); + + } + else { + m_positionAprioriSigma.append(sigma.toDouble()); + } + } + } + else { + xmlReader->skipCurrentElement(); + } + } } else { - m_xmlHandlerObservationSettings->m_positionAprioriSigma.append( - toDouble(m_xmlHandlerAprioriSigmas[i])); + xmlReader->skipCurrentElement(); } } } - m_xmlHandlerCharacters = ""; + else { + xmlReader->skipCurrentElement(); + } } - return XmlStackedHandler::endElement(namespaceURI, localName, qName); } } diff --git a/isis/src/control/objs/BundleUtilities/BundleObservationSolveSettings.h b/isis/src/control/objs/BundleUtilities/BundleObservationSolveSettings.h index 3cddd1489a..a337f777cb 100644 --- a/isis/src/control/objs/BundleUtilities/BundleObservationSolveSettings.h +++ b/isis/src/control/objs/BundleUtilities/BundleObservationSolveSettings.h @@ -13,12 +13,12 @@ find files of those names at the top level of this repository. **/ #include #include #include +#include #include #include "SpicePosition.h" #include "SpiceRotation.h" -#include "XmlStackedHandler.h" class QDataStream; class QUuid; @@ -28,7 +28,6 @@ namespace Isis { class FileName; class Project; // TODO: does xml stuff need project??? class PvlObject; - class XmlStackedHandlerReader; /** * This class is used to modify and manage solve settings for 1 to many BundleObservations. These * settings indicate how any associated observations should be solved. @@ -83,11 +82,9 @@ class BundleObservationSolveSettings { public: BundleObservationSolveSettings(); - BundleObservationSolveSettings(Project *project, - XmlStackedHandlerReader *xmlReader); // TODO: does xml stuff need project??? + BundleObservationSolveSettings(QXmlStreamReader *xmlReader); BundleObservationSolveSettings(FileName xmlFile, - Project *project, - XmlStackedHandlerReader *xmlReader); // TODO: does xml stuff need project??? + QXmlStreamReader *xmlReader); BundleObservationSolveSettings(const BundleObservationSolveSettings &src); BundleObservationSolveSettings(const PvlGroup &scParameterGroup); ~BundleObservationSolveSettings(); @@ -185,38 +182,8 @@ class BundleObservationSolveSettings { QList aprioriPositionSigmas() const; SpicePosition::Source positionInterpolationType() const; - // TODO: does xml stuff need project??? void save(QXmlStreamWriter &stream, const Project *project) const; - - - private: - /** - * - * @author 2014-07-28 Jeannie Backer - * - * @internal - * @todo To be docuemnted if XML handler code is used for serialization. - */ - class XmlHandler : public XmlStackedHandler { - public: - // TODO: does xml stuff need project??? - XmlHandler(BundleObservationSolveSettings *settings, Project *project); - ~XmlHandler(); - - virtual bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts); - virtual bool characters(const QString &ch); - virtual bool endElement(const QString &namespaceURI, const QString &localName, - const QString &qName); - - private: - Q_DISABLE_COPY(XmlHandler); - - BundleObservationSolveSettings *m_xmlHandlerObservationSettings; - Project *m_xmlHandlerProject; // TODO: does xml stuff need project??? - QString m_xmlHandlerCharacters; - QStringList m_xmlHandlerAprioriSigmas; - }; + void readSolveSettings(QXmlStreamReader *xmlReader); /** * A unique ID for this object (useful for others to reference this object diff --git a/isis/src/control/objs/BundleUtilities/BundleUtilities.truth b/isis/src/control/objs/BundleUtilities/BundleUtilities.truth index 082692d99d..46408b753a 100644 --- a/isis/src/control/objs/BundleUtilities/BundleUtilities.truth +++ b/isis/src/control/objs/BundleUtilities/BundleUtilities.truth @@ -197,9 +197,7 @@ Testing XML: read XML to BundleObservationSolveSettings object... - - N/A - + @@ -295,9 +293,7 @@ Testing XML: read XML with no attributes or values to object... - - N/A - + @@ -488,9 +484,7 @@ TWI (dd) 0.00000000 0.00000000 0.00000000 - - N/A - + @@ -505,18 +499,18 @@ parameter list: ("X", "Y", "Z", "RA", "DEC", "TWIST") image names: () parameter weights : 0.0 0.0 0.0 parameter corrections : 0.0 0.0 0.0 -apriori sigmas : -1.79769313486231e+308 -1.79769313486231e+308 -1.79769313486231e+308 +apriori sigmas : 0.0 0.0 0.0 adjusted sigmas : 0.0 0.0 0.0 output bundle observation... -0.0,0.0,0.0,N/A,N/A,0.0,0.0,0.0,N/A,N/A,0.0,0.0,0.0,N/A,N/A,0.0,0.0,0.0,FREE,N/A,0.0,0.0,0.0,FREE,N/A,0.0,0.0,0.0,FREE,N/A, +0.0,0.0,0.0,N/A,N/A,0.0,0.0,0.0,N/A,N/A,0.0,0.0,0.0,N/A,N/A,0.0,0.0,0.0,0.0,N/A,0.0,0.0,0.0,0.0,N/A,0.0,0.0,0.0,0.0,N/A, X (km) 0.00000000 0.00000000 0.00000000 N/A N/A m Y (km) 0.00000000 0.00000000 0.00000000 N/A N/A m Z (km) 0.00000000 0.00000000 0.00000000 N/A N/A m - RA (dd) 0.00000000 0.00000000 0.00000000 FREE N/A dd -DEC (dd) 0.00000000 0.00000000 0.00000000 FREE N/A dd -TWI (dd) 0.00000000 0.00000000 0.00000000 FREE N/A dd + RA (dd) 0.00000000 0.00000000 0.00000000 0.0 N/A dd +DEC (dd) 0.00000000 0.00000000 0.00000000 0.0 N/A dd +TWI (dd) 0.00000000 0.00000000 0.00000000 0.0 N/A dd -0.0,0.0,0.0,N/A,N/A,0.0,0.0,0.0,N/A,N/A,0.0,0.0,0.0,N/A,N/A,0.0,0.0,0.0,FREE,0.00000000,0.0,0.0,0.0,FREE,0.00000000,0.0,0.0,0.0,FREE,0.00000000, +0.0,0.0,0.0,N/A,N/A,0.0,0.0,0.0,N/A,N/A,0.0,0.0,0.0,N/A,N/A,0.0,0.0,0.0,0.0,0.00000000,0.0,0.0,0.0,0.0,0.00000000,0.0,0.0,0.0,0.0,0.00000000, init exterior orientiation successful? "Yes" apply param corrections successful? **ERROR** Unable to apply parameter corrections to IsisBundleObservation. diff --git a/isis/src/control/objs/BundleUtilities/unitTest.cpp b/isis/src/control/objs/BundleUtilities/unitTest.cpp index f19cf97e86..a37cbab14c 100755 --- a/isis/src/control/objs/BundleUtilities/unitTest.cpp +++ b/isis/src/control/objs/BundleUtilities/unitTest.cpp @@ -31,7 +31,6 @@ find files of those names at the top level of this repository. **/ #include "Spice.h" #include "SurfacePoint.h" #include "Target.h" -#include "XmlStackedHandlerReader.h" #include #include @@ -82,8 +81,8 @@ void printXml(const BundleObservationSolveSettings &); namespace Isis { class XmlHandlerTester : public BundleObservationSolveSettings { public: - XmlHandlerTester(Project *project, XmlStackedHandlerReader *reader, FileName xmlFile) - : BundleObservationSolveSettings(project, reader) { + XmlHandlerTester(QXmlStreamReader *reader, FileName xmlFile) + : BundleObservationSolveSettings() { QString xmlPath(xmlFile.expanded()); QFile file(xmlPath); @@ -94,12 +93,13 @@ namespace Isis { _FILEINFO_); } - QXmlInputSource xmlInputSource(&file); - bool success = reader->parse(xmlInputSource); - if (!success) { - throw IException(IException::Unknown, - QString("Failed to parse xml file, [%1]").arg(xmlPath), - _FILEINFO_); + if (reader->readNextStartElement()) { + if (reader->name() == "bundleObservationSolveSettings") { + readSolveSettings(reader); + } + else { + reader->raiseError(QObject::tr("Incorrect file")); + } } } @@ -267,9 +267,15 @@ int main(int argc, char *argv[]) { qXmlFile.close(); // read xml qDebug() << "Testing XML: read XML to BundleObservationSolveSettings object..."; - XmlStackedHandlerReader reader; - XmlHandlerTester bsFromXml1(project, &reader, xmlFile); + if(!qXmlFile.open(QFile::ReadOnly | QFile::Text)){ + throw IException(IException::Unknown, + QString("Failed to parse xml file, [%1]").arg(qXmlFile.fileName()), + _FILEINFO_); + } + QXmlStreamReader reader2(&qXmlFile); + XmlHandlerTester bsFromXml1(&reader2, xmlFile); printXml(bsFromXml1); + qXmlFile.close(); if (!qXmlFile.open(QIODevice::WriteOnly|QIODevice::Text)) { throw IException(IException::Io, @@ -282,9 +288,16 @@ int main(int argc, char *argv[]) { writer.writeEndDocument(); qXmlFile.close(); // read xml + if(!qXmlFile.open(QFile::ReadOnly | QFile::Text)){ + throw IException(IException::Unknown, + QString("Failed to parse xml file, [%1]").arg(qXmlFile.fileName()), + _FILEINFO_); + } + QXmlStreamReader reader3(&qXmlFile); qDebug() << "Testing XML: read XML to BundleObservationSolveSettings object..."; - XmlHandlerTester bsFromXml2(project, &reader, xmlFile); + XmlHandlerTester bsFromXml2(&reader3, xmlFile); printXml(bsFromXml2); + qXmlFile.close(); if (!qXmlFile.open(QIODevice::WriteOnly|QIODevice::Text)) { throw IException(IException::Io, @@ -298,8 +311,15 @@ int main(int argc, char *argv[]) { qXmlFile.close(); // read xml qDebug() << "Testing XML: read XML to BundleObservationSolveSettings object..."; - XmlHandlerTester bsFromXml3(project, &reader, xmlFile); + if(!qXmlFile.open(QFile::ReadOnly | QFile::Text)){ + throw IException(IException::Unknown, + QString("Failed to parse xml file, [%1]").arg(qXmlFile.fileName()), + _FILEINFO_); + } + QXmlStreamReader reader4(&qXmlFile); + XmlHandlerTester bsFromXml3(&reader4, xmlFile); printXml(bsFromXml3); + qXmlFile.close(); if (!qXmlFile.open(QIODevice::WriteOnly|QIODevice::Text)) { throw IException(IException::Io, @@ -313,8 +333,15 @@ int main(int argc, char *argv[]) { qXmlFile.close(); // read xml qDebug() << "Testing XML: read XML to BundleObservationSolveSettings object..."; - XmlHandlerTester bsFromXml4(project, &reader, xmlFile); + if(!qXmlFile.open(QFile::ReadOnly | QFile::Text)){ + throw IException(IException::Unknown, + QString("Failed to parse xml file, [%1]").arg(qXmlFile.fileName()), + _FILEINFO_); + } + QXmlStreamReader reader5(&qXmlFile); + XmlHandlerTester bsFromXml4(&reader5, xmlFile); printXml(bsFromXml4); + qXmlFile.close(); if (!qXmlFile.open(QIODevice::WriteOnly|QIODevice::Text)) { throw IException(IException::Io, @@ -328,15 +355,30 @@ int main(int argc, char *argv[]) { qXmlFile.close(); // read xml qDebug() << "Testing XML: read XML to BundleObservationSolveSettings object..."; - XmlHandlerTester bossToFill(project, &reader, xmlFile); -// BundleObservationSolveSettings bossToFill(xmlFile, project, &reader); + if(!qXmlFile.open(QFile::ReadOnly | QFile::Text)){ + throw IException(IException::Unknown, + QString("Failed to parse xml file, [%1]").arg(qXmlFile.fileName()), + _FILEINFO_); + } + QXmlStreamReader reader6(&qXmlFile); + XmlHandlerTester bossToFill(&reader6, xmlFile); printXml(bossToFill); + qXmlFile.close(); // read xml with no attributes or values qDebug() << "Testing XML: read XML with no attributes or values to object..."; FileName emptyXmlFile("./unitTest_NoElementValues.xml"); - XmlHandlerTester bsFromEmptyXml(project, &reader, emptyXmlFile); + QFile xml(emptyXmlFile.expanded()); + if(!xml.open(QFile::ReadOnly | QFile::Text)){ + throw IException(IException::Unknown, + QString("Failed to parse xml file, [%1]").arg(xml.fileName()), + _FILEINFO_); + } + + QXmlStreamReader reader7(&xml); + XmlHandlerTester bsFromEmptyXml(&reader7, emptyXmlFile); printXml(bsFromEmptyXml); + xml.close(); qXmlFile.remove(); diff --git a/isis/src/qisis/objs/CnetEditorView/CnetEditorView.cpp b/isis/src/qisis/objs/CnetEditorView/CnetEditorView.cpp index 118fb16b2c..2807f81fee 100644 --- a/isis/src/qisis/objs/CnetEditorView/CnetEditorView.cpp +++ b/isis/src/qisis/objs/CnetEditorView/CnetEditorView.cpp @@ -28,7 +28,6 @@ find files of those names at the top level of this repository. **/ #include "Directory.h" #include "FileName.h" #include "Project.h" -#include "XmlStackedHandlerReader.h" #include "ProjectItemViewMenu.h" namespace Isis { @@ -173,16 +172,6 @@ namespace Isis { } - /** - * This method pushes a new XmlHandler into the parser stack. - * - * @param xmlReader This is the parser stack. - */ - void CnetEditorView::load(XmlStackedHandlerReader *xmlReader) { - xmlReader->pushContentHandler(new XmlHandler(this)); - } - - /** * This method saves the Controls object ids to the stream. * @@ -197,60 +186,4 @@ namespace Isis { stream.writeAttribute("id", m_control->id()); stream.writeEndElement(); } - - - /** - * Creates an XmlHandler for cnetEditor - * - * @param cnetEditor The widget to be serialized - */ - CnetEditorView::XmlHandler::XmlHandler(CnetEditorView *cnetEditorView) { - m_cnetEditorView = cnetEditorView; - } - - - /** - * Destructor - */ - CnetEditorView::XmlHandler::~XmlHandler() { - delete m_cnetEditorView; - m_cnetEditorView = NULL; - } - - - /** - * Placeholder for later serialization of CnetEditorViews - * - * @param cnetEditor The CnetEditorView to be serialized - * @param namespaceURI ??? - * @param localName Determines what attributes to retrieve from atts. - * @param qName ??? - * @param atts Stores the attributes. - * - * @return @b bool The result of XmlStackedHandler's startElement() method. - */ - bool CnetEditorView::XmlHandler::startElement(const QString &namespaceURI, - const QString &localName, const QString &qName, const QXmlAttributes &atts) { - - bool result = XmlStackedHandler::startElement(namespaceURI, localName, qName, atts); - return result; - } - - - /** - * This method calls XmlStackedHandler's endElement() and dereferences pointers according to - * the value of localName. - * - * @param namespaceURI ??? - * @param localName Determines which pointers to dereference. - * @param qName ??? - * - * @return @b bool The result of XmlStackedHandler's endElement() method. - */ - bool CnetEditorView::XmlHandler::endElement(const QString &namespaceURI, - const QString &localName, const QString &qName) { - - bool result = XmlStackedHandler::endElement(namespaceURI, localName, qName); - return result; - } } diff --git a/isis/src/qisis/objs/CnetEditorView/CnetEditorView.h b/isis/src/qisis/objs/CnetEditorView/CnetEditorView.h index 73a67a98d9..8ef4c87fc8 100644 --- a/isis/src/qisis/objs/CnetEditorView/CnetEditorView.h +++ b/isis/src/qisis/objs/CnetEditorView/CnetEditorView.h @@ -16,7 +16,6 @@ find files of those names at the top level of this repository. **/ #include "AbstractProjectItemView.h" #include "FileName.h" -#include "XmlStackedHandler.h" class QAction; class QToolBar; @@ -30,7 +29,6 @@ namespace Isis { class FileName; class Project; class ToolPad; - class XmlStackedHandlerReader; class ProjectItemViewMenu; /** @@ -74,7 +72,6 @@ class CnetEditorView : public AbstractProjectItemView { CnetEditorWidget *cnetEditorWidget(); Control *control(); - void load(XmlStackedHandlerReader *xmlReader); void save(QXmlStreamWriter &stream, Project *project, FileName newProjectRoot) const; private: @@ -82,29 +79,6 @@ class CnetEditorView : public AbstractProjectItemView { void createMenus(); void leaveEvent(QEvent *event); - - /** - * @author 2012-09-?? Steven Lambright - * - * @internal - * @history 2018-04-04 Tracie Sucharski - Implemented for CnetEditorView - */ - class XmlHandler : public XmlStackedHandler { - public: - XmlHandler(CnetEditorView *cnetEditorView); - ~XmlHandler(); - - virtual bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts); - virtual bool endElement(const QString &namespaceURI, const QString &localName, - const QString &qName); - - private: - Q_DISABLE_COPY(XmlHandler); - - CnetEditorView *m_cnetEditorView; //!< The view we are working with - }; - private: QPointer m_cnetEditorWidget; QPointer m_control; diff --git a/isis/src/qisis/objs/CnetEditorWidget/CnetEditorWidget.cpp b/isis/src/qisis/objs/CnetEditorWidget/CnetEditorWidget.cpp index 789c12c297..8dd76cbea6 100644 --- a/isis/src/qisis/objs/CnetEditorWidget/CnetEditorWidget.cpp +++ b/isis/src/qisis/objs/CnetEditorWidget/CnetEditorWidget.cpp @@ -56,8 +56,6 @@ find files of those names at the top level of this repository. **/ #include "TableView.h" #include "TableViewHeader.h" #include "TreeView.h" -#include "XmlStackedHandler.h" -#include "XmlStackedHandlerReader.h" namespace Isis { diff --git a/isis/src/qisis/objs/CnetEditorWidget/CnetEditorWidget.h b/isis/src/qisis/objs/CnetEditorWidget/CnetEditorWidget.h index d49028e9d7..58a25a5f1a 100644 --- a/isis/src/qisis/objs/CnetEditorWidget/CnetEditorWidget.h +++ b/isis/src/qisis/objs/CnetEditorWidget/CnetEditorWidget.h @@ -12,7 +12,6 @@ find files of those names at the top level of this repository. **/ #include -#include "XmlStackedHandler.h" class QAction; class QBoxLayout; diff --git a/isis/src/qisis/objs/Control/Control.cpp b/isis/src/qisis/objs/Control/Control.cpp index 9380f0ea3e..7bedf8b51b 100644 --- a/isis/src/qisis/objs/Control/Control.cpp +++ b/isis/src/qisis/objs/Control/Control.cpp @@ -23,7 +23,6 @@ find files of those names at the top level of this repository. **/ #include "IString.h" #include "Project.h" #include "PvlObject.h" -#include "XmlStackedHandlerReader.h" namespace Isis { /** @@ -101,25 +100,6 @@ namespace Isis { } - /** - * Construct this control from XML. - * - * @param cnetFolder Location of control xml - * @param xmlReader An XML reader that's up to an tag. - * @param parent The Qt-relationship parent - */ - Control::Control(FileName cnetFolder, XmlStackedHandlerReader *xmlReader, QObject *parent) : - QObject(parent) { - m_controlNet = NULL; - m_displayProperties = NULL; - m_id = NULL; - m_project = NULL; - m_modified = false; - - xmlReader->pushContentHandler(new XmlHandler(this, cnetFolder)); - } - - /** * Destroys Control object. */ @@ -381,56 +361,4 @@ namespace Isis { stream.writeEndElement(); } - - - /** - * Constructor for the Control object's XmlHandler - * - * @param control A pointer to the Control object. - * @param cnetFolder The name of the folder for the Control xml - * - */ - Control::XmlHandler::XmlHandler(Control *control, FileName cnetFolder) { - m_xmlHandlerControl = control; - m_xmlHandlerCnetFolderName = cnetFolder; - } - - - /** - * Method to read the given XML formatted attribute for a Control object - * into the XmlHandler. - * - * @param namespaceURI ??? - * @param localName The keyword name given to the member variable in the XML. - * @param qName ??? - * @param atts The attribute containing the keyword value for the given - * localName. - * - * @return @b bool Indicates whether the localName is recognized. - */ - bool Control::XmlHandler::startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts) { - if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) { - if (localName == "controlNet") { - QString id = atts.value("id"); - QString path = atts.value("path"); - QString fileName = atts.value("fileName"); - - if (!id.isEmpty()) { - delete m_xmlHandlerControl->m_id; - m_xmlHandlerControl->m_id = NULL; - m_xmlHandlerControl->m_id = new QUuid(id.toLatin1()); - } - - if (!fileName.isEmpty()) { - m_xmlHandlerControl->m_fileName = m_xmlHandlerCnetFolderName.expanded() + "/" + fileName; - } - } - else if (localName == "displayProperties") { - m_xmlHandlerControl->m_displayProperties = new ControlDisplayProperties(reader()); - } - } - - return true; - } } diff --git a/isis/src/qisis/objs/Control/Control.h b/isis/src/qisis/objs/Control/Control.h index 92242f6875..d54a38f233 100644 --- a/isis/src/qisis/objs/Control/Control.h +++ b/isis/src/qisis/objs/Control/Control.h @@ -13,7 +13,6 @@ find files of those names at the top level of this repository. **/ #include #include "FileName.h" -#include "XmlStackedHandler.h" class QMutex; class QUuid; @@ -71,7 +70,6 @@ namespace Isis { explicit Control(QString cnetFileName, QObject *parent = 0); explicit Control(Project *project, QString cnetFileName, QObject *parent = 0); explicit Control(ControlNet *controlNet, QString cnetFileName, QObject *parent = 0); - Control(FileName cnetFolder, XmlStackedHandlerReader *xmlReader, QObject *parent = 0); ~Control(); ControlNet *controlNet(); @@ -94,30 +92,6 @@ namespace Isis { void updateFileName(Project *); void closeControlNet(); - private: - /** - * Nested class used to write the Control object information to an XML file for the - * purpose of saving and restoring the state of the project. - * - * @author 2012-??-?? Steven Lambright - * - * @internal - */ - class XmlHandler : public XmlStackedHandler { - public: - XmlHandler(Control *control, FileName cnetFolder); - - virtual bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts); - - private: - Q_DISABLE_COPY(XmlHandler); - - Control *m_xmlHandlerControl; /**< A pointer to the Control object to be read or - written.*/ - FileName m_xmlHandlerCnetFolderName; /**< The name of the folder for the control xml.*/ - }; - private: Control(const Control &other); Control &operator=(const Control &rhs); diff --git a/isis/src/qisis/objs/ControlDisplayProperties/ControlDisplayProperties.cpp b/isis/src/qisis/objs/ControlDisplayProperties/ControlDisplayProperties.cpp index a1eafa8bef..a1e5d12e7a 100644 --- a/isis/src/qisis/objs/ControlDisplayProperties/ControlDisplayProperties.cpp +++ b/isis/src/qisis/objs/ControlDisplayProperties/ControlDisplayProperties.cpp @@ -20,7 +20,6 @@ find files of those names at the top level of this repository. **/ #include "FileName.h" #include "Pvl.h" -#include "XmlStackedHandlerReader.h" namespace Isis { /** @@ -46,15 +45,6 @@ namespace Isis { } - ControlDisplayProperties::ControlDisplayProperties(XmlStackedHandlerReader *xmlReader, - QObject *parent) : DisplayProperties("", parent) { - m_propertiesUsed = None; - m_propertyValues = new QMap; - - xmlReader->pushContentHandler(new XmlHandler(this)); - } - - /** * destructor */ @@ -178,47 +168,6 @@ namespace Isis { } } - - ControlDisplayProperties::XmlHandler::XmlHandler(ControlDisplayProperties *displayProperties) { - m_displayProperties = displayProperties; - } - - - bool ControlDisplayProperties::XmlHandler::startElement(const QString &namespaceURI, - const QString &localName, const QString &qName, const QXmlAttributes &atts) { - if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) { - if (localName == "displayProperties") { - QString displayName = atts.value("displayName"); - - if (!displayName.isEmpty()) { - m_displayProperties->setDisplayName(displayName); - } - } - } - - return true; - } - - - bool ControlDisplayProperties::XmlHandler::characters(const QString &ch) { - m_hexData += ch; - - return XmlStackedHandler::characters(ch); - } - - - bool ControlDisplayProperties::XmlHandler::endElement(const QString &namespaceURI, - const QString &localName, const QString &qName) { - if (localName == "displayProperties") { - QByteArray hexValues(m_hexData.toLatin1()); - QDataStream valuesStream(QByteArray::fromHex(hexValues)); - valuesStream >> *m_displayProperties->m_propertyValues; - } - - return XmlStackedHandler::endElement(namespaceURI, localName, qName); - } - - /** * This is the generic mutator for properties. Given a value, this will * change it and emit propertyChanged if its different and supported. diff --git a/isis/src/qisis/objs/ControlDisplayProperties/ControlDisplayProperties.h b/isis/src/qisis/objs/ControlDisplayProperties/ControlDisplayProperties.h index cd6005a8a4..b2913779f2 100644 --- a/isis/src/qisis/objs/ControlDisplayProperties/ControlDisplayProperties.h +++ b/isis/src/qisis/objs/ControlDisplayProperties/ControlDisplayProperties.h @@ -14,7 +14,6 @@ find files of those names at the top level of this repository. **/ #include // This is required since QColor is in a slot #include "DisplayProperties.h" -#include "XmlStackedHandler.h" class QAction; class QXmlStreamWriter; @@ -24,7 +23,6 @@ namespace Isis { class Project; class Pvl; class PvlObject; - class XmlStackedHandlerReader; /** * @brief This is the GUI communication mechanism for cubes @@ -75,7 +73,6 @@ namespace Isis { ControlDisplayProperties(QString displayName, QObject *parent = NULL); - ControlDisplayProperties(XmlStackedHandlerReader *xmlReader, QObject *parent = NULL); virtual ~ControlDisplayProperties(); // void fromPvl(const PvlObject &pvl); @@ -102,31 +99,6 @@ namespace Isis { private slots: void toggleShowLabel(); - private: - /** - * @author 2012-??-?? ??? - * - * @internal - */ - class XmlHandler : public XmlStackedHandler { - public: - XmlHandler(ControlDisplayProperties *displayProperties); - - virtual bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts); - - virtual bool characters(const QString &ch); - - virtual bool endElement(const QString &namespaceURI, const QString &localName, - const QString &qName); - - private: - Q_DISABLE_COPY(XmlHandler); - - ControlDisplayProperties *m_displayProperties; - QString m_hexData; - }; - private: ControlDisplayProperties(const ControlDisplayProperties &); ControlDisplayProperties &operator=(const ControlDisplayProperties &); diff --git a/isis/src/qisis/objs/ControlList/ControlList.cpp b/isis/src/qisis/objs/ControlList/ControlList.cpp index 8b5dbd3be6..d6dc2f7d5c 100644 --- a/isis/src/qisis/objs/ControlList/ControlList.cpp +++ b/isis/src/qisis/objs/ControlList/ControlList.cpp @@ -24,7 +24,6 @@ find files of those names at the top level of this repository. **/ #include "FileName.h" #include "IException.h" #include "Project.h" -#include "XmlStackedHandlerReader.h" namespace Isis { /** @@ -59,20 +58,6 @@ namespace Isis { append(controls); } - - /** - * Create an control list from XML - * - * @param project The project with the control list - * @param xmlReader The XML reader currently at an tag. - * @param parent The Qt-relationship parent - */ - ControlList::ControlList(Project *project, XmlStackedHandlerReader *xmlReader, QObject *parent) : - QObject(parent) { - xmlReader->pushContentHandler(new XmlHandler(this, project)); - } - - /** * Copy constructor. * @@ -726,97 +711,4 @@ namespace Isis { m_newProjectRoot = rhs.m_newProjectRoot; return *this; } - - - /** - * Create an XML Handler (reader/writer) that can populate the ControlList class data. See - * ControlList::save() for the expected format. - * - * @param controlList The control list we're going to be initializing - * @param project The project that contains the control list - */ - ControlList::XmlHandler::XmlHandler(ControlList *controlList, Project *project) { - m_controlList = controlList; - m_project = project; - } - - - /** - * Handle an XML start element. This expects and elements (it reads both - * the project XML and the controls.xml file). - * - * @param namespaceURI ??? - * @param localName The keyword name given to the member variable in the XML - * @param qName ??? - * @param atts The attribute containing the keyword value given for the given localName - * - * @return @b bool If we should continue reading the XML (usually true). - */ - bool ControlList::XmlHandler::startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts) { - if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) { - if (localName == "controlList") { - QString name = atts.value("name"); - QString path = atts.value("path"); - - if (!name.isEmpty()) { - m_controlList->setName(name); - } - - if (!path.isEmpty()) { - m_controlList->setPath(path); - } - } - else if (localName == "controlNet") { - m_controlList->append(new Control(m_project->cnetRoot() + "/" + - m_controlList->path(), reader())); - } - } - - return true; - } - - - /** - * Handle an XML end element. This handles by opening and reading the controls.xml - * file. - * - * @param namespaceURI ??? - * @param localName The keyword name given to the member variable in the XML - * @param qName ??? - * - * @return @b bool If we should continue reading the XML (usually true). - * - * @throws IException::Io "Unable to open with read access" - * @throws IException::Io "Failed to open control list XML" - */ - bool ControlList::XmlHandler::endElement(const QString &namespaceURI, const QString &localName, - const QString &qName) { - if (localName == "controlList") { - XmlHandler handler(m_controlList, m_project); - - XmlStackedHandlerReader reader; - reader.pushContentHandler(&handler); - reader.setErrorHandler(&handler); - - QString controlListXmlPath = m_project->cnetRoot() + "/" + m_controlList->path() + - "/controlNetworks.xml"; - QFile file(controlListXmlPath); - - if (!file.open(QFile::ReadOnly)) { - throw IException(IException::Io, - QString("Unable to open [%1] with read access") - .arg(controlListXmlPath), - _FILEINFO_); - } - - QXmlInputSource xmlInputSource(&file); - if (!reader.parse(xmlInputSource)) - throw IException(IException::Io, - tr("Failed to open control list XML [%1]").arg(controlListXmlPath), - _FILEINFO_); - } - - return XmlStackedHandler::endElement(namespaceURI, localName, qName); - } } diff --git a/isis/src/qisis/objs/ControlList/ControlList.h b/isis/src/qisis/objs/ControlList/ControlList.h index 4d3db3f5fb..20555e294b 100644 --- a/isis/src/qisis/objs/ControlList/ControlList.h +++ b/isis/src/qisis/objs/ControlList/ControlList.h @@ -16,14 +16,12 @@ find files of those names at the top level of this repository. **/ #include "Control.h" #include "ControlDisplayProperties.h" -#include "XmlStackedHandler.h" class QStringList; class QXmlStreamWriter; namespace Isis { class FileName; - class XmlStackedHandlerReader; /** * Maintains a list of Controls so that control nets can easily be copied from one Project to @@ -49,8 +47,6 @@ namespace Isis { ControlList(QString name, QString path, QObject *parent = NULL); explicit ControlList(QObject *parent = NULL); explicit ControlList(QList, QObject *parent = NULL); - explicit ControlList(Project *project, XmlStackedHandlerReader *xmlReader, - QObject *parent = NULL); explicit ControlList(QStringList &); ControlList(const ControlList &); ~ControlList(); @@ -138,34 +134,6 @@ namespace Isis { FileName m_newProjectRoot; //!< The filename of the destination project's root }; - /** - * Nested class used to write the ControlList object information to an XML file for the - * purposes of saving an restoring the state of the object. - * - * @see ControlList::save for the expected format - * - * @author 2012-09-27 Tracie Sucharski - Adapted from ImageList::XmlHandler - * - * @internal - * @history 2012-09-27 Tracie Sucharski - Original version. - */ - class XmlHandler : public XmlStackedHandler { - public: - XmlHandler(ControlList *controlList, Project *project); - - virtual bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts); - virtual bool endElement(const QString &namespaceURI, const QString &localName, - const QString &qName); - - private: - Q_DISABLE_COPY(XmlHandler); - - ControlList *m_controlList; //!< Control list to be read or written - Project *m_project; //!< Project that contains the control list - }; - - private: QString m_name; //!< Name of the ControlList diff --git a/isis/src/qisis/objs/CubeDnView/CubeDnView.cpp b/isis/src/qisis/objs/CubeDnView/CubeDnView.cpp index ebfbc5a440..d4ce36f9fd 100644 --- a/isis/src/qisis/objs/CubeDnView/CubeDnView.cpp +++ b/isis/src/qisis/objs/CubeDnView/CubeDnView.cpp @@ -67,7 +67,6 @@ find files of those names at the top level of this repository. **/ #include "ViewportMdiSubWindow.h" #include "Workspace.h" #include "WindowTool.h" -#include "XmlStackedHandlerReader.h" #include "ZoomTool.h" #include "ProjectItemViewMenu.h" @@ -530,11 +529,6 @@ namespace Isis { } - void CubeDnView::load(XmlStackedHandlerReader *xmlReader, Project *project) { - xmlReader->pushContentHandler(new XmlHandler(this, project)); - } - - void CubeDnView::save(QXmlStreamWriter &stream, Project *, FileName) const { stream.writeStartElement("cubeDnView"); stream.writeAttribute("objectName", objectName()); @@ -553,55 +547,4 @@ namespace Isis { } stream.writeEndElement(); } - - - CubeDnView::XmlHandler::XmlHandler(CubeDnView *cubeDnView, Project *project) { - - m_cubeDnView = cubeDnView; - m_project = project; - } - - - CubeDnView::XmlHandler::~XmlHandler() { - } - - - bool CubeDnView::XmlHandler::startElement(const QString &namespaceURI, - const QString &localName, const QString &qName, const QXmlAttributes &atts) { - bool result = XmlStackedHandler::startElement(namespaceURI, localName, qName, atts); - - if (result) { - ProjectItemProxyModel *proxy = (ProjectItemProxyModel *) m_cubeDnView->internalModel(); - ProjectItemModel *source = proxy->sourceModel(); - QString id = atts.value("id"); - - ProjectItem *item = NULL; - if (localName == "image") { - Image *image = m_project->image(id); - if (image) { - // Find ProjectItem and append to list - item = source->findItemData(qVariantFromValue(image)); - } - } - else if (localName == "shape") { - Shape *shape = m_project->shape(id); - if (shape) { - item = source->findItemData(qVariantFromValue(shape)); - } - } - if (item) { - proxy->addItem(item); - } - } - - return result; - } - - - bool CubeDnView::XmlHandler::endElement(const QString &namespaceURI, - const QString &localName, const QString &qName) { - bool result = XmlStackedHandler::endElement(namespaceURI, localName, qName); - - return result; - } } diff --git a/isis/src/qisis/objs/CubeDnView/CubeDnView.h b/isis/src/qisis/objs/CubeDnView/CubeDnView.h index 94bb32ddaf..fb116cc09d 100644 --- a/isis/src/qisis/objs/CubeDnView/CubeDnView.h +++ b/isis/src/qisis/objs/CubeDnView/CubeDnView.h @@ -15,7 +15,6 @@ find files of those names at the top level of this repository. **/ #include "AbstractProjectItemView.h" #include "FileName.h" -#include "XmlStackedHandler.h" class QAction; class QMenu; @@ -35,7 +34,6 @@ namespace Isis { class Project; class ToolPad; class Workspace; - class XmlStackedHandlerReader; class ProjectItemViewMenu; /** @@ -104,7 +102,6 @@ namespace Isis { bool viewportContainsShape(MdiCubeViewport *viewport); - void load(XmlStackedHandlerReader *xmlReader, Project *project); void save(QXmlStreamWriter &stream, Project *project, FileName newProjectRoot) const; signals: @@ -136,30 +133,6 @@ namespace Isis { void leaveEvent(QEvent *event); void enableActions(); - private: - /** - * @author 2012-09-?? Steven Lambright - * - * @internal - * @history 2016-11-07 Tracie Sucharski - Implemented for CubeDnView - */ - class XmlHandler : public XmlStackedHandler { - public: - XmlHandler(CubeDnView *cubeDnView, Project *project); - ~XmlHandler(); - - virtual bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts); - virtual bool endElement(const QString &namespaceURI, const QString &localName, - const QString &qName); - - private: - Q_DISABLE_COPY(XmlHandler); - - Project *m_project; //!< The current project - CubeDnView *m_cubeDnView; //!< The view we are working with - }; - private: QMap m_cubeItemMap; //!< Maps cubes to their items Workspace *m_workspace; //!< The workspace diff --git a/isis/src/qisis/objs/Directory/Directory.cpp b/isis/src/qisis/objs/Directory/Directory.cpp index 9b5a6c2f23..95e991c210 100644 --- a/isis/src/qisis/objs/Directory/Directory.cpp +++ b/isis/src/qisis/objs/Directory/Directory.cpp @@ -91,8 +91,6 @@ find files of those names at the top level of this repository. **/ #include "WarningTreeWidget.h" #include "WorkOrder.h" #include "Workspace.h" -#include "XmlStackedHandler.h" -#include "XmlStackedHandlerReader.h" namespace Isis { @@ -1502,15 +1500,6 @@ namespace Isis { } - /** - * @brief Loads the Directory from an XML file. - * @param xmlReader The reader that takes in and parses the XML file. - */ - void Directory::load(XmlStackedHandlerReader *xmlReader) { - xmlReader->pushContentHandler( new XmlHandler(this) ); - } - - /** * @brief Save the directory to an XML file. * @param stream The XML stream writer @@ -1571,65 +1560,6 @@ namespace Isis { } - /** - * @brief This function sets the Directory pointer for the Directory::XmlHandler class - * @param directory The new directory we are setting XmlHandler's member variable to. - */ - Directory::XmlHandler::XmlHandler(Directory *directory) { - m_directory = directory; - } - - - /** - * @brief The Destructor for Directory::XmlHandler - */ - Directory::XmlHandler::~XmlHandler() { - } - - - /** - * @brief The XML reader invokes this method at the start of every element in the - * XML document. This method expects and - * elements. - * A quick example using this function: - * startElement("xsl","stylesheet","xsl:stylesheet",attributes) - * - * @param namespaceURI The Uniform Resource Identifier of the element's namespace - * @param localName The local name string - * @param qName The XML qualified string (or empty, if QNames are not available). - * @param atts The XML attributes attached to each element - * @return @b bool Returns True signalling to the reader the start of a valid XML element. If - * False is returned, something bad happened. - * - */ - bool Directory::XmlHandler::startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts) { - bool result = XmlStackedHandler::startElement(namespaceURI, localName, qName, atts); - if (result) { - QString viewObjectName; - if (localName == "footprint2DView") { - viewObjectName = atts.value("objectName"); - m_directory->addFootprint2DView(viewObjectName)->load(reader()); - } - else if (localName == "imageFileList") { - viewObjectName = atts.value("objectName"); - m_directory->addImageFileListView(viewObjectName)->load(reader()); - } - else if (localName == "cubeDnView") { - viewObjectName = atts.value("objectName"); - m_directory->addCubeDnView(viewObjectName)->load(reader(), m_directory->project()); - } - else if (localName == "cnetEditorView") { - viewObjectName = atts.value("objectName"); - QString id = atts.value("id"); - m_directory->addCnetEditorView(m_directory->project()->control(id), viewObjectName); - } - } - - return result; - } - - /** * @brief Reformat actionPairings to be user friendly for use in menus. * diff --git a/isis/src/qisis/objs/Directory/Directory.h b/isis/src/qisis/objs/Directory/Directory.h index 995c27164f..9b11b2b015 100644 --- a/isis/src/qisis/objs/Directory/Directory.h +++ b/isis/src/qisis/objs/Directory/Directory.h @@ -387,7 +387,6 @@ namespace Isis { QAction *redoAction(); QAction *undoAction(); - void load(XmlStackedHandlerReader *xmlReader); void save(QXmlStreamWriter &stream, FileName newProjectRoot) const; signals: @@ -436,26 +435,6 @@ namespace Isis { void newActiveControl(bool newControl); void reloadActiveControlInCnetEditorView(); - private: - /** - * @author 2012-08-?? Steven Lambright - * - * @internal - */ - class XmlHandler : public XmlStackedHandler { - public: - XmlHandler(Directory *directory); - ~XmlHandler(); - - virtual bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts); - - private: - Q_DISABLE_COPY(XmlHandler); - - Directory *m_directory; //!< Pointer to a Directory which is set by the XmlHandler class. - }; - private: Directory(const Directory &other); Directory &operator=(const Directory &rhs); diff --git a/isis/src/qisis/objs/DisplayProperties/DisplayProperties.cpp b/isis/src/qisis/objs/DisplayProperties/DisplayProperties.cpp index ac764eec38..42124041b9 100644 --- a/isis/src/qisis/objs/DisplayProperties/DisplayProperties.cpp +++ b/isis/src/qisis/objs/DisplayProperties/DisplayProperties.cpp @@ -14,7 +14,6 @@ find files of those names at the top level of this repository. **/ #include "FileName.h" #include "Pvl.h" -#include "XmlStackedHandlerReader.h" namespace Isis { /** @@ -36,14 +35,6 @@ namespace Isis { } - DisplayProperties::DisplayProperties(XmlStackedHandlerReader *xmlReader, QObject *parent) { - m_propertiesUsed = 0; - m_propertyValues = new QMap; - - xmlReader->pushContentHandler(new XmlHandler(this)); - } - - /** * destructor */ @@ -173,44 +164,4 @@ namespace Isis { stream.writeEndElement(); } - - - DisplayProperties::XmlHandler::XmlHandler(DisplayProperties *displayProperties) { - m_displayProperties = displayProperties; - } - - - bool DisplayProperties::XmlHandler::startElement(const QString &namespaceURI, - const QString &localName, const QString &qName, const QXmlAttributes &atts) { - if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) { - if (localName == "displayProperties") { - QString displayName = atts.value("displayName"); - - if (!displayName.isEmpty()) { - m_displayProperties->setDisplayName(displayName); - } - } - } - - return true; - } - - - bool DisplayProperties::XmlHandler::characters(const QString &ch) { - m_hexData += ch; - - return XmlStackedHandler::characters(ch); - } - - - bool DisplayProperties::XmlHandler::endElement(const QString &namespaceURI, - const QString &localName, const QString &qName) { - if (localName == "displayProperties") { - QByteArray hexValues(m_hexData.toLatin1()); - QDataStream valuesStream(QByteArray::fromHex(hexValues)); - valuesStream >> *m_displayProperties->m_propertyValues; - } - - return XmlStackedHandler::endElement(namespaceURI, localName, qName); - } } diff --git a/isis/src/qisis/objs/DisplayProperties/DisplayProperties.h b/isis/src/qisis/objs/DisplayProperties/DisplayProperties.h index 9b06ff1d5f..769f704784 100644 --- a/isis/src/qisis/objs/DisplayProperties/DisplayProperties.h +++ b/isis/src/qisis/objs/DisplayProperties/DisplayProperties.h @@ -14,8 +14,6 @@ find files of those names at the top level of this repository. **/ // This is required since QColor is in a slot #include -#include "XmlStackedHandler.h" - class QAction; class QBitArray; class QXmlStreamWriter; @@ -35,7 +33,6 @@ namespace Isis { Q_OBJECT public: DisplayProperties(QString displayName, QObject *parent = NULL); - DisplayProperties(XmlStackedHandlerReader *xmlReader, QObject *parent = NULL); virtual ~DisplayProperties(); void fromPvl(const PvlObject &pvl); @@ -62,30 +59,6 @@ namespace Isis { private: Q_DISABLE_COPY(DisplayProperties); - /** - * @author 2012-??-?? Steven Lambright - * - * @internal - */ - class XmlHandler : public XmlStackedHandler { - public: - XmlHandler(DisplayProperties *displayProperties); - - virtual bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts); - - virtual bool characters(const QString &ch); - - virtual bool endElement(const QString &namespaceURI, const QString &localName, - const QString &qName); - - private: - Q_DISABLE_COPY(XmlHandler); - - DisplayProperties *m_displayProperties; - QString m_hexData; - }; - private: diff --git a/isis/src/qisis/objs/Footprint2DView/Footprint2DView.cpp b/isis/src/qisis/objs/Footprint2DView/Footprint2DView.cpp index 09e50befbe..054a8cc0e8 100644 --- a/isis/src/qisis/objs/Footprint2DView/Footprint2DView.cpp +++ b/isis/src/qisis/objs/Footprint2DView/Footprint2DView.cpp @@ -41,7 +41,6 @@ find files of those names at the top level of this repository. **/ #include "ProjectItemModel.h" #include "Shape.h" #include "ToolPad.h" -#include "XmlStackedHandlerReader.h" namespace Isis { /** @@ -342,15 +341,6 @@ namespace Isis { } - /** - * @brief Loads the Footprint2DView from an XML file. - * @param xmlReader The reader that takes in and parses the XML file. - */ - void Footprint2DView::load(XmlStackedHandlerReader *xmlReader) { - xmlReader->pushContentHandler( new XmlHandler(this) ); - } - - /** * @brief Save the footprint view widgets (ImageFileListWidget and MosaicSceneWidget to an XML * file. @@ -372,60 +362,4 @@ namespace Isis { stream.writeEndElement(); } - - - /** - * @brief This function sets the Directory pointer for the Directory::XmlHandler class - * @param directory The new directory we are setting XmlHandler's member variable to. - */ - Footprint2DView::XmlHandler::XmlHandler(Footprint2DView *footprintView) { - - m_footprintView = footprintView; - } - - - /** - * @brief The Destructor for Directory::XmlHandler - */ - Footprint2DView::XmlHandler::~XmlHandler() { - } - - - /** - * @brief The XML reader invokes this method at the start of every element in the - * XML document. This method expects and - * elements. - * A quick example using this function: - * startElement("xsl","stylesheet","xsl:stylesheet",attributes) - * - * @param namespaceURI The Uniform Resource Identifier of the element's namespace - * @param localName The local name string - * @param qName The XML qualified string (or empty, if QNames are not available). - * @param atts The XML attributes attached to each element - * @return @b bool Returns True signalling to the reader the start of a valid XML element. If - * False is returned, something bad happened. - * - */ - bool Footprint2DView::XmlHandler::startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts) { - bool result = XmlStackedHandler::startElement(namespaceURI, localName, qName, atts); - - if (result) { - if (localName == "mosaicScene") { - m_footprintView->mosaicSceneWidget()->load(reader()); - } - if (localName == "imageFileList") { - m_footprintView->m_fileListWidget->load(reader()); - } - } - return result; - } - - - bool Footprint2DView::XmlHandler::endElement(const QString &namespaceURI, - const QString &localName, const QString &qName) { - bool result = XmlStackedHandler::endElement(namespaceURI, localName, qName); - - return result; - } } diff --git a/isis/src/qisis/objs/Footprint2DView/Footprint2DView.h b/isis/src/qisis/objs/Footprint2DView/Footprint2DView.h index 34a8414103..0874960742 100644 --- a/isis/src/qisis/objs/Footprint2DView/Footprint2DView.h +++ b/isis/src/qisis/objs/Footprint2DView/Footprint2DView.h @@ -16,7 +16,6 @@ find files of those names at the top level of this repository. **/ #include "AbstractProjectItemView.h" #include "FileName.h" #include "ImageList.h" -#include "XmlStackedHandler.h" class QAction; class QEvent; @@ -34,7 +33,6 @@ namespace Isis { class MosaicSceneWidget; class Project; class ToolPad; - class XmlStackedHandlerReader; /** * View for displaying footprints of images in a QMos like way. @@ -110,7 +108,6 @@ namespace Isis { MosaicSceneWidget *mosaicSceneWidget(); ImageFileListWidget *fileListWidget(); - void load(XmlStackedHandlerReader *xmlReader); void save(QXmlStreamWriter &stream, Project *project, FileName newProjectRoot) const; signals: @@ -137,27 +134,6 @@ namespace Isis { private: void enableActions(); - /** - * @author 2018-05-11 Tracie Sucharski - * - * @internal - */ - class XmlHandler : public XmlStackedHandler { - public: - XmlHandler(Footprint2DView *footprintView); - ~XmlHandler(); - - virtual bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts); - virtual bool endElement(const QString &namespaceURI, const QString &localName, - const QString &qName); - - private: - Q_DISABLE_COPY(XmlHandler); - - Footprint2DView *m_footprintView; //!< The Footprint2DView - }; - private: MosaicSceneWidget *m_sceneWidget; //!< The scene widget ImageFileListWidget *m_fileListWidget; //!< The file list widget diff --git a/isis/src/qisis/objs/GuiCamera/GuiCamera.cpp b/isis/src/qisis/objs/GuiCamera/GuiCamera.cpp index 80b24b7c78..d1eacf3e1d 100644 --- a/isis/src/qisis/objs/GuiCamera/GuiCamera.cpp +++ b/isis/src/qisis/objs/GuiCamera/GuiCamera.cpp @@ -12,7 +12,6 @@ #include "Project.h" #include "PvlKeyword.h" #include "PvlObject.h" -#include "XmlStackedHandlerReader.h" namespace Isis { @@ -49,16 +48,6 @@ namespace Isis { -// GuiCamera::GuiCamera(Project *project, XmlStackedHandlerReader *xmlReader, -// QObject *parent) : QObject(parent) { -// TODO: does xml stuff need project??? -// m_id = NULL; -// xmlReader->pushContentHandler(new XmlHandler(this, project)); -// xmlReader->setErrorHandler(new XmlHandler(this, project)); -// } - - - // GuiCamera::GuiCamera(const GuiCamera &src) // : m_id(new QUuid(src.m_id->toString())) { // @@ -135,162 +124,6 @@ namespace Isis { } - - - /** - * Output format: - * - * - * - * ... - * - * - * (fileName attribute is just the base name) - */ -// void GuiCamera::save(QXmlStreamWriter &stream, const Project *project, -// FileName newProjectRoot) const { - -// stream.writeStartElement("GuiCamera"); -// // save ID, cnet file name, and run time to stream -// stream.writeStartElement("generalAttributes"); -// stream.writeTextElement("id", m_id->toString()); -// stream.writeTextElement("runTime", runTime()); -// stream.writeTextElement("fileName", m_controlNetworkFileName->expanded()); -// stream.writeEndElement(); // end general attributes - -// // save settings to stream -// m_settings->save(stream, project); - -// // save statistics to stream -// m_statisticsResults->save(stream, project); - -// // save image lists to stream -// if ( !m_images->isEmpty() ) { -// stream.writeStartElement("imageLists"); - -// for (int i = 0; i < m_images->count(); i++) { -// m_images->at(i)->save(stream, project, ""); -// } - -// stream.writeEndElement(); -// } -// stream.writeEndElement(); //end GuiCamera -// } - - - -// void GuiCamera::save(QXmlStreamWriter &stream, const Project *project) const { - -// stream.writeStartElement("GuiCamera"); - -// // save ID, attributes, and run time to stream -// stream.writeStartElement("generalAttributes"); -// stream.writeTextElement("id", m_id->toString()); -// stream.writeTextElement("runTime", runTime()); -// stream.writeEndElement(); // end general attributes - -// stream.writeEndElement(); //end GuiCamera -// } - - - - /** - * Create an XML Handler (reader) that can populate the BundleSettings class data. See - * BundleSettings::save() for the expected format. - * - * @param bundleSettings The image we're going to be initializing - * @param imageFolder The folder that contains the Cube - */ -// GuiCamera::XmlHandler::XmlHandler(GuiCamera *GuiCamera, Project *project) { -// m_xmlHandlerGuiCamera = GuiCamera; -// m_xmlHandlerProject = NULL; -// m_xmlHandlerProject = project; -// m_xmlHandlerCharacters = ""; -// } - - - -// GuiCamera::XmlHandler::~XmlHandler() { - // GuiCamera passed in is "this" delete+null will cause problems,no? -// delete m_xmlHandlerGuiCamera; -// m_xmlHandlerGuiCamera = NULL; - - // we do not delete this pointer since it was set to a passed in pointer in constructor and we - // don't own it... is that right??? -// delete m_xmlHandlerProject; -// m_xmlHandlerProject = NULL; -// } - - - - /** - * Handle an XML start element. This expects and elements. - * - * @return If we should continue reading the XML (usually true). - */ -// bool GuiCamera::XmlHandler::startElement(const QString &namespaceURI, const QString &localName, -// const QString &qName, const QXmlAttributes &atts) { -// m_xmlHandlerCharacters = ""; -// -// if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) { -// -// if (localName == "GuiCamera") { -// m_xmlHandlerGuiCamera = -// BundleSettingsQsp(new GuiCamera(m_xmlHandlerProject, reader())); -// } -// else if (localName == "bundleResults") { -// delete m_xmlHandlerBundleResults; -// m_xmlHandlerBundleResults = NULL; -// m_xmlHandlerBundleResults = new BundleResults(m_xmlHandlerProject, reader()); -//TODO: need to add constructor for this??? -// } -// else if (localName == "imageList") { -// m_xmlHandlerImages->append(new ImageList(m_xmlHandlerProject, reader())); -// } -// } -// return true; -// } - - - -// bool GuiCamera::XmlHandler::characters(const QString &ch) { -// m_xmlHandlerCharacters += ch; -// return XmlStackedHandler::characters(ch); -// } - - - -// bool GuiCamera::XmlHandler::endElement(const QString &namespaceURI, const QString &localName, -// const QString &qName) { -// if (localName == "id") { -// m_xmlHandlerGuiCamera->m_id = NULL; -// m_xmlHandlerGuiCamera->m_id = new QUuid(m_xmlHandlerCharacters); -// } -// else if (localName == "runTime") { -// m_xmlHandlerGuiCamera->m_runTime = m_xmlHandlerCharacters; -// } -// else if (localName == "fileName") { -// m_xmlHandlerGuiCamera->m_controlNetworkFileName = NULL; -// m_xmlHandlerGuiCamera->m_controlNetworkFileName = new FileName(m_xmlHandlerCharacters); -// } -// else if (localName == "bundleSettings") { -// m_xmlHandlerGuiCamera->m_settings = -// BundleSettingsQsp(new BundleSettings(*m_xmlHandlerBundleSettings)); -// } -// else if (localName == "bundleResults") { -// m_xmlHandlerGuiCamera->m_statisticsResults = new BundleResults(*m_xmlHandlerBundleResults); -// } -// if (localName == "imageLists") { -// for (int i = 0; i < m_xmlHandlerImages->size(); i++) { -// m_xmlHandlerGuiCamera->m_images->append(m_xmlHandlerImages->at(i)); -// } -// m_xmlHandlerImages->clear(); -// } -// m_xmlHandlerCharacters = ""; -// return XmlStackedHandler::endElement(namespaceURI, localName, qName); -// } - - /** * @brief Retrieves a unique, identifying string associated with this GuiCamera object. * @return @b QString returns m_id diff --git a/isis/src/qisis/objs/GuiCamera/GuiCamera.h b/isis/src/qisis/objs/GuiCamera/GuiCamera.h index 57df7f7c2c..4962901618 100644 --- a/isis/src/qisis/objs/GuiCamera/GuiCamera.h +++ b/isis/src/qisis/objs/GuiCamera/GuiCamera.h @@ -32,7 +32,6 @@ #include #include #include -#include "XmlStackedHandler.h" class QDataStream; class QUuid; @@ -45,7 +44,6 @@ namespace Isis { class GuiCameraDisplayProperties; class Project; // TODO: does xml stuff need project??? class PvlObject; - class XmlStackedHandlerReader; /** * @brief Container class for GuiCamera. @@ -73,8 +71,6 @@ namespace Isis { Q_OBJECT public: GuiCamera(Camera *camera, QObject *parent = 0); -// GuiCamera(Project *project, XmlStackedHandlerReader *xmlReader, -// QObject *parent = 0); // TODO: does xml stuff need project??? ~GuiCamera(); bool operator==(const GuiCamera &srcGuiCamera) const; @@ -112,32 +108,6 @@ namespace Isis { // QDataStream &read(QDataStream &stream); - private: - /** - * - * @author 2015-06-08 Ken Edmundson - * - * @internal - */ -// class XmlHandler : public XmlStackedHandler { -// public: -// XmlHandler(GuiCamera *GuiCamera, Project *project); // TODO: does xml stuff need project??? -// ~XmlHandler(); - -// virtual bool startElement(const QString &namespaceURI, const QString &localName, -// const QString &qName, const QXmlAttributes &atts); -// virtual bool characters(const QString &ch); -// virtual bool endElement(const QString &namespaceURI, const QString &localName, -// const QString &qName); - -// private: -// Q_DISABLE_COPY(XmlHandler); - -// GuiCamera *m_xmlHandlerGuiCamera; -// Project *m_xmlHandlerProject; // TODO: does xml stuff need project??? -// QString m_xmlHandlerCharacters; -// }; - private: GuiCamera(const GuiCamera &other); // NOTE: copy constructor & assignment operators GuiCamera &operator=(const GuiCamera &src); // are private so compiler will generate error diff --git a/isis/src/qisis/objs/GuiCameraDisplayProperties/GuiCameraDisplayProperties.cpp b/isis/src/qisis/objs/GuiCameraDisplayProperties/GuiCameraDisplayProperties.cpp index 850f3818e8..1c90041a65 100644 --- a/isis/src/qisis/objs/GuiCameraDisplayProperties/GuiCameraDisplayProperties.cpp +++ b/isis/src/qisis/objs/GuiCameraDisplayProperties/GuiCameraDisplayProperties.cpp @@ -12,7 +12,6 @@ #include "FileName.h" #include "Pvl.h" -#include "XmlStackedHandlerReader.h" namespace Isis { /** @@ -36,21 +35,6 @@ namespace Isis { } - /** - * @brief GuiCameraDisplayProperties constructor - * @param xmlReader XML reader class for loading the Gui Camera Display Properties - * @param parent - */ - - GuiCameraDisplayProperties::GuiCameraDisplayProperties(XmlStackedHandlerReader *xmlReader, - QObject *parent) : DisplayProperties("", parent) { - m_propertiesUsed = None; - m_propertyValues = new QMap; - - xmlReader->pushContentHandler(new XmlHandler(this)); - } - - /** * destructor */ @@ -216,86 +200,6 @@ namespace Isis { } - /** - * @brief Sets the GuiCameraDisplayProperties variable pointer. - * @param displayProperties The new pointer. - */ - - GuiCameraDisplayProperties::XmlHandler::XmlHandler(GuiCameraDisplayProperties *displayProperties) { - m_displayProperties = displayProperties; - } - - - /** - * @brief The XML reader invokes this method at the start of every element in the - * XML document. - * A quick example using this function: - * startElement("xsl","stylesheet","xsl:stylesheet",attributes) - * - * @param namespaceURI The Uniform Resource Identifier of the element's namespace - * @param localName The local name string - * @param qName The XML qualified string (or empty, if QNames are not available). - * @param atts The XML attributes attached to each element - * @return @b bool Returns True signalling to the reader the start of a valid XML element. If - * False is returned, something bad happened. - * - */ - bool GuiCameraDisplayProperties::XmlHandler::startElement(const QString &namespaceURI, - const QString &localName, const QString &qName, const QXmlAttributes &atts) { - if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) { - if (localName == "displayProperties") { - QString displayName = atts.value("displayName"); - - if (!displayName.isEmpty()) { - m_displayProperties->setDisplayName(displayName); - } - } - } - - return true; - } - - - /** - * @brief This implementation of a virtual function calls - * QXmlDefaultHandler::characters(QString &ch) - * which in turn calls QXmlContentHandler::characters(QString &ch) which - * is called when the XML processor has parsed a chunk of character data. - * @see XmlStackedHandler, QXmlDefaultHandler,QXmlContentHandler - * @param ch The character data. - * @return @b bool Returns True if there were no problems with the character processing. - * It returns False if there was a problem, and the XML reader stops. - */ - bool GuiCameraDisplayProperties::XmlHandler::characters(const QString &ch) { - m_hexData += ch; - - return XmlStackedHandler::characters(ch); - } - - - /** - * @brief The XML reader invokes this method at the end of every element in the - * XML document. - * @param namespaceURI The Uniform Resource Identifier of the namespace (eg. "xmlns") - * @param localName The local name string (eg. "xhtml") - * @param qName The XML qualified string (eg. "xmlns:xhtml"). This can be empty if - * QNames are not available. - * @return @b bool If this function returns True, then a signal is sent to the reader indicating - * the end of the element. If this function returns False, something bad - * happened and processing stops. - */ - bool GuiCameraDisplayProperties::XmlHandler::endElement(const QString &namespaceURI, - const QString &localName, const QString &qName) { - if (localName == "displayProperties") { - QByteArray hexValues(m_hexData.toLatin1()); - QDataStream valuesStream(QByteArray::fromHex(hexValues)); - valuesStream >> *m_displayProperties->m_propertyValues; - } - - return XmlStackedHandler::endElement(namespaceURI, localName, qName); - } - - /** * @brief This is the generic mutator for properties. * diff --git a/isis/src/qisis/objs/GuiCameraDisplayProperties/GuiCameraDisplayProperties.h b/isis/src/qisis/objs/GuiCameraDisplayProperties/GuiCameraDisplayProperties.h index 2b5d0d999f..4570c8a90d 100644 --- a/isis/src/qisis/objs/GuiCameraDisplayProperties/GuiCameraDisplayProperties.h +++ b/isis/src/qisis/objs/GuiCameraDisplayProperties/GuiCameraDisplayProperties.h @@ -28,7 +28,6 @@ #include "DisplayProperties.h" -#include "XmlStackedHandler.h" class QAction; class QXmlStreamWriter; @@ -38,7 +37,6 @@ namespace Isis { class Project; class Pvl; class PvlObject; - class XmlStackedHandlerReader; /** * @brief The GUI communication mechanism for target body objects. @@ -92,7 +90,6 @@ namespace Isis { GuiCameraDisplayProperties(QString displayName, QObject *parent = NULL); - GuiCameraDisplayProperties(XmlStackedHandlerReader *xmlReader, QObject *parent = NULL); virtual ~GuiCameraDisplayProperties(); // void fromPvl(const PvlObject &pvl); @@ -119,51 +116,6 @@ namespace Isis { private slots: void toggleShowLabel(); - private: - /** - * @brief Process a GuiCameraDisplayProperties in a stack-oriented way - * - * Child class for XmlStackedHandler which is used to process XML in - * a stack-oriented way. It's been modified to process a GuiCameraDisplayProperties - * object. - * - * @author 2015-09-08 Ken Edmundson - * - * @internal - * @history 2015-09-08 Ken Edmundson - Creation. - * @history 2016-06-08 Tyler Wilson - Added documentation to many of the - * member functions, and cleaned up the formatting. - * Fixes #3997. - * - * - */ - class XmlHandler : public XmlStackedHandler { - public: - XmlHandler(GuiCameraDisplayProperties *displayProperties); - - virtual bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts); - - virtual bool characters(const QString &ch); - - virtual bool endElement(const QString &namespaceURI, const QString &localName, - const QString &qName); - - private: - Q_DISABLE_COPY(XmlHandler); - - /** - * An internal pointer to GuiCameraDisplayProperties object. - */ - GuiCameraDisplayProperties *m_displayProperties; - - /** - * An internal QString variable used to store character data found in the - * content of XML elements. - */ - QString m_hexData; - }; - private: GuiCameraDisplayProperties(const GuiCameraDisplayProperties &); GuiCameraDisplayProperties &operator=(const GuiCameraDisplayProperties &); diff --git a/isis/src/qisis/objs/GuiCameraList/GuiCameraList.cpp b/isis/src/qisis/objs/GuiCameraList/GuiCameraList.cpp index 58ae54893b..d6a7be9dfa 100644 --- a/isis/src/qisis/objs/GuiCameraList/GuiCameraList.cpp +++ b/isis/src/qisis/objs/GuiCameraList/GuiCameraList.cpp @@ -38,7 +38,6 @@ #include "IException.h" #include "IString.h" #include "Project.h" -#include "XmlStackedHandlerReader.h" namespace Isis { /** @@ -75,19 +74,6 @@ namespace Isis { } - /** - * Create an image list from XML - * - * @param project The project with the gui camera list - * @param xmlReader The XML reader currently at an tag. - * @param parent The Qt-relationship parent - */ - GuiCameraList::GuiCameraList(Project *project, XmlStackedHandlerReader *xmlReader, - QObject *parent) : QObject(parent) { - xmlReader->pushContentHandler(new XmlHandler(this, project)); - } - - /** * Copy constructor. * @@ -867,97 +853,4 @@ namespace Isis { // return results; // } - - - /** - * Create an XML Handler (reader) that can populate the GuiCameraList class data. See - * GuiCameraList::save() for the expected format. - * - * @param GuiCameraList The gui camera list we're going to be initializing - * @param project The project that contains the gui camera list - */ - GuiCameraList::XmlHandler::XmlHandler(GuiCameraList *GuiCameraList, Project *project) { - m_GuiCameraList = GuiCameraList; - m_project = project; - } - - - /** - * Handle an XML start element. This expects and elements (it reads both - * the project XML and the targets.xml file). - * - * @param namespaceURI ??? - * @param localName The name of the element the XmlHandler is at - * @param qName ??? - * @param atts The attributes of the element the XmlHanler is at - * - * @return @b bool If we should continue reading the XML (usually true). - */ - bool GuiCameraList::XmlHandler::startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts) { - if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) { - if (localName == "GuiCameraList") { - QString name = atts.value("name"); - QString path = atts.value("path"); - - if (!name.isEmpty()) { - m_GuiCameraList->setName(name); - } - - if (!path.isEmpty()) { - m_GuiCameraList->setPath(path); - } - } - else if (localName == "target") { -// m_GuiCameraList->append(GuiCameraQsp(new TargetBody(m_project->targetBodyRoot() + "/" + m_GuiCameraList->path(), -// reader()))); - } - } - - return true; - } - - - /** - * Handle an XML end element. This handles by opening and reading the images.xml - * file. - * - * @param namespaceURI ??? - * @param localName The name of the element the XmlHandler is at - * @param qName ??? - * - * @return @b bool If we should continue reading the XML (usually true). - * - * @throws IException::Io "Unable to open with read access" - * @throws IException::Io "Failed to open target body list XML" - */ - bool GuiCameraList::XmlHandler::endElement(const QString &namespaceURI, const QString &localName, - const QString &qName) { - if (localName == "GuiCameraList") { - XmlHandler handler(m_GuiCameraList, m_project); - - XmlStackedHandlerReader reader; - reader.pushContentHandler(&handler); - reader.setErrorHandler(&handler); - - QString GuiCameraListXmlPath = m_project->targetBodyRoot() + "/" + m_GuiCameraList->path() + - "/targets.xml"; - QFile file(GuiCameraListXmlPath); - - if (!file.open(QFile::ReadOnly)) { - throw IException(IException::Io, - QString("Unable to open [%1] with read access") - .arg(GuiCameraListXmlPath), - _FILEINFO_); - } - - QXmlInputSource xmlInputSource(&file); - if (!reader.parse(xmlInputSource)) - throw IException(IException::Io, - tr("Failed to open target body list XML [%1]").arg(GuiCameraListXmlPath), - _FILEINFO_); - } - - return XmlStackedHandler::endElement(namespaceURI, localName, qName); - } } diff --git a/isis/src/qisis/objs/GuiCameraList/GuiCameraList.h b/isis/src/qisis/objs/GuiCameraList/GuiCameraList.h index f8f3a18080..7cf4e8c249 100644 --- a/isis/src/qisis/objs/GuiCameraList/GuiCameraList.h +++ b/isis/src/qisis/objs/GuiCameraList/GuiCameraList.h @@ -10,14 +10,12 @@ #include "GuiCameraDisplayProperties.h" //#include "GuiCameraListActionWorkOrder.h" TODO - will we need this? #include "WorkOrder.h" -#include "XmlStackedHandler.h" class QStringList; class QXmlStreamWriter; namespace Isis { class FileName; - class XmlStackedHandlerReader; /** * List of GuiCameras saved as QSharedPointers. Overrides many QList methods in order to @@ -41,8 +39,6 @@ namespace Isis { GuiCameraList(QString name, QString path, QObject *parent = NULL); explicit GuiCameraList(QObject *parent = NULL); explicit GuiCameraList(QList, QObject *parent = NULL); - explicit GuiCameraList(Project *project, - XmlStackedHandlerReader *xmlReader, QObject *parent = NULL); // explicit GuiCameraList(QStringList &); GuiCameraList(const GuiCameraList &); ~GuiCameraList(); @@ -104,33 +100,6 @@ namespace Isis { */ void countChanged(int newCount); - private: - /** - * XmlHandler used to save to xml files. - * - * JAM - The save() method that uses this is currently not implemented. - * - * @author 2012-07-01 Steven Lambright - * - * @internal - */ - class XmlHandler : public XmlStackedHandler { - public: - XmlHandler(GuiCameraList *GuiCameraList, Project *project); - - virtual bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts); - virtual bool endElement(const QString &namespaceURI, const QString &localName, - const QString &qName); - - private: - Q_DISABLE_COPY(XmlHandler); - - GuiCameraList *m_GuiCameraList; - Project *m_project; - }; - - /** * This functor is used for copying the GuiCamera objects between two projects quickly. This is designed * to work with QtConcurrentMap, though the results are all NULL (QtConcurrentMap is much diff --git a/isis/src/qisis/objs/Image/Image.cpp b/isis/src/qisis/objs/Image/Image.cpp index cc1f2f1d7f..576f8fc9a7 100644 --- a/isis/src/qisis/objs/Image/Image.cpp +++ b/isis/src/qisis/objs/Image/Image.cpp @@ -29,8 +29,6 @@ #include "Project.h" #include "SerialNumber.h" #include "Target.h" -#include "XmlStackedHandlerReader.h" - namespace Isis { @@ -132,29 +130,6 @@ namespace Isis { } - /** - * @brief Construct this image from XML. - * @param imageFolder Where this image XML resides - /work/.../projectRoot/images/import1 - * @param xmlReader An XML reader that's up to an tag. - * @param parent The Qt-relationship parent - */ - Image::Image(FileName imageFolder, XmlStackedHandlerReader *xmlReader, QObject *parent) : - QObject(parent) { - m_bodyCode = NULL; - m_cube = NULL; - m_displayProperties = NULL; - m_footprint = NULL; - m_id = NULL; - - m_aspectRatio = Null; - m_resolution = Null; - m_lineResolution = Null; - m_sampleResolution = Null; - - xmlReader->pushContentHandler(new XmlHandler(this, imageFolder)); - } - - /** * @brief Clean up this image. If you haven't saved this image, all of its settings will be lost. */ @@ -818,162 +793,4 @@ namespace Isis { ImagePolygon poly = cube()->readFootprint(); m_footprint = PolygonTools::MakeMultiPolygon(poly.Polys()->clone().release()); } - - - /** - * @brief Create an XML Handler (reader) that can populate the Image class data. - * @see Image::save() for the expected format. - * @param image The image we're going to be initializing - * @param imageFolder The folder that contains the Cube - */ - Image::XmlHandler::XmlHandler(Image *image, FileName imageFolder) { - m_image = image; - m_imageFolder = imageFolder; - } - - - - /** - * @brief Read mage class attributes - * - * The XML reader invokes this method at the start of every element in the - * XML document. This expects and elements. - * A quick example using this function: - * startElement("xsl","stylesheet","xsl:stylesheet",attributes) - * - * @param namespaceURI The Uniform Resource Identifier of the element's namespace - * @param localName The local name string - * @param qName The XML qualified string (or empty, if QNames are not available). - * @param atts The XML attributes attached to each element - * @return @b bool Returns True signalling to the reader the start of a valid XML element. If - * False is returned, something bad happened. - */ - bool Image::XmlHandler::startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts) { - m_characters = ""; - - if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) { - if (localName == "image") { - QString id = atts.value("id"); - QString fileName = atts.value("fileName"); - QString instrumentId = atts.value("instrumentId"); - QString spacecraftName = atts.value("spacecraftName"); - - QString aspectRatioStr = atts.value("aspectRatio"); - QString resolutionStr = atts.value("resolution"); - QString emissionAngleStr = atts.value("emissionAngle"); - QString incidenceAngleStr = atts.value("incidenceAngle"); - QString lineResolutionStr = atts.value("lineResolution"); - QString localRadiusStr = atts.value("localRadius"); - QString northAzimuthStr = atts.value("northAzimuth"); - QString phaseAngleStr = atts.value("phaseAngle"); - QString sampleResolutionStr = atts.value("sampleResolution"); - - if (!id.isEmpty()) { - delete m_image->m_id; - m_image->m_id = NULL; - m_image->m_id = new QUuid(id.toLatin1()); - } - - if (!fileName.isEmpty()) { - m_image->m_fileName = m_imageFolder.expanded() + "/" + fileName; - } - - if (!instrumentId.isEmpty()) { - m_image->m_instrumentId = instrumentId; - } - - if (!spacecraftName.isEmpty()) { - m_image->m_spacecraftName = spacecraftName; - } - - if (!aspectRatioStr.isEmpty()) { - m_image->m_aspectRatio = aspectRatioStr.toDouble(); - } - - if (!resolutionStr.isEmpty()) { - m_image->m_resolution = resolutionStr.toDouble(); - } - - if (!emissionAngleStr.isEmpty()) { - m_image->m_emissionAngle = Angle(emissionAngleStr.toDouble(), Angle::Radians); - } - - if (!incidenceAngleStr.isEmpty()) { - m_image->m_incidenceAngle = Angle(incidenceAngleStr.toDouble(), Angle::Radians); - } - - if (!lineResolutionStr.isEmpty()) { - m_image->m_lineResolution = lineResolutionStr.toDouble(); - } - - if (!localRadiusStr.isEmpty()) { - m_image->m_localRadius = Distance(localRadiusStr.toDouble(), Distance::Meters); - } - - if (!northAzimuthStr.isEmpty()) { - m_image->m_northAzimuth = Angle(northAzimuthStr.toDouble(), Angle::Radians); - } - - if (!phaseAngleStr.isEmpty()) { - m_image->m_phaseAngle = Angle(phaseAngleStr.toDouble(), Angle::Radians); - } - - if (!sampleResolutionStr.isEmpty()) { - m_image->m_sampleResolution = sampleResolutionStr.toDouble(); - } - } - else if (localName == "displayProperties") { - m_image->m_displayProperties = new ImageDisplayProperties(reader()); - } - } - - return true; - } - - - /** - * @brief This implementation of a virtual function calls - * QXmlDefaultHandler::characters(QString &ch) - * which in turn calls QXmlContentHandler::characters(QString &ch) which - * is called when the XML processor has parsed a chunk of character data. - * @see XmlStackedHandler, QXmlDefaultHandler,QXmlContentHandler - * @param ch The character data. - * @return @b bool Returns True if there were no problems with the character processing. - * It returns False if there was a problem, and the XML reader stops. - */ - bool Image::XmlHandler::characters(const QString &ch) { - m_characters += ch; - - return XmlStackedHandler::characters(ch); - } - - - /** - * @brief The XML reader invokes this method at the end of every element in the - * XML document. This expects and elements. - * @param namespaceURI The Uniform Resource Identifier of the namespace (eg. "xmlns") - * @param localName The local name string (eg. "xhtml") - * @param qName The XML qualified string (eg. "xmlns:xhtml"). This can be empty if - * QNames are not available. - * @return @b bool If this function returns True, then a signal is sent to the reader indicating - * the end of the element. If this function returns False, something bad - * happened and processing stops. - */ - bool Image::XmlHandler::endElement(const QString &namespaceURI, const QString &localName, - const QString &qName) { - if (localName == "footprint" && !m_characters.isEmpty()) { - geos::io::WKTReader wktReader(*globalFactory); - m_image->m_footprint = PolygonTools::MakeMultiPolygon( - wktReader.read(m_characters.toStdString()).release()); - } - else if (localName == "image" && !m_image->m_footprint) { - QMutex mutex; - m_image->initFootprint(&mutex); - m_image->closeCube(); - } - - m_characters = ""; - return XmlStackedHandler::endElement(namespaceURI, localName, qName); - } } diff --git a/isis/src/qisis/objs/Image/Image.h b/isis/src/qisis/objs/Image/Image.h index dda2e45c3a..af72d32656 100644 --- a/isis/src/qisis/objs/Image/Image.h +++ b/isis/src/qisis/objs/Image/Image.h @@ -30,7 +30,6 @@ #include "Angle.h" #include "Distance.h" #include "FileName.h" -#include "XmlStackedHandler.h" #include #include @@ -52,7 +51,6 @@ namespace Isis { class ImageDisplayProperties; class Project; class PvlObject; - class XmlStackedHandlerReader; /** * This represents a cube in a project-based GUI interface. The actual cube doesn't have to be @@ -111,7 +109,6 @@ namespace Isis { explicit Image(Cube *imageCube, QObject *parent = 0); explicit Image(Cube *imageCube, geos::geom::MultiPolygon *footprint, QString id, QObject *parent = 0); - Image(FileName imageFolder, XmlStackedHandlerReader *xmlReader, QObject *parent = 0); ~Image(); void fromPvl(const PvlObject &pvl); @@ -154,40 +151,6 @@ namespace Isis { void initCamStats(); void initQuickFootprint(); - - private: - /** - * @brief Process XML in a stack-oriented fashion - * - * Child class for XmlStackedHandler which is used to process XML in - * a stack-oriented way. It's been modified to process an Image object - * object. - * @author 2012-??-?? Steven Lambright - * - * @history 2016-06-23 Tyler Wilson - Added documention to the member functions. - * Fixes #3950. - * - * @internal - */ - class XmlHandler : public XmlStackedHandler { - public: - XmlHandler(Image *image, FileName imageFolder); - - virtual bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts); - virtual bool characters(const QString &ch); - virtual bool endElement(const QString &namespaceURI, const QString &localName, - const QString &qName); - - private: - Q_DISABLE_COPY(XmlHandler); - - Image *m_image; //!< Pointer to the Image. - FileName m_imageFolder; //!< The Name/path of the image. - QString m_characters; //!< Character data storage found in the content of XML elements. - - }; - private: Image(const Image &other); Image &operator=(const Image &rhs); diff --git a/isis/src/qisis/objs/ImageDisplayProperties/ImageDisplayProperties.cpp b/isis/src/qisis/objs/ImageDisplayProperties/ImageDisplayProperties.cpp index ec65991f92..cbfc65395d 100644 --- a/isis/src/qisis/objs/ImageDisplayProperties/ImageDisplayProperties.cpp +++ b/isis/src/qisis/objs/ImageDisplayProperties/ImageDisplayProperties.cpp @@ -11,7 +11,6 @@ #include "FileName.h" #include "Pvl.h" -#include "XmlStackedHandlerReader.h" namespace Isis { /** @@ -36,11 +35,6 @@ namespace Isis { } - ImageDisplayProperties::ImageDisplayProperties(XmlStackedHandlerReader *xmlReader, - QObject *parent) : DisplayProperties(xmlReader, parent) { - } - - /** */ ImageDisplayProperties::~ImageDisplayProperties() { diff --git a/isis/src/qisis/objs/ImageDisplayProperties/ImageDisplayProperties.h b/isis/src/qisis/objs/ImageDisplayProperties/ImageDisplayProperties.h index b6a010646f..610b0c417f 100644 --- a/isis/src/qisis/objs/ImageDisplayProperties/ImageDisplayProperties.h +++ b/isis/src/qisis/objs/ImageDisplayProperties/ImageDisplayProperties.h @@ -40,7 +40,6 @@ namespace Isis { class Pvl; class PvlObject; class UniversalGroundMap; - class XmlStackedHandlerReader; /** * @brief This is the GUI communication mechanism for cubes @@ -113,7 +112,6 @@ namespace Isis { }; ImageDisplayProperties(QString displayName, QObject *parent = NULL); - ImageDisplayProperties(XmlStackedHandlerReader *xmlReader, QObject *parent = NULL); virtual ~ImageDisplayProperties(); static QColor randomColor(); diff --git a/isis/src/qisis/objs/ImageFileListWidget/ImageFileListWidget.cpp b/isis/src/qisis/objs/ImageFileListWidget/ImageFileListWidget.cpp index aecfce4929..6de2e9eb77 100644 --- a/isis/src/qisis/objs/ImageFileListWidget/ImageFileListWidget.cpp +++ b/isis/src/qisis/objs/ImageFileListWidget/ImageFileListWidget.cpp @@ -32,7 +32,6 @@ #include "PvlObject.h" #include "Shape.h" #include "TextFile.h" -#include "XmlStackedHandlerReader.h" namespace Isis { @@ -605,16 +604,6 @@ namespace Isis { } - /** - * This method pushes a new XmlHandler into the parser stack. - * - * @param xmlReader This is the parser stack. - */ - void ImageFileListWidget::load(XmlStackedHandlerReader *xmlReader) { - xmlReader->pushContentHandler(new XmlHandler(this)); - } - - /** * This method saves the FootprintColumns in the project and the settings associated * with every column. @@ -733,147 +722,6 @@ namespace Isis { stream.writeEndElement(); } - /** - * Creates a XmlHandler for fileList - * - * @param fileList The image file list we are handling - */ - ImageFileListWidget::XmlHandler::XmlHandler(ImageFileListWidget *fileList) { - m_fileList = fileList; - m_currentImageList = NULL; - m_currentImageListItem = NULL; - m_currentGroup = NULL; - } - - /** - * Destructor - */ - ImageFileListWidget::XmlHandler::~XmlHandler() { - } - - /** - * This method calls XmlStackedHandler's startElement() and retrieves attributes from - * atts according to what localName is and stores that in m_fileList. - * - * @param namespaceURI ??? - * @param localName Determines what attributes to retrieve from atts. - * @param qName ??? - * @param atts Stores the attributes. - * - * @return @b bool The result of XmlStackedHandler's startElement() method. - */ - bool ImageFileListWidget::XmlHandler::startElement(const QString &namespaceURI, - const QString &localName, const QString &qName, const QXmlAttributes &atts) { - bool result = XmlStackedHandler::startElement(namespaceURI, localName, qName, atts); - - if (result) { - -// if (localName == "geometry") { -// QByteArray -// restoreGeometry(atts.value("value").toLatin1()); -// } - - if (localName == "position") { - QPoint pos = QPoint(atts.value("x").toInt(), atts.value("y").toInt()); - //qDebug()<<" ::startElement pos = "<move(pos); - } - else if (localName == "size") { - QSize size = QSize(atts.value("width").toInt(), atts.value("height").toInt()); - //qDebug()<<" ::startElement size = "<resize(size); - } - else if (localName == "column") { - QString colName = atts.value("name"); - QString colVisibleStr = atts.value("visible"); - QString colSortedStr = atts.value("sorted"); - - - ImageTreeWidgetItem::TreeColumn col = - ImageTreeWidgetItem::NameColumn; - while (col < ImageTreeWidgetItem::BlankColumn) { - QString curColName = ImageTreeWidgetItem::treeColumnToString(col); - - if (curColName == colName) { - if (colVisibleStr != "false") { - m_fileList->m_tree->showColumn(col); - } - else { - m_fileList->m_tree->hideColumn(col); - } - - if (colSortedStr == "true") { - m_fileList->m_tree->sortItems(col, Qt::AscendingOrder); - } - } - - col = (ImageTreeWidgetItem::TreeColumn)(col + 1); - } - } - - else if (localName == "group") { - if (atts.value("isImageList") == "true") { - if (!m_currentImageList) { - QString name = atts.value("name"); - m_currentImageListItem = m_fileList->m_tree->createImageListNameItem(name); - m_currentImageList = m_fileList->m_directory->project()->imageList(name); - m_fileList->m_tree->addTopLevelItem(m_currentImageListItem); - m_currentImageListItem->setExpanded(true); - } - } - else { - m_currentGroup = m_fileList->m_tree->createGroup(m_currentImageListItem, - atts.value("name")); - } - } - - else if (localName == "image" && m_currentGroup) { - Image *image = m_fileList->m_directory->project()->image(atts.value("id")); - // If Image for id doesn't exist, check shapes. If corresponds to Shape, new Image will - // need to be created. - if (!image) { - Shape *shape = m_fileList->m_directory->project()->shape(atts.value("id")); - if (shape) { - image = new Image(shape->cube(), shape->footprint(), atts.value("id")); - } - } - m_currentGroup->addChild(m_fileList->m_tree->prepCube(m_currentImageList, image)); - } - - } - - return result; - } - - /** - * This method calls XmlStackedHandler's endElement() and dereferences pointers according to - * the value of localName. - * - * @param namespaceURI ??? - * @param localName Determines which pointers to dereference. - * @param qName ??? - * - * @return @b bool The result of XmlStackedHandler's endElement() method. - */ - bool ImageFileListWidget::XmlHandler::endElement(const QString &namespaceURI, - const QString &localName, const QString &qName) { - bool result = XmlStackedHandler::endElement(namespaceURI, localName, qName); - - if (result) { - if (localName == "group") { - if (m_currentGroup) { - m_currentGroup = NULL; - } - else { - m_currentImageList = NULL; - m_currentImageListItem = NULL; - } - } - } - - return result; - } - void ImageFileListWidget::filterFileList() { QString filterString = m_searchLineEdit->text(); diff --git a/isis/src/qisis/objs/ImageFileListWidget/ImageFileListWidget.h b/isis/src/qisis/objs/ImageFileListWidget/ImageFileListWidget.h index ef33e3c2bd..2c16a27e46 100644 --- a/isis/src/qisis/objs/ImageFileListWidget/ImageFileListWidget.h +++ b/isis/src/qisis/objs/ImageFileListWidget/ImageFileListWidget.h @@ -70,7 +70,6 @@ namespace Isis { QProgressBar *getProgress(); void fromPvl(PvlObject &pvl); PvlObject toPvl() const; - void load(XmlStackedHandlerReader *xmlReader); void save(QXmlStreamWriter &stream, Project *project, FileName newProjectRoot) const; QList actions(); @@ -98,31 +97,6 @@ namespace Isis { void restoreExpandedStates(QVariant expandedStates, QTreeWidgetItem *item); QVariant saveExpandedStates(QTreeWidgetItem *item); - private: - /** - * @author 2012-09-?? Steven Lambright - * - * @internal - */ - class XmlHandler : public XmlStackedHandler { - public: - XmlHandler(ImageFileListWidget *fileList); - ~XmlHandler(); - - virtual bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts); - virtual bool endElement(const QString &namespaceURI, const QString &localName, - const QString &qName); - - private: - Q_DISABLE_COPY(XmlHandler); - - ImageFileListWidget *m_fileList; //!< The widget we are working with - ImageList *m_currentImageList; //!< The list of images being worked on - QTreeWidgetItem *m_currentImageListItem; //!< The image being worked on - QTreeWidgetItem *m_currentGroup; //!< The group of cubes being worked on - }; - private: QPointer m_progress; //!< The ProgressBar of the ImageFileListWidget //! Serialized (file) version of this object diff --git a/isis/src/qisis/objs/ImageList/ImageList.cpp b/isis/src/qisis/objs/ImageList/ImageList.cpp index 42e445c2a2..2674d66df2 100644 --- a/isis/src/qisis/objs/ImageList/ImageList.cpp +++ b/isis/src/qisis/objs/ImageList/ImageList.cpp @@ -41,7 +41,6 @@ #include "IException.h" #include "IString.h" #include "Project.h" -#include "XmlStackedHandlerReader.h" namespace Isis { /** @@ -77,19 +76,6 @@ namespace Isis { } - /** - * Creates an image list from XML. - * - * @param project The project with the image list. - * @param xmlReader The XML reader currently at an tag. - * @param parent The Qt-relationship parent. - */ - ImageList::ImageList(Project *project, XmlStackedHandlerReader *xmlReader, QObject *parent) : - QObject(parent) { - xmlReader->pushContentHandler(new XmlHandler(this, project)); - } - - /** * Copy constructor. * @@ -1345,94 +1331,4 @@ namespace Isis { return results; } - - - /** - * Create an XML Handler (reader) that can populate the Image list class data. - * - * @param imageList The image list we're going to be initializing - * @param project The project that contains the image list - * - * @see ImageList::save() - */ - ImageList::XmlHandler::XmlHandler(ImageList *imageList, Project *project, QString dataRoot) { - m_imageList = imageList; - m_project = project; - m_imageDataRoot = dataRoot; - } - - - /** - * Handle an XML start element. This expects and elements (it reads both - * the project XML and the images.xml file). - * - * @return @b bool If we should continue reading the XML (usually true). - */ - bool ImageList::XmlHandler::startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts) { - if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) { - if (localName == "imageList") { - QString name = atts.value("name"); - QString path = atts.value("path"); - m_imageDataRoot = atts.value("dataRoot"); - - if (!name.isEmpty()) { - m_imageList->setName(name); - } - - if (!path.isEmpty()) { - m_imageList->setPath(path); - } - } - else if (localName == "image") { - m_imageList->append(new Image( - m_project->projectRoot() + "/" + m_imageDataRoot + "/" + m_imageList->path(), reader())); - } - } - - return true; - } - - - /** - * Handle an XML end element. This handles by opening and reading the images.xml - * file. - * - * @return @b bool If we should continue reading the XML (usually true). - * - * @throws IException::Io "Unable to open with read access" - * @throws IException::Io "Failed to open image list XML" - */ - bool ImageList::XmlHandler::endElement(const QString &namespaceURI, const QString &localName, - const QString &qName) { - if (localName == "imageList") { - XmlHandler handler(m_imageList, m_project, m_imageDataRoot); - - XmlStackedHandlerReader reader; - reader.pushContentHandler(&handler); - reader.setErrorHandler(&handler); - - QDir projectPath = QDir(m_project->projectRoot()).dirName(); - QString imageListXmlPath = m_project->projectRoot() + "/" + m_imageDataRoot + "/" + - m_imageList->path() + "/images.xml"; - imageListXmlPath = QDir::cleanPath(imageListXmlPath); - - QFile file(imageListXmlPath); - - if (!file.open(QFile::ReadOnly)) { - throw IException(IException::Io, - QString("Unable to open [%1] with read access") - .arg(imageListXmlPath), - _FILEINFO_); - } - - QXmlInputSource xmlInputSource(&file); - if (!reader.parse(xmlInputSource)) - throw IException(IException::Io, - tr("Failed to open image list XML [%1]").arg(imageListXmlPath), - _FILEINFO_); - } - - return XmlStackedHandler::endElement(namespaceURI, localName, qName); - } } diff --git a/isis/src/qisis/objs/ImageList/ImageList.h b/isis/src/qisis/objs/ImageList/ImageList.h index f2a7c9c838..3ef52504b4 100644 --- a/isis/src/qisis/objs/ImageList/ImageList.h +++ b/isis/src/qisis/objs/ImageList/ImageList.h @@ -12,14 +12,12 @@ #include "ImageListActionWorkOrder.h" #include "SerialNumberList.h" #include "WorkOrder.h" -#include "XmlStackedHandler.h" class QStringList; class QXmlStreamWriter; namespace Isis { class FileName; - class XmlStackedHandlerReader; /** * @brief Internalizes a list of images and allows for operations on the entire list @@ -61,8 +59,6 @@ namespace Isis { ImageList(QString name, QString path, QObject *parent = NULL); explicit ImageList(QObject *parent = NULL); explicit ImageList(QList, QObject *parent = NULL); - explicit ImageList(Project *project, - XmlStackedHandlerReader *xmlReader, QObject *parent = NULL); explicit ImageList(QStringList &); ImageList(const ImageList &); ~ImageList(); @@ -122,41 +118,7 @@ namespace Isis { signals: void countChanged(int newCount); - private: - /** - * This class is used to read an images.xml file into an image list - * - * @author 2012-07-01 Steven Lambright - * - * @internal - */ - class XmlHandler : public XmlStackedHandler { - public: - XmlHandler(ImageList *imageList, Project *project, QString dataRoot=""); - - virtual bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts); - virtual bool endElement(const QString &namespaceURI, const QString &localName, - const QString &qName); - - private: - Q_DISABLE_COPY(XmlHandler); - - /** - * This stores a pointer to the image list that will be read into - */ - ImageList *m_imageList; - /** - * This stores a pointer to the project that the images in the image list will be a part of - */ - Project *m_project; - /** - * This is a relative path to the image data. - * e.g. project/images or project/bundle/results/TIMESTAMP/images - */ - QString m_imageDataRoot; - }; - + private: /** * This functor is used for copying the images between two projects quickly. This is designed diff --git a/isis/src/qisis/objs/MatrixSceneWidget/MatrixSceneWidget.cpp b/isis/src/qisis/objs/MatrixSceneWidget/MatrixSceneWidget.cpp index 36a71054cb..ec2978494f 100644 --- a/isis/src/qisis/objs/MatrixSceneWidget/MatrixSceneWidget.cpp +++ b/isis/src/qisis/objs/MatrixSceneWidget/MatrixSceneWidget.cpp @@ -31,7 +31,6 @@ #include "TextFile.h" #include "Target.h" #include "ToolPad.h" -#include "XmlStackedHandlerReader.h" #include #include @@ -246,12 +245,6 @@ namespace Isis { } - -// void MatrixSceneWidget::load(XmlStackedHandlerReader *xmlReader) { -// xmlReader->pushContentHandler( new XmlHandler(this) ); -// } - - /** * Returns the bounding rectangle for the images * diff --git a/isis/src/qisis/objs/MatrixSceneWidget/MatrixSceneWidget.h b/isis/src/qisis/objs/MatrixSceneWidget/MatrixSceneWidget.h index a50224a804..489a38d327 100644 --- a/isis/src/qisis/objs/MatrixSceneWidget/MatrixSceneWidget.h +++ b/isis/src/qisis/objs/MatrixSceneWidget/MatrixSceneWidget.h @@ -3,8 +3,6 @@ #include -#include "XmlStackedHandler.h" - template class QList; class QGraphicsPolygonItem; class QGraphicsRectItem; @@ -70,7 +68,6 @@ namespace Isis { QProgressBar *getProgress(); PvlObject toPvl() const; void fromPvl(const PvlObject &); -// void load(XmlStackedHandlerReader *xmlReader); QRectF elementsBoundingRect() const; Directory *directory() const; diff --git a/isis/src/qisis/objs/MosaicSceneWidget/MosaicSceneWidget.cpp b/isis/src/qisis/objs/MosaicSceneWidget/MosaicSceneWidget.cpp index 5851ce8b07..2e93df3f41 100644 --- a/isis/src/qisis/objs/MosaicSceneWidget/MosaicSceneWidget.cpp +++ b/isis/src/qisis/objs/MosaicSceneWidget/MosaicSceneWidget.cpp @@ -55,7 +55,6 @@ #include "TextFile.h" #include "Target.h" #include "ToolPad.h" -#include "XmlStackedHandlerReader.h" namespace Isis { /** @@ -617,11 +616,6 @@ namespace Isis { } - void MosaicSceneWidget::load(XmlStackedHandlerReader *xmlReader) { - xmlReader->pushContentHandler(new XmlHandler(this)); - } - - void MosaicSceneWidget::save(QXmlStreamWriter &stream, Project *, FileName ) const { if (m_projection) { stream.writeStartElement("mosaicScene"); @@ -2103,119 +2097,4 @@ namespace Isis { MosaicSceneItem *second) { return first->zValue() > second->zValue(); } - - - MosaicSceneWidget::XmlHandler::XmlHandler(MosaicSceneWidget *scene) { - m_scene = scene; - m_scrollBarXValue = -1; - m_scrollBarYValue = -1; - m_imagesToAdd = NULL; - - m_imagesToAdd = new ImageList; - } - - - MosaicSceneWidget::XmlHandler::~XmlHandler() { - delete m_imagesToAdd; - m_imagesToAdd = NULL; - } - - - bool MosaicSceneWidget::XmlHandler::startElement(const QString &namespaceURI, - const QString &localName, const QString &qName, const QXmlAttributes &atts) { - bool result = XmlStackedHandler::startElement(namespaceURI, localName, qName, atts); - - m_characterData = ""; - - if (result) { - if (localName == "image" && m_scene->m_directory) { - QString id = atts.value("id"); - double zValue = atts.value("zValue").toDouble(); - Image *image = m_scene->m_directory->project()->image(id); - // If Image for id doesn't exist, check shapes. If corresponds to Shape, new Image will - // need to be created. - if (!image) { - Shape *shape = m_scene->m_directory->project()->shape(id); - if (shape) { - image = new Image(shape->cube(), shape->footprint(), id); - } - } - if (image) { - m_imagesToAdd->append(image); - m_imageZValues.append(zValue); -// m_scene->cubeToMosaic(image)->setZValue(zValue); - } - } - else if (localName == "viewTransform") { - m_scrollBarXValue = atts.value("scrollBarXValue").toInt(); - m_scrollBarYValue = atts.value("scrollBarYValue").toInt(); - } - } - - return result; - } - - - bool MosaicSceneWidget::XmlHandler::characters(const QString &ch) { - bool result = XmlStackedHandler::characters(ch); - - if (result) { - m_characterData += ch; - } - - return result; - } - - - bool MosaicSceneWidget::XmlHandler::endElement(const QString &namespaceURI, - const QString &localName, const QString &qName) { - bool result = XmlStackedHandler::endElement(namespaceURI, localName, qName); - - if (result) { - if (localName == "projection") { - std::stringstream strStream(m_characterData.toStdString()); - PvlGroup mappingGroup; - strStream >> mappingGroup; - m_scene->setProjection(mappingGroup); - } - else if (localName == "viewTransform") { - QByteArray hexValues(m_characterData.toLatin1()); - QDataStream transformStream(QByteArray::fromHex(hexValues)); - - QTransform viewTransform; - transformStream >> viewTransform; - m_scene->getView()->show(); - QCoreApplication::processEvents(); - m_scene->getView()->setTransform(viewTransform); - m_scene->getView()->horizontalScrollBar()->setValue(m_scrollBarXValue); - m_scene->getView()->verticalScrollBar()->setValue(m_scrollBarYValue); - } - else if (localName == "toolData") { - PvlObject toolSettings; - std::stringstream strStream(m_characterData.toStdString()); - strStream >> toolSettings; - - foreach (MosaicTool *tool, *m_scene->m_tools) { - if (tool->projectPvlObjectName() == toolSettings.name()) { - tool->fromPvl(toolSettings); - } - } - } - else if (localName == "images" && m_imagesToAdd->count()) { - m_scene->addImages(*m_imagesToAdd); - - for (int i = 0; i < m_imageZValues.count(); i++) { - m_scene->cubeToMosaic(m_imagesToAdd->at(i))->setZValue(m_imageZValues[i]); - m_scene->m_currentMinimumFootprintZ = qMin(m_scene->m_currentMinimumFootprintZ, - m_imageZValues[i]); - m_scene->m_currentMaximumFootprintZ = qMax(m_scene->m_currentMaximumFootprintZ, - m_imageZValues[i]); - } - } - } - - m_characterData = ""; - - return result; - } } diff --git a/isis/src/qisis/objs/MosaicSceneWidget/MosaicSceneWidget.h b/isis/src/qisis/objs/MosaicSceneWidget/MosaicSceneWidget.h index 178dc3f898..3eb848aa20 100644 --- a/isis/src/qisis/objs/MosaicSceneWidget/MosaicSceneWidget.h +++ b/isis/src/qisis/objs/MosaicSceneWidget/MosaicSceneWidget.h @@ -199,7 +199,6 @@ namespace Isis { QProgressBar *getProgress(); PvlObject toPvl() const; void fromPvl(const PvlObject &); - void load(XmlStackedHandlerReader *xmlReader); void save(QXmlStreamWriter &stream, Project *project, FileName newProjectRoot) const; // QPointF currentLatLonPosition(); @@ -324,36 +323,6 @@ namespace Isis { static bool zOrderGreaterThan(MosaicSceneItem *first, MosaicSceneItem *second); - private: - /** - * @author 2012-09-?? Steven Lambright - * - * @internal - */ - class XmlHandler : public XmlStackedHandler { - public: - XmlHandler(MosaicSceneWidget *scene); - ~XmlHandler(); - - virtual bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts); - virtual bool characters(const QString &ch); - virtual bool endElement(const QString &namespaceURI, const QString &localName, - const QString &qName); - - private: - Q_DISABLE_COPY(XmlHandler); - - QString m_characterData; - MosaicSceneWidget *m_scene; - - int m_scrollBarXValue; - int m_scrollBarYValue; - - ImageList *m_imagesToAdd; - QList m_imageZValues; - }; - private: Directory *m_directory; diff --git a/isis/src/qisis/objs/Project/Project.cpp b/isis/src/qisis/objs/Project/Project.cpp index 601da42ec5..ff80874837 100644 --- a/isis/src/qisis/objs/Project/Project.cpp +++ b/isis/src/qisis/objs/Project/Project.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include "BundleSettings.h" #include "BundleSolutionInfo.h" @@ -75,12 +76,9 @@ #include "TemplateList.h" #include "WorkOrder.h" #include "WorkOrderFactory.h" -#include "XmlStackedHandlerReader.h" namespace Isis { - - /** * Create a new Project. This creates a project on disk at /tmp/username_appname_pid. */ @@ -1391,40 +1389,35 @@ namespace Isis { m_clearing = false; m_isTemporaryProject = false; - XmlHandler handler(this); - - XmlStackedHandlerReader reader; - reader.pushContentHandler(&handler); - reader.setErrorHandler(&handler); - QDir oldProjectRoot(*m_projectRoot); *m_projectRoot = QDir(projectAbsolutePathStr); - QXmlInputSource xmlInputSource(&file); + QXmlStreamReader projectXmlReader(&file); //This prevents the project from not loading if everything //can't be loaded, and outputs the warnings/errors to the //Warnings Tab try { - reader.parse(xmlInputSource); - } + readProjectXml(&projectXmlReader); + } catch (IException &e) { directory()->showWarning(QString("Failed to open project completely [%1]") .arg(projectAbsolutePathStr)); directory()->showWarning(e.toString()); - } + } catch (std::exception &e) { directory()->showWarning(QString("Failed to open project completely[%1]") .arg(projectAbsolutePathStr)); directory()->showWarning(e.what()); } - reader.pushContentHandler(&handler); - QXmlInputSource xmlHistoryInputSource(&historyFile); + QXmlStreamReader reader2(&historyFile); try { - reader.parse(xmlHistoryInputSource); + while (!reader2.atEnd()) { + reader2.readNext(); } + } catch (IException &e) { directory()->showWarning(QString("Failed to read history from project[%1]") @@ -1436,28 +1429,29 @@ namespace Isis { .arg(projectAbsolutePathStr)); directory()->showWarning(e.what()); } + + QXmlStreamReader reader3(&warningsFile); - reader.pushContentHandler(&handler); - - QXmlInputSource xmlWarningsInputSource(&warningsFile); - - if (!reader.parse(xmlWarningsInputSource)) { + while (!reader3.atEnd()) { + reader3.readNext(); + } + if (reader3.hasError()) { warn(tr("Failed to read warnings from project [%1]").arg(projectAbsolutePathStr)); } - reader.pushContentHandler(&handler); - - QXmlInputSource xmlDirectoryInputSource(&directoryFile); + QXmlStreamReader reader4(&directoryFile); try { - reader.parse(xmlDirectoryInputSource); - } + while (!reader4.atEnd()) { + reader4.readNext(); + } + } catch (IException &e) { directory()->showWarning(QString("Failed to read GUI state from project[%1]") .arg(projectAbsolutePathStr)); directory()->showWarning(e.toString()); - } + } catch (std::exception &e) { directory()->showWarning(QString("Failed to read GUI state from project[%1]") .arg(projectAbsolutePathStr)); @@ -1495,6 +1489,74 @@ namespace Isis { } + void Project::readProjectXml(QXmlStreamReader *xmlReader) { + if (xmlReader->readNextStartElement()) { + if (xmlReader->name() == "project") { + QStringRef name = xmlReader->attributes().value("name"); + if (!name.isEmpty()) { + m_project->setName(*(name.string())); + } + } + else if (xmlReader->name() == "controlNets") { + // m_controls.append(new ControlList(m_project, xmlReader)); + } + else if (xmlReader->name() == "imageList") { + // m_imageLists.append(new ImageList(m_project, xmlReader)); + } + else if (xmlReader->name() == "shapeList") { + // m_shapeLists.append(new ShapeList(m_project, xmlReader)); + } + else if (xmlReader->name() == "mapTemplateList") { + // m_mapTemplateLists.append(new TemplateList(m_project, xmlReader)); + } + else if (xmlReader->name() == "regTemplateList") { + // m_regTemplateLists.append(new TemplateList(m_project, xmlReader)); + } + // workOrders are stored in history.xml, using same reader as project.xml + else if (xmlReader->name() == "workOrder") { + QString type = *(xmlReader->attributes().value("type").string()); + + m_workOrder = WorkOrderFactory::create(m_project, type); + + // m_workOrder->read(xmlReader); + } + // warnings stored in warning.xml, using same reader as project.xml + else if (xmlReader->name() == "warning") { + QString warningText = *(xmlReader->attributes().value("text").string()); + + if (!warningText.isEmpty()) + { + m_project->warn(warningText); + } + } + else if (xmlReader->name() == "directory") { + // m_project->directory()->load(xmlReader); + } + else if (xmlReader->name() == "dockRestore") { + // QVariant geo_data = QVariant(atts.value("geometry")); + // restoreGeometry(geo_data); + // QVariant layout_data = QVariant(atts.value("state")); + // restoreState(layout_data); + } + else if (xmlReader->name() == "bundleSolutionInfo") { + m_bundleSolutionInfos.append(new BundleSolutionInfo(m_project, xmlReader)); + } + else if (xmlReader->name() == "activeImageList") { + QString displayName = *(xmlReader->attributes().value("displayName").string()); + m_project->setActiveImageList(displayName); + } + else if (xmlReader->name() == "activeControl") { + // Find Control + QString displayName = *(xmlReader->attributes().value("displayName").string()); + m_project->setActiveControl(displayName); + } + else + { + xmlReader->raiseError(QObject::tr("Incorrect file")); + } + } + } + QProgressBar *Project::progress() { return m_imageReader->progress(); } @@ -2302,7 +2364,7 @@ namespace Isis { * @param newProjectRoot The new root directory for the project. */ void Project::relocateProjectRoot(QString newProjectRoot) { - *m_projectRoot = newProjectRoot; + m_projectRoot->setPath(newProjectRoot); emit projectRelocated(this); } @@ -2965,13 +3027,6 @@ namespace Isis { m_idToShapeMap->remove(m_idToShapeMap->key((Shape *)imageObj)); } - - Project::XmlHandler::XmlHandler(Project *project) { - m_project = project; - m_workOrder = NULL; - } - - /** * This function returns a QMutex. This was needed to be able to deal with a threading issue with * Work Order functions returning a member variable. This is used by creating a QMutexLocker @@ -2985,136 +3040,4 @@ namespace Isis { QMutex *Project::workOrderMutex() { return m_workOrderMutex; } - - - bool Project::XmlHandler::startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts) { - if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) { - - if (localName == "project") { - QString name = atts.value("name"); - if (!name.isEmpty()) { - m_project->setName(name); - } - } - else if (localName == "controlNets") { - m_controls.append(new ControlList(m_project, reader())); - } - else if (localName == "imageList") { - m_imageLists.append(new ImageList(m_project, reader())); - } - else if (localName == "shapeList") { - m_shapeLists.append(new ShapeList(m_project, reader())); - } - else if (localName == "mapTemplateList") { - m_mapTemplateLists.append( new TemplateList(m_project, reader())); - } - else if (localName == "regTemplateList") { - m_regTemplateLists.append( new TemplateList(m_project, reader())); - } - // workOrders are stored in history.xml, using same reader as project.xml - else if (localName == "workOrder") { - QString type = atts.value("type"); - - m_workOrder = WorkOrderFactory::create(m_project, type); - - m_workOrder->read(reader()); - } - // warnings stored in warning.xml, using same reader as project.xml - else if (localName == "warning") { - QString warningText = atts.value("text"); - - if (!warningText.isEmpty()) { - m_project->warn(warningText); - } - } - else if (localName == "directory") { - m_project->directory()->load(reader()); - } - else if (localName == "dockRestore") { -// QVariant geo_data = QVariant(atts.value("geometry")); -// restoreGeometry(geo_data); -// QVariant layout_data = QVariant(atts.value("state")); -// restoreState(layout_data); - } - - else if (localName == "bundleSolutionInfo") { - m_bundleSolutionInfos.append(new BundleSolutionInfo(m_project, reader())); - } - else if (localName == "activeImageList") { - QString displayName = atts.value("displayName"); - m_project->setActiveImageList(displayName); - } - else if (localName == "activeControl") { - // Find Control - QString displayName = atts.value("displayName"); - m_project->setActiveControl(displayName); - } - } - - return true; - } - - - /** - * The xml parser for ending tags - * - * @internal - * @history 2016-12-02 Tracie Sucharski - Changed localName == "project" to - * localName == "imageLists", so that images and shapes - * are added to the project as soon as their end tag is found. - * Restoring activeImageList was not working since the project had - * no images until the end tag for "project" was reached. - * - */ - bool Project::XmlHandler::endElement(const QString &namespaceURI, const QString &localName, - const QString &qName) { - if (localName == "imageLists") { - foreach (ImageList *imageList, m_imageLists) { - m_project->imagesReady(*imageList); - } - } - else if (localName == "shapeLists") { - // TODO does this go here under project or should it be under shapes? - foreach (ShapeList *shapeList, m_shapeLists) { - m_project->shapesReady(*shapeList); - } - } - else if (localName == "mapTemplateLists") { - foreach (TemplateList *templateList, m_mapTemplateLists) { - m_project->addTemplates(templateList); - } - } - else if (localName == "regTemplateLists") { - foreach (TemplateList *templateList, m_regTemplateLists) { - m_project->addTemplates(templateList); - } - } - else if (localName == "workOrder") { - m_project->m_workOrderHistory->append(m_workOrder); - m_workOrder = NULL; - } - else if (localName == "controlNets") { - foreach (ControlList *list, m_controls) { - foreach (Control *control, *list) { - m_project->addControl(control); - } - delete list; - } - m_controls.clear(); - } - else if (localName == "results") { - foreach (BundleSolutionInfo *bundleInfo, m_bundleSolutionInfos) { - m_project->addBundleSolutionInfo(bundleInfo); - - // If BundleSolutionInfo contains adjusted images, add to the project id map. - if (bundleInfo->adjustedImages().count()) { - foreach (ImageList *adjustedImageList, bundleInfo->adjustedImages()) { - m_project->addImagesToIdMap(*adjustedImageList); - } - } - } - } - return XmlStackedHandler::endElement(namespaceURI, localName, qName); - } -} +} \ No newline at end of file diff --git a/isis/src/qisis/objs/Project/Project.h b/isis/src/qisis/objs/Project/Project.h index b50c33b3c3..2c22bcb848 100644 --- a/isis/src/qisis/objs/Project/Project.h +++ b/isis/src/qisis/objs/Project/Project.h @@ -27,12 +27,11 @@ #include #include #include -#include class QMutex; class QProgressBar; -class QXmlAttributes; class QXmlStreamWriter; +class QXmlStreamReader; #include "ControlList.h" #include "Directory.h" @@ -41,7 +40,6 @@ class QXmlStreamWriter; #include "ShapeList.h" #include "TargetBody.h" #include "TemplateList.h" -#include "XmlStackedHandler.h" namespace Isis { class BundleSolutionInfo; @@ -345,6 +343,8 @@ namespace Isis { QList workOrderHistory(); void writeSettings(FileName projName) const; + void readProjectXml(QXmlStreamReader *xmlReader); + void setActiveControl(QString displayName); Control *activeControl(); void setActiveImageList(QString displayName); @@ -588,34 +588,6 @@ namespace Isis { void storeWarning(QString text); void storeWarning(QString text, const ImageList &relevantData); - private: - /** - * @author 2012-09-?? Steven Lambright - * - * @internal - */ - class XmlHandler : public XmlStackedHandler { - public: - XmlHandler(Project *project); - - virtual bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts); - virtual bool endElement(const QString &namespaceURI, const QString &localName, - const QString &qName); - - private: - Q_DISABLE_COPY(XmlHandler); - - Project *m_project; - QList m_imageLists; - QList m_shapeLists; - QList m_controls; - QList m_bundleSolutionInfos; - QList m_mapTemplateLists; - QList m_regTemplateLists; - WorkOrder *m_workOrder; - }; - private: static const int m_maxRecentProjects = 5; @@ -678,9 +650,16 @@ namespace Isis { QUndoStack m_undoStack; + Project *m_project; + QList m_imageLists; + QList m_shapeLists; + QList m_bundleSolutionInfos; + QList m_mapTemplateLists; + QList m_regTemplateLists; + WorkOrder *m_workOrder; }; } Q_DECLARE_METATYPE(Isis::Project *); -#endif // Project_H +#endif // Project_H \ No newline at end of file diff --git a/isis/src/qisis/objs/Shape/Shape.cpp b/isis/src/qisis/objs/Shape/Shape.cpp index 2e18d51e30..0061a412fe 100644 --- a/isis/src/qisis/objs/Shape/Shape.cpp +++ b/isis/src/qisis/objs/Shape/Shape.cpp @@ -33,7 +33,6 @@ #include "SerialNumber.h" #include "ShapeDisplayProperties.h" #include "Target.h" -#include "XmlStackedHandlerReader.h" namespace Isis { /** @@ -68,21 +67,6 @@ namespace Isis { } - /** - * Construct this shape from XML. - * - * @param shapeFolder Where this shape XML resides - /work/.../projectRoot/shapes/import1 - * @param xmlReader An XML reader that's up to an tag. - * @param parent The Qt-relationship parent - */ - Shape::Shape(FileName shapeFolder, XmlStackedHandlerReader *xmlReader, QObject *parent) : - QObject(parent) { - - initMemberData(); - xmlReader->pushContentHandler(new XmlHandler(this, shapeFolder)); - } - - /** * Clean up this shape. If you haven't saved this shape, all of its settings will be lost. */ @@ -818,19 +802,6 @@ namespace Isis { } - /** - * Create an XML Handler (reader) that can populate the Shape class data. See Shape::save() for - * the expected format. - * - * @param shape The shape we're going to be initializing - * @param shapeFolder The folder that contains the Cube - */ - Shape::XmlHandler::XmlHandler(Shape *shape, FileName shapeFolder) { - m_shape = shape; - m_shapeFolder = shapeFolder; - } - - /** * Output format: * @@ -926,160 +897,4 @@ namespace Isis { stream.writeEndElement(); } - - - /** - * Handle an XML start element. This expects and elements. - * - * @return If we should continue reading the XML (usually true). - */ - bool Shape::XmlHandler::startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts) { - m_characters = ""; - - if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) { - if (localName == "shape") { - QString id = atts.value("id"); - QString fileName = atts.value("fileName"); - m_shape->m_serialNumber = atts.value("serialNumber"); - - if (!id.isEmpty()) { - delete m_shape->m_id; - m_shape->m_id = NULL; - m_shape->m_id = new QUuid(id.toLatin1()); - } - - if (!fileName.isEmpty()) { - m_shape->m_fileName = m_shapeFolder.expanded() + "/" + fileName; - } - - if (m_shape->m_serialNumber.isEmpty()) { - m_shape->m_serialNumber = SerialNumber::Compose(*m_shape->cube(), true); - } - - m_shape->m_surfacePointSource = - ControlPoint::StringToSurfacePointSource(atts.value("surfacePointSource")); - m_shape->m_radiusSource = - ControlPoint::StringToRadiusSource(atts.value("radiusSource")); - QString shapeType = atts.value("shapeType"); - - if (shapeType == "Unprojected") { - m_shape->m_shapeType = Unprojected; - QString instrumentId = atts.value("instrumentId"); - QString spacecraftName = atts.value("spacecraftName"); - - QString aspectRatioStr = atts.value("aspectRatio"); - QString resolutionStr = atts.value("resolution"); - QString emissionAngleStr = atts.value("emissionAngle"); - QString incidenceAngleStr = atts.value("incidenceAngle"); - QString lineResolutionStr = atts.value("lineResolution"); - QString localRadiusStr = atts.value("localRadius"); - QString northAzimuthStr = atts.value("northAzimuth"); - QString phaseAngleStr = atts.value("phaseAngle"); - QString sampleResolutionStr = atts.value("sampleResolution"); - - if (!instrumentId.isEmpty()) { - m_shape->m_instrumentId = m_shapeFolder.expanded() + "/" + instrumentId; - } - - if (!instrumentId.isEmpty()) { - m_shape->m_instrumentId = m_shapeFolder.expanded() + "/" + instrumentId; - } - - if (!spacecraftName.isEmpty()) { - m_shape->m_spacecraftName = m_shapeFolder.expanded() + "/" + spacecraftName; - } - - if (!aspectRatioStr.isEmpty()) { - m_shape->m_aspectRatio = aspectRatioStr.toDouble(); - } - - if (!resolutionStr.isEmpty()) { - m_shape->m_resolution = resolutionStr.toDouble(); - } - - if (!emissionAngleStr.isEmpty()) { - m_shape->m_emissionAngle = Angle(emissionAngleStr.toDouble(), Angle::Radians); - } - - if (!incidenceAngleStr.isEmpty()) { - m_shape->m_incidenceAngle = Angle(incidenceAngleStr.toDouble(), Angle::Radians); - } - - if (!lineResolutionStr.isEmpty()) { - m_shape->m_lineResolution = lineResolutionStr.toDouble(); - } - - if (!localRadiusStr.isEmpty()) { - m_shape->m_localRadius = Distance(localRadiusStr.toDouble(), Distance::Meters); - } - - if (!northAzimuthStr.isEmpty()) { - m_shape->m_northAzimuth = Angle(northAzimuthStr.toDouble(), Angle::Radians); - } - - if (!phaseAngleStr.isEmpty()) { - m_shape->m_phaseAngle = Angle(phaseAngleStr.toDouble(), Angle::Radians); - } - - if (!sampleResolutionStr.isEmpty()) { - m_shape->m_sampleResolution = sampleResolutionStr.toDouble(); - } - } - else if (shapeType == "Basemap") { - m_shape->m_shapeType = Basemap; - } - else if (shapeType == "Dem") { - m_shape->m_shapeType = Dem; - } - else { - m_shape->m_shapeType = Unknown; - } - - - } - else if (localName == "displayProperties") { - m_shape->m_displayProperties = new ShapeDisplayProperties(reader()); - } - } - - return true; - } - - - - bool Shape::XmlHandler::characters(const QString &ch) { - m_characters += ch; - - return XmlStackedHandler::characters(ch); - } - - - - bool Shape::XmlHandler::endElement(const QString &namespaceURI, const QString &localName, - const QString &qName) { - if (localName == "footprint" && !m_characters.isEmpty()) { - geos::io::WKTReader wktReader(*globalFactory); - try { - m_shape->m_footprint = PolygonTools::MakeMultiPolygon( - wktReader.read(m_characters.toStdString()).release()); - } - catch (IException &e) { - e.print(); - } - } - else if (localName == "shape" && !m_shape->m_footprint) { - try { - QMutex mutex; - m_shape->initFootprint(&mutex); - m_shape->closeCube(); - } - catch (IException &e) { - e.print(); - } - } - - m_characters = ""; - return XmlStackedHandler::endElement(namespaceURI, localName, qName); - } } diff --git a/isis/src/qisis/objs/Shape/Shape.h b/isis/src/qisis/objs/Shape/Shape.h index 82a32b8221..43e2df83be 100644 --- a/isis/src/qisis/objs/Shape/Shape.h +++ b/isis/src/qisis/objs/Shape/Shape.h @@ -19,7 +19,6 @@ find files of those names at the top level of this repository. **/ #include "FileName.h" #include "Latitude.h" #include "Longitude.h" -#include "XmlStackedHandler.h" #include #include @@ -42,7 +41,6 @@ namespace Isis { class Project; class PvlObject; class ShapeDisplayProperties; - class XmlStackedHandlerReader; /** * This represents a shape in a project-based GUI interface. The actual cube doesn't have to be @@ -76,7 +74,6 @@ namespace Isis { explicit Shape(QString shapeFileName, QObject *parent = 0); explicit Shape(Cube *shapeCube, QObject *parent = 0); - Shape(FileName shapeFolder, XmlStackedHandlerReader *xmlReader, QObject *parent = 0); ~Shape(); void fromPvl(const PvlObject &pvl); @@ -129,30 +126,6 @@ namespace Isis { geos::geom::MultiPolygon *createFootprint(QMutex *cameraMutex); void initQuickFootprint(); - /** - * - * @author 2012-??-?? Steven Lambright - * - * @internal - */ - class XmlHandler : public XmlStackedHandler { - public: - XmlHandler(Shape *shape, FileName shapeFolder); - - virtual bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts); - virtual bool characters(const QString &ch); - virtual bool endElement(const QString &namespaceURI, const QString &localName, - const QString &qName); - - private: - Q_DISABLE_COPY(XmlHandler); - - Shape *m_shape; - FileName m_shapeFolder; - QString m_characters; - }; - private: SpiceInt *m_bodyCode; /**< The NaifBodyCode value, if it exists in the labels. Otherwise, if the target is sky, diff --git a/isis/src/qisis/objs/ShapeDisplayProperties/ShapeDisplayProperties.cpp b/isis/src/qisis/objs/ShapeDisplayProperties/ShapeDisplayProperties.cpp index c32f0e522e..5d7184d258 100644 --- a/isis/src/qisis/objs/ShapeDisplayProperties/ShapeDisplayProperties.cpp +++ b/isis/src/qisis/objs/ShapeDisplayProperties/ShapeDisplayProperties.cpp @@ -12,7 +12,6 @@ #include "FileName.h" #include "Pvl.h" -#include "XmlStackedHandlerReader.h" namespace Isis { /** @@ -36,19 +35,6 @@ namespace Isis { setValue(Color, QVariant::fromValue(randomColor())); } - /** - * @brief ShapeDisplayProperties constructor - * @param xmlReader The XML reader parsing the XML file containing the display properties. - * @param parent The Qt parent object (this is destroyed when the parent is destroyed). - */ - ShapeDisplayProperties::ShapeDisplayProperties(XmlStackedHandlerReader *xmlReader, - QObject *parent) : DisplayProperties("", parent) { - m_propertiesUsed = None; - m_propertyValues = new QMap; - - xmlReader->pushContentHandler(new XmlHandler(this)); - } - /** * @brief The destructor. @@ -187,88 +173,6 @@ namespace Isis { } - /** - * @brief Constructor for the XmlHandler class. - * - * This is a child class of XmlStackedHandler, - * which is used by XmlStackedHandlerReader to parse an XML file. - * @param displayProperties Pointer to a ShapeDisplayProperties object. - */ - ShapeDisplayProperties::XmlHandler::XmlHandler(ShapeDisplayProperties *displayProperties) { - m_displayProperties = displayProperties; - } - - - /** - * @brief This overrides the parent startElement function in XmlStackedHandler so the parser can - * handle an XML file containing ShapeDisplayProperties information. - * @param namespaceURI The Uniform Resource Identifier of the element's namespace - * @param localName The local name string - * @param qName The XML qualified string (or empty, if QNames are not available). - * @param atts The XML attributes attached to each element - * @return @b bool Returns True signalling to the reader the start of a valid XML element. If - * False is returned, something bad happened. - */ - bool ShapeDisplayProperties::XmlHandler::startElement(const QString &namespaceURI, - const QString &localName, const QString &qName, const QXmlAttributes &atts) { - if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) { - if (localName == "displayProperties") { - QString displayName = atts.value("displayName"); - - if (!displayName.isEmpty()) { - m_displayProperties->setDisplayName(displayName); - } - } - } - - return true; - } - - - /** - * @brief This is called when the XML processor has parsed a chunk of character data. - * - * This implementation of a virtual function calls - * QXmlDefaultHandler::characters(QString &ch) - * which in turn calls QXmlContentHandler::characters(QString &ch) which - * is called when the XML processor has parsed a chunk of character data. - * @see XmlStackedHandler, QXmlDefaultHandler,QXmlContentHandler - * @param ch The character data. - * @return @b bool Returns True if there were no problems with the character processing. - * It returns False if there was a problem, and the XML reader stops. - */ - bool ShapeDisplayProperties::XmlHandler::characters(const QString &ch) { - m_hexData += ch; - - return XmlStackedHandler::characters(ch); - } - - - - /** - * @brief The XML reader invokes this method at the end of every element in the - * XML document. - * @param namespaceURI The Uniform Resource Identifier of the namespace (eg. "xmlns") - * @param localName The local name string (eg. "xhtml") - * @param qName The XML qualified string (eg. "xmlns:xhtml"). This can be empty if - * QNames are not available. - * @return @b bool If this function returns True, then a signal is sent to the reader indicating - * the end of the element. If this function returns False, something bad - * happened and processing stops. - */ - bool ShapeDisplayProperties::XmlHandler::endElement(const QString &namespaceURI, - const QString &localName, const QString &qName) { - if (localName == "displayProperties") { - QByteArray hexValues(m_hexData.toLatin1()); - QDataStream valuesStream(QByteArray::fromHex(hexValues)); - valuesStream >> *m_displayProperties->m_propertyValues; - } - - return XmlStackedHandler::endElement(namespaceURI, localName, qName); - } - - - /** * @brief This is the generic mutator for properties. * diff --git a/isis/src/qisis/objs/ShapeDisplayProperties/ShapeDisplayProperties.h b/isis/src/qisis/objs/ShapeDisplayProperties/ShapeDisplayProperties.h index 13cbf4f94c..378c90c1df 100644 --- a/isis/src/qisis/objs/ShapeDisplayProperties/ShapeDisplayProperties.h +++ b/isis/src/qisis/objs/ShapeDisplayProperties/ShapeDisplayProperties.h @@ -14,7 +14,6 @@ find files of those names at the top level of this repository. **/ #include #include "DisplayProperties.h" -#include "XmlStackedHandler.h" class QAction; class QXmlStreamWriter; @@ -24,7 +23,6 @@ namespace Isis { class Project; class Pvl; class PvlObject; - class XmlStackedHandlerReader; /** * @brief This is the GUI communication mechanism for shape objects. @@ -76,7 +74,6 @@ namespace Isis { ShapeDisplayProperties(QString displayName, QObject *parent = NULL); - ShapeDisplayProperties(XmlStackedHandlerReader *xmlReader, QObject *parent = NULL); virtual ~ShapeDisplayProperties(); // void fromPvl(const PvlObject &pvl); @@ -103,34 +100,6 @@ namespace Isis { private slots: void toggleShowLabel(); - private: - /** - * @brief This class is used for processing an XML file containing information - * about a WorkOrder. - * - * @author 2012-??-?? Steven Lambright - * - * @internal - */ - class XmlHandler : public XmlStackedHandler { - public: - XmlHandler(ShapeDisplayProperties *displayProperties); - - virtual bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts); - - virtual bool characters(const QString &ch); - - virtual bool endElement(const QString &namespaceURI, const QString &localName, - const QString &qName); - - private: - Q_DISABLE_COPY(XmlHandler); - - ShapeDisplayProperties *m_displayProperties; - QString m_hexData; - }; - private: ShapeDisplayProperties(const ShapeDisplayProperties &); ShapeDisplayProperties &operator=(const ShapeDisplayProperties &); diff --git a/isis/src/qisis/objs/ShapeList/ShapeList.cpp b/isis/src/qisis/objs/ShapeList/ShapeList.cpp index 75d5127c34..d150f1f3c4 100644 --- a/isis/src/qisis/objs/ShapeList/ShapeList.cpp +++ b/isis/src/qisis/objs/ShapeList/ShapeList.cpp @@ -22,7 +22,6 @@ find files of those names at the top level of this repository. **/ #include "IException.h" #include "IString.h" #include "Project.h" -#include "XmlStackedHandlerReader.h" namespace Isis { /** @@ -58,19 +57,6 @@ namespace Isis { } - /** - * Creates an shape list from XML. - * - * @param project The project with the shape list. - * @param xmlReader The XML reader currently at an tag. - * @param parent The Qt-relationship parent. - */ - ShapeList::ShapeList(Project *project, XmlStackedHandlerReader *xmlReader, QObject *parent) : - QObject(parent) { - xmlReader->pushContentHandler(new XmlHandler(this, project)); - } - - /** * Copy constructor. * @@ -742,89 +728,4 @@ namespace Isis { m_newProjectRoot = rhs.m_newProjectRoot; return *this; } - - - /** - * Create an XML Handler (reader) that can populate the Shape list class data. - * - * @param shapeList The shape list we're going to be initializing - * @param project The project that contains the shape list - * - * @see ShapeList::save() - */ - ShapeList::XmlHandler::XmlHandler(ShapeList *shapeList, Project *project) { - m_shapeList = shapeList; - m_project = project; - } - - - /** - * Handle an XML start element. This expects and elements (it reads both - * the project XML and the shapes.xml file). - * - * @return @b bool If we should continue reading the XML (usually true). - */ - bool ShapeList::XmlHandler::startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts) { - if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) { - if (localName == "shapeList") { - QString name = atts.value("name"); - QString path = atts.value("path"); - - if (!name.isEmpty()) { - m_shapeList->setName(name); - } - - if (!path.isEmpty()) { - m_shapeList->setPath(path); - } - } - else if (localName == "shape") { - m_shapeList->append(new Shape(m_project->shapeDataRoot() + "/" + m_shapeList->path(), - reader())); - } - } - - return true; - } - - - /** - * Handle an XML end element. This handles by opening and reading the shapes.xml - * file. - * - * @return @b bool If we should continue reading the XML (usually true). - * - * @throws IException::Io "Unable to open with read access" - * @throws IException::Io "Failed to open shape list XML" - */ - bool ShapeList::XmlHandler::endElement(const QString &namespaceURI, const QString &localName, - const QString &qName) { - if (localName == "shapeList") { - XmlHandler handler(m_shapeList, m_project); - - XmlStackedHandlerReader reader; - reader.pushContentHandler(&handler); - reader.setErrorHandler(&handler); - - QString shapeListXmlPath = m_project->shapeDataRoot() + "/" + m_shapeList->path() + - "/shapes.xml"; - QFile file(shapeListXmlPath); - - if (!file.open(QFile::ReadOnly)) { - throw IException(IException::Io, - QString("Unable to open [%1] with read access") - .arg(shapeListXmlPath), - _FILEINFO_); - } - - QXmlInputSource xmlInputSource(&file); - if (!reader.parse(xmlInputSource)) - throw IException(IException::Io, - tr("Failed to open shape list XML [%1]").arg(shapeListXmlPath), - _FILEINFO_); - } - - return XmlStackedHandler::endElement(namespaceURI, localName, qName); - } } diff --git a/isis/src/qisis/objs/ShapeList/ShapeList.h b/isis/src/qisis/objs/ShapeList/ShapeList.h index cb3d9f9147..2570b9c0d8 100644 --- a/isis/src/qisis/objs/ShapeList/ShapeList.h +++ b/isis/src/qisis/objs/ShapeList/ShapeList.h @@ -10,14 +10,12 @@ #include "ShapeDisplayProperties.h" #include "SerialNumberList.h" #include "WorkOrder.h" -#include "XmlStackedHandler.h" class QStringList; class QXmlStreamWriter; namespace Isis { class FileName; - class XmlStackedHandlerReader; /** * @brief Internalizes a list of shapes and allows for operations on the entire list @@ -37,8 +35,6 @@ namespace Isis { ShapeList(QString name, QString path, QObject *parent = NULL); explicit ShapeList(QObject *parent = NULL); explicit ShapeList(QList, QObject *parent = NULL); - explicit ShapeList(Project *project, - XmlStackedHandlerReader *xmlReader, QObject *parent = NULL); explicit ShapeList(QStringList &); ShapeList(const ShapeList &); ~ShapeList(); @@ -94,36 +90,7 @@ namespace Isis { signals: void countChanged(int newCount); - private: - /** - * This class is used to read an shapes.xml file into an shape list - * - * @author 2012-07-01 Steven Lambright - * - * @internal - */ - class XmlHandler : public XmlStackedHandler { - public: - XmlHandler(ShapeList *shapeList, Project *project); - - virtual bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts); - virtual bool endElement(const QString &namespaceURI, const QString &localName, - const QString &qName); - - private: - Q_DISABLE_COPY(XmlHandler); - - /** - * This stores a pointer to the shape list that will be read into - */ - ShapeList *m_shapeList; - /** - * This stores a pointer to the project that the shapes in the shape list will be a part of - */ - Project *m_project; - }; - + private: /** * This functor is used for copying the shapes between two projects quickly. This is designed diff --git a/isis/src/qisis/objs/TargetBody/TargetBody.cpp b/isis/src/qisis/objs/TargetBody/TargetBody.cpp index 7185ab17c9..55ee1d88ef 100644 --- a/isis/src/qisis/objs/TargetBody/TargetBody.cpp +++ b/isis/src/qisis/objs/TargetBody/TargetBody.cpp @@ -12,7 +12,6 @@ #include "PvlKeyword.h" #include "PvlObject.h" #include "TargetBodyDisplayProperties.h" -#include "XmlStackedHandlerReader.h" namespace Isis { /** @@ -102,15 +101,6 @@ TargetBody::TargetBody(Target *target, QObject *parent) : QObject(parent) { } */ -// TargetBody::TargetBody(Project *project, XmlStackedHandlerReader *xmlReader, -// QObject *parent) : QObject(parent) { -// TODO: does xml stuff need project??? -// m_id = NULL; - -// xmlReader->pushContentHandler(new XmlHandler(this, project)); -// xmlReader->setErrorHandler(new XmlHandler(this, project)); -// } - // TargetBody::TargetBody(const TargetBody &src) @@ -417,161 +407,6 @@ TargetBody::TargetBody(Target *target, QObject *parent) : QObject(parent) { } - /** - * Output format: - * - * - * - * ... - * - * - * (fileName attribute is just the base name) - */ -// void TargetBody::save(QXmlStreamWriter &stream, const Project *project, -// FileName newProjectRoot) const { - -// stream.writeStartElement("TargetBody"); -// // save ID, cnet file name, and run time to stream -// stream.writeStartElement("generalAttributes"); -// stream.writeTextElement("id", m_id->toString()); -// stream.writeTextElement("runTime", runTime()); -// stream.writeTextElement("fileName", m_controlNetworkFileName->expanded()); -// stream.writeEndElement(); // end general attributes - -// // save settings to stream -// m_settings->save(stream, project); - -// // save statistics to stream -// m_statisticsResults->save(stream, project); - -// // save image lists to stream -// if ( !m_images->isEmpty() ) { -// stream.writeStartElement("imageLists"); - -// for (int i = 0; i < m_images->count(); i++) { -// m_images->at(i)->save(stream, project, ""); -// } - -// stream.writeEndElement(); -// } -// stream.writeEndElement(); //end TargetBody -// } - - - -// void TargetBody::save(QXmlStreamWriter &stream, const Project *project) const { - -// stream.writeStartElement("TargetBody"); - -// // save ID, attributes, and run time to stream -// stream.writeStartElement("generalAttributes"); -// stream.writeTextElement("id", m_id->toString()); -// stream.writeTextElement("runTime", runTime()); -// stream.writeEndElement(); // end general attributes - -// stream.writeEndElement(); //end TargetBody -// } - - - - /** - * Create an XML Handler (reader) that can populate the BundleSettings class data. See - * BundleSettings::save() for the expected format. - * - * @param bundleSettings The image we're going to be initializing - * @param imageFolder The folder that contains the Cube - */ -// TargetBody::XmlHandler::XmlHandler(TargetBody *TargetBody, Project *project) { -// m_xmlHandlerTargetBody = TargetBody; -// m_xmlHandlerProject = NULL; -// m_xmlHandlerProject = project; -// m_xmlHandlerCharacters = ""; -// } - - - -// TargetBody::XmlHandler::~XmlHandler() { - // TargetBody passed in is "this" delete+null will cause problems,no? -// delete m_xmlHandlerTargetBody; -// m_xmlHandlerTargetBody = NULL; - - // we do not delete this pointer since it was set to a passed in pointer in constructor and we - // don't own it... is that right??? -// delete m_xmlHandlerProject; -// m_xmlHandlerProject = NULL; -// } - - - - /** - * Handle an XML start element. This expects and elements. - * - * @return If we should continue reading the XML (usually true). - */ -// bool TargetBody::XmlHandler::startElement(const QString &namespaceURI, const QString &localName, -// const QString &qName, const QXmlAttributes &atts) { -// m_xmlHandlerCharacters = ""; -// -// if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) { -// -// if (localName == "targetBody") { -// m_xmlHandlerTargetBody = -// BundleSettingsQsp(new TargetBody(m_xmlHandlerProject, reader())); -// } -// else if (localName == "bundleResults") { -// delete m_xmlHandlerBundleResults; -// m_xmlHandlerBundleResults = NULL; -// m_xmlHandlerBundleResults = new BundleResults(m_xmlHandlerProject, reader()); -//TODO: need to add constructor for this??? -// } -// else if (localName == "imageList") { -// m_xmlHandlerImages->append(new ImageList(m_xmlHandlerProject, reader())); -// } -// } -// return true; -// } - - - -// bool TargetBody::XmlHandler::characters(const QString &ch) { -// m_xmlHandlerCharacters += ch; -// return XmlStackedHandler::characters(ch); -// } - - - -// bool TargetBody::XmlHandler::endElement(const QString &namespaceURI, const QString &localName, -// const QString &qName) { -// if (localName == "id") { -// m_xmlHandlerTargetBody->m_id = NULL; -// m_xmlHandlerTargetBody->m_id = new QUuid(m_xmlHandlerCharacters); -// } -// else if (localName == "runTime") { -// m_xmlHandlerTargetBody->m_runTime = m_xmlHandlerCharacters; -// } -// else if (localName == "fileName") { -// m_xmlHandlerTargetBody->m_controlNetworkFileName = NULL; -// m_xmlHandlerTargetBody->m_controlNetworkFileName = new FileName(m_xmlHandlerCharacters); -// } -// else if (localName == "bundleSettings") { -// m_xmlHandlerTargetBody->m_settings = -// BundleSettingsQsp(new BundleSettings(*m_xmlHandlerBundleSettings)); -// } -// else if (localName == "bundleResults") { -// m_xmlHandlerTargetBody->m_statisticsResults = new BundleResults(*m_xmlHandlerBundleResults); -// } -// if (localName == "imageLists") { -// for (int i = 0; i < m_xmlHandlerImages->size(); i++) { -// m_xmlHandlerTargetBody->m_images->append(m_xmlHandlerImages->at(i)); -// } -// m_xmlHandlerImages->clear(); -// } -// m_xmlHandlerCharacters = ""; -// return XmlStackedHandler::endElement(namespaceURI, localName, qName); -// } - - - /** * @brief Get a unique, identifying string associated with this TargetBody object. * diff --git a/isis/src/qisis/objs/TargetBody/TargetBody.h b/isis/src/qisis/objs/TargetBody/TargetBody.h index 7c54351190..e69ea23814 100644 --- a/isis/src/qisis/objs/TargetBody/TargetBody.h +++ b/isis/src/qisis/objs/TargetBody/TargetBody.h @@ -24,7 +24,6 @@ find files of those names at the top level of this repository. **/ //#include "BundleTargetBody.h" #include "Distance.h" #include "Target.h" -#include "XmlStackedHandler.h" class QDataStream; @@ -37,7 +36,6 @@ namespace Isis { class Project; // TODO: does xml stuff need project??? class PvlObject; class TargetBodyDisplayProperties; - class XmlStackedHandlerReader; /** * @brief Container class for TargetBody. @@ -68,9 +66,6 @@ namespace Isis { public: TargetBody(Target *target, QObject *parent = 0); - //TargetBody(BundleTargetBodyQsp bundleTargetBody, QObject *parent = 0); -// TargetBody(Project *project, XmlStackedHandlerReader *xmlReader, -// QObject *parent = 0); // TODO: does xml stuff need project??? ~TargetBody(); bool operator==(const TargetBody &src) const; @@ -116,33 +111,6 @@ namespace Isis { // QDataStream &write(QDataStream &stream) const; // QDataStream &read(QDataStream &stream); - private: - /** - * - * @author 2015-06-08 Ken Edmundson - * - * @internal - */ -// class XmlHandler : public XmlStackedHandler { -// public: -// XmlHandler(TargetBody *TargetBody, Project *project); -// TODO: does xml stuff need project??? -// ~XmlHandler(); -// -// virtual bool startElement(const QString &namespaceURI, const QString &localName, -// const QString &qName, const QXmlAttributes &atts); -// virtual bool characters(const QString &ch); -// virtual bool endElement(const QString &namespaceURI, const QString &localName, -// const QString &qName); -// -// private: -// Q_DISABLE_COPY(XmlHandler); -// -// TargetBody *m_xmlHandlerTargetBody; -// Project *m_xmlHandlerProject; // TODO: does xml stuff need project??? -// QString m_xmlHandlerCharacters; -// }; - private: TargetBody(const TargetBody &other); // NOTE: copy constructor & assignment operators TargetBody &operator=(const TargetBody &rhs); // are private so compiler will generate error diff --git a/isis/src/qisis/objs/TargetBodyDisplayProperties/TargetBodyDisplayProperties.cpp b/isis/src/qisis/objs/TargetBodyDisplayProperties/TargetBodyDisplayProperties.cpp index e6ea2499db..e1b01b41e5 100644 --- a/isis/src/qisis/objs/TargetBodyDisplayProperties/TargetBodyDisplayProperties.cpp +++ b/isis/src/qisis/objs/TargetBodyDisplayProperties/TargetBodyDisplayProperties.cpp @@ -12,7 +12,6 @@ #include "FileName.h" #include "Pvl.h" -#include "XmlStackedHandlerReader.h" namespace Isis { /** @@ -35,19 +34,6 @@ namespace Isis { setValue(Color, QVariant::fromValue(randomColor())); } - /** - * @brief TargetBodyDisplayProperties constructor - * @param xmlReader The XML reader parsing the XML file containing the display properties. - * @param parent The Qt parent object (this is destroyed when the parent is destroyed). - */ - TargetBodyDisplayProperties::TargetBodyDisplayProperties(XmlStackedHandlerReader *xmlReader, - QObject *parent) : DisplayProperties("", parent) { - m_propertiesUsed = None; - m_propertyValues = new QMap; - - xmlReader->pushContentHandler(new XmlHandler(this)); - } - /** * @brief The destructor. @@ -218,85 +204,6 @@ namespace Isis { } - /** - * @brief Constructor for the XmlHandler class. - * - * This is a child class of XmlStackedHandler, - * which is used by XmlStackedHandlerReader to parse an XML file. - * @param displayProperties Pointer to a TargetBodyDisplayProperties object. - */ - TargetBodyDisplayProperties::XmlHandler::XmlHandler(TargetBodyDisplayProperties *displayProperties) { - m_displayProperties = displayProperties; - } - - - /** - * @brief This overrides the parent startElement function in XmlStackedHandler so the parser can - * handle an XML file containing TargetBodyDisplayProperties information. - * @param namespaceURI The Uniform Resource Identifier of the element's namespace - * @param localName The local name string - * @param qName The XML qualified string (or empty, if QNames are not available). - * @param atts The XML attributes attached to each element - * @return @b bool Returns True signalling to the reader the start of a valid XML element. If - * False is returned, something bad happened. - */ - bool TargetBodyDisplayProperties::XmlHandler::startElement(const QString &namespaceURI, - const QString &localName, const QString &qName, const QXmlAttributes &atts) { - if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) { - if (localName == "displayProperties") { - QString displayName = atts.value("displayName"); - - if (!displayName.isEmpty()) { - m_displayProperties->setDisplayName(displayName); - } - } - } - - return true; - } - - - /** - * @brief This implementation of a virtual function calls - * QXmlDefaultHandler::characters(QString &ch) - * which in turn calls QXmlContentHandler::characters(QString &ch) which - * is called when the XML processor has parsed a chunk of character data. - * @see XmlStackedHandler, QXmlDefaultHandler,QXmlContentHandler - * @param ch The character data. - * @return @b bool Returns True if there were no problems with the character processing. - * It returns False if there was a problem, and the XML reader stops. - */ - bool TargetBodyDisplayProperties::XmlHandler::characters(const QString &ch) { - m_hexData += ch; - - return XmlStackedHandler::characters(ch); - } - - - - /** - * @brief The XML reader invokes this method at the end of every element in the - * XML document. - * @param namespaceURI The Uniform Resource Identifier of the namespace (eg. "xmlns") - * @param localName The local name string (eg. "xhtml") - * @param qName The XML qualified string (eg. "xmlns:xhtml"). This can be empty if - * QNames are not available. - * @return @b bool If this function returns True, then a signal is sent to the reader indicating - * the end of the element. If this function returns False, something bad - * happened and processing stops. - */ - bool TargetBodyDisplayProperties::XmlHandler::endElement(const QString &namespaceURI, - const QString &localName, const QString &qName) { - if (localName == "displayProperties") { - QByteArray hexValues(m_hexData.toLatin1()); - QDataStream valuesStream(QByteArray::fromHex(hexValues)); - valuesStream >> *m_displayProperties->m_propertyValues; - } - - return XmlStackedHandler::endElement(namespaceURI, localName, qName); - } - - /** * @brief This is the generic mutator for properties. diff --git a/isis/src/qisis/objs/TargetBodyDisplayProperties/TargetBodyDisplayProperties.h b/isis/src/qisis/objs/TargetBodyDisplayProperties/TargetBodyDisplayProperties.h index c31810d687..ffc05a5667 100644 --- a/isis/src/qisis/objs/TargetBodyDisplayProperties/TargetBodyDisplayProperties.h +++ b/isis/src/qisis/objs/TargetBodyDisplayProperties/TargetBodyDisplayProperties.h @@ -14,7 +14,6 @@ find files of those names at the top level of this repository. **/ #include #include "DisplayProperties.h" -#include "XmlStackedHandler.h" class QAction; class QXmlStreamWriter; @@ -24,7 +23,6 @@ namespace Isis { class Project; class Pvl; class PvlObject; - class XmlStackedHandlerReader; /** * @brief This is the GUI communication mechanism for target body objects. @@ -79,7 +77,6 @@ namespace Isis { TargetBodyDisplayProperties(QString displayName, QObject *parent = NULL); - TargetBodyDisplayProperties(XmlStackedHandlerReader *xmlReader, QObject *parent = NULL); virtual ~TargetBodyDisplayProperties(); // void fromPvl(const PvlObject &pvl); @@ -106,33 +103,6 @@ namespace Isis { private slots: void toggleShowLabel(); - private: - /** - * @brief Process an XML file containing information about a WorkOrder. - * - * @author 2012-??-?? Steven Lambright - * - * @internal - */ - class XmlHandler : public XmlStackedHandler { - public: - XmlHandler(TargetBodyDisplayProperties *displayProperties); - - virtual bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts); - - virtual bool characters(const QString &ch); - - virtual bool endElement(const QString &namespaceURI, const QString &localName, - const QString &qName); - - private: - Q_DISABLE_COPY(XmlHandler); - - TargetBodyDisplayProperties *m_displayProperties; - QString m_hexData; - }; - private: TargetBodyDisplayProperties(const TargetBodyDisplayProperties &); TargetBodyDisplayProperties &operator=(const TargetBodyDisplayProperties &); diff --git a/isis/src/qisis/objs/TargetBodyList/TargetBodyList.cpp b/isis/src/qisis/objs/TargetBodyList/TargetBodyList.cpp index 925dcb794f..1b21b858de 100644 --- a/isis/src/qisis/objs/TargetBodyList/TargetBodyList.cpp +++ b/isis/src/qisis/objs/TargetBodyList/TargetBodyList.cpp @@ -24,7 +24,6 @@ find files of those names at the top level of this repository. **/ #include "IString.h" #include "Project.h" #include "TargetBody.h" -#include "XmlStackedHandlerReader.h" namespace Isis { /** @@ -61,19 +60,6 @@ namespace Isis { } - /** - * Create an image list from XML - * - * @param project The project with the target body list - * @param xmlReader The XML reader currently at an tag. - * @param parent The Qt-relationship parent - */ - TargetBodyList::TargetBodyList(Project *project, XmlStackedHandlerReader *xmlReader, - QObject *parent) : QObject(parent) { - xmlReader->pushContentHandler(new XmlHandler(this, project)); - } - - /** * Copy constructor. * @@ -851,100 +837,4 @@ namespace Isis { // return results; // } - - /** - * Create an XML Handler (reader) that can populate the TargetBodyList class data. See - * TargetBodyList::save() for the expected format. - * - * @param TargetBodyList The target body list we're going to be initializing - * @param project The project that contains the target body list - */ - TargetBodyList::XmlHandler::XmlHandler(TargetBodyList *TargetBodyList, Project *project) { - m_TargetBodyList = TargetBodyList; - m_project = project; - } - - - /** - * Handle an XML start element. This expects and elements - * (it reads both the project XML and the targets.xml file). - * - * @param namespaceURI ??? - * @param localName The name of the element the XmlReader is at - * @param qName ??? - * @param atts The attributes of the element the XmlReader is at - * - * @return @b bool If we should continue reading the XML (usually true). - */ - bool TargetBodyList::XmlHandler::startElement(const QString &namespaceURI, - const QString &localName, - const QString &qName, - const QXmlAttributes &atts) { - if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) { - if (localName == "TargetBodyList") { - QString name = atts.value("name"); - QString path = atts.value("path"); - - if (!name.isEmpty()) { - m_TargetBodyList->setName(name); - } - - if (!path.isEmpty()) { - m_TargetBodyList->setPath(path); - } - } - else if (localName == "target") { -// m_TargetBodyList->append(TargetBodyQsp(new TargetBody(m_project->targetBodyRoot() -// + "/" + m_TargetBodyList->path(), -// reader()))); - } - } - - return true; - } - - - /** - * Handle an XML end element. This handles by opening and reading the - * images.xml file. - * - * @param namespaceURI ??? - * @param localName The name of the element the XmlReader is at - * @param qName ??? - * - * @return @b bool If we should continue reading the XML (usually true). - * - * @throws IException::Io "Unable to open with read access" - * @throws IException::Io "Failed to open target body list XML" - */ - bool TargetBodyList::XmlHandler::endElement(const QString &namespaceURI, - const QString &localName, - const QString &qName) { - if (localName == "TargetBodyList") { - XmlHandler handler(m_TargetBodyList, m_project); - - XmlStackedHandlerReader reader; - reader.pushContentHandler(&handler); - reader.setErrorHandler(&handler); - - QString TargetBodyListXmlPath = m_project->targetBodyRoot() + "/" + - m_TargetBodyList->path() + "/targets.xml"; - QFile file(TargetBodyListXmlPath); - - if (!file.open(QFile::ReadOnly)) { - throw IException(IException::Io, - QString("Unable to open [%1] with read access") - .arg(TargetBodyListXmlPath), - _FILEINFO_); - } - - QXmlInputSource xmlInputSource(&file); - if (!reader.parse(xmlInputSource)) - throw IException(IException::Io, - tr("Failed to open target body list XML [%1]").arg(TargetBodyListXmlPath), - _FILEINFO_); - } - - return XmlStackedHandler::endElement(namespaceURI, localName, qName); - } } diff --git a/isis/src/qisis/objs/TargetBodyList/TargetBodyList.h b/isis/src/qisis/objs/TargetBodyList/TargetBodyList.h index 2ce78fb6d0..596452cb9d 100644 --- a/isis/src/qisis/objs/TargetBodyList/TargetBodyList.h +++ b/isis/src/qisis/objs/TargetBodyList/TargetBodyList.h @@ -10,14 +10,12 @@ #include "TargetBodyDisplayProperties.h" //#include "TargetBodyListActionWorkOrder.h" TODO - will we need this? #include "WorkOrder.h" -#include "XmlStackedHandler.h" class QStringList; class QXmlStreamWriter; namespace Isis { class FileName; - class XmlStackedHandlerReader; /** * List for holding TargetBodies. Overrides several QList methods in order to emit @@ -39,9 +37,6 @@ namespace Isis { TargetBodyList(QString name, QString path, QObject *parent = NULL); explicit TargetBodyList(QObject *parent = NULL); explicit TargetBodyList(QList, QObject *parent = NULL); - explicit TargetBodyList(Project *project, - XmlStackedHandlerReader *xmlReader, QObject *parent = NULL); -// explicit TargetBodyList(QStringList &); TargetBodyList(const TargetBodyList &); ~TargetBodyList(); @@ -98,31 +93,6 @@ namespace Isis { signals: void countChanged(int newCount); - private: - /** - * XmlReader for working with TargetBody XML files - * - * @author 2012-07-01 Steven Lambright - * - * @internal - */ - class XmlHandler : public XmlStackedHandler { - public: - XmlHandler(TargetBodyList *TargetBodyList, Project *project); - - virtual bool startElement(const QString &namespaceURI, const QString &localName, - const QString &qName, const QXmlAttributes &atts); - virtual bool endElement(const QString &namespaceURI, const QString &localName, - const QString &qName); - - private: - Q_DISABLE_COPY(XmlHandler); - - TargetBodyList *m_TargetBodyList; //!< The TargetBodyList to read into/save from - Project *m_project; //!< The project that contains the TargetBodies - }; - - /** * This functor is used for copying the TargetBody objects between two projects quickly. This * is designed to work with QtConcurrentMap, though the results are all NULL diff --git a/isis/src/qisis/objs/Template/Template.cpp b/isis/src/qisis/objs/Template/Template.cpp index bcf2ab1e7a..889a626464 100755 --- a/isis/src/qisis/objs/Template/Template.cpp +++ b/isis/src/qisis/objs/Template/Template.cpp @@ -5,7 +5,6 @@ #include "FileName.h" #include "IException.h" #include "Project.h" -#include "XmlStackedHandlerReader.h" namespace Isis{ /** @@ -30,9 +29,9 @@ namespace Isis{ * @param xmlReader An XML reader that's up to an