QGIS API Documentation  2.14.5-Essen
qgslabelfeature.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgslabelfeature.cpp
3  ---------------------
4  begin : December 2015
5  copyright : (C) 2015 by Martin Dobias
6  email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #include "qgslabelfeature.h"
16 #include "feature.h"
17 
18 
19 QgsLabelFeature::QgsLabelFeature( QgsFeatureId id, GEOSGeometry* geometry, QSizeF size )
20  : mLayer( nullptr )
21  , mId( id )
22  , mGeometry( geometry )
23  , mObstacleGeometry( nullptr )
24  , mSize( size )
25  , mPriority( -1 )
26  , mZIndex( 0 )
27  , mHasFixedPosition( false )
28  , mHasFixedAngle( false )
29  , mFixedAngle( 0 )
30  , mHasFixedQuadrant( false )
31  , mDistLabel( 0 )
32  , mOffsetType( QgsPalLayerSettings::FromPoint )
33  , mRepeatDistance( 0 )
34  , mAlwaysShow( false )
35  , mIsObstacle( false )
36  , mObstacleFactor( 1 )
37  , mInfo( nullptr )
38 {
39 }
40 
42 {
43  if ( mGeometry )
44  GEOSGeom_destroy_r( QgsGeometry::getGEOSHandler(), mGeometry );
45 
46  if ( mObstacleGeometry )
47  GEOSGeom_destroy_r( QgsGeometry::getGEOSHandler(), mObstacleGeometry );
48 
49  delete mInfo;
50 }
51 
52 void QgsLabelFeature::setObstacleGeometry( GEOSGeometry* obstacleGeom )
53 {
54  if ( mObstacleGeometry )
55  GEOSGeom_destroy_r( QgsGeometry::getGEOSHandler(), mObstacleGeometry );
56 
57  mObstacleGeometry = obstacleGeom;
58 }
virtual ~QgsLabelFeature()
Clean up geometry and curved label info (if present)
pal::LabelInfo * mInfo
extra information for curved labels (may be null)
QgsLabelFeature(QgsFeatureId id, GEOSGeometry *geometry, QSizeF size)
Create label feature, takes ownership of the geometry instance.
GEOSGeometry * mObstacleGeometry
Optional geometry to use for label obstacles, if different to mGeometry.
GEOSGeometry * mGeometry
Geometry of the feature to be labelled.
static GEOSContextHandle_t getGEOSHandler()
Return GEOS context handle.
void setObstacleGeometry(GEOSGeometry *obstacleGeom)
Sets the label's obstacle geometry, if different to the feature geometry.
qint64 QgsFeatureId
Definition: qgsfeature.h:31