QGIS API Documentation  2.9.0-Master
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
pal::Layer Class Reference

A layer of spacial entites. More...

#include <layer.h>

Public Types

enum  LabelMode { LabelPerFeature, LabelPerFeaturePart }
enum  UpsideDownLabels { Upright, ShowDefined, ShowAll }

Public Member Functions

void chopFeaturesAtRepeatDistance ()
 chop layer features at the repeat distance More...
Arrangement getArrangement ()
 get arrangement policy More...
unsigned long getArrangementFlags () const
bool getCentroidInside () const
bool getDisplayAll () const
FeaturegetFeature (const char *geom_id)
 return pointer to feature or NULL if doesn't exist More...
LabelMode getLabelMode () const
Units getLabelUnit ()
 get units for label size More...
double getMaxScale ()
 return the maximum valid scale More...
bool getMergeConnectedLines () const
double getMinScale ()
 return the minimum valid scale More...
const char * getName ()
 get layer's name More...
int getNbFeatures ()
 get the number of features into layer More...
double getPriority ()
 return the layer's priority More...
UpsideDownLabels getUpsidedownLabels () const
bool isActive ()
 return the layer's activity status More...
bool isObstacle ()
 return the obstacle status More...
bool isToLabel ()
 return if the layer will be labelled or not More...
void joinConnectedFeatures ()
 join connected features with the same label text More...
bool registerFeature (const char *geom_id, PalGeometry *userGeom, double label_x=-1, double label_y=-1, const char *labelText=NULL, double labelPosX=0.0, double labelPosY=0.0, bool fixedPos=false, double angle=0.0, bool fixedAngle=false, int xQuadOffset=0, int yQuadOffset=0, double xOffset=0.0, double yOffset=0.0, bool alwaysShow=false, double repeatDistance=0)
 register a feature in the layer More...
void setActive (bool active)
 activate or desactivate the layer More...
void setArrangement (Arrangement arrangement)
 set arrangement policy More...
void setArrangementFlags (unsigned long flags)
void setCentroidInside (bool forceInside)
void setLabelMode (LabelMode m)
void setLabelUnit (Units label_unit)
 set unit for label size More...
void setMaxScale (double max_scale)
 set the maximum valid scale, upon this scale the layer will not be labelled More...
void setMergeConnectedLines (bool m)
void setMinScale (double min_scale)
 set the minimum valid scale, below this scale the layer will not be labelled More...
void setObstacle (bool obstacle)
 mark layer's features as obstacles More...
void setPriority (double priority)
 \ brief set the layer priority More...
void setToLabel (bool toLabel)
 tell pal whether the layer has to be labelled. More...
void setUpsidedownLabels (UpsideDownLabels ud)

Protected Member Functions

 Layer (const char *lyrName, double min_scale, double max_scale, Arrangement arrangement, Units label_unit, double defaultPriority, bool obstacle, bool active, bool toLabel, Pal *pal, bool displayAll=false)
 Create a new layer. More...
virtual ~Layer ()
 Delete the layer. More...
void addFeaturePart (FeaturePart *fpart, const char *labelText=NULL)
 add newly creted feature part into r tree and to the list More...
bool isScaleValid (double scale)
 check if the scal is in the scale range min_scale -> max_scale More...

Protected Attributes

bool active
Arrangement arrangement
 optional flags used for some placement methods More...
unsigned long arrangementFlags
bool centroidInside
HashTable< LinkedList< FeaturePart * > * > * connectedHashtable
LinkedList< char * > * connectedTexts
double defaultPriority
bool displayAll
LinkedList< FeaturePart * > * featureParts
 list of feature parts More...
LinkedList< Feature * > * features
 list of features - for deletion More...
HashTable< Feature * > * hashtable
Units label_unit
double max_scale
bool mergeLines
double min_scale
LabelMode mode
char * name
bool obstacle
RTree< FeaturePart *, double, 2, double, 8, 4 > * rtree
bool toLabel
UpsideDownLabels upsidedownLabels


bool extractFeatCallback (FeaturePart *ft_ptr, void *ctx)
class FeaturePart
class LabelPosition
class Pal
class Problem
void toSVGPath (int nbPoints, double *x, double *y, int dpi, Layer *layer, int type, char *uid, std::ostream &out, double scale, int xmin, int ymax, bool exportInfo, char *color)

Detailed Description

A layer of spacial entites.

a layer is a bog of feature with some data which influence the labelling process

Maxence Laurent (maxence dot laurent at heig-vd dot ch)

Definition at line 65 of file layer.h.

Member Enumeration Documentation


Definition at line 77 of file layer.h.


Definition at line 78 of file layer.h.

Constructor & Destructor Documentation

pal::Layer::Layer ( const char *  lyrName,
double  min_scale,
double  max_scale,
Arrangement  arrangement,
Units  label_unit,
double  defaultPriority,
bool  obstacle,
bool  active,
bool  toLabel,
Pal pal,
bool  displayAll = false 

Create a new layer.

lyrNamelayer's name
min_scalebellow this scale: no labeling
max_scaleabove this scale: no labeling
arrangementArrangement mode : how to place candidates
label_unitUnit for labels sizes
defaultPrioritylayer's prioriry (0 is the best, 1 the worst)
obstacle'true' will discourage other label to be placed above features of this layer
activeis the layer is active (currently displayed)
toLabelthe layer will be labeled whether toLablel is true
palpointer to the pal object
displayAllif true, all features will be labelled even though overlaps occur

Definition at line 61 of file layer.cpp.

pal::Layer::~Layer ( )

Delete the layer.

Definition at line 100 of file layer.cpp.

Member Function Documentation

void pal::Layer::addFeaturePart ( FeaturePart fpart,
const char *  labelText = NULL 

add newly creted feature part into r tree and to the list

Definition at line 386 of file layer.cpp.

void pal::Layer::chopFeaturesAtRepeatDistance ( )

chop layer features at the repeat distance

Definition at line 506 of file layer.cpp.

Arrangement pal::Layer::getArrangement ( )

get arrangement policy

Definition at line 161 of file layer.cpp.

unsigned long pal::Layer::getArrangementFlags ( ) const

Definition at line 184 of file layer.h.

bool pal::Layer::getCentroidInside ( ) const

Definition at line 299 of file layer.h.

bool pal::Layer::getDisplayAll ( ) const

Definition at line 85 of file layer.h.

Feature * pal::Layer::getFeature ( const char *  geom_id)

return pointer to feature or NULL if doesn't exist

Definition at line 137 of file layer.cpp.

LabelMode pal::Layer::getLabelMode ( ) const

Definition at line 287 of file layer.h.

Units pal::Layer::getLabelUnit ( )

get units for label size

Definition at line 428 of file layer.cpp.

double pal::Layer::getMaxScale ( )

return the maximum valid scale

Definition at line 193 of file layer.cpp.

bool pal::Layer::getMergeConnectedLines ( ) const

Definition at line 290 of file layer.h.

double pal::Layer::getMinScale ( )

return the minimum valid scale

Definition at line 188 of file layer.cpp.

const char * pal::Layer::getName ( )

get layer's name

Definition at line 156 of file layer.cpp.

int pal::Layer::getNbFeatures ( )

get the number of features into layer

Definition at line 151 of file layer.cpp.

double pal::Layer::getPriority ( )

return the layer's priority

Definition at line 198 of file layer.cpp.

UpsideDownLabels pal::Layer::getUpsidedownLabels ( ) const

Definition at line 296 of file layer.h.

bool pal::Layer::isActive ( )

return the layer's activity status

Definition at line 182 of file layer.cpp.

bool pal::Layer::isObstacle ( )

return the obstacle status

Definition at line 172 of file layer.cpp.

bool pal::Layer::isScaleValid ( double  scale)

check if the scal is in the scale range min_scale -> max_scale

scalethe scale to check

Definition at line 144 of file layer.cpp.

bool pal::Layer::isToLabel ( )

return if the layer will be labelled or not

Definition at line 177 of file layer.cpp.

void pal::Layer::joinConnectedFeatures ( )

join connected features with the same label text

Definition at line 451 of file layer.cpp.

bool pal::Layer::registerFeature ( const char *  geom_id,
PalGeometry userGeom,
double  label_x = -1,
double  label_y = -1,
const char *  labelText = NULL,
double  labelPosX = 0.0,
double  labelPosY = 0.0,
bool  fixedPos = false,
double  angle = 0.0,
bool  fixedAngle = false,
int  xQuadOffset = 0,
int  yQuadOffset = 0,
double  xOffset = 0.0,
double  yOffset = 0.0,
bool  alwaysShow = false,
double  repeatDistance = 0 

register a feature in the layer

geom_idunique identifier
userGeomuser's geometry that implements the PalGeometry interface
label_xlabel width
label_ylabel height
labelTextlabel text
labelPosXx position of the label (in case of fixed label position)
labelPosYy position of the label (in case of fixed label position)
fixedPostrue if a single fixed position for this label is needed
anglefixed angle (in radians) to rotate the label
fixedAnglewhether to use provided fixed angle
xQuadOffsetmove label to quadrant: left, don't move, right (-1, 0, 1)
yQuadOffsetmove label to quadrant: down, don't move, up (-1, 0, 1)
xOffsetmap unit (+/-) to x-offset the label
yOffsetmap unit (+/-) to y-offset the label
alwaysShowwhether to skip priority and always show the label (causes overlapping)
repeatDistancedistance for repeating the label
true on success (i.e. valid geometry)

Definition at line 240 of file layer.cpp.

void pal::Layer::setActive ( bool  active)

activate or desactivate the layer

active means "is currently display". When active is false feature of this layer will never be used (neither for labelling nor as obstacles)

activeturn the layer active (true) or inactive (false)

Definition at line 208 of file layer.cpp.

void pal::Layer::setArrangement ( Arrangement  arrangement)

set arrangement policy

arrangementarrangement policy

Definition at line 166 of file layer.cpp.

void pal::Layer::setArrangementFlags ( unsigned long  flags)

Definition at line 185 of file layer.h.

void pal::Layer::setCentroidInside ( bool  forceInside)

Definition at line 298 of file layer.h.

void pal::Layer::setLabelMode ( LabelMode  m)

Definition at line 286 of file layer.h.

void pal::Layer::setLabelUnit ( Units  label_unit)

set unit for label size

Definition at line 422 of file layer.cpp.

void pal::Layer::setMaxScale ( double  max_scale)

set the maximum valid scale, upon this scale the layer will not be labelled

use -1 to disable

Definition at line 223 of file layer.cpp.

void pal::Layer::setMergeConnectedLines ( bool  m)

Definition at line 289 of file layer.h.

void pal::Layer::setMinScale ( double  min_scale)

set the minimum valid scale, below this scale the layer will not be labelled

Use -1 to disable

Definition at line 218 of file layer.cpp.

void pal::Layer::setObstacle ( bool  obstacle)

mark layer's features as obstacles

Avoid putting labels over obstalces. isActive must also be true to consider feature as obstacles, otherwise they will be ignored

Definition at line 203 of file layer.cpp.

void pal::Layer::setPriority ( double  priority)

\ brief set the layer priority

The best priority is 0, the worst is 1 Should be links with a slider in a nice gui

Definition at line 228 of file layer.cpp.

void pal::Layer::setToLabel ( bool  toLabel)

tell pal whether the layer has to be labelled.

The layer will be labelled if and only if toLabel and isActive were set to true

toLabelset to false disable lbelling this layer

Definition at line 213 of file layer.cpp.

void pal::Layer::setUpsidedownLabels ( UpsideDownLabels  ud)

Definition at line 295 of file layer.h.

Friends And Related Function Documentation

bool extractFeatCallback ( FeaturePart ft_ptr,
void *  ctx 

Definition at line 235 of file pal.cpp.

friend class FeaturePart

Definition at line 68 of file layer.h.

friend class LabelPosition

Definition at line 72 of file layer.h.

friend class Pal

Definition at line 67 of file layer.h.

friend class Problem

Definition at line 70 of file layer.h.

void toSVGPath ( int  nbPoints,
double *  x,
double *  y,
int  dpi,
Layer layer,
int  type,
char *  uid,
std::ostream &  out,
double  scale,
int  xmin,
int  ymax,
bool  exportInfo,
char *  color 

Member Data Documentation

bool pal::Layer::active

Definition at line 101 of file layer.h.

Arrangement pal::Layer::arrangement

optional flags used for some placement methods

Definition at line 112 of file layer.h.

unsigned long pal::Layer::arrangementFlags

Definition at line 113 of file layer.h.

bool pal::Layer::centroidInside

Definition at line 104 of file layer.h.

HashTable< LinkedList<FeaturePart*>* >* pal::Layer::connectedHashtable

Definition at line 123 of file layer.h.

LinkedList< char* >* pal::Layer::connectedTexts

Definition at line 124 of file layer.h.

double pal::Layer::defaultPriority

Definition at line 98 of file layer.h.

bool pal::Layer::displayAll

Definition at line 103 of file layer.h.

LinkedList<FeaturePart*>* pal::Layer::featureParts

list of feature parts

Definition at line 91 of file layer.h.

LinkedList<Feature*>* pal::Layer::features

list of features - for deletion

Definition at line 94 of file layer.h.

HashTable<Feature*>* pal::Layer::hashtable

Definition at line 121 of file layer.h.

Units pal::Layer::label_unit

Definition at line 106 of file layer.h.

double pal::Layer::max_scale

Definition at line 109 of file layer.h.

bool pal::Layer::mergeLines

Definition at line 115 of file layer.h.

double pal::Layer::min_scale

Definition at line 108 of file layer.h.

LabelMode pal::Layer::mode

Definition at line 114 of file layer.h.

SimpleMutex* pal::Layer::modMutex

Definition at line 126 of file layer.h.

char* pal::Layer::name

Definition at line 88 of file layer.h.

bool pal::Layer::obstacle

Definition at line 100 of file layer.h.

Pal* pal::Layer::pal

Definition at line 96 of file layer.h.

RTree<FeaturePart*, double, 2, double, 8, 4>* pal::Layer::rtree

Definition at line 120 of file layer.h.

bool pal::Layer::toLabel

Definition at line 102 of file layer.h.

UpsideDownLabels pal::Layer::upsidedownLabels

Definition at line 117 of file layer.h.

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