changeset 224:b5a2428f647b

* Merge from transforms branch -- switch over to using Transform object properly
author Chris Cannam
date Fri, 07 Dec 2007 16:47:31 +0000
parents a3011df6ddad
children d7ded015af32
files main/MainWindow.cpp main/OSCHandler.cpp
diffstat 2 files changed, 41 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/main/MainWindow.cpp	Fri Nov 30 17:31:09 2007 +0000
+++ b/main/MainWindow.cpp	Fri Dec 07 16:47:31 2007 +0000
@@ -911,7 +911,7 @@
     };
 
     std::vector<Model *> models;
-    if (m_document) models = m_document->getTransformerInputModels(); //!!! not well named for this!
+    if (m_document) models = m_document->getTransformInputModels();
     bool plural = (models.size() > 1);
     if (models.empty()) {
         models.push_back(getMainModel()); // probably 0
@@ -1184,7 +1184,7 @@
    }
 
     TransformList transforms =
-	TransformFactory::getInstance()->getAllTransforms();
+	TransformFactory::getInstance()->getAllTransformDescriptions();
 
     vector<QString> types =
         TransformFactory::getInstance()->getAllTransformTypes();
@@ -2734,7 +2734,7 @@
     if (suggestedModel) {
 
         // check its validity
-        std::vector<Model *> inputModels = m_document->getTransformerInputModels();
+        std::vector<Model *> inputModels = m_document->getTransformInputModels();
         for (size_t j = 0; j < inputModels.size(); ++j) {
             if (inputModels[j] == suggestedModel) {
                 model = suggestedModel;
@@ -2855,11 +2855,9 @@
 	return;
     }
 
-    TransformId transform = i->second;
-    ModelTransformerFactory *factory = ModelTransformerFactory::getInstance();
-
-    QString configurationXml;
-
+    //!!! want to do something like this, but it's not supported in
+    //ModelTransformerFactory yet
+    /*
     int channel = -1;
     // pick up the default channel from any existing layers on the same pane
     for (int j = 0; j < pane->getLayerCount(); ++j) {
@@ -2869,15 +2867,18 @@
 	    break;
 	}
     }
+    */
 
     // We always ask for configuration, even if the plugin isn't
     // supposed to be configurable, because we need to let the user
     // change the execution context (block size etc).
 
-    PluginTransformer::ExecutionContext context(channel);
+    QString transformId = i->second;
+    Transform transform = TransformFactory::getInstance()->
+        getDefaultTransformFor(transformId);
 
     std::vector<Model *> candidateInputModels =
-        m_document->getTransformerInputModels();
+        m_document->getTransformInputModels();
 
     Model *defaultInputModel = 0;
     for (int j = 0; j < pane->getLayerCount(); ++j) {
@@ -2900,29 +2901,25 @@
     if (endFrame > startFrame) duration = endFrame - startFrame;
     else startFrame = 0;
 
-    Model *inputModel = factory->getConfigurationForTransformer
+    ModelTransformer::Input input = ModelTransformerFactory::getInstance()->
+        getConfigurationForTransform
         (transform,
          candidateInputModels,
          defaultInputModel,
-         context,
-         configurationXml,
          m_playSource,
          startFrame,
          duration);
 
-    if (!inputModel) return;
-
-//    std::cerr << "MainWindow::addLayer: Input model is " << inputModel << " \"" << inputModel->objectName().toStdString() << "\"" << std::endl;
-
-    Layer *newLayer = m_document->createDerivedLayer(transform,
-                                                     inputModel,
-                                                     context,
-                                                     configurationXml);
+    if (!input.getModel()) return;
+
+//    std::cerr << "MainWindow::addLayer: Input model is " << input.getModel() << " \"" << input.getModel()->objectName().toStdString() << "\"" << std::endl;
+
+    Layer *newLayer = m_document->createDerivedLayer(transform, input);
 
     if (newLayer) {
         m_document->addLayerToView(pane, newLayer);
-        m_document->setChannel(newLayer, context.channel);
-        m_recentTransforms.add(transform);
+        m_document->setChannel(newLayer, input.getChannel());
+        m_recentTransforms.add(transformId);
         m_paneStack->setCurrentLayer(pane, newLayer);
     }
 
--- a/main/OSCHandler.cpp	Fri Nov 30 17:31:09 2007 +0000
+++ b/main/OSCHandler.cpp	Fri Dec 07 16:47:31 2007 +0000
@@ -1,3 +1,17 @@
+/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
+
+/*
+    Sonic Visualiser
+    An audio file viewer and annotation editor.
+    Centre for Digital Music, Queen Mary, University of London.
+    This file copyright 2006-2007 Chris Cannam and QMUL.
+    
+    This program is free software; you can redistribute it and/or
+    modify it under the terms of the GNU General Public License as
+    published by the Free Software Foundation; either version 2 of the
+    License, or (at your option) any later version.  See the file
+    COPYING included with this distribution for more information.
+*/
 
 #include "MainWindow.h"
 #include "data/osc/OSCQueue.h"
@@ -12,7 +26,7 @@
 #include "audioio/AudioCallbackPlayTarget.h"
 #include "framework/Document.h"
 #include "data/fileio/WavFileWriter.h"
-#include "plugin/transform/ModelTransformerFactory.h"
+#include "plugin/transform/TransformFactory.h"
 #include "widgets/Fader.h"
 #include "widgets/AudioDial.h"
 
@@ -482,18 +496,17 @@
             message.getArgCount() == 1 &&
             message.getArg(0).canConvert(QVariant::String)) {
 
-            TransformId transform = message.getArg(0).toString();
+            TransformId transformId = message.getArg(0).toString();
 
+	    Transform transform = TransformFactory::getInstance()->
+                getDefaultTransformFor(transformId);
+	    
             Layer *newLayer = m_document->createDerivedLayer
-                (transform,
-                 getMainModel(),
-                 ModelTransformerFactory::getInstance()->getDefaultContextForTransformer
-                 (transform, getMainModel()),
-                 "");
+                (transform, getMainModel());
 
             if (newLayer) {
                 m_document->addLayerToView(pane, newLayer);
-                m_recentTransforms.add(transform);
+                m_recentTransforms.add(transformId);
                 m_paneStack->setCurrentLayer(pane, newLayer);
             }
         }