QgsEffectStack::QgsEffectStack( const QgsEffectStack &other ) : QgsPaintEffect( other ) { //deep copy for ( int i = 0; i < other.count(); ++i ) { appendEffect( other.effect( i )->clone() ); } }
Qgs25DRenderer::Qgs25DRenderer() : QgsFeatureRendererV2( "25dRenderer" ) { mSymbol.reset( new QgsFillSymbolV2() ); mSymbol->deleteSymbolLayer( 0 ); // We never asked for the default layer QgsSymbolLayerV2* floor = QgsSimpleFillSymbolLayerV2::create(); QgsStringMap wallProperties; wallProperties.insert( "geometryModifier", WALL_EXPRESSION ); wallProperties.insert( "symbolType", "Fill" ); QgsSymbolLayerV2* walls = QgsGeometryGeneratorSymbolLayerV2::create( wallProperties ); QgsStringMap roofProperties; roofProperties.insert( "geometryModifier", ROOF_EXPRESSION ); roofProperties.insert( "symbolType", "Fill" ); QgsSymbolLayerV2* roof = QgsGeometryGeneratorSymbolLayerV2::create( roofProperties ); floor->setLocked( true ); mSymbol->appendSymbolLayer( floor ); mSymbol->appendSymbolLayer( walls ); mSymbol->appendSymbolLayer( roof ); QgsEffectStack* effectStack = new QgsEffectStack(); QgsOuterGlowEffect* glowEffect = new QgsOuterGlowEffect(); glowEffect->setBlurLevel( 5 ); glowEffect->setSpreadUnit( QgsSymbolV2::MapUnit ); effectStack->appendEffect( glowEffect ); floor->setPaintEffect( effectStack ); // These methods must only be used after the above initialization! setRoofColor( QColor( "#b1a97c" ) ); setWallColor( QColor( "#777777" ) ); wallLayer()->setDataDefinedProperty( "color", new QgsDataDefined( QString( WALL_SHADING_EXPRESSION ) ) ); setShadowSpread( 4 ); setShadowColor( QColor( "#111111" ) ); QgsFeatureRequest::OrderBy orderBy; orderBy << QgsFeatureRequest::OrderByClause( ORDER_BY_EXPRESSION, false ); setOrderBy( orderBy ); setOrderByEnabled( true ); }
bool QgsPaintEffectRegistry::isDefaultStack( QgsPaintEffect* effect ) { QgsEffectStack* effectStack = dynamic_cast< QgsEffectStack* >( effect ); if ( !effectStack ) return false; if ( effectStack->count() != 5 ) return false; for ( int i = 0; i < 5; ++i ) { //only the third effect should be enabled if ( effectStack->effect( i )->enabled() != ( i == 2 ) ) return false; } if ( !dynamic_cast< QgsDropShadowEffect* >( effectStack->effect( 0 ) ) ) return false; if ( !dynamic_cast< QgsOuterGlowEffect* >( effectStack->effect( 1 ) ) ) return false; if ( !dynamic_cast< QgsDrawSourceEffect* >( effectStack->effect( 2 ) ) ) return false; if ( !dynamic_cast< QgsInnerShadowEffect* >( effectStack->effect( 3 ) ) ) return false; if ( !dynamic_cast< QgsInnerGlowEffect* >( effectStack->effect( 4 ) ) ) return false; //we don't go as far as to check the individual effect's properties return true; }
void TestQgsPaintEffectRegistry::defaultStack() { QgsPaintEffectRegistry* registry = QgsApplication::paintEffectRegistry(); QgsEffectStack* effect = static_cast<QgsEffectStack*>( registry->defaultStack() ); QVERIFY( registry->isDefaultStack( effect ) ); effect->effect( 1 )->setEnabled( true ); QVERIFY( !registry->isDefaultStack( effect ) ); effect->effect( 1 )->setEnabled( false ); effect->effect( 2 )->setEnabled( false ); //third effect should be enabled by default QVERIFY( !registry->isDefaultStack( effect ) ); effect->effect( 2 )->setEnabled( true ); effect->appendEffect( new QgsEffectStack() ); QVERIFY( !registry->isDefaultStack( effect ) ); delete effect; QgsPaintEffect* effect2 = new DummyPaintEffect(); QVERIFY( !registry->isDefaultStack( effect2 ) ); delete effect2; }
QgsPaintEffect* QgsPaintEffectRegistry::defaultStack() { QgsEffectStack* stack = new QgsEffectStack(); QgsDropShadowEffect* dropShadow = new QgsDropShadowEffect(); dropShadow->setEnabled( false ); stack->appendEffect( dropShadow ); QgsOuterGlowEffect* outerGlow = new QgsOuterGlowEffect(); outerGlow->setEnabled( false ); stack->appendEffect( outerGlow ); stack->appendEffect( new QgsDrawSourceEffect() ); QgsInnerShadowEffect* innerShadow = new QgsInnerShadowEffect(); innerShadow->setEnabled( false ); stack->appendEffect( innerShadow ); QgsInnerGlowEffect* innerGlow = new QgsInnerGlowEffect(); innerGlow->setEnabled( false ); stack->appendEffect( innerGlow ); return stack; }
QgsPaintEffect* QgsPaintEffectRegistry::defaultStack() { //NOTE - also remember to update isDefaultStack below if making changes to this list QgsEffectStack* stack = new QgsEffectStack(); QgsDropShadowEffect* dropShadow = new QgsDropShadowEffect(); dropShadow->setEnabled( false ); stack->appendEffect( dropShadow ); QgsOuterGlowEffect* outerGlow = new QgsOuterGlowEffect(); outerGlow->setEnabled( false ); stack->appendEffect( outerGlow ); stack->appendEffect( new QgsDrawSourceEffect() ); QgsInnerShadowEffect* innerShadow = new QgsInnerShadowEffect(); innerShadow->setEnabled( false ); stack->appendEffect( innerShadow ); QgsInnerGlowEffect* innerGlow = new QgsInnerGlowEffect(); innerGlow->setEnabled( false ); stack->appendEffect( innerGlow ); return stack; }
QgsPaintEffect *QgsEffectStack::create( const QgsStringMap &map ) { QgsEffectStack* effect = new QgsEffectStack(); effect->readProperties( map ); return effect; }