QGIS API Documentation 3.41.0-Master (25ec5511245)
|
A cartoon talking bubble callout style. More...
#include <qgscallout.h>
Public Member Functions | |
QgsBalloonCallout () | |
QgsBalloonCallout (const QgsBalloonCallout &other) | |
~QgsBalloonCallout () override | |
QgsBalloonCallout * | clone () const override |
Duplicates a callout by creating a deep copy of the callout. | |
double | cornerRadius () const |
Returns the corner radius of the balloon shapes. | |
const QgsMapUnitScale & | cornerRadiusMapUnitScale () const |
Returns the map unit scale for the corner radius. | |
Qgis::RenderUnit | cornerRadiusUnit () const |
Returns the units for the corner radius. | |
QgsFillSymbol * | fillSymbol () |
Returns the fill symbol used to render the callout. | |
const QgsMargins & | margins () const |
Returns the margins between the outside of the callout frame and the label's bounding rectangle. | |
Qgis::RenderUnit | marginsUnit () const |
Returns the units for the margins between the outside of the callout frame and the label's bounding rectangle. | |
QgsMarkerSymbol * | markerSymbol () |
Returns the marker symbol used to render the callout endpoint. | |
double | offsetFromAnchor () const |
Returns the offset distance from the anchor point at which to start the line. | |
const QgsMapUnitScale & | offsetFromAnchorMapUnitScale () const |
Returns the map unit scale for the offset from anchor. | |
Qgis::RenderUnit | offsetFromAnchorUnit () const |
Returns the units for the offset from anchor point. | |
QgsBalloonCallout & | operator= (const QgsBalloonCallout &)=delete |
QVariantMap | properties (const QgsReadWriteContext &context) const override |
Returns the properties describing the callout encoded in a string format. | |
void | readProperties (const QVariantMap &props, const QgsReadWriteContext &context) override |
Reads a string map of an callout's properties and restores the callout to the state described by the properties map. | |
QSet< QString > | referencedFields (const QgsRenderContext &context) const override |
Returns the set of attributes referenced by the callout. | |
void | setCornerRadius (double radius) |
Sets the radius of the corners for the balloon shapes. | |
void | setCornerRadiusMapUnitScale (const QgsMapUnitScale &scale) |
Sets the map unit scale for the corner radius. | |
void | setCornerRadiusUnit (Qgis::RenderUnit unit) |
Sets the unit for the corner radius. | |
void | setFillSymbol (QgsFillSymbol *symbol) |
Sets the fill symbol used to render the callout. | |
void | setMargins (const QgsMargins &margins) |
Sets the margins between the outside of the callout frame and the label's bounding rectangle. | |
void | setMarginsUnit (Qgis::RenderUnit unit) |
Sets the unit for the margins between the outside of the callout frame and the label's bounding rectangle. | |
void | setMarkerSymbol (QgsMarkerSymbol *symbol) |
Sets the marker symbol used to render the callout endpoint. | |
void | setOffsetFromAnchor (double distance) |
Sets the offset distance from the anchor point at which to start the line. | |
void | setOffsetFromAnchorMapUnitScale (const QgsMapUnitScale &scale) |
Sets the map unit scale for the offset from anchor. | |
void | setOffsetFromAnchorUnit (Qgis::RenderUnit unit) |
Sets the unit for the offset from anchor distance. | |
void | setWedgeWidth (double width) |
Sets the width of the wedge shape at the side it connects with the label. | |
void | setWedgeWidthMapUnitScale (const QgsMapUnitScale &scale) |
Sets the map unit scale for the wedge width. | |
void | setWedgeWidthUnit (Qgis::RenderUnit unit) |
Sets the unit for the wedge width. | |
void | startRender (QgsRenderContext &context) override |
Prepares the callout for rendering on the specified render context. | |
void | stopRender (QgsRenderContext &context) override |
Finalises the callout after a set of rendering operations on the specified render context. | |
QString | type () const override |
Returns a unique string representing the callout type. | |
double | wedgeWidth () const |
Returns the width of the wedge shape at the side it connects with the label. | |
const QgsMapUnitScale & | wedgeWidthMapUnitScale () const |
Returns the map unit scale for the wedge width. | |
Qgis::RenderUnit | wedgeWidthUnit () const |
Returns the units for the wedge width. | |
Public Member Functions inherited from QgsCallout | |
QgsCallout () | |
Constructor for QgsCallout. | |
virtual | ~QgsCallout ()=default |
AnchorPoint | anchorPoint () const |
Returns the feature's anchor point position. | |
QPainter::CompositionMode | blendMode () const |
Returns the blending mode used for drawing callouts. | |
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. | |
QgsPropertyCollection & | dataDefinedProperties () |
Returns a reference to the callout's property collection, used for data defined overrides. | |
const QgsPropertyCollection & | dataDefinedProperties () const |
Returns a reference to the callout's property collection, used for data defined overrides. | |
virtual DrawOrder | drawOrder () const |
Returns the desired drawing order (stacking) to use while rendering this callout. | |
bool | enabled () const |
Returns true if the the callout is enabled. | |
LabelAnchorPoint | labelAnchorPoint () const |
Returns the label's anchor point position. | |
void | render (QgsRenderContext &context, const QRectF &rect, const double angle, const QgsGeometry &anchor, QgsCalloutContext &calloutContext) |
Renders the callout onto the specified render context. | |
virtual void | restoreProperties (const QDomElement &element, const QgsReadWriteContext &context) |
Restores the callout's properties from a DOM element. | |
virtual bool | saveProperties (QDomDocument &doc, QDomElement &element, const QgsReadWriteContext &context) const |
Saves the current state of the callout to a DOM element. | |
void | setAnchorPoint (AnchorPoint anchor) |
Sets the feature's anchor point position. | |
void | setBlendMode (QPainter::CompositionMode mode) |
Sets the blending mode used for drawing callouts. | |
void | setDataDefinedProperties (const QgsPropertyCollection &collection) |
Sets the callout's property collection, used for data defined overrides. | |
void | setEnabled (bool enabled) |
Sets whether the callout is enabled. | |
void | setLabelAnchorPoint (LabelAnchorPoint anchor) |
Sets the label's anchor point position. | |
Static Public Member Functions | |
static QgsCallout * | create (const QVariantMap &properties=QVariantMap(), const QgsReadWriteContext &context=QgsReadWriteContext()) |
Creates a new QgsBalloonCallout, using the settings serialized in the properties map (corresponding to the output from QgsBalloonCallout::properties() ). | |
Static Public Member Functions inherited from QgsCallout | |
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. | |
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. | |
static QString | encodeAnchorPoint (AnchorPoint anchor) |
Encodes an anchor point to its string representation. | |
static QString | encodeLabelAnchorPoint (LabelAnchorPoint anchor) |
Encodes a label anchor point to its string representation. | |
static QgsPropertiesDefinition | propertyDefinitions () |
Returns the definitions for data defined properties available for use in callouts. | |
Protected Member Functions | |
void | draw (QgsRenderContext &context, const QRectF &bodyBoundingBox, const double angle, const QgsGeometry &anchor, QgsCallout::QgsCalloutContext &calloutContext) override |
Performs the actual rendering of the callout implementation onto the specified render context. | |
Protected Member Functions inherited from QgsCallout | |
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. | |
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. | |
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. | |
Additional Inherited Members | |
Public Types inherited from QgsCallout | |
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 class | Property : int { MinimumCalloutLength , OffsetFromAnchor , OffsetFromLabel , DrawCalloutToAllParts , AnchorPointPosition , LabelAnchorPointPosition , OriginX , OriginY , DestinationX , DestinationY , Curvature , Orientation , Margins , WedgeWidth , CornerRadius , BlendMode } |
Data definable properties. More... | |
QgsBalloonCallout::QgsBalloonCallout | ( | ) |
Definition at line 1036 of file qgscallout.cpp.
|
overridedefault |
QgsBalloonCallout::QgsBalloonCallout | ( | const QgsBalloonCallout & | other | ) |
Definition at line 1043 of file qgscallout.cpp.
|
overridevirtual |
Duplicates a callout by creating a deep copy of the callout.
Caller takes ownership of the returned object.
Implements QgsCallout.
Definition at line 1074 of file qgscallout.cpp.
|
inline |
Returns the corner radius of the balloon shapes.
Units are specified through wedgeWidthUnit().
Definition at line 1096 of file qgscallout.h.
|
inline |
Returns the map unit scale for the corner radius.
Definition at line 1140 of file qgscallout.h.
|
inline |
Returns the units for the corner radius.
Definition at line 1122 of file qgscallout.h.
|
static |
Creates a new QgsBalloonCallout, using the settings serialized in the properties map (corresponding to the output from QgsBalloonCallout::properties() ).
Definition at line 1062 of file qgscallout.cpp.
|
overrideprotectedvirtual |
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.
Implements QgsCallout.
Definition at line 1199 of file qgscallout.cpp.
QgsFillSymbol * QgsBalloonCallout::fillSymbol | ( | ) |
Returns the fill symbol used to render the callout.
Ownership is not transferred.
Definition at line 1179 of file qgscallout.cpp.
|
inline |
Returns the margins between the outside of the callout frame and the label's bounding rectangle.
Units are retrieved via marginsUnit()
Definition at line 1004 of file qgscallout.h.
|
inline |
Returns the units for the margins between the outside of the callout frame and the label's bounding rectangle.
Definition at line 1032 of file qgscallout.h.
QgsMarkerSymbol * QgsBalloonCallout::markerSymbol | ( | ) |
Returns the marker symbol used to render the callout endpoint.
May be nullptr
, if no endpoint marker will be used.
The marker will always be rendered below the fill symbol for the callout.
Ownership is not transferred.
Definition at line 1189 of file qgscallout.cpp.
|
inline |
Returns the offset distance from the anchor point at which to start the line.
Units are specified through offsetFromAnchorUnit().
Definition at line 955 of file qgscallout.h.
|
inline |
Returns the map unit scale for the offset from anchor.
Definition at line 992 of file qgscallout.h.
|
inline |
Returns the units for the offset from anchor point.
Definition at line 976 of file qgscallout.h.
|
delete |
|
overridevirtual |
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 from QgsCallout.
Definition at line 1079 of file qgscallout.cpp.
|
overridevirtual |
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 from QgsCallout.
Definition at line 1111 of file qgscallout.cpp.
|
overridevirtual |
Returns the set of attributes referenced by the callout.
This includes attributes required by any data defined properties associated with the callout.
Reimplemented from QgsCallout.
Definition at line 1169 of file qgscallout.cpp.
|
inline |
Sets the radius of the corners for the balloon shapes.
Units are specified through setCornerRadiusUnit().
Definition at line 1106 of file qgscallout.h.
|
inline |
Sets the map unit scale for the corner radius.
Definition at line 1131 of file qgscallout.h.
|
inline |
Sets the unit for the corner radius.
Definition at line 1114 of file qgscallout.h.
void QgsBalloonCallout::setFillSymbol | ( | QgsFillSymbol * | symbol | ) |
Sets the fill symbol used to render the callout.
Ownership of symbol is transferred to the callout.
Definition at line 1184 of file qgscallout.cpp.
|
inline |
Sets the margins between the outside of the callout frame and the label's bounding rectangle.
Units are set via setMarginsUnit()
Definition at line 1016 of file qgscallout.h.
|
inline |
Sets the unit for the margins between the outside of the callout frame and the label's bounding rectangle.
Definition at line 1024 of file qgscallout.h.
void QgsBalloonCallout::setMarkerSymbol | ( | QgsMarkerSymbol * | symbol | ) |
Sets the marker symbol used to render the callout endpoint.
Ownership of symbol is transferred to the callout.
Set to nullptr
to disable the endpoint marker.
The marker will always be rendered below the fill symbol for the callout.
Definition at line 1194 of file qgscallout.cpp.
|
inline |
Sets the offset distance from the anchor point at which to start the line.
Units are specified through setOffsetFromAnchorUnit().
Definition at line 962 of file qgscallout.h.
|
inline |
Sets the map unit scale for the offset from anchor.
Definition at line 984 of file qgscallout.h.
|
inline |
Sets the unit for the offset from anchor distance.
Definition at line 969 of file qgscallout.h.
|
inline |
Sets the width of the wedge shape at the side it connects with the label.
Units are specified through setWedgeWidthUnit().
Definition at line 1052 of file qgscallout.h.
|
inline |
Sets the map unit scale for the wedge width.
Definition at line 1077 of file qgscallout.h.
|
inline |
Sets the unit for the wedge width.
Definition at line 1060 of file qgscallout.h.
|
overridevirtual |
Prepares the callout for rendering on the specified render context.
Reimplemented from QgsCallout.
Definition at line 1151 of file qgscallout.cpp.
|
overridevirtual |
Finalises the callout after a set of rendering operations on the specified render context.
Reimplemented from QgsCallout.
Definition at line 1160 of file qgscallout.cpp.
|
overridevirtual |
Returns a unique string representing the callout type.
Implements QgsCallout.
Definition at line 1069 of file qgscallout.cpp.
|
inline |
Returns the width of the wedge shape at the side it connects with the label.
Units are specified through wedgeWidthUnit().
Definition at line 1042 of file qgscallout.h.
|
inline |
Returns the map unit scale for the wedge width.
Definition at line 1086 of file qgscallout.h.
|
inline |
Returns the units for the wedge width.
Definition at line 1068 of file qgscallout.h.