# HG changeset patch # User Chris Cannam # Date 1373993941 -3600 # Node ID 47735c9518e711aa1252a5550e3e9a839bb8dfbc # Parent 123ebecd12e699aa607cd13d8ae2efad74b74fd2# Parent d52751e2728b3e714b31d7ff17d95035d1e4b706 Merge from default branch diff -r 123ebecd12e6 -r 47735c9518e7 layer/FlexiNoteLayer.cpp --- a/layer/FlexiNoteLayer.cpp Tue Jul 16 14:45:55 2013 +0100 +++ b/layer/FlexiNoteLayer.cpp Tue Jul 16 17:59:01 2013 +0100 @@ -249,6 +249,10 @@ max = Pitch::getFrequencyForPitch(lrintf(max + 1)); } +#ifdef DEBUG_NOTE_LAYER + std::cerr << "NoteLayer::getDisplayExtents: min = " << min << ", max = " << max << " (m_scaleMinimum = " << m_scaleMinimum << ", m_scaleMaximum = " << m_scaleMaximum << ")" << std::endl; +#endif + return true; } @@ -268,7 +272,9 @@ m_scaleMinimum = min; m_scaleMaximum = max; -// SVDEBUG << "FlexiNoteLayer::setDisplayExtents: min = " << min << ", max = " << max << endl; +#ifdef DEBUG_NOTE_LAYER + std::cerr << "FlexiNoteLayer::setDisplayExtents: min = " << min << ", max = " << max << std::endl; +#endif emit layerParametersChanged(); return true; @@ -349,7 +355,9 @@ newmax = max; } - SVDEBUG << "FlexiNoteLayer::setVerticalZoomStep: " << step << ": " << newmin << " -> " << newmax << " (range " << newdist << ")" << endl; +#ifdef DEBUG_NOTE_LAYER + std::cerr << "FlexiNoteLayer::setVerticalZoomStep: " << step << ": " << newmin << " -> " << newmax << " (range " << newdist << ")" << std::endl; +#endif setDisplayExtents(newmin, newmax); } @@ -1579,7 +1587,7 @@ float min = attributes.value("scaleMinimum").toFloat(&ok); float max = attributes.value("scaleMaximum").toFloat(&alsoOk); - // if (ok && alsoOk) setDisplayExtents(min, max); +// if (ok && alsoOk && min != max) setDisplayExtents(min, max); } void diff -r 123ebecd12e6 -r 47735c9518e7 layer/NoteLayer.cpp --- a/layer/NoteLayer.cpp Tue Jul 16 14:45:55 2013 +0100 +++ b/layer/NoteLayer.cpp Tue Jul 16 17:59:01 2013 +0100 @@ -236,6 +236,10 @@ max = Pitch::getFrequencyForPitch(lrintf(max + 1)); } +#ifdef DEBUG_NOTE_LAYER + std::cerr << "NoteLayer::getDisplayExtents: min = " << min << ", max = " << max << " (m_scaleMinimum = " << m_scaleMinimum << ", m_scaleMaximum = " << m_scaleMaximum << ")" << std::endl; +#endif + return true; } @@ -255,7 +259,9 @@ m_scaleMinimum = min; m_scaleMaximum = max; -// SVDEBUG << "NoteLayer::setDisplayExtents: min = " << min << ", max = " << max << endl; +#ifdef DEBUG_NOTE_LAYER + std::cerr << "NoteLayer::setDisplayExtents: min = " << min << ", max = " << max << std::endl; +#endif emit layerParametersChanged(); return true; @@ -336,7 +342,9 @@ newmax = max; } - SVDEBUG << "NoteLayer::setVerticalZoomStep: " << step << ": " << newmin << " -> " << newmax << " (range " << newdist << ")" << endl; +#ifdef DEBUG_NOTE_LAYER + std::cerr << "NoteLayer::setVerticalZoomStep: " << step << ": " << newmin << " -> " << newmax << " (range " << newdist << ")" << std::endl; +#endif setDisplayExtents(newmin, newmax); } @@ -1278,7 +1286,7 @@ float min = attributes.value("scaleMinimum").toFloat(&ok); float max = attributes.value("scaleMaximum").toFloat(&alsoOk); - if (ok && alsoOk) setDisplayExtents(min, max); + if (ok && alsoOk && min != max) setDisplayExtents(min, max); } diff -r 123ebecd12e6 -r 47735c9518e7 layer/TimeValueLayer.cpp --- a/layer/TimeValueLayer.cpp Tue Jul 16 14:45:55 2013 +0100 +++ b/layer/TimeValueLayer.cpp Tue Jul 16 17:59:01 2013 +0100 @@ -320,10 +320,14 @@ bool &logarithmic, QString &unit) const { if (!m_model) return false; + min = m_model->getValueMinimum(); max = m_model->getValueMaximum(); + logarithmic = (m_verticalScale == LogScale); + unit = m_model->getScaleUnits(); + if (m_derivative) { max = std::max(fabsf(min), fabsf(max)); min = -max; @@ -333,6 +337,22 @@ std::cerr << "TimeValueLayer::getValueExtents: min = " << min << ", max = " << max << std::endl; #endif + if (!shouldAutoAlign() && !logarithmic && !m_derivative) { + + if (max == min) { + max = max + 0.5; + min = min - 0.5; + } else { + float margin = (max - min) / 10.0; + max = max + margin; + min = min - margin; + } + +#ifdef DEBUG_TIME_VALUE_LAYER + std::cerr << "TimeValueLayer::getValueExtents: min = " << min << ", max = " << max << " (after adjustment)" << std::endl; +#endif + } + return true; } @@ -342,8 +362,9 @@ if (!m_model || shouldAutoAlign()) return false; if (m_scaleMinimum == m_scaleMaximum) { - min = m_model->getValueMinimum(); - max = m_model->getValueMaximum(); + bool log; + QString unit; + getValueExtents(min, max, log, unit); } else { min = m_scaleMinimum; max = m_scaleMaximum; @@ -746,18 +767,13 @@ max = 0.0; log = false; - bool haveAutoAlignment = false; - if (shouldAutoAlign()) { if (!v->getValueExtents(m_model->getScaleUnits(), min, max, log)) { min = m_model->getValueMinimum(); max = m_model->getValueMaximum(); - } else { - haveAutoAlignment = true; - if (log) { - LogRange::mapRange(min, max); - } + } else if (log) { + LogRange::mapRange(min, max); } } else if (m_verticalScale == PlusMinusOneScale) { @@ -778,22 +794,6 @@ #ifdef DEBUG_TIME_VALUE_LAYER std::cerr << "TimeValueLayer::getScaleExtents: min = " << min << ", max = " << max << std::endl; #endif - - if (!haveAutoAlignment) { - - if (max == min) { - max = max + 0.5; - min = min - 0.5; - } else { - float margin = (max - min) / 10.0; - max = max + margin; - min = min - margin; - } - -#ifdef DEBUG_TIME_VALUE_LAYER - std::cerr << "TimeValueLayer::getScaleExtents: min = " << min << ", max = " << max << " (after adjustment)" << std::endl; -#endif - } } int