QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
Loading...
Searching...
No Matches
qgslabelingenginerule.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgslabelingenginerule.cpp
3 ---------------------
4 Date : August 2024
5 Copyright : (C) 2024 by 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
17
18
19//
20// QgsLabelingEngineContext
21//
22
24 : mRenderContext( renderContext )
25{
26
27}
28
30{
31 return mMapBoundaryGeometry;
32}
33
35{
36 mMapBoundaryGeometry = geometry;
37}
38
40{
41 return mExtent;
42}
43
45{
46 mExtent = extent;
47}
48
49//
50// QgsAbstractLabelingEngineRule
51//
52
54
59
64
66{
67 return candidateBounds;
68}
69
74
79
81{
82 other->mName = mName;
83 other->mIsActive = mIsActive;
84}
85
87{
88 return true;
89}
90
92{
93 return mName.isEmpty() ? displayType() : mName;
94}
95
97{
98 return mIsActive;
99}
100
102{
103 mIsActive = active;
104}
Abstract base class for labeling engine rules.
virtual void alterCandidateCost(pal::LabelPosition *candidate, QgsLabelingEngineContext &context) const
Provides an opportunity for the rule to alter the cost for a candidate.
virtual void resolveReferences(const QgsProject *project)
Resolves reference to layers from stored layer ID.
void setActive(bool active)
Sets whether the rule is active.
virtual bool isAvailable() const
Returns true if the rule is available for use within the current QGIS environment.
virtual QgsRectangle modifyCandidateConflictSearchBoundingBox(const QgsRectangle &candidateBounds) const
Returns a (possibly expanded) bounding box to use when searching for conflicts for a candidate.
bool active() const
Returns true if the rule is active.
virtual bool candidatesAreConflicting(const pal::LabelPosition *lp1, const pal::LabelPosition *lp2) const
Returns true if a labeling candidate lp1 conflicts with lp2 after applying the rule.
virtual QString displayType() const =0
Returns a user-friendly, translated string representing the rule type.
virtual QString description() const
Returns a user-friendly description of the rule.
virtual bool candidateIsIllegal(const pal::LabelPosition *candidate, QgsLabelingEngineContext &context) const
Returns true if a labeling candidate violates the rule and should be eliminated.
virtual void copyCommonProperties(QgsAbstractLabelingEngineRule *other) const
Copies common properties from this object to an other.
A geometry is the spatial representation of a feature.
Encapsulates the context for a labeling engine run.
QgsGeometry mapBoundaryGeometry() const
Returns the map label boundary geometry, which defines the limits within which labels may be placed i...
void setMapBoundaryGeometry(const QgsGeometry &geometry)
Sets the map label boundary geometry, which defines the limits within which labels may be placed in t...
void setExtent(const QgsRectangle &extent)
Sets the map extent defining the limits for labeling.
QgsRectangle extent() const
Returns the map extent defining the limits for labeling.
QgsLabelingEngineContext(QgsRenderContext &renderContext)
Constructor for QgsLabelingEngineContext.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:107
A rectangle specified with double values.
Contains information about the context of a rendering operation.
LabelPosition is a candidate feature label position.