QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgscallout.h
Go to the documentation of this file.
1/***************************************************************************
2 qgscallout.h
3 ----------------
4 begin : July 2019
5 copyright : (C) 2019 Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17#ifndef QGSCALLOUT_H
18#define QGSCALLOUT_H
19
20#include <memory>
21
22#include "qgis.h"
23#include "qgis_core.h"
24#include "qgis_sip.h"
25#include "qgscalloutposition.h"
27#include "qgsmapunitscale.h"
28#include "qgsmargins.h"
30#include "qgsreadwritecontext.h"
31
32#include <QPainter>
33#include <QRectF>
34#include <QString>
35
36class QgsLineSymbol;
37class QgsMarkerSymbol;
38class QgsFillSymbol;
39class QgsGeometry;
41
42class QgsCalloutWidget; //stop sip breaking
43
54class CORE_EXPORT QgsCallout
55{
56
57#ifdef SIP_RUN
59 if ( sipCpp->type() == "simple" && dynamic_cast<QgsSimpleLineCallout *>( sipCpp ) != NULL )
60 {
61 sipType = sipType_QgsSimpleLineCallout;
62 }
63 else if ( sipCpp->type() == "manhattan" && dynamic_cast<QgsManhattanLineCallout *>( sipCpp ) != NULL )
64 {
65 sipType = sipType_QgsManhattanLineCallout;
66 }
67 else if ( sipCpp->type() == "curved" && dynamic_cast<QgsCurvedLineCallout *>( sipCpp ) != NULL )
68 {
69 sipType = sipType_QgsCurvedLineCallout;
70 }
71 else if ( sipCpp->type() == "balloon" && dynamic_cast<QgsBalloonCallout *>( sipCpp ) != NULL )
72 {
73 sipType = sipType_QgsBalloonCallout;
74 }
75 else
76 {
77 sipType = 0;
78 }
80#endif
81
82 public:
83
84 // *INDENT-OFF*
87 {
88 MinimumCalloutLength,
89 OffsetFromAnchor,
90 OffsetFromLabel,
91 DrawCalloutToAllParts,
92 AnchorPointPosition,
93 LabelAnchorPointPosition,
94 OriginX,
95 OriginY,
96 DestinationX,
97 DestinationY,
98 Curvature,
99 Orientation,
100 Margins,
101 WedgeWidth,
102 CornerRadius,
103 BlendMode,
104 };
105 // *INDENT-ON*
106
113
122
140
144 QgsCallout();
145 virtual ~QgsCallout() = default;
146
150 virtual QString type() const = 0;
151
157 virtual QgsCallout *clone() const = 0 SIP_FACTORY;
158
169 virtual QVariantMap properties( const QgsReadWriteContext &context ) const;
170
180 virtual void readProperties( const QVariantMap &props, const QgsReadWriteContext &context );
181
189 virtual bool saveProperties( QDomDocument &doc, QDomElement &element, const QgsReadWriteContext &context ) const;
190
198 virtual void restoreProperties( const QDomElement &element, const QgsReadWriteContext &context );
199
205 bool containsAdvancedEffects() const;
206
215 virtual void startRender( QgsRenderContext &context );
216
225 virtual void stopRender( QgsRenderContext &context );
226
234 virtual QSet< QString > referencedFields( const QgsRenderContext &context ) const;
235
241 virtual DrawOrder drawOrder() const;
242
249 class CORE_EXPORT QgsCalloutContext
250 {
251 public:
254
261
269
280 void addCalloutPosition( const QgsCalloutPosition &position ) { return mPositions.push_back( position ); }
281
287 QList< QgsCalloutPosition > positions() const { return mPositions; }
288
289 private:
291 mutable QgsCoordinateTransform mOriginalFeatureToMapTransform;
292
293 QList< QgsCalloutPosition > mPositions;
294 };
295
317 void render( QgsRenderContext &context, const QRectF &rect, const double angle, const QgsGeometry &anchor, QgsCalloutContext &calloutContext );
318
323 bool enabled() const { return mEnabled; }
324
329 void setEnabled( bool enabled );
330
335 QgsPropertyCollection &dataDefinedProperties() { return mDataDefinedProperties; }
336
343 const QgsPropertyCollection &dataDefinedProperties() const SIP_SKIP { return mDataDefinedProperties; }
344
353 void setDataDefinedProperties( const QgsPropertyCollection &collection ) { mDataDefinedProperties = collection; }
354
358 static QgsPropertiesDefinition propertyDefinitions();
359
365 AnchorPoint anchorPoint() const { return mAnchorPoint; }
366
372 void setAnchorPoint( AnchorPoint anchor ) { mAnchorPoint = anchor; }
373
379 static QString encodeAnchorPoint( AnchorPoint anchor );
380
389 static QgsCallout::AnchorPoint decodeAnchorPoint( const QString &name, bool *ok = nullptr );
390
391
398 LabelAnchorPoint labelAnchorPoint() const { return mLabelAnchorPoint; }
399
406 void setLabelAnchorPoint( LabelAnchorPoint anchor ) { mLabelAnchorPoint = anchor; }
407
414 static QString encodeLabelAnchorPoint( LabelAnchorPoint anchor );
415
425 static QgsCallout::LabelAnchorPoint decodeLabelAnchorPoint( const QString &name, bool *ok = nullptr );
426
432 QPainter::CompositionMode blendMode() const { return mBlendMode; }
433
439 void setBlendMode( QPainter::CompositionMode mode ) { mBlendMode = mode; }
440
441 protected:
442
461 virtual void draw( QgsRenderContext &context, const QRectF &bodyBoundingBox, const double angle, const QgsGeometry &anchor, QgsCalloutContext &calloutContext ) = 0;
462
467 Q_DECL_DEPRECATED QgsGeometry labelAnchorGeometry( const QRectF &bodyBoundingBox, const double angle, LabelAnchorPoint anchor ) const SIP_DEPRECATED;
468
476 QgsGeometry calloutLabelPoint( const QRectF &bodyBoundingBox, double angle, LabelAnchorPoint anchor, QgsRenderContext &context, const QgsCalloutContext &calloutContext, bool &pinned ) const;
477
488 QgsGeometry calloutLineToPart( const QgsGeometry &labelGeometry, const QgsAbstractGeometry *partGeometry, QgsRenderContext &context, const QgsCalloutContext &calloutContext, bool &pinned ) const;
489
490 private:
491
492 bool mEnabled = false;
493
494 AnchorPoint mAnchorPoint = PoleOfInaccessibility;
495 LabelAnchorPoint mLabelAnchorPoint = LabelPointOnExterior;
496
497 QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
498
500 QgsPropertyCollection mDataDefinedProperties;
501
503 static QgsPropertiesDefinition sPropertyDefinitions;
504
505 static void initPropertyDefinitions();
506};
507
514class CORE_EXPORT QgsSimpleLineCallout : public QgsCallout
515{
516 public:
517
520
521#ifndef SIP_RUN
524#endif
525
531 static QgsCallout *create( const QVariantMap &properties = QVariantMap(), const QgsReadWriteContext &context = QgsReadWriteContext() ) SIP_FACTORY;
532
533 QString type() const override;
534 QgsSimpleLineCallout *clone() const override;
535 QVariantMap properties( const QgsReadWriteContext &context ) const override;
536 void readProperties( const QVariantMap &props, const QgsReadWriteContext &context ) override;
537 void startRender( QgsRenderContext &context ) override;
538 void stopRender( QgsRenderContext &context ) override;
539 QSet< QString > referencedFields( const QgsRenderContext &context ) const override;
540
549
557
563 double minimumLength() const { return mMinCalloutLength; }
564
570 void setMinimumLength( double length ) { mMinCalloutLength = length; }
571
577 void setMinimumLengthUnit( Qgis::RenderUnit unit ) { mMinCalloutLengthUnit = unit; }
578
584 Qgis::RenderUnit minimumLengthUnit() const { return mMinCalloutLengthUnit; }
585
592 void setMinimumLengthMapUnitScale( const QgsMapUnitScale &scale ) { mMinCalloutLengthScale = scale; }
593
600 const QgsMapUnitScale &minimumLengthMapUnitScale() const { return mMinCalloutLengthScale; }
601
602
608 double offsetFromAnchor() const { return mOffsetFromAnchorDistance; }
609
615 void setOffsetFromAnchor( double distance ) { mOffsetFromAnchorDistance = distance; }
616
622 void setOffsetFromAnchorUnit( Qgis::RenderUnit unit ) { mOffsetFromAnchorUnit = unit; }
623
629 Qgis::RenderUnit offsetFromAnchorUnit() const { return mOffsetFromAnchorUnit; }
630
637 void setOffsetFromAnchorMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetFromAnchorScale = scale; }
638
645 const QgsMapUnitScale &offsetFromAnchorMapUnitScale() const { return mOffsetFromAnchorScale; }
646
652 double offsetFromLabel() const { return mOffsetFromLabelDistance; }
653
659 void setOffsetFromLabel( double distance ) { mOffsetFromLabelDistance = distance; }
660
666 void setOffsetFromLabelUnit( Qgis::RenderUnit unit ) { mOffsetFromLabelUnit = unit; }
667
673 Qgis::RenderUnit offsetFromLabelUnit() const { return mOffsetFromLabelUnit; }
674
681 void setOffsetFromLabelMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetFromLabelScale = scale; }
682
689 const QgsMapUnitScale &offsetFromLabelMapUnitScale() const { return mOffsetFromLabelScale; }
690
696 bool drawCalloutToAllParts() const { return mDrawCalloutToAllParts; }
697
703 void setDrawCalloutToAllParts( bool drawToAllParts ) { mDrawCalloutToAllParts = drawToAllParts; }
704
705 protected:
706 void draw( QgsRenderContext &context, const QRectF &bodyBoundingBox, const double angle, const QgsGeometry &anchor, QgsCallout::QgsCalloutContext &calloutContext ) override;
707
715 virtual QgsCurve *createCalloutLine( const QgsPoint &start, const QgsPoint &end, QgsRenderContext &context, const QRectF &bodyBoundingBox, const double angle, const QgsGeometry &anchor, QgsCallout::QgsCalloutContext &calloutContext ) const SIP_FACTORY;
716
717 private:
718
719#ifdef SIP_RUN
721 QgsSimpleLineCallout &operator=( const QgsSimpleLineCallout & );
722#endif
723
724 std::unique_ptr< QgsLineSymbol > mLineSymbol;
725 double mMinCalloutLength = 0;
726 Qgis::RenderUnit mMinCalloutLengthUnit = Qgis::RenderUnit::Millimeters;
727 QgsMapUnitScale mMinCalloutLengthScale;
728
729 double mOffsetFromAnchorDistance = 0;
730 Qgis::RenderUnit mOffsetFromAnchorUnit = Qgis::RenderUnit::Millimeters;
731 QgsMapUnitScale mOffsetFromAnchorScale;
732
733 double mOffsetFromLabelDistance = 0;
734 Qgis::RenderUnit mOffsetFromLabelUnit = Qgis::RenderUnit::Millimeters;
735 QgsMapUnitScale mOffsetFromLabelScale;
736
737 bool mDrawCalloutToAllParts = false;
738};
739
740
748{
749 public:
750
752
753#ifndef SIP_RUN
756#endif
757
763 static QgsCallout *create( const QVariantMap &properties = QVariantMap(), const QgsReadWriteContext &context = QgsReadWriteContext() ) SIP_FACTORY; // cppcheck-suppress duplInheritedMember
764
765 QString type() const override;
766 QgsManhattanLineCallout *clone() const override;
767
768 protected:
769 QgsCurve *createCalloutLine( const QgsPoint &start, const QgsPoint &end, QgsRenderContext &context, const QRectF &bodyBoundingBox, const double angle, const QgsGeometry &anchor, QgsCallout::QgsCalloutContext &calloutContext ) const override SIP_FACTORY;
770
771 private:
772#ifdef SIP_RUN
775#endif
776};
777
778
786{
787 public:
788
798
800
801#ifndef SIP_RUN
804#endif
805
811 static QgsCallout *create( const QVariantMap &properties = QVariantMap(), const QgsReadWriteContext &context = QgsReadWriteContext() ) SIP_FACTORY; // cppcheck-suppress duplInheritedMember
812
813 QString type() const override;
814 QgsCurvedLineCallout *clone() const override;
815 QVariantMap properties( const QgsReadWriteContext &context ) const override;
816
824 double curvature() const;
825
833 void setCurvature( double curvature );
834
840 Orientation orientation() const;
841
848
849 protected:
850 QgsCurve *createCalloutLine( const QgsPoint &start, const QgsPoint &end, QgsRenderContext &context, const QRectF &bodyBoundingBox, const double angle, const QgsGeometry &anchor, QgsCalloutContext &calloutContext ) const override SIP_FACTORY;
851
852 private:
853#ifdef SIP_RUN
856#endif
857
861 static Orientation decodeOrientation( const QString &string );
862
866 static QString encodeOrientation( Orientation orientation );
867
868
869 Orientation mOrientation = Automatic;
870 double mCurvature = 0.1;
871};
872
873
880class CORE_EXPORT QgsBalloonCallout : public QgsCallout
881{
882 public:
883
886
887#ifndef SIP_RUN
888 QgsBalloonCallout( const QgsBalloonCallout &other );
890#endif
891
897 static QgsCallout *create( const QVariantMap &properties = QVariantMap(), const QgsReadWriteContext &context = QgsReadWriteContext() ) SIP_FACTORY;
898
899 QString type() const override;
900 QgsBalloonCallout *clone() const override;
901 QVariantMap properties( const QgsReadWriteContext &context ) const override;
902 void readProperties( const QVariantMap &props, const QgsReadWriteContext &context ) override;
903 void startRender( QgsRenderContext &context ) override;
904 void stopRender( QgsRenderContext &context ) override;
905 QSet< QString > referencedFields( const QgsRenderContext &context ) const override;
906
915
923
937
950
956 double offsetFromAnchor() const { return mOffsetFromAnchorDistance; }
957
963 void setOffsetFromAnchor( double distance ) { mOffsetFromAnchorDistance = distance; }
964
970 void setOffsetFromAnchorUnit( Qgis::RenderUnit unit ) { mOffsetFromAnchorUnit = unit; }
971
977 Qgis::RenderUnit offsetFromAnchorUnit() const { return mOffsetFromAnchorUnit; }
978
985 void setOffsetFromAnchorMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetFromAnchorScale = scale; }
986
993 const QgsMapUnitScale &offsetFromAnchorMapUnitScale() const { return mOffsetFromAnchorScale; }
994
1005 const QgsMargins &margins() const { return mMargins; }
1006
1017 void setMargins( const QgsMargins &margins ) { mMargins = margins; }
1018
1025 void setMarginsUnit( Qgis::RenderUnit unit ) { mMarginUnit = unit; }
1026
1033 Qgis::RenderUnit marginsUnit() const { return mMarginUnit; }
1034
1043 double wedgeWidth() const { return mWedgeWidth; }
1044
1053 void setWedgeWidth( double width ) { mWedgeWidth = width; }
1054
1061 void setWedgeWidthUnit( Qgis::RenderUnit unit ) { mWedgeWidthUnit = unit; }
1062
1069 Qgis::RenderUnit wedgeWidthUnit() const { return mWedgeWidthUnit; }
1070
1078 void setWedgeWidthMapUnitScale( const QgsMapUnitScale &scale ) { mWedgeWidthScale = scale; }
1079
1087 const QgsMapUnitScale &wedgeWidthMapUnitScale() const { return mWedgeWidthScale; }
1088
1097 double cornerRadius() const { return mCornerRadius; }
1098
1107 void setCornerRadius( double radius ) { mCornerRadius = radius; }
1108
1115 void setCornerRadiusUnit( Qgis::RenderUnit unit ) { mCornerRadiusUnit = unit; }
1116
1123 Qgis::RenderUnit cornerRadiusUnit() const { return mCornerRadiusUnit; }
1124
1132 void setCornerRadiusMapUnitScale( const QgsMapUnitScale &scale ) { mCornerRadiusScale = scale; }
1133
1141 const QgsMapUnitScale &cornerRadiusMapUnitScale() const { return mCornerRadiusScale; }
1142
1143
1144 protected:
1145 void draw( QgsRenderContext &context, const QRectF &bodyBoundingBox, const double angle, const QgsGeometry &anchor, QgsCallout::QgsCalloutContext &calloutContext ) override;
1146
1147 private:
1148
1149 QPolygonF getPoints( QgsRenderContext &context, QgsPointXY origin, QRectF rect ) const;
1150
1151#ifdef SIP_RUN
1152 QgsBalloonCallout( const QgsBalloonCallout &other );
1153 QgsBalloonCallout &operator=( const QgsBalloonCallout & );
1154#endif
1155
1156 std::unique_ptr< QgsFillSymbol > mFillSymbol;
1157 std::unique_ptr< QgsMarkerSymbol > mMarkerSymbol;
1158
1159 double mOffsetFromAnchorDistance = 0;
1160 Qgis::RenderUnit mOffsetFromAnchorUnit = Qgis::RenderUnit::Millimeters;
1161 QgsMapUnitScale mOffsetFromAnchorScale;
1162
1163 QgsMargins mMargins;
1165
1166 double mWedgeWidth = 2.64;
1168 QgsMapUnitScale mWedgeWidthScale;
1169
1170 double mCornerRadius = 0.0;
1172 QgsMapUnitScale mCornerRadiusScale;
1173
1174};
1175
1176
1177
1178#endif // QGSCALLOUT_H
1179
RenderUnit
Rendering size units.
Definition qgis.h:5183
@ Millimeters
Millimeters.
Definition qgis.h:5184
Abstract base class for all geometries.
A cartoon talking bubble callout style.
Definition qgscallout.h:881
QgsFillSymbol * fillSymbol()
Returns the fill symbol used to render the callout.
void setCornerRadius(double radius)
Sets the radius of the corners for the balloon shapes.
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.
QgsBalloonCallout & operator=(const QgsBalloonCallout &)=delete
double cornerRadius() const
Returns the corner radius of the balloon shapes.
void setCornerRadiusUnit(Qgis::RenderUnit unit)
Sets the unit for the corner radius.
Qgis::RenderUnit wedgeWidthUnit() const
Returns the units for the wedge width.
void setOffsetFromAnchorUnit(Qgis::RenderUnit unit)
Sets the unit for the offset from anchor distance.
Definition qgscallout.h:970
QString type() const override
Returns a unique string representing the callout type.
void setMarginsUnit(Qgis::RenderUnit unit)
Sets the unit for the margins between the outside of the callout frame and the label's bounding recta...
void setCornerRadiusMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the corner radius.
QgsMarkerSymbol * markerSymbol()
Returns the marker symbol used to render the callout endpoint.
void startRender(QgsRenderContext &context) override
Prepares the callout for rendering on the specified render context.
QSet< QString > referencedFields(const QgsRenderContext &context) const override
Returns the set of attributes referenced by the callout.
Qgis::RenderUnit offsetFromAnchorUnit() const
Returns the units for the offset from anchor point.
Definition qgscallout.h:977
void stopRender(QgsRenderContext &context) override
Finalises the callout after a set of rendering operations on the specified render context.
const QgsMapUnitScale & offsetFromAnchorMapUnitScale() const
Returns the map unit scale for the offset from anchor.
Definition qgscallout.h:993
const QgsMargins & margins() const
Returns the margins between the outside of the callout frame and the label's bounding rectangle.
QVariantMap properties(const QgsReadWriteContext &context) const override
Returns the properties describing the callout encoded in a string format.
void setWedgeWidthUnit(Qgis::RenderUnit unit)
Sets the unit for the wedge width.
void setOffsetFromAnchor(double distance)
Sets the offset distance from the anchor point at which to start the line.
Definition qgscallout.h:963
void setFillSymbol(QgsFillSymbol *symbol)
Sets the fill symbol used to render the callout.
Qgis::RenderUnit marginsUnit() const
Returns the units for the margins between the outside of the callout frame and the label's bounding r...
void setWedgeWidth(double width)
Sets the width of the wedge shape at the side it connects with the label.
void setOffsetFromAnchorMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the offset from anchor.
Definition qgscallout.h:985
const QgsMapUnitScale & cornerRadiusMapUnitScale() const
Returns the map unit scale for the corner radius.
Qgis::RenderUnit cornerRadiusUnit() const
Returns the units for the corner radius.
void setMargins(const QgsMargins &margins)
Sets 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 setWedgeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the wedge width.
~QgsBalloonCallout() override
QgsBalloonCallout * clone() const override
Duplicates a callout by creating a deep copy of the callout.
static QgsCallout * create(const QVariantMap &properties=QVariantMap(), const QgsReadWriteContext &context=QgsReadWriteContext())
Creates a new QgsBalloonCallout, using the settings serialized in the properties map (corresponding t...
double offsetFromAnchor() const
Returns the offset distance from the anchor point at which to start the line.
Definition qgscallout.h:956
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 ...
Represents the calculated placement of a map label callout line.
Base class for widgets which allow control over the properties of callouts.
Contains additional contextual information about the context in which a callout is being rendered.
Definition qgscallout.h:250
QgsCoordinateTransform originalFeatureToMapTransform(const QgsRenderContext &renderContext) const
Returns the coordinate transform to convert from the original layer associated with the callout to th...
void addCalloutPosition(const QgsCalloutPosition &position)
Adds a rendered callout position.
Definition qgscallout.h:280
bool allFeaturePartsLabeled
true if all parts of associated feature were labeled
Definition qgscallout.h:253
QList< QgsCalloutPosition > positions() const
Returns the list of rendered callout positions.
Definition qgscallout.h:287
QgsCoordinateReferenceSystem originalFeatureCrs
Contains the CRS of the original feature associated with this callout.
Definition qgscallout.h:260
Abstract base class for callout renderers.
Definition qgscallout.h:55
bool containsAdvancedEffects() const
Returns true if the callout requires advanced effects such as blend modes, which require output in ra...
virtual bool saveProperties(QDomDocument &doc, QDomElement &element, const QgsReadWriteContext &context) const
Saves the current state of the callout to a DOM element.
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the callout's property collection, used for data defined overrides.
Definition qgscallout.h:353
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing callouts.
Definition qgscallout.h:439
virtual ~QgsCallout()=default
virtual void stopRender(QgsRenderContext &context)
Finalises the callout after a set of rendering operations on the specified render context.
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 c...
virtual QString type() const =0
Returns a unique string representing the callout type.
virtual QgsCallout * clone() const =0
Duplicates a callout by creating a deep copy of the callout.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the callout's property collection, used for data defined overrides.
Definition qgscallout.h:335
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.
AnchorPoint anchorPoint() const
Returns the feature's anchor point position.
Definition qgscallout.h:365
LabelAnchorPoint labelAnchorPoint() const
Returns the label's anchor point position.
Definition qgscallout.h:398
AnchorPoint
Feature's anchor point position.
Definition qgscallout.h:116
@ PointOnExterior
A point on the surface's outline closest to the label is used as anchor for polygon geometries.
Definition qgscallout.h:118
@ Centroid
The surface's centroid is used as anchor for polygon geometries.
Definition qgscallout.h:120
@ PointOnSurface
A point guaranteed to be on the surface is used as anchor for polygon geometries.
Definition qgscallout.h:119
@ PoleOfInaccessibility
The surface's pole of inaccessibility used as anchor for polygon geometries.
Definition qgscallout.h:117
const QgsPropertyCollection & dataDefinedProperties() const
Returns a reference to the callout's property collection, used for data defined overrides.
Definition qgscallout.h:343
virtual void restoreProperties(const QDomElement &element, const QgsReadWriteContext &context)
Restores the callout's properties from a DOM element.
void setLabelAnchorPoint(LabelAnchorPoint anchor)
Sets the label's anchor point position.
Definition qgscallout.h:406
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.
virtual void startRender(QgsRenderContext &context)
Prepares the callout for rendering on the specified render context.
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.
QgsCallout()
Constructor for QgsCallout.
DrawOrder
Options for draw order (stacking) of callouts.
Definition qgscallout.h:109
@ OrderBelowIndividualLabels
Render callouts below their individual associated labels, some callouts may be drawn over other label...
Definition qgscallout.h:111
@ OrderBelowAllLabels
Render callouts below all labels.
Definition qgscallout.h:110
virtual DrawOrder drawOrder() const
Returns the desired drawing order (stacking) to use while rendering this callout.
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing callouts.
Definition qgscallout.h:432
LabelAnchorPoint
Label's anchor point position.
Definition qgscallout.h:128
@ LabelPointOnExterior
The point on the label's boundary closest to the feature.
Definition qgscallout.h:129
@ LabelBottomLeft
Bottom left corner of the label's boundary.
Definition qgscallout.h:136
@ LabelBottomMiddle
Bottom middle of the label's boundary.
Definition qgscallout.h:137
@ LabelMiddleLeft
Middle left of the label's boundary.
Definition qgscallout.h:134
@ LabelBottomRight
Bottom right corner of the label's boundary.
Definition qgscallout.h:138
@ LabelMiddleRight
Middle right of the label's boundary.
Definition qgscallout.h:135
@ LabelTopMiddle
Top middle of the label's boundary.
Definition qgscallout.h:132
@ LabelTopLeft
Top left corner of the label's boundary.
Definition qgscallout.h:131
@ LabelCentroid
The labe's centroid.
Definition qgscallout.h:130
@ LabelTopRight
Top right corner of the label's boundary.
Definition qgscallout.h:133
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 ...
virtual QSet< QString > referencedFields(const QgsRenderContext &context) const
Returns the set of attributes referenced by the callout.
void setAnchorPoint(AnchorPoint anchor)
Sets the feature's anchor point position.
Definition qgscallout.h:372
Property
Data definable properties.
Definition qgscallout.h:87
virtual QVariantMap properties(const QgsReadWriteContext &context) const
Returns the properties describing the callout encoded in a string format.
bool enabled() const
Returns true if the the callout is enabled.
Definition qgscallout.h:323
Represents a coordinate reference system (CRS).
Handles coordinate transforms between two coordinate systems.
Abstract base class for curved geometry type.
Definition qgscurve.h:36
Draws curved lines as callouts.
Definition qgscallout.h:786
QgsCurvedLineCallout & operator=(const QgsCurvedLineCallout &)=delete
QgsCurvedLineCallout * clone() const override
Duplicates a callout by creating a deep copy of the callout.
QgsCurve * createCalloutLine(const QgsPoint &start, const QgsPoint &end, QgsRenderContext &context, const QRectF &bodyBoundingBox, const double angle, const QgsGeometry &anchor, QgsCalloutContext &calloutContext) const override
Creates a callout line between start and end in the desired style.
QVariantMap properties(const QgsReadWriteContext &context) const override
Returns the properties describing the callout encoded in a string format.
void setOrientation(Orientation orientation)
Sets the callout line's curve orientation.
void setCurvature(double curvature)
Sets the callout line's curvature.
static QgsCallout * create(const QVariantMap &properties=QVariantMap(), const QgsReadWriteContext &context=QgsReadWriteContext())
Creates a new QgsCurvedLineCallout, using the settings serialized in the properties map (correspondin...
QString type() const override
Returns a unique string representing the callout type.
double curvature() const
Returns the callout line's curvature.
Orientation
Curve orientation.
Definition qgscallout.h:793
@ Clockwise
Curve lines in a clockwise direction.
Definition qgscallout.h:795
@ CounterClockwise
Curve lines in a counter-clockwise direction.
Definition qgscallout.h:796
@ Automatic
Automatically choose most cartographically pleasing orientation based on label and callout arrangemen...
Definition qgscallout.h:794
Orientation orientation() const
Returns the callout line's curve orientation.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
A geometry is the spatial representation of a feature.
A line symbol type, for rendering LineString and MultiLineString geometries.
Draws straight (right angled) lines as callouts.
Definition qgscallout.h:748
QString type() const override
Returns a unique string representing the callout type.
QgsCurve * createCalloutLine(const QgsPoint &start, const QgsPoint &end, QgsRenderContext &context, const QRectF &bodyBoundingBox, const double angle, const QgsGeometry &anchor, QgsCallout::QgsCalloutContext &calloutContext) const override
Creates a callout line between start and end in the desired style.
QgsManhattanLineCallout & operator=(const QgsManhattanLineCallout &)=delete
static QgsCallout * create(const QVariantMap &properties=QVariantMap(), const QgsReadWriteContext &context=QgsReadWriteContext())
Creates a new QgsManhattanLineCallout, using the settings serialized in the properties map (correspon...
QgsManhattanLineCallout * clone() const override
Duplicates a callout by creating a deep copy of the callout.
Struct for storing maximum and minimum scales for measurements in map units.
Defines the four margins of a rectangle.
Definition qgsmargins.h:38
A marker symbol type, for rendering Point and MultiPoint geometries.
Represents a 2D point.
Definition qgspointxy.h:60
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:49
A grouped map of multiple QgsProperty objects, each referenced by an integer key value.
A container for the context for various read/write operations on objects.
Contains information about the context of a rendering operation.
A simple direct line callout style.
Definition qgscallout.h:515
void setMinimumLengthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the minimum callout length.
Definition qgscallout.h:592
Qgis::RenderUnit offsetFromAnchorUnit() const
Returns the units for the offset from anchor point.
Definition qgscallout.h:629
void startRender(QgsRenderContext &context) override
Prepares the callout for rendering on the specified render context.
double minimumLength() const
Returns the minimum length of callout lines.
Definition qgscallout.h:563
QgsSimpleLineCallout & operator=(const QgsSimpleLineCallout &)=delete
void setLineSymbol(QgsLineSymbol *symbol)
Sets the line symbol used to render the callout line.
void stopRender(QgsRenderContext &context) override
Finalises the callout after a set of rendering operations on the specified render context.
void setOffsetFromLabelUnit(Qgis::RenderUnit unit)
Sets the unit for the offset from label area distance.
Definition qgscallout.h:666
QSet< QString > referencedFields(const QgsRenderContext &context) const override
Returns the set of attributes referenced by the callout.
double offsetFromLabel() const
Returns the offset distance from label area at which to end the line.
Definition qgscallout.h:652
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 ...
void setOffsetFromAnchorMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the offset from anchor.
Definition qgscallout.h:637
QString type() const override
Returns a unique string representing the callout type.
double offsetFromAnchor() const
Returns the offset distance from the anchor point at which to start the line.
Definition qgscallout.h:608
const QgsMapUnitScale & offsetFromAnchorMapUnitScale() const
Returns the map unit scale for the offset from anchor.
Definition qgscallout.h:645
void setOffsetFromAnchor(double distance)
Sets the offset distance from the anchor point at which to start the line.
Definition qgscallout.h:615
~QgsSimpleLineCallout() override
void setOffsetFromAnchorUnit(Qgis::RenderUnit unit)
Sets the unit for the offset from anchor distance.
Definition qgscallout.h:622
void setMinimumLength(double length)
Sets the minimum length of callout lines.
Definition qgscallout.h:570
const QgsMapUnitScale & minimumLengthMapUnitScale() const
Returns the map unit scale for the minimum callout length.
Definition qgscallout.h:600
bool drawCalloutToAllParts() const
Returns true if callout lines should be drawn to all feature parts.
Definition qgscallout.h:696
void setDrawCalloutToAllParts(bool drawToAllParts)
Sets whether callout lines should be drawn to all feature parts.
Definition qgscallout.h:703
static QgsCallout * create(const QVariantMap &properties=QVariantMap(), const QgsReadWriteContext &context=QgsReadWriteContext())
Creates a new QgsSimpleLineCallout, using the settings serialized in the properties map (correspondin...
Qgis::RenderUnit offsetFromLabelUnit() const
Returns the units for the offset from label area.
Definition qgscallout.h:673
QVariantMap properties(const QgsReadWriteContext &context) const override
Returns the properties describing the callout encoded in a string format.
QgsSimpleLineCallout * clone() const override
Duplicates a callout by creating a deep copy of the callout.
QgsLineSymbol * lineSymbol()
Returns the line symbol used to render the callout line.
void setOffsetFromLabelMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the offset from label area.
Definition qgscallout.h:681
void setMinimumLengthUnit(Qgis::RenderUnit unit)
Sets the unit for the minimum length of callout lines.
Definition qgscallout.h:577
void setOffsetFromLabel(double distance)
Sets the offset distance from label area at which to end the line.
Definition qgscallout.h:659
const QgsMapUnitScale & offsetFromLabelMapUnitScale() const
Returns the map unit scale for the minimum callout length.
Definition qgscallout.h:689
Qgis::RenderUnit minimumLengthUnit() const
Returns the units for the minimum length of callout lines.
Definition qgscallout.h:584
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:199
#define SIP_DEPRECATED
Definition qgis_sip.h:114
#define SIP_SKIP
Definition qgis_sip.h:134
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)
Definition qgis_sip.h:268
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:84
#define SIP_END
Definition qgis_sip.h:216
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.
record about vertex coordinates and index of anchor to which it is snapped