changeset 1284:51e6125627fa

Hack to ensure vertical scale lines are in the right place in pixel-doubling rendering
author Chris Cannam
date Tue, 08 May 2018 14:27:54 +0100
parents 6e35062fc10a
children abd52bd8d435 91670e4e76a6
files layer/SliceLayer.cpp layer/SliceLayer.h
diffstat 2 files changed, 16 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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<std::vector<int> *>(&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");
--- 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<int>          m_scalePoints;
+    mutable int                       m_scalePaintHeight;
     mutable std::map<int, int>        m_xorigins; // LayerGeometryProvider id -> x
     mutable std::map<int, int>        m_yorigins; // LayerGeometryProvider id -> y
     mutable std::map<int, int>        m_heights;  // LayerGeometryProvider id -> h