55 , mLayerGeometryType( layer->geometryType() )
56 , mRenderer( layer->rendererV2() )
57 , mFields( layer->fields() )
58 , mCrs( layer->crs() )
62 if ( withFeatureLoop )
181 attributeNames.
append( name );
213 attributeNames.
append( name );
269 if ( !
prepare( ctx, attrNames ) )
356 bounds = bounds.
united( static_cast< QgsMarkerSymbolV2* >( symbol )->bounds( pt, context ) );
371 for (
int i = 0; i < boundLineString->
numPoints(); ++i )
374 boundLineString->
setXAt( i, point.
x() );
375 boundLineString->
setYAt( i, point.
y() );
381 boundLineString->
close();
392 obstacleGeom = obstaclePolygon;
425 case LabelPosition::QuadrantAboveLeft:
426 case LabelPosition::QuadrantLeft:
427 case LabelPosition::QuadrantBelowLeft:
430 case LabelPosition::QuadrantAbove:
431 case LabelPosition::QuadrantOver:
432 case LabelPosition::QuadrantBelow:
435 case LabelPosition::QuadrantAboveRight:
436 case LabelPosition::QuadrantRight:
437 case LabelPosition::QuadrantBelowRight:
529 QRectF rect( 0, 0, outPt2.
x() - outPt.
x(), outPt2.
y() - outPt.
y() );
562 double xc = outPt2.
x() - outPt.
x();
563 double yc = outPt2.
y() - outPt.
y();
566 double xd = xc * cos( angle ) - yc * sin( angle );
567 double yd = xc * sin( angle ) + yc * cos( angle );
569 centerPt.
setX( centerPt.
x() + xd );
570 centerPt.
setY( centerPt.
y() + yd );
591 bool prependSymb =
false;
637 int lines = multiLineList.
size();
639 double labelWidest = 0.0;
640 for (
int i = 0; i < lines; ++i )
642 double labelWidth = labelfm->
width( multiLineList.
at( i ) );
643 if ( labelWidth > labelWidest )
645 labelWidest = labelWidth;
653 double ascentOffset = 0.25 * labelfm->
ascent();
655 for (
int i = 0; i < lines; ++i )
658 #if 0 // TODO: generalize some of this 662 double cx = lp->
getX() + w / 2.0;
663 double cy = lp->
getY() + h / 2.0;
666 double sw = w * scale;
667 double sh = h * scale;
668 QRectF rect( -sw / 2, -sh / 2, sw, sh );
673 if ( lp->
getFeaturePart()->getLayer()->getArrangement() != P_POINT &&
674 lp->
getFeaturePart()->getLayer()->getArrangement() != P_POINT_OVER &&
677 painter->
rotate( rotation );
692 double xMultiLineOffset = 0.0;
693 double labelWidth = labelfm->
width( multiLineList.
at( i ) );
696 double labelWidthDiff = labelWidest - labelWidth;
701 xMultiLineOffset = labelWidthDiff;
705 double yMultiLineOffset = ( lines - 1 - i ) * labelHeight * tmpLyr.
multilineHeight;
706 painter->
translate(
QPointF( xMultiLineOffset, - ascentOffset - yMultiLineOffset ) );
708 component.
setText( multiLineList.
at( i ) );
729 textp.
begin( &textPict );
730 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.
QgsFeatureRendererV2 * mRenderer
void close()
Closes the line string by appending the first point to the end of the line, if it is not already clos...
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)
void setCompositionMode(CompositionMode mode)
void setRenderHint(RenderHint hint, bool on)
QgsLabelFeature * feature()
Returns the parent feature.
void registerFeature(QgsFeature &f, QgsRenderContext &context, const QString &dxfLayer, QgsLabelFeature **labelFeature=nullptr, QgsGeometry *obstacleGeometry=nullptr)
Register a feature for labelling.
double x() const
Returns the point's x-coordinate.
Q_DECL_DEPRECATED bool prepare(const QgsFields &fields)
Get the expression ready for evaluation - find out column indexes.
UpsideDownLabels upsidedownLabels
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
double mPriority
Default priority of labels.
bool mOwnsSource
Whether layer's feature source is owned.
double xAt(int index) const
Returns the x-coordinate of the specified node in the line string.
QgsAbstractGeometryV2 * geometry() const
Returns the underlying geometry store.
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
QgsVectorLayerLabelProvider(QgsVectorLayer *layer, bool withFeatureLoop=true, const QgsPalLayerSettings *settings=nullptr, const QString &layerName=QString())
Convenience constructor to initialize the provider from given vector layer.
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...
QGis::GeometryType type() const
Returns type of the geometry as a QGis::GeometryType.
Class that adds extra information to QgsLabelFeature for text labels.
Abstract base class for all geometries.
static QgsGeometry * getPointObstacleGeometry(QgsFeature &fet, QgsRenderContext &context, const QgsSymbolV2List &symbols)
Returns the geometry for a point feature which should be used as an obstacle for labels.
bool hasCrsTransformEnabled() const
returns true if projections are enabled for this layer set
Container of fields for a vector layer.
A geometry is the spatial representation of a 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
The QGis class provides global constants for use throughout the application.
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.
FeaturePart * getFeaturePart()
return the feature corresponding to this labelposition
void transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection d=QgsCoordinateTransform::ForwardTransform) override
Transforms the geometry using a coordinate transform.
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.
int nCoordinates() const
Returns the number of nodes contained in the geometry.
static void drawLabelBackground(QgsRenderContext &context, QgsLabelComponent component, const QgsPalLayerSettings &tmpLyr)
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)=0
Needs to be called when a new render cycle is started.
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.
double y() const
Returns the point's y-coordinate.
QString styleName() const
virtual void stopRender(QgsRenderContext &context)=0
Needs to be called when a render cycle has finished to clean up.
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
virtual Q_DECL_DEPRECATED QgsSymbolV2List originalSymbolsForFeature(QgsFeature &feat)
Equivalent of originalSymbolsForFeature() call extended to support renderers that may use more symbol...
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)
void transformInPlace(double &x, double &y) const
Transform device coordinates to map coordinates.
QgsExpressionContextScope * lastScope()
Returns the last scope added to the context.
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)
virtual void setExteriorRing(QgsCurveV2 *ring) override
Sets the exterior ring of the polygon.
const QgsCoordinateTransform * ct
double rasterCompressFactor
void setFillRule(Qt::FillRule fillRule)
Utility class for identifying a unique vertex within a geometry.
#define QgsDebugMsgLevel(str, level)
Line string geometry type, with support for z-dimension and m-values.
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
Point geometry type, with support for z-dimension and m-values.
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)
double getY(int i=0) const
get the down-left y coordinate
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
QRectF united(const QRectF &rectangle) const
whether all features will be labelled even though overlaps occur
void setYAt(int index, double y)
Sets the y-coordinate of the specified node in the line string.
Single scope for storing variables and functions for use within a QgsExpressionContext.
Base class that can be used for any class that is capable of returning features.
double getX(int i=0) const
get the down-left x coordinate
double yAt(int index) const
Returns the y-coordinate of the specified node in the line string.
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)
void setDpiRatio(const double ratio)
bool testFlag(Flag f) const
Test whether a particular flag is enabled.
QString layerId() const
Returns ID of associated layer, or empty string if no layer is associated with the provider...
virtual void registerFeature(QgsFeature &feature, QgsRenderContext &context, QgsGeometry *obstacleGeometry=nullptr)
Register a feature for labeling as one or more QgsLabelFeature objects stored into mLabels...
void setXAt(int index, double x)
Sets the x-coordinate of the specified node in the line string.
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.
QgsExpressionContext & expressionContext()
Gets the expression context.
double getAlpha() const
get alpha
unsigned int placementFlags
QgsPoint toMapCoordinates(int x, int y) const
QgsFields mFields
Layer's fields.
QgsAbstractFeatureSource * mSource
Layer's feature source.
QString rightDirectionSymbol
void addVertex(const QgsPointV2 &pt)
Adds a new vertex to the end of the line string.
QgsExpression * getLabelExpression()
Returns the QgsExpression for this label settings.
Arranges candidates over a point (or centroid of a polygon), or at a preset offset from the point...
Contains information about the context of a rendering operation.
QFont definedFont()
Font to be used for rendering.
void setPicture(QPicture *picture)
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.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
Class for storing a coordinate reference system (CRS)
QPointF bottomLeft() const
const QgsGeometry * constGeometry() const
Gets a const pointer to the geometry object associated with this feature.
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.
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.
Multi polygon geometry collection.
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'.
bool isEmpty() const
Returns true if the geometry is empty (ie, contains no underlying geometry accessible via geometry)...
void setSize(const QgsPoint &point)
void drawPicture(const QPointF &point, const QPicture &picture)
QPointF bottomRight() const
virtual QgsFeatureIterator getFeatures(const QgsFeatureRequest &request)=0
Get an iterator for features matching the specified request.
void setPictureBuffer(const double buffer)
QgsExpressionContextScope * popScope()
Removes the last scope from the expression context and return it.
bool nextFeature(QgsFeature &f)
QFontMetricsF * labelFontMetrics()
Metrics of the font for rendering.
bool insertLabel(pal::LabelPosition *labelPos, int featureId, const QString &layerName, const QString &labeltext, const QFont &labelfont, bool diagram=false, bool pinned=false)
Inserts label position.
Represents a vector layer which manages a vector based data sets.
bool begin(QPaintDevice *device)
~QgsVectorLayerLabelProvider()
QString mLayerId
Associated layer's ID, if applicable.
static QgsExpressionContextScope * updateSymbolScope(const QgsSymbolV2 *symbol, QgsExpressionContextScope *symbolScope=nullptr)
Updates a symbol scope related to a QgsSymbolV2 to an expression context.
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.
virtual QgsPointV2 vertexAt(QgsVertexId id) const =0
Returns the point corresponding to a specified vertex id.
QGis::GeometryType mLayerGeometryType
Geometry type of layer.
int numPoints() const override
Returns the number of points in the curve.
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
QgsFeatureId featureId() const
Returns the unique ID of the feature.
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)