Skip to content

Commit b5e4922

Browse files
committedSep 21, 2015
Use QgsLabelFeature internally by PAL
This code has been funded by Tuscany Region (Italy) - SITA (CIG: 63526840AE) and commissioned to Gis3W s.a.s.
1 parent 26c1e0f commit b5e4922

File tree

9 files changed

+201
-375
lines changed

9 files changed

+201
-375
lines changed
 

‎src/core/pal/costcalculator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ namespace pal
8686
lp->setConflictsWithObstacle( true );
8787

8888
//scale cost by obstacle's factor
89-
double obstacleCost = obstacle->getFeature()->obstacleFactor() * double( n );
89+
double obstacleCost = obstacle->obstacleFactor() * double( n );
9090

9191
// label cost is penalized
9292
lp->setCost( lp->cost() + obstacleCost );

‎src/core/pal/feature.cpp

Lines changed: 106 additions & 136 deletions
Large diffs are not rendered by default.

‎src/core/pal/feature.h

Lines changed: 23 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#include <cmath>
4040
#include <QString>
4141

42-
class QgsLabelFeature;
42+
#include "qgslabelingenginev2.h"
4343

4444
namespace pal
4545
{
@@ -73,130 +73,6 @@ namespace pal
7373
class LabelPosition;
7474
class FeaturePart;
7575

76-
class CORE_EXPORT Feature
77-
{
78-
friend class FeaturePart;
79-
80-
public:
81-
Feature( Layer* l, QgsFeatureId fid, QgsLabelFeature* userFeat, double lx, double ly );
82-
~Feature();
83-
84-
void setLabelInfo( LabelInfo* info ) { labelInfo = info; }
85-
void setDistLabel( double dist ) { distlabel = dist; }
86-
/** Set label position of the feature to fixed x/y values */
87-
void setFixedPosition( double x, double y ) { fixedPos = true; fixedPosX = x; fixedPosY = y;}
88-
void setQuadOffset( double x, double y ) { quadOffset = true; quadOffsetX = x; quadOffsetY = y;}
89-
90-
/** Sets whether the quadrant for the label must be respected. This can be used
91-
* to fix the quadrant for specific features when using an "around point" placement.
92-
* @see fixedQuadrant
93-
*/
94-
void setFixedQuadrant( bool fixed ) { mFixedQuadrant = fixed; }
95-
96-
/** Returns whether the quadrant for the label is fixed.
97-
* @see setFixedQuadrant
98-
*/
99-
bool fixedQuadrant() const { return mFixedQuadrant; }
100-
101-
void setPosOffset( double x, double y ) { offsetPos = true; offsetPosX = x; offsetPosY = y;}
102-
bool fixedPosition() const { return fixedPos; }
103-
104-
/** Set label rotation to fixed value
105-
*/
106-
void setFixedAngle( double a ) { fixedRotation = true; fixedAngle = a; }
107-
void setRepeatDistance( double dist ) { repeatDist = dist; }
108-
double repeatDistance() const { return repeatDist; }
109-
void setAlwaysShow( bool bl ) { alwaysShow = bl; }
110-
111-
/** Sets whether the feature will act as an obstacle for labels.
112-
* @param obstacle whether feature will act as an obstacle
113-
* @see isObstacle
114-
*/
115-
void setIsObstacle( bool obstacle ) { mIsObstacle = obstacle; }
116-
117-
/** Returns whether the feature will act as an obstacle for labels.
118-
* @returns true if feature is an obstacle
119-
* @see setIsObstacle
120-
*/
121-
double isObstacle() const { return mIsObstacle; }
122-
123-
/** Sets the obstacle factor for the feature. The factor controls the penalty
124-
* for labels overlapping this feature.
125-
* @param factor larger factors ( > 1.0 ) will result in labels
126-
* which are less likely to cover this feature, smaller factors ( < 1.0 ) mean labels
127-
* are more likely to cover this feature (where required)
128-
* @see obstacleFactor
129-
*/
130-
void setObstacleFactor( double factor ) { mObstacleFactor = factor; }
131-
132-
/** Returns the obstacle factor for the feature. The factor controls the penalty
133-
* for labels overlapping this feature.
134-
* @see setObstacleFactor
135-
*/
136-
double obstacleFactor() const { return mObstacleFactor; }
137-
138-
/** Sets the priority for labeling the feature.
139-
* @param priority feature's priority, as a value between 0 (highest priority)
140-
* and 1 (lowest priority). Set to -1.0 to use the layer's default priority
141-
* for this feature.
142-
* @see priority
143-
* @see calculatePriority
144-
*/
145-
void setPriority( double priority ) { mPriority = priority; }
146-
147-
/** Returns the feature's labeling priority.
148-
* @returns feature's priority, as a value between 0 (highest priority)
149-
* and 1 (lowest priority). Returns -1.0 if feature will use the layer's default priority.
150-
* @see setPriority
151-
* @see calculatePriority
152-
*/
153-
double priority() const { return mPriority; }
154-
155-
/** Calculates the priority for the feature. This will be the feature's priority if set,
156-
* otherwise the layer's default priority.
157-
* @see setPriority
158-
* @see priority
159-
*/
160-
double calculatePriority() const;
161-
162-
protected:
163-
Layer *layer;
164-
QgsLabelFeature* userFeature;
165-
double label_x;
166-
double label_y;
167-
double distlabel;
168-
LabelInfo* labelInfo; // optional
169-
170-
QgsFeatureId uid;
171-
172-
bool fixedPos; //true in case of fixed position (only 1 candidate position with cost 0)
173-
double fixedPosX;
174-
double fixedPosY;
175-
bool quadOffset; // true if a quadrant offset exists
176-
double quadOffsetX;
177-
double quadOffsetY;
178-
bool offsetPos; //true if position is to be offset by set amount
179-
double offsetPosX;
180-
double offsetPosY;
181-
//Fixed (e.g. data defined) angle only makes sense together with fixed position
182-
bool fixedRotation;
183-
double fixedAngle; //fixed angle value (in rad)
184-
double repeatDist;
185-
186-
bool alwaysShow; //true is label is to always be shown (but causes overlapping)
187-
188-
private:
189-
190-
bool mFixedQuadrant;
191-
bool mIsObstacle;
192-
double mObstacleFactor;
193-
194-
//-1 if layer priority should be used
195-
double mPriority;
196-
197-
198-
};
199-
20076
/**
20177
* \brief Main class to handle feature
20278
*/
@@ -209,7 +85,7 @@ namespace pal
20985
* @param feat a pointer for a feature which contains the spatial entites
21086
* @param geom a pointer to a GEOS geometry
21187
*/
212-
FeaturePart( Feature *feat, const GEOSGeometry* geom );
88+
FeaturePart( QgsLabelFeature* lf, const GEOSGeometry* geom );
21389

21490
/** Delete the feature
21591
*/
@@ -261,7 +137,7 @@ namespace pal
261137

262138
/** Returns the parent feature.
263139
*/
264-
Feature* getFeature() { return mFeature; }
140+
QgsLabelFeature* feature() { return mLF; }
265141

266142
/** Returns the layer that feature belongs to.
267143
*/
@@ -291,19 +167,19 @@ namespace pal
291167
void print();
292168
#endif
293169

294-
QgsLabelFeature* userFeature() { return mFeature->userFeature; }
170+
QgsLabelFeature* userFeature() { return mLF; }
295171

296-
void setLabelSize( double lx, double ly ) { mFeature->label_x = lx; mFeature->label_y = ly; }
297-
double getLabelWidth() const { return mFeature->label_x; }
298-
double getLabelHeight() const { return mFeature->label_y; }
299-
void setLabelDistance( double dist ) { mFeature->distlabel = dist; }
300-
double getLabelDistance() const { return mFeature->distlabel; }
301-
void setLabelInfo( LabelInfo* info ) { mFeature->labelInfo = info; }
172+
double getLabelWidth() const { return mLF->size().width(); }
173+
double getLabelHeight() const { return mLF->size().height(); }
174+
double getLabelDistance() const { return mLF->distLabel(); }
302175

303-
bool getFixedRotation() { return mFeature->fixedRotation; }
304-
double getLabelAngle() { return mFeature->fixedAngle; }
305-
bool getFixedPosition() { return mFeature->fixedPos; }
306-
bool getAlwaysShow() { return mFeature->alwaysShow; }
176+
bool getFixedRotation() { return mLF->hasFixedAngle(); }
177+
double getLabelAngle() { return mLF->fixedAngle(); }
178+
bool getFixedPosition() { return mLF->hasFixedPosition(); }
179+
bool getAlwaysShow() { return mLF->alwaysShow(); }
180+
bool isObstacle() { return mLF->isObstacle(); }
181+
double obstacleFactor() { return mLF->obstacleFactor(); }
182+
double repeatDistance() { return mLF->repeatDistance(); }
307183

308184
int getNumSelfObstacles() const { return mHoles.count(); }
309185
FeaturePart* getSelfObstacle( int i ) { return mHoles.at( i ); }
@@ -317,9 +193,17 @@ namespace pal
317193

318194
void addSizePenalty( int nbp, QList<LabelPosition *> &lPos, double bbx[4], double bby[4] );
319195

196+
/** Calculates the priority for the feature. This will be the feature's priority if set,
197+
* otherwise the layer's default priority.
198+
* @see Feature::setPriority
199+
* @see Feature::priority
200+
*/
201+
double calculatePriority() const;
202+
203+
320204
protected:
321205

322-
Feature* mFeature;
206+
QgsLabelFeature* mLF;
323207
QList<FeaturePart*> mHoles;
324208

325209
/** \brief read coordinates from a GEOS geom */

‎src/core/pal/layer.cpp

Lines changed: 15 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ namespace pal
7777
qDeleteAll( mFeatureParts );
7878
mFeatureParts.clear();
7979

80-
// features in the hashtable
81-
qDeleteAll( features );
82-
features.clear();
83-
8480
//should already be empty
8581
qDeleteAll( mConnectedHashtable );
8682
mConnectedHashtable.clear();
@@ -90,15 +86,6 @@ namespace pal
9086
mMutex.unlock();
9187
}
9288

93-
Feature* Layer::getFeature( QgsFeatureId fid )
94-
{
95-
QHash< QgsFeatureId, Feature*>::const_iterator i = mHashtable.find( fid );
96-
if ( i != mHashtable.constEnd() )
97-
return *i;
98-
else
99-
return 0;
100-
}
101-
10289
void Layer::setPriority( double priority )
10390
{
10491
if ( priority >= 1.0 ) // low priority
@@ -109,61 +96,35 @@ namespace pal
10996
mDefaultPriority = priority;
11097
}
11198

112-
bool Layer::registerFeature( QgsLabelFeature* label, QgsFeatureId fid, const GEOSGeometry* userGeom, double label_x, double label_y, const QString &labelText,
113-
double labelPosX, double labelPosY, bool fixedPos, double angle, bool fixedAngle,
114-
int xQuadOffset, int yQuadOffset, double xOffset, double yOffset, bool alwaysShow, double repeatDistance )
99+
bool Layer::registerFeature( QgsLabelFeature* lf )
115100
{
116-
if ( label_x < 0 || label_y < 0 )
101+
if ( lf->size().width() < 0 || lf->size().height() < 0 )
117102
return false;
118103

119104
mMutex.lock();
120105

121-
if ( mHashtable.contains( fid ) )
106+
if ( mHashtable.contains( lf->id() ) )
122107
{
123108
mMutex.unlock();
124109
//A feature with this id already exists. Don't throw an exception as sometimes,
125110
//the same feature is added twice (dateline split with otf-reprojection)
126111
return false;
127112
}
128113

129-
// Split MULTI GEOM and Collection in simple geometries
114+
// assign label feature to this PAL layer
115+
lf->setLayer( this );
130116

131-
Feature* f = new Feature( this, fid, label, label_x, label_y );
132-
if ( fixedPos )
133-
{
134-
f->setFixedPosition( labelPosX, labelPosY );
135-
}
136-
if ( xQuadOffset != 0 || yQuadOffset != 0 )
137-
{
138-
f->setQuadOffset( xQuadOffset, yQuadOffset );
139-
}
140-
if ( xOffset != 0.0 || yOffset != 0.0 )
141-
{
142-
f->setPosOffset( xOffset, yOffset );
143-
}
144-
if ( fixedAngle )
145-
{
146-
f->setFixedAngle( angle );
147-
}
148-
// use layer-level defined rotation, but not if position fixed
149-
if ( !fixedPos && angle != 0.0 )
150-
{
151-
f->setFixedAngle( angle );
152-
}
153-
f->setRepeatDistance( repeatDistance );
154-
155-
f->setAlwaysShow( alwaysShow );
117+
// Split MULTI GEOM and Collection in simple geometries
156118

157119
bool addedFeature = false;
158120

159121
double geom_size = -1, biggest_size = -1;
160122
FeaturePart* biggest_part = NULL;
161123

162124
// break the (possibly multi-part) geometry into simple geometries
163-
QLinkedList<const GEOSGeometry*>* simpleGeometries = unmulti( userGeom );
125+
QLinkedList<const GEOSGeometry*>* simpleGeometries = unmulti( lf->geometry() );
164126
if ( simpleGeometries == NULL ) // unmulti() failed?
165127
{
166-
delete f;
167128
mMutex.unlock();
168129
throw InternalException::UnknownGeometry();
169130
}
@@ -189,7 +150,7 @@ namespace pal
189150
throw InternalException::UnknownGeometry();
190151
}
191152

192-
FeaturePart* fpart = new FeaturePart( f, geom );
153+
FeaturePart* fpart = new FeaturePart( lf, geom );
193154

194155
// ignore invalid geometries
195156
if (( type == GEOS_LINESTRING && fpart->nbPoints < 2 ) ||
@@ -228,53 +189,29 @@ namespace pal
228189
}
229190

230191
// feature part is ready!
231-
addFeaturePart( fpart, labelText );
192+
addFeaturePart( fpart, lf->labelText() );
232193
addedFeature = true;
233194
}
234195
delete simpleGeometries;
235196

236197
mMutex.unlock();
237198

238199
// if using only biggest parts...
239-
if (( mMode == LabelPerFeature || f->fixedPosition() ) && biggest_part != NULL )
200+
if (( mMode == LabelPerFeature || lf->hasFixedPosition() ) && biggest_part != NULL )
240201
{
241-
addFeaturePart( biggest_part, labelText );
202+
addFeaturePart( biggest_part, lf->labelText() );
242203
addedFeature = true;
243204
}
244205

245206
// add feature to layer if we have added something
246207
if ( addedFeature )
247208
{
248-
features << f;
249-
mHashtable.insert( fid, f );
250-
}
251-
else
252-
{
253-
delete f;
209+
mHashtable.insert( lf->id(), lf );
254210
}
255211

256212
return addedFeature; // true if we've added something
257213
}
258214

259-
bool Layer::registerFeature( QgsLabelFeature* label )
260-
{
261-
if ( !registerFeature( label, label->id(), label->geometry(), label->size().width(), label->size().height(), label->labelText(),
262-
label->fixedPosition().x(), label->fixedPosition().y(), label->hasFixedPosition(),
263-
label->fixedAngle(), label->hasFixedAngle(),
264-
label->quadOffset().x(), label->quadOffset().y(),
265-
label->positionOffset().x(), label->positionOffset().y(),
266-
label->alwaysShow(), label->repeatDistance() ) )
267-
return false;
268-
269-
pal::Feature* pf = getFeature( label->id() );
270-
pf->setLabelInfo( label->curvedLabelInfo() );
271-
pf->setPriority( label->priority() );
272-
pf->setDistLabel( label->distLabel() );
273-
pf->setFixedQuadrant( label->hasFixedQuadrant() );
274-
pf->setIsObstacle( label->isObstacle() );
275-
pf->setObstacleFactor( label->obstacleFactor() );
276-
return true;
277-
}
278215

279216
void Layer::addFeaturePart( FeaturePart* fpart, const QString& labelText )
280217
{
@@ -387,7 +324,7 @@ namespace pal
387324
{
388325
FeaturePart* fpart = mFeatureParts.takeFirst();
389326
const GEOSGeometry* geom = fpart->geos();
390-
double chopInterval = fpart->getFeature()->repeatDistance();
327+
double chopInterval = fpart->repeatDistance();
391328
if ( chopInterval != 0. && GEOSGeomTypeId_r( geosctxt, geom ) == GEOS_LINESTRING )
392329
{
393330

@@ -446,7 +383,7 @@ namespace pal
446383
}
447384

448385
GEOSGeometry* newgeom = GEOSGeom_createLineString_r( geosctxt, cooSeq );
449-
FeaturePart* newfpart = new FeaturePart( fpart->getFeature(), newgeom );
386+
FeaturePart* newfpart = new FeaturePart( fpart->feature(), newgeom );
450387
newFeatureParts.append( newfpart );
451388
newfpart->getBoundingBox( bmin, bmax );
452389
rtree->Insert( bmin, bmax, newfpart );
@@ -463,7 +400,7 @@ namespace pal
463400
}
464401

465402
GEOSGeometry* newgeom = GEOSGeom_createLineString_r( geosctxt, cooSeq );
466-
FeaturePart* newfpart = new FeaturePart( fpart->getFeature(), newgeom );
403+
FeaturePart* newfpart = new FeaturePart( fpart->feature(), newgeom );
467404
newFeatureParts.append( newfpart );
468405
newfpart->getBoundingBox( bmin, bmax );
469406
rtree->Insert( bmin, bmax, newfpart );

‎src/core/pal/layer.h

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ namespace pal
4343

4444
template<class DATATYPE, class ELEMTYPE, int NUMDIMS, class ELEMTYPEREAL, int TMAXNODES, int TMINNODES> class RTree;
4545

46-
class Feature;
4746
class FeaturePart;
4847
class Pal;
4948
class LabelInfo;
@@ -80,7 +79,7 @@ namespace pal
8079

8180
/** Returns the number of features in layer.
8281
*/
83-
int featureCount() { return features.size(); }
82+
int featureCount() { return mHashtable.size(); }
8483

8584
/** Returns the layer's name.
8685
*/
@@ -256,9 +255,6 @@ namespace pal
256255

257256
bool registerFeature( QgsLabelFeature* label );
258257

259-
/** Return pointer to feature or NULL if doesn't exist */
260-
Feature* getFeature( QgsFeatureId fid );
261-
262258
/** Join connected features with the same label text */
263259
void joinConnectedFeatures();
264260

@@ -271,9 +267,6 @@ namespace pal
271267
/** List of feature parts */
272268
QLinkedList<FeaturePart*> mFeatureParts;
273269

274-
/** List of features - for deletion */
275-
QList<Feature*> features;
276-
277270
Pal *pal;
278271

279272
double mDefaultPriority;
@@ -295,7 +288,8 @@ namespace pal
295288

296289
// indexes (spatial and id)
297290
RTree<FeaturePart*, double, 2, double, 8, 4> *rtree;
298-
QHash< QgsFeatureId, Feature*> mHashtable;
291+
//! Lookup table of label features (owned by the label feature provider that created them)
292+
QHash< QgsFeatureId, QgsLabelFeature*> mHashtable;
299293

300294
QHash< QString, QLinkedList<FeaturePart*>* > mConnectedHashtable;
301295
QStringList mConnectedTexts;

‎src/core/pal/pal.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ namespace pal
186186
#endif
187187

188188
// all feature which are obstacle will be inserted into obstacles
189-
if ( ft_ptr->getFeature()->isObstacle() )
189+
if ( ft_ptr->isObstacle() )
190190
{
191191
ft_ptr->getBoundingBox( amin, amax );
192192
context->obstacles->Insert( amin, amax, ft_ptr );
@@ -225,7 +225,7 @@ namespace pal
225225
ft->feature = ft_ptr;
226226
ft->shape = NULL;
227227
ft->lPos = lPos;
228-
ft->priority = ft_ptr->getFeature()->calculatePriority();
228+
ft->priority = ft_ptr->calculatePriority();
229229
context->fFeats->append( ft );
230230
}
231231
else

‎src/core/pal/pointset.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ namespace pal
4040
{
4141

4242
class Pal;
43-
class Feature;
4443
class Projection;
4544
class LabelPosition;
4645

‎src/core/qgslabelingenginev2.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,8 @@ QgsAbstractLabelProvider* QgsLabelingEngineV2::providerById( const QString& id )
344344

345345

346346
QgsLabelFeature::QgsLabelFeature( QgsFeatureId id, GEOSGeometry* geometry, const QSizeF& size )
347-
: mId( id )
347+
: mLayer( 0 )
348+
, mId( id )
348349
, mGeometry( geometry )
349350
, mSize( size )
350351
, mPriority( -1 )

‎src/core/qgslabelingenginev2.h

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,18 @@ class CORE_EXPORT QgsLabelFeature
6262
//! Size of the label (in map units)
6363
QSizeF size() const { return mSize; }
6464

65-
//! Priority of the label - between 0 (highest) to 1 (lowest). Value -1 means to use layer default priority
65+
/** Returns the feature's labeling priority.
66+
* @returns feature's priority, as a value between 0 (highest priority)
67+
* and 1 (lowest priority). Returns -1.0 if feature will use the layer's default priority.
68+
* @see setPriority
69+
*/
6670
double priority() const { return mPriority; }
71+
/** Sets the priority for labeling the feature.
72+
* @param priority feature's priority, as a value between 0 (highest priority)
73+
* and 1 (lowest priority). Set to -1.0 to use the layer's default priority
74+
* for this feature.
75+
* @see priority
76+
*/
6777
void setPriority( double priority ) { mPriority = priority; }
6878

6979
//! Whether the label should use a fixed position instead of being automatically placed
@@ -80,9 +90,17 @@ class CORE_EXPORT QgsLabelFeature
8090
double fixedAngle() const { return mFixedAngle; }
8191
void setFixedAngle( double angle ) { mFixedAngle = angle; }
8292

83-
//! Applies to "around point" placement strategy.
84-
//! Determines whether a fixed quadrant (quadOffset()) should be used instead of using automatically chosen one.
93+
/** Returns whether the quadrant for the label is fixed.
94+
* Applies to "around point" placement strategy.
95+
* @see setFixedQuadrant
96+
* @see quadOffset
97+
*/
8598
bool hasFixedQuadrant() const { return mHasFixedQuadrant; }
99+
/** Sets whether the quadrant for the label must be respected. This can be used
100+
* to fix the quadrant for specific features when using an "around point" placement.
101+
* @see fixedQuadrant
102+
* @see quadOffset
103+
*/
86104
void setHasFixedQuadrant( bool enabled ) { mHasFixedQuadrant = enabled; }
87105
//! Applies to "offset from point" placement strategy and "around point" (in case hasFixedQuadrant() returns true).
88106
//! Determines which side of the point to use.
@@ -107,16 +125,33 @@ class CORE_EXPORT QgsLabelFeature
107125
bool alwaysShow() const { return mAlwaysShow; }
108126
void setAlwaysShow( bool enabled ) { mAlwaysShow = enabled; }
109127

110-
//! Determine whether the feature geometry acts as an obstacle for other labels
128+
/** Returns whether the feature will act as an obstacle for labels.
129+
* @returns true if feature is an obstacle
130+
* @see setIsObstacle
131+
*/
111132
bool isObstacle() const { return mIsObstacle; }
133+
/** Sets whether the feature will act as an obstacle for labels.
134+
* @param obstacle whether feature will act as an obstacle
135+
* @see isObstacle
136+
*/
112137
void setIsObstacle( bool enabled ) { mIsObstacle = enabled; }
113-
//! Only applies if isObstacle() returns true: How strong is the obstacle.
114-
//! Larger factors ( > 1.0 ) will result in labels which are less likely to cover this feature,
115-
//! smaller factors ( < 1.0 ) mean labels are more likely to cover this feature (where required)
138+
/** Returns the obstacle factor for the feature. The factor controls the penalty
139+
* for labels overlapping this feature.
140+
* @see setObstacleFactor
141+
*/
116142
double obstacleFactor() const { return mObstacleFactor; }
143+
/** Sets the obstacle factor for the feature. The factor controls the penalty
144+
* for labels overlapping this feature.
145+
* @param factor larger factors ( > 1.0 ) will result in labels
146+
* which are less likely to cover this feature, smaller factors ( < 1.0 ) mean labels
147+
* are more likely to cover this feature (where required)
148+
* @see obstacleFactor
149+
*/
117150
void setObstacleFactor( double factor ) { mObstacleFactor = factor; }
118151

119-
//! Text of the label - used if "merge connected lines to avoid duplicate labels" is enabled
152+
//! Text of the label
153+
//!
154+
//! Used if "merge connected lines to avoid duplicate labels" is enabled
120155
//! to identify which features may be merged
121156
QString labelText() const { return mLabelText; }
122157
void setLabelText( const QString& text ) { mLabelText = text; }
@@ -126,7 +161,13 @@ class CORE_EXPORT QgsLabelFeature
126161
//! takes ownership of the instance
127162
void setCurvedLabelInfo( pal::LabelInfo* info ) { mInfo = info; }
128163

164+
//! Get PAL layer of the label feature. Should be only used internally in PAL
165+
pal::Layer* layer() const { return mLayer; }
166+
//! Assign PAL layer to the label feature. Should be only used internally in PAL
167+
void setLayer(pal::Layer* layer) { mLayer = layer; }
168+
129169
protected:
170+
pal::Layer* mLayer;
130171

131172
//! Associated ID unique within the parent label provider
132173
QgsFeatureId mId;

0 commit comments

Comments
 (0)
Please sign in to comment.