QGIS API Documentation  3.8.0-Zanzibar (11aff65)
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 "qgsrendercontext.h"
20 #include <QFlags>
21 
22 class QgsProject;
23 
29 class CORE_EXPORT QgsLabelingEngineSettings
30 {
31  public:
33  enum Flag
34  {
35  UseAllLabels = 1 << 1,
36  UsePartialCandidates = 1 << 2,
37  // TODO QGIS 4.0: remove
38  RenderOutlineLabels = 1 << 3,
39  DrawLabelRectOnly = 1 << 4,
40  DrawCandidates = 1 << 5,
41  };
42  Q_DECLARE_FLAGS( Flags, Flag )
43 
44 
48  enum Search
49  {
54  Falp
55  };
56 
58 
60  void clear();
61 
63  void setFlags( Flags flags ) { mFlags = flags; }
65  Flags flags() const { return mFlags; }
67  bool testFlag( Flag f ) const { return mFlags.testFlag( f ); }
69  void setFlag( Flag f, bool enabled = true ) { if ( enabled ) mFlags |= f; else mFlags &= ~f; }
70 
72  void numCandidatePositions( int &candPoint, int &candLine, int &candPolygon ) const { candPoint = mCandPoint; candLine = mCandLine; candPolygon = mCandPolygon; }
74  void setNumCandidatePositions( int candPoint, int candLine, int candPolygon ) { mCandPoint = candPoint; mCandLine = candLine; mCandPolygon = candPolygon; }
75 
77  void setSearchMethod( Search s ) { mSearchMethod = s; }
79  Search searchMethod() const { return mSearchMethod; }
80 
82  void readSettingsFromProject( QgsProject *project );
84  void writeSettingsToProject( QgsProject *project );
85 
86  // TODO QGIS 4.0: In reality the text render format settings don't only apply to labels, but also
87  // ANY text rendered using QgsTextRenderer (including some non-label text items in layouts).
88  // These methods should possibly be moved out of here and into the general QgsProject settings.
89 
97  {
98  return mDefaultTextRenderFormat;
99  }
100 
108  {
109  mDefaultTextRenderFormat = format;
110  }
111 
112  private:
114  Flags mFlags;
116  Search mSearchMethod = Chain;
118  int mCandPoint = 16, mCandLine = 50, mCandPolygon = 30;
119 
121 
122 };
123 
124 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsLabelingEngineSettings::Flags )
125 
126 #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.
void setSearchMethod(Search s)
Sets which search method to use for removal collisions between labels.
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
Reads and writes project states.
Definition: qgsproject.h:89
TextRenderFormat
Options for rendering text.
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) ...
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...
Search searchMethod() const
Which search method to use for removal collisions between labels.
void setFlag(Flag f, bool enabled=true)
Sets whether a particual flag is enabled.
Flags flags() const
Gets flags of the labeling engine.