QGIS API Documentation 3.41.0-Master (3440c17df1d)
|
A set of features which influence the labeling process. More...
#include <layer.h>
Public Member Functions | |
Layer (QgsAbstractLabelProvider *provider, const QString &name, Qgis::LabelPlacement arrangement, double defaultPriority, bool active, bool toLabel, Pal *pal) | |
Create a new layer. | |
virtual | ~Layer () |
bool | active () const |
Returns whether the layer is currently active. | |
Qgis::LabelPlacement | arrangement () const |
Returns the layer's arrangement policy. | |
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. | |
void | chopFeaturesAtRepeatDistance () |
Chop layer features at the repeat distance. | |
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() | |
int | featureCount () const |
Returns the number of features in layer. | |
bool | isCurved () const |
Returns true if the layer has curved labels. | |
void | joinConnectedFeatures () |
Join connected features with the same label text. | |
bool | labelLayer () const |
Returns whether the layer will be labeled or not. | |
std::size_t | maximumLineLabelCandidates () const |
Returns the maximum number of line label candidates to generate for features in this layer. | |
std::size_t | maximumPointLabelCandidates () const |
Returns the maximum number of point label candidates to generate for features in this layer. | |
std::size_t | maximumPolygonLabelCandidates () const |
Returns the maximum number of polygon label candidates to generate for features in this layer. | |
bool | mergeConnectedLines () const |
Returns whether connected lines will be merged before labeling. | |
QString | name () const |
Returns the layer's name. | |
QgsLabelObstacleSettings::ObstacleType | obstacleType () const |
Returns the obstacle type, which controls how features within the layer act as obstacles for labels. | |
double | priority () const |
Returns the layer's priority, between 0 and 1. | |
QgsAbstractLabelProvider * | provider () const |
Returns pointer to the associated provider. | |
bool | registerFeature (QgsLabelFeature *label) |
Register a feature in the layer. | |
void | setActive (bool active) |
Sets whether the layer is currently active. | |
void | setArrangement (Qgis::LabelPlacement arrangement) |
Sets the layer's arrangement policy. | |
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. | |
void | setLabelLayer (bool toLabel) |
Sets whether the layer will be labeled. | |
void | setMergeConnectedLines (bool merge) |
Sets whether connected lines should be merged before labeling. | |
void | setObstacleType (QgsLabelObstacleSettings::ObstacleType obstacleType) |
Sets the obstacle type, which controls how features within the layer act as obstacles for labels. | |
void | setPriority (double priority) |
Sets the layer's priority. | |
void | setUpsidedownLabels (Qgis::UpsideDownLabelHandling ud) |
Sets how upside down labels will be handled within the layer. | |
Qgis::UpsideDownLabelHandling | upsidedownLabels () const |
Returns how upside down labels are handled within the layer. | |
Protected Member Functions | |
void | addFeaturePart (std::unique_ptr< FeaturePart > fpart, const QString &labelText=QString()) |
Add newly created feature part into r tree and to the list. | |
void | addObstaclePart (FeaturePart *fpart) |
Add newly created obstacle part into r tree and to the list. | |
Protected Attributes | |
bool | mActive |
Qgis::LabelPlacement | mArrangement |
Optional flags used for some placement methods. | |
bool | mCentroidInside = false |
QHash< QgsFeatureId, int > | mConnectedFeaturesIds |
QHash< QString, QVector< FeaturePart * > > | mConnectedHashtable |
double | mDefaultPriority |
std::deque< std::unique_ptr< FeaturePart > > | mFeatureParts |
List of feature parts. | |
std::vector< geos::unique_ptr > | mGeosObstacleGeometries |
QHash< QgsFeatureId, QgsLabelFeature * > | mHashtable |
Lookup table of label features (owned by the label feature provider that created them) | |
bool | mLabelLayer |
bool | mMergeLines = false |
QMutex | mMutex |
QString | mName |
QList< FeaturePart * > | mObstacleParts |
List of obstacle parts. | |
QgsLabelObstacleSettings::ObstacleType | mObstacleType = QgsLabelObstacleSettings::ObstacleType::PolygonBoundary |
Pal * | mPal = nullptr |
QgsAbstractLabelProvider * | mProvider |
Qgis::UpsideDownLabelHandling | mUpsidedownLabels = Qgis::UpsideDownLabelHandling::FlipUpsideDownLabels |
Friends | |
class | FeaturePart |
class | LabelPosition |
class | Pal |
class | Problem |
A set of features which influence the labeling process.
Layer::Layer | ( | QgsAbstractLabelProvider * | provider, |
const QString & | name, | ||
Qgis::LabelPlacement | arrangement, | ||
double | defaultPriority, | ||
bool | active, | ||
bool | toLabel, | ||
Pal * | pal | ||
) |
Create a new layer.
provider | Associated provider |
name | Name of the layer (for stats, debugging - does not need to be unique) |
arrangement | Arrangement mode : how to place candidates |
defaultPriority | layer's priority (0 is the best, 1 the worst) |
active | is the layer is active (currently displayed) |
toLabel | the layer will be labeled whether toLablel is true |
pal | pointer to the pal object |
|
inline |
|
protected |
|
protected |
|
inline |
Returns the layer's arrangement policy.
|
inline |
Returns whether labels placed at the centroid of features within the layer are forced to be placed inside the feature's geometry.
void Layer::chopFeaturesAtRepeatDistance | ( | ) |
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()
|
inline |
|
inline |
void Layer::joinConnectedFeatures | ( | ) |
|
inline |
Returns whether the layer will be labeled or not.
|
inline |
|
inline |
|
inline |
|
inline |
Returns whether connected lines will be merged before labeling.
|
inline |
|
inline |
Returns the obstacle type, which controls how features within the layer act as obstacles for labels.
|
inline |
Returns the layer's priority, between 0 and 1.
0 corresponds to highest priority, 1 to lowest priority.
|
inline |
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).
PalException::FeatureExists |
true
on success (i.e. valid geometry)
|
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.
active | set to true to make the layer active, or false to deactivate the layer |
|
inline |
|
inline |
Sets whether labels placed at the centroid of features within the layer are forced to be placed inside the feature's geometry.
forceInside | set to true to force centroid labels to be within the feature. If set to false then the centroid may fall outside the feature. |
|
inline |
Sets whether the layer will be labeled.
true
toLabel | set to false disable labeling this layer |
|
inline |
Sets whether connected lines should be merged before labeling.
merge | set to true to merge connected lines |
|
inline |
Sets the obstacle type, which controls how features within the layer act as obstacles for labels.
obstacleType | new obstacle type |
void Layer::setPriority | ( | double | priority | ) |
|
inline |
Sets how upside down labels will be handled within the layer.
ud | upside down label handling mode |
|
inline |
Returns how upside down labels are handled within the layer.
|
friend |
|
friend |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |