QGIS API Documentation 4.3.0-Master (0de80482b60)
Loading...
Searching...
No Matches
qgslabelingresults.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslabelingresults.h
3 -------------------
4 begin : February 2021
5 copyright : (C) Nyall Dawson
6 email : nyall dot dawson 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
16#ifndef QGSLABELINGRESULTS_H
17#define QGSLABELINGRESULTS_H
18
19#include <memory>
20
21#include "qgis_core.h"
22#include "qgis_sip.h"
23#include "qgscalloutposition.h"
24#include "qgslabelposition.h"
25#include "qgsmapsettings.h"
26
27#include <QTransform>
28
29class QgsMapSettings;
31
32#ifndef SIP_RUN
33namespace pal
34{
35 class LabelPosition;
36}
37#endif
38
43class CORE_EXPORT QgsLabelingResults
44{
45 public:
50 QgsLabelingResults( bool enableSearchTree = true );
52
55
63 bool hasSearchTree() const;
64
65#ifndef SIP_RUN
73 bool insertLabel(
74 pal::LabelPosition *labelPos,
75 QgsFeatureId featureId,
76 const QString &layerName,
77 const QString &labeltext,
78 const QFont &labelfont,
79 bool diagram = false,
80 bool pinned = false,
81 const QString &providerId = QString(),
82 bool isUnplaced = false,
83 long long linkedId = 0,
84 long long linkedPositionIndex = 0,
85 long long subPartId = 0
86 );
87#endif
88
96 bool insertCallout( const QgsCalloutPosition &position ) SIP_SKIP;
97
103 QList< QgsLabelPosition > allLabels() const;
104
110 QList<QgsLabelPosition> labelsAtPosition( const QgsPointXY &p ) const;
111
117 QList<QgsLabelPosition> labelsWithinRect( const QgsRectangle &r ) const;
118
126 QList<QgsLabelPosition> groupedLabelPositions( long long groupId ) const;
127
137 QList<QgsCalloutPosition> calloutsWithinRectangle( const QgsRectangle &rectangle ) const;
138
143 void setMapSettings( const QgsMapSettings &settings );
144
145 private:
146#ifdef SIP_RUN
148#endif
149
150 std::unique_ptr< QgsLabelSearchTree > mLabelSearchTree;
151 // used only when mLabelSearchTree is nullptr
152 QList< QgsLabelPosition > mAllLabels;
153
154 QgsMapSettings mMapSettings;
155 QTransform mTransform;
156 long long mNextFeatureId = 1;
157 QHash< long long, QList< QgsLabelPosition * > > mLinkedLabelHash;
158
159 std::vector< std::unique_ptr< QgsLabelPosition > > mOwnedPositions;
160 std::vector< std::unique_ptr< QgsCalloutPosition > > mOwnedCalloutPositions;
161};
162
163#endif // QGSLABELINGRESULTS_H
Represents the calculated placement of a map label callout line.
Queries the labeling structure at a given point.
QgsLabelingResults(const QgsLabelingResults &)=delete
bool insertCallout(const QgsCalloutPosition &position)
Inserts a rendered callout position.
bool hasSearchTree() const
Returns true if the results were constructed with search tree enabled.
QList< QgsCalloutPosition > calloutsWithinRectangle(const QgsRectangle &rectangle) const
Returns a list of callouts with origins or destinations inside the given rectangle.
QgsLabelingResults(bool enableSearchTree=true)
Constructor for QgsLabelingResults.
bool insertLabel(pal::LabelPosition *labelPos, QgsFeatureId featureId, const QString &layerName, const QString &labeltext, const QFont &labelfont, bool diagram=false, bool pinned=false, const QString &providerId=QString(), bool isUnplaced=false, long long linkedId=0, long long linkedPositionIndex=0, long long subPartId=0)
Inserts label position.
QgsLabelingResults & operator=(const QgsLabelingResults &rh)=delete
void setMapSettings(const QgsMapSettings &settings)
Sets the map settings associated with the labeling run.
QList< QgsLabelPosition > allLabels() const
Returns a list of all labels generated by the labeling run.
QList< QgsLabelPosition > labelsAtPosition(const QgsPointXY &p) const
Returns the details of any labels placed at the specified point (in map coordinates).
QList< QgsLabelPosition > groupedLabelPositions(long long groupId) const
Returns a list of all label positions sharing the same group ID (i.e.
QList< QgsLabelPosition > labelsWithinRect(const QgsRectangle &r) const
Returns the details of any labels placed within the specified rectangle (in map coordinates).
Contains configuration for rendering maps.
Represents a 2D point.
Definition qgspointxy.h:62
A rectangle specified with double values.
LabelPosition is a candidate feature label position.
#define SIP_SKIP
Definition qgis_sip.h:138
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features