QGIS API Documentation 3.41.0-Master (af5edcb665c)
|
Main Pal labeling class. More...
#include <pal.h>
Public Types | |
typedef bool(* | FnIsCanceled) (void *ctx) |
Public Member Functions | |
Pal () | |
Pal (const Pal &other)=delete | |
~Pal () | |
Layer * | addLayer (QgsAbstractLabelProvider *provider, const QString &layerName, Qgis::LabelPlacement arrangement, double defaultPriority, bool active, bool toLabel) |
add a new layer | |
bool | candidatesAreConflicting (const LabelPosition *lp1, const LabelPosition *lp2) const |
Returns true if a labelling candidate lp1 conflicts with lp2. | |
std::unique_ptr< Problem > | extractProblem (const QgsRectangle &extent, const QgsGeometry &mapBoundary, QgsRenderContext &context) |
Extracts the labeling problem for the specified map extent - only features within this extent will be considered. | |
int | globalCandidatesLimitLine () const |
Returns the global candidates limit for line features, or 0 if no global limit is in effect. | |
int | globalCandidatesLimitPoint () const |
Returns the global candidates limit for point features, or 0 if no global limit is in effect. | |
int | globalCandidatesLimitPolygon () const |
Returns the global candidates limit for polygon features, or 0 if no global limit is in effect. | |
bool | isCanceled () |
Check whether the job has been canceled. | |
double | maximumLineCandidatesPerMapUnit () const |
Returns the maximum number of line label candidate positions per map unit. | |
double | maximumPolygonCandidatesPerMapUnitSquared () const |
Returns the maximum number of polygon label candidate positions per map unit squared. | |
Pal & | operator= (const Pal &other)=delete |
Qgis::LabelPlacementEngineVersion | placementVersion () const |
Returns the placement engine version, which dictates how the label placement problem is solved. | |
void | registerCancellationCallback (FnIsCanceled fnCanceled, void *context) |
Register a function that returns whether this job has been canceled - PAL calls it during the computation. | |
void | removeLayer (Layer *layer) |
remove a layer | |
QList< QgsAbstractLabelingEngineRule * > | rules () const |
Returns the rules which the labeling solution must satisify. | |
void | setMaximumLineCandidatesPerMapUnit (double candidates) |
Sets the maximum number of line label candidates per map unit. | |
void | setMaximumPolygonCandidatesPerMapUnitSquared (double candidates) |
Sets the maximum number of polygon label candidates per map unit squared. | |
void | setPlacementVersion (Qgis::LabelPlacementEngineVersion placementVersion) |
Sets the placement engine version, which dictates how the label placement problem is solved. | |
void | setRules (const QList< QgsAbstractLabelingEngineRule * > &rules) |
Sets rules which the labeling solution must satisfy. | |
void | setShowPartialLabels (bool show) |
Sets whether partial labels show be allowed. | |
bool | showPartialLabels () const |
Returns whether partial labels should be allowed. | |
QList< LabelPosition * > | solveProblem (Problem *prob, QgsRenderContext &context, bool displayAll, QList< pal::LabelPosition * > *unlabeled=nullptr) |
Solves the labeling problem, selecting the best candidate locations for all labels and returns a list of these calculated label positions. | |
Static Public Attributes | |
static const QgsSettingsEntryInteger * | settingsRenderingLabelCandidatesLimitLines = new QgsSettingsEntryInteger( QStringLiteral( "label-candidates-limit-lines" ), sTreePal, 0 ) |
static const QgsSettingsEntryInteger * | settingsRenderingLabelCandidatesLimitPoints = new QgsSettingsEntryInteger( QStringLiteral( "label-candidates-limit-points" ), sTreePal, 0 ) |
static const QgsSettingsEntryInteger * | settingsRenderingLabelCandidatesLimitPolygons = new QgsSettingsEntryInteger( QStringLiteral( "label-candidates-limit-polygons" ), sTreePal, 0 ) |
static QgsSettingsTreeNode * | sTreePal = QgsSettingsTree::sTreeRendering->createChildNode( QStringLiteral( "pal" ) ) |
Friends | |
class | FeaturePart |
class | Layer |
class | Problem |
Main Pal labeling class.
A pal object will contains layers and global information such as which search method will be used.
|
default |
|
delete |
Layer * Pal::addLayer | ( | QgsAbstractLabelProvider * | provider, |
const QString & | layerName, | ||
Qgis::LabelPlacement | arrangement, | ||
double | defaultPriority, | ||
bool | active, | ||
bool | toLabel | ||
) |
add a new layer
provider | Provider associated with the layer |
layerName | layer's name |
arrangement | Howto 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 only if toLablel is true |
PalException::LayerExists |
bool Pal::candidatesAreConflicting | ( | const LabelPosition * | lp1, |
const LabelPosition * | lp2 | ||
) | const |
std::unique_ptr< Problem > Pal::extractProblem | ( | const QgsRectangle & | extent, |
const QgsGeometry & | mapBoundary, | ||
QgsRenderContext & | context | ||
) |
Extracts the labeling problem for the specified map extent - only features within this extent will be considered.
The mapBoundary argument specifies the actual geometry of the map boundary, which will be used to detect whether a label is visible (or partially visible) in the rendered map. This may differ from extent in the case of rotated or non-rectangular maps.
This method:
|
inline |
Returns the global candidates limit for line features, or 0 if no global limit is in effect.
This is an installation-wide setting which applies to all projects, and is set via QSettings. It can be used to place global limits on the number of candidates generated for line features in order to optimise map rendering speeds.
|
inline |
Returns the global candidates limit for point features, or 0 if no global limit is in effect.
This is an installation-wide setting which applies to all projects, and is set via QSettings. It can be used to place global limits on the number of candidates generated for point features in order to optimise map rendering speeds.
|
inline |
Returns the global candidates limit for polygon features, or 0 if no global limit is in effect.
This is an installation-wide setting which applies to all projects, and is set via QSettings. It can be used to place global limits on the number of candidates generated for polygon features in order to optimise map rendering speeds.
|
inline |
|
inline |
Returns the maximum number of line label candidate positions per map unit.
|
inline |
Returns the maximum number of polygon label candidate positions per map unit squared.
Qgis::LabelPlacementEngineVersion Pal::placementVersion | ( | ) | const |
Returns the placement engine version, which dictates how the label placement problem is solved.
void Pal::registerCancellationCallback | ( | Pal::FnIsCanceled | fnCanceled, |
void * | context | ||
) |
void Pal::removeLayer | ( | Layer * | layer | ) |
|
inline |
|
inline |
Sets the maximum number of line label candidates per map unit.
|
inline |
Sets the maximum number of polygon label candidates per map unit squared.
void Pal::setPlacementVersion | ( | Qgis::LabelPlacementEngineVersion | placementVersion | ) |
Sets the placement engine version, which dictates how the label placement problem is solved.
void Pal::setRules | ( | const QList< QgsAbstractLabelingEngineRule * > & | rules | ) |
void Pal::setShowPartialLabels | ( | bool | show | ) |
Sets whether partial labels show be allowed.
bool Pal::showPartialLabels | ( | ) | const |
Returns whether partial labels should be allowed.
QList< LabelPosition * > Pal::solveProblem | ( | Problem * | prob, |
QgsRenderContext & | context, | ||
bool | displayAll, | ||
QList< pal::LabelPosition * > * | unlabeled = nullptr |
||
) |
Solves the labeling problem, selecting the best candidate locations for all labels and returns a list of these calculated label positions.
If displayAll is true
, then the best positions for ALL labels will be returned, regardless of whether these labels overlap other labels.
If the optional unlabeled list is specified, it will be filled with a list of all feature labels which could not be placed in the returned solution (e.g. due to overlaps or other constraints).
Ownership of the returned labels is not transferred - it resides with the pal object.
|
friend |
|
static |
|
static |
|
static |
|
inlinestatic |