QGIS API Documentation  3.6.0-Noosa (5873452)
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 #include "qgsgeometry.h"
18 #include "qgsgeos.h"
19 
21  : mId( id )
22  , mGeometry( std::move( geometry ) )
23  , mSize( size )
24  , mPriority( -1 )
25  , mZIndex( 0 )
26  , mHasFixedPosition( false )
27  , mHasFixedAngle( false )
28  , mFixedAngle( 0 )
29  , mHasFixedQuadrant( false )
30  , mDistLabel( 0 )
31  , mOffsetType( QgsPalLayerSettings::FromPoint )
32  , mRepeatDistance( 0 )
33  , mAlwaysShow( false )
34  , mIsObstacle( false )
35  , mObstacleFactor( 1 )
36 {
37 }
38 
40 {
41  if ( mPermissibleZoneGeosPrepared )
42  {
43  mPermissibleZoneGeosPrepared.reset();
44  mPermissibleZoneGeos.reset();
45  }
46 
47  delete mInfo;
48 }
49 
51 {
52  mObstacleGeometry = std::move( obstacleGeom );
53 }
54 
56 {
58 
59  if ( mPermissibleZoneGeosPrepared )
60  {
61  mPermissibleZoneGeosPrepared.reset();
62  mPermissibleZoneGeos.reset();
63  mPermissibleZoneGeosPrepared = nullptr;
64  }
65 
66  if ( mPermissibleZone.isNull() )
67  return;
68 
69  mPermissibleZoneGeos = QgsGeos::asGeos( mPermissibleZone );
70  if ( !mPermissibleZoneGeos )
71  return;
72 
73  mPermissibleZoneGeosPrepared.reset( GEOSPrepare_r( QgsGeos::getGEOSHandler(), mPermissibleZoneGeos.get() ) );
74 }
virtual ~QgsLabelFeature()
Clean up geometry and curved label info (if present)
qint64 QgsFeatureId
Definition: qgsfeatureid.h:25
pal::LabelInfo * mInfo
extra information for curved labels (may be null)
GEOSGeometry * geometry() const
Gets access to the associated geometry.
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:106
static GEOSContextHandle_t getGEOSHandler()
Definition: qgsgeos.cpp:2777
void setPermissibleZone(const QgsGeometry &geometry)
Sets the label's permissible zone geometry.
geos::unique_ptr mObstacleGeometry
Optional geometry to use for label obstacles, if different to mGeometry.
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
Definition: qgsgeos.h:79
QgsLabelFeature(QgsFeatureId id, geos::unique_ptr geometry, QSizeF size)
Create label feature, takes ownership of the geometry instance.
static geos::unique_ptr asGeos(const QgsGeometry &geometry, double precision=0)
Returns a geos geometry - caller takes ownership of the object (should be deleted with GEOSGeom_destr...
Definition: qgsgeos.cpp:166
void setObstacleGeometry(geos::unique_ptr obstacleGeom)
Sets the label&#39;s obstacle geometry, if different to the feature geometry.
QgsGeometry mPermissibleZone
Optional geometry to use for label&#39;s permissible zone.