Mercurial > hg > svgui
diff layer/TimeValueLayer.cpp @ 664:62330d542e1d
Do not pad edges of scale extent when auto-aligning to another layer
author | Chris Cannam |
---|---|
date | Tue, 16 Jul 2013 13:22:31 +0100 |
parents | c6d705bf1672 |
children | ab9fefdaa103 |
line wrap: on
line diff
--- a/layer/TimeValueLayer.cpp Thu May 16 15:00:20 2013 +0100 +++ b/layer/TimeValueLayer.cpp Tue Jul 16 13:22:31 2013 +0100 @@ -746,13 +746,18 @@ 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 if (log) { - LogRange::mapRange(min, max); + } else { + haveAutoAlignment = true; + if (log) { + LogRange::mapRange(min, max); + } } } else if (m_verticalScale == PlusMinusOneScale) { @@ -774,18 +779,21 @@ std::cerr << "TimeValueLayer::getScaleExtents: min = " << min << ", max = " << max << std::endl; #endif - if (max == min) { - max = max + 0.5; - min = min - 0.5; - } else { - float margin = (max - min) / 10.0; - max = max + margin; - min = min - margin; - } + 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; + std::cerr << "TimeValueLayer::getScaleExtents: min = " << min << ", max = " << max << " (after adjustment)" << std::endl; #endif + } } int