Mercurial > hg > svgui
diff layer/TimeValueLayer.cpp @ 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 | 45ba0b381c5d |
children | 01f27a282c90 |
line wrap: on
line diff
--- 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); + } } }