diff document/SVFileReader.cpp @ 167:567df8af372c

* Fix failure to auto-calculate bounds on time-value or note model loaded from session file if min and max not specified in the model * Attempt to work out why some points in time-value layer are not being locally illuminated when expected, and why models are loaded from sv file without their names -- both failed so far...
author Chris Cannam
date Thu, 12 Jul 2007 21:10:43 +0000
parents f6ce5febc07f
children 102317ae3970
line wrap: on
line diff
--- a/document/SVFileReader.cpp	Thu Jul 12 16:14:59 2007 +0000
+++ b/document/SVFileReader.cpp	Thu Jul 12 21:10:43 2007 +0000
@@ -396,6 +396,8 @@
 
     QString name = attributes.value("name");
 
+    std::cerr << "SVFileReader::readModel: model name \"" << name.toStdString() << "\"" << std::endl;
+
     READ_MANDATORY(int, sampleRate, toInt);
 
     QString type = attributes.value("type").trimmed();
@@ -435,6 +437,7 @@
 
         if (!model) return false;
 
+        model->setObjectName(name);
 	m_models[id] = model;
 	if (mainModel) {
 	    m_document->setMainModel(model);
@@ -472,6 +475,7 @@
 	    int dataset = attributes.value("dataset").trimmed().toInt(&ok);
 	    if (ok) m_awaitingDatasets[dataset] = id;
 
+            model->setObjectName(name);
 	    m_models[id] = model;
 	    return true;
 
@@ -490,6 +494,7 @@
 
 	    SparseOneDimensionalModel *model = new SparseOneDimensionalModel
 		(sampleRate, resolution);
+            model->setObjectName(name);
 	    m_models[id] = model;
 
 	    int dataset = attributes.value("dataset").trimmed().toInt(&ok);
@@ -501,8 +506,12 @@
 	    
 	    READ_MANDATORY(int, resolution, toInt);
 
+            bool haveMinMax = true;
 	    float minimum = attributes.value("minimum").trimmed().toFloat(&ok);
+            if (!ok) haveMinMax = false;
 	    float maximum = attributes.value("maximum").trimmed().toFloat(&ok);
+            if (!ok) haveMinMax = false;
+
 	    float valueQuantization =
 		attributes.value("valueQuantization").trimmed().toFloat(&ok);
 
@@ -514,18 +523,33 @@
 		if (attributes.value("subtype") == "text") {
 		    TextModel *model = new TextModel
 			(sampleRate, resolution, notifyOnAdd);
+                    model->setObjectName(name);
 		    m_models[id] = model;
 		} else {
-		    SparseTimeValueModel *model = new SparseTimeValueModel
-			(sampleRate, resolution, minimum, maximum, notifyOnAdd);
+		    SparseTimeValueModel *model;
+                    if (haveMinMax) {
+                        model = new SparseTimeValueModel
+                            (sampleRate, resolution, minimum, maximum, notifyOnAdd);
+                    } else {
+                        model = new SparseTimeValueModel
+                            (sampleRate, resolution, notifyOnAdd);
+                    }
                     model->setScaleUnits(units);
+                    model->setObjectName(name);
 		    m_models[id] = model;
 		}
 	    } else {
-		NoteModel *model = new NoteModel
-		    (sampleRate, resolution, minimum, maximum, notifyOnAdd);
+		NoteModel *model;
+                if (haveMinMax) {
+                    model = new NoteModel
+                        (sampleRate, resolution, minimum, maximum, notifyOnAdd);
+                } else {
+                    model = new NoteModel
+                        (sampleRate, resolution, notifyOnAdd);
+                }
 		model->setValueQuantization(valueQuantization);
                 model->setScaleUnits(units);
+                model->setObjectName(name);
 		m_models[id] = model;
 	    }