changeset 78:58bfaaed07ed

* Part of #1877436 transform fails to re-run when file loaded at different rate
author Chris Cannam
date Wed, 23 Jan 2008 18:09:50 +0000
parents 0535c49069ba
children b1a68403714b
files framework/Document.cpp framework/Document.h framework/MainWindowBase.cpp framework/MainWindowBase.h framework/SVFileReader.cpp
diffstat 5 files changed, 51 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/framework/Document.cpp	Wed Jan 23 15:43:27 2008 +0000
+++ b/framework/Document.cpp	Wed Jan 23 18:09:50 2008 +0000
@@ -205,11 +205,13 @@
 Document::createDerivedLayer(const Transform &transform,
                              const ModelTransformer::Input &input)
 {
-    Model *newModel = addDerivedModel(transform, input);
+    QString message;
+    Model *newModel = addDerivedModel(transform, input, message);
     if (!newModel) {
-        // error already printed to stderr by addDerivedModel
-        emit modelGenerationFailed(transform.getIdentifier());
+        emit modelGenerationFailed(transform.getIdentifier(), message);
         return 0;
+    } else if (message != "") {
+        emit modelGenerationWarning(transform.getIdentifier(), message);
     }
 
     LayerFactory::LayerTypeSet types =
@@ -317,11 +319,12 @@
             //!!! We have a problem here if the number of channels in
             //the main model has changed.
 
+            QString message;
 	    Model *replacementModel =
                 addDerivedModel(transform,
                                 ModelTransformer::Input
-                                (m_mainModel,
-                                 m_models[model].channel));
+                                (m_mainModel, m_models[model].channel),
+                                message);
 	    
 	    if (!replacementModel) {
 		std::cerr << "WARNING: Document::setMainModel: Failed to regenerate model for transform \""
@@ -329,11 +332,17 @@
                 if (failedTransformers.find(transformId)
                     == failedTransformers.end()) {
                     emit modelRegenerationFailed(layer->objectName(),
-                                                 transformId);
+                                                 transformId,
+                                                 message);
                     failedTransformers.insert(transformId);
                 }
 		obsoleteLayers.push_back(layer);
 	    } else {
+                if (message != "") {
+                    emit modelRegenerationWarning(layer->objectName(),
+                                                  transformId,
+                                                  message);
+                }
 #ifdef DEBUG_DOCUMENT
                 std::cerr << "Replacing model " << model << " (type "
                           << typeid(*model).name() << ") with model "
@@ -428,7 +437,8 @@
 
 Model *
 Document::addDerivedModel(const Transform &transform,
-                          const ModelTransformer::Input &input)
+                          const ModelTransformer::Input &input,
+                          QString &message)
 {
     Model *model = 0;
 
@@ -440,7 +450,8 @@
 	}
     }
 
-    model = ModelTransformerFactory::getInstance()->transform(transform, input);
+    model = ModelTransformerFactory::getInstance()->transform
+        (transform, input, message);
 
     if (!model) {
 	std::cerr << "WARNING: Document::addDerivedModel: no output model for transform " << transform.getIdentifier().toStdString() << std::endl;
@@ -787,11 +798,12 @@
 
     ModelTransformerFactory *mtf = ModelTransformerFactory::getInstance();
 
-    Model *transformOutput = mtf->transform(transform, aggregate);
+    QString message;
+    Model *transformOutput = mtf->transform(transform, aggregate, message);
 
     if (!transformOutput) {
         transform.setStepSize(0);
-        transformOutput = mtf->transform(transform, aggregate);
+        transformOutput = mtf->transform(transform, aggregate, message);
     }
 
     SparseTimeValueModel *path = dynamic_cast<SparseTimeValueModel *>
@@ -799,6 +811,7 @@
 
     if (!path) {
         std::cerr << "Document::alignModel: ERROR: Failed to create alignment path (no MATCH plugin?)" << std::endl;
+        emit alignmentFailed(id, message);
         delete transformOutput;
         delete aggregate;
         return;
--- a/framework/Document.h	Wed Jan 23 15:43:27 2008 +0000
+++ b/framework/Document.h	Wed Jan 23 18:09:50 2008 +0000
@@ -150,7 +150,8 @@
      * running the transform and returning the resulting model.
      */
     Model *addDerivedModel(const Transform &transform,
-                           const ModelTransformer::Input &input);
+                           const ModelTransformer::Input &input,
+                           QString &returnedMessage);
 
     /**
      * Add a derived model associated with the given transform.  This
@@ -227,8 +228,13 @@
     void mainModelChanged(WaveFileModel *); // emitted after modelAdded
     void modelAboutToBeDeleted(Model *);
 
-    void modelGenerationFailed(QString transformName);
-    void modelRegenerationFailed(QString layerName, QString transformName);
+    void modelGenerationFailed(QString transformName, QString message);
+    void modelGenerationWarning(QString transformName, QString message);
+    void modelRegenerationFailed(QString layerName, QString transformName,
+                                 QString message);
+    void modelRegenerationWarning(QString layerName, QString transformName,
+                                  QString message);
+    void alignmentFailed(QString transformName, QString message);
 
 protected:
     void releaseModel(Model *model);
--- a/framework/MainWindowBase.cpp	Wed Jan 23 15:43:27 2008 +0000
+++ b/framework/MainWindowBase.cpp	Wed Jan 23 18:09:50 2008 +0000
@@ -1312,10 +1312,16 @@
     connect(m_document, SIGNAL(modelAboutToBeDeleted(Model *)),
 	    this, SLOT(modelAboutToBeDeleted(Model *)));
 
-    connect(m_document, SIGNAL(modelGenerationFailed(QString)),
-            this, SLOT(modelGenerationFailed(QString)));
-    connect(m_document, SIGNAL(modelRegenerationFailed(QString, QString)),
-            this, SLOT(modelRegenerationFailed(QString, QString)));
+    connect(m_document, SIGNAL(modelGenerationFailed(QString, QString)),
+            this, SLOT(modelGenerationFailed(QString, QString)));
+    connect(m_document, SIGNAL(modelRegenerationWarning(QString, QString, QString)),
+            this, SLOT(modelRegenerationWarning(QString, QString, QString)));
+    connect(m_document, SIGNAL(modelGenerationFailed(QString, QString)),
+            this, SLOT(modelGenerationFailed(QString, QString)));
+    connect(m_document, SIGNAL(modelRegenerationWarning(QString, QString, QString)),
+            this, SLOT(modelRegenerationWarning(QString, QString, QString)));
+    connect(m_document, SIGNAL(alignmentFailed(QString, QString)),
+            this, SLOT(alignmentFailed(QString, QString)));
 }
 
 bool
--- a/framework/MainWindowBase.h	Wed Jan 23 15:43:27 2008 +0000
+++ b/framework/MainWindowBase.h	Wed Jan 23 18:09:50 2008 +0000
@@ -222,8 +222,11 @@
     virtual void updateMenuStates();
     virtual void updateDescriptionLabel() = 0;
 
-    virtual void modelGenerationFailed(QString) = 0;
-    virtual void modelRegenerationFailed(QString, QString) = 0;
+    virtual void modelGenerationFailed(QString, QString) = 0;
+    virtual void modelGenerationWarning(QString, QString) = 0;
+    virtual void modelRegenerationFailed(QString, QString, QString) = 0;
+    virtual void modelRegenerationWarning(QString, QString, QString) = 0;
+    virtual void alignmentFailed(QString, QString) = 0;
 
     virtual void rightButtonMenuRequested(Pane *, QPoint point) = 0;
 
--- a/framework/SVFileReader.cpp	Wed Jan 23 15:43:27 2008 +0000
+++ b/framework/SVFileReader.cpp	Wed Jan 23 18:09:50 2008 +0000
@@ -301,11 +301,14 @@
                           << m_currentDerivedModelId
                           << " as target, not regenerating" << std::endl;
             } else {
+                QString message;
                 m_currentDerivedModel = m_models[m_currentDerivedModelId] =
                     m_document->addDerivedModel
                     (m_currentTransform,
                      ModelTransformer::Input(m_currentTransformSource,
-                                             m_currentTransformChannel));
+                                             m_currentTransformChannel),
+                     message);
+                //!!! do something with message
             }
         } else {
             m_document->addDerivedModel