Skip to content

Commit

Permalink
Merge pull request #4581 from nyalldawson/fix_16567
Browse files Browse the repository at this point in the history
Fix transform shear value not saved (fix #16567)
  • Loading branch information
nyalldawson authored May 17, 2017
2 parents e12209e + 1ae3163 commit e6f6406
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/core/effects/qgstransformeffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ void QgsTransformEffect::readProperties( const QgsStringMap &props )
mScaleX = props.value( "scale_x", "1.0" ).toDouble();
mScaleY = props.value( "scale_y", "1.0" ).toDouble();
mRotation = props.value( "rotation", "0.0" ).toDouble();
mShearX = props.value( "shear_x", "0.0" ).toDouble();
mShearY = props.value( "shear_y", "0.0" ).toDouble();
mTranslateX = props.value( "translate_x", "0.0" ).toDouble();
mTranslateY = props.value( "translate_y", "0.0" ).toDouble();
mTranslateUnit = QgsSymbolLayerV2Utils::decodeOutputUnit( props.value( "translate_unit" ) );
Expand Down
98 changes: 98 additions & 0 deletions tests/src/core/testqgspainteffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "qgsshadoweffect.h"
#include "qgseffectstack.h"
#include "qgsgloweffect.h"
#include "qgstransformeffect.h"
#include "qgspainteffectregistry.h"
#include "qgsvectorcolorrampv2.h"
#include "qgssymbollayerv2utils.h"
Expand Down Expand Up @@ -106,6 +107,7 @@ class TestQgsPaintEffect: public QObject
void blur();
void dropShadow();
void glow();
void transform();

void stack();

Expand Down Expand Up @@ -628,6 +630,102 @@ void TestQgsPaintEffect::glow()

}

void TestQgsPaintEffect::transform()
{
//create
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->setTranslateMapUnitScale( QgsMapUnitScale( 1.0, 2.0 ) );
QCOMPARE( effect->translateMapUnitScale().minScale, 1.0 );
QCOMPARE( effect->translateMapUnitScale().maxScale, 2.0 );
effect->setScaleX( 0.5 );
QCOMPARE( effect->scaleX(), 0.5 );
effect->setScaleY( 1.5 );
QCOMPARE( effect->scaleY(), 1.5 );
effect->setRotation( 45.5 );
QCOMPARE( effect->rotation(), 45.5 );
effect->setShearX( 1.2 );
QCOMPARE( effect->shearX(), 1.2 );
effect->setShearY( 0.6 );
QCOMPARE( effect->shearY(), 0.6 );
effect->setReflectX( true );
QCOMPARE( effect->reflectX(), true );
effect->setReflectY( true );
QCOMPARE( effect->reflectY(), true );
effect->setDrawMode( QgsPaintEffect::Modifier );
QCOMPARE( effect->drawMode(), QgsPaintEffect::Modifier );

//copy constructor
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->translateMapUnitScale().minScale, 1.0 );
QCOMPARE( copy->translateMapUnitScale().maxScale, 2.0 );
QCOMPARE( copy->scaleX(), 0.5 );
QCOMPARE( copy->scaleY(), 1.5 );
QCOMPARE( copy->rotation(), 45.5 );
QCOMPARE( copy->shearX(), 1.2 );
QCOMPARE( copy->shearY(), 0.6 );
QCOMPARE( copy->reflectX(), true );
QCOMPARE( copy->reflectY(), true );
QCOMPARE( copy->drawMode(), QgsPaintEffect::Modifier );
delete copy;

//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->translateMapUnitScale().minScale, 1.0 );
QCOMPARE( cloneCast->translateMapUnitScale().maxScale, 2.0 );
QCOMPARE( cloneCast->scaleX(), 0.5 );
QCOMPARE( cloneCast->scaleY(), 1.5 );
QCOMPARE( cloneCast->rotation(), 45.5 );
QCOMPARE( cloneCast->shearX(), 1.2 );
QCOMPARE( cloneCast->shearY(), 0.6 );
QCOMPARE( cloneCast->reflectX(), true );
QCOMPARE( cloneCast->reflectY(), true );
QCOMPARE( cloneCast->drawMode(), QgsPaintEffect::Modifier );
delete cloneCast;

//read/write
QgsStringMap props = effect->properties();
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->translateMapUnitScale().minScale, 1.0 );
QCOMPARE( readCast->translateMapUnitScale().maxScale, 2.0 );
QCOMPARE( readCast->scaleX(), 0.5 );
QCOMPARE( readCast->scaleY(), 1.5 );
QCOMPARE( readCast->rotation(), 45.5 );
QCOMPARE( readCast->shearX(), 1.2 );
QCOMPARE( readCast->shearY(), 0.6 );
QCOMPARE( readCast->reflectX(), true );
QCOMPARE( readCast->reflectY(), true );
QCOMPARE( readCast->drawMode(), QgsPaintEffect::Modifier );
delete readCast;

delete effect;
}

void TestQgsPaintEffect::stack()
{
//create
Expand Down

0 comments on commit e6f6406

Please sign in to comment.