Skip to content

Commit

Permalink
Fix view parent/children feature panning/zooming on high dpi screens
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn authored and github-actions[bot] committed Nov 9, 2023
1 parent d36352e commit a05eff2
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/core/utils/featureutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit a05eff2

Please sign in to comment.