QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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.h"
19#include "qgis_core.h"
20#include "qgis_sip.h"
21
22#include <QColor>
23
24class QgsProject;
26class QDomDocument;
27class QDomElement;
29
35{
36 public:
37 // TODO QGIS 5 - remove
38
51
54
57
60
62 void clear();
63
67 Qgis::LabelingFlags flags() const { return mFlags; }
69 bool testFlag( Qgis::LabelingFlag f ) const { return mFlags.testFlag( f ); }
71 void setFlag( Qgis::LabelingFlag f, bool enabled = true )
72 {
73 if ( enabled )
74 mFlags |= f;
75 else
76 mFlags &= ~static_cast< int >( f );
77 }
78
85 double maximumLineCandidatesPerCm() const { return mMaxLineCandidatesPerCm; }
86
93 void setMaximumLineCandidatesPerCm( double candidates ) { mMaxLineCandidatesPerCm = candidates; }
94
101 double maximumPolygonCandidatesPerCmSquared() const { return mMaxPolygonCandidatesPerCmSquared; }
102
109 void setMaximumPolygonCandidatesPerCmSquared( double candidates ) { mMaxPolygonCandidatesPerCmSquared = candidates; }
110
115 Q_DECL_DEPRECATED void numCandidatePositions( int &candPoint, int &candLine, int &candPolygon ) const SIP_DEPRECATED
116 {
117 Q_UNUSED( candPoint )
118 Q_UNUSED( candLine )
119 Q_UNUSED( candPolygon )
120 }
121
126 Q_DECL_DEPRECATED void setNumCandidatePositions( int candPoint, int candLine, int candPolygon ) SIP_DEPRECATED
127 {
128 Q_UNUSED( candPoint )
129 Q_UNUSED( candLine )
130 Q_UNUSED( candPolygon )
131 }
132
137 Q_DECL_DEPRECATED void setSearchMethod( Search s ) SIP_DEPRECATED { Q_UNUSED( s ) }
138
143 Q_DECL_DEPRECATED Search searchMethod() const SIP_DEPRECATED { return Chain; }
144
145 // TODO QGIS 5.0 -- remove these, and just use read/writeXml directly:
146
152 void readSettingsFromProject( QgsProject *project );
153
159 void writeSettingsToProject( QgsProject *project );
160
171 void writeXml( QDomDocument &doc, QDomElement &element, const QgsReadWriteContext &context ) const;
172
185 void readXml( const QDomElement &element, const QgsReadWriteContext &context );
186
194 void resolveReferences( const QgsProject *project ); // cppcheck-suppress functionConst
195
196 // TODO QGIS 5.0: In reality the text render format settings don't only apply to labels, but also
197 // ANY text rendered using QgsTextRenderer (including some non-label text items in layouts).
198 // These methods should possibly be moved out of here and into the general QgsProject settings.
199
206 Qgis::TextRenderFormat defaultTextRenderFormat() const { return mDefaultTextRenderFormat; }
207
214 void setDefaultTextRenderFormat( Qgis::TextRenderFormat format ) { mDefaultTextRenderFormat = format; }
215
222 QColor unplacedLabelColor() const;
223
230 void setUnplacedLabelColor( const QColor &color );
231
238 Qgis::LabelPlacementEngineVersion placementVersion() const;
239
246 void setPlacementVersion( Qgis::LabelPlacementEngineVersion version );
247
256 QList< QgsAbstractLabelingEngineRule * > rules();
257
266 QList< const QgsAbstractLabelingEngineRule * > rules() const SIP_SKIP;
267
278 void addRule( QgsAbstractLabelingEngineRule *rule SIP_TRANSFER );
279
290 void setRules( const QList< QgsAbstractLabelingEngineRule * > &rules SIP_TRANSFER );
291
292 private:
294 Qgis::LabelingFlags mFlags = Qgis::LabelingFlag::UsePartialCandidates;
296 Search mSearchMethod = Chain;
297
298 // maximum density of line/polygon candidates per mm
299 double mMaxLineCandidatesPerCm = 5;
300 double mMaxPolygonCandidatesPerCmSquared = 2.5;
301
302 QColor mUnplacedLabelColor = QColor( 255, 0, 0 );
303
304 Qgis::LabelPlacementEngineVersion mPlacementVersion = Qgis::LabelPlacementEngineVersion::Version2;
305
306 Qgis::TextRenderFormat mDefaultTextRenderFormat = Qgis::TextRenderFormat::AlwaysOutlines;
307
308 std::vector< std::unique_ptr< QgsAbstractLabelingEngineRule > > mEngineRules;
309};
310
311#endif // QGSLABELINGENGINESETTINGS_H
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:62
LabelingFlag
Various flags that affect drawing and placement of labels.
Definition qgis.h:2942
TextRenderFormat
Options for rendering text.
Definition qgis.h:2923
QFlags< LabelingFlag > LabelingFlags
Flags that affect drawing and placement of labels.
Definition qgis.h:2962
LabelPlacementEngineVersion
Labeling placement engine version.
Definition qgis.h:2973
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.
void clear()
Returns the configuration to the defaults.
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.
QgsLabelingEngineSettings & operator=(const QgsLabelingEngineSettings &other)
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:113
A container for the context for various read/write operations on objects.
#define SIP_DEPRECATED
Definition qgis_sip.h:113
#define SIP_SKIP
Definition qgis_sip.h:133
#define SIP_TRANSFER
Definition qgis_sip.h:35