QGIS API Documentation  2.6.0-Brighton
 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

bool getDisplayAll () const
int getNbFeatures ()
 get the number of features into layer
const char * getName ()
 get layer's name
Arrangement getArrangement ()
 get arrangement policy
void setArrangement (Arrangement arrangement)
 set arrangement policy
unsigned long getArrangementFlags () const
void setArrangementFlags (unsigned long flags)
Units getLabelUnit ()
 get units for label size
void setLabelUnit (Units label_unit)
 set unit for label size
void setActive (bool active)
 activate or desactivate the layer
bool isActive ()
 return the layer's activity status
void setToLabel (bool toLabel)
 tell pal whether the layer has to be labelled.
bool isToLabel ()
 return if the layer will be labelled or not
void setObstacle (bool obstacle)
 mark layer's features as obstacles
bool isObstacle ()
 return the obstacle status
void setMinScale (double min_scale)
 set the minimum valid scale, below this scale the layer will not be labelled
double getMinScale ()
 return the minimum valid scale
void setMaxScale (double max_scale)
 set the maximum valid scale, upon this scale the layer will not be labelled
double getMaxScale ()
 return the maximum valid scale
void setPriority (double priority)
 \ brief set the layer priority
double getPriority ()
 return the layer's priority
void setLabelMode (LabelMode m)
LabelMode getLabelMode () const
void setMergeConnectedLines (bool m)
bool getMergeConnectedLines () const
void setRepeatDistance (double distance)
double getRepeatDistance () const
void setUpsidedownLabels (UpsideDownLabels ud)
UpsideDownLabels getUpsidedownLabels () const
void setCentroidInside (bool forceInside)
bool getCentroidInside () const
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
FeaturegetFeature (const char *geom_id)
 return pointer to feature or NULL if doesn't exist
void joinConnectedFeatures ()
 join connected features with the same label text
void chopFeaturesAtRepeatDistance ()
 chop layer features at the repeat distance

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.
bool isScaleValid (double scale)
 check if the scal is in the scale range min_scale -> max_scale
void addFeaturePart (FeaturePart *fpart, const char *labelText=NULL)
 add newly creted feature part into r tree and to the list

Protected Attributes

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

Friends

class Pal
class FeaturePart
class Problem
class LabelPosition
bool extractFeatCallback (FeaturePart *ft_ptr, void *ctx)
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)

Member Enumeration Documentation

Enumerator:
LabelPerFeature 
LabelPerFeaturePart 
Enumerator:
Upright 
ShowDefined 
ShowAll 

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
pal::Layer::~Layer ( )
protectedvirtual

Delete the layer.

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

void pal::Layer::chopFeaturesAtRepeatDistance ( )

chop layer features at the repeat distance

Arrangement pal::Layer::getArrangement ( )

get arrangement policy

unsigned long pal::Layer::getArrangementFlags ( ) const
inline
bool pal::Layer::getCentroidInside ( ) const
inline
bool pal::Layer::getDisplayAll ( ) const
inline
Feature * pal::Layer::getFeature ( const char *  geom_id)

return pointer to feature or NULL if doesn't exist

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

get units for label size

double pal::Layer::getMaxScale ( )

return the maximum valid scale

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

return the minimum valid scale

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

get layer's name

int pal::Layer::getNbFeatures ( )

get the number of features into layer

double pal::Layer::getPriority ( )

return the layer's priority

double pal::Layer::getRepeatDistance ( ) const
inline
UpsideDownLabels pal::Layer::getUpsidedownLabels ( ) const
inline
bool pal::Layer::isActive ( )

return the layer's activity status

bool pal::Layer::isObstacle ( )

return the obstacle status

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
bool pal::Layer::isToLabel ( )

return if the layer will be labelled or not

void pal::Layer::joinConnectedFeatures ( )

join connected features with the same label text

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)
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)
void pal::Layer::setArrangement ( Arrangement  arrangement)

set arrangement policy

Parameters
arrangementarrangement policy
void pal::Layer::setArrangementFlags ( unsigned long  flags)
inline
void pal::Layer::setCentroidInside ( bool  forceInside)
inline
void pal::Layer::setLabelMode ( LabelMode  m)
inline
void pal::Layer::setLabelUnit ( Units  label_unit)

set unit for label size

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

void pal::Layer::setMergeConnectedLines ( bool  m)
inline
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

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

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

void pal::Layer::setRepeatDistance ( double  distance)
inline
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
void pal::Layer::setUpsidedownLabels ( UpsideDownLabels  ud)
inline

Friends And Related Function Documentation

bool extractFeatCallback ( FeaturePart ft_ptr,
void *  ctx 
)
friend
friend class FeaturePart
friend
friend class LabelPosition
friend
friend class Pal
friend
friend class Problem
friend
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
Arrangement pal::Layer::arrangement
protected

optional flags used for some placement methods

unsigned long pal::Layer::arrangementFlags
protected
bool pal::Layer::centroidInside
protected
HashTable< LinkedList<FeaturePart*>* >* pal::Layer::connectedHashtable
protected
LinkedList< char* >* pal::Layer::connectedTexts
protected
double pal::Layer::defaultPriority
protected
bool pal::Layer::displayAll
protected
LinkedList<FeaturePart*>* pal::Layer::featureParts
protected

list of feature parts

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

list of features - for deletion

HashTable<Feature*>* pal::Layer::hashtable
protected
Units pal::Layer::label_unit
protected
double pal::Layer::max_scale
protected
bool pal::Layer::mergeLines
protected
double pal::Layer::min_scale
protected
LabelMode pal::Layer::mode
protected
SimpleMutex* pal::Layer::modMutex
protected
char* pal::Layer::name
protected
bool pal::Layer::obstacle
protected
Pal* pal::Layer::pal
protected
double pal::Layer::repeatDistance
protected
RTree<FeaturePart*, double, 2, double, 8, 4>* pal::Layer::rtree
protected
bool pal::Layer::toLabel
protected
UpsideDownLabels pal::Layer::upsidedownLabels
protected

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