示例#1
0
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;
}
示例#2
0
QgsEffectStack::QgsEffectStack( const QgsEffectStack &other )
    : QgsPaintEffect( other )
{
  //deep copy
  for ( int i = 0; i < other.count(); ++i )
  {
    appendEffect( other.effect( i )->clone() );
  }
}
示例#3
0
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;
}