| 
    QGIS API Documentation
    3.14.0-Pi (9f7028fd23)
    
   | 
 
 
 
 
Go to the documentation of this file.
   28   for ( 
int i = 0; i < other.
count(); ++i )
 
   37   std::swap( mEffectList, other.mEffectList );
 
   57   for ( 
int i = 0; i < rhs.
count(); ++i )
 
   67   std::swap( mEffectList, other.mEffectList );
 
   81   QPainter *destPainter = context.
painter();
 
   86   QPicture *sourcePic = 
new QPicture( *
source() );
 
   87   QPicture *currentPic = sourcePic;
 
   88   QList< QPicture * > results;
 
   89   for ( 
int i = mEffectList.count() - 1; i >= 0; --i )
 
   97     QPicture *pic = 
nullptr;
 
   98     if ( 
effect->
type() == QLatin1String( 
"drawSource" ) )
 
  108     QPicture *resultPic = 
new QPicture();
 
  109     QPainter p( resultPic );
 
  118     results << resultPic;
 
  121       currentPic = resultPic;
 
  129   for ( 
int i = 0; i < mEffectList.count(); ++i )
 
  131     if ( !mEffectList[i]->
enabled() )
 
  136     QPicture *pic = results.takeLast();
 
  141       context.
painter()->drawPicture( 0, 0, *pic );
 
  157   if ( element.isNull() )
 
  162   QDomElement effectElement = doc.createElement( QStringLiteral( 
"effect" ) );
 
  163   effectElement.setAttribute( QStringLiteral( 
"type" ), 
type() );
 
  164   effectElement.setAttribute( QStringLiteral( 
"enabled" ), 
mEnabled );
 
  173   element.appendChild( effectElement );
 
  179   if ( element.isNull() )
 
  184   mEnabled = ( element.attribute( QStringLiteral( 
"enabled" ), QStringLiteral( 
"0" ) ) != QLatin1String( 
"0" ) );
 
  189   QDomNodeList childNodes = element.childNodes();
 
  190   for ( 
int i = 0; i < childNodes.size(); ++i )
 
  192     QDomElement childElement = childNodes.at( i ).toElement();
 
  211 void QgsEffectStack::clearStack()
 
  213   qDeleteAll( mEffectList );
 
  219   mEffectList.append( 
effect );
 
  224   if ( index < 0 || index > mEffectList.count() )
 
  229   mEffectList.insert( index, 
effect );
 
  235   if ( index < 0 || index >= mEffectList.count() )
 
  240   delete mEffectList.at( index );
 
  241   mEffectList[index] = 
effect;
 
  247   if ( index < 0 || index >= mEffectList.count() )
 
  250   return mEffectList.takeAt( index );
 
  260   if ( index >= 0 && index < mEffectList.count() )
 
  262     return mEffectList.at( index );
 
  
~QgsEffectStack() override
 
bool requiresQPainterDpiFix
 
virtual void render(QPicture &picture, QgsRenderContext &context)
Renders a picture using the effect.
 
QgsEffectStack()=default
Constructor for empty QgsEffectStack.
 
void fixQPictureDpi(QPainter *painter) const
Applies a workaround to a QPainter to avoid an issue with incorrect scaling when drawing QPictures.
 
QgsPaintEffect * createEffect(const QString &name, const QgsStringMap &properties=QgsStringMap()) const
Creates a new paint effect given the effect name and properties map.
 
void setPainter(QPainter *p)
Sets the destination QPainter for the render operation.
 
virtual bool saveProperties(QDomDocument &doc, QDomElement &element) const
Saves the current state of the effect to a DOM element.
 
bool insertEffect(int index, QgsPaintEffect *effect)
Inserts an effect at a specified index within the stack.
 
@ Modifier
The result of the effect is not rendered, but is passed on to following effects in the stack.
 
@ Render
The result of the effect is rendered on the destination, but does not affect subsequent effects in th...
 
bool readProperties(const QDomElement &element) override
Restores the effect to the state described by a DOM element.
 
static QgsPaintEffect * create(const QgsStringMap &map)
Creates a new QgsEffectStack effect.
 
void draw(QgsRenderContext &context) override
Handles drawing of the effect's result on to the specified render context.
 
QString type() const override
Returns the effect type.
 
QgsEffectStack * clone() const override
Duplicates an effect by creating a deep copy of the effect.
 
QgsPaintEffect * effect(int index) const
Returns a pointer to the effect at a specified index within the stack.
 
QgsPaintEffect * takeEffect(int index)
Removes an effect from the stack and returns a pointer to it.
 
virtual QgsPaintEffect * clone() const =0
Duplicates an effect by creating a deep copy of the effect.
 
virtual void readProperties(const QgsStringMap &props)=0
Reads a string map of an effect's properties and restores the effect to the state described by the pr...
 
QList< QgsPaintEffect * > * effectList()
Returns a pointer to the list of effects currently contained by the stack.
 
QgsStringMap properties() const override
Unused for QgsEffectStack, will always return an empty string map.
 
bool saveProperties(QDomDocument &doc, QDomElement &element) const override
Saves the current state of the effect to a DOM element.
 
QMap< QString, QString > QgsStringMap
 
int count() const
Returns count of effects contained by the stack.
 
static QgsPaintEffectRegistry * paintEffectRegistry()
Returns the application's paint effect registry, used for managing paint effects.
 
const QPicture * source() const
Returns the source QPicture.
 
void appendEffect(QgsPaintEffect *effect)
Appends an effect to the end of the stack.
 
Base class for visual effects which can be applied to QPicture drawings.
 
QPainter * painter()
Returns the destination QPainter for the render operation.
 
bool enabled() const
Returns whether the effect is enabled.
 
QgsEffectStack & operator=(const QgsEffectStack &rhs)
 
virtual QString type() const =0
Returns the effect type.
 
bool changeEffect(int index, QgsPaintEffect *effect)
Replaces the effect at a specified position within the stack.
 
A paint effect which consists of a stack of other chained paint effects.