QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
22 : mFlags( UsePartialCandidates )
34 mSearchMethod =
static_cast< Search >( prj->
readNumEntry( QStringLiteral(
"PAL" ), QStringLiteral(
"/SearchMethod" ),
static_cast< int >(
Chain ), &saved ) );
35 mMaxLineCandidatesPerCm = prj->
readDoubleEntry( QStringLiteral(
"PAL" ), QStringLiteral(
"/CandidatesLinePerCM" ), 5, &saved );
36 mMaxPolygonCandidatesPerCmSquared = prj->
readDoubleEntry( QStringLiteral(
"PAL" ), QStringLiteral(
"/CandidatesPolygonPerCM" ), 2.5, &saved );
39 if ( prj->
readBoolEntry( QStringLiteral(
"PAL" ), QStringLiteral(
"/ShowingCandidates" ),
false, &saved ) ) mFlags |=
DrawCandidates;
41 if ( prj->
readBoolEntry( QStringLiteral(
"PAL" ), QStringLiteral(
"/ShowingAllLabels" ),
false, &saved ) ) mFlags |=
UseAllLabels;
45 mDefaultTextRenderFormat = Qgis::TextRenderFormat::AlwaysOutlines;
47 if ( !prj->
readBoolEntry( QStringLiteral(
"PAL" ), QStringLiteral(
"/DrawOutlineLabels" ),
true ) )
48 mDefaultTextRenderFormat = Qgis::TextRenderFormat::AlwaysText;
50 const int projectTextFormat = prj->
readNumEntry( QStringLiteral(
"PAL" ), QStringLiteral(
"/TextFormat" ), -1 );
51 if ( projectTextFormat >= 0 )
61 project->
writeEntry( QStringLiteral(
"PAL" ), QStringLiteral(
"/SearchMethod" ),
static_cast< int >( mSearchMethod ) );
62 project->
writeEntry( QStringLiteral(
"PAL" ), QStringLiteral(
"/CandidatesLinePerCM" ), mMaxLineCandidatesPerCm );
63 project->
writeEntry( QStringLiteral(
"PAL" ), QStringLiteral(
"/CandidatesPolygonPerCM" ), mMaxPolygonCandidatesPerCmSquared );
65 project->
writeEntry( QStringLiteral(
"PAL" ), QStringLiteral(
"/ShowingCandidates" ), mFlags.testFlag(
DrawCandidates ) );
68 project->
writeEntry( QStringLiteral(
"PAL" ), QStringLiteral(
"/ShowingAllLabels" ), mFlags.testFlag(
UseAllLabels ) );
71 project->
writeEntry( QStringLiteral(
"PAL" ), QStringLiteral(
"/TextFormat" ),
static_cast< int >( mDefaultTextRenderFormat ) );
75 project->
writeEntry( QStringLiteral(
"PAL" ), QStringLiteral(
"/PlacementEngineVersion" ), mPlacementVersion );
80 return mUnplacedLabelColor;
90 return mPlacementVersion;
bool writeEntry(const QString &scope, const QString &key, bool value)
Write a boolean value to the project file.
void readSettingsFromProject(QgsProject *project)
Read configuration of the labeling engine from a project.
static QString encodeColor(const QColor &color)
void clear()
Returns the configuration to the defaults.
TextRenderFormat
Options for rendering text.
@ DrawCandidates
Whether to draw rectangles of generated candidates (good for debugging)
PlacementEngineVersion placementVersion() const
Returns the placement engine version, which dictates how the label placement problem is solved.
QString readEntry(const QString &scope, const QString &key, const QString &def=QString(), bool *ok=nullptr) const
Reads a string from the specified scope and key.
bool readBoolEntry(const QString &scope, const QString &key, bool def=false, bool *ok=nullptr) const
Reads a boolean from the specified scope and key.
static QColor decodeColor(const QString &str)
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
QgsLabelingEngineSettings()
PlacementEngineVersion
Placement engine version.
void writeSettingsToProject(QgsProject *project)
Write configuration of the labeling engine to a project.
void setUnplacedLabelColor(const QColor &color)
Sets the color to use when rendering unplaced labels.
QColor unplacedLabelColor() const
Returns the color to use when rendering unplaced labels.
double readDoubleEntry(const QString &scope, const QString &key, double def=0, bool *ok=nullptr) const
Reads a double from the specified scope and key.
@ PlacementEngineVersion1
Version 1, matches placement from QGIS <= 3.10.1.
Search
Search methods in the PAL library to remove colliding labels (methods have different processing speed...
void setPlacementVersion(PlacementEngineVersion version)
Sets the placement engine version, which dictates how the label placement problem is solved.
@ UsePartialCandidates
Whether to use also label candidates that are partially outside of the map view.
@ DrawLabelRectOnly
Whether to only draw the label rect and not the actual label text (used for unit tests)
@ UseAllLabels
Whether to draw all labels even if there would be collisions.
@ DrawUnplacedLabels
Whether to render unplaced labels as an indicator/warning for users.
int readNumEntry(const QString &scope, const QString &key, int def=0, bool *ok=nullptr) const
Reads an integer from the specified scope and key.