Skip to content

Commit

Permalink
Fix rubber band display 'glitchy' following optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Oct 22, 2023
1 parent 0f009c9 commit 8e9f971
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
7 changes: 3 additions & 4 deletions src/core/linepolygonhighlight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ QSGNode *LinePolygonHighlight::updatePaintNode( QSGNode *n, QQuickItem::UpdatePa
n->appendChildNode( gn );

mDirty = false;
updateTransform();

emit updated();
}
Expand Down Expand Up @@ -133,10 +132,10 @@ void LinePolygonHighlight::updateTransform()

const QgsPointXY pixelCorner = mMapSettings->coordinateToScreen( mGeometryCorner );

setX( pixelCorner.x() );
setY( pixelCorner.y() );
setX( mDirty ? 0 : pixelCorner.x() );
setY( mDirty ? 0 : pixelCorner.y() );
setScale( mDirty ? 1.0 : mGeometryMUPP / mMapSettings->mapUnitsPerPoint() );
setRotation( mMapSettings->rotation() );
setScale( mGeometryMUPP / mMapSettings->mapUnitsPerPoint() );

update();
}
Expand Down
9 changes: 4 additions & 5 deletions src/core/rubberband.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ void Rubberband::updateTransform()

const QgsPointXY pixelCorner = mMapSettings->coordinateToScreen( mGeometryCorner );

setX( pixelCorner.x() );
setY( pixelCorner.y() );
setScale( mGeometryMUPP / mMapSettings->mapUnitsPerPoint() );
setX( mDirty ? 0 : pixelCorner.x() );
setY( mDirty ? 0 : pixelCorner.y() );
setScale( mDirty ? 1.0 : mGeometryMUPP / mMapSettings->mapUnitsPerPoint() );
setRotation( mMapSettings->rotation() );

update();
Expand All @@ -147,7 +147,7 @@ void Rubberband::rotationChanged()
void Rubberband::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 Expand Up @@ -221,7 +221,6 @@ QSGNode *Rubberband::updatePaintNode( QSGNode *n, QQuickItem::UpdatePaintNodeDat
mGeometryMUPP = mMapSettings->mapUnitsPerPoint();

mDirty = false;
updateTransform();
}

return n;
Expand Down

1 comment on commit 8e9f971

@qfield-fairy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.