Mercurial > hg > svgui
diff view/View.cpp @ 362:a9dfa2d6d5ac
* Add pitch range in octaves, semitones and cents to the measurement rect
as well as in Hz
* Avoid crash when adding time ruler
This commit contains a lot of debug output (will be slow)
author | Chris Cannam |
---|---|
date | Wed, 06 Feb 2008 16:21:29 +0000 |
parents | 020c485aa7e0 |
children | 6167a28d25fc |
line wrap: on
line diff
--- a/view/View.cpp Wed Feb 06 14:25:46 2008 +0000 +++ b/view/View.cpp Wed Feb 06 16:21:29 2008 +0000 @@ -1910,6 +1910,8 @@ int labelCount = 0; + // top-left point, x-coord + if ((b0 = topLayer->getXScaleValue(this, r.x(), v0, u0))) { axs = QString("%1 %2").arg(v0).arg(u0); if (u0 == "Hz" && Pitch::isFrequencyInMidiRange(v0)) { @@ -1919,6 +1921,8 @@ aw = paint.fontMetrics().width(axs); ++labelCount; } + + // bottom-right point, x-coord if (r.width() > 0) { if ((b1 = topLayer->getXScaleValue(this, r.x() + r.width(), v1, u1))) { @@ -1930,15 +1934,19 @@ bw = paint.fontMetrics().width(bxs); } } + + // dimension, width if (b0 && b1 && v1 != v0 && u0 == u1) { - dxs = QString("(%1 %2)").arg(fabs(v1 - v0)).arg(u1); + dxs = QString("[%1 %2]").arg(fabs(v1 - v0)).arg(u1); dw = paint.fontMetrics().width(dxs); } b0 = false; b1 = false; + // top-left point, y-coord + if ((b0 = topLayer->getYScaleValue(this, r.y(), v0, u0))) { ays = QString("%1 %2").arg(v0).arg(u0); if (u0 == "Hz" && Pitch::isFrequencyInMidiRange(v0)) { @@ -1949,6 +1957,8 @@ ++labelCount; } + // bottom-right point, y-coord + if (r.height() > 0) { if ((b1 = topLayer->getYScaleValue(this, r.y() + r.height(), v1, u1))) { bys = QString("%1 %2").arg(v1).arg(u1); @@ -1964,13 +1974,24 @@ float dy = 0.f; QString du; + // dimension, height + if ((bd = topLayer->getYScaleDifference(this, r.y(), r.y() + r.height(), dy, du)) && dy != 0) { if (du != "") { - dys = QString("(%1 %2)").arg(dy).arg(du); + if (du == "Hz") { + int semis; + float cents; + semis = Pitch::getPitchForFrequencyDifference(v0, v1, ¢s); + dys = QString("[%1 %2 (%3)]") + .arg(dy).arg(du) + .arg(Pitch::getLabelForPitchRange(semis, cents)); + } else { + dys = QString("[%1 %2]").arg(dy).arg(du); + } } else { - dys = QString("(%1)").arg(dy); + dys = QString("[%1]").arg(dy); } dw = std::max(dw, paint.fontMetrics().width(dys)); }