QGIS API Documentation  3.0.2-Girona (307d082)
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 
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  RenderOutlineLabels = 1 << 3,
38  DrawLabelRectOnly = 1 << 4,
39  DrawCandidates = 1 << 5,
40  };
41  Q_DECLARE_FLAGS( Flags, Flag )
42 
43 
47  enum Search
48  {
53  Falp
54  };
55 
57 
59  void clear();
60 
62  void setFlags( Flags flags ) { mFlags = flags; }
64  Flags flags() const { return mFlags; }
66  bool testFlag( Flag f ) const { return mFlags.testFlag( f ); }
68  void setFlag( Flag f, bool enabled = true ) { if ( enabled ) mFlags |= f; else mFlags &= ~f; }
69 
71  void numCandidatePositions( int &candPoint, int &candLine, int &candPolygon ) const { candPoint = mCandPoint; candLine = mCandLine; candPolygon = mCandPolygon; }
73  void setNumCandidatePositions( int candPoint, int candLine, int candPolygon ) { mCandPoint = candPoint; mCandLine = candLine; mCandPolygon = candPolygon; }
74 
76  void setSearchMethod( Search s ) { mSearchMethod = s; }
78  Search searchMethod() const { return mSearchMethod; }
79 
81  void readSettingsFromProject( QgsProject *project );
83  void writeSettingsToProject( QgsProject *project );
84 
85  private:
87  Flags mFlags;
89  Search mSearchMethod = Chain;
91  int mCandPoint = 16, mCandLine = 50, mCandPolygon = 30;
92 
93 };
94 
95 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsLabelingEngineSettings::Flags )
96 
97 #endif // QGSLABELINGENGINESETTINGS_H
void setFlags(Flags flags)
Set flags of the labeling engine.
void setSearchMethod(Search s)
Set which search method to use for removal collisions between labels.
Flag
Various flags that affect drawing and placement of labels.
struct pal::_chain Chain
Reads and writes project states.
Definition: qgsproject.h:82
void numCandidatePositions(int &candPoint, int &candLine, int &candPolygon) const
Get 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)
Set 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)
Set whether a particual flag is enabled.
Flags flags() const
Get flags of the labeling engine.