diff framework/MainWindowBase.cpp @ 143:9ef382913c17

* Add ability to export a transform structure as RDF -- for use when exporting data from runner, so as to refer back to the generating transform from the audio features rdf * some improvements to pane & layer management when importing rdf, but it's all still a big hack here
author Chris Cannam
date Tue, 25 Nov 2008 17:46:02 +0000
parents 8b31cdd7e005
children 675443abbc05
line wrap: on
line diff
--- a/framework/MainWindowBase.cpp	Tue Nov 25 10:04:37 2008 +0000
+++ b/framework/MainWindowBase.cpp	Tue Nov 25 17:46:02 2008 +0000
@@ -1148,6 +1148,16 @@
             for (int i = 0; i < models.size(); ++i) {
                 Layer *newLayer = m_document->createImportedLayer(models[i]);
                 if (newLayer) {
+                    if (newLayer->isLayerOpaque() ||
+                        dynamic_cast<Colour3DPlotLayer *>(newLayer)) {
+                        //!!! general garbage.  we should be using
+                        // a separate loader class that uses callbacks
+                        // and directly calls on the document, much
+                        // more like SVFileReader
+                        AddPaneCommand *command = new AddPaneCommand(this);
+                        CommandHistory::getInstance()->addCommand(command);
+                        pane = command->getPane();
+                    }
                     m_document->addLayerToView(pane, newLayer);
                 }
             }
@@ -1446,38 +1456,44 @@
         rate = m_playSource->getSourceSampleRate();
     }
 
-    WaveFileModel *newModel = new WaveFileModel(audioUrl, rate);
-
-    if (!newModel->isOK()) {
-        delete newModel;
-        std::cerr << "MainWindowBase::openSessionFromRDF: Cannot open audio URL \"" << audioUrl.toStdString() << "\" referred to in RDF, can't open a session without audio" << std::endl;
-        return FileOpenFailed;
+    {
+        ProgressDialog dialog(tr("Importing from RDF..."), true, 2000, this);
+        connect(&dialog, SIGNAL(showing()), this, SIGNAL(hideSplash()));
+
+        FileSource audioSource(audioUrl, &dialog);
+        if (!audioSource.isAvailable()) {
+            std::cerr << "MainWindowBase::openSessionFromRDF: Cannot open audio URL \"" << audioUrl.toStdString() << "\" referred to in RDF, can't open a session without audio" << std::endl;
+            return FileOpenFailed;
+        }
+
+        if (!checkSaveModified()) {
+            return FileOpenCancelled;
+        }
+
+        closeSession();
+        createDocument();
+
+        audioSource.waitForData();
+
+        WaveFileModel *newModel = new WaveFileModel(audioSource); 
+
+        m_viewManager->clearSelections();
+    
+        AddPaneCommand *command = new AddPaneCommand(this);
+        CommandHistory::getInstance()->addCommand(command);
+    
+        Pane *pane = command->getPane();
+      
+        if (m_timeRulerLayer) {
+            m_document->addLayerToView(pane, m_timeRulerLayer);
+        }
+    
+        Layer *newLayer = m_document->createMainModelLayer(LayerFactory::Waveform);
+        m_document->addLayerToView(pane, newLayer);
+
+        m_document->setMainModel(newModel);
     }
 
-    if (!checkSaveModified()) {
-        delete newModel;
-        return FileOpenCancelled;
-    }
-
-    closeSession();
-    createDocument();
-
-    m_viewManager->clearSelections();
-
-    AddPaneCommand *command = new AddPaneCommand(this);
-    CommandHistory::getInstance()->addCommand(command);
-    
-    Pane *pane = command->getPane();
-        
-    if (m_timeRulerLayer) {
-        m_document->addLayerToView(pane, m_timeRulerLayer);
-    }
-    
-    Layer *newLayer = m_document->createMainModelLayer(LayerFactory::Waveform);
-    m_document->addLayerToView(pane, newLayer);
-
-    m_document->setMainModel(newModel);
-
     FileOpenStatus layerStatus = openLayer(source);
 
     setupMenus();