Skip to content

Commit

Permalink
comments pt1
Browse files Browse the repository at this point in the history
(cherry picked from commit dd3667b)
  • Loading branch information
roya0045 authored and nyalldawson committed Jan 12, 2021
1 parent e040d37 commit 62753f5
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions src/app/qgsmaptoolscalefeature.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ QgsScaleMagnetWidget::QgsScaleMagnetWidget( const QString &label, QWidget *paren
mMagnetSpinBox->setMinimum( 0 ); mMagnetSpinBox->setMinimum( 0 );
mMagnetSpinBox->setMaximum( 180 ); mMagnetSpinBox->setMaximum( 180 );
mMagnetSpinBox->setPrefix( tr( "Snap to " ) ); mMagnetSpinBox->setPrefix( tr( "Snap to " ) );
mMagnetSpinBox->setSuffix( tr( "°" ) ); mMagnetSpinBox->setSuffix( tr( "x" ) );
mMagnetSpinBox->setSingleStep( 5 ); mMagnetSpinBox->setSingleStep( 5 );
mMagnetSpinBox->setValue( 0 ); mMagnetSpinBox->setValue( 0 );
mMagnetSpinBox->setClearValue( 0, tr( "No snapping" ) ); mMagnetSpinBox->setClearValue( 0, tr( "No snapping" ) );
Expand Down Expand Up @@ -149,6 +149,10 @@ QgsMapToolScaleFeature::~QgsMapToolScaleFeature()


void QgsMapToolScaleFeature::canvasMoveEvent( QgsMapMouseEvent *e ) void QgsMapToolScaleFeature::canvasMoveEvent( QgsMapMouseEvent *e )
{ {
if ( mBaseDistance == 0)
{
return;
}
if ( mScalingActive ) if ( mScalingActive )
{ {
const double distance = mFeatureCenter.distance( toLayerCoordinates( mLayer, e->mapPoint() ) ); const double distance = mFeatureCenter.distance( toLayerCoordinates( mLayer, e->mapPoint() ) );
Expand Down Expand Up @@ -200,14 +204,14 @@ void QgsMapToolScaleFeature::canvasReleaseEvent( QgsMapMouseEvent *e )
{ {
return; return;
} }
mFeatureCenter = toLayerCoordinates( mLayer, e->mapPoint() );; mFeatureCenter = toLayerCoordinates( mLayer, e->mapPoint() );
mAnchorPoint->setCenter( mFeatureCenter ); mAnchorPoint->setCenter( mFeatureCenter );
return; return;
} }


deleteScalingWidget(); deleteScalingWidget();


// Initialize rotation if not yet active // Initialize scaling if not yet active
if ( !mScalingActive ) if ( !mScalingActive )
{ {
mScaling = 1; mScaling = 1;
Expand Down Expand Up @@ -300,13 +304,6 @@ void QgsMapToolScaleFeature::canvasReleaseEvent( QgsMapMouseEvent *e )
mScaling = 1.0; mScaling = 1.0;


createScalingWidget(); createScalingWidget();
if ( e->modifiers() & Qt::ShiftModifier )
{
if ( mScalingWidget )
{
mScalingWidget->setMagnet( 45 );
}
}


mScalingActive = true; mScalingActive = true;


Expand Down Expand Up @@ -351,7 +348,6 @@ void QgsMapToolScaleFeature::applyScaling( double scale )
mScaling = scale; mScaling = scale;
mScalingActive = false; mScalingActive = false;


QgsVectorLayer *mLayer = currentVectorLayer();
if ( !mLayer ) if ( !mLayer )
{ {
deleteRubberband(); deleteRubberband();
Expand All @@ -365,14 +361,12 @@ void QgsMapToolScaleFeature::applyScaling( double scale )


int start = ( mLayer->geometryType() == 2 )? 1 : 0; int start = ( mLayer->geometryType() == 2 )? 1 : 0;


int i = 0; for ( QgsFeatureId id : qgis::as_const( mScaledFeatures ) )
const auto constMScaledFeatures = mScaledFeatures;
for ( QgsFeatureId id : constMScaledFeatures )
{ {
QgsFeature feat; QgsFeature feat;
mLayer->getFeatures( QgsFeatureRequest().setFilterFid( id ) ).nextFeature( feat ); mLayer->getFeatures( QgsFeatureRequest().setFilterFid( id ) ).nextFeature( feat );
QgsGeometry geom = feat.geometry(); QgsGeometry geom = feat.geometry();
i = start; int i = start;
QgsPointXY vertex = geom.vertexAt( i ); QgsPointXY vertex = geom.vertexAt( i );
while ( !vertex.isEmpty() ) while ( !vertex.isEmpty() )
{ {
Expand All @@ -384,7 +378,10 @@ void QgsMapToolScaleFeature::applyScaling( double scale )
i = i + 1; i = i + 1;
vertex = geom.vertexAt( i ); vertex = geom.vertexAt( i );
} }

//double offsetx = ( 1 - mScaling ) * mRubberScale.x();
//double offsety = ( 1 - mScaling ) * mRubberScale.y();
//QgsGeometry::OperationResult res = geom.transform( QTransform( mScaling, 0, 0, mScaling, offsetx, offsety ) );
//QString::number( res );
} }


deleteScalingWidget(); deleteScalingWidget();
Expand Down

0 comments on commit 62753f5

Please sign in to comment.