QGIS API Documentation  2.11.0-Master
 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

virtual ~Layer ()
 
bool active () const
 Returns whether the layer is currently active. More...
 
Arrangement arrangement () const
 Returns the layer's arrangement policy. More...
 
LineArrangementFlags arrangementFlags () const
 Returns the layer's arrangement flags. More...
 
bool centroidInside () const
 Returns whether labels placed at the centroid of features within the layer are forced to be placed inside the feature's geometry. More...
 
void chopFeaturesAtRepeatDistance ()
 Chop layer features at the repeat distance. More...
 
bool displayAll () const
 
int featureCount ()
 Returns the number of features in layer. More...
 
bool fitInPolygonOnly () const
 Returns whether labels which do not fit completely within a polygon feature are discarded. More...
 
FeaturegetFeature (const QString &geom_id)
 Return pointer to feature or NULL if doesn't exist. More...
 
void joinConnectedFeatures ()
 Join connected features with the same label text. More...
 
bool labelLayer () const
 Returns whether the layer will be labeled or not. More...
 
LabelMode labelMode () const
 Returns the layer's labeling mode. More...
 
bool mergeConnectedLines () const
 Returns whether connected lines will be merged before labeling. More...
 
QString name () const
 Returns the layer's name. More...
 
bool obstacle () const
 Returns whether features within the layer act as obstacles for labels. More...
 
ObstacleType obstacleType () const
 Returns the obstacle type, which controls how features within the layer act as obstacles for labels. More...
 
double priority () const
 Returns the layer's priority, between 0 and 1. More...
 
bool registerFeature (const QString &geom_id, PalGeometry *userGeom, double label_x=-1, double label_y=-1, const QString &labelText=QString(), 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)
 Sets whether the layer is currently active. More...
 
void setArrangement (Arrangement arrangement)
 Sets the layer's arrangement policy. More...
 
void setArrangementFlags (LineArrangementFlags flags)
 Sets the layer's arrangement flags. More...
 
void setCentroidInside (bool forceInside)
 Sets whether labels placed at the centroid of features within the layer are forced to be placed inside the feature's geometry. More...
 
void setFitInPolygonOnly (bool fitInPolygon)
 Sets whether labels which do not fit completely within a polygon feature are discarded. More...
 
void setLabelLayer (bool toLabel)
 Sets whether the layer will be labeled. More...
 
void setLabelMode (LabelMode mode)
 Sets the layer's labeling mode. More...
 
void setMergeConnectedLines (bool merge)
 Sets whether connected lines should be merged before labeling. More...
 
void setObstacle (bool obstacle)
 Sets whether features within the layer will act as obstacles for labels. More...
 
void setObstacleType (ObstacleType obstacleType)
 Sets the obstacle type, which controls how features within the layer act as obstacles for labels. More...
 
void setPriority (double priority)
 Sets the layer's priority. More...
 
void setUpsidedownLabels (UpsideDownLabels ud)
 Sets how upside down labels will be handled within the layer. More...
 
UpsideDownLabels upsidedownLabels () const
 Returns how upside down labels are handled within the layer. More...
 

Protected Member Functions

 Layer (const QString &lyrName, Arrangement arrangement, double defaultPriority, bool obstacle, bool active, bool toLabel, Pal *pal, bool displayAll=false)
 Create a new layer. More...
 
void addFeaturePart (FeaturePart *fpart, const QString &labelText=QString())
 Add newly created feature part into r tree and to the list. More...
 

Protected Attributes

QList< Feature * > features
 List of features - for deletion. More...
 
bool mActive
 
Arrangement mArrangement
 Optional flags used for some placement methods. More...
 
LineArrangementFlags mArrangementFlags
 
bool mCentroidInside
 
QHash< QString, QLinkedList
< FeaturePart * > * > 
mConnectedHashtable
 
QStringList mConnectedTexts
 
double mDefaultPriority
 
bool mDisplayAll
 
QLinkedList< FeaturePart * > mFeatureParts
 List of feature parts. More...
 
bool mFitInPolygon
 
QHash< QString, Feature * > mHashtable
 
bool mLabelLayer
 
bool mMergeLines
 
LabelMode mMode
 
QMutex mMutex
 
QString mName
 
bool mObstacle
 
ObstacleType mObstacleType
 
UpsideDownLabels mUpsidedownLabels
 
Palpal
 
RTree< FeaturePart *, double,
2, double, 8, 4 > * 
rtree
 

Friends

bool extractFeatCallback (FeaturePart *ft_ptr, void *ctx)
 
class FeaturePart
 
class LabelPosition
 
class Pal
 
class Problem
 

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 57 of file layer.h.

Member Enumeration Documentation

Enumerator
LabelPerFeature 
LabelPerFeaturePart 

Definition at line 68 of file layer.h.

Enumerator
Upright 
ShowDefined 
ShowAll 

Definition at line 69 of file layer.h.

Constructor & Destructor Documentation

pal::Layer::~Layer ( )
virtual

Definition at line 72 of file layer.cpp.

pal::Layer::Layer ( const QString lyrName,
Arrangement  arrangement,
double  defaultPriority,
bool  obstacle,
bool  active,
bool  toLabel,
Pal pal,
bool  displayAll = false 
)
protected

Create a new layer.

Parameters
lyrNamelayer's name
arrangementArrangement mode : how to place candidates
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 46 of file layer.cpp.

Member Function Documentation

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

Returns whether the layer is currently active.

See Also
setActive

Definition at line 125 of file layer.h.

void pal::Layer::addFeaturePart ( FeaturePart fpart,
const QString labelText = QString() 
)
protected

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

Definition at line 264 of file layer.cpp.

Arrangement pal::Layer::arrangement ( ) const
inline

Returns the layer's arrangement policy.

See Also
setArrangement

Definition at line 91 of file layer.h.

LineArrangementFlags pal::Layer::arrangementFlags ( ) const
inline

Returns the layer's arrangement flags.

See Also
setArrangementFlags

Definition at line 102 of file layer.h.

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

Returns whether labels placed at the centroid of features within the layer are forced to be placed inside the feature's geometry.

See Also
setCentroidInside

Definition at line 224 of file layer.h.

void pal::Layer::chopFeaturesAtRepeatDistance ( )

Chop layer features at the repeat distance.

Definition at line 367 of file layer.cpp.

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

Definition at line 78 of file layer.h.

int pal::Layer::featureCount ( )
inline

Returns the number of features in layer.

Definition at line 82 of file layer.h.

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

Returns whether labels which do not fit completely within a polygon feature are discarded.

See Also
setFitInPolygonOnly

Definition at line 239 of file layer.h.

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

Return pointer to feature or NULL if doesn't exist.

Definition at line 92 of file layer.cpp.

void pal::Layer::joinConnectedFeatures ( )

Join connected features with the same label text.

Definition at line 312 of file layer.cpp.

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

Returns whether the layer will be labeled or not.

See Also
setLabelLayer

Definition at line 138 of file layer.h.

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

Returns the layer's labeling mode.

See Also
setLabelMode

Definition at line 188 of file layer.h.

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

Returns whether connected lines will be merged before labeling.

See Also
setMergeConnectedLines

Definition at line 199 of file layer.h.

QString pal::Layer::name ( ) const
inline

Returns the layer's name.

Definition at line 86 of file layer.h.

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

Returns whether features within the layer act as obstacles for labels.

See Also
setObstacle

Definition at line 151 of file layer.h.

ObstacleType pal::Layer::obstacleType ( ) const
inline

Returns the obstacle type, which controls how features within the layer act as obstacles for labels.

See Also
setObstacleType

Definition at line 157 of file layer.h.

double pal::Layer::priority ( ) const
inline

Returns the layer's priority, between 0 and 1.

0 corresponds to highest priority, 1 to lowest priority.

See Also
setPriority

Definition at line 177 of file layer.h.

bool pal::Layer::registerFeature ( const QString geom_id,
PalGeometry userGeom,
double  label_x = -1,
double  label_y = -1,
const QString labelText = QString(),
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 111 of file layer.cpp.

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

Sets whether the layer is currently active.

Active means "is currently displayed or used as obstacles". When a layer is deactivated then feature of this layer will not be used for either labelling or as obstacles.

Parameters
activeset to true to make the layer active, or false to deactivate the layer
See Also
active

Definition at line 120 of file layer.h.

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

Sets the layer's arrangement policy.

Parameters
arrangementarrangement policy
See Also
arrangement

Definition at line 97 of file layer.h.

void pal::Layer::setArrangementFlags ( LineArrangementFlags  flags)
inline

Sets the layer's arrangement flags.

Parameters
flagsarrangement flags
See Also
arrangementFlags

Definition at line 108 of file layer.h.

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

Sets whether labels placed at the centroid of features within the layer are forced to be placed inside the feature's geometry.

Parameters
forceInsideset to true to force centroid labels to be within the feature. If set to false then the centroid may fall outside the feature.
See Also
centroidInside

Definition at line 218 of file layer.h.

void pal::Layer::setFitInPolygonOnly ( bool  fitInPolygon)
inline

Sets whether labels which do not fit completely within a polygon feature are discarded.

Parameters
fitInPolygonset to true to discard labels which do not fit within polygon features. Set to false to allow labels which partially fall outside the polygon.
See Also
fitInPolygonOnly

Definition at line 233 of file layer.h.

void pal::Layer::setLabelLayer ( bool  toLabel)
inline

Sets whether the layer will be labeled.

Note
Layers are labelled if and only if labelLayer and active are true
Parameters
toLabelset to false disable labeling this layer
See Also
labelLayer
setActive

Definition at line 133 of file layer.h.

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

Sets the layer's labeling mode.

Parameters
modelabel mode
See Also
labelMode

Definition at line 183 of file layer.h.

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

Sets whether connected lines should be merged before labeling.

Parameters
mergeset to true to merge connected lines
See Also
mergeConnectedLines

Definition at line 194 of file layer.h.

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

Sets whether features within the layer will act as obstacles for labels.

Note
this property is only effective if the layer is active
Parameters
obstacleset to true if features will act as obstacles
See Also
setActive
obstacle

Definition at line 146 of file layer.h.

void pal::Layer::setObstacleType ( ObstacleType  obstacleType)
inline

Sets the obstacle type, which controls how features within the layer act as obstacles for labels.

Parameters
obstacleTypenew obstacle type
See Also
obstacleType

Definition at line 164 of file layer.h.

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

Sets the layer's priority.

Parameters
prioritylayer priority, between 0 and 1. 0 corresponds to highest priority, 1 to lowest priority.
See Also
priority

Definition at line 101 of file layer.cpp.

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

Sets how upside down labels will be handled within the layer.

Parameters
udupside down label handling mode
See Also
upsideDownLabels

Definition at line 205 of file layer.h.

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

Returns how upside down labels are handled within the layer.

See Also
setUpsidedownLabels

Definition at line 210 of file layer.h.

Friends And Related Function Documentation

bool extractFeatCallback ( FeaturePart ft_ptr,
void *  ctx 
)
friend

Definition at line 178 of file pal.cpp.

friend class FeaturePart
friend

Definition at line 60 of file layer.h.

friend class LabelPosition
friend

Definition at line 64 of file layer.h.

friend class Pal
friend

Definition at line 59 of file layer.h.

friend class Problem
friend

Definition at line 62 of file layer.h.

Member Data Documentation

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

List of features - for deletion.

Definition at line 285 of file layer.h.

bool pal::Layer::mActive
protected

Definition at line 293 of file layer.h.

Arrangement pal::Layer::mArrangement
protected

Optional flags used for some placement methods.

Definition at line 300 of file layer.h.

LineArrangementFlags pal::Layer::mArrangementFlags
protected

Definition at line 301 of file layer.h.

bool pal::Layer::mCentroidInside
protected

Definition at line 296 of file layer.h.

QHash< QString, QLinkedList<FeaturePart*>* > pal::Layer::mConnectedHashtable
protected

Definition at line 311 of file layer.h.

QStringList pal::Layer::mConnectedTexts
protected

Definition at line 312 of file layer.h.

double pal::Layer::mDefaultPriority
protected

Definition at line 289 of file layer.h.

bool pal::Layer::mDisplayAll
protected

Definition at line 295 of file layer.h.

QLinkedList<FeaturePart*> pal::Layer::mFeatureParts
protected

List of feature parts.

Definition at line 282 of file layer.h.

bool pal::Layer::mFitInPolygon
protected

Definition at line 297 of file layer.h.

QHash< QString, Feature*> pal::Layer::mHashtable
protected

Definition at line 309 of file layer.h.

bool pal::Layer::mLabelLayer
protected

Definition at line 294 of file layer.h.

bool pal::Layer::mMergeLines
protected

Definition at line 303 of file layer.h.

LabelMode pal::Layer::mMode
protected

Definition at line 302 of file layer.h.

QMutex pal::Layer::mMutex
protected

Definition at line 314 of file layer.h.

QString pal::Layer::mName
protected

Definition at line 279 of file layer.h.

bool pal::Layer::mObstacle
protected

Definition at line 291 of file layer.h.

ObstacleType pal::Layer::mObstacleType
protected

Definition at line 292 of file layer.h.

UpsideDownLabels pal::Layer::mUpsidedownLabels
protected

Definition at line 305 of file layer.h.

Pal* pal::Layer::pal
protected

Definition at line 287 of file layer.h.

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

Definition at line 308 of file layer.h.


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