QGIS API Documentation  2.14.0-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 
17 #include "feature.h"
18 
19 
20 QgsLabelFeature::QgsLabelFeature( QgsFeatureId id, GEOSGeometry* geometry, QSizeF size )
21  : mLayer( nullptr )
22  , mId( id )
23  , mGeometry( geometry )
24  , mObstacleGeometry( nullptr )
25  , mSize( size )
26  , mPriority( -1 )
27  , mZIndex( 0 )
28  , mHasFixedPosition( false )
29  , mHasFixedAngle( false )
30  , mFixedAngle( 0 )
31  , mHasFixedQuadrant( false )
32  , mDistLabel( 0 )
33  , mOffsetType( QgsPalLayerSettings::FromPoint )
34  , mRepeatDistance( 0 )
35  , mAlwaysShow( false )
36  , mIsObstacle( false )
37  , mObstacleFactor( 1 )
38  , mInfo( nullptr )
39 {
40 }
41 
43 {
44  if ( mGeometry )
45  GEOSGeom_destroy_r( QgsGeometry::getGEOSHandler(), mGeometry );
46 
47  if ( mObstacleGeometry )
48  GEOSGeom_destroy_r( QgsGeometry::getGEOSHandler(), mObstacleGeometry );
49 
50  delete mInfo;
51 }
52 
53 void QgsLabelFeature::setObstacleGeometry( GEOSGeometry* obstacleGeom )
54 {
55  if ( mObstacleGeometry )
56  GEOSGeom_destroy_r( QgsGeometry::getGEOSHandler(), mObstacleGeometry );
57 
58  mObstacleGeometry = obstacleGeom;
59 }
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