diff --git a/src/core/linepolygonhighlight.cpp b/src/core/linepolygonhighlight.cpp index 3ee101884e..1e9f0ad60e 100644 --- a/src/core/linepolygonhighlight.cpp +++ b/src/core/linepolygonhighlight.cpp @@ -47,9 +47,6 @@ QSGNode *LinePolygonHighlight::updatePaintNode( QSGNode *n, QQuickItem::UpdatePa geometry.transform( ct ); } - const QgsRectangle extent = mMapSettings->visibleExtent(); - mGeometryCorner = QgsPoint( extent.xMinimum(), extent.yMaximum() ); - mGeometryMUPP = mMapSettings->mapUnitsPerPoint(); QgsSGGeometry *gn = new QgsSGGeometry( geometry, mColor, mWidth * mMapSettings->devicePixelRatio(), mMapSettings->visibleExtent(), 1.0 / mMapSettings->mapUnitsPerPoint() ); gn->setFlag( QSGNode::OwnedByParent ); n->appendChildNode( gn ); @@ -130,11 +127,18 @@ void LinePolygonHighlight::updateTransform() if ( !mMapSettings ) return; + if ( mDirty ) + { + const QgsRectangle extent = mMapSettings->visibleExtent(); + mGeometryCorner = QgsPoint( extent.xMinimum(), extent.yMaximum() ); + mGeometryMUPP = mMapSettings->mapUnitsPerPoint(); + } + const QgsPointXY pixelCorner = mMapSettings->coordinateToScreen( mGeometryCorner ); - setX( mDirty ? 0 : pixelCorner.x() ); - setY( mDirty ? 0 : pixelCorner.y() ); - setScale( mDirty ? 1.0 : mGeometryMUPP / mMapSettings->mapUnitsPerPoint() ); + setX( pixelCorner.x() ); + setY( pixelCorner.y() ); + setScale( mGeometryMUPP / mMapSettings->mapUnitsPerPoint() ); setRotation( mMapSettings->rotation() ); update(); @@ -148,7 +152,7 @@ void LinePolygonHighlight::rotationChanged() void LinePolygonHighlight::visibleExtentChanged() { const double scaleChange = mGeometryMUPP / mMapSettings->mapUnitsPerPoint(); - mDirty = mGeometryMUPP == 0.0 || scaleChange > 1.75 || scaleChange < 0.25; + mDirty = mDirty || mGeometryMUPP == 0.0 || scaleChange > 1.75 || scaleChange < 0.25; updateTransform(); } diff --git a/src/core/rubberband.cpp b/src/core/rubberband.cpp index d9f82eb9b0..28ba17baae 100644 --- a/src/core/rubberband.cpp +++ b/src/core/rubberband.cpp @@ -129,11 +129,18 @@ void Rubberband::updateTransform() if ( !mMapSettings ) return; + if ( mDirty ) + { + const QgsRectangle extent = mMapSettings->visibleExtent(); + mGeometryCorner = QgsPoint( extent.xMinimum(), extent.yMaximum() ); + mGeometryMUPP = mMapSettings->mapUnitsPerPoint(); + } + const QgsPointXY pixelCorner = mMapSettings->coordinateToScreen( mGeometryCorner ); - setX( mDirty ? 0 : pixelCorner.x() ); - setY( mDirty ? 0 : pixelCorner.y() ); - setScale( mDirty ? 1.0 : mGeometryMUPP / mMapSettings->mapUnitsPerPoint() ); + setX( pixelCorner.x() ); + setY( pixelCorner.y() ); + setScale( mGeometryMUPP / mMapSettings->mapUnitsPerPoint() ); setRotation( mMapSettings->rotation() ); update(); @@ -216,9 +223,6 @@ QSGNode *Rubberband::updatePaintNode( QSGNode *n, QQuickItem::UpdatePaintNodeDat n->appendChildNode( rbCurrentPoint ); } } - const QgsRectangle extent = mMapSettings->visibleExtent(); - mGeometryCorner = QgsPoint( extent.xMinimum(), extent.yMaximum() ); - mGeometryMUPP = mMapSettings->mapUnitsPerPoint(); mDirty = false; }