QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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 "qgsrendercontext.h"
21 #include <QFlags>
22 
23 class QgsProject;
24 
30 class CORE_EXPORT QgsLabelingEngineSettings
31 {
32  public:
34  enum Flag
35  {
36  UseAllLabels = 1 << 1,
37  UsePartialCandidates = 1 << 2,
38  // TODO QGIS 4.0: remove
39  RenderOutlineLabels = 1 << 3,
40  DrawLabelRectOnly = 1 << 4,
41  DrawCandidates = 1 << 5,
42  DrawUnplacedLabels = 1 << 6,
43  };
44  Q_DECLARE_FLAGS( Flags, Flag )
45 
46  // TODO QGIS 4 - remove
47 
48 
52  enum Search
53  {
58  Falp
59  };
60 
62 
64  void clear();
65 
67  void setFlags( Flags flags ) { mFlags = flags; }
69  Flags flags() const { return mFlags; }
71  bool testFlag( Flag f ) const { return mFlags.testFlag( f ); }
73  void setFlag( Flag f, bool enabled = true ) { if ( enabled ) mFlags |= f; else mFlags &= ~f; }
74 
76  void numCandidatePositions( int &candPoint, int &candLine, int &candPolygon ) const { candPoint = mCandPoint; candLine = mCandLine; candPolygon = mCandPolygon; }
78  void setNumCandidatePositions( int candPoint, int candLine, int candPolygon ) { mCandPoint = candPoint; mCandLine = candLine; mCandPolygon = candPolygon; }
79 
84  Q_DECL_DEPRECATED void setSearchMethod( Search s ) SIP_DEPRECATED { Q_UNUSED( s ) }
85 
90  Q_DECL_DEPRECATED Search searchMethod() const SIP_DEPRECATED { return Chain; }
91 
93  void readSettingsFromProject( QgsProject *project );
95  void writeSettingsToProject( QgsProject *project );
96 
97  // TODO QGIS 4.0: In reality the text render format settings don't only apply to labels, but also
98  // ANY text rendered using QgsTextRenderer (including some non-label text items in layouts).
99  // These methods should possibly be moved out of here and into the general QgsProject settings.
100 
108  {
109  return mDefaultTextRenderFormat;
110  }
111 
119  {
120  mDefaultTextRenderFormat = format;
121  }
122 
129  QColor unplacedLabelColor() const;
130 
137  void setUnplacedLabelColor( const QColor &color );
138 
139  private:
141  Flags mFlags;
143  Search mSearchMethod = Chain;
145  int mCandPoint = 16, mCandLine = 50, mCandPolygon = 30;
146 
147  QColor mUnplacedLabelColor = QColor( 255, 0, 0 );
148 
150 
151 };
152 
153 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsLabelingEngineSettings::Flags )
154 
155 #endif // QGSLABELINGENGINESETTINGS_H
QgsRenderContext::TextRenderFormat defaultTextRenderFormat() const
Returns the default text rendering format for the labels.
void setFlags(Flags flags)
Sets flags of the labeling engine.
Flag
Various flags that affect drawing and placement of labels.
void setDefaultTextRenderFormat(QgsRenderContext::TextRenderFormat format)
Sets the default text rendering format for the labels.
Always render text using path objects (AKA outlines/curves).
struct pal::_chain Chain
Encapsulates a QGIS project, including sets of map layers and their styles, layouts, annotations, canvases, etc.
Definition: qgsproject.h:89
TextRenderFormat
Options for rendering text.
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
Q_DECL_DEPRECATED void setSearchMethod(Search s)
Used to set which search method to use for removal collisions between labels.
void numCandidatePositions(int &candPoint, int &candLine, int &candPolygon) const
Gets number of candidate positions that will be generated for each label feature (default to 8) ...
Q_DECL_DEPRECATED Search searchMethod() const
Which search method to use for removal collisions between labels.
Stores global configuration for labeling engine.
bool testFlag(Flag f) const
Test whether a particular flag is enabled.
void setNumCandidatePositions(int candPoint, int candLine, int candPolygon)
Sets number of candidate positions that will be generated for each label feature. ...
Search
Search methods in the PAL library to remove colliding labels (methods have different processing speed...
void setFlag(Flag f, bool enabled=true)
Sets whether a particual flag is enabled.
Flags flags() const
Gets flags of the labeling engine.