changeset 79:19bf27e4fb29

* Replace crash with warning when a transform could not be automatically re-run * More sensible default paths for Vamp plugin lookup (at least on Linux and OS/X) * A start to making the y coords for time value layers etc align * Set sensible y coords for text labels in time instant and value layers
author Chris Cannam
date Thu, 13 Apr 2006 18:29:10 +0000
parents 967193b6c7aa
children d99d67a5b93a
files layer/Colour3DPlotLayer.h layer/NoteLayer.cpp layer/NoteLayer.h layer/SpectrogramLayer.cpp layer/SpectrogramLayer.h layer/TextLayer.cpp layer/TextLayer.h layer/TimeInstantLayer.cpp layer/TimeInstantLayer.h layer/TimeRulerLayer.h layer/TimeValueLayer.cpp layer/TimeValueLayer.h layer/WaveformLayer.cpp layer/WaveformLayer.h widgets/PaneStack.cpp
diffstat 15 files changed, 110 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/layer/Colour3DPlotLayer.h	Wed Apr 12 09:59:40 2006 +0000
+++ b/layer/Colour3DPlotLayer.h	Thu Apr 13 18:29:10 2006 +0000
@@ -64,6 +64,7 @@
 
     virtual int getCompletion() const { return m_model->getCompletion(); }
 
+    virtual bool getValueExtents(float &, float &, QString &) const { return false; }
 
 /*
     virtual PropertyList getProperties() const;
--- a/layer/NoteLayer.cpp	Wed Apr 12 09:59:40 2006 +0000
+++ b/layer/NoteLayer.cpp	Thu Apr 13 18:29:10 2006 +0000
@@ -181,6 +181,16 @@
     return !v->shouldIlluminateLocalFeatures(this, discard);
 }
 
+bool
+NoteLayer::getValueExtents(float &min, float &max, QString &unit) const
+{
+    if (!m_model) return false;
+    min = m_model->getValueMinimum();
+    max = m_model->getValueMaximum();
+    unit = m_model->getScaleUnits();
+    return true;
+}
+
 NoteModel::PointList
 NoteLayer::getLocalPoints(View *v, int x) const
 {
--- a/layer/NoteLayer.h	Wed Apr 12 09:59:40 2006 +0000
+++ b/layer/NoteLayer.h	Thu Apr 13 18:29:10 2006 +0000
@@ -86,6 +86,8 @@
 
     virtual int getCompletion() const { return m_model->getCompletion(); }
 
+    virtual bool getValueExtents(float &min, float &max, QString &unit) const;
+
     virtual QString toXmlString(QString indent = "",
 				QString extraAttributes = "") const;
 
--- a/layer/SpectrogramLayer.cpp	Wed Apr 12 09:59:40 2006 +0000
+++ b/layer/SpectrogramLayer.cpp	Thu Apr 13 18:29:10 2006 +0000
@@ -2092,6 +2092,15 @@
 }
 
 bool
+SpectrogramLayer::getValueExtents(float &min, float &max, QString &unit) const
+{
+    min = getEffectiveMinFrequency();
+    max = getEffectiveMaxFrequency();
+    unit = "Hz";
+    return true;
+}
+
+bool
 SpectrogramLayer::snapToFeatureFrame(View *v, int &frame,
 				     size_t &resolution,
 				     SnapType snap) const
--- a/layer/SpectrogramLayer.h	Wed Apr 12 09:59:40 2006 +0000
+++ b/layer/SpectrogramLayer.h	Thu Apr 13 18:29:10 2006 +0000
@@ -184,6 +184,8 @@
 
     virtual int getCompletion() const;
 
+    virtual bool getValueExtents(float &min, float &max, QString &unit) const;
+
     virtual QString toXmlString(QString indent = "",
 				QString extraAttributes = "") const;
 
--- a/layer/TextLayer.cpp	Wed Apr 12 09:59:40 2006 +0000
+++ b/layer/TextLayer.cpp	Thu Apr 13 18:29:10 2006 +0000
@@ -135,6 +135,12 @@
     }
 }
 
+bool
+TextLayer::getValueExtents(float &min, float &max, QString &unit) const
+{
+    return false;
+}
+
 void
 TextLayer::setBaseColour(QColor colour)
 {
--- a/layer/TextLayer.h	Wed Apr 12 09:59:40 2006 +0000
+++ b/layer/TextLayer.h	Thu Apr 13 18:29:10 2006 +0000
@@ -77,6 +77,8 @@
 
     virtual int getCompletion() const { return m_model->getCompletion(); }
 
+    virtual bool getValueExtents(float &min, float &max, QString &unit) const;
+
     virtual QString toXmlString(QString indent = "",
 				QString extraAttributes = "") const;
 
--- a/layer/TimeInstantLayer.cpp	Wed Apr 12 09:59:40 2006 +0000
+++ b/layer/TimeInstantLayer.cpp	Thu Apr 13 18:29:10 2006 +0000
@@ -385,7 +385,8 @@
     }
 	
     int prevX = -1;
-
+    int textY = v->getTextLabelHeight(this, paint);
+    
     for (SparseOneDimensionalModel::PointList::const_iterator i = points.begin();
 	 i != points.end(); ++i) {
 
@@ -463,9 +464,7 @@
 	    }
 
 	    if (good) {
-		paint.drawText(x + iw + 2,
-			       v->height() - paint.fontMetrics().height(),
-			       p.label);
+		paint.drawText(x + iw + 2, textY, p.label);
 	    }
 	}
 
--- a/layer/TimeInstantLayer.h	Wed Apr 12 09:59:40 2006 +0000
+++ b/layer/TimeInstantLayer.h	Thu Apr 13 18:29:10 2006 +0000
@@ -85,6 +85,12 @@
 
     virtual int getCompletion() const { return m_model->getCompletion(); }
 
+    virtual bool needsTextLabelHeight() const { return true; }
+
+    virtual bool getValueExtents(float &min, float &max, QString &unit) const {
+        return false;
+    }
+
     virtual QString toXmlString(QString indent = "",
 				QString extraAttributes = "") const;
 
--- a/layer/TimeRulerLayer.h	Wed Apr 12 09:59:40 2006 +0000
+++ b/layer/TimeRulerLayer.h	Thu Apr 13 18:29:10 2006 +0000
@@ -52,6 +52,10 @@
 					  int value) const;
     virtual void setProperty(const PropertyName &, int value);
 
+    virtual bool getValueExtents(float &min, float &max, QString &unit) const {
+        return false;
+    }
+
     virtual QString toXmlString(QString indent = "",
 				QString extraAttributes = "") const;
 
--- a/layer/TimeValueLayer.cpp	Wed Apr 12 09:59:40 2006 +0000
+++ b/layer/TimeValueLayer.cpp	Thu Apr 13 18:29:10 2006 +0000
@@ -216,6 +216,15 @@
     return !v->shouldIlluminateLocalFeatures(this, discard);
 }
 
+bool
+TimeValueLayer::getValueExtents(float &min, float &max, QString &unit) const
+{
+    min = m_model->getValueMinimum();
+    max = m_model->getValueMaximum();
+    unit = m_model->getScaleUnits();
+    return true;
+}
+
 SparseTimeValueModel::PointList
 TimeValueLayer::getLocalPoints(View *v, int x) const
 {
@@ -373,6 +382,17 @@
 int
 TimeValueLayer::getYForValue(View *v, float val) const
 {
+    float min = 0.0, max = 0.0;
+    int h = v->height();
+
+    if (!v->getValueExtents(m_model->getScaleUnits(), min, max)) {
+        min = m_model->getValueMinimum();
+        max = m_model->getValueMaximum();
+    }
+
+    if (max == min) max = min + 1.0;
+
+/*!!!
     float min = m_model->getValueMinimum();
     float max = m_model->getValueMaximum();
     if (max == min) max = min + 1.0;
@@ -401,6 +421,7 @@
         min = -1.0;
         max = 1.0;
     }
+*/
 
     return int(h - ((val - min) * h) / (max - min));
 }
@@ -492,6 +513,11 @@
 
     QPainterPath path;
     int pointCount = 0;
+
+    int textY = 0;
+    if (m_plotStyle == PlotSegmentation) {
+        textY = v->getTextLabelHeight(this, paint);
+    }
     
     for (SparseTimeValueModel::PointList::const_iterator i = points.begin();
 	 i != points.end(); ++i) {
@@ -501,6 +527,11 @@
 	int x = v->getXForFrame(p.frame);
 	int y = getYForValue(v, p.value);
 
+        if (m_plotStyle != PlotSegmentation) {
+            textY = y - paint.fontMetrics().height()
+                      + paint.fontMetrics().ascent();
+        }
+
 	bool haveNext = false;
 	int nx = v->getXForFrame(v->getModelsEndFrame());
 // m_model->getEndFrame());
@@ -576,8 +607,10 @@
 
 		if (m_plotStyle == PlotConnectedPoints) {
 		    
+                    paint.save();
 		    paint.setPen(brushColour);
 		    paint.drawLine(x + w, y, nx, ny);
+                    paint.restore();
 
 		} else if (m_plotStyle == PlotLines) {
 
@@ -626,7 +659,9 @@
 	}
 
 	if (p.label != "") {
-	    paint.drawText(x + 5, y - paint.fontMetrics().height() + paint.fontMetrics().ascent(), p.label);
+            if (!haveNext || nx > x + 6 + paint.fontMetrics().width(p.label)) {
+                paint.drawText(x + 5, textY, p.label);
+            }
 	}
     }
 
--- a/layer/TimeValueLayer.h	Wed Apr 12 09:59:40 2006 +0000
+++ b/layer/TimeValueLayer.h	Thu Apr 13 18:29:10 2006 +0000
@@ -102,6 +102,12 @@
 
     virtual int getCompletion() const { return m_model->getCompletion(); }
 
+    virtual bool needsTextLabelHeight() const {
+        return m_plotStyle == PlotSegmentation;
+    }
+
+    virtual bool getValueExtents(float &min, float &max, QString &unit) const;
+
     virtual QString toXmlString(QString indent = "",
 				QString extraAttributes = "") const;
 
--- a/layer/WaveformLayer.cpp	Wed Apr 12 09:59:40 2006 +0000
+++ b/layer/WaveformLayer.cpp	Thu Apr 13 18:29:10 2006 +0000
@@ -336,6 +336,23 @@
     return completion;
 }
 
+bool
+WaveformLayer::getValueExtents(float &min, float &max, QString &unit) const
+{
+    if (m_scale == LinearScale) {
+        min = 0.0;
+        max = 1.0;
+        unit = "V";
+    } else if (m_scale == MeterScale) {
+        return false; //!!!
+    } else {
+        min = AudioLevel::multiplier_to_dB(0.0);
+        max = AudioLevel::multiplier_to_dB(1.0);
+        unit = "dB";
+    }
+    return true;
+}
+
 int
 WaveformLayer::dBscale(float sample, int m) const
 {
--- a/layer/WaveformLayer.h	Wed Apr 12 09:59:40 2006 +0000
+++ b/layer/WaveformLayer.h	Thu Apr 13 18:29:10 2006 +0000
@@ -172,6 +172,8 @@
 
     virtual int getCompletion() const;
 
+    virtual bool getValueExtents(float &min, float &max, QString &unit) const;
+
     virtual QString toXmlString(QString indent = "",
 				QString extraAttributes = "") const;
 
--- a/widgets/PaneStack.cpp	Wed Apr 12 09:59:40 2006 +0000
+++ b/widgets/PaneStack.cpp	Thu Apr 13 18:29:10 2006 +0000
@@ -331,16 +331,16 @@
 
     for (size_t i = 0; i < m_panes.size(); ++i) {
 	if (!m_panes[i].propertyStack) continue;
-	std::cerr << "PaneStack::sizePropertyStacks: " << i << ": min " 
-		  << m_panes[i].propertyStack->minimumSizeHint().width() << ", current "
-		  << m_panes[i].propertyStack->width() << std::endl;
+//	std::cerr << "PaneStack::sizePropertyStacks: " << i << ": min " 
+//		  << m_panes[i].propertyStack->minimumSizeHint().width() << ", current "
+//		  << m_panes[i].propertyStack->width() << std::endl;
 
 	if (m_panes[i].propertyStack->minimumSizeHint().width() > maxMinWidth) {
 	    maxMinWidth = m_panes[i].propertyStack->minimumSizeHint().width();
 	}
     }
 
-    std::cerr << "PaneStack::sizePropertyStacks: max min width " << maxMinWidth << std::endl;
+//    std::cerr << "PaneStack::sizePropertyStacks: max min width " << maxMinWidth << std::endl;
 
 #ifdef Q_WS_MAC
     // This is necessary to compensate for cb->setMinimumSize(10, 10)