QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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 
26 class QDomDocument;
27 class QDomElement;
28 
31 class QgsVectorLayer;
33 
41 {
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;
51  SIP_END
52 #endif
53 
54  public:
57  virtual ~QgsAbstractVectorLayerLabeling() = default;
58 
60  virtual QString type() const = 0;
61 
63  virtual QgsAbstractVectorLayerLabeling *clone() const = 0 SIP_FACTORY;
64 
69  virtual QgsVectorLayerLabelProvider *provider( QgsVectorLayer *layer ) const SIP_SKIP { Q_UNUSED( layer ); return nullptr; }
70 
72  virtual QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) const = 0;
73 
75  virtual QStringList subProviders() const { return QStringList( QString() ); }
76 
81  virtual QgsPalLayerSettings settings( const QString &providerId = QString() ) const = 0;
82 
91  virtual void setSettings( QgsPalLayerSettings *settings SIP_TRANSFER, const QString &providerId = QString() ) = 0;
92 
99  virtual bool requiresAdvancedEffects() const = 0;
100 
101  // static stuff
102 
104  static QgsAbstractVectorLayerLabeling *create( const QDomElement &element, const QgsReadWriteContext &context ) SIP_FACTORY;
105 
109  virtual void toSld( QDomNode &parent, const QgsStringMap &props ) const
110  {
111  Q_UNUSED( parent )
112  Q_UNUSED( props )
113  QDomDocument doc = parent.ownerDocument();
114  parent.appendChild( doc.createComment( QStringLiteral( "SE Export for %1 not implemented yet" ).arg( type() ) ) );
115  }
116 
117  protected:
118 
125  virtual void writeTextSymbolizer( QDomNode &parent, QgsPalLayerSettings &settings, const QgsStringMap &props ) const;
126 
127  private:
128  Q_DISABLE_COPY( QgsAbstractVectorLayerLabeling )
129 
130 #ifdef SIP_RUN
132 #endif
133 
134 };
135 
145 {
146  public:
148  explicit QgsVectorLayerSimpleLabeling( const QgsPalLayerSettings &settings );
149 
150  QString type() const override;
154  QDomElement save( QDomDocument &doc, const QgsReadWriteContext &context ) const override;
155  QgsPalLayerSettings settings( const QString &providerId = QString() ) const override;
156 
165  void setSettings( QgsPalLayerSettings *settings SIP_TRANSFER, const QString &providerId = QString() ) override;
166 
167  bool requiresAdvancedEffects() const override;
168  void toSld( QDomNode &parent, const QgsStringMap &props ) const override;
169 
171  static QgsVectorLayerSimpleLabeling *create( const QDomElement &element, const QgsReadWriteContext &context );
172 
173  private:
174  std::unique_ptr<QgsPalLayerSettings> mSettings;
175 };
176 
177 #endif // QGSVECTORLAYERLABELING_H
The class is used as a container of context for various read/write operations on other objects...
virtual QgsAbstractVectorLayerLabeling * clone() const =0
Returns a new copy of the object.
virtual QStringList subProviders() const
Gets list of sub-providers within the layer&#39;s labeling.
virtual QgsVectorLayerLabelProvider * provider(QgsVectorLayer *layer) const
Factory for label provider implementation.
virtual void setSettings(QgsPalLayerSettings *settings, const QString &providerId=QString())=0
Set pal settings for a specific provider (takes ownership).
The QgsVectorLayerLabelProvider class implements a label provider for vector layers.
QMap< QString, QString > QgsStringMap
Definition: qgis.h:577
virtual bool requiresAdvancedEffects() const =0
Returns true if drawing labels requires advanced effects like composition modes, which could prevent ...
virtual QgsPalLayerSettings settings(const QString &providerId=QString()) const =0
Gets associated label settings.
#define SIP_SKIP
Definition: qgis_sip.h:119
#define SIP_TRANSFER
Definition: qgis_sip.h:36
virtual QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) const =0
Returns labeling configuration as XML element.
#define SIP_END
Definition: qgis_sip.h:182
virtual void toSld(QDomNode &parent, const QgsStringMap &props) const
Writes the SE 1.1 TextSymbolizer element based on the current layer labeling settings.
#define SIP_FACTORY
Definition: qgis_sip.h:69
Abstract base class - its implementations define different approaches to the labeling of a vector lay...
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:165
Basic implementation of the labeling interface.
virtual QString type() const =0
Unique type string of the labeling configuration implementation.
Represents a vector layer which manages a vector based data sets.
static QgsAbstractVectorLayerLabeling * create(const QDomElement &element, const QgsReadWriteContext &context)
Try to create instance of an implementation based on the XML data.