Skip to content

Commit

Permalink
Fix transform shear value not saved (fix #16567)
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 17, 2017
1 parent 6e98b9f commit 09975ce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
2 changes: 2 additions & 0 deletions src/core/effects/qgstransformeffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ void QgsTransformEffect::readProperties( const QgsStringMap &props )
mScaleX = props.value( QStringLiteral( "scale_x" ), QStringLiteral( "1.0" ) ).toDouble();
mScaleY = props.value( QStringLiteral( "scale_y" ), QStringLiteral( "1.0" ) ).toDouble();
mRotation = props.value( QStringLiteral( "rotation" ), QStringLiteral( "0.0" ) ).toDouble();
mShearX = props.value( QStringLiteral( "shear_x" ), QStringLiteral( "0.0" ) ).toDouble();
mShearY = props.value( QStringLiteral( "shear_y" ), QStringLiteral( "0.0" ) ).toDouble();
mTranslateX = props.value( QStringLiteral( "translate_x" ), QStringLiteral( "0.0" ) ).toDouble();
mTranslateY = props.value( QStringLiteral( "translate_y" ), QStringLiteral( "0.0" ) ).toDouble();
mTranslateUnit = QgsUnitTypes::decodeRenderUnit( props.value( QStringLiteral( "translate_unit" ) ) );
Expand Down
22 changes: 11 additions & 11 deletions tests/src/core/testqgspainteffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,16 +632,16 @@ void TestQgsPaintEffect::glow()
void TestQgsPaintEffect::transform()
{
//create
QgsTransformEffect* effect = new QgsTransformEffect();
QgsTransformEffect *effect = new QgsTransformEffect();
QVERIFY( effect );
effect->setEnabled( false );
QCOMPARE( effect->enabled(), false );
effect->setTranslateX( 6 );
QCOMPARE( effect->translateX(), 6.0 );
effect->setTranslateY( 77 );
QCOMPARE( effect->translateY(), 77.0 );
effect->setTranslateUnit( QgsSymbolV2::MapUnit );
QCOMPARE( effect->translateUnit(), QgsSymbolV2::MapUnit );
effect->setTranslateUnit( QgsUnitTypes::RenderMapUnits );
QCOMPARE( effect->translateUnit(), QgsUnitTypes::RenderMapUnits );
effect->setTranslateMapUnitScale( QgsMapUnitScale( 1.0, 2.0 ) );
QCOMPARE( effect->translateMapUnitScale().minScale, 1.0 );
QCOMPARE( effect->translateMapUnitScale().maxScale, 2.0 );
Expand All @@ -663,12 +663,12 @@ void TestQgsPaintEffect::transform()
QCOMPARE( effect->drawMode(), QgsPaintEffect::Modifier );

//copy constructor
QgsTransformEffect* copy = new QgsTransformEffect( *effect );
QgsTransformEffect *copy = new QgsTransformEffect( *effect );
QVERIFY( copy );
QCOMPARE( copy->enabled(), false );
QCOMPARE( copy->translateX(), 6.0 );
QCOMPARE( copy->translateY(), 77.0 );
QCOMPARE( copy->translateUnit(), QgsSymbolV2::MapUnit );
QCOMPARE( copy->translateUnit(), QgsUnitTypes::RenderMapUnits );
QCOMPARE( copy->translateMapUnitScale().minScale, 1.0 );
QCOMPARE( copy->translateMapUnitScale().maxScale, 2.0 );
QCOMPARE( copy->scaleX(), 0.5 );
Expand All @@ -682,13 +682,13 @@ void TestQgsPaintEffect::transform()
delete copy;

//clone
QgsPaintEffect* clone = effect->clone();
QgsTransformEffect* cloneCast = dynamic_cast<QgsTransformEffect* >( clone );
QgsPaintEffect *clone = effect->clone();
QgsTransformEffect *cloneCast = dynamic_cast<QgsTransformEffect * >( clone );
QVERIFY( cloneCast );
QCOMPARE( cloneCast->enabled(), false );
QCOMPARE( cloneCast->translateX(), 6.0 );
QCOMPARE( cloneCast->translateY(), 77.0 );
QCOMPARE( cloneCast->translateUnit(), QgsSymbolV2::MapUnit );
QCOMPARE( cloneCast->translateUnit(), QgsUnitTypes::RenderMapUnits );
QCOMPARE( cloneCast->translateMapUnitScale().minScale, 1.0 );
QCOMPARE( cloneCast->translateMapUnitScale().maxScale, 2.0 );
QCOMPARE( cloneCast->scaleX(), 0.5 );
Expand All @@ -703,13 +703,13 @@ void TestQgsPaintEffect::transform()

//read/write
QgsStringMap props = effect->properties();
QgsPaintEffect* readEffect = QgsTransformEffect::create( props );
QgsTransformEffect* readCast = dynamic_cast<QgsTransformEffect* >( readEffect );
QgsPaintEffect *readEffect = QgsTransformEffect::create( props );
QgsTransformEffect *readCast = dynamic_cast<QgsTransformEffect * >( readEffect );
QVERIFY( readCast );
QCOMPARE( readCast->enabled(), false );
QCOMPARE( readCast->translateX(), 6.0 );
QCOMPARE( readCast->translateY(), 77.0 );
QCOMPARE( readCast->translateUnit(), QgsSymbolV2::MapUnit );
QCOMPARE( readCast->translateUnit(), QgsUnitTypes::RenderMapUnits );
QCOMPARE( readCast->translateMapUnitScale().minScale, 1.0 );
QCOMPARE( readCast->translateMapUnitScale().maxScale, 2.0 );
QCOMPARE( readCast->scaleX(), 0.5 );
Expand Down

0 comments on commit 09975ce

Please sign in to comment.