changeset 154:f6ce5febc07f

* save/reload measurements in session
author Chris Cannam
date Tue, 26 Jun 2007 12:27:47 +0000
parents d2cc3b10e26f
children 7310316bf74b
files document/SVFileReader.cpp document/SVFileReader.h
diffstat 2 files changed, 33 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/document/SVFileReader.cpp	Thu Jun 14 15:20:49 2007 +0000
+++ b/document/SVFileReader.cpp	Tue Jun 26 12:27:47 2007 +0000
@@ -54,6 +54,8 @@
     m_currentPlayParameters(0),
     m_datasetSeparator(" "),
     m_inRow(false),
+    m_inLayer(false),
+    m_inView(false),
     m_rowNumber(0),
     m_ok(false)
 {
@@ -204,6 +206,14 @@
     } else if (name == "selection") {
 
 	ok = readSelection(attributes);
+
+    } else if (name == "measurement") {
+
+        ok = readMeasurement(attributes);
+
+    } else {
+        std::cerr << "WARNING: SV-XML: Unexpected element \""
+                  << name.toLocal8Bit().data() << "\"" << std::endl;
     }
 
     if (!ok) {
@@ -295,6 +305,8 @@
 
     } else if (name == "row") {
 	m_inRow = false;
+    } else if (name == "layer") {
+        m_inLayer = false;
     } else if (name == "view") {
 	m_inView = false;
     } else if (name == "selections") {
@@ -707,6 +719,9 @@
         layer->setLayerDormant(m_currentPane, dormant);
     }
 
+    m_currentLayer = layer;
+    m_inLayer = true;
+
     return true;
 }
 
@@ -1064,6 +1079,21 @@
     return true;
 }
 
+bool
+SVFileReader::readMeasurement(const QXmlAttributes &attributes)
+{
+    std::cerr << "SVFileReader::readMeasurement: inLayer "
+              << m_inLayer << ", layer " << m_currentLayer << std::endl;
+
+    if (!m_inLayer) {
+        std::cerr << "WARNING: SV-XML: Measurement found outside layer" << std::endl;
+        return false;
+    }
+
+    m_currentLayer->addMeasurementRect(attributes);
+    return true;
+}
+
 SVFileReaderPaneCallback::~SVFileReaderPaneCallback()
 {
 }
--- a/document/SVFileReader.h	Thu Jun 14 15:20:49 2007 +0000
+++ b/document/SVFileReader.h	Tue Jun 26 12:27:47 2007 +0000
@@ -196,6 +196,7 @@
     bool readPlayParameters(const QXmlAttributes &);
     bool readPlugin(const QXmlAttributes &);
     bool readSelection(const QXmlAttributes &);
+    bool readMeasurement(const QXmlAttributes &);
     void addUnaddedModels();
 
     Document *m_document;
@@ -206,6 +207,7 @@
     std::map<int, Model *> m_models;
     std::set<Model *> m_addedModels;
     std::map<int, int> m_awaitingDatasets; // map dataset id -> model id
+    Layer *m_currentLayer;
     Model *m_currentDataset;
     Model *m_currentDerivedModel;
     int m_currentDerivedModelId;
@@ -216,6 +218,7 @@
     QString m_currentTransformConfiguration;
     QString m_datasetSeparator;
     bool m_inRow;
+    bool m_inLayer;
     bool m_inView;
     bool m_inData;
     bool m_inSelections;