QGIS API Documentation 3.41.0-Master (3440c17df1d)
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;
25class QDomDocument;
26class QDomElement;
28
34{
35 public:
36
37 // TODO QGIS 4 - remove
38
51
54
57
59 void clear();
60
62 void setFlags( Qgis::LabelingFlags flags ) { mFlags = flags; }
64 Qgis::LabelingFlags flags() const { return mFlags; }
66 bool testFlag( Qgis::LabelingFlag f ) const { return mFlags.testFlag( f ); }
68 void setFlag( Qgis::LabelingFlag f, bool enabled = true ) { if ( enabled ) mFlags |= f; else mFlags &= ~static_cast< int >( f ); }
69
76 double maximumLineCandidatesPerCm() const { return mMaxLineCandidatesPerCm; }
77
84 void setMaximumLineCandidatesPerCm( double candidates ) { mMaxLineCandidatesPerCm = candidates; }
85
92 double maximumPolygonCandidatesPerCmSquared() const { return mMaxPolygonCandidatesPerCmSquared; }
93
100 void setMaximumPolygonCandidatesPerCmSquared( double candidates ) { mMaxPolygonCandidatesPerCmSquared = candidates; }
101
106 Q_DECL_DEPRECATED void numCandidatePositions( int &candPoint, int &candLine, int &candPolygon ) const SIP_DEPRECATED
107 {
108 Q_UNUSED( candPoint )
109 Q_UNUSED( candLine )
110 Q_UNUSED( candPolygon )
111 }
112
117 Q_DECL_DEPRECATED void setNumCandidatePositions( int candPoint, int candLine, int candPolygon ) SIP_DEPRECATED
118 {
119 Q_UNUSED( candPoint )
120 Q_UNUSED( candLine )
121 Q_UNUSED( candPolygon )
122 }
123
128 Q_DECL_DEPRECATED void setSearchMethod( Search s ) SIP_DEPRECATED { Q_UNUSED( s ) }
129
134 Q_DECL_DEPRECATED Search searchMethod() const SIP_DEPRECATED { return Chain; }
135
136 // TODO QGIS 4.0 -- remove these, and just use read/writeXml directly:
137
143 void readSettingsFromProject( QgsProject *project );
144
150 void writeSettingsToProject( QgsProject *project );
151
162 void writeXml( QDomDocument &doc, QDomElement &element, const QgsReadWriteContext &context ) const;
163
176 void readXml( const QDomElement &element, const QgsReadWriteContext &context );
177
185 void resolveReferences( const QgsProject *project ); // cppcheck-suppress functionConst
186
187 // TODO QGIS 4.0: In reality the text render format settings don't only apply to labels, but also
188 // ANY text rendered using QgsTextRenderer (including some non-label text items in layouts).
189 // These methods should possibly be moved out of here and into the general QgsProject settings.
190
198 {
199 return mDefaultTextRenderFormat;
200 }
201
209 {
210 mDefaultTextRenderFormat = format;
211 }
212
219 QColor unplacedLabelColor() const;
220
227 void setUnplacedLabelColor( const QColor &color );
228
235 Qgis::LabelPlacementEngineVersion placementVersion() const;
236
243 void setPlacementVersion( Qgis::LabelPlacementEngineVersion version );
244
253 QList< QgsAbstractLabelingEngineRule * > rules();
254
263 QList< const QgsAbstractLabelingEngineRule * > rules() const SIP_SKIP;
264
275 void addRule( QgsAbstractLabelingEngineRule *rule SIP_TRANSFER );
276
287 void setRules( const QList< QgsAbstractLabelingEngineRule * > &rules SIP_TRANSFER );
288
289 private:
291 Qgis::LabelingFlags mFlags = Qgis::LabelingFlag::UsePartialCandidates;
293 Search mSearchMethod = Chain;
294
295 // maximum density of line/polygon candidates per mm
296 double mMaxLineCandidatesPerCm = 5;
297 double mMaxPolygonCandidatesPerCmSquared = 2.5;
298
299 QColor mUnplacedLabelColor = QColor( 255, 0, 0 );
300
301 Qgis::LabelPlacementEngineVersion mPlacementVersion = Qgis::LabelPlacementEngineVersion::Version2;
302
303 Qgis::TextRenderFormat mDefaultTextRenderFormat = Qgis::TextRenderFormat::AlwaysOutlines;
304
305 std::vector< std::unique_ptr< QgsAbstractLabelingEngineRule > > mEngineRules;
306
307};
308
309#endif // QGSLABELINGENGINESETTINGS_H
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
LabelingFlag
Various flags that affect drawing and placement of labels.
Definition qgis.h:2639
TextRenderFormat
Options for rendering text.
Definition qgis.h:2624
QFlags< LabelingFlag > LabelingFlags
Flags that affect drawing and placement of labels.
Definition qgis.h:2659
LabelPlacementEngineVersion
Labeling placement engine version.
Definition qgis.h:2670
Abstract base class for labeling engine rules.
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
The class is used as a container of context for various read/write operations on other objects.
#define SIP_DEPRECATED
Definition qgis_sip.h:106
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_TRANSFER
Definition qgis_sip.h:36