QGIS API Documentation 4.1.0-Master (60fea48833c)
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#ifdef SIP_RUN
58 if ( sipCpp->type() == "simple" && dynamic_cast<QgsSimpleLineCallout *>( sipCpp ) != NULL )
59 {
60 sipType = sipType_QgsSimpleLineCallout;
61 }
62 else if ( sipCpp->type() == "manhattan" && dynamic_cast<QgsManhattanLineCallout *>( sipCpp ) != NULL )
63 {
64 sipType = sipType_QgsManhattanLineCallout;
65 }
66 else if ( sipCpp->type() == "curved" && dynamic_cast<QgsCurvedLineCallout *>( sipCpp ) != NULL )
67 {
68 sipType = sipType_QgsCurvedLineCallout;
69 }
70 else if ( sipCpp->type() == "balloon" && dynamic_cast<QgsBalloonCallout *>( sipCpp ) != NULL )
71 {
72 sipType = sipType_QgsBalloonCallout;
73 }
74 else
75 {
76 sipType = 0;
77 }
79#endif
80
81 public:
82 // *INDENT-OFF*
85 {
86 MinimumCalloutLength,
87 OffsetFromAnchor,
88 OffsetFromLabel,
89 DrawCalloutToAllParts,
90 AnchorPointPosition,
91 LabelAnchorPointPosition,
92 OriginX,
93 OriginY,
94 DestinationX,
95 DestinationY,
96 Curvature,
97 Orientation,
98 Margins,
99 WedgeWidth,
100 CornerRadius,
101 BlendMode,
102 };
103 // *INDENT-ON*
104
111
120
138
142 QgsCallout();
143 virtual ~QgsCallout() = default;
144
148 virtual QString type() const = 0;
149
155 virtual QgsCallout *clone() const = 0 SIP_FACTORY;
156
167 virtual QVariantMap properties( const QgsReadWriteContext &context ) const;
168
178 virtual void readProperties( const QVariantMap &props, const QgsReadWriteContext &context );
179
187 virtual bool saveProperties( QDomDocument &doc, QDomElement &element, const QgsReadWriteContext &context ) const;
188
196 virtual void restoreProperties( const QDomElement &element, const QgsReadWriteContext &context );
197
203 bool containsAdvancedEffects() const;
204
213 virtual void startRender( QgsRenderContext &context );
214
223 virtual void stopRender( QgsRenderContext &context );
224
232 virtual QSet< QString > referencedFields( const QgsRenderContext &context ) const;
233
239 virtual DrawOrder drawOrder() const;
240
247 class CORE_EXPORT QgsCalloutContext
248 {
249 public:
252
259
267
278 void addCalloutPosition( const QgsCalloutPosition &position ) { return mPositions.push_back( position ); }
279
285 QList< QgsCalloutPosition > positions() const { return mPositions; }
286
287 private:
289 mutable QgsCoordinateTransform mOriginalFeatureToMapTransform;
290
291 QList< QgsCalloutPosition > mPositions;
292 };
293
315 void render( QgsRenderContext &context, const QRectF &rect, const double angle, const QgsGeometry &anchor, QgsCalloutContext &calloutContext );
316
321 bool enabled() const { return mEnabled; }
322
327 void setEnabled( bool enabled );
328
333 QgsPropertyCollection &dataDefinedProperties() { return mDataDefinedProperties; }
334
341 const QgsPropertyCollection &dataDefinedProperties() const SIP_SKIP { return mDataDefinedProperties; }
342
351 void setDataDefinedProperties( const QgsPropertyCollection &collection ) { mDataDefinedProperties = collection; }
352
356 static QgsPropertiesDefinition propertyDefinitions();
357
363 AnchorPoint anchorPoint() const { return mAnchorPoint; }
364
370 void setAnchorPoint( AnchorPoint anchor ) { mAnchorPoint = anchor; }
371
377 static QString encodeAnchorPoint( AnchorPoint anchor );
378
387 static QgsCallout::AnchorPoint decodeAnchorPoint( const QString &name, bool *ok = nullptr );
388
389
396 LabelAnchorPoint labelAnchorPoint() const { return mLabelAnchorPoint; }
397
404 void setLabelAnchorPoint( LabelAnchorPoint anchor ) { mLabelAnchorPoint = anchor; }
405
412 static QString encodeLabelAnchorPoint( LabelAnchorPoint anchor );
413
423 static QgsCallout::LabelAnchorPoint decodeLabelAnchorPoint( const QString &name, bool *ok = nullptr );
424
430 QPainter::CompositionMode blendMode() const { return mBlendMode; }
431
437 void setBlendMode( QPainter::CompositionMode mode ) { mBlendMode = mode; }
438
439 protected:
458 virtual void draw( QgsRenderContext &context, const QRectF &bodyBoundingBox, const double angle, const QgsGeometry &anchor, QgsCalloutContext &calloutContext ) = 0;
459
464 Q_DECL_DEPRECATED QgsGeometry labelAnchorGeometry( const QRectF &bodyBoundingBox, const double angle, LabelAnchorPoint anchor ) const SIP_DEPRECATED;
465
473 QgsGeometry calloutLabelPoint( const QRectF &bodyBoundingBox, double angle, LabelAnchorPoint anchor, QgsRenderContext &context, const QgsCalloutContext &calloutContext, bool &pinned ) const;
474
485 QgsGeometry calloutLineToPart( const QgsGeometry &labelGeometry, const QgsAbstractGeometry *partGeometry, QgsRenderContext &context, const QgsCalloutContext &calloutContext, bool &pinned ) const;
486
487 private:
488 bool mEnabled = false;
489
490 AnchorPoint mAnchorPoint = PoleOfInaccessibility;
491 LabelAnchorPoint mLabelAnchorPoint = LabelPointOnExterior;
492
493 QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
494
496 QgsPropertyCollection mDataDefinedProperties;
497
499 static QgsPropertiesDefinition sPropertyDefinitions;
500
501 static void initPropertyDefinitions();
502};
503
510class CORE_EXPORT QgsSimpleLineCallout : public QgsCallout
511{
512 public:
515
516#ifndef SIP_RUN
519#endif
520
526 static QgsCallout *create( const QVariantMap &properties = QVariantMap(), const QgsReadWriteContext &context = QgsReadWriteContext() ) SIP_FACTORY;
527
528 QString type() const override;
529 QgsSimpleLineCallout *clone() const override;
530 QVariantMap properties( const QgsReadWriteContext &context ) const override;
531 void readProperties( const QVariantMap &props, const QgsReadWriteContext &context ) override;
532 void startRender( QgsRenderContext &context ) override;
533 void stopRender( QgsRenderContext &context ) override;
534 QSet< QString > referencedFields( const QgsRenderContext &context ) const override;
535
544
552
558 double minimumLength() const { return mMinCalloutLength; }
559
565 void setMinimumLength( double length ) { mMinCalloutLength = length; }
566
572 void setMinimumLengthUnit( Qgis::RenderUnit unit ) { mMinCalloutLengthUnit = unit; }
573
579 Qgis::RenderUnit minimumLengthUnit() const { return mMinCalloutLengthUnit; }
580
587 void setMinimumLengthMapUnitScale( const QgsMapUnitScale &scale ) { mMinCalloutLengthScale = scale; }
588
595 const QgsMapUnitScale &minimumLengthMapUnitScale() const { return mMinCalloutLengthScale; }
596
597
603 double offsetFromAnchor() const { return mOffsetFromAnchorDistance; }
604
610 void setOffsetFromAnchor( double distance ) { mOffsetFromAnchorDistance = distance; }
611
617 void setOffsetFromAnchorUnit( Qgis::RenderUnit unit ) { mOffsetFromAnchorUnit = unit; }
618
624 Qgis::RenderUnit offsetFromAnchorUnit() const { return mOffsetFromAnchorUnit; }
625
632 void setOffsetFromAnchorMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetFromAnchorScale = scale; }
633
640 const QgsMapUnitScale &offsetFromAnchorMapUnitScale() const { return mOffsetFromAnchorScale; }
641
647 double offsetFromLabel() const { return mOffsetFromLabelDistance; }
648
654 void setOffsetFromLabel( double distance ) { mOffsetFromLabelDistance = distance; }
655
661 void setOffsetFromLabelUnit( Qgis::RenderUnit unit ) { mOffsetFromLabelUnit = unit; }
662
668 Qgis::RenderUnit offsetFromLabelUnit() const { return mOffsetFromLabelUnit; }
669
676 void setOffsetFromLabelMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetFromLabelScale = scale; }
677
684 const QgsMapUnitScale &offsetFromLabelMapUnitScale() const { return mOffsetFromLabelScale; }
685
691 bool drawCalloutToAllParts() const { return mDrawCalloutToAllParts; }
692
698 void setDrawCalloutToAllParts( bool drawToAllParts ) { mDrawCalloutToAllParts = drawToAllParts; }
699
700 protected:
701 void draw( QgsRenderContext &context, const QRectF &bodyBoundingBox, const double angle, const QgsGeometry &anchor, QgsCallout::QgsCalloutContext &calloutContext ) override;
702
710 virtual QgsCurve *createCalloutLine(
711 const QgsPoint &start, const QgsPoint &end, QgsRenderContext &context, const QRectF &bodyBoundingBox, const double angle, const QgsGeometry &anchor, QgsCallout::QgsCalloutContext &calloutContext
712 ) const SIP_FACTORY;
713
714 private:
715#ifdef SIP_RUN
717 QgsSimpleLineCallout &operator=( const QgsSimpleLineCallout & );
718#endif
719
720 std::unique_ptr< QgsLineSymbol > mLineSymbol;
721 double mMinCalloutLength = 0;
722 Qgis::RenderUnit mMinCalloutLengthUnit = Qgis::RenderUnit::Millimeters;
723 QgsMapUnitScale mMinCalloutLengthScale;
724
725 double mOffsetFromAnchorDistance = 0;
726 Qgis::RenderUnit mOffsetFromAnchorUnit = Qgis::RenderUnit::Millimeters;
727 QgsMapUnitScale mOffsetFromAnchorScale;
728
729 double mOffsetFromLabelDistance = 0;
730 Qgis::RenderUnit mOffsetFromLabelUnit = Qgis::RenderUnit::Millimeters;
731 QgsMapUnitScale mOffsetFromLabelScale;
732
733 bool mDrawCalloutToAllParts = false;
734};
735
736
744{
745 public:
747
748#ifndef SIP_RUN
751#endif
752
758 static QgsCallout *create( const QVariantMap &properties = QVariantMap(), const QgsReadWriteContext &context = QgsReadWriteContext() ) SIP_FACTORY; // cppcheck-suppress duplInheritedMember
759
760 QString type() const override;
761 QgsManhattanLineCallout *clone() const override;
762
763 protected:
765 const QgsPoint &start, const QgsPoint &end, QgsRenderContext &context, const QRectF &bodyBoundingBox, const double angle, const QgsGeometry &anchor, QgsCallout::QgsCalloutContext &calloutContext
766 ) const override SIP_FACTORY;
767
768 private:
769#ifdef SIP_RUN
772#endif
773};
774
775
783{
784 public:
794
796
797#ifndef SIP_RUN
800#endif
801
807 static QgsCallout *create( const QVariantMap &properties = QVariantMap(), const QgsReadWriteContext &context = QgsReadWriteContext() ) SIP_FACTORY; // cppcheck-suppress duplInheritedMember
808
809 QString type() const override;
810 QgsCurvedLineCallout *clone() const override;
811 QVariantMap properties( const QgsReadWriteContext &context ) const override;
812
820 double curvature() const;
821
829 void setCurvature( double curvature );
830
836 Orientation orientation() const;
837
844
845 protected:
847 const QgsPoint &start, const QgsPoint &end, QgsRenderContext &context, const QRectF &bodyBoundingBox, const double angle, const QgsGeometry &anchor, QgsCalloutContext &calloutContext
848 ) const override SIP_FACTORY;
849
850 private:
851#ifdef SIP_RUN
854#endif
855
859 static Orientation decodeOrientation( const QString &string );
860
864 static QString encodeOrientation( Orientation orientation );
865
866
867 Orientation mOrientation = Automatic;
868 double mCurvature = 0.1;
869};
870
871
878class CORE_EXPORT QgsBalloonCallout : public QgsCallout
879{
880 public:
883
884#ifndef SIP_RUN
885 QgsBalloonCallout( const QgsBalloonCallout &other );
887#endif
888
894 static QgsCallout *create( const QVariantMap &properties = QVariantMap(), const QgsReadWriteContext &context = QgsReadWriteContext() ) SIP_FACTORY;
895
896 QString type() const override;
897 QgsBalloonCallout *clone() const override;
898 QVariantMap properties( const QgsReadWriteContext &context ) const override;
899 void readProperties( const QVariantMap &props, const QgsReadWriteContext &context ) override;
900 void startRender( QgsRenderContext &context ) override;
901 void stopRender( QgsRenderContext &context ) override;
902 QSet< QString > referencedFields( const QgsRenderContext &context ) const override;
903
912
920
934
947
953 double offsetFromAnchor() const { return mOffsetFromAnchorDistance; }
954
960 void setOffsetFromAnchor( double distance ) { mOffsetFromAnchorDistance = distance; }
961
967 void setOffsetFromAnchorUnit( Qgis::RenderUnit unit ) { mOffsetFromAnchorUnit = unit; }
968
974 Qgis::RenderUnit offsetFromAnchorUnit() const { return mOffsetFromAnchorUnit; }
975
982 void setOffsetFromAnchorMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetFromAnchorScale = scale; }
983
990 const QgsMapUnitScale &offsetFromAnchorMapUnitScale() const { return mOffsetFromAnchorScale; }
991
1002 const QgsMargins &margins() const { return mMargins; }
1003
1014 void setMargins( const QgsMargins &margins ) { mMargins = margins; }
1015
1022 void setMarginsUnit( Qgis::RenderUnit unit ) { mMarginUnit = unit; }
1023
1030 Qgis::RenderUnit marginsUnit() const { return mMarginUnit; }
1031
1040 double wedgeWidth() const { return mWedgeWidth; }
1041
1050 void setWedgeWidth( double width ) { mWedgeWidth = width; }
1051
1058 void setWedgeWidthUnit( Qgis::RenderUnit unit ) { mWedgeWidthUnit = unit; }
1059
1066 Qgis::RenderUnit wedgeWidthUnit() const { return mWedgeWidthUnit; }
1067
1075 void setWedgeWidthMapUnitScale( const QgsMapUnitScale &scale ) { mWedgeWidthScale = scale; }
1076
1084 const QgsMapUnitScale &wedgeWidthMapUnitScale() const { return mWedgeWidthScale; }
1085
1094 double cornerRadius() const { return mCornerRadius; }
1095
1104 void setCornerRadius( double radius ) { mCornerRadius = radius; }
1105
1112 void setCornerRadiusUnit( Qgis::RenderUnit unit ) { mCornerRadiusUnit = unit; }
1113
1120 Qgis::RenderUnit cornerRadiusUnit() const { return mCornerRadiusUnit; }
1121
1129 void setCornerRadiusMapUnitScale( const QgsMapUnitScale &scale ) { mCornerRadiusScale = scale; }
1130
1138 const QgsMapUnitScale &cornerRadiusMapUnitScale() const { return mCornerRadiusScale; }
1139
1140
1141 protected:
1142 void draw( QgsRenderContext &context, const QRectF &bodyBoundingBox, const double angle, const QgsGeometry &anchor, QgsCallout::QgsCalloutContext &calloutContext ) override;
1143
1144 private:
1145 QPolygonF getPoints( QgsRenderContext &context, QgsPointXY origin, QRectF rect ) const;
1146
1147#ifdef SIP_RUN
1148 QgsBalloonCallout( const QgsBalloonCallout &other );
1149 QgsBalloonCallout &operator=( const QgsBalloonCallout & );
1150#endif
1151
1152 std::unique_ptr< QgsFillSymbol > mFillSymbol;
1153 std::unique_ptr< QgsMarkerSymbol > mMarkerSymbol;
1154
1155 double mOffsetFromAnchorDistance = 0;
1156 Qgis::RenderUnit mOffsetFromAnchorUnit = Qgis::RenderUnit::Millimeters;
1157 QgsMapUnitScale mOffsetFromAnchorScale;
1158
1159 QgsMargins mMargins;
1161
1162 double mWedgeWidth = 2.64;
1164 QgsMapUnitScale mWedgeWidthScale;
1165
1166 double mCornerRadius = 0.0;
1168 QgsMapUnitScale mCornerRadiusScale;
1169};
1170
1171
1172#endif // QGSCALLOUT_H
RenderUnit
Rendering size units.
Definition qgis.h:5340
@ Millimeters
Millimeters.
Definition qgis.h:5341
Abstract base class for all geometries.
A cartoon talking bubble callout style.
Definition qgscallout.h:879
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:967
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:974
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:990
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:960
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:982
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:953
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:248
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:278
bool allFeaturePartsLabeled
true if all parts of associated feature were labeled
Definition qgscallout.h:251
QList< QgsCalloutPosition > positions() const
Returns the list of rendered callout positions.
Definition qgscallout.h:285
QgsCoordinateReferenceSystem originalFeatureCrs
Contains the CRS of the original feature associated with this callout.
Definition qgscallout.h:258
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:351
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing callouts.
Definition qgscallout.h:437
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:333
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:363
LabelAnchorPoint labelAnchorPoint() const
Returns the label's anchor point position.
Definition qgscallout.h:396
AnchorPoint
Feature's anchor point position.
Definition qgscallout.h:114
@ PointOnExterior
A point on the surface's outline closest to the label is used as anchor for polygon geometries.
Definition qgscallout.h:116
@ Centroid
The surface's centroid is used as anchor for polygon geometries.
Definition qgscallout.h:118
@ PointOnSurface
A point guaranteed to be on the surface is used as anchor for polygon geometries.
Definition qgscallout.h:117
@ PoleOfInaccessibility
The surface's pole of inaccessibility used as anchor for polygon geometries.
Definition qgscallout.h:115
const QgsPropertyCollection & dataDefinedProperties() const
Returns a reference to the callout's property collection, used for data defined overrides.
Definition qgscallout.h:341
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:404
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:107
@ OrderBelowIndividualLabels
Render callouts below their individual associated labels, some callouts may be drawn over other label...
Definition qgscallout.h:109
@ OrderBelowAllLabels
Render callouts below all labels.
Definition qgscallout.h:108
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:430
LabelAnchorPoint
Label's anchor point position.
Definition qgscallout.h:126
@ LabelPointOnExterior
The point on the label's boundary closest to the feature.
Definition qgscallout.h:127
@ LabelBottomLeft
Bottom left corner of the label's boundary.
Definition qgscallout.h:134
@ LabelBottomMiddle
Bottom middle of the label's boundary.
Definition qgscallout.h:135
@ LabelMiddleLeft
Middle left of the label's boundary.
Definition qgscallout.h:132
@ LabelBottomRight
Bottom right corner of the label's boundary.
Definition qgscallout.h:136
@ LabelMiddleRight
Middle right of the label's boundary.
Definition qgscallout.h:133
@ LabelTopMiddle
Top middle of the label's boundary.
Definition qgscallout.h:130
@ LabelTopLeft
Top left corner of the label's boundary.
Definition qgscallout.h:129
@ LabelCentroid
The labe's centroid.
Definition qgscallout.h:128
@ LabelTopRight
Top right corner of the label's boundary.
Definition qgscallout.h:131
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:370
Property
Data definable properties.
Definition qgscallout.h:85
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 callout is enabled.
Definition qgscallout.h:321
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:783
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:789
@ Clockwise
Curve lines in a clockwise direction.
Definition qgscallout.h:791
@ CounterClockwise
Curve lines in a counter-clockwise direction.
Definition qgscallout.h:792
@ Automatic
Automatically choose most cartographically pleasing orientation based on label and callout arrangemen...
Definition qgscallout.h:790
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:744
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:40
A marker symbol type, for rendering Point and MultiPoint geometries.
Represents a 2D point.
Definition qgspointxy.h:62
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:53
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:511
void setMinimumLengthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the minimum callout length.
Definition qgscallout.h:587
Qgis::RenderUnit offsetFromAnchorUnit() const
Returns the units for the offset from anchor point.
Definition qgscallout.h:624
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:558
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:661
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:647
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:632
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:603
const QgsMapUnitScale & offsetFromAnchorMapUnitScale() const
Returns the map unit scale for the offset from anchor.
Definition qgscallout.h:640
void setOffsetFromAnchor(double distance)
Sets the offset distance from the anchor point at which to start the line.
Definition qgscallout.h:610
~QgsSimpleLineCallout() override
void setOffsetFromAnchorUnit(Qgis::RenderUnit unit)
Sets the unit for the offset from anchor distance.
Definition qgscallout.h:617
void setMinimumLength(double length)
Sets the minimum length of callout lines.
Definition qgscallout.h:565
const QgsMapUnitScale & minimumLengthMapUnitScale() const
Returns the map unit scale for the minimum callout length.
Definition qgscallout.h:595
bool drawCalloutToAllParts() const
Returns true if callout lines should be drawn to all feature parts.
Definition qgscallout.h:691
void setDrawCalloutToAllParts(bool drawToAllParts)
Sets whether callout lines should be drawn to all feature parts.
Definition qgscallout.h:698
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:668
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:676
void setMinimumLengthUnit(Qgis::RenderUnit unit)
Sets the unit for the minimum length of callout lines.
Definition qgscallout.h:572
void setOffsetFromLabel(double distance)
Sets the offset distance from label area at which to end the line.
Definition qgscallout.h:654
const QgsMapUnitScale & offsetFromLabelMapUnitScale() const
Returns the map unit scale for the minimum callout length.
Definition qgscallout.h:684
Qgis::RenderUnit minimumLengthUnit() const
Returns the units for the minimum length of callout lines.
Definition qgscallout.h:579
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:198
#define SIP_DEPRECATED
Definition qgis_sip.h:113
#define SIP_SKIP
Definition qgis_sip.h:133
#define SIP_MONKEYPATCH_SCOPEENUM_UNNEST(OUTSIDE_CLASS, FORMERNAME)
Definition qgis_sip.h:267
#define SIP_TRANSFER
Definition qgis_sip.h:35
#define SIP_FACTORY
Definition qgis_sip.h:83
#define SIP_END
Definition qgis_sip.h:215
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.
record about vertex coordinates and index of anchor to which it is snapped