QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
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 <QDomElement>
22#include <QDomDocument>
23#include <QMap>
24#include <QVariantMap>
25
26class QgsPaintEffect;
28
40{
41 public:
42
48 QgsPaintEffectAbstractMetadata( const QString &name, const QString &visibleName );
49
51
57 QString name() const { return mName; }
58
64 QString visibleName() const { return mVisibleName; }
65
71 virtual QgsPaintEffect *createPaintEffect( const QVariantMap &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
86typedef QgsPaintEffect *( *QgsPaintEffectCreateFunc )( const QVariantMap & ) SIP_SKIP;
87typedef QgsPaintEffectWidget *( *QgsPaintEffectWidgetFunc )() SIP_SKIP;
88
97{
98
99 public:
100
109 QgsPaintEffectMetadata( const QString &name, const QString &visibleName,
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 QVariantMap &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
172class CORE_EXPORT QgsPaintEffectRegistry
173{
174 public:
175
178
181
187 QgsPaintEffectAbstractMetadata *effectMetadata( const QString &name ) const;
188
194 bool addEffectType( QgsPaintEffectAbstractMetadata *metadata SIP_TRANSFER );
195
203 QgsPaintEffect *createEffect( const QString &name, const QVariantMap &properties = QVariantMap() ) const SIP_FACTORY;
204
212 QgsPaintEffect *createEffect( const QDomElement &element ) const SIP_FACTORY;
213
218 QStringList effects() const;
219
227 static QgsPaintEffect *defaultStack() SIP_FACTORY;
228
235 static bool isDefaultStack( QgsPaintEffect *effect );
236
237 private:
238#ifdef SIP_RUN
240#endif
241
242 QMap<QString, QgsPaintEffectAbstractMetadata *> mMetadata;
243};
244
245#endif //QGSPAINTEFFECTREGISTRY_H
Stores metadata about a paint effect class.
virtual QgsPaintEffectWidget * createWidget()
Create configuration widget for paint effect of this class.
QString visibleName() const
Returns the user visible string representing the paint effect class.
QString name() const
Returns the unique string representing the paint effect class.
virtual QgsPaintEffect * createPaintEffect(const QVariantMap &map)=0
Create a paint effect of this class given an encoded map of properties.
virtual ~QgsPaintEffectAbstractMetadata()=default
Convenience metadata class that uses static functions to create an effect and its widget.
QgsPaintEffectCreateFunc createFunction() const
Returns the paint effect creation function for the paint effect class.
QgsPaintEffectCreateFunc mCreateFunc
QgsPaintEffectWidgetFunc mWidgetFunc
QgsPaintEffect * createPaintEffect(const QVariantMap &map) override
Creates a new paint effect of the metadata's effect class.
void setWidgetFunction(QgsPaintEffectWidgetFunc f)
Sets the paint effect properties widget creation function for the paint effect class.
QgsPaintEffectWidgetFunc widgetFunction() const
Returns the paint effect properties widget creation function for the paint effect class.
QgsPaintEffectWidget * createWidget() override
Creates a new paint effect properties widget for the metadata's effect class.
QgsPaintEffectMetadata(const QString &name, const QString &visibleName, QgsPaintEffectCreateFunc pfCreate, QgsPaintEffectWidgetFunc pfWidget=nullptr)
Create effect metadata from static functions.
Registry of available paint effects.
QgsPaintEffectRegistry(const QgsPaintEffectRegistry &rh)=delete
QgsPaintEffectRegistry & operator=(const QgsPaintEffectRegistry &rh)=delete
Base class for effect properties widgets.
Base class for visual effects which can be applied to QPicture drawings.
#define SIP_EXTERNAL
Definition qgis_sip.h:116
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:76
QgsPaintEffect *(* QgsPaintEffectCreateFunc)(const QVariantMap &)
QgsPaintEffectWidget *(* QgsPaintEffectWidgetFunc)()