16 #ifndef QGSLABELINGENGINEV2_H
17 #define QGSLABELINGENGINEV2_H
63 GEOSGeometry*
geometry()
const {
return mGeometry; }
263 DrawAllLabels = 1 << 2,
264 MergeConnectedLines = 1 << 3,
265 CentroidMustBeInside = 1 << 4,
266 FitInPolygonOnly = 1 << 5,
267 LabelPerFeaturePart = 1 << 6,
269 Q_DECLARE_FLAGS( Flags, Flag )
284 Flags
flags()
const {
return mFlags; }
321 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsAbstractLabelProvider::Flags )
360 QgsLabelingEngineV2();
362 ~QgsLabelingEngineV2();
366 UseAllLabels = 1 << 1,
367 UsePartialCandidates = 1 << 2,
368 RenderOutlineLabels = 1 << 3,
369 DrawLabelRectOnly = 1 << 4,
370 DrawCandidates = 1 << 5,
371 DrawShadowRects = 1 << 6,
373 Q_DECLARE_FLAGS( Flags, Flag )
376 void setMapSettings( const
QgsMapSettings& mapSettings ) { mMapSettings = mapSettings; }
396 void setFlags(
const Flags& flags ) { mFlags = flags; }
398 Flags
flags()
const {
return mFlags; }
402 void setFlag(
Flag f,
bool enabled =
true ) {
if ( enabled ) mFlags |= f;
else mFlags &= ~f; }
405 void numCandidatePositions(
int& candPoint,
int& candLine,
int& candPolygon ) { candPoint = mCandPoint; candLine = mCandLine; candPolygon = mCandPolygon; }
407 void setNumCandidatePositions(
int candPoint,
int candLine,
int candPolygon ) { mCandPoint = candPoint; mCandLine = candLine; mCandPolygon = candPolygon; }
415 void readSettingsFromProject();
417 void writeSettingsToProject();
439 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsLabelingEngineV2::Flags )
441 #endif // QGSLABELINGENGINEV2_H
pal::Layer * layer() const
Get PAL layer of the label feature. Should be only used internally in PAL.
QString name() const
Name of the layer (for statistics, debugging etc.) - does not need to be unique.
void setQuadOffset(const QPointF &quadOffset)
Set which side of the point to use.
QgsPalLayerSettings::Placement mPlacement
Placement strategy.
unsigned int linePlacementFlags() const
For layers with linestring geometries - extra placement flags (or-ed combination of QgsPalLayerSettin...
double repeatDistance() const
Applies only to linestring features - after what distance (in map units) the labels should be repeate...
bool alwaysShow() const
Whether label should be always shown (sets very high label priority)
double mPriority
Default priority of labels.
A layer of spacial entites.
QString mLabelText
text of the label
void setFlags(const Flags &flags)
Set flags of the labeling engine.
pal::LabelInfo * mInfo
extra information for curved labels (may be null)
bool mIsObstacle
whether the feature geometry acts as an obstacle for labels
The QgsLabelingEngineV2 class provides map labeling functionality.
void setObstacleFactor(double factor)
Sets the obstacle factor for the feature.
QPointF quadOffset() const
Applies to "offset from point" placement strategy and "around point" (in case hasFixedQuadrant() retu...
A geometry is the spatial representation of a feature.
void setCurvedLabelInfo(pal::LabelInfo *info)
takes ownership of the instance
bool mHasFixedQuadrant
whether mQuadOffset should be respected (only for "around point" placement)
double priority() const
Returns the feature's labeling priority.
double mRepeatDistance
distance after which label should be repeated (only for linestrings)
double mObstacleFactor
how strong is the geometry acting as obstacle
QgsFeatureId mId
Associated ID unique within the parent label provider.
void setFixedPosition(const QgsPoint &point)
Set coordinates of the fixed position (relevant only if hasFixedPosition() returns true) ...
QgsPalLayerSettings::UpsideDownLabels upsidedownLabels() const
How to handle labels that would be upside down.
void setNumCandidatePositions(int candPoint, int candLine, int candPolygon)
Set number of candidate positions that will be generated for each label feature.
QgsPoint mFixedPosition
fixed position for the label (instead of automatic placement)
void setAlwaysShow(bool enabled)
Set whether label should be always shown (sets very high label priority)
void setLabelText(const QString &text)
Set text of the label.
bool mHasFixedPosition
whether mFixedPosition should be respected
bool isObstacle() const
Returns whether the feature will act as an obstacle for labels.
void setHasFixedPosition(bool enabled)
Set whether the label should use a fixed position instead of being automatically placed.
The QgsMapSettings class contains configuration for rendering of the map.
GEOSGeometry * geometry() const
Get access to the associated geometry.
QgsLabelingResults * results() const
For internal use by the providers.
pal::LabelInfo * curvedLabelInfo() const
Get additional infor required for curved label placement. Returns null if not set.
QSizeF size() const
Size of the label (in map units)
QSizeF mSize
Width and height of the label.
bool hasFixedPosition() const
Whether the label should use a fixed position instead of being automatically placed.
void setSearchMethod(QgsPalLabeling::Search s)
Set which search method to use for removal collisions between labels.
double mFixedAngle
fixed rotation for the label (instead of automatic choice)
void setIsObstacle(bool enabled)
Sets whether the feature will act as an obstacle for labels.
QgsPalLayerSettings::Placement placement() const
What placement strategy to use for the labels.
QgsMapSettings mMapSettings
Associated map settings instance.
QList< QgsAbstractLabelProvider * > mProviders
List of providers (the are owned by the labeling engine)
unsigned int mLinePlacementFlags
Extra placement flags for linestring geometries.
const QgsMapSettings & mapSettings() const
Get associated map settings.
void setLayer(pal::Layer *layer)
Assign PAL layer to the label feature. Should be only used internally in PAL.
QgsPoint fixedPosition() const
Coordinates of the fixed position (relevant only if hasFixedPosition() returns true) ...
bool hasFixedQuadrant() const
Returns whether the quadrant for the label is fixed.
Flags flags() const
Get flags of the labeling engine.
Optional additional info about label (for curved labels)
void setFixedAngle(double angle)
Set angle in degrees of the fixed angle (relevant only if hasFixedAngle() returns true) ...
Flags mFlags
Flags altering drawing and registration of features.
GEOSGeometry * mGeometry
Geometry of the feature to be labelled.
QgsPalLabeling::Search mSearchMethod
search method to use for removal collisions between labels
double priority() const
Default priority of labels (may be overridden by individual labels)
const QgsLabelingEngineV2 * mEngine
Associated labeling engine.
QgsLabelingResults * mResults
Resulting labeling layout.
Flags flags() const
Flags associated with the provider.
void setEngine(const QgsLabelingEngineV2 *engine)
Associate provider with a labeling engine (should be only called internally from QgsLabelingEngineV2)...
void setDistLabel(double dist)
Applies to "around point" placement strategy or linestring features.
bool mAlwaysShow
whether to always show label - even in case of collisions
A class to represent a point.
The QgsAbstractLabelProvider class is an interface class.
double ANALYSIS_EXPORT angle(Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
bool testFlag(Flag f) const
Test whether a particular flag is enabled.
bool mHasFixedAngle
whether mFixedAngle should be respected
QgsPoint positionOffset() const
Applies only to "offset from point" placement strategy.
Contains information about the context of a rendering operation.
double obstacleFactor() const
Returns the obstacle factor for the feature.
The QgsLabelFeature class describes a feature that should be used within the labeling engine...
double mPriority
Priority of the label.
QString mName
Name of the layer.
QgsPalLayerSettings::ObstacleType obstacleType() const
How the feature geometries will work as obstacles.
void setHasFixedAngle(bool enabled)
Set whether the label should use a fixed angle instead of using angle from automatic placement...
void setRepeatDistance(double dist)
Applies only to linestring features - set after what distance (in map units) the labels should be rep...
virtual ~QgsAbstractLabelProvider()
Vritual destructor.
QgsPoint mPositionOffset
offset of label from the feature (only for "offset from point" placement)
double distLabel() const
Applies to "around point" placement strategy or linestring features.
QgsPalLabeling::Search searchMethod() const
Which search method to use for removal collisions between labels.
void setHasFixedQuadrant(bool enabled)
Sets whether the quadrant for the label must be respected.
QgsPalLayerSettings::ObstacleType mObstacleType
Type of the obstacle of feature geometries.
QgsPalLayerSettings::UpsideDownLabels mUpsidedownLabels
How to handle labels that would be upside down.
pal::Layer * mLayer
Pointer to PAL layer (assigned when registered to PAL)
void setPositionOffset(const QgsPoint &offset)
Applies only to "offset from point" placement strategy.
Class that stores computed placement from labeling engine.
bool hasFixedAngle() const
Whether the label should use a fixed angle instead of using angle from automatic placement.
double mDistLabel
distance of label from the feature (only for "around point" placement or linestrings) ...
void setFlag(Flag f, bool enabled=true)
Set whether a particual flag is enabled.
QString labelText() const
Text of the label.
QList< QgsAbstractLabelProvider * > mSubProviders
double fixedAngle() const
Angle in degrees of the fixed angle (relevant only if hasFixedAngle() returns true) ...
void numCandidatePositions(int &candPoint, int &candLine, int &candPolygon)
Get number of candidate positions that will be generated for each label feature (default to 8) ...
void setPriority(double priority)
Sets the priority for labeling the feature.
QgsFeatureId id() const
Identifier of the label (unique within the parent label provider)
ObstacleType
Valid obstacle types, which affect how features within the layer will act as obstacles for labels...
QPointF mQuadOffset
whether the side of the label is fixed (only for "around point" placement)