# HG changeset patch # User Chris Cannam # Date 1530714856 -3600 # Node ID 1d7921b1852fbee918c06795a5f90ed90dc6f476 # Parent 769d7890203b1984c7439d0c2aeaee074649de01 Ensure scale appears for layer when drawn in AutoAlign mode without any other layer present to align to diff -r 769d7890203b -r 1d7921b1852f layer/Layer.cpp --- a/layer/Layer.cpp Wed Jul 04 15:33:47 2018 +0100 +++ b/layer/Layer.cpp Wed Jul 04 15:34:16 2018 +0100 @@ -588,6 +588,31 @@ v->drawMeasurementRect(paint, this, r.pixrect.normalized(), focus); } +bool +Layer::valueExtentsMatchMine(LayerGeometryProvider *v) const +{ + double min, min_; + double max, max_; + bool logarithmic, logarithmic_; + QString unit; + + if (!getValueExtents(min_, max_, logarithmic_, unit)) { + return false; + } + + if (!v->getValueExtents(unit, min, max, logarithmic)) { + return false; + } + + if (min != min_ || + max != max_ || + logarithmic != logarithmic_) { + return false; + } + + return true; +} + void Layer::toXml(QTextStream &stream, QString indent, QString extraAttributes) const diff -r 769d7890203b -r 1d7921b1852f layer/Layer.h --- a/layer/Layer.h Wed Jul 04 15:33:47 2018 +0100 +++ b/layer/Layer.h Wed Jul 04 15:34:16 2018 +0100 @@ -626,6 +626,8 @@ void paintMeasurementRect(LayerGeometryProvider *v, QPainter &paint, const MeasureRect &r, bool focus) const; + bool valueExtentsMatchMine(LayerGeometryProvider *v) const; + QString m_presentationName; private: diff -r 769d7890203b -r 1d7921b1852f layer/NoteLayer.cpp --- a/layer/NoteLayer.cpp Wed Jul 04 15:33:47 2018 +0100 +++ b/layer/NoteLayer.cpp Wed Jul 04 15:34:16 2018 +0100 @@ -61,7 +61,7 @@ m_scaleMinimum(0), m_scaleMaximum(0) { - SVDEBUG << "constructed NoteLayer" << endl; + SVDEBUG << "constructed NoteLayer" << endl; } void @@ -833,14 +833,18 @@ int NoteLayer::getVerticalScaleWidth(LayerGeometryProvider *v, bool, QPainter &paint) const { - if (!m_model || shouldAutoAlign()) { + if (!m_model) { return 0; - } else { - if (m_verticalScale == LogScale || m_verticalScale == MIDIRangeScale) { - return LogNumericalScale().getWidth(v, paint) + 10; // for piano - } else { - return LinearNumericalScale().getWidth(v, paint); - } + } + + if (shouldAutoAlign() && !valueExtentsMatchMine(v)) { + return 0; + } + + if (m_verticalScale == LogScale || m_verticalScale == MIDIRangeScale) { + return LogNumericalScale().getWidth(v, paint) + 10; // for piano + } else { + return LinearNumericalScale().getWidth(v, paint); } } diff -r 769d7890203b -r 1d7921b1852f layer/SingleColourLayer.h --- a/layer/SingleColourLayer.h Wed Jul 04 15:33:47 2018 +0100 +++ b/layer/SingleColourLayer.h Wed Jul 04 15:34:16 2018 +0100 @@ -13,8 +13,8 @@ COPYING included with this distribution for more information. */ -#ifndef _SINGLE_COLOUR_LAYER_H_ -#define _SINGLE_COLOUR_LAYER_H_ +#ifndef SV_SINGLE_COLOUR_LAYER_H +#define SV_SINGLE_COLOUR_LAYER_H #include "Layer.h" #include diff -r 769d7890203b -r 1d7921b1852f layer/TimeValueLayer.cpp --- a/layer/TimeValueLayer.cpp Wed Jul 04 15:33:47 2018 +0100 +++ b/layer/TimeValueLayer.cpp Wed Jul 04 15:34:16 2018 +0100 @@ -1238,7 +1238,9 @@ int TimeValueLayer::getVerticalScaleWidth(LayerGeometryProvider *v, bool, QPainter &paint) const { - if (!m_model || shouldAutoAlign()) { + if (!m_model) { + return 0; + } else if (shouldAutoAlign() && !valueExtentsMatchMine(v)) { return 0; } else if (m_plotStyle == PlotSegmentation) { if (m_verticalScale == LogScale) { diff -r 769d7890203b -r 1d7921b1852f view/Pane.cpp --- a/view/Pane.cpp Wed Jul 04 15:33:47 2018 +0100 +++ b/view/Pane.cpp Wed Jul 04 15:34:16 2018 +0100 @@ -594,8 +594,6 @@ int sw = topLayer->getVerticalScaleWidth (this, m_manager->shouldShowVerticalColourScale(), paint); - -// cerr << "sw = " << sw << endl; if (sw > 0) { scaleLayer = topLayer;