QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
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 <QString>
21#include <QStringList>
22#include <QDomNode>
23
24#include "qgis.h"
25
26class QDomDocument;
27class QDomElement;
28
31class QgsVectorLayer;
34
42{
43
44#ifdef SIP_RUN
46 if ( sipCpp->type() == "simple" )
47 sipType = sipType_QgsVectorLayerSimpleLabeling;
48 else if ( sipCpp->type() == "rule-based" )
49 sipType = sipType_QgsRuleBasedLabeling;
50 else
51 sipType = 0;
53#endif
54
55 public:
56
60
62 virtual QString type() const = 0;
63
66
71 virtual QgsVectorLayerLabelProvider *provider( QgsVectorLayer *layer ) const SIP_SKIP { Q_UNUSED( layer ) return nullptr; }
72
74 virtual QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) const = 0;
75
77 virtual QStringList subProviders() const { return QStringList( QString() ); }
78
83 virtual QgsPalLayerSettings settings( const QString &providerId = QString() ) const = 0;
84
93 virtual void setSettings( QgsPalLayerSettings *settings SIP_TRANSFER, const QString &providerId = QString() ) = 0;
94
101 virtual bool requiresAdvancedEffects() const = 0;
102
111 virtual void multiplyOpacity( double opacityFactor ) { Q_UNUSED( opacityFactor ); };
112
113
114 // static stuff
115
117 static QgsAbstractVectorLayerLabeling *create( const QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY;
118
122 virtual void toSld( QDomNode &parent, const QVariantMap &props ) const
123 {
124 Q_UNUSED( parent )
125 Q_UNUSED( props )
126 QDomDocument doc = parent.ownerDocument();
127 parent.appendChild( doc.createComment( QStringLiteral( "SE Export for %1 not implemented yet" ).arg( type() ) ) );
128 }
129
139 virtual bool accept( QgsStyleEntityVisitorInterface *visitor ) const;
140
146 static QgsPalLayerSettings defaultSettingsForLayer( const QgsVectorLayer *layer );
147
148 protected:
149
156 virtual void writeTextSymbolizer( QDomNode &parent, QgsPalLayerSettings &settings, const QVariantMap &props ) const;
157
158 private:
159 Q_DISABLE_COPY( QgsAbstractVectorLayerLabeling )
160
161#ifdef SIP_RUN
163#endif
164
165};
166
176{
177 public:
179 explicit QgsVectorLayerSimpleLabeling( const QgsPalLayerSettings &settings );
180
181 QString type() const override;
182 QgsAbstractVectorLayerLabeling *clone() const override SIP_FACTORY;
184 QgsVectorLayerLabelProvider *provider( QgsVectorLayer *layer ) const override SIP_SKIP;
185 QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) const override;
186 QgsPalLayerSettings settings( const QString &providerId = QString() ) const override;
187 bool accept( QgsStyleEntityVisitorInterface *visitor ) const override;
188
197 void setSettings( QgsPalLayerSettings *settings SIP_TRANSFER, const QString &providerId = QString() ) override;
198
199 bool requiresAdvancedEffects() const override;
200 void toSld( QDomNode &parent, const QVariantMap &props ) const override;
201 void multiplyOpacity( double opacityFactor ) override;
203 static QgsVectorLayerSimpleLabeling *create( const QDomElement &element, const QgsReadWriteContext &context );
204
205 private:
206 std::unique_ptr<QgsPalLayerSettings> mSettings;
207};
208
209#endif // QGSVECTORLAYERLABELING_H
Abstract base class - its implementations define different approaches to the labeling of a vector lay...
virtual void toSld(QDomNode &parent, const QVariantMap &props) const
Writes the SE 1.1 TextSymbolizer element based on the current layer labeling settings.
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.
QgsAbstractVectorLayerLabeling()=default
Default constructor.
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.
The class is used as a container of context for various read/write operations on other objects.
An interface for classes which can visit style entity (e.g.
The QgsVectorLayerLabelProvider class implements a label provider for vector layers.
Basic implementation of the labeling interface.
Represents a vector layer which manages a vector based data sets.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:186
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_FACTORY
Definition: qgis_sip.h:76
#define SIP_END
Definition: qgis_sip.h:203