54 if ( withFeatureLoop )
75 : mSettings( settings )
80 , mOwnsSource( ownsSource )
162 attributeNames.
append( name );
194 attributeNames.
append( name );
250 if ( !
prepare( ctx, attrNames ) )
308 case LabelPosition::QuadrantAboveLeft:
309 case LabelPosition::QuadrantLeft:
310 case LabelPosition::QuadrantBelowLeft:
313 case LabelPosition::QuadrantAbove:
314 case LabelPosition::QuadrantOver:
315 case LabelPosition::QuadrantBelow:
318 case LabelPosition::QuadrantAboveRight:
319 case LabelPosition::QuadrantRight:
320 case LabelPosition::QuadrantBelowRight:
412 QRectF rect( 0, 0, outPt2.
x() - outPt.
x(), outPt2.
y() - outPt.
y() );
445 double xc = outPt2.
x() - outPt.
x();
446 double yc = outPt2.
y() - outPt.
y();
449 double xd = xc * cos( angle ) - yc * sin( angle );
450 double yd = xc * sin( angle ) + yc * cos( angle );
452 centerPt.
setX( centerPt.
x() + xd );
453 centerPt.
setY( centerPt.
y() + yd );
474 bool prependSymb =
false;
520 int lines = multiLineList.
size();
522 double labelWidest = 0.0;
523 for (
int i = 0; i < lines; ++i )
525 double labelWidth = labelfm->
width( multiLineList.
at( i ) );
526 if ( labelWidth > labelWidest )
528 labelWidest = labelWidth;
536 double ascentOffset = 0.25 * labelfm->
ascent();
538 for (
int i = 0; i < lines; ++i )
541 #if 0 // TODO: generalize some of this
545 double cx = lp->
getX() + w / 2.0;
546 double cy = lp->
getY() + h / 2.0;
549 double sw = w * scale;
550 double sh = h * scale;
551 QRectF rect( -sw / 2, -sh / 2, sw, sh );
560 painter->
rotate( rotation );
575 double xMultiLineOffset = 0.0;
576 double labelWidth = labelfm->
width( multiLineList.
at( i ) );
579 double labelWidthDiff = labelWidest - labelWidth;
584 xMultiLineOffset = labelWidthDiff;
588 double yMultiLineOffset = ( lines - 1 - i ) * labelHeight * tmpLyr.
multilineHeight;
589 painter->
translate(
QPointF( xMultiLineOffset, - ascentOffset - yMultiLineOffset ) );
591 component.
setText( multiLineList.
at( i ) );
612 textp.
begin( &textPict );
613 textp.
setPen( Qt::NoPen );
Class for parsing and evaluation of expressions (formerly called "search strings").
void setExpressionParams(const QMap< QString, QVariant > ¶ms)
bool hasEvalError() const
Returns true if an error occurred when evaluating last input.
Wrapper for iterator of features from vector data provider or vector layer.
QString name() const
Name of the layer (for statistics, debugging etc.) - does not need to be unique.
FeaturePart * getFeaturePart()
return the feature corresponding to this labelposition
A rectangle specified with double values.
QString & append(QChar ch)
QString leftDirectionSymbol
static void dataDefinedShapeBackground(QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
void setMapRotation(double degrees, double cx, double cy)
Set map rotation in degrees (clockwise)
QStringList referencedColumns() const
Get list of columns referenced by the expression.
QgsPalLayerSettings::Placement mPlacement
Placement strategy.
static void dataDefinedTextStyle(QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
A container class for data source field mapping or expression.
void setOrigin(const QgsPoint &point)
virtual void registerFeature(QgsFeature &feature, QgsRenderContext &context)
Register a feature for labeling as one or more QgsLabelFeature objects stored into mLabels...
void setCompositionMode(CompositionMode mode)
void setRenderHint(RenderHint hint, bool on)
QgsLabelFeature * feature()
Returns the parent feature.
arranges candidates around a point (centroid for polygon)
const QString & text() const
Q_DECL_DEPRECATED bool prepare(const QgsFields &fields)
Get the expression ready for evaluation - find out column indexes.
UpsideDownLabels upsidedownLabels
QgsFields fields() const
Returns the list of fields of this layer.
double mPriority
Default priority of labels.
bool mOwnsSource
Whether layer's feature source is owned.
Whether to show debugging rectangles for drop shadows.
int fieldNameIndex(const QString &fieldName) const
Look up field's index from name also looks up case-insensitive if there is no match otherwise...
QString & prepend(QChar ch)
double rendererScale() const
void scale(qreal sx, qreal sy)
const_iterator constBegin() const
QgsPoint transform(const QgsPoint &p) const
Transform the point from map (world) coordinates to device coordinates.
const T & at(int i) const
static void drawLabelBuffer(QgsRenderContext &context, const QgsLabelComponent &component, const QgsPalLayerSettings &tmpLyr)
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
QgsRectangle visibleExtent() const
Return the actual extent derived from requested extent that takes takes output image size into accoun...
Class that adds extra information to QgsLabelFeature for text labels.
bool hasCrsTransformEnabled() const
returns true if projections are enabled for this layer set
Container of fields for a vector layer.
static QgsPalLayerSettings fromLayer(QgsVectorLayer *layer)
QgsFeatureId featureId() const
Returns the unique ID of the feature.
bool drawLabels
Whether to draw labels for this layer.
static void _fixQPictureDPI(QPainter *p)
const QgsRectangle & extent() const
const QgsMapToPixel & mapToPixel() const
static void dataDefinedDropShadow(QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
MultiLineAlign multilineAlign
double scaleFactor() const
whether to label each part of multi-part features separately
double rotation() const
Return the rotation of the resulting map image Units are clockwise degrees.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
void addText(const QPointF &point, const QFont &font, const QString &text)
const QgsCoordinateTransform * coordinateTransform() const
static QStringList splitToLines(const QString &text, const QString &wrapCharacter)
Splits a text string to a list of separate lines, using a specified wrap character.
virtual bool prepare(const QgsRenderContext &context, QStringList &attributeNames)
Prepare for registration of features.
double mapRotation() const
Return current map rotation in degrees.
qreal width(const QString &text) const
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
bool reverseDirectionSymbol
void setRotationOffset(const double rotation)
double x() const
Get the x value of the point.
static void drawLabelBackground(QgsRenderContext &context, QgsLabelComponent component, const QgsPalLayerSettings &tmpLyr)
QList< QgsLabelFeature * > mLabels
List of generated.
whether adjacent lines (with the same label text) should be merged
The QgsMapSettings class contains configuration for rendering of the map.
QString styleName() const
QgsLabelingResults * results() const
For internal use by the providers.
bool useAdvancedEffects() const
Returns true if advanced effects such as blend modes such be used.
virtual QList< QgsLabelFeature * > labelFeatures(QgsRenderContext &context) override
Return list of label features (they are owned by the provider and thus deleted on its destruction) ...
void init()
initialization method - called from constructors
bool hasFixedPosition() const
Whether the label should use a fixed position instead of being automatically placed.
bool conflictsWithObstacle() const
Returns whether the position is marked as conflicting with an obstacle feature.
void drawRect(const QRectF &rectangle)
Perform transforms between map coordinates and device coordinates.
void setFont(const QFont &font)
ObstacleType obstacleType
Controls how features act as obstacles for labels.
void setRotation(const double rotation)
void append(const T &value)
static void dataDefinedTextBuffer(QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)
const QgsCoordinateTransform * ct
double rasterCompressFactor
void setFillRule(Qt::FillRule fillRule)
double getY(int i=0) const
get the down-left y coordinate
#define QgsDebugMsgLevel(str, level)
double getAlpha() const
get alpha
QPainter::CompositionMode blendMode
unsigned int mLinePlacementFlags
Extra placement flags for linestring geometries.
void setPen(const QColor &color)
const QgsMapSettings & mapSettings() const
Get associated map settings.
Quadrant getQuadrant() const
const QgsCoordinateReferenceSystem & destinationCrs() const
returns CRS of destination coordinate reference system
QgsPalLayerSettings mSettings
Layer's labeling configuration.
const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > & dataDefinedValues() const
Get data-defined values.
const_iterator constEnd() const
void setCenter(const QgsPoint &point)
const QgsMapToPixel * xform
QMap< QgsPalLayerSettings::DataDefinedProperties, QgsDataDefined * > dataDefinedProperties
Map of current data defined properties.
QPaintDevice * device() const
This class wraps a request for features to a vector layer (or directly its vector data provider)...
Flags mFlags
Flags altering drawing and registration of features.
whether location of centroid must be inside of polygons
void setBrush(const QBrush &brush)
void drawText(const QPointF &position, const QString &text)
double rasterScaleFactor() const
void setText(const QString &text)
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry.
const QgsLabelingEngineV2 * mEngine
Associated labeling engine.
double mapUnitsPerPixel() const
Return current map units per pixel.
LabelPosition * getNextPart() const
whether labels must fall completely within the polygon
whether all features will be labelled even though overlaps occur
Base class that can be used for any class that is capable of returning features.
A class to represent a point.
bool insertLabel(LabelPosition *labelPos, int featureId, const QString &layerName, const QString &labeltext, const QFont &labelfont, bool diagram=false, bool pinned=false)
Inserts label position.
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)
void setDpiRatio(const double ratio)
bool testFlag(Flag f) const
Test whether a particular flag is enabled.
Partial snapshot of vector layer's state (only the members necessary for access to features) ...
void setX(double x)
Sets the x value of the point.
void setY(double y)
Sets the y value of the point.
Only for lines, labels along the line.
QgsExpressionContext & expressionContext()
Gets the expression context.
unsigned int placementFlags
QgsPoint toMapCoordinates(int x, int y) const
QgsFields mFields
Layer's fields.
QgsAbstractFeatureSource * mSource
Layer's feature source.
QString rightDirectionSymbol
QgsExpression * getLabelExpression()
Returns the QgsExpression for this label settings.
Contains information about the context of a rendering operation.
QFont definedFont()
Font to be used for rendering.
void setPicture(QPicture *picture)
QgsVectorLayerLabelProvider(QgsVectorLayer *layer, bool withFeatureLoop=true, const QgsPalLayerSettings *settings=0, const QString &layerName=QString())
Convenience constructor to initialize the provider from given vector layer.
QString text(int partId) const
Returns the text component corresponding to a specified label part.
The QgsLabelFeature class describes a feature that should be used within the labeling engine...
void drawPath(const QPainterPath &path)
Whether to only draw the label rect and not the actual label text (used for unit tests) ...
void setOffset(const QgsPoint &point)
QString mName
Name of the layer.
QgsCoordinateReferenceSystem mCrs
Layer's CRS.
bool fitInPolygonOnly
True if only labels which completely fit within a polygon are allowed.
int rotate(double rotation, const QgsPoint ¢er)
Rotate this geometry around the Z axis.
Class for storing a coordinate reference system (CRS)
QPointF bottomLeft() const
static QgsGeometry * fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
LabelPosition is a candidate feature label position.
void translate(const QPointF &offset)
QgsPalLayerSettings::ObstacleType mObstacleType
Type of the obstacle of feature geometries.
void registerFeature(QgsFeature &f, QgsRenderContext &context, const QString &dxfLayer, QgsLabelFeature **labelFeature=0)
Register a feature for labelling.
const QgsMapToPixel & mapToPixel() const
QgsPalLayerSettings::UpsideDownLabels mUpsidedownLabels
How to handle labels that would be upside down.
double y() const
Get the y value of the point.
const QgsCoordinateReferenceSystem & crs() const
Returns layer's spatial reference system.
double getX(int i=0) const
get the down-left x coordinate
whether the labels should be rendered
iterator insert(const Key &key, const T &value)
bool isExpression
Is this label made from a expression string eg FieldName || 'mm'.
void setSize(const QgsPoint &point)
QString mLayerId
Layer's ID.
void drawPicture(const QPointF &point, const QPicture &picture)
virtual QgsFeatureIterator getFeatures(const QgsFeatureRequest &request)=0
Get an iterator for features matching the specified request.
void setPictureBuffer(const double buffer)
bool nextFeature(QgsFeature &f)
QFontMetricsF * labelFontMetrics()
Metrics of the font for rendering.
Represents a vector layer which manages a vector based data sets.
bool begin(QPaintDevice *device)
~QgsVectorLayerLabelProvider()
Q_GUI_EXPORT int qt_defaultDpiY()
Whether to render labels as text or outlines.
QgsPoint center() const
Center point of the rectangle.
QString labelText() const
Text of the label.
QString evalErrorString() const
Returns evaluation error.
Maintains current state of more grainular and temporal values when creating/painting component parts ...
virtual void drawLabel(QgsRenderContext &context, pal::LabelPosition *label) const override
draw this label at the position determined by the labeling engine
Q_DECL_DEPRECATED QStringList referencedColumns(QgsVectorLayer *layer)
Returns the columns referenced by the QgsDataDefined.
Q_GUI_EXPORT int qt_defaultDpiX()
QgsFeatureRequest & setFilterRect(const QgsRectangle &rect)
Set rectangle from which features will be taken.
void drawLabelPrivate(pal::LabelPosition *label, QgsRenderContext &context, QgsPalLayerSettings &tmpLyr, QgsPalLabeling::DrawLabelType drawType, double dpiRatio=1.0) const
Internal label drawing method.
const T value(const Key &key) const
DirectionSymbols placeDirectionSymbol
QPointF toQPointF() const
Converts a point to a QPointF.
static void drawLabelShadow(QgsRenderContext &context, const QgsLabelComponent &component, const QgsPalLayerSettings &tmpLyr)
static void dataDefinedTextFormatting(QgsPalLayerSettings &tmpLyr, const QMap< QgsPalLayerSettings::DataDefinedProperties, QVariant > &ddValues)