QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
Loading...
Searching...
No Matches
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 "qgis.h"
23
24#include <QDomNode>
25#include <QString>
26#include <QStringList>
27
28using namespace Qt::StringLiterals;
29
30class QDomDocument;
31class QDomElement;
32
35class QgsMeshLayer;
38
39
47{
48 public:
50 virtual ~QgsAbstractMeshLayerLabeling() = default;
51
53 virtual QString type() const = 0;
54
57
63 {
64 Q_UNUSED( layer )
65 return nullptr;
66 }
67
69 virtual QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) const = 0;
70
72 virtual QStringList subProviders() const { return QStringList( QString() ); }
73
78 virtual QgsPalLayerSettings settings( const QString &providerId = QString() ) const = 0;
79
86 virtual void setSettings( QgsPalLayerSettings *settings SIP_TRANSFER, const QString &providerId = QString() ) = 0;
87
93 virtual bool requiresAdvancedEffects() const = 0;
94
106 virtual bool hasNonDefaultCompositionMode() const = 0;
107
114 virtual void multiplyOpacity( double opacityFactor ) { Q_UNUSED( opacityFactor ); };
115
116
117 // static stuff
118
120 static QgsAbstractMeshLayerLabeling *create( const QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY;
121
125 virtual void toSld( QDomNode &parent, const QVariantMap &props ) const
126 {
127 Q_UNUSED( parent )
128 Q_UNUSED( props )
129 QDomDocument doc = parent.ownerDocument();
130 parent.appendChild( doc.createComment( u"SE Export for %1 not implemented yet"_s.arg( type() ) ) );
131 }
132
140 virtual bool accept( QgsStyleEntityVisitorInterface *visitor ) const;
141
145 static QgsPalLayerSettings defaultSettingsForLayer( const QgsMeshLayer *layer );
146
147 private:
148 Q_DISABLE_COPY( QgsAbstractMeshLayerLabeling )
149
150#ifdef SIP_RUN
152#endif
153};
154
162{
163 public:
168 explicit QgsMeshLayerSimpleLabeling( const QgsPalLayerSettings &settings, bool labelFaces = false );
169
170 QString type() const override;
174 QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) const override;
175 QgsPalLayerSettings settings( const QString &providerId = QString() ) const override;
176 bool accept( QgsStyleEntityVisitorInterface *visitor ) const override;
177
184 void setSettings( QgsPalLayerSettings *settings SIP_TRANSFER, const QString &providerId = QString() ) override;
185
186 bool requiresAdvancedEffects() const override;
187 bool hasNonDefaultCompositionMode() const override;
188 void multiplyOpacity( double opacityFactor ) override;
190 static QgsMeshLayerSimpleLabeling *create( const QDomElement &element, const QgsReadWriteContext &context ); // cppcheck-suppress duplInheritedMember
191
192 private:
193 std::unique_ptr<QgsPalLayerSettings> mSettings;
194 bool mLabelFaces = false;
195};
196
197#endif // QGSMESHLAYERLABELING_H
Abstract base class - its implementations define different approaches to the labeling of a mesh layer...
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 bool hasNonDefaultCompositionMode() const =0
Returns true the labeling requires a non-default composition mode.
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
Implements a label provider for mesh layers.
QgsMeshLayerLabelProvider * provider(QgsMeshLayer *layer) const override
QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) const override
Returns labeling configuration as XML element.
void setSettings(QgsPalLayerSettings *settings, const QString &providerId=QString()) override
Set pal settings (takes ownership).
QgsMeshLayerSimpleLabeling * clone() const override
Returns a new copy of the object.
void multiplyOpacity(double opacityFactor) override
Multiply opacity by opacityFactor.
bool hasNonDefaultCompositionMode() const override
Returns true the labeling requires a non-default composition mode.
static QgsMeshLayerSimpleLabeling * create(const QDomElement &element, const QgsReadWriteContext &context)
Create the instance from a DOM element with saved configuration.
bool requiresAdvancedEffects() const override
Returns true if drawing labels requires advanced effects like composition modes, which could prevent ...
QgsPalLayerSettings settings(const QString &providerId=QString()) const override
Gets associated label settings.
QgsMeshLayerSimpleLabeling(const QgsPalLayerSettings &settings, bool labelFaces=false)
Constructs simple labeling configuration with given initial settings.
QString type() const override
Unique type string of the labeling configuration implementation.
bool accept(QgsStyleEntityVisitorInterface *visitor) const override
Accepts the specified symbology visitor, causing it to visit all symbols associated with the labeling...
Represents a mesh layer supporting display of data on structured or unstructured meshes.
Contains settings for how a map layer will be labeled.
A container for the context for various read/write operations on objects.
An interface for classes which can visit style entity (e.g.
#define SIP_SKIP
Definition qgis_sip.h:133
#define SIP_TRANSFER
Definition qgis_sip.h:35
#define SIP_FACTORY
Definition qgis_sip.h:83