QGIS API Documentation 4.1.0-Master (60fea48833c)
Loading...
Searching...
No Matches
qgsvectorlayerlabeling.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsvectorlayerlabeling.h
3 ---------------------
4 begin : September 2015
5 copyright : (C) 2015 by Martin Dobias
6 email : wonder dot sk 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#ifndef QGSVECTORLAYERLABELING_H
16#define QGSVECTORLAYERLABELING_H
17
18#include <memory>
19
20#include "qgis.h"
21
22#include <QDomNode>
23#include <QString>
24#include <QStringList>
25
26class QDomDocument;
27class QDomElement;
28
31class QgsVectorLayer;
35
42{
43#ifdef SIP_RUN
45 if ( sipCpp->type() == "simple" )
46 sipType = sipType_QgsVectorLayerSimpleLabeling;
47 else if ( sipCpp->type() == "rule-based" )
48 sipType = sipType_QgsRuleBasedLabeling;
49 else
50 sipType = 0;
52#endif
53
54 public:
55
58
60 virtual QString type() const = 0;
61
64
70 {
71 Q_UNUSED( layer )
72 return nullptr;
73 }
74
76 virtual QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) const = 0;
77
79 virtual QStringList subProviders() const { return QStringList( QString() ); }
80
85 virtual QgsPalLayerSettings settings( const QString &providerId = QString() ) const = 0;
86
94 virtual void setSettings( QgsPalLayerSettings *settings SIP_TRANSFER, const QString &providerId = QString() ) = 0;
95
101 virtual bool requiresAdvancedEffects() const = 0;
102
114 virtual bool hasNonDefaultCompositionMode() const = 0;
115
124 virtual void multiplyOpacity( double opacityFactor ) { Q_UNUSED( opacityFactor ); };
125
126
127 // static stuff
128
130 static QgsAbstractVectorLayerLabeling *create( const QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY;
131
137 Q_DECL_DEPRECATED virtual void toSld( QDomNode &parent, const QVariantMap &props ) const SIP_DEPRECATED;
138
144 virtual bool toSld( QDomNode &parent, QgsSldExportContext &context ) const;
145
155 virtual bool accept( QgsStyleEntityVisitorInterface *visitor ) const;
156
162 static QgsPalLayerSettings defaultSettingsForLayer( const QgsVectorLayer *layer );
163
164 protected:
172 Q_DECL_DEPRECATED virtual void writeTextSymbolizer( QDomNode &parent, QgsPalLayerSettings &settings, const QVariantMap &props ) const SIP_DEPRECATED;
173
181 virtual bool writeTextSymbolizer( QDomNode &parent, QgsPalLayerSettings &settings, QgsSldExportContext &context ) const;
182
183 private:
184 Q_DISABLE_COPY( QgsAbstractVectorLayerLabeling )
185
186#ifdef SIP_RUN
188#endif
189};
190
199{
200 public:
203
204 QString type() const override;
208 QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) const override;
209 QgsPalLayerSettings settings( const QString &providerId = QString() ) const override;
210 bool accept( QgsStyleEntityVisitorInterface *visitor ) const override;
211
219 void setSettings( QgsPalLayerSettings *settings SIP_TRANSFER, const QString &providerId = QString() ) override;
220
221 bool requiresAdvancedEffects() const override;
222 bool hasNonDefaultCompositionMode() const override;
223 Q_DECL_DEPRECATED void toSld( QDomNode &parent, const QVariantMap &props ) const override SIP_DEPRECATED;
224 bool toSld( QDomNode &parent, QgsSldExportContext &context ) const override;
225 void multiplyOpacity( double opacityFactor ) override;
227 static QgsVectorLayerSimpleLabeling *create( const QDomElement &element, const QgsReadWriteContext &context ); // cppcheck-suppress duplInheritedMember
228
229 private:
230 std::unique_ptr<QgsPalLayerSettings> mSettings;
231};
232
233#endif // QGSVECTORLAYERLABELING_H
Abstract base class - its implementations define different approaches to the labeling of a vector lay...
virtual bool hasNonDefaultCompositionMode() const =0
Returns true the labeling requires a non-default composition mode.
virtual QStringList subProviders() const
Gets list of sub-providers within the layer's labeling.
virtual void setSettings(QgsPalLayerSettings *settings, const QString &providerId=QString())=0
Set pal settings for a specific provider (takes ownership).
virtual ~QgsAbstractVectorLayerLabeling()=default
virtual QgsPalLayerSettings settings(const QString &providerId=QString()) const =0
Gets associated label settings.
virtual bool requiresAdvancedEffects() const =0
Returns true if drawing labels requires advanced effects like composition modes, which could prevent ...
virtual QString type() const =0
Unique type string of the labeling configuration implementation.
virtual QgsVectorLayerLabelProvider * provider(QgsVectorLayer *layer) const
Factory for label provider implementation.
virtual QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) const =0
Returns labeling configuration as XML element.
virtual void multiplyOpacity(double opacityFactor)
Multiply opacity by opacityFactor.
virtual QgsAbstractVectorLayerLabeling * clone() const =0
Returns a new copy of the object.
Contains settings for how a map layer will be labeled.
A container for the context for various read/write operations on objects.
Holds SLD export options and other information related to SLD export of a QGIS layer style.
An interface for classes which can visit style entity (e.g.
Implements a label provider for vector layers.
QString type() const override
Unique type string of the labeling configuration implementation.
void multiplyOpacity(double opacityFactor) override
Multiply opacity by opacityFactor.
bool accept(QgsStyleEntityVisitorInterface *visitor) const override
Accepts the specified symbology visitor, causing it to visit all symbols associated with the labeling...
QgsPalLayerSettings settings(const QString &providerId=QString()) const override
Gets associated label settings.
QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) const override
Returns labeling configuration as XML element.
bool requiresAdvancedEffects() const override
Returns true if drawing labels requires advanced effects like composition modes, which could prevent ...
QgsVectorLayerSimpleLabeling(const QgsPalLayerSettings &settings)
Constructs simple labeling configuration with given initial settings.
void setSettings(QgsPalLayerSettings *settings, const QString &providerId=QString()) override
Set pal settings (takes ownership).
QgsVectorLayerLabelProvider * provider(QgsVectorLayer *layer) const override
static QgsVectorLayerSimpleLabeling * create(const QDomElement &element, const QgsReadWriteContext &context)
Create the instance from a DOM element with saved configuration.
QgsAbstractVectorLayerLabeling * clone() const override
Returns a new copy of the object.
Q_DECL_DEPRECATED void toSld(QDomNode &parent, const QVariantMap &props) const override
Writes the SE 1.1 TextSymbolizer element based on the current layer labeling settings.
bool hasNonDefaultCompositionMode() const override
Returns true the labeling requires a non-default composition mode.
Represents a vector layer which manages a vector based dataset.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:198
#define SIP_DEPRECATED
Definition qgis_sip.h:113
#define SIP_SKIP
Definition qgis_sip.h:133
#define SIP_TRANSFER
Definition qgis_sip.h:35
#define SIP_FACTORY
Definition qgis_sip.h:83
#define SIP_END
Definition qgis_sip.h:215