diff transform/ModelTransformerFactory.cpp @ 849:418cd2064769 tonioni_multi_transform

More on multi-transform stuff
author Chris Cannam
date Mon, 02 Dec 2013 11:17:24 +0000
parents 539740f231fa
children dba8a02b0413
line wrap: on
line diff
--- a/transform/ModelTransformerFactory.cpp	Fri Nov 29 15:43:50 2013 +0000
+++ b/transform/ModelTransformerFactory.cpp	Mon Dec 02 11:17:24 2013 +0000
@@ -230,6 +230,46 @@
     return model;
 }
 
+vector<Model *>
+ModelTransformerFactory::transformMultiple(const Transforms &transforms,
+                                           const ModelTransformer::Input &input,
+                                           QString &message) 
+{
+    SVDEBUG << "ModelTransformerFactory::transformMultiple: Constructing transformer with input model " << input.getModel() << endl;
+    
+    ModelTransformer *t = createTransformer(transforms, input);
+    if (!t) return 0;
+
+    connect(t, SIGNAL(finished()), this, SLOT(transformerFinished()));
+
+    m_runningTransformers.insert(t);
+
+    t->start();
+    Model *model = t->detachOutputModel();
+
+    if (model) {
+        QString imn = input.getModel()->objectName();
+        QString trn =
+            TransformFactory::getInstance()->getTransformFriendlyName
+            (transform.getIdentifier());
+        if (imn != "") {
+            if (trn != "") {
+                model->setObjectName(tr("%1: %2").arg(imn).arg(trn));
+            } else {
+                model->setObjectName(imn);
+            }
+        } else if (trn != "") {
+            model->setObjectName(trn);
+        }
+    } else {
+        t->wait();
+    }
+
+    message = t->getMessage();
+
+    return model;
+}
+
 void
 ModelTransformerFactory::transformerFinished()
 {