Pal class
Main Pal labeling class.
Contents
A pal object will contains layers and global information such as which search method will be used.
Constructors, destructors, conversion operators
Public functions
-
auto addLayer(QgsAbstractLabelProvider* provider,
const QString& layerName,
QgsPalLayerSettings::
Placement arrangement, double defaultPriority, bool active, bool toLabel, bool displayAll = false) -> Layer* - add a new layer
- auto extractProblem(const QgsRectangle& extent, const QgsGeometry& mapBoundary) -> std::unique_ptr<Problem>
- Extracts the labeling problem for the specified map extent - only features within this extent will be considered.
- auto getLineP() -> int
- Returns the number of candidates to generate for line features.
- auto getPointP() -> int
- Returns the number of candidates to generate for point features.
- auto getPolyP() -> int
- Returns the number of candidates to generate for polygon features.
- auto getSearch() -> SearchMethod
- Returns the search method in use.
- auto getShowPartial() -> bool
- Returns whether partial labels should be allowed.
- auto isCanceled() -> bool
- Check whether the job has been canceled.
- auto operator=(const Pal& other) -> Pal& deleted
- Pal cannot be copied.
- void registerCancelationCallback(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
- void setLineP(int line_p)
- set maximum # candidates to generate for lines features Higher the value is, longer Pal::labeller will spend time
- void setPointP(int point_p)
- set # candidates to generate for points features Higher the value is, longer Pal::labeller will spend time
- void setPolyP(int poly_p)
- set maximum # candidates to generate for polygon features Higher the value is, longer Pal::labeller will spend time
- void setSearch(SearchMethod method)
- Select the search method to use.
- void setShowPartial(bool show)
- Set flag show partial label.
Function documentation
Layer* pal:: Pal:: addLayer(QgsAbstractLabelProvider* provider,
const QString& layerName,
QgsPalLayerSettings:: Placement arrangement,
double defaultPriority,
bool active,
bool toLabel,
bool displayAll = false)
add a new layer
| Parameters | |
|---|---|
| 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 |
| Exceptions | |
| None | |
std::unique_ptr<Problem> pal:: 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.
void pal:: Pal:: setLineP(int line_p)
set maximum # candidates to generate for lines features Higher the value is, longer Pal::labeller will spend time
| Parameters | |
|---|---|
| line_p | maximum # candidates for a line |
void pal:: Pal:: setPointP(int point_p)
set # candidates to generate for points features Higher the value is, longer Pal::labeller will spend time
| Parameters | |
|---|---|
| point_p | # candidates for a point |
void pal:: Pal:: setPolyP(int poly_p)
set maximum # candidates to generate for polygon features Higher the value is, longer Pal::labeller will spend time
| Parameters | |
|---|---|
| poly_p | maximum # candidate for a polygon |
void pal:: Pal:: setSearch(SearchMethod method)
Select the search method to use.
| Parameters | |
|---|---|
| method | the method to use |
For interactive mapping using CHAIN is a good idea because it is the fastest. Other methods, ordered by speedness, are POPMUSIC_TABU, POPMUSIC_CHAIN and POPMUSIC_TABU_CHAIN, defined in pal::_searchMethod enumeration