QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
QgsSimpleLineCallout Class Reference

A simple direct line callout style. More...

#include <qgscallout.h>

Inheritance diagram for QgsSimpleLineCallout:
Inheritance graph
[legend]

Public Member Functions

 QgsSimpleLineCallout ()
 
 QgsSimpleLineCallout (const QgsSimpleLineCallout &other)
 
 ~QgsSimpleLineCallout () override
 
QgsSimpleLineCalloutclone () const override
 Duplicates a callout by creating a deep copy of the callout.
 
bool drawCalloutToAllParts () const
 Returns true if callout lines should be drawn to all feature parts.
 
QgsLineSymbollineSymbol ()
 Returns the line symbol used to render the callout line.
 
double minimumLength () const
 Returns the minimum length of callout lines.
 
const QgsMapUnitScaleminimumLengthMapUnitScale () const
 Returns the map unit scale for the minimum callout length.
 
Qgis::RenderUnit minimumLengthUnit () const
 Returns the units for the minimum length of callout lines.
 
double offsetFromAnchor () const
 Returns the offset distance from the anchor point at which to start the line.
 
const QgsMapUnitScaleoffsetFromAnchorMapUnitScale () const
 Returns the map unit scale for the offset from anchor.
 
Qgis::RenderUnit offsetFromAnchorUnit () const
 Returns the units for the offset from anchor point.
 
double offsetFromLabel () const
 Returns the offset distance from label area at which to end the line.
 
const QgsMapUnitScaleoffsetFromLabelMapUnitScale () const
 Returns the map unit scale for the minimum callout length.
 
Qgis::RenderUnit offsetFromLabelUnit () const
 Returns the units for the offset from label area.
 
QgsSimpleLineCalloutoperator= (const QgsSimpleLineCallout &)=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 setDrawCalloutToAllParts (bool drawToAllParts)
 Sets whether callout lines should be drawn to all feature parts.
 
void setLineSymbol (QgsLineSymbol *symbol)
 Sets the line symbol used to render the callout line.
 
void setMinimumLength (double length)
 Sets the minimum length of callout lines.
 
void setMinimumLengthMapUnitScale (const QgsMapUnitScale &scale)
 Sets the map unit scale for the minimum callout length.
 
void setMinimumLengthUnit (Qgis::RenderUnit unit)
 Sets the unit for the minimum length of callout lines.
 
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 setOffsetFromLabel (double distance)
 Sets the offset distance from label area at which to end the line.
 
void setOffsetFromLabelMapUnitScale (const QgsMapUnitScale &scale)
 Sets the map unit scale for the offset from label area.
 
void setOffsetFromLabelUnit (Qgis::RenderUnit unit)
 Sets the unit for the offset from label area distance.
 
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.
 
- 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.
 
QgsPropertyCollectiondataDefinedProperties ()
 Returns a reference to the callout's property collection, used for data defined overrides.
 
const QgsPropertyCollectiondataDefinedProperties () 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 QgsCalloutcreate (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() ).
 
- 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

virtual QgsCurvecreateCalloutLine (const QgsPoint &start, const QgsPoint &end, QgsRenderContext &context, const QRectF &bodyBoundingBox, const double angle, const QgsGeometry &anchor, QgsCallout::QgsCalloutContext &calloutContext) const
 Creates a callout line between start and end in the desired style.
 
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...
 

Detailed Description

A simple direct line callout style.

Since
QGIS 3.10

Definition at line 513 of file qgscallout.h.

Constructor & Destructor Documentation

◆ QgsSimpleLineCallout() [1/2]

QgsSimpleLineCallout::QgsSimpleLineCallout ( )

Definition at line 531 of file qgscallout.cpp.

◆ ~QgsSimpleLineCallout()

QgsSimpleLineCallout::~QgsSimpleLineCallout ( )
overridedefault

◆ QgsSimpleLineCallout() [2/2]

QgsSimpleLineCallout::QgsSimpleLineCallout ( const QgsSimpleLineCallout other)

Definition at line 539 of file qgscallout.cpp.

Member Function Documentation

◆ clone()

QgsSimpleLineCallout * QgsSimpleLineCallout::clone ( ) const
overridevirtual

Duplicates a callout by creating a deep copy of the callout.

Caller takes ownership of the returned object.

Implements QgsCallout.

Definition at line 568 of file qgscallout.cpp.

◆ create()

QgsCallout * QgsSimpleLineCallout::create ( const QVariantMap &  properties = QVariantMap(),
const QgsReadWriteContext context = QgsReadWriteContext() 
)
static

Creates a new QgsSimpleLineCallout, using the settings serialized in the properties map (corresponding to the output from QgsSimpleLineCallout::properties() ).

Definition at line 556 of file qgscallout.cpp.

◆ createCalloutLine()

QgsCurve * QgsSimpleLineCallout::createCalloutLine ( const QgsPoint start,
const QgsPoint end,
QgsRenderContext context,
const QRectF &  bodyBoundingBox,
const double  angle,
const QgsGeometry anchor,
QgsCallout::QgsCalloutContext calloutContext 
) const
protectedvirtual

Creates a callout line between start and end in the desired style.

The base class method returns a straight line.

Since
QGIS 3.20

Reimplemented in QgsManhattanLineCallout, and QgsCurvedLineCallout.

Definition at line 745 of file qgscallout.cpp.

◆ draw()

void QgsSimpleLineCallout::draw ( QgsRenderContext context,
const QRectF &  bodyBoundingBox,
const double  angle,
const QgsGeometry anchor,
QgsCallout::QgsCalloutContext calloutContext 
)
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 655 of file qgscallout.cpp.

◆ drawCalloutToAllParts()

bool QgsSimpleLineCallout::drawCalloutToAllParts ( ) const
inline

Returns true if callout lines should be drawn to all feature parts.

See also
setDrawCalloutToAllParts()

Definition at line 695 of file qgscallout.h.

◆ lineSymbol()

QgsLineSymbol * QgsSimpleLineCallout::lineSymbol ( )

Returns the line symbol used to render the callout line.

Ownership is not transferred.

See also
setLineSymbol()

Definition at line 645 of file qgscallout.cpp.

◆ minimumLength()

double QgsSimpleLineCallout::minimumLength ( ) const
inline

Returns the minimum length of callout lines.

Units are specified through minimumLengthUnits().

See also
setMinimumLength()
minimumLengthUnit()

Definition at line 562 of file qgscallout.h.

◆ minimumLengthMapUnitScale()

const QgsMapUnitScale & QgsSimpleLineCallout::minimumLengthMapUnitScale ( ) const
inline

Returns the map unit scale for the minimum callout length.

See also
setMinimumLengthMapUnitScale()
minimumLengthUnit()
minimumLength()

Definition at line 599 of file qgscallout.h.

◆ minimumLengthUnit()

Qgis::RenderUnit QgsSimpleLineCallout::minimumLengthUnit ( ) const
inline

Returns the units for the minimum length of callout lines.

See also
setMinimumLengthUnit()
minimumLength()

Definition at line 583 of file qgscallout.h.

◆ offsetFromAnchor()

double QgsSimpleLineCallout::offsetFromAnchor ( ) const
inline

Returns the offset distance from the anchor point at which to start the line.

Units are specified through offsetFromAnchorUnit().

See also
setOffsetFromAnchor()
offsetFromAnchorUnit()

Definition at line 607 of file qgscallout.h.

◆ offsetFromAnchorMapUnitScale()

const QgsMapUnitScale & QgsSimpleLineCallout::offsetFromAnchorMapUnitScale ( ) const
inline

Returns the map unit scale for the offset from anchor.

See also
setOffsetFromAnchorMapUnitScale()
offsetFromAnchorUnit()
offsetFromAnchor()

Definition at line 644 of file qgscallout.h.

◆ offsetFromAnchorUnit()

Qgis::RenderUnit QgsSimpleLineCallout::offsetFromAnchorUnit ( ) const
inline

Returns the units for the offset from anchor point.

See also
setOffsetFromAnchorUnit()
offsetFromAnchor()

Definition at line 628 of file qgscallout.h.

◆ offsetFromLabel()

double QgsSimpleLineCallout::offsetFromLabel ( ) const
inline

Returns the offset distance from label area at which to end the line.

Units are specified through offsetFromLabelUnit().

See also
setOffsetFromLabel()
offsetFromLabelUnit()

Definition at line 651 of file qgscallout.h.

◆ offsetFromLabelMapUnitScale()

const QgsMapUnitScale & QgsSimpleLineCallout::offsetFromLabelMapUnitScale ( ) const
inline

Returns the map unit scale for the minimum callout length.

See also
setOffsetFromLabelMapUnitScale()
offsetFromLabelUnit()
offsetFromLabel()

Definition at line 688 of file qgscallout.h.

◆ offsetFromLabelUnit()

Qgis::RenderUnit QgsSimpleLineCallout::offsetFromLabelUnit ( ) const
inline

Returns the units for the offset from label area.

See also
setOffsetFromLabelUnit()
offsetFromLabel()

Definition at line 672 of file qgscallout.h.

◆ operator=()

QgsSimpleLineCallout & QgsSimpleLineCallout::operator= ( const QgsSimpleLineCallout )
delete

◆ properties()

QVariantMap QgsSimpleLineCallout::properties ( const QgsReadWriteContext context) const
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.

See also
readProperties()
saveProperties()

Reimplemented from QgsCallout.

Definition at line 573 of file qgscallout.cpp.

◆ readProperties()

void QgsSimpleLineCallout::readProperties ( const QVariantMap &  props,
const QgsReadWriteContext context 
)
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.

See also
properties()

Reimplemented from QgsCallout.

Definition at line 597 of file qgscallout.cpp.

◆ referencedFields()

QSet< QString > QgsSimpleLineCallout::referencedFields ( const QgsRenderContext context) const
overridevirtual

Returns the set of attributes referenced by the callout.

This includes attributes required by any data defined properties associated with the callout.

Warning
This must only be called after a corresponding call to startRender() with the same render context.

Reimplemented from QgsCallout.

Definition at line 637 of file qgscallout.cpp.

◆ setDrawCalloutToAllParts()

void QgsSimpleLineCallout::setDrawCalloutToAllParts ( bool  drawToAllParts)
inline

Sets whether callout lines should be drawn to all feature parts.

See also
drawCalloutToAllParts()

Definition at line 702 of file qgscallout.h.

◆ setLineSymbol()

void QgsSimpleLineCallout::setLineSymbol ( QgsLineSymbol symbol)

Sets the line symbol used to render the callout line.

Ownership of symbol is transferred to the callout.

See also
lineSymbol()

Definition at line 650 of file qgscallout.cpp.

◆ setMinimumLength()

void QgsSimpleLineCallout::setMinimumLength ( double  length)
inline

Sets the minimum length of callout lines.

Units are specified through setMinimumLengthUnit().

See also
minimumLength()
setMinimumLengthUnit()

Definition at line 569 of file qgscallout.h.

◆ setMinimumLengthMapUnitScale()

void QgsSimpleLineCallout::setMinimumLengthMapUnitScale ( const QgsMapUnitScale scale)
inline

Sets the map unit scale for the minimum callout length.

See also
minimumLengthMapUnitScale()
setMinimumLengthUnit()
setMinimumLength()

Definition at line 591 of file qgscallout.h.

◆ setMinimumLengthUnit()

void QgsSimpleLineCallout::setMinimumLengthUnit ( Qgis::RenderUnit  unit)
inline

Sets the unit for the minimum length of callout lines.

See also
minimumLengthUnit()
setMinimumLength()

Definition at line 576 of file qgscallout.h.

◆ setOffsetFromAnchor()

void QgsSimpleLineCallout::setOffsetFromAnchor ( double  distance)
inline

Sets the offset distance from the anchor point at which to start the line.

Units are specified through setOffsetFromAnchorUnit().

See also
offsetFromAnchor()
setOffsetFromAnchorUnit()

Definition at line 614 of file qgscallout.h.

◆ setOffsetFromAnchorMapUnitScale()

void QgsSimpleLineCallout::setOffsetFromAnchorMapUnitScale ( const QgsMapUnitScale scale)
inline

Sets the map unit scale for the offset from anchor.

See also
offsetFromAnchorMapUnitScale()
setOffsetFromAnchorUnit()
setOffsetFromAnchor()

Definition at line 636 of file qgscallout.h.

◆ setOffsetFromAnchorUnit()

void QgsSimpleLineCallout::setOffsetFromAnchorUnit ( Qgis::RenderUnit  unit)
inline

Sets the unit for the offset from anchor distance.

See also
offsetFromAnchor()
setOffsetFromAnchor()

Definition at line 621 of file qgscallout.h.

◆ setOffsetFromLabel()

void QgsSimpleLineCallout::setOffsetFromLabel ( double  distance)
inline

Sets the offset distance from label area at which to end the line.

Units are specified through setOffsetFromLabelUnit().

See also
offsetFromLabel()
setOffsetFromLabelUnit()

Definition at line 658 of file qgscallout.h.

◆ setOffsetFromLabelMapUnitScale()

void QgsSimpleLineCallout::setOffsetFromLabelMapUnitScale ( const QgsMapUnitScale scale)
inline

Sets the map unit scale for the offset from label area.

See also
offsetFromLabelMapUnitScale()
setOffsetFromLabelUnit()
setOffsetFromLabel()

Definition at line 680 of file qgscallout.h.

◆ setOffsetFromLabelUnit()

void QgsSimpleLineCallout::setOffsetFromLabelUnit ( Qgis::RenderUnit  unit)
inline

Sets the unit for the offset from label area distance.

See also
offsetFromLabel()
setOffsetFromLabel()

Definition at line 665 of file qgscallout.h.

◆ startRender()

void QgsSimpleLineCallout::startRender ( QgsRenderContext context)
overridevirtual

Prepares the callout for rendering on the specified render context.

Warning
This MUST be called prior to calling render() on the callout, and must always be accompanied by a corresponding call to stopRender().
See also
stopRender()

Reimplemented from QgsCallout.

Definition at line 623 of file qgscallout.cpp.

◆ stopRender()

void QgsSimpleLineCallout::stopRender ( QgsRenderContext context)
overridevirtual

Finalises the callout after a set of rendering operations on the specified render context.

Warning
This MUST be called after to after render() operations on the callout, and must always be accompanied by a corresponding prior call to startRender().
See also
startRender()

Reimplemented from QgsCallout.

Definition at line 630 of file qgscallout.cpp.

◆ type()

QString QgsSimpleLineCallout::type ( ) const
overridevirtual

Returns a unique string representing the callout type.

Implements QgsCallout.

Definition at line 563 of file qgscallout.cpp.


The documentation for this class was generated from the following files: