QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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_sip.h"
21 #include "qgssymbollayer.h"
22 #include <QDomElement>
23 #include <QDomDocument>
24 
25 class QgsPaintEffect;
27 
40 {
41  public:
42 
48  QgsPaintEffectAbstractMetadata( const QString &name, const QString &visibleName );
49 
50  virtual ~QgsPaintEffectAbstractMetadata() = default;
51 
57  QString name() const { return mName; }
58 
64  QString visibleName() const { return mVisibleName; }
65 
71  virtual QgsPaintEffect *createPaintEffect( const QgsStringMap &map ) = 0 SIP_FACTORY;
72 
78  virtual QgsPaintEffectWidget *createWidget() SIP_FACTORY { return nullptr; }
79 
80  protected:
81  QString mName;
82  QString mVisibleName;
83 
84 };
85 
86 typedef QgsPaintEffect *( *QgsPaintEffectCreateFunc )( const QgsStringMap & ) SIP_SKIP;
87 typedef QgsPaintEffectWidget *( *QgsPaintEffectWidgetFunc )() SIP_SKIP;
88 
98 {
99 
100  public:
101 
110  QgsPaintEffectMetadata( const QString &name, const QString &visibleName,
111  QgsPaintEffectCreateFunc pfCreate,
112  QgsPaintEffectWidgetFunc pfWidget = nullptr ) SIP_SKIP
113  : QgsPaintEffectAbstractMetadata( name, visibleName )
114  , mCreateFunc( pfCreate )
115  , mWidgetFunc( pfWidget )
116  {}
117 
123  QgsPaintEffectCreateFunc createFunction() const { return mCreateFunc; } SIP_SKIP
124 
131  QgsPaintEffectWidgetFunc widgetFunction() const { return mWidgetFunc; } SIP_SKIP
132 
139  void setWidgetFunction( QgsPaintEffectWidgetFunc f ) { mWidgetFunc = f; } SIP_SKIP
140 
148  QgsPaintEffect *createPaintEffect( const QgsStringMap &map ) override { return mCreateFunc ? mCreateFunc( map ) : nullptr; } SIP_SKIP
149 
156  QgsPaintEffectWidget *createWidget() override SIP_FACTORY { return mWidgetFunc ? mWidgetFunc() : nullptr; } SIP_SKIP
157 
158  protected:
161 };
162 
163 
174 class CORE_EXPORT QgsPaintEffectRegistry
175 {
176  public:
177 
180 
182  QgsPaintEffectRegistry( const QgsPaintEffectRegistry &rh ) = delete;
184  QgsPaintEffectRegistry &operator=( const QgsPaintEffectRegistry &rh ) = delete;
185 
191  QgsPaintEffectAbstractMetadata *effectMetadata( const QString &name ) const;
192 
198  bool addEffectType( QgsPaintEffectAbstractMetadata *metadata SIP_TRANSFER );
199 
207  QgsPaintEffect *createEffect( const QString &name, const QgsStringMap &properties = QgsStringMap() ) const SIP_FACTORY;
208 
216  QgsPaintEffect *createEffect( const QDomElement &element ) const SIP_FACTORY;
217 
222  QStringList effects() const;
223 
231  static QgsPaintEffect *defaultStack() SIP_FACTORY;
232 
240  static bool isDefaultStack( QgsPaintEffect *effect );
241 
242  private:
243 #ifdef SIP_RUN
245 #endif
246 
247  QMap<QString, QgsPaintEffectAbstractMetadata *> mMetadata;
248 };
249 
250 #endif //QGSPAINTEFFECTREGISTRY_H
QgsPaintEffectMetadata::createPaintEffect
QgsPaintEffect * createPaintEffect(const QgsStringMap &map) override
Creates a new paint effect of the metadata's effect class.
Definition: qgspainteffectregistry.h:148
QgsPaintEffectMetadata::widgetFunction
QgsPaintEffectWidgetFunc widgetFunction() const
Returns the paint effect properties widget creation function for the paint effect class.
Definition: qgspainteffectregistry.h:131
QgsPaintEffectAbstractMetadata::createWidget
virtual QgsPaintEffectWidget * createWidget()
Create configuration widget for paint effect of this class.
Definition: qgspainteffectregistry.h:78
QgsPaintEffectCreateFunc
QgsPaintEffect *(* QgsPaintEffectCreateFunc)(const QgsStringMap &)
Definition: qgspainteffectregistry.h:86
QgsPaintEffectMetadata::mWidgetFunc
QgsPaintEffectWidgetFunc mWidgetFunc
Definition: qgspainteffectregistry.h:160
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsPaintEffectAbstractMetadata::name
QString name() const
Returns the unique string representing the paint effect class.
Definition: qgspainteffectregistry.h:57
QgsPaintEffectMetadata::createFunction
QgsPaintEffectCreateFunc createFunction() const
Returns the paint effect creation function for the paint effect class.
Definition: qgspainteffectregistry.h:123
QgsPaintEffectAbstractMetadata::mVisibleName
QString mVisibleName
Definition: qgspainteffectregistry.h:82
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsPaintEffectAbstractMetadata
Stores metadata about a paint effect class.
Definition: qgspainteffectregistry.h:39
qgis_sip.h
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsPaintEffectMetadata::mCreateFunc
QgsPaintEffectCreateFunc mCreateFunc
Definition: qgspainteffectregistry.h:159
QgsPaintEffectMetadata::createWidget
QgsPaintEffectWidget * createWidget() override
Creates a new paint effect properties widget for the metadata's effect class.
Definition: qgspainteffectregistry.h:156
qgssymbollayer.h
QgsPaintEffectRegistry
Registry of available paint effects.
Definition: qgspainteffectregistry.h:174
QgsPaintEffectMetadata::QgsPaintEffectMetadata
QgsPaintEffectMetadata(const QString &name, const QString &visibleName, QgsPaintEffectCreateFunc pfCreate, QgsPaintEffectWidgetFunc pfWidget=nullptr)
Create effect metadata from static functions.
Definition: qgspainteffectregistry.h:110
QgsPaintEffectWidget
Base class for effect properties widgets.
Definition: qgspainteffectwidget.h:40
QgsStringMap
QMap< QString, QString > QgsStringMap
Definition: qgis.h:714
QgsPaintEffectMetadata::setWidgetFunction
void setWidgetFunction(QgsPaintEffectWidgetFunc f)
Sets the paint effect properties widget creation function for the paint effect class.
Definition: qgspainteffectregistry.h:139
QgsPaintEffectAbstractMetadata::visibleName
QString visibleName() const
Returns the user visible string representing the paint effect class.
Definition: qgspainteffectregistry.h:64
QgsPaintEffect
Base class for visual effects which can be applied to QPicture drawings.
Definition: qgspainteffect.h:53
QgsPaintEffectWidgetFunc
QgsPaintEffectWidget *(* QgsPaintEffectWidgetFunc)()
Definition: qgspainteffectregistry.h:87
QgsPaintEffectAbstractMetadata::mName
QString mName
Definition: qgspainteffectregistry.h:81
SIP_EXTERNAL
#define SIP_EXTERNAL
Definition: qgis_sip.h:116
QgsPaintEffectMetadata
Convenience metadata class that uses static functions to create an effect and its widget.
Definition: qgspainteffectregistry.h:97