diff view/View.cpp @ 301:5636eeacc467

* Merge from sv-match-alignment branch (excluding alignment-specific document). - add aggregate wave model (not yet complete enough to be added as a true model in a layer, but there's potential) - add play solo mode - add alignment model -- unused in plain SV - fix two plugin leaks - add m3u playlist support (opens all files at once, potentially hazardous) - fix retrieval of pre-encoded URLs - add ability to resample audio files on import, so as to match rates with other files previously loaded; add preference for same - add preliminary support in transform code for range and rate of transform input - reorganise preferences dialog, move dark-background option to preferences, add option for temporary directory location
author Chris Cannam
date Fri, 28 Sep 2007 13:56:38 +0000
parents 226cb289bdf4
children 1517c76cd678
line wrap: on
line diff
--- a/view/View.cpp	Thu Sep 06 15:17:35 2007 +0000
+++ b/view/View.cpp	Fri Sep 28 13:56:38 2007 +0000
@@ -20,9 +20,10 @@
 #include "base/Profiler.h"
 #include "base/Pitch.h"
 
-#include "layer/TimeRulerLayer.h" //!!! damn, shouldn't be including that here
+#include "layer/TimeRulerLayer.h"
 #include "layer/SingleColourLayer.h"
-#include "data/model/PowerOfSqrtTwoZoomConstraint.h" //!!! likewise
+#include "data/model/PowerOfSqrtTwoZoomConstraint.h"
+#include "data/model/RangeSummarisableTimeValueModel.h"
 
 #include <QPainter>
 #include <QPaintEvent>
@@ -801,6 +802,8 @@
 void
 View::modelCompletionChanged()
 {
+    std::cerr << "View(" << this << ")::modelCompletionChanged()" << std::endl;
+
     QObject *obj = sender();
     checkProgress(obj);
 }
@@ -877,6 +880,8 @@
 	if (sender() != m_manager) return;
     }
 
+    f = getAlignedPlaybackFrame();
+
     if (m_playPointerFrame == f) return;
     bool visible = (getXForFrame(m_playPointerFrame) != getXForFrame(f));
     size_t oldPlayPointerFrame = m_playPointerFrame;
@@ -1052,6 +1057,51 @@
     return 0;
 }
 
+int
+View::getAlignedPlaybackFrame() const
+{
+    if (!m_manager) return 0;
+    if (!m_manager->getPlaybackModel()) return m_manager->getPlaybackFrame();
+
+    RangeSummarisableTimeValueModel *waveformModel = 0;
+    for (LayerList::const_iterator i = m_layers.begin(); i != m_layers.end(); ++i) {
+
+        if (!*i) continue;
+        if (dynamic_cast<TimeRulerLayer *>(*i)) continue;
+
+        Model *model = (*i)->getModel();
+        if (!model) continue;
+
+        waveformModel = dynamic_cast<RangeSummarisableTimeValueModel *>(model);
+        if (!waveformModel) {
+            waveformModel = dynamic_cast<RangeSummarisableTimeValueModel *>
+                (model->getSourceModel());
+        }
+
+        if (waveformModel) break;
+    }
+
+    int pf = m_manager->getPlaybackFrame();
+
+    if (!waveformModel) return pf;
+
+    RangeSummarisableTimeValueModel *pm =
+        dynamic_cast<RangeSummarisableTimeValueModel *>
+        (m_manager->getPlaybackModel());
+
+//    std::cerr << "View[" << this << "]::getAlignedPlaybackFrame: pf = " << pf;
+
+    if (pm) {
+        pf = pm->alignFromReference(pf);
+//        std::cerr << " -> " << pf;
+    }
+
+    int af = waveformModel->alignToReference(pf);
+
+//    std::cerr << ", aligned = " << af << std::endl;
+    return af;
+}
+
 bool
 View::areLayersScrollable() const
 {
@@ -1232,6 +1282,21 @@
 	if (i->first == object) {
 
 	    int completion = i->first->getCompletion(this);
+            QString text = i->first->getPropertyContainerName();
+
+            if (completion >= 100) {
+
+                //!!!
+                Model *model = i->first->getModel();
+                RangeSummarisableTimeValueModel *wfm = 
+                    dynamic_cast<RangeSummarisableTimeValueModel *>(model);
+                if (wfm) {
+                    completion = wfm->getAlignmentCompletion();
+                    if (completion < 100) {
+                        text = tr("Alignment");
+                    }
+                }
+            }
 
 	    if (completion >= 100) {
 
@@ -1239,7 +1304,7 @@
 
 	    } else {
 
-		i->second->setText(i->first->getPropertyContainerName());
+		i->second->setText(text);
 
 		i->second->setValue(completion);
 		i->second->move(0, ph - i->second->height());