QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
qgsmeshlayerlabeling.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmeshlayerlabeling.h
3 ---------------------
4 begin : November 2023
5 copyright : (C) 2023 by Alexander Bruy
6 email : alexander dot bruy at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#ifndef QGSMESHLAYERLABELING_H
18#define QGSMESHLAYERLABELING_H
19
20#include <memory>
21
22#include <QString>
23#include <QStringList>
24#include <QDomNode>
25
26#include "qgis.h"
27
28class QDomDocument;
29class QDomElement;
30
33class QgsMeshLayer;
36
37
45{
46 public:
47
50 virtual ~QgsAbstractMeshLayerLabeling() = default;
51
53 virtual QString type() const = 0;
54
57
62 virtual QgsMeshLayerLabelProvider *provider( QgsMeshLayer *layer ) const SIP_SKIP { Q_UNUSED( layer ) return nullptr; }
63
65 virtual QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) const = 0;
66
68 virtual QStringList subProviders() const { return QStringList( QString() ); }
69
74 virtual QgsPalLayerSettings settings( const QString &providerId = QString() ) const = 0;
75
82 virtual void setSettings( QgsPalLayerSettings *settings SIP_TRANSFER, const QString &providerId = QString() ) = 0;
83
89 virtual bool requiresAdvancedEffects() const = 0;
90
97 virtual void multiplyOpacity( double opacityFactor ) { Q_UNUSED( opacityFactor ); };
98
99
100 // static stuff
101
103 static QgsAbstractMeshLayerLabeling *create( const QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY;
104
108 virtual void toSld( QDomNode &parent, const QVariantMap &props ) const
109 {
110 Q_UNUSED( parent )
111 Q_UNUSED( props )
112 QDomDocument doc = parent.ownerDocument();
113 parent.appendChild( doc.createComment( QStringLiteral( "SE Export for %1 not implemented yet" ).arg( type() ) ) );
114 }
115
123 virtual bool accept( QgsStyleEntityVisitorInterface *visitor ) const;
124
128 static QgsPalLayerSettings defaultSettingsForLayer( const QgsMeshLayer *layer );
129
130 private:
131 Q_DISABLE_COPY( QgsAbstractMeshLayerLabeling )
132
133#ifdef SIP_RUN
135#endif
136
137};
138
146{
147 public:
148
153 explicit QgsMeshLayerSimpleLabeling( const QgsPalLayerSettings &settings, bool labelFaces = false );
154
155 QString type() const override;
156 QgsMeshLayerSimpleLabeling *clone() const override SIP_FACTORY;
158 QgsMeshLayerLabelProvider *provider( QgsMeshLayer *layer ) const override SIP_SKIP;
159 QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) const override;
160 QgsPalLayerSettings settings( const QString &providerId = QString() ) const override;
161 bool accept( QgsStyleEntityVisitorInterface *visitor ) const override;
162
169 void setSettings( QgsPalLayerSettings *settings SIP_TRANSFER, const QString &providerId = QString() ) override;
170
171 bool requiresAdvancedEffects() const override;
172 void multiplyOpacity( double opacityFactor ) override;
174 static QgsMeshLayerSimpleLabeling *create( const QDomElement &element, const QgsReadWriteContext &context );
175
176 private:
177 std::unique_ptr<QgsPalLayerSettings> mSettings;
178 bool mLabelFaces = false;
179};
180
181#endif // QGSMESHLAYERLABELING_H
Abstract base class - its implementations define different approaches to the labeling of a mesh layer...
QgsAbstractMeshLayerLabeling()=default
Default constructor.
virtual QgsMeshLayerLabelProvider * provider(QgsMeshLayer *layer) const
Factory for label provider implementation.
virtual QStringList subProviders() const
Gets list of sub-providers within the layer's labeling.
virtual void toSld(QDomNode &parent, const QVariantMap &props) const
Writes the SE 1.1 TextSymbolizer element based on the current layer labeling settings.
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 QgsAbstractMeshLayerLabeling * clone() const =0
Returns a new copy of the object.
virtual QString type() const =0
Unique type string of the labeling configuration implementation.
virtual bool requiresAdvancedEffects() const =0
Returns true if drawing labels requires advanced effects like composition modes, which could prevent ...
virtual void setSettings(QgsPalLayerSettings *settings, const QString &providerId=QString())=0
Set pal settings for a specific provider (takes ownership).
virtual QgsPalLayerSettings settings(const QString &providerId=QString()) const =0
Gets associated label settings.
virtual ~QgsAbstractMeshLayerLabeling()=default
The QgsMeshLayerLabelProvider class implements a label provider for mesh layers.
Basic implementation of the labeling interface for mesh layer.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
Definition: qgsmeshlayer.h:101
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.
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_FACTORY
Definition: qgis_sip.h:76