Skip to content
Permalink
Browse files
Fix scale tool on different map crs
  • Loading branch information
uclaros committed Apr 26, 2021
1 parent b6e354f commit a7344775290318893ba3427056e98abdc09d0e25
Showing with 9 additions and 7 deletions.
  1. +9 −7 src/app/qgsmaptoolscalefeature.cpp
@@ -317,15 +317,16 @@ void QgsMapToolScaleFeature::updateRubberband( double scale )
{
mScaling = scale;

QTransform t;
t.translate( mFeatureCenterMapCoords.x(), mFeatureCenterMapCoords.y() );
t.scale( mScaling, mScaling );
t.translate( -mFeatureCenterMapCoords.x(), -mFeatureCenterMapCoords.y() );

QgsVectorLayer *vlayer = currentVectorLayer();
if ( !vlayer )
return;

QgsPointXY layerCoords = toLayerCoordinates( vlayer, mFeatureCenterMapCoords );
QTransform t;
t.translate( layerCoords.x(), layerCoords.y() );
t.scale( mScaling, mScaling );
t.translate( -layerCoords.x(), -layerCoords.y() );

mRubberBand->reset( vlayer->geometryType() );
for ( const QgsGeometry &originalGeometry : mOriginalGeometries )
{
@@ -355,10 +356,11 @@ void QgsMapToolScaleFeature::applyScaling( double scale )

vlayer->beginEditCommand( tr( "Features Scaled" ) );

QgsPointXY layerCoords = toLayerCoordinates( vlayer, mFeatureCenterMapCoords );
QTransform t;
t.translate( mFeatureCenterMapCoords.x(), mFeatureCenterMapCoords.y() );
t.translate( layerCoords.x(), layerCoords.y() );
t.scale( mScaling, mScaling );
t.translate( -mFeatureCenterMapCoords.x(), -mFeatureCenterMapCoords.y() );
t.translate( -layerCoords.x(), -layerCoords.y() );

for ( QgsFeatureId id : std::as_const( mScaledFeatures ) )
{

0 comments on commit a734477

Please sign in to comment.