Mercurial > hg > svgui
changeset 445:4a14499fb184
* Save & reload vertical scale extents from note, time/value & colour 3d
plot layers
* Fix display of vertical scale in zoomed colour 3d plot layer
author | Chris Cannam |
---|---|
date | Wed, 12 Nov 2008 15:51:41 +0000 |
parents | e5800f4490c4 |
children | ae51d4b73860 |
files | layer/Colour3DPlotLayer.cpp layer/NoteLayer.cpp layer/TimeValueLayer.cpp |
diffstat | 3 files changed, 47 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/layer/Colour3DPlotLayer.cpp Wed Nov 12 15:17:16 2008 +0000 +++ b/layer/Colour3DPlotLayer.cpp Wed Nov 12 15:51:41 2008 +0000 @@ -362,7 +362,7 @@ { if (!m_model) return; - std::cerr << "Colour3DPlotLayer::setVerticalZoomStep(" <<step <<"): before: miny = " << m_miny << ", maxy = " << m_maxy << std::endl; +// std::cerr << "Colour3DPlotLayer::setVerticalZoomStep(" <<step <<"): before: miny = " << m_miny << ", maxy = " << m_maxy << std::endl; int dist = m_model->getHeight() - step; if (dist < 1) dist = 1; @@ -372,7 +372,7 @@ m_maxy = m_miny + dist; if (m_maxy > m_model->getHeight()) m_maxy = m_model->getHeight(); - std::cerr << "Colour3DPlotLayer::setVerticalZoomStep(" <<step <<"): after: miny = " << m_miny << ", maxy = " << m_maxy << std::endl; +// std::cerr << "Colour3DPlotLayer::setVerticalZoomStep(" <<step <<"): after: miny = " << m_miny << ", maxy = " << m_maxy << std::endl; emit layerParametersChanged(); } @@ -466,7 +466,6 @@ if (!m_model) return; int h = rect.height(), w = rect.width(); - float binHeight = float(v->height()) / m_model->getHeight(); int cw = getColourScaleWidth(paint); @@ -486,18 +485,31 @@ paint.setPen(v->getForeground()); + int sh = m_model->getHeight(); + + int symin = m_miny; + int symax = m_maxy; + if (symax <= symin) { + symin = 0; + symax = sh; + } + if (symin < 0) symin = 0; + if (symax > sh) symax = sh; + int count = v->height() / paint.fontMetrics().height(); - int step = m_model->getHeight() / count; + int step = (symax - symin) / count; if (step == 0) step = 1; - for (size_t i = 0; i < m_model->getHeight(); ++i) { + float binHeight = float(v->height()) / (symax - symin); + + for (size_t i = symin; i < symax; ++i) { size_t idx = i; if (m_invertVertical) idx = m_model->getHeight() - idx - 1; if ((idx % step) != 0) continue; - int y0 = int(v->height() - (i * binHeight) - 1); + int y0 = int(v->height() - ((i - symin) * binHeight) - 1); QString text = m_model->getBinName(idx); if (text == "") text = QString("[%1]").arg(idx + 1); @@ -957,11 +969,15 @@ QString s = QString("scale=\"%1\" " "colourScheme=\"%2\" " "normalizeColumns=\"%3\" " - "normalizeVisibleArea=\"%4\"") + "normalizeVisibleArea=\"%4\" " + "minY=\"%5\" " + "maxY=\"%6\" ") .arg((int)m_colourScale) .arg(m_colourMap) .arg(m_normalizeColumns ? "true" : "false") - .arg(m_normalizeVisibleArea ? "true" : "false"); + .arg(m_normalizeVisibleArea ? "true" : "false") + .arg(m_miny) + .arg(m_maxy); Layer::toXml(stream, indent, extraAttributes + " " + s); } @@ -969,7 +985,7 @@ void Colour3DPlotLayer::setProperties(const QXmlAttributes &attributes) { - bool ok = false; + bool ok = false, alsoOk = false; ColourScale scale = (ColourScale)attributes.value("scale").toInt(&ok); if (ok) setColourScale(scale); @@ -984,5 +1000,9 @@ bool normalizeVisibleArea = (attributes.value("normalizeVisibleArea").trimmed() == "true"); setNormalizeVisibleArea(normalizeVisibleArea); + + float min = attributes.value("minY").toFloat(&ok); + float max = attributes.value("maxY").toFloat(&alsoOk); + if (ok && alsoOk) setDisplayExtents(min, max); }
--- a/layer/NoteLayer.cpp Wed Nov 12 15:17:16 2008 +0000 +++ b/layer/NoteLayer.cpp Wed Nov 12 15:51:41 2008 +0000 @@ -1170,8 +1170,10 @@ QString indent, QString extraAttributes) const { SingleColourLayer::toXml(stream, indent, extraAttributes + - QString(" verticalScale=\"%1\"") - .arg(m_verticalScale)); + QString(" verticalScale=\"%1\" scaleMinimum=\"%2\" scaleMaximum=\"%3\" ") + .arg(m_verticalScale) + .arg(m_scaleMinimum) + .arg(m_scaleMaximum)); } void @@ -1179,10 +1181,14 @@ { SingleColourLayer::setProperties(attributes); - bool ok; + bool ok, alsoOk; VerticalScale scale = (VerticalScale) attributes.value("verticalScale").toInt(&ok); if (ok) setVerticalScale(scale); + + float min = attributes.value("scaleMinimum").toFloat(&ok); + float max = attributes.value("scaleMaximum").toFloat(&alsoOk); + if (ok && alsoOk) setDisplayExtents(min, max); }
--- a/layer/TimeValueLayer.cpp Wed Nov 12 15:17:16 2008 +0000 +++ b/layer/TimeValueLayer.cpp Wed Nov 12 15:51:41 2008 +0000 @@ -1616,10 +1616,12 @@ { SingleColourLayer::toXml(stream, indent, extraAttributes + - QString(" colourMap=\"%1\" plotStyle=\"%2\" verticalScale=\"%3\"") + QString(" colourMap=\"%1\" plotStyle=\"%2\" verticalScale=\"%3\" scaleMinimum=\"%4\" scaleMaximum=\"%5\" ") .arg(m_colourMap) .arg(m_plotStyle) - .arg(m_verticalScale)); + .arg(m_verticalScale) + .arg(m_scaleMinimum) + .arg(m_scaleMaximum)); } void @@ -1627,7 +1629,7 @@ { SingleColourLayer::setProperties(attributes); - bool ok; + bool ok, alsoOk; int cmap = attributes.value("colourMap").toInt(&ok); if (ok) setFillColourMap(cmap); @@ -1639,5 +1641,9 @@ VerticalScale scale = (VerticalScale) attributes.value("verticalScale").toInt(&ok); if (ok) setVerticalScale(scale); + + float min = attributes.value("scaleMinimum").toFloat(&ok); + float max = attributes.value("scaleMaximum").toFloat(&alsoOk); + if (ok && alsoOk) setDisplayExtents(min, max); }