QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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

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

Definition at line 129 of file pal.h.

Constructor & Destructor Documentation

Pal::Pal ( )

Create an new pal instance.

Definition at line 48 of file pal.cpp.

Pal::~Pal ( )

Definition at line 90 of file pal.cpp.

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

Pal cannot be copied.

Member Function Documentation

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.

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.

int Pal::getLineP ( )

Returns the number of candidates to generate for line features.

Definition at line 542 of file pal.cpp.

int Pal::getPointP ( )

Returns the number of candidates to generate for point features.

Definition at line 537 of file pal.cpp.

int Pal::getPolyP ( )

Returns the number of candidates to generate for polygon features.

Definition at line 547 of file pal.cpp.

SearchMethod Pal::getSearch ( )

Returns the search method in use.

Definition at line 567 of file pal.cpp.

bool Pal::getShowPartial ( )

Returns whether partial labels should be allowed.

Definition at line 562 of file pal.cpp.

bool pal::Pal::isCanceled ( )
inline

Check whether the job has been canceled.

Definition at line 135 of file pal.h.

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

Pal cannot be copied.

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.

void Pal::removeLayer ( Layer layer)

remove a layer

Parameters
layerlayer to remove

Definition at line 76 of file pal.cpp.

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.

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.

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.

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.

void Pal::setShowPartial ( bool  show)

Set flag show partial label.

Parameters
showflag value

Definition at line 532 of file pal.cpp.

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

Definition at line 455 of file pal.cpp.

Friends And Related Function Documentation

friend class FeaturePart
friend

Definition at line 90 of file pal.h.

friend class Layer
friend

Definition at line 91 of file pal.h.

friend class Problem
friend

Definition at line 89 of file pal.h.


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