From a05eff2539d0f05bbc80af819a339c84e040e43e Mon Sep 17 00:00:00 2001 From: Mathieu Pellerin Date: Sun, 5 Nov 2023 11:25:16 +0700 Subject: [PATCH] Fix view parent/children feature panning/zooming on high dpi screens --- src/core/utils/featureutils.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/core/utils/featureutils.cpp b/src/core/utils/featureutils.cpp index 4396b691bd..223014cc71 100644 --- a/src/core/utils/featureutils.cpp +++ b/src/core/utils/featureutils.cpp @@ -63,14 +63,15 @@ QgsRectangle FeatureUtils::extent( QgsQuickMapSettings *mapSettings, QgsVectorLa geom.transform( transf ); QgsRectangle extent; - const double rightPercentage = rightEdge / mapSettings->outputSize().width(); - const double bottomPercentage = bottomEdge / mapSettings->outputSize().height(); + QSizeF outputSize = mapSettings->outputSize() / mapSettings->devicePixelRatio(); + const double rightPercentage = rightEdge / outputSize.width(); + const double bottomPercentage = bottomEdge / outputSize.height(); if ( geom.type() == Qgis::GeometryType::Point ) { extent = mapSettings->extent(); QgsVector delta = QgsPointXY( geom.asPoint() ) - extent.center(); - const double deltaX = delta.x() + ( rightEdge > 0.0 ? mapSettings->mapUnitsPerPoint() * mapSettings->outputSize().width() * ( 0.5 - rightPercentage / 2.0 ) : 0.0 ); - const double deltaY = delta.y() - ( bottomEdge > 0.0 ? mapSettings->mapUnitsPerPoint() * mapSettings->outputSize().height() * ( 0.5 - ( 1.0 - bottomPercentage ) / 2.0 ) : 0.0 ); + const double deltaX = delta.x() + ( rightEdge > 0.0 ? mapSettings->mapUnitsPerPoint() * outputSize.width() * ( 0.5 - rightPercentage / 2.0 ) : 0.0 ); + const double deltaY = delta.y() - ( bottomEdge > 0.0 ? mapSettings->mapUnitsPerPoint() * outputSize.height() * ( 0.5 - ( 1.0 - bottomPercentage ) / 2.0 ) : 0.0 ); extent.setXMinimum( extent.xMinimum() + deltaX ); extent.setXMaximum( extent.xMaximum() + deltaX ); extent.setYMinimum( extent.yMinimum() + deltaY );