QGIS API Documentation  2.11.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
 
QMutex mMutex
 
LabelMode mode
 
char * name
 
bool obstacle
 
Palpal
 
RTree< FeaturePart *, double, 2, double, 8, 4 > * rtree
 
bool toLabel
 
UpsideDownLabels upsidedownLabels
 

Friends

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

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

Definition at line 60 of file layer.h.

Member Enumeration Documentation

Enumerator
LabelPerFeature 
LabelPerFeaturePart 

Definition at line 72 of file layer.h.

Enumerator
Upright 
ShowDefined 
ShowAll 

Definition at line 73 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 
)
protected

Create a new layer.

Parameters
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 53 of file layer.cpp.

pal::Layer::~Layer ( )
protectedvirtual

Delete the layer.

Definition at line 90 of file layer.cpp.

Member Function Documentation

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

Add newly creted feature part into r tree and to the list.

Definition at line 376 of file layer.cpp.

void pal::Layer::chopFeaturesAtRepeatDistance ( )

Chop layer features at the repeat distance.

Definition at line 496 of file layer.cpp.

Arrangement pal::Layer::getArrangement ( )

get arrangement policy

Definition at line 151 of file layer.cpp.

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

Definition at line 105 of file layer.h.

bool pal::Layer::getCentroidInside ( ) const
inline

Definition at line 220 of file layer.h.

bool pal::Layer::getDisplayAll ( ) const
inline

Definition at line 80 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 127 of file layer.cpp.

LabelMode pal::Layer::getLabelMode ( ) const
inline

Definition at line 208 of file layer.h.

Units pal::Layer::getLabelUnit ( )

get units for label size

Definition at line 418 of file layer.cpp.

double pal::Layer::getMaxScale ( )

return the maximum valid scale

Definition at line 183 of file layer.cpp.

bool pal::Layer::getMergeConnectedLines ( ) const
inline

Definition at line 211 of file layer.h.

double pal::Layer::getMinScale ( )

return the minimum valid scale

Definition at line 178 of file layer.cpp.

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

get layer's name

Definition at line 146 of file layer.cpp.

int pal::Layer::getNbFeatures ( )

get the number of features into layer

Definition at line 141 of file layer.cpp.

double pal::Layer::getPriority ( )

return the layer's priority

Definition at line 188 of file layer.cpp.

UpsideDownLabels pal::Layer::getUpsidedownLabels ( ) const
inline

Definition at line 217 of file layer.h.

bool pal::Layer::isActive ( )

return the layer's activity status

Definition at line 172 of file layer.cpp.

bool pal::Layer::isObstacle ( )

return the obstacle status

Definition at line 162 of file layer.cpp.

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

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

Parameters
scalethe scale to check

Definition at line 134 of file layer.cpp.

bool pal::Layer::isToLabel ( )

return if the layer will be labelled or not

Definition at line 167 of file layer.cpp.

void pal::Layer::joinConnectedFeatures ( )

Join connected features with the same label text.

Definition at line 441 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

Parameters
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
Exceptions
PalException::FeatureExists
Returns
true on success (i.e. valid geometry)

Definition at line 230 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)

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

Definition at line 198 of file layer.cpp.

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

set arrangement policy

Parameters
arrangementarrangement policy

Definition at line 156 of file layer.cpp.

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

Definition at line 106 of file layer.h.

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

Definition at line 219 of file layer.h.

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

Definition at line 207 of file layer.h.

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

set unit for label size

Definition at line 412 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 213 of file layer.cpp.

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

Definition at line 210 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 208 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 193 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 218 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

Parameters
toLabelset to false disable lbelling this layer

Definition at line 203 of file layer.cpp.

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

Definition at line 216 of file layer.h.

Friends And Related Function Documentation

bool extractFeatCallback ( FeaturePart ft_ptr,
void *  ctx 
)
friend

Definition at line 222 of file pal.cpp.

friend class FeaturePart
friend

Definition at line 63 of file layer.h.

friend class LabelPosition
friend

Definition at line 67 of file layer.h.

friend class Pal
friend

Definition at line 62 of file layer.h.

friend class Problem
friend

Definition at line 65 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 
)
friend

Member Data Documentation

bool pal::Layer::active
protected

Definition at line 275 of file layer.h.

Arrangement pal::Layer::arrangement
protected

Optional flags used for some placement methods.

Definition at line 286 of file layer.h.

unsigned long pal::Layer::arrangementFlags
protected

Definition at line 287 of file layer.h.

bool pal::Layer::centroidInside
protected

Definition at line 278 of file layer.h.

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

Definition at line 297 of file layer.h.

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

Definition at line 298 of file layer.h.

double pal::Layer::defaultPriority
protected

Definition at line 272 of file layer.h.

bool pal::Layer::displayAll
protected

Definition at line 277 of file layer.h.

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

List of feature parts.

Definition at line 265 of file layer.h.

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

List of features - for deletion.

Definition at line 268 of file layer.h.

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

Definition at line 295 of file layer.h.

Units pal::Layer::label_unit
protected

Definition at line 280 of file layer.h.

double pal::Layer::max_scale
protected

Definition at line 283 of file layer.h.

bool pal::Layer::mergeLines
protected

Definition at line 289 of file layer.h.

double pal::Layer::min_scale
protected

Definition at line 282 of file layer.h.

QMutex pal::Layer::mMutex
protected

Definition at line 300 of file layer.h.

LabelMode pal::Layer::mode
protected

Definition at line 288 of file layer.h.

char* pal::Layer::name
protected

Definition at line 262 of file layer.h.

bool pal::Layer::obstacle
protected

Definition at line 274 of file layer.h.

Pal* pal::Layer::pal
protected

Definition at line 270 of file layer.h.

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

Definition at line 294 of file layer.h.

bool pal::Layer::toLabel
protected

Definition at line 276 of file layer.h.

UpsideDownLabels pal::Layer::upsidedownLabels
protected

Definition at line 291 of file layer.h.


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