QGIS API Documentation
3.10.0-A Coruña (6c816b4204)
|
A simple direct line callout style. More...
#include <qgscallout.h>
Public Member Functions | |
QgsSimpleLineCallout () | |
QgsSimpleLineCallout (const QgsSimpleLineCallout &other) | |
Copy constructor. More... | |
~QgsSimpleLineCallout () override | |
QgsSimpleLineCallout * | clone () const override |
Duplicates a callout by creating a deep copy of the callout. More... | |
bool | drawCalloutToAllParts () const |
Returns true if callout lines should be drawn to all feature parts. More... | |
QgsLineSymbol * | lineSymbol () |
Returns the line symbol used to render the callout line. More... | |
double | minimumLength () const |
Returns the minimum length of callout lines. More... | |
const QgsMapUnitScale & | minimumLengthMapUnitScale () const |
Returns the map unit scale for the minimum callout length. More... | |
QgsUnitTypes::RenderUnit | minimumLengthUnit () const |
Returns the units for the minimum length of callout lines. More... | |
double | offsetFromAnchor () const |
Returns the offset distance from the anchor point at which to start the line. More... | |
const QgsMapUnitScale & | offsetFromAnchorMapUnitScale () const |
Returns the map unit scale for the offset from anchor. More... | |
QgsUnitTypes::RenderUnit | offsetFromAnchorUnit () const |
Returns the units for the offset from anchor point. More... | |
double | offsetFromLabel () const |
Returns the offset distance from label area at which to end the line. More... | |
const QgsMapUnitScale & | offsetFromLabelMapUnitScale () const |
Returns the map unit scale for the minimum callout length. More... | |
QgsUnitTypes::RenderUnit | offsetFromLabelUnit () const |
Returns the units for the offset from label area. More... | |
QgsSimpleLineCallout & | operator= (const QgsSimpleLineCallout &)=delete |
QVariantMap | properties (const QgsReadWriteContext &context) const override |
Returns the properties describing the callout encoded in a string format. More... | |
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. More... | |
QSet< QString > | referencedFields (const QgsRenderContext &context) const override |
Returns the set of attributes referenced by the callout. More... | |
void | setDrawCalloutToAllParts (bool drawToAllParts) |
Sets whether callout lines should be drawn to all feature parts. More... | |
void | setLineSymbol (QgsLineSymbol *symbol) |
Sets the line symbol used to render the callout line. More... | |
void | setMinimumLength (double length) |
Sets the minimum length of callout lines. More... | |
void | setMinimumLengthMapUnitScale (const QgsMapUnitScale &scale) |
Sets the map unit scale for the minimum callout length. More... | |
void | setMinimumLengthUnit (QgsUnitTypes::RenderUnit unit) |
Sets the unit for the minimum length of callout lines. More... | |
void | setOffsetFromAnchor (double distance) |
Sets the offset distance from the anchor point at which to start the line. More... | |
void | setOffsetFromAnchorMapUnitScale (const QgsMapUnitScale &scale) |
Sets the map unit scale for the offset from anchor. More... | |
void | setOffsetFromAnchorUnit (QgsUnitTypes::RenderUnit unit) |
Sets the unit for the offset from anchor distance. More... | |
void | setOffsetFromLabel (double distance) |
Sets the offset distance from label area at which to end the line. More... | |
void | setOffsetFromLabelMapUnitScale (const QgsMapUnitScale &scale) |
Sets the map unit scale for the offset from label area. More... | |
void | setOffsetFromLabelUnit (QgsUnitTypes::RenderUnit unit) |
Sets the unit for the offset from label area distance. More... | |
void | startRender (QgsRenderContext &context) override |
Prepares the callout for rendering on the specified render context. More... | |
void | stopRender (QgsRenderContext &context) override |
Finalises the callout after a set of rendering operations on the specified render context. More... | |
QString | type () const override |
Returns a unique string representing the callout type. More... | |
Public Member Functions inherited from QgsCallout | |
QgsCallout () | |
Constructor for QgsCallout. More... | |
virtual | ~QgsCallout ()=default |
AnchorPoint | anchorPoint () const |
Returns the feature's anchor point position. 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... | |
void | render (QgsRenderContext &context, 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 | 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... | |
Static Public Member Functions | |
static QgsCallout * | create (const QVariantMap &properties=QVariantMap(), const QgsReadWriteContext &context=QgsReadWriteContext()) |
Creates a new QgsSimpleLineCallout, using the settings serialized in the properties map (corresponding to the output from QgsSimpleLineCallout::properties() ). More... | |
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. More... | |
static QString | encodeAnchorPoint (AnchorPoint anchor) |
Encodes an 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 | |
void | draw (QgsRenderContext &context, 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. More... | |
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 | Property { MinimumCalloutLength, OffsetFromAnchor, OffsetFromLabel, DrawCalloutToAllParts, AnchorPointPosition } |
Data definable properties. More... | |
QgsSimpleLineCallout::QgsSimpleLineCallout | ( | ) |
Definition at line 191 of file qgscallout.cpp.
|
overridedefault |
QgsSimpleLineCallout::QgsSimpleLineCallout | ( | const QgsSimpleLineCallout & | other | ) |
Copy constructor.
Definition at line 199 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.
Reimplemented in QgsManhattanLineCallout.
Definition at line 228 of file qgscallout.cpp.
|
static |
Creates a new QgsSimpleLineCallout, using the settings serialized in the properties map (corresponding to the output from QgsSimpleLineCallout::properties() ).
Definition at line 216 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.
Reimplemented in QgsManhattanLineCallout.
Definition at line 315 of file qgscallout.cpp.
|
inline |
Returns true
if callout lines should be drawn to all feature parts.
Definition at line 525 of file qgscallout.h.
QgsLineSymbol * QgsSimpleLineCallout::lineSymbol | ( | ) |
Returns the line symbol used to render the callout line.
Ownership is not transferred.
Definition at line 305 of file qgscallout.cpp.
|
inline |
Returns the minimum length of callout lines.
Units are specified through minimumLengthUnits().
Definition at line 392 of file qgscallout.h.
|
inline |
Returns the map unit scale for the minimum callout length.
Definition at line 429 of file qgscallout.h.
|
inline |
Returns the units for the minimum length of callout lines.
Definition at line 413 of file qgscallout.h.
|
inline |
Returns the offset distance from the anchor point at which to start the line.
Units are specified through offsetFromAnchorUnit().
Definition at line 437 of file qgscallout.h.
|
inline |
Returns the map unit scale for the offset from anchor.
Definition at line 474 of file qgscallout.h.
|
inline |
Returns the units for the offset from anchor point.
Definition at line 458 of file qgscallout.h.
|
inline |
Returns the offset distance from label area at which to end the line.
Units are specified through offsetFromLabelUnit().
Definition at line 481 of file qgscallout.h.
|
inline |
Returns the map unit scale for the minimum callout length.
Definition at line 518 of file qgscallout.h.
|
inline |
Returns the units for the offset from label area.
Definition at line 502 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 233 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 257 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 297 of file qgscallout.cpp.
|
inline |
Sets whether callout lines should be drawn to all feature parts.
Definition at line 532 of file qgscallout.h.
void QgsSimpleLineCallout::setLineSymbol | ( | QgsLineSymbol * | symbol | ) |
Sets the line symbol used to render the callout line.
Ownership of symbol is transferred to the callout.
Definition at line 310 of file qgscallout.cpp.
|
inline |
Sets the minimum length of callout lines.
Units are specified through setMinimumLengthUnit().
Definition at line 399 of file qgscallout.h.
|
inline |
Sets the map unit scale for the minimum callout length.
Definition at line 421 of file qgscallout.h.
|
inline |
Sets the unit for the minimum length of callout lines.
Definition at line 406 of file qgscallout.h.
|
inline |
Sets the offset distance from the anchor point at which to start the line.
Units are specified through setOffsetFromAnchorUnit().
Definition at line 444 of file qgscallout.h.
|
inline |
Sets the map unit scale for the offset from anchor.
Definition at line 466 of file qgscallout.h.
|
inline |
Sets the unit for the offset from anchor distance.
Definition at line 451 of file qgscallout.h.
|
inline |
Sets the offset distance from label area at which to end the line.
Units are specified through setOffsetFromLabelUnit().
Definition at line 488 of file qgscallout.h.
|
inline |
Sets the map unit scale for the offset from label area.
Definition at line 510 of file qgscallout.h.
|
inline |
Sets the unit for the offset from label area distance.
Definition at line 495 of file qgscallout.h.
|
overridevirtual |
Prepares the callout for rendering on the specified render context.
Reimplemented from QgsCallout.
Definition at line 283 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 290 of file qgscallout.cpp.
|
overridevirtual |
Returns a unique string representing the callout type.
Implements QgsCallout.
Reimplemented in QgsManhattanLineCallout.
Definition at line 223 of file qgscallout.cpp.