QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
qgslabelingenginesettings.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslabelingenginesettings.h
3 ---------------------
4 begin : April 2017
5 copyright : (C) 2017 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 QGSLABELINGENGINESETTINGS_H
16#define QGSLABELINGENGINESETTINGS_H
17
18#include "qgis_core.h"
19#include "qgis_sip.h"
20#include "qgis.h"
21#include <QColor>
22
23class QgsProject;
24
31{
32 public:
33
34 // TODO QGIS 4 - remove
35
40 enum Search
41 {
46 Falp
47 };
48
50
52 void clear();
53
55 void setFlags( Qgis::LabelingFlags flags ) { mFlags = flags; }
57 Qgis::LabelingFlags flags() const { return mFlags; }
59 bool testFlag( Qgis::LabelingFlag f ) const { return mFlags.testFlag( f ); }
61 void setFlag( Qgis::LabelingFlag f, bool enabled = true ) { if ( enabled ) mFlags |= f; else mFlags &= ~static_cast< int >( f ); }
62
69 double maximumLineCandidatesPerCm() const { return mMaxLineCandidatesPerCm; }
70
77 void setMaximumLineCandidatesPerCm( double candidates ) { mMaxLineCandidatesPerCm = candidates; }
78
85 double maximumPolygonCandidatesPerCmSquared() const { return mMaxPolygonCandidatesPerCmSquared; }
86
93 void setMaximumPolygonCandidatesPerCmSquared( double candidates ) { mMaxPolygonCandidatesPerCmSquared = candidates; }
94
99 Q_DECL_DEPRECATED void numCandidatePositions( int &candPoint, int &candLine, int &candPolygon ) const SIP_DEPRECATED
100 {
101 Q_UNUSED( candPoint )
102 Q_UNUSED( candLine )
103 Q_UNUSED( candPolygon )
104 }
105
110 Q_DECL_DEPRECATED void setNumCandidatePositions( int candPoint, int candLine, int candPolygon ) SIP_DEPRECATED
111 {
112 Q_UNUSED( candPoint )
113 Q_UNUSED( candLine )
114 Q_UNUSED( candPolygon )
115 }
116
121 Q_DECL_DEPRECATED void setSearchMethod( Search s ) SIP_DEPRECATED { Q_UNUSED( s ) }
122
127 Q_DECL_DEPRECATED Search searchMethod() const SIP_DEPRECATED { return Chain; }
128
130 void readSettingsFromProject( QgsProject *project );
132 void writeSettingsToProject( QgsProject *project );
133
134 // TODO QGIS 4.0: In reality the text render format settings don't only apply to labels, but also
135 // ANY text rendered using QgsTextRenderer (including some non-label text items in layouts).
136 // These methods should possibly be moved out of here and into the general QgsProject settings.
137
145 {
146 return mDefaultTextRenderFormat;
147 }
148
156 {
157 mDefaultTextRenderFormat = format;
158 }
159
166 QColor unplacedLabelColor() const;
167
174 void setUnplacedLabelColor( const QColor &color );
175
182 Qgis::LabelPlacementEngineVersion placementVersion() const;
183
190 void setPlacementVersion( Qgis::LabelPlacementEngineVersion version );
191
192 private:
194 Qgis::LabelingFlags mFlags = Qgis::LabelingFlag::UsePartialCandidates;
196 Search mSearchMethod = Chain;
197
198 // maximum density of line/polygon candidates per mm
199 double mMaxLineCandidatesPerCm = 5;
200 double mMaxPolygonCandidatesPerCmSquared = 2.5;
201
202 QColor mUnplacedLabelColor = QColor( 255, 0, 0 );
203
204 Qgis::LabelPlacementEngineVersion mPlacementVersion = Qgis::LabelPlacementEngineVersion::Version2;
205
206 Qgis::TextRenderFormat mDefaultTextRenderFormat = Qgis::TextRenderFormat::AlwaysOutlines;
207
208};
209
210#endif // QGSLABELINGENGINESETTINGS_H
LabelingFlag
Various flags that affect drawing and placement of labels.
Definition: qgis.h:1741
@ UsePartialCandidates
Whether to use also label candidates that are partially outside of the map view.
TextRenderFormat
Options for rendering text.
Definition: qgis.h:1727
LabelPlacementEngineVersion
Labeling placement engine version.
Definition: qgis.h:1772
Stores global configuration for labeling engine.
Q_DECL_DEPRECATED void numCandidatePositions(int &candPoint, int &candLine, int &candPolygon) const
Gets number of candidate positions that will be generated for each label feature.
Qgis::TextRenderFormat defaultTextRenderFormat() const
Returns the default text rendering format for the labels.
void setDefaultTextRenderFormat(Qgis::TextRenderFormat format)
Sets the default text rendering format for the labels.
void setFlag(Qgis::LabelingFlag f, bool enabled=true)
Sets whether a particual flag is enabled.
Q_DECL_DEPRECATED Search searchMethod() const
Which search method to use for removal collisions between labels.
Search
Search methods in the PAL library to remove colliding labels (methods have different processing speed...
void setMaximumPolygonCandidatesPerCmSquared(double candidates)
Sets the maximum number of polygon label candidates per centimeter squared.
bool testFlag(Qgis::LabelingFlag f) const
Test whether a particular flag is enabled.
Qgis::LabelingFlags flags() const
Gets flags of the labeling engine.
Q_DECL_DEPRECATED void setNumCandidatePositions(int candPoint, int candLine, int candPolygon)
Sets the number of candidate positions that will be generated for each label feature.
void setFlags(Qgis::LabelingFlags flags)
Sets flags of the labeling engine.
double maximumPolygonCandidatesPerCmSquared() const
Returns the maximum number of polygon label candidate positions per centimeter squared.
Q_DECL_DEPRECATED void setSearchMethod(Search s)
Used to set which search method to use for removal collisions between labels.
void setMaximumLineCandidatesPerCm(double candidates)
Sets the maximum number of line label candidates per centimeter.
double maximumLineCandidatesPerCm() const
Returns the maximum number of line label candidate positions per centimeter.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition: qgsproject.h:105
#define SIP_DEPRECATED
Definition: qgis_sip.h:106