QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
Public Types | Public Member Functions | Friends | List of all members
pal::Pal Class Reference

Main Pal labelling class. More...

#include <pal.h>

Public Types

typedef bool(* FnIsCancelled) (void *ctx)
 

Public Member Functions

 Pal ()
 Create an new pal instance. More...
 
 ~Pal ()
 delete an instance More...
 
LayeraddLayer (QgsAbstractLabelProvider *provider, const QString &layerName, QgsPalLayerSettings::Placement arrangement, double defaultPriority, bool active, bool toLabel, bool displayAll=false)
 add a new layer More...
 
ProblemextractProblem (double bbox[4])
 
int getLineP ()
 get maximum # candidates to generate for line features More...
 
int getPointP ()
 get # candidates to generate for point features More...
 
int getPolyP ()
 get maximum # candidates to generate for polygon features More...
 
SearchMethod getSearch ()
 get the search method in use More...
 
bool getShowPartial ()
 Get flag show partial label. More...
 
bool isCancelled ()
 Check whether the job has been cancelled. More...
 
QList< LabelPosition * > * labeller (double bbox[4], PalStat **stats, bool displayAll)
 the labeling machine Will extract all active layers More...
 
void registerCancellationCallback (FnIsCancelled fnCancelled, void *context)
 Register a function that returns whether this job has been cancelled - 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 labelling 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 84 of file pal.h.

Member Typedef Documentation

◆ FnIsCancelled

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

Definition at line 138 of file pal.h.

Constructor & Destructor Documentation

◆ Pal()

Pal::Pal ( )

Create an new pal instance.

Definition at line 53 of file pal.cpp.

◆ ~Pal()

Pal::~Pal ( )

delete an instance

Definition at line 95 of file pal.cpp.

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
Todo:
add symbolUnit

Definition at line 108 of file pal.cpp.

◆ extractProblem()

Problem * Pal::extractProblem ( double  bbox[4])

Definition at line 512 of file pal.cpp.

◆ getLineP()

int Pal::getLineP ( )

get maximum # candidates to generate for line features

Definition at line 604 of file pal.cpp.

◆ getPointP()

int Pal::getPointP ( )

get # candidates to generate for point features

Definition at line 599 of file pal.cpp.

◆ getPolyP()

int Pal::getPolyP ( )

get maximum # candidates to generate for polygon features

Definition at line 609 of file pal.cpp.

◆ getSearch()

SearchMethod Pal::getSearch ( )

get the search method in use

Returns
the search method

Definition at line 629 of file pal.cpp.

◆ getShowPartial()

bool Pal::getShowPartial ( )

Get flag show partial label.

Returns
value of flag

Definition at line 624 of file pal.cpp.

◆ isCancelled()

bool pal::Pal::isCancelled ( )
inline

Check whether the job has been cancelled.

Definition at line 144 of file pal.h.

◆ labeller()

QList< LabelPosition * > * Pal::labeller ( double  bbox[4],
PalStat **  stats,
bool  displayAll 
)

the labeling machine Will extract all active layers

Parameters
bboxmap extent
statsA PalStat object (can be NULL)
displayAllif true, all feature will be labelled even though overlaps occur
Returns
A list of label to display on map

Definition at line 454 of file pal.cpp.

◆ registerCancellationCallback()

void Pal::registerCancellationCallback ( Pal::FnIsCancelled  fnCancelled,
void *  context 
)

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

Definition at line 506 of file pal.cpp.

◆ removeLayer()

void Pal::removeLayer ( Layer layer)

remove a layer

Parameters
layerlayer to remove

Definition at line 81 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 548 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 542 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 554 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 634 of file pal.cpp.

◆ setShowPartial()

void Pal::setShowPartial ( bool  show)

Set flag show partial label.

Parameters
showflag value

Definition at line 594 of file pal.cpp.

◆ solveProblem()

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

Definition at line 517 of file pal.cpp.

Friends And Related Function Documentation

◆ FeaturePart

friend class FeaturePart
friend

Definition at line 87 of file pal.h.

◆ Layer

friend class Layer
friend

Definition at line 88 of file pal.h.

◆ Problem

friend class Problem
friend

Definition at line 86 of file pal.h.


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