# HG changeset patch # User Chris Cannam # Date 1525786074 -3600 # Node ID 51e6125627fac189f3c57fcc4d960a0841a21380 # Parent 6e35062fc10ad4a16397f34e0a3597116c20280a Hack to ensure vertical scale lines are in the right place in pixel-doubling rendering diff -r 6e35062fc10a -r 51e6125627fa layer/SliceLayer.cpp --- a/layer/SliceLayer.cpp Tue May 08 14:07:22 2018 +0100 +++ b/layer/SliceLayer.cpp Tue May 08 14:27:54 2018 +0100 @@ -373,8 +373,11 @@ if (v->getViewManager() && v->getViewManager()->shouldShowScaleGuides()) { if (!m_scalePoints.empty()) { paint.setPen(QColor(240, 240, 240)); //!!! and dark background? + int ratio = int(round(double(v->getPaintHeight()) / + m_scalePaintHeight)); for (int i = 0; i < (int)m_scalePoints.size(); ++i) { - paint.drawLine(0, m_scalePoints[i], rect.width(), m_scalePoints[i]); + paint.drawLine(0, m_scalePoints[i] * ratio, + rect.width(), m_scalePoints[i] * ratio); } } } @@ -554,6 +557,15 @@ mult, const_cast *>(&m_scalePoints)); + // Ugly hack (but then everything about this scale drawing is a + // bit ugly). In pixel-doubling hi-dpi scenarios, the scale is + // painted at pixel-doubled resolution but we do explicit + // pixel-doubling ourselves when painting the layer content. We + // make a note of this here so that we can compare with the + // equivalent dimension in the paint method when deciding where to + // place scale continuation lines. + m_scalePaintHeight = v->getPaintHeight(); + if (mult != 1 && mult != 0) { int log = int(lrint(log10(mult))); QString a = tr("x10"); diff -r 6e35062fc10a -r 51e6125627fa layer/SliceLayer.h --- a/layer/SliceLayer.h Tue May 08 14:07:22 2018 +0100 +++ b/layer/SliceLayer.h Tue May 08 14:27:54 2018 +0100 @@ -13,8 +13,8 @@ COPYING included with this distribution for more information. */ -#ifndef _SLICE_LAYER_H_ -#define _SLICE_LAYER_H_ +#ifndef SV_SLICE_LAYER_H +#define SV_SLICE_LAYER_H #include "SingleColourLayer.h" @@ -153,6 +153,7 @@ int m_minbin; int m_maxbin; mutable std::vector m_scalePoints; + mutable int m_scalePaintHeight; mutable std::map m_xorigins; // LayerGeometryProvider id -> x mutable std::map m_yorigins; // LayerGeometryProvider id -> y mutable std::map m_heights; // LayerGeometryProvider id -> h