diff transform/FeatureExtractionModelTransformer.cpp @ 454:ba7aaacb7211

* Support transforms that output regions with more than one bin (by creating more than one region) * When model displayed in the spreadsheet dialog is deleted, close the dialog in preference to crashing
author Chris Cannam
date Thu, 09 Oct 2008 13:13:33 +0000
parents 3c5252e7cefd
children 6d45f77e63ee
line wrap: on
line diff
--- a/transform/FeatureExtractionModelTransformer.cpp	Thu Oct 09 12:22:02 2008 +0000
+++ b/transform/FeatureExtractionModelTransformer.cpp	Thu Oct 09 13:13:33 2008 +0000
@@ -633,15 +633,21 @@
 	
     } else if (isOutput<SparseTimeValueModel>()) {
 
-	float value = 0.0;
-	if (feature.values.size() > 0) value = feature.values[0];
-
 	SparseTimeValueModel *model =
             getConformingOutput<SparseTimeValueModel>();
 	if (!model) return;
 
-	model->addPoint(SparseTimeValueModel::Point
-                        (frame, value, feature.label.c_str()));
+        for (int i = 0; i < feature.values.size(); ++i) {
+
+            float value = feature.values[i];
+
+            QString label = feature.label.c_str();
+            if (feature.values.size() > 1) {
+                label = QString("[%1] %2").arg(i+1).arg(label);
+            }
+
+            model->addPoint(SparseTimeValueModel::Point(frame, value, label));
+        }
 
     } else if (isOutput<NoteModel>() || isOutput<RegionModel>()) {
 
@@ -678,11 +684,29 @@
                                              feature.label.c_str()));
         } else {
             RegionModel *model = getConformingOutput<RegionModel>();
-            if (model) {
+            if (!model) return;
+
+            if (feature.hasDuration) {
+
+                for (int i = 0; i < feature.values.size(); ++i) {
+
+                    float value = feature.values[i];
+
+                    QString label = feature.label.c_str();
+                    if (feature.values.size() > 1) {
+                        label = QString("[%1] %2").arg(i+1).arg(label);
+                    }
+
+                    model->addPoint(RegionModel::Point(frame, value,
+                                                       lrintf(duration),
+                                                       label));
+                }
+            } else {
+            
                 model->addPoint(RegionModel::Point(frame, value,
                                                    lrintf(duration),
                                                    feature.label.c_str()));
-            } else return;
+            }
         }
 	
     } else if (isOutput<EditableDenseThreeDimensionalModel>()) {