QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
pal::Layer Class Reference

A set of features which influence the labeling process. More...

#include <layer.h>

Public Types

enum  UpsideDownLabels { Upright, ShowDefined, ShowAll }
 

Public Member Functions

virtual ~Layer ()
 
bool active () const
 Returns whether the layer is currently active. More...
 
QgsPalLayerSettings::Placement arrangement () const
 Returns the layer's arrangement policy. More...
 
bool centroidInside () const
 Returns whether labels placed at the centroid of features within the layer are forced to be placed inside the feature's geometry. More...
 
void chopFeaturesAtRepeatDistance ()
 Chop layer features at the repeat distance *. More...
 
int connectedFeatureId (QgsFeatureId featureId) const
 Returns the connected feature ID for a label feature ID, which is unique for all features which have been joined as a result of joinConnectedFeatures() More...
 
bool displayAll () const
 
int featureCount ()
 Returns the number of features in layer. More...
 
bool isCurved () const
 Returns true if the layer has curved labels. More...
 
void joinConnectedFeatures ()
 Join connected features with the same label text. More...
 
bool labelLayer () const
 Returns whether the layer will be labeled or not. More...
 
int maximumLineLabelCandidates () const
 Returns the maximum number of line label candidates to generate for features in this layer. More...
 
int maximumPointLabelCandidates () const
 Returns the maximum number of point label candidates to generate for features in this layer. More...
 
int maximumPolygonLabelCandidates () const
 Returns the maximum number of polygon label candidates to generate for features in this layer. More...
 
bool mergeConnectedLines () const
 Returns whether connected lines will be merged before labeling. More...
 
QString name () const
 Returns the layer's name. More...
 
QgsPalLayerSettings::ObstacleType obstacleType () const
 Returns the obstacle type, which controls how features within the layer act as obstacles for labels. More...
 
double priority () const
 Returns the layer's priority, between 0 and 1. More...
 
QgsAbstractLabelProviderprovider () const
 Returns pointer to the associated provider. More...
 
bool registerFeature (QgsLabelFeature *label)
 Register a feature in the layer. More...
 
void setActive (bool active)
 Sets whether the layer is currently active. More...
 
void setArrangement (QgsPalLayerSettings::Placement arrangement)
 Sets the layer's arrangement policy. More...
 
void setCentroidInside (bool forceInside)
 Sets whether labels placed at the centroid of features within the layer are forced to be placed inside the feature's geometry. More...
 
void setLabelLayer (bool toLabel)
 Sets whether the layer will be labeled. More...
 
void setMergeConnectedLines (bool merge)
 Sets whether connected lines should be merged before labeling. More...
 
void setObstacleType (QgsPalLayerSettings::ObstacleType obstacleType)
 Sets the obstacle type, which controls how features within the layer act as obstacles for labels. More...
 
void setPriority (double priority)
 Sets the layer's priority. More...
 
void setUpsidedownLabels (UpsideDownLabels ud)
 Sets how upside down labels will be handled within the layer. More...
 
UpsideDownLabels upsidedownLabels () const
 Returns how upside down labels are handled within the layer. More...
 

Protected Member Functions

 Layer (QgsAbstractLabelProvider *provider, const QString &name, QgsPalLayerSettings::Placement arrangement, double defaultPriority, bool active, bool toLabel, Pal *pal, bool displayAll=false)
 Create a new layer. More...
 
void addFeaturePart (FeaturePart *fpart, const QString &labelText=QString())
 Add newly created feature part into r tree and to the list. More...
 
void addObstaclePart (FeaturePart *fpart)
 Add newly created obstacle part into r tree and to the list. More...
 

Protected Attributes

bool mActive
 
QgsPalLayerSettings::Placement mArrangement
 Optional flags used for some placement methods. More...
 
bool mCentroidInside
 
QHash< QgsFeatureId, int > mConnectedFeaturesIds
 
QHash< QString, QVector< FeaturePart * > > mConnectedHashtable
 
double mDefaultPriority
 
bool mDisplayAll
 
RTree< FeaturePart *, double, 2, double, 8, 4 > * mFeatureIndex
 
QLinkedList< FeaturePart * > mFeatureParts
 List of feature parts. More...
 
QHash< QgsFeatureId, QgsLabelFeature * > mHashtable
 Lookup table of label features (owned by the label feature provider that created them) More...
 
bool mLabelLayer
 
bool mMergeLines
 
QMutex mMutex
 
QString mName
 
RTree< FeaturePart *, double, 2, double, 8, 4 > * mObstacleIndex
 
QList< FeaturePart * > mObstacleParts
 List of obstacle parts. More...
 
QgsPalLayerSettings::ObstacleType mObstacleType
 
QgsAbstractLabelProvidermProvider
 
UpsideDownLabels mUpsidedownLabels
 
Palpal = nullptr
 

Friends

class FeaturePart
 
class LabelPosition
 
class Pal
 
class Problem
 

Detailed Description

A set of features which influence the labeling process.

Note
not available in Python bindings

Definition at line 63 of file layer.h.

Member Enumeration Documentation

◆ UpsideDownLabels

Enumerator
Upright 
ShowDefined 
ShowAll 

Definition at line 73 of file layer.h.

Constructor & Destructor Documentation

◆ ~Layer()

Layer::~Layer ( )
virtual

Definition at line 68 of file layer.cpp.

◆ Layer()

Layer::Layer ( QgsAbstractLabelProvider provider,
const QString &  name,
QgsPalLayerSettings::Placement  arrangement,
double  defaultPriority,
bool  active,
bool  toLabel,
Pal pal,
bool  displayAll = false 
)
protected

Create a new layer.

Parameters
providerAssociated provider
nameName of the layer (for stats, debugging - does not need to be unique)
arrangementArrangement mode : how to place candidates
defaultPrioritylayer's prioriry (0 is the best, 1 the worst)
activeis the layer is active (currently displayed)
toLabelthe layer will be labeled whether toLablel is true
palpointer to the pal object
displayAllif true, all features will be labelled even though overlaps occur

Definition at line 44 of file layer.cpp.

Member Function Documentation

◆ active()

bool pal::Layer::active ( ) const
inline

Returns whether the layer is currently active.

See also
setActive

Definition at line 194 of file layer.h.

◆ addFeaturePart()

void Layer::addFeaturePart ( FeaturePart fpart,
const QString &  labelText = QString() 
)
protected

Add newly created feature part into r tree and to the list.

Definition at line 267 of file layer.cpp.

◆ addObstaclePart()

void Layer::addObstaclePart ( FeaturePart fpart)
protected

Add newly created obstacle part into r tree and to the list.

Definition at line 286 of file layer.cpp.

◆ arrangement()

QgsPalLayerSettings::Placement pal::Layer::arrangement ( ) const
inline

Returns the layer's arrangement policy.

See also
setArrangement

Definition at line 164 of file layer.h.

◆ centroidInside()

bool pal::Layer::centroidInside ( ) const
inline

Returns whether labels placed at the centroid of features within the layer are forced to be placed inside the feature's geometry.

See also
setCentroidInside

Definition at line 281 of file layer.h.

◆ chopFeaturesAtRepeatDistance()

void Layer::chopFeaturesAtRepeatDistance ( )

Chop layer features at the repeat distance *.

Definition at line 376 of file layer.cpp.

◆ connectedFeatureId()

int Layer::connectedFeatureId ( QgsFeatureId  featureId) const

Returns the connected feature ID for a label feature ID, which is unique for all features which have been joined as a result of joinConnectedFeatures()

Returns
connected feature ID, or -1 if feature was not joined

Definition at line 371 of file layer.cpp.

◆ displayAll()

bool pal::Layer::displayAll ( ) const
inline

Definition at line 82 of file layer.h.

◆ featureCount()

int pal::Layer::featureCount ( )
inline

Returns the number of features in layer.

Definition at line 87 of file layer.h.

◆ isCurved()

bool pal::Layer::isCurved ( ) const
inline

Returns true if the layer has curved labels.

Definition at line 169 of file layer.h.

◆ joinConnectedFeatures()

void Layer::joinConnectedFeatures ( )

Join connected features with the same label text.

Definition at line 316 of file layer.cpp.

◆ labelLayer()

bool pal::Layer::labelLayer ( ) const
inline

Returns whether the layer will be labeled or not.

See also
setLabelLayer

Definition at line 209 of file layer.h.

◆ maximumLineLabelCandidates()

int pal::Layer::maximumLineLabelCandidates ( ) const
inline

Returns the maximum number of line label candidates to generate for features in this layer.

Definition at line 114 of file layer.h.

◆ maximumPointLabelCandidates()

int pal::Layer::maximumPointLabelCandidates ( ) const
inline

Returns the maximum number of point label candidates to generate for features in this layer.

Definition at line 93 of file layer.h.

◆ maximumPolygonLabelCandidates()

int pal::Layer::maximumPolygonLabelCandidates ( ) const
inline

Returns the maximum number of polygon label candidates to generate for features in this layer.

Definition at line 135 of file layer.h.

◆ mergeConnectedLines()

bool pal::Layer::mergeConnectedLines ( ) const
inline

Returns whether connected lines will be merged before labeling.

See also
setMergeConnectedLines

Definition at line 252 of file layer.h.

◆ name()

QString pal::Layer::name ( ) const
inline

Returns the layer's name.

Definition at line 158 of file layer.h.

◆ obstacleType()

QgsPalLayerSettings::ObstacleType pal::Layer::obstacleType ( ) const
inline

Returns the obstacle type, which controls how features within the layer act as obstacles for labels.

See also
setObstacleType

Definition at line 216 of file layer.h.

◆ priority()

double pal::Layer::priority ( ) const
inline

Returns the layer's priority, between 0 and 1.

0 corresponds to highest priority, 1 to lowest priority.

See also
setPriority

Definition at line 239 of file layer.h.

◆ provider()

QgsAbstractLabelProvider* pal::Layer::provider ( ) const
inline

Returns pointer to the associated provider.

Definition at line 153 of file layer.h.

◆ registerFeature()

bool Layer::registerFeature ( QgsLabelFeature label)

Register a feature in the layer.

Does not take ownership of the label feature (it is owned by its provider).

Exceptions
PalException::FeatureExists
Returns
true on success (i.e. valid geometry)

Definition at line 91 of file layer.cpp.

◆ setActive()

void pal::Layer::setActive ( bool  active)
inline

Sets whether the layer is currently active.

Active means "is currently displayed or used as obstacles". When a layer is deactivated then feature of this layer will not be used for either labeling or as obstacles.

Parameters
activeset to true to make the layer active, or false to deactivate the layer
See also
active

Definition at line 188 of file layer.h.

◆ setArrangement()

void pal::Layer::setArrangement ( QgsPalLayerSettings::Placement  arrangement)
inline

Sets the layer's arrangement policy.

Parameters
arrangementarrangement policy
See also
arrangement

Definition at line 176 of file layer.h.

◆ setCentroidInside()

void pal::Layer::setCentroidInside ( bool  forceInside)
inline

Sets whether labels placed at the centroid of features within the layer are forced to be placed inside the feature's geometry.

Parameters
forceInsideset to true to force centroid labels to be within the feature. If set to false then the centroid may fall outside the feature.
See also
centroidInside

Definition at line 274 of file layer.h.

◆ setLabelLayer()

void pal::Layer::setLabelLayer ( bool  toLabel)
inline

Sets whether the layer will be labeled.

Note
Layers are labelled if and only if labelLayer and active are true
Parameters
toLabelset to false disable labeling this layer
See also
labelLayer
setActive

Definition at line 203 of file layer.h.

◆ setMergeConnectedLines()

void pal::Layer::setMergeConnectedLines ( bool  merge)
inline

Sets whether connected lines should be merged before labeling.

Parameters
mergeset to true to merge connected lines
See also
mergeConnectedLines

Definition at line 246 of file layer.h.

◆ setObstacleType()

void pal::Layer::setObstacleType ( QgsPalLayerSettings::ObstacleType  obstacleType)
inline

Sets the obstacle type, which controls how features within the layer act as obstacles for labels.

Parameters
obstacleTypenew obstacle type
See also
obstacleType

Definition at line 224 of file layer.h.

◆ setPriority()

void Layer::setPriority ( double  priority)

Sets the layer's priority.

Parameters
prioritylayer priority, between 0 and 1. 0 corresponds to highest priority, 1 to lowest priority.
See also
priority

Definition at line 81 of file layer.cpp.

◆ setUpsidedownLabels()

void pal::Layer::setUpsidedownLabels ( UpsideDownLabels  ud)
inline

Sets how upside down labels will be handled within the layer.

Parameters
udupside down label handling mode
See also
upsidedownLabels

Definition at line 259 of file layer.h.

◆ upsidedownLabels()

UpsideDownLabels pal::Layer::upsidedownLabels ( ) const
inline

Returns how upside down labels are handled within the layer.

See also
setUpsidedownLabels

Definition at line 265 of file layer.h.

Friends And Related Function Documentation

◆ FeaturePart

friend class FeaturePart
friend

Definition at line 66 of file layer.h.

◆ LabelPosition

friend class LabelPosition
friend

Definition at line 70 of file layer.h.

◆ Pal

friend class Pal
friend

Definition at line 65 of file layer.h.

◆ Problem

friend class Problem
friend

Definition at line 68 of file layer.h.

Member Data Documentation

◆ mActive

bool pal::Layer::mActive
protected

Definition at line 322 of file layer.h.

◆ mArrangement

QgsPalLayerSettings::Placement pal::Layer::mArrangement
protected

Optional flags used for some placement methods.

Definition at line 328 of file layer.h.

◆ mCentroidInside

bool pal::Layer::mCentroidInside
protected

Definition at line 325 of file layer.h.

◆ mConnectedFeaturesIds

QHash< QgsFeatureId, int > pal::Layer::mConnectedFeaturesIds
protected

Definition at line 343 of file layer.h.

◆ mConnectedHashtable

QHash< QString, QVector<FeaturePart *> > pal::Layer::mConnectedHashtable
protected

Definition at line 342 of file layer.h.

◆ mDefaultPriority

double pal::Layer::mDefaultPriority
protected

Definition at line 319 of file layer.h.

◆ mDisplayAll

bool pal::Layer::mDisplayAll
protected

Definition at line 324 of file layer.h.

◆ mFeatureIndex

RTree<FeaturePart *, double, 2, double, 8, 4>* pal::Layer::mFeatureIndex
protected

Definition at line 335 of file layer.h.

◆ mFeatureParts

QLinkedList<FeaturePart *> pal::Layer::mFeatureParts
protected

List of feature parts.

Definition at line 312 of file layer.h.

◆ mHashtable

QHash< QgsFeatureId, QgsLabelFeature *> pal::Layer::mHashtable
protected

Lookup table of label features (owned by the label feature provider that created them)

Definition at line 337 of file layer.h.

◆ mLabelLayer

bool pal::Layer::mLabelLayer
protected

Definition at line 323 of file layer.h.

◆ mMergeLines

bool pal::Layer::mMergeLines
protected

Definition at line 330 of file layer.h.

◆ mMutex

QMutex pal::Layer::mMutex
protected

Definition at line 345 of file layer.h.

◆ mName

QString pal::Layer::mName
protected

Definition at line 309 of file layer.h.

◆ mObstacleIndex

RTree<FeaturePart *, double, 2, double, 8, 4>* pal::Layer::mObstacleIndex
protected

Definition at line 340 of file layer.h.

◆ mObstacleParts

QList<FeaturePart *> pal::Layer::mObstacleParts
protected

List of obstacle parts.

Definition at line 315 of file layer.h.

◆ mObstacleType

QgsPalLayerSettings::ObstacleType pal::Layer::mObstacleType
protected

Definition at line 321 of file layer.h.

◆ mProvider

QgsAbstractLabelProvider* pal::Layer::mProvider
protected

Definition at line 308 of file layer.h.

◆ mUpsidedownLabels

UpsideDownLabels pal::Layer::mUpsidedownLabels
protected

Definition at line 332 of file layer.h.

◆ pal

Pal* pal::Layer::pal = nullptr
protected

Definition at line 317 of file layer.h.


The documentation for this class was generated from the following files: