QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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
Arrangement getArrangement ()
 get arrangement policy
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
LabelMode getLabelMode () const
Units getLabelUnit ()
 get units for label size
double getMaxScale ()
 return the maximum valid scale
bool getMergeConnectedLines () const
double getMinScale ()
 return the minimum valid scale
const char * getName ()
 get layer's name
int getNbFeatures ()
 get the number of features into layer
double getPriority ()
 return the layer's priority
UpsideDownLabels getUpsidedownLabels () const
bool isActive ()
 return the layer's activity status
bool isObstacle ()
 return the obstacle status
bool isToLabel ()
 return if the layer will be labelled or not
void joinConnectedFeatures ()
 join connected features with the same label text
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
void setActive (bool active)
 activate or desactivate the layer
void setArrangement (Arrangement arrangement)
 set arrangement policy
void setArrangementFlags (unsigned long flags)
void setCentroidInside (bool forceInside)
void setLabelMode (LabelMode m)
void setLabelUnit (Units label_unit)
 set unit for label size
void setMaxScale (double max_scale)
 set the maximum valid scale, upon this scale the layer will not be labelled
void setMergeConnectedLines (bool m)
void setMinScale (double min_scale)
 set the minimum valid scale, below this scale the layer will not be labelled
void setObstacle (bool obstacle)
 mark layer's features as obstacles
void setPriority (double priority)
 \ brief set the layer priority
void setToLabel (bool toLabel)
 tell pal whether the layer has to be labelled.
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.
virtual ~Layer ()
 Delete the layer.
void addFeaturePart (FeaturePart *fpart, const char *labelText=NULL)
 add newly creted feature part into r tree and to the list
bool isScaleValid (double scale)
 check if the scal is in the scale range min_scale -> max_scale

Protected Attributes

bool active
Arrangement arrangement
 optional flags used for some placement methods
unsigned long arrangementFlags
bool centroidInside
HashTable< LinkedList
< FeaturePart * > * > * 
connectedHashtable
LinkedList< char * > * connectedTexts
double defaultPriority
bool displayAll
LinkedList< FeaturePart * > * featureParts
 list of feature parts
LinkedList< Feature * > * features
 list of features - for deletion
HashTable< Feature * > * hashtable
Units label_unit
double max_scale
bool mergeLines
double min_scale
LabelMode mode
SimpleMutexmodMutex
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 65 of file layer.h.

Member Enumeration Documentation

Enumerator:
LabelPerFeature 
LabelPerFeaturePart 

Definition at line 77 of file layer.h.

Enumerator:
Upright 
ShowDefined 
ShowAll 

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 
)
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 61 of file layer.cpp.

pal::Layer::~Layer ( )
protectedvirtual

Delete the layer.

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

void pal::Layer::chopFeaturesAtRepeatDistance ( )

chop layer features at the repeat distance

Definition at line 497 of file layer.cpp.

Arrangement pal::Layer::getArrangement ( )

get arrangement policy

Definition at line 152 of file layer.cpp.

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

Definition at line 184 of file layer.h.

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

Definition at line 299 of file layer.h.

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

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

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

Definition at line 287 of file layer.h.

Units pal::Layer::getLabelUnit ( )

get units for label size

Definition at line 419 of file layer.cpp.

double pal::Layer::getMaxScale ( )

return the maximum valid scale

Definition at line 184 of file layer.cpp.

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

Definition at line 290 of file layer.h.

double pal::Layer::getMinScale ( )

return the minimum valid scale

Definition at line 179 of file layer.cpp.

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

get layer's name

Definition at line 147 of file layer.cpp.

int pal::Layer::getNbFeatures ( )

get the number of features into layer

Definition at line 142 of file layer.cpp.

double pal::Layer::getPriority ( )

return the layer's priority

Definition at line 189 of file layer.cpp.

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

Definition at line 296 of file layer.h.

bool pal::Layer::isActive ( )

return the layer's activity status

Definition at line 173 of file layer.cpp.

bool pal::Layer::isObstacle ( )

return the obstacle status

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

bool pal::Layer::isToLabel ( )

return if the layer will be labelled or not

Definition at line 168 of file layer.cpp.

void pal::Layer::joinConnectedFeatures ( )

join connected features with the same label text

Definition at line 442 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 231 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 199 of file layer.cpp.

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

set arrangement policy

Parameters
arrangementarrangement policy

Definition at line 157 of file layer.cpp.

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

Definition at line 185 of file layer.h.

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

Definition at line 298 of file layer.h.

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

Definition at line 286 of file layer.h.

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

set unit for label size

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

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

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 209 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 194 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 219 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 204 of file layer.cpp.

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

Definition at line 295 of file layer.h.

Friends And Related Function Documentation

bool extractFeatCallback ( FeaturePart ft_ptr,
void *  ctx 
)
friend

Definition at line 235 of file pal.cpp.

friend class FeaturePart
friend

Definition at line 68 of file layer.h.

friend class LabelPosition
friend

Definition at line 72 of file layer.h.

friend class Pal
friend

Definition at line 67 of file layer.h.

friend class Problem
friend

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 
)
friend

Member Data Documentation

bool pal::Layer::active
protected

Definition at line 101 of file layer.h.

Arrangement pal::Layer::arrangement
protected

optional flags used for some placement methods

Definition at line 112 of file layer.h.

unsigned long pal::Layer::arrangementFlags
protected

Definition at line 113 of file layer.h.

bool pal::Layer::centroidInside
protected

Definition at line 104 of file layer.h.

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

Definition at line 123 of file layer.h.

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

Definition at line 124 of file layer.h.

double pal::Layer::defaultPriority
protected

Definition at line 98 of file layer.h.

bool pal::Layer::displayAll
protected

Definition at line 103 of file layer.h.

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

list of feature parts

Definition at line 91 of file layer.h.

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

list of features - for deletion

Definition at line 94 of file layer.h.

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

Definition at line 121 of file layer.h.

Units pal::Layer::label_unit
protected

Definition at line 106 of file layer.h.

double pal::Layer::max_scale
protected

Definition at line 109 of file layer.h.

bool pal::Layer::mergeLines
protected

Definition at line 115 of file layer.h.

double pal::Layer::min_scale
protected

Definition at line 108 of file layer.h.

LabelMode pal::Layer::mode
protected

Definition at line 114 of file layer.h.

SimpleMutex* pal::Layer::modMutex
protected

Definition at line 126 of file layer.h.

char* pal::Layer::name
protected

Definition at line 88 of file layer.h.

bool pal::Layer::obstacle
protected

Definition at line 100 of file layer.h.

Pal* pal::Layer::pal
protected

Definition at line 96 of file layer.h.

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

Definition at line 120 of file layer.h.

bool pal::Layer::toLabel
protected

Definition at line 102 of file layer.h.

UpsideDownLabels pal::Layer::upsidedownLabels
protected

Definition at line 117 of file layer.h.


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