diff main/MainWindow.cpp @ 895:509b4649b172

Quick hack at a multiplex option for transform input (see #1108)
author Chris Cannam
date Thu, 04 Dec 2014 14:48:19 +0000
parents c62c3e4825ee
children 35ce47084c84
line wrap: on
line diff
--- a/main/MainWindow.cpp	Tue Dec 02 17:53:17 2014 +0000
+++ b/main/MainWindow.cpp	Thu Dec 04 14:48:19 2014 +0000
@@ -24,6 +24,7 @@
 #include "data/model/SparseOneDimensionalModel.h"
 #include "data/model/RangeSummarisableTimeValueModel.h"
 #include "data/model/NoteModel.h"
+#include "data/model/AggregateWaveModel.h"
 #include "data/model/Labeller.h"
 #include "data/osc/OSCQueue.h"
 #include "framework/Document.h"
@@ -3705,22 +3706,46 @@
         m_document->getTransformInputModels();
 
     Model *defaultInputModel = 0;
+
     for (int j = 0; j < pane->getLayerCount(); ++j) {
+
         Layer *layer = pane->getLayer(j);
         if (!layer) continue;
+
         if (LayerFactory::getInstance()->getLayerType(layer) !=
             LayerFactory::Waveform &&
             !layer->isLayerOpaque()) continue;
+
         Model *model = layer->getModel();
         if (!model) continue;
+
         for (size_t k = 0; k < candidateInputModels.size(); ++k) {
             if (candidateInputModels[k] == model) {
                 defaultInputModel = model;
                 break;
             }
         }
+
         if (defaultInputModel) break;
     }
+
+    if (candidateInputModels.size() > 1) {
+        // Add an aggregate model as another option
+        AggregateWaveModel::ChannelSpecList sl;
+        foreach (Model *m, candidateInputModels) {
+            RangeSummarisableTimeValueModel *r =
+                qobject_cast<RangeSummarisableTimeValueModel *>(m);
+            if (r) {
+                sl.push_back(AggregateWaveModel::ModelChannelSpec(r, -1));
+            }
+        }
+        if (!sl.empty()) {
+            AggregateWaveModel *aggregate = new AggregateWaveModel(sl);
+            aggregate->setObjectName(tr("Multiplex all of the above"));
+            candidateInputModels.push_back(aggregate);
+            //!!! but it leaks
+        }
+    }
     
     int startFrame = 0, duration = 0;
     int endFrame = 0;