QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
qgsmeshlayerlabelprovider.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmeshlayerlabelprovider.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
18#ifndef QGSMESHLAYERLABELPROVIDER_H
19#define QGSMESHLAYERLABELPROVIDER_H
20
21#define SIP_NO_FILE
22
23#include "qgis_core.h"
24#include "qgslabelingengine.h"
25#include "qgsrenderer.h"
26#include "qgspallabeling.h"
27
28class QgsMeshLayer;
29
41{
42 public:
43
46 const QString &providerId,
47 const QgsPalLayerSettings *settings,
48 const QString &layerName = QString(),
49 bool labelFaces = false );
50
52
53 QList<QgsLabelFeature *> labelFeatures( QgsRenderContext &context ) override;
54
55 //void drawLabelBackground( QgsRenderContext &context, pal::LabelPosition *label ) const override;
56 void drawLabel( QgsRenderContext &context, pal::LabelPosition *label ) const override;
57 //void drawUnplacedLabel( QgsRenderContext &context, pal::LabelPosition *label ) const override;
58 void startRender( QgsRenderContext &context ) override;
59 void stopRender( QgsRenderContext &context ) override;
60
67 virtual bool prepare( QgsRenderContext &context, QSet<QString> &attributeNames );
68
83 virtual QList< QgsLabelFeature * > registerFeature( const QgsFeature &feature, QgsRenderContext &context, const QgsGeometry &obstacleGeometry = QgsGeometry(), const QgsSymbol *symbol = nullptr );
84
88 const QgsPalLayerSettings &settings() const;
89
91 bool labelFaces() const { return mLabelFaces; }
92
93 protected:
95 void init();
97 void drawLabelPrivate( pal::LabelPosition *label, QgsRenderContext &context, QgsPalLayerSettings &tmpLyr, Qgis::TextComponent drawType, double dpiRatio = 1.0 ) const;
98
99 protected:
102
103 bool mLabelFaces = false;
104
107
109 QList<QgsLabelFeature *> mLabels;
110
111 private:
112 std::unique_ptr<QgsVectorLayerLabelProvider> mVectorLabelProvider;
113
114 friend class TestQgsLabelingEngine;
115};
116
117#endif // QGSMESHLAYERLABELPROVIDER_H
TextComponent
Text components.
Definition qgis.h:2716
The QgsAbstractLabelProvider class is an interface class.
virtual QList< QgsLabelFeature * > labelFeatures(QgsRenderContext &context)=0
Returns list of label features (they are owned by the provider and thus deleted on its destruction)
virtual void stopRender(QgsRenderContext &context)
To be called after rendering is complete.
virtual void drawLabel(QgsRenderContext &context, pal::LabelPosition *label) const =0
Draw this label at the position determined by the labeling engine.
virtual void startRender(QgsRenderContext &context)
To be called before rendering of labels begins.
This class represents a coordinate reference system (CRS).
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:58
A geometry is the spatial representation of a feature.
The QgsMeshLayerLabelProvider class implements a label provider for mesh layers.
QgsCoordinateReferenceSystem mCrs
Layer's CRS.
bool labelFaces() const
Returns false if labeling mesh vertices, true if labeling mesh faces.
void drawLabelPrivate(pal::LabelPosition *label, QgsRenderContext &context, QgsPalLayerSettings &tmpLyr, Qgis::TextComponent drawType, double dpiRatio=1.0) const
Internal label drawing method.
QList< QgsLabelFeature * > mLabels
List of generated.
QgsPalLayerSettings mSettings
Layer's labeling configuration.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
Contains settings for how a map layer will be labeled.
Contains information about the context of a rendering operation.
Abstract base class for all rendered symbols.
Definition qgssymbol.h:231
LabelPosition is a candidate feature label position.