QGIS API Documentation
3.18.1-Zürich (202f1bf7e5)
|
Main Pal labeling class. More...
#include <pal.h>
Public Types | |
typedef bool(* | FnIsCanceled) (void *ctx) |
Public Member Functions | |
Pal () | |
Create an new pal instance. More... | |
Pal (const Pal &other)=delete | |
Pal cannot be copied. More... | |
~Pal () | |
Layer * | addLayer (QgsAbstractLabelProvider *provider, const QString &layerName, QgsPalLayerSettings::Placement arrangement, double defaultPriority, bool active, bool toLabel, bool displayAll=false) |
add a new layer More... | |
std::unique_ptr< Problem > | extractProblem (const QgsRectangle &extent, const QgsGeometry &mapBoundary) |
Extracts the labeling problem for the specified map extent - only features within this extent will be considered. More... | |
int | globalCandidatesLimitLine () const |
Returns the global candidates limit for line features, or 0 if no global limit is in effect. More... | |
int | globalCandidatesLimitPoint () const |
Returns the global candidates limit for point features, or 0 if no global limit is in effect. More... | |
int | globalCandidatesLimitPolygon () const |
Returns the global candidates limit for polygon features, or 0 if no global limit is in effect. More... | |
bool | isCanceled () |
Check whether the job has been canceled. More... | |
double | maximumLineCandidatesPerMapUnit () const |
Returns the maximum number of line label candidate positions per map unit. More... | |
double | maximumPolygonCandidatesPerMapUnitSquared () const |
Returns the maximum number of polygon label candidate positions per map unit squared. More... | |
Pal & | operator= (const Pal &other)=delete |
Pal cannot be copied. More... | |
QgsLabelingEngineSettings::PlacementEngineVersion | placementVersion () const |
Returns the placement engine version, which dictates how the label placement problem is solved. More... | |
void | registerCancellationCallback (FnIsCanceled fnCanceled, void *context) |
Register a function that returns whether this job has been canceled - PAL calls it during the computation. More... | |
void | removeLayer (Layer *layer) |
remove a layer More... | |
void | setMaximumLineCandidatesPerMapUnit (double candidates) |
Sets the maximum number of line label candidates per map unit. More... | |
void | setMaximumPolygonCandidatesPerMapUnitSquared (double candidates) |
Sets the maximum number of polygon label candidates per map unit squared. More... | |
void | setPlacementVersion (QgsLabelingEngineSettings::PlacementEngineVersion placementVersion) |
Sets the placement engine version, which dictates how the label placement problem is solved. More... | |
void | setShowPartialLabels (bool show) |
Sets whether partial labels show be allowed. More... | |
bool | showPartialLabels () const |
Returns whether partial labels should be allowed. More... | |
QList< LabelPosition * > | solveProblem (Problem *prob, 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. More... | |
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 |
Layer * Pal::addLayer | ( | QgsAbstractLabelProvider * | provider, |
const QString & | layerName, | ||
QgsPalLayerSettings::Placement | arrangement, | ||
double | defaultPriority, | ||
bool | active, | ||
bool | toLabel, | ||
bool | displayAll = false |
||
) |
add a new layer
provider | Provider associated with the layer |
layerName | layer's name |
arrangement | Howto place candidates |
defaultPriority | layer's prioriry (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 |
displayAll | if true , all features will be labelled even though overlaps occur |
PalException::LayerExists |
std::unique_ptr< Problem > Pal::extractProblem | ( | const QgsRectangle & | extent, |
const QgsGeometry & | mapBoundary | ||
) |
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.
|
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.
QgsLabelingEngineSettings::PlacementEngineVersion 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 |
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 | ( | QgsLabelingEngineSettings::PlacementEngineVersion | placementVersion | ) |
Sets the placement engine version, which dictates how the label placement problem is solved.
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, |
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 |