QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
|
Abstract base class for callout renderers. More...
#include <qgscallout.h>
Classes | |
class | QgsCalloutContext |
Contains additional contextual information about the context in which a callout is being rendered. More... | |
Public Types | |
enum | AnchorPoint { PoleOfInaccessibility = 0 , PointOnExterior , PointOnSurface , Centroid } |
Feature's anchor point position. More... | |
enum | DrawOrder { OrderBelowAllLabels , OrderBelowIndividualLabels } |
Options for draw order (stacking) of callouts. More... | |
enum | LabelAnchorPoint { LabelPointOnExterior , LabelCentroid , LabelTopLeft , LabelTopMiddle , LabelTopRight , LabelMiddleLeft , LabelMiddleRight , LabelBottomLeft , LabelBottomMiddle , LabelBottomRight } |
Label's anchor point position. More... | |
enum | Property { MinimumCalloutLength , OffsetFromAnchor , OffsetFromLabel , DrawCalloutToAllParts , AnchorPointPosition , LabelAnchorPointPosition , OriginX , OriginY , DestinationX , DestinationY , Curvature , Orientation , Margins , WedgeWidth , CornerRadius , BlendMode } |
Data definable properties. More... | |
Public Member Functions | |
QgsCallout () | |
Constructor for QgsCallout. More... | |
virtual | ~QgsCallout ()=default |
AnchorPoint | anchorPoint () const |
Returns the feature's anchor point position. More... | |
QPainter::CompositionMode | blendMode () const |
Returns the blending mode used for drawing callouts. More... | |
virtual QgsCallout * | clone () const =0 |
Duplicates a callout by creating a deep copy of the callout. More... | |
bool | containsAdvancedEffects () const |
Returns true if the callout requires advanced effects such as blend modes, which require output in raster formats to be fully respected. More... | |
QgsPropertyCollection & | dataDefinedProperties () |
Returns a reference to the callout's property collection, used for data defined overrides. More... | |
const QgsPropertyCollection & | dataDefinedProperties () const |
Returns a reference to the callout's property collection, used for data defined overrides. More... | |
virtual DrawOrder | drawOrder () const |
Returns the desired drawing order (stacking) to use while rendering this callout. More... | |
bool | enabled () const |
Returns true if the the callout is enabled. More... | |
LabelAnchorPoint | labelAnchorPoint () const |
Returns the label's anchor point position. More... | |
virtual QVariantMap | properties (const QgsReadWriteContext &context) const |
Returns the properties describing the callout encoded in a string format. More... | |
virtual void | readProperties (const QVariantMap &props, const QgsReadWriteContext &context) |
Reads a string map of an callout's properties and restores the callout to the state described by the properties map. More... | |
virtual QSet< QString > | referencedFields (const QgsRenderContext &context) const |
Returns the set of attributes referenced by the callout. More... | |
void | render (QgsRenderContext &context, const QRectF &rect, const double angle, const QgsGeometry &anchor, QgsCalloutContext &calloutContext) |
Renders the callout onto the specified render context. More... | |
virtual void | restoreProperties (const QDomElement &element, const QgsReadWriteContext &context) |
Restores the callout's properties from a DOM element. More... | |
virtual bool | saveProperties (QDomDocument &doc, QDomElement &element, const QgsReadWriteContext &context) const |
Saves the current state of the callout to a DOM element. More... | |
void | setAnchorPoint (AnchorPoint anchor) |
Sets the feature's anchor point position. More... | |
void | setBlendMode (QPainter::CompositionMode mode) |
Sets the blending mode used for drawing callouts. More... | |
void | setDataDefinedProperties (const QgsPropertyCollection &collection) |
Sets the callout's property collection, used for data defined overrides. More... | |
void | setEnabled (bool enabled) |
Sets whether the callout is enabled. More... | |
void | setLabelAnchorPoint (LabelAnchorPoint anchor) |
Sets the label's anchor point position. More... | |
virtual void | startRender (QgsRenderContext &context) |
Prepares the callout for rendering on the specified render context. More... | |
virtual void | stopRender (QgsRenderContext &context) |
Finalises the callout after a set of rendering operations on the specified render context. More... | |
virtual QString | type () const =0 |
Returns a unique string representing the callout type. More... | |
Static Public Member Functions | |
static QgsCallout::AnchorPoint | decodeAnchorPoint (const QString &name, bool *ok=nullptr) |
Attempts to decode a string representation of an anchor point name to the corresponding anchor point. More... | |
static QgsCallout::LabelAnchorPoint | decodeLabelAnchorPoint (const QString &name, bool *ok=nullptr) |
Attempts to decode a string representation of a label anchor point name to the corresponding anchor point. More... | |
static QString | encodeAnchorPoint (AnchorPoint anchor) |
Encodes an anchor point to its string representation. More... | |
static QString | encodeLabelAnchorPoint (LabelAnchorPoint anchor) |
Encodes a label anchor point to its string representation. More... | |
static QgsPropertiesDefinition | propertyDefinitions () |
Returns the definitions for data defined properties available for use in callouts. More... | |
Protected Member Functions | |
QgsGeometry | calloutLabelPoint (const QRectF &bodyBoundingBox, double angle, LabelAnchorPoint anchor, QgsRenderContext &context, const QgsCalloutContext &calloutContext, bool &pinned) const |
Returns the anchor point geometry for a label with the given bounding box and anchor point mode. More... | |
QgsGeometry | calloutLineToPart (const QgsGeometry &labelGeometry, const QgsAbstractGeometry *partGeometry, QgsRenderContext &context, const QgsCalloutContext &calloutContext, bool &pinned) const |
Calculates the direct line from a label geometry to an anchor geometry part, respecting the various callout settings which influence how the callout end should be placed in the anchor geometry. More... | |
virtual void | draw (QgsRenderContext &context, const QRectF &bodyBoundingBox, const double angle, const QgsGeometry &anchor, QgsCalloutContext &calloutContext)=0 |
Performs the actual rendering of the callout implementation onto the specified render context. More... | |
Q_DECL_DEPRECATED QgsGeometry | labelAnchorGeometry (const QRectF &bodyBoundingBox, const double angle, LabelAnchorPoint anchor) const |
Returns the anchor point geometry for a label with the given bounding box and anchor point mode. More... | |
Abstract base class for callout renderers.
Implementations of QgsCallout are responsible for performing the actual render of callouts, including determining the desired shape of the callout and using any relevant symbology elements to render them.
Definition at line 52 of file qgscallout.h.
Feature's anchor point position.
Definition at line 111 of file qgscallout.h.
Options for draw order (stacking) of callouts.
Enumerator | |
---|---|
OrderBelowAllLabels | Render callouts below all labels. |
OrderBelowIndividualLabels | Render callouts below their individual associated labels, some callouts may be drawn over other labels. |
Definition at line 104 of file qgscallout.h.
Label's anchor point position.
Definition at line 123 of file qgscallout.h.
enum QgsCallout::Property |
Data definable properties.
Definition at line 83 of file qgscallout.h.
QgsCallout::QgsCallout | ( | ) |
Constructor for QgsCallout.
Definition at line 76 of file qgscallout.cpp.
|
virtualdefault |
|
inline |
Returns the feature's anchor point position.
Definition at line 361 of file qgscallout.h.
|
inline |
Returns the blending mode used for drawing callouts.
Definition at line 428 of file qgscallout.h.
|
protected |
Returns the anchor point geometry for a label with the given bounding box and anchor point mode.
The pinned argument will be set to true
if the callout label point is pinned (manually placed).
Definition at line 350 of file qgscallout.cpp.
|
protected |
Calculates the direct line from a label geometry to an anchor geometry part, respecting the various callout settings which influence how the callout end should be placed in the anchor geometry.
Returns a null geometry if the callout line cannot be calculated.
The pinned argument will be set to true
if the callout anchor point is pinned (manually placed).
Definition at line 427 of file qgscallout.cpp.
|
pure virtual |
Duplicates a callout by creating a deep copy of the callout.
Caller takes ownership of the returned object.
Implemented in QgsSimpleLineCallout, QgsManhattanLineCallout, QgsCurvedLineCallout, and QgsBalloonCallout.
bool QgsCallout::containsAdvancedEffects | ( | ) | const |
Returns true
if the callout requires advanced effects such as blend modes, which require output in raster formats to be fully respected.
Definition at line 133 of file qgscallout.cpp.
|
inline |
Returns a reference to the callout's property collection, used for data defined overrides.
Definition at line 331 of file qgscallout.h.
|
inline |
Returns a reference to the callout's property collection, used for data defined overrides.
Definition at line 339 of file qgscallout.h.
|
static |
Attempts to decode a string representation of an anchor point name to the corresponding anchor point.
name | encoded anchor point name |
ok | if specified, will be set to true if the anchor point was successfully decoded |
Definition at line 203 of file qgscallout.cpp.
|
static |
Attempts to decode a string representation of a label anchor point name to the corresponding anchor point.
name | encoded label anchor point name |
ok | if specified, will be set to true if the anchor point was successfully decoded |
Definition at line 268 of file qgscallout.cpp.
|
protectedpure virtual |
Performs the actual rendering of the callout implementation onto the specified render context.
The bodyBoundingBox argument gives the desired size and position of the body of the callout (e.g. the actual label geometry). The angle argument specifies the rotation of the callout body (in degrees clockwise from horizontal). It is assumed that angle rotation specified via angle is applied around the center of rect.
The anchor argument dictates the geometry which the callout should connect to. Depending on the callout subclass and anchor geometry type, the actual shape of the rendered callout may vary. E.g. a subclass may prefer to attach to the centroid of the anchor, while another subclass may prefer to attach to the closest point on anchor instead.
Both rect and anchor are specified in painter coordinates (i.e. pixels).
The calloutContext argument is used to specify additional contextual information about how a callout is being rendered.
Implemented in QgsSimpleLineCallout, and QgsBalloonCallout.
|
virtual |
Returns the desired drawing order (stacking) to use while rendering this callout.
The default order is QgsCallout::OrderBelowIndividualLabels.
Definition at line 144 of file qgscallout.cpp.
|
inline |
Returns true
if the the callout is enabled.
Definition at line 319 of file qgscallout.h.
|
static |
Encodes an anchor point to its string representation.
Definition at line 223 of file qgscallout.cpp.
|
static |
Encodes a label anchor point to its string representation.
Definition at line 239 of file qgscallout.cpp.
|
protected |
Returns the anchor point geometry for a label with the given bounding box and anchor point mode.
Definition at line 300 of file qgscallout.cpp.
|
inline |
Returns the label's anchor point position.
Definition at line 394 of file qgscallout.h.
|
virtual |
Returns the properties describing the callout encoded in a string format.
Subclasses must ensure that they include the base class' properties() in their returned value.
Reimplemented in QgsSimpleLineCallout, QgsCurvedLineCallout, and QgsBalloonCallout.
Definition at line 80 of file qgscallout.cpp.
|
static |
Returns the definitions for data defined properties available for use in callouts.
Definition at line 193 of file qgscallout.cpp.
|
virtual |
Reads a string map of an callout's properties and restores the callout to the state described by the properties map.
Subclasses must ensure that they call the base class' readProperties() method.
Reimplemented in QgsSimpleLineCallout, and QgsBalloonCallout.
Definition at line 91 of file qgscallout.cpp.
|
virtual |
Returns the set of attributes referenced by the callout.
This includes attributes required by any data defined properties associated with the callout.
Reimplemented in QgsSimpleLineCallout, and QgsBalloonCallout.
Definition at line 138 of file qgscallout.cpp.
void QgsCallout::render | ( | QgsRenderContext & | context, |
const QRectF & | rect, | ||
const double | angle, | ||
const QgsGeometry & | anchor, | ||
QgsCalloutContext & | calloutContext | ||
) |
Renders the callout onto the specified render context.
The rect argument gives the desired size and position of the body of the callout (e.g. the actual label geometry). The angle argument specifies the rotation of the callout body (in degrees clockwise from horizontal). It is assumed that angle rotation specified via angle is applied around the center of rect.
The anchor argument dictates the geometry which the callout should connect to. Depending on the callout subclass and anchor geometry type, the actual shape of the rendered callout may vary. E.g. a subclass may prefer to attach to the centroid of the anchor, while another subclass may prefer to attach to the closest point on anchor instead.
Both rect and anchor must be specified in painter coordinates (i.e. pixels).
The calloutContext argument is used to specify additional contextual information about how a callout is being rendered.
Definition at line 149 of file qgscallout.cpp.
|
virtual |
Restores the callout's properties from a DOM element.
The default behavior is the read the DOM contents and call readProperties() on the subclass.
Definition at line 118 of file qgscallout.cpp.
|
virtual |
Saves the current state of the callout to a DOM element.
The default behavior is to save the properties string map returned by properties().
true
if save was successful Definition at line 101 of file qgscallout.cpp.
|
inline |
Sets the feature's anchor point position.
Definition at line 368 of file qgscallout.h.
|
inline |
Sets the blending mode used for drawing callouts.
Definition at line 435 of file qgscallout.h.
|
inline |
Sets the callout's property collection, used for data defined overrides.
Any existing properties will be discarded.
Definition at line 349 of file qgscallout.h.
void QgsCallout::setEnabled | ( | bool | enabled | ) |
Sets whether the callout is enabled.
Definition at line 188 of file qgscallout.cpp.
|
inline |
Sets the label's anchor point position.
Definition at line 402 of file qgscallout.h.
|
virtual |
Prepares the callout for rendering on the specified render context.
Reimplemented in QgsSimpleLineCallout, and QgsBalloonCallout.
Definition at line 124 of file qgscallout.cpp.
|
virtual |
Finalises the callout after a set of rendering operations on the specified render context.
Reimplemented in QgsSimpleLineCallout, and QgsBalloonCallout.
Definition at line 128 of file qgscallout.cpp.
|
pure virtual |
Returns a unique string representing the callout type.
Implemented in QgsSimpleLineCallout, QgsManhattanLineCallout, QgsCurvedLineCallout, and QgsBalloonCallout.