Skip to content
Permalink
Browse files
Fix transform shear value not saved (fix #16567)
  • Loading branch information
nyalldawson committed May 17, 2017
1 parent 6e98b9f commit 09975cec0734c36e06e0779298d4a1f7932bf0f6
Showing with 13 additions and 11 deletions.
  1. +2 −0 src/core/effects/qgstransformeffect.cpp
  2. +11 −11 tests/src/core/testqgspainteffect.cpp
@@ -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" ) ) );
@@ -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 );
@@ -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 );
@@ -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 );
@@ -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 );

0 comments on commit 09975ce

Please sign in to comment.