QGIS API Documentation  3.2.0-Bonn (bc43194)
Public Types | Public Member Functions | Friends | List of all members
pal::Pal Class Reference

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 ()
 
LayeraddLayer (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< ProblemextractProblem (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 getLineP ()
 Returns the number of candidates to generate for line features. More...
 
int getPointP ()
 Returns the number of candidates to generate for point features. More...
 
int getPolyP ()
 Returns the number of candidates to generate for polygon features. More...
 
SearchMethod getSearch ()
 Returns the search method in use. More...
 
bool getShowPartial ()
 Returns whether partial labels should be allowed. More...
 
bool isCanceled ()
 Check whether the job has been canceled. More...
 
Paloperator= (const Pal &other)=delete
 Pal cannot be copied. More...
 
void registerCancelationCallback (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 setLineP (int line_p)
 set maximum # candidates to generate for lines features Higher the value is, longer Pal::labeller will spend time More...
 
void setPointP (int point_p)
 set # candidates to generate for points features Higher the value is, longer Pal::labeller will spend time More...
 
void setPolyP (int poly_p)
 set maximum # candidates to generate for polygon features Higher the value is, longer Pal::labeller will spend time More...
 
void setSearch (SearchMethod method)
 Select the search method to use. More...
 
void setShowPartial (bool show)
 Set flag show partial label. More...
 
QList< LabelPosition * > solveProblem (Problem *prob, bool displayAll)
 

Friends

class FeaturePart
 
class Layer
 
class Problem
 

Detailed Description

Main Pal labeling class.

A pal object will contains layers and global information such as which search method will be used.

Note
not available in Python bindings

Definition at line 87 of file pal.h.

Member Typedef Documentation

◆ FnIsCanceled

typedef bool( * pal::Pal::FnIsCanceled) (void *ctx)

Definition at line 129 of file pal.h.

Constructor & Destructor Documentation

◆ Pal() [1/2]

Pal::Pal ( )

Create an new pal instance.

Definition at line 48 of file pal.cpp.

◆ ~Pal()

Pal::~Pal ( )

Definition at line 90 of file pal.cpp.

◆ Pal() [2/2]

pal::Pal::Pal ( const Pal other)
delete

Pal cannot be copied.

Member Function Documentation

◆ addLayer()

Layer * Pal::addLayer ( QgsAbstractLabelProvider provider,
const QString &  layerName,
QgsPalLayerSettings::Placement  arrangement,
double  defaultPriority,
bool  active,
bool  toLabel,
bool  displayAll = false 
)

add a new layer

Parameters
providerProvider associated with the layer
layerNamelayer's name
arrangementHowto place candidates
defaultPrioritylayer's prioriry (0 is the best, 1 the worst)
activeis the layer is active (currently displayed)
toLabelthe layer will be labeled only if toLablel is true
displayAllif true, all features will be labelled even though overlaps occur
Exceptions
PalException::LayerExists

Definition at line 103 of file pal.cpp.

◆ extractProblem()

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.

Definition at line 450 of file pal.cpp.

◆ getLineP()

int Pal::getLineP ( )

Returns the number of candidates to generate for line features.

Definition at line 542 of file pal.cpp.

◆ getPointP()

int Pal::getPointP ( )

Returns the number of candidates to generate for point features.

Definition at line 537 of file pal.cpp.

◆ getPolyP()

int Pal::getPolyP ( )

Returns the number of candidates to generate for polygon features.

Definition at line 547 of file pal.cpp.

◆ getSearch()

SearchMethod Pal::getSearch ( )

Returns the search method in use.

Definition at line 567 of file pal.cpp.

◆ getShowPartial()

bool Pal::getShowPartial ( )

Returns whether partial labels should be allowed.

Definition at line 562 of file pal.cpp.

◆ isCanceled()

bool pal::Pal::isCanceled ( )
inline

Check whether the job has been canceled.

Definition at line 135 of file pal.h.

◆ operator=()

Pal& pal::Pal::operator= ( const Pal other)
delete

Pal cannot be copied.

◆ registerCancelationCallback()

void Pal::registerCancelationCallback ( Pal::FnIsCanceled  fnCanceled,
void *  context 
)

Register a function that returns whether this job has been canceled - PAL calls it during the computation.

Definition at line 444 of file pal.cpp.

◆ removeLayer()

void Pal::removeLayer ( Layer layer)

remove a layer

Parameters
layerlayer to remove

Definition at line 76 of file pal.cpp.

◆ setLineP()

void 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_pmaximum # candidates for a line

Definition at line 486 of file pal.cpp.

◆ setPointP()

void 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

Definition at line 480 of file pal.cpp.

◆ setPolyP()

void 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_pmaximum # candidate for a polygon

Definition at line 492 of file pal.cpp.

◆ setSearch()

void Pal::setSearch ( SearchMethod  method)

Select the search 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

Parameters
methodthe method to use

Definition at line 572 of file pal.cpp.

◆ setShowPartial()

void Pal::setShowPartial ( bool  show)

Set flag show partial label.

Parameters
showflag value

Definition at line 532 of file pal.cpp.

◆ solveProblem()

QList< LabelPosition * > Pal::solveProblem ( Problem prob,
bool  displayAll 
)

Definition at line 455 of file pal.cpp.

Friends And Related Function Documentation

◆ FeaturePart

friend class FeaturePart
friend

Definition at line 90 of file pal.h.

◆ Layer

friend class Layer
friend

Definition at line 91 of file pal.h.

◆ Problem

friend class Problem
friend

Definition at line 89 of file pal.h.


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