QGIS API Documentation  3.0.2-Girona (307d082)
qgspainteffectregistry.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgspainteffectregistry.h
3  ------------------------
4  begin : January 2015
5  copyright : (C) 2015 Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSPAINTEFFECTREGISTRY_H
17 #define QGSPAINTEFFECTREGISTRY_H
18 
19 #include "qgis_core.h"
20 #include "qgis.h"
21 #include <QDomElement>
22 #include <QDomDocument>
23 
24 class QgsPaintEffect;
26 
39 {
40  public:
41 
47  QgsPaintEffectAbstractMetadata( const QString &name, const QString &visibleName );
48 
49  virtual ~QgsPaintEffectAbstractMetadata() = default;
50 
56  QString name() const { return mName; }
57 
63  QString visibleName() const { return mVisibleName; }
64 
70  virtual QgsPaintEffect *createPaintEffect( const QgsStringMap &map ) = 0 SIP_FACTORY;
71 
77  virtual QgsPaintEffectWidget *createWidget() SIP_FACTORY { return nullptr; }
78 
79  protected:
80  QString mName;
81  QString mVisibleName;
82 
83 };
84 
85 typedef QgsPaintEffect *( *QgsPaintEffectCreateFunc )( const QgsStringMap & ) SIP_SKIP;
86 typedef QgsPaintEffectWidget *( *QgsPaintEffectWidgetFunc )() SIP_SKIP;
87 
97 {
98 
99  public:
100 
109  QgsPaintEffectMetadata( const QString &name, const QString &visibleName,
110  QgsPaintEffectCreateFunc pfCreate,
111  QgsPaintEffectWidgetFunc pfWidget = nullptr ) SIP_SKIP
112  : QgsPaintEffectAbstractMetadata( name, visibleName )
113  , mCreateFunc( pfCreate )
114  , mWidgetFunc( pfWidget )
115  {}
116 
122  QgsPaintEffectCreateFunc createFunction() const { return mCreateFunc; } SIP_SKIP
123 
130  QgsPaintEffectWidgetFunc widgetFunction() const { return mWidgetFunc; } SIP_SKIP
131 
139 
147  QgsPaintEffect *createPaintEffect( const QgsStringMap &map ) override { return mCreateFunc ? mCreateFunc( map ) : nullptr; } SIP_SKIP
148 
155  QgsPaintEffectWidget *createWidget() override SIP_FACTORY { return mWidgetFunc ? mWidgetFunc() : nullptr; } SIP_SKIP
156 
157  protected:
160 };
161 
162 
173 class CORE_EXPORT QgsPaintEffectRegistry
174 {
175  public:
176 
179 
181  QgsPaintEffectRegistry( const QgsPaintEffectRegistry &rh ) = delete;
183  QgsPaintEffectRegistry &operator=( const QgsPaintEffectRegistry &rh ) = delete;
184 
190  QgsPaintEffectAbstractMetadata *effectMetadata( const QString &name ) const;
191 
197  bool addEffectType( QgsPaintEffectAbstractMetadata *metadata SIP_TRANSFER );
198 
206  QgsPaintEffect *createEffect( const QString &name, const QgsStringMap &properties = QgsStringMap() ) const SIP_FACTORY;
207 
215  QgsPaintEffect *createEffect( const QDomElement &element ) const SIP_FACTORY;
216 
221  QStringList effects() const;
222 
230  static QgsPaintEffect *defaultStack() SIP_FACTORY;
231 
239  static bool isDefaultStack( QgsPaintEffect *effect );
240 
241  private:
242 #ifdef SIP_RUN
244 #endif
245 
246  QMap<QString, QgsPaintEffectAbstractMetadata *> mMetadata;
247 };
248 
249 #endif //QGSPAINTEFFECTREGISTRY_H
Convenience metadata class that uses static functions to create an effect and its widget...
QgsPaintEffect * createPaintEffect(const QgsStringMap &map) override
Creates a new paint effect of the metadata&#39;s effect class.
Base class for effect properties widgets.
Base class for visual effects which can be applied to QPicture drawings.
Stores metadata about a paint effect class.
QgsPaintEffectWidgetFunc widgetFunction() const
Returns the paint effect properties widget creation function for the paint effect class...
QMap< QString, QString > QgsStringMap
Definition: qgis.h:479
QgsPaintEffectCreateFunc mCreateFunc
QgsPaintEffectWidgetFunc mWidgetFunc
#define SIP_SKIP
Definition: qgis_sip.h:119
QgsPaintEffectWidget *(* QgsPaintEffectWidgetFunc)()
QgsPaintEffectWidget * createWidget() override
Creates a new paint effect properties widget for the metadata&#39;s effect class.
QString name() const
Returns the unique string representing the paint effect class.
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_FACTORY
Definition: qgis_sip.h:69
QgsPaintEffectCreateFunc createFunction() const
Returns the paint effect creation function for the paint effect class.
QgsPaintEffect *(* QgsPaintEffectCreateFunc)(const QgsStringMap &)
QgsPaintEffectMetadata(const QString &name, const QString &visibleName, QgsPaintEffectCreateFunc pfCreate, QgsPaintEffectWidgetFunc pfWidget=nullptr)
Create effect metadata from static functions.
#define SIP_EXTERNAL
Definition: qgis_sip.h:109
QString visibleName() const
Returns the user visible string representing the paint effect class.
void setWidgetFunction(QgsPaintEffectWidgetFunc f)
Sets the paint effect properties widget creation function for the paint effect class.
virtual QgsPaintEffectWidget * createWidget()
Create configuration widget for paint effect of this class.
Registry of available paint effects.