QGIS API Documentation 3.36.0-Maidenhead (09951dc0acf)
Loading...
Searching...
No Matches
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
30{
31 public:
32
33 // TODO QGIS 4 - remove
34
47
49
51 void clear();
52
54 void setFlags( Qgis::LabelingFlags flags ) { mFlags = flags; }
56 Qgis::LabelingFlags flags() const { return mFlags; }
58 bool testFlag( Qgis::LabelingFlag f ) const { return mFlags.testFlag( f ); }
60 void setFlag( Qgis::LabelingFlag f, bool enabled = true ) { if ( enabled ) mFlags |= f; else mFlags &= ~static_cast< int >( f ); }
61
68 double maximumLineCandidatesPerCm() const { return mMaxLineCandidatesPerCm; }
69
76 void setMaximumLineCandidatesPerCm( double candidates ) { mMaxLineCandidatesPerCm = candidates; }
77
84 double maximumPolygonCandidatesPerCmSquared() const { return mMaxPolygonCandidatesPerCmSquared; }
85
92 void setMaximumPolygonCandidatesPerCmSquared( double candidates ) { mMaxPolygonCandidatesPerCmSquared = candidates; }
93
98 Q_DECL_DEPRECATED void numCandidatePositions( int &candPoint, int &candLine, int &candPolygon ) const SIP_DEPRECATED
99 {
100 Q_UNUSED( candPoint )
101 Q_UNUSED( candLine )
102 Q_UNUSED( candPolygon )
103 }
104
109 Q_DECL_DEPRECATED void setNumCandidatePositions( int candPoint, int candLine, int candPolygon ) SIP_DEPRECATED
110 {
111 Q_UNUSED( candPoint )
112 Q_UNUSED( candLine )
113 Q_UNUSED( candPolygon )
114 }
115
120 Q_DECL_DEPRECATED void setSearchMethod( Search s ) SIP_DEPRECATED { Q_UNUSED( s ) }
121
126 Q_DECL_DEPRECATED Search searchMethod() const SIP_DEPRECATED { return Chain; }
127
129 void readSettingsFromProject( QgsProject *project );
131 void writeSettingsToProject( QgsProject *project );
132
133 // TODO QGIS 4.0: In reality the text render format settings don't only apply to labels, but also
134 // ANY text rendered using QgsTextRenderer (including some non-label text items in layouts).
135 // These methods should possibly be moved out of here and into the general QgsProject settings.
136
144 {
145 return mDefaultTextRenderFormat;
146 }
147
155 {
156 mDefaultTextRenderFormat = format;
157 }
158
165 QColor unplacedLabelColor() const;
166
173 void setUnplacedLabelColor( const QColor &color );
174
181 Qgis::LabelPlacementEngineVersion placementVersion() const;
182
189 void setPlacementVersion( Qgis::LabelPlacementEngineVersion version );
190
191 private:
193 Qgis::LabelingFlags mFlags = Qgis::LabelingFlag::UsePartialCandidates;
195 Search mSearchMethod = Chain;
196
197 // maximum density of line/polygon candidates per mm
198 double mMaxLineCandidatesPerCm = 5;
199 double mMaxPolygonCandidatesPerCmSquared = 2.5;
200
201 QColor mUnplacedLabelColor = QColor( 255, 0, 0 );
202
204
206
207};
208
209#endif // QGSLABELINGENGINESETTINGS_H
LabelingFlag
Various flags that affect drawing and placement of labels.
Definition qgis.h:2301
@ UsePartialCandidates
Whether to use also label candidates that are partially outside of the map view.
TextRenderFormat
Flags which control how map layer renderers behave.
Definition qgis.h:2287
@ AlwaysOutlines
Always render text using path objects (AKA outlines/curves). This setting guarantees the best quality...
LabelPlacementEngineVersion
Labeling placement engine version.
Definition qgis.h:2332
@ Version2
Version 2 (default for new projects since QGIS 3.12)
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:107
#define SIP_DEPRECATED
Definition qgis_sip.h:106