Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport release-3_0] Fix display of rubber band and geometry highlight on rotated canvas #4703

Merged
merged 1 commit into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions src/core/linepolygonhighlight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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();
Expand All @@ -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();
}

Expand Down
16 changes: 10 additions & 6 deletions src/core/rubberband.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
Expand Down
Loading