QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 "qgis_core.h"
21 #include "qgis_sip.h"
22 #include "qgsexpressioncontext.h"
23 #include "qgsreadwritecontext.h"
24 #include "qgspropertycollection.h"
25 #include "qgsmapunitscale.h"
26 #include "qgscalloutposition.h"
27 #include "qgsmargins.h"
28 #include "qgscoordinatetransform.h"
29 
30 #include <QPainter>
31 #include <QString>
32 #include <QRectF>
33 #include <memory>
34 
35 class QgsLineSymbol;
36 class QgsFillSymbol;
37 class QgsGeometry;
38 class QgsRenderContext;
39 
40 class QgsCalloutWidget; //stop sip breaking
41 
52 class CORE_EXPORT QgsCallout
53 {
54 
55 #ifdef SIP_RUN
57  if ( sipCpp->type() == "simple" && dynamic_cast<QgsSimpleLineCallout *>( sipCpp ) != NULL )
58  {
59  sipType = sipType_QgsSimpleLineCallout;
60  }
61  else if ( sipCpp->type() == "manhattan" && dynamic_cast<QgsManhattanLineCallout *>( sipCpp ) != NULL )
62  {
63  sipType = sipType_QgsManhattanLineCallout;
64  }
65  else if ( sipCpp->type() == "curved" && dynamic_cast<QgsCurvedLineCallout *>( sipCpp ) != NULL )
66  {
67  sipType = sipType_QgsCurvedLineCallout;
68  }
69  else if ( sipCpp->type() == "balloon" && dynamic_cast<QgsBalloonCallout *>( sipCpp ) != NULL )
70  {
71  sipType = sipType_QgsBalloonCallout;
72  }
73  else
74  {
75  sipType = 0;
76  }
77  SIP_END
78 #endif
79 
80  public:
81 
83  enum Property
84  {
101  };
102 
105  {
108  };
109 
112  {
113  PoleOfInaccessibility = 0,
117  };
118 
124  {
135  };
136 
140  QgsCallout();
141  virtual ~QgsCallout() = default;
142 
146  virtual QString type() const = 0;
147 
153  virtual QgsCallout *clone() const = 0 SIP_FACTORY;
154 
165  virtual QVariantMap properties( const QgsReadWriteContext &context ) const;
166 
176  virtual void readProperties( const QVariantMap &props, const QgsReadWriteContext &context );
177 
185  virtual bool saveProperties( QDomDocument &doc, QDomElement &element, const QgsReadWriteContext &context ) const;
186 
194  virtual void restoreProperties( const QDomElement &element, const QgsReadWriteContext &context );
195 
201  bool containsAdvancedEffects() const;
202 
211  virtual void startRender( QgsRenderContext &context );
212 
221  virtual void stopRender( QgsRenderContext &context );
222 
230  virtual QSet< QString > referencedFields( const QgsRenderContext &context ) const;
231 
237  virtual DrawOrder drawOrder() const;
238 
245  class CORE_EXPORT QgsCalloutContext
246  {
247  public:
249  bool allFeaturePartsLabeled = false;
250 
257 
264  QgsCoordinateTransform originalFeatureToMapTransform( const QgsRenderContext &renderContext ) const;
265 
276  void addCalloutPosition( const QgsCalloutPosition &position ) { return mPositions.push_back( position ); }
277 
283  QList< QgsCalloutPosition > positions() const { return mPositions; }
284 
285  private:
287  mutable QgsCoordinateTransform mOriginalFeatureToMapTransform;
288 
289  QList< QgsCalloutPosition > mPositions;
290  };
291 
313  void render( QgsRenderContext &context, const QRectF &rect, const double angle, const QgsGeometry &anchor, QgsCalloutContext &calloutContext );
314 
319  bool enabled() const { return mEnabled; }
320 
325  void setEnabled( bool enabled );
326 
331  QgsPropertyCollection &dataDefinedProperties() { return mDataDefinedProperties; }
332 
339  const QgsPropertyCollection &dataDefinedProperties() const SIP_SKIP { return mDataDefinedProperties; }
340 
349  void setDataDefinedProperties( const QgsPropertyCollection &collection ) { mDataDefinedProperties = collection; }
350 
354  static QgsPropertiesDefinition propertyDefinitions();
355 
361  AnchorPoint anchorPoint() const { return mAnchorPoint; }
362 
368  void setAnchorPoint( AnchorPoint anchor ) { mAnchorPoint = anchor; }
369 
375  static QString encodeAnchorPoint( AnchorPoint anchor );
376 
385  static QgsCallout::AnchorPoint decodeAnchorPoint( const QString &name, bool *ok = nullptr );
386 
387 
394  LabelAnchorPoint labelAnchorPoint() const { return mLabelAnchorPoint; }
395 
402  void setLabelAnchorPoint( LabelAnchorPoint anchor ) { mLabelAnchorPoint = anchor; }
403 
410  static QString encodeLabelAnchorPoint( LabelAnchorPoint anchor );
411 
421  static QgsCallout::LabelAnchorPoint decodeLabelAnchorPoint( const QString &name, bool *ok = nullptr );
422 
428  QPainter::CompositionMode blendMode() const { return mBlendMode; }
429 
435  void setBlendMode( QPainter::CompositionMode mode ) { mBlendMode = mode; }
436 
437  protected:
438 
457  virtual void draw( QgsRenderContext &context, const QRectF &bodyBoundingBox, const double angle, const QgsGeometry &anchor, QgsCalloutContext &calloutContext ) = 0;
458 
463  Q_DECL_DEPRECATED QgsGeometry labelAnchorGeometry( const QRectF &bodyBoundingBox, const double angle, LabelAnchorPoint anchor ) const SIP_DEPRECATED;
464 
472  QgsGeometry calloutLabelPoint( const QRectF &bodyBoundingBox, double angle, LabelAnchorPoint anchor, QgsRenderContext &context, const QgsCalloutContext &calloutContext, bool &pinned ) const;
473 
484  QgsGeometry calloutLineToPart( const QgsGeometry &labelGeometry, const QgsAbstractGeometry *partGeometry, QgsRenderContext &context, const QgsCalloutContext &calloutContext, bool &pinned ) const;
485 
486  private:
487 
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 
510 class CORE_EXPORT QgsSimpleLineCallout : public QgsCallout
511 {
512  public:
513 
515  ~QgsSimpleLineCallout() override;
516 
517 #ifndef SIP_RUN
518 
523  QgsSimpleLineCallout &operator=( const QgsSimpleLineCallout & ) = delete;
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 
548  QgsLineSymbol *lineSymbol();
549 
556  void setLineSymbol( QgsLineSymbol *symbol SIP_TRANSFER );
557 
563  double minimumLength() const { return mMinCalloutLength; }
564 
570  void setMinimumLength( double length ) { mMinCalloutLength = length; }
571 
577  void setMinimumLengthUnit( QgsUnitTypes::RenderUnit unit ) { mMinCalloutLengthUnit = unit; }
578 
584  QgsUnitTypes::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( QgsUnitTypes::RenderUnit unit ) { mOffsetFromAnchorUnit = unit; }
623 
629  QgsUnitTypes::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( QgsUnitTypes::RenderUnit unit ) { mOffsetFromLabelUnit = unit; }
667 
673  QgsUnitTypes::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;
727  QgsMapUnitScale mMinCalloutLengthScale;
728 
729  double mOffsetFromAnchorDistance = 0;
731  QgsMapUnitScale mOffsetFromAnchorScale;
732 
733  double mOffsetFromLabelDistance = 0;
735  QgsMapUnitScale mOffsetFromLabelScale;
736 
737  bool mDrawCalloutToAllParts = false;
738 };
739 
740 
748 {
749  public:
750 
752 
753 #ifndef SIP_RUN
754 
759 
761 #endif
762 
768  static QgsCallout *create( const QVariantMap &properties = QVariantMap(), const QgsReadWriteContext &context = QgsReadWriteContext() ) SIP_FACTORY;
769 
770  QString type() const override;
771  QgsManhattanLineCallout *clone() const override;
772 
773  protected:
774  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;
775 
776  private:
777 #ifdef SIP_RUN
780 #endif
781 };
782 
783 
790 class CORE_EXPORT QgsCurvedLineCallout : public QgsSimpleLineCallout
791 {
792  public:
793 
798  {
802  };
803 
805 
806 #ifndef SIP_RUN
807 
812 
814 #endif
815 
821  static QgsCallout *create( const QVariantMap &properties = QVariantMap(), const QgsReadWriteContext &context = QgsReadWriteContext() ) SIP_FACTORY;
822 
823  QString type() const override;
824  QgsCurvedLineCallout *clone() const override;
825  QVariantMap properties( const QgsReadWriteContext &context ) const override;
826 
834  double curvature() const;
835 
843  void setCurvature( double curvature );
844 
850  Orientation orientation() const;
851 
857  void setOrientation( Orientation orientation );
858 
859  protected:
860  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;
861 
862  private:
863 #ifdef SIP_RUN
866 #endif
867 
871  static Orientation decodeOrientation( const QString &string );
872 
876  static QString encodeOrientation( Orientation orientation );
877 
878 
879  Orientation mOrientation = Automatic;
880  double mCurvature = 0.1;
881 };
882 
883 
890 class CORE_EXPORT QgsBalloonCallout : public QgsCallout
891 {
892  public:
893 
895  ~QgsBalloonCallout() override;
896 
897 #ifndef SIP_RUN
898 
902  QgsBalloonCallout( const QgsBalloonCallout &other );
903  QgsBalloonCallout &operator=( const QgsBalloonCallout & ) = delete;
904 #endif
905 
911  static QgsCallout *create( const QVariantMap &properties = QVariantMap(), const QgsReadWriteContext &context = QgsReadWriteContext() ) SIP_FACTORY;
912 
913  QString type() const override;
914  QgsBalloonCallout *clone() const override;
915  QVariantMap properties( const QgsReadWriteContext &context ) const override;
916  void readProperties( const QVariantMap &props, const QgsReadWriteContext &context ) override;
917  void startRender( QgsRenderContext &context ) override;
918  void stopRender( QgsRenderContext &context ) override;
919  QSet< QString > referencedFields( const QgsRenderContext &context ) const override;
920 
928  QgsFillSymbol *fillSymbol();
929 
936  void setFillSymbol( QgsFillSymbol *symbol SIP_TRANSFER );
937 
943  double offsetFromAnchor() const { return mOffsetFromAnchorDistance; }
944 
950  void setOffsetFromAnchor( double distance ) { mOffsetFromAnchorDistance = distance; }
951 
957  void setOffsetFromAnchorUnit( QgsUnitTypes::RenderUnit unit ) { mOffsetFromAnchorUnit = unit; }
958 
964  QgsUnitTypes::RenderUnit offsetFromAnchorUnit() const { return mOffsetFromAnchorUnit; }
965 
972  void setOffsetFromAnchorMapUnitScale( const QgsMapUnitScale &scale ) { mOffsetFromAnchorScale = scale; }
973 
980  const QgsMapUnitScale &offsetFromAnchorMapUnitScale() const { return mOffsetFromAnchorScale; }
981 
992  const QgsMargins &margins() const { return mMargins; }
993 
1004  void setMargins( const QgsMargins &margins ) { mMargins = margins; }
1005 
1012  void setMarginsUnit( QgsUnitTypes::RenderUnit unit ) { mMarginUnit = unit; }
1013 
1020  QgsUnitTypes::RenderUnit marginsUnit() const { return mMarginUnit; }
1021 
1030  double wedgeWidth() const { return mWedgeWidth; }
1031 
1040  void setWedgeWidth( double width ) { mWedgeWidth = width; }
1041 
1048  void setWedgeWidthUnit( QgsUnitTypes::RenderUnit unit ) { mWedgeWidthUnit = unit; }
1049 
1056  QgsUnitTypes::RenderUnit wedgeWidthUnit() const { return mWedgeWidthUnit; }
1057 
1065  void setWedgeWidthMapUnitScale( const QgsMapUnitScale &scale ) { mWedgeWidthScale = scale; }
1066 
1074  const QgsMapUnitScale &wedgeWidthMapUnitScale() const { return mWedgeWidthScale; }
1075 
1084  double cornerRadius() const { return mCornerRadius; }
1085 
1094  void setCornerRadius( double radius ) { mCornerRadius = radius; }
1095 
1102  void setCornerRadiusUnit( QgsUnitTypes::RenderUnit unit ) { mCornerRadiusUnit = unit; }
1103 
1110  QgsUnitTypes::RenderUnit cornerRadiusUnit() const { return mCornerRadiusUnit; }
1111 
1119  void setCornerRadiusMapUnitScale( const QgsMapUnitScale &scale ) { mCornerRadiusScale = scale; }
1120 
1128  const QgsMapUnitScale &cornerRadiusMapUnitScale() const { return mCornerRadiusScale; }
1129 
1130 
1131  protected:
1132  void draw( QgsRenderContext &context, const QRectF &bodyBoundingBox, const double angle, const QgsGeometry &anchor, QgsCallout::QgsCalloutContext &calloutContext ) override;
1133 
1134  private:
1135 
1136  QPolygonF getPoints( QgsRenderContext &context, QgsPointXY origin, QRectF rect ) const;
1137 
1138 #ifdef SIP_RUN
1139  QgsBalloonCallout( const QgsBalloonCallout &other );
1140  QgsBalloonCallout &operator=( const QgsBalloonCallout & );
1141 #endif
1142 
1143  std::unique_ptr< QgsFillSymbol > mFillSymbol;
1144 
1145  double mOffsetFromAnchorDistance = 0;
1147  QgsMapUnitScale mOffsetFromAnchorScale;
1148 
1149  QgsMargins mMargins;
1151 
1152  double mWedgeWidth = 2.64;
1154  QgsMapUnitScale mWedgeWidthScale;
1155 
1156  double mCornerRadius = 0.0;
1158  QgsMapUnitScale mCornerRadiusScale;
1159 
1160 };
1161 
1162 
1163 
1164 #endif // QGSCALLOUT_H
1165 
QgsCurve
Abstract base class for curved geometry type.
Definition: qgscurve.h:35
QgsBalloonCallout::setMargins
void setMargins(const QgsMargins &margins)
Sets the margins between the outside of the callout frame and the label's bounding rectangle.
Definition: qgscallout.h:1004
QgsSimpleLineCallout::offsetFromLabelUnit
QgsUnitTypes::RenderUnit offsetFromLabelUnit() const
Returns the units for the offset from label area.
Definition: qgscallout.h:673
QgsSimpleLineCallout::setMinimumLengthMapUnitScale
void setMinimumLengthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the minimum callout length.
Definition: qgscallout.h:592
QgsCallout::LabelPointOnExterior
@ LabelPointOnExterior
The point on the label's boundary closest to the feature.
Definition: qgscallout.h:125
QgsCurvedLineCallout::Clockwise
@ Clockwise
Curve lines in a clockwise direction.
Definition: qgscallout.h:800
QgsCalloutWidget
Base class for widgets which allow control over the properties of callouts.
Definition: qgscalloutwidget.h:34
QgsCallout::BlendMode
@ BlendMode
Callout blend mode (since QGIS 3.20)
Definition: qgscallout.h:100
QgsBalloonCallout::cornerRadiusUnit
QgsUnitTypes::RenderUnit cornerRadiusUnit() const
Returns the units for the corner radius.
Definition: qgscallout.h:1110
QgsCallout::OffsetFromAnchor
@ OffsetFromAnchor
Distance to offset lines from anchor points.
Definition: qgscallout.h:86
QgsSimpleLineCallout::offsetFromAnchor
double offsetFromAnchor() const
Returns the offset distance from the anchor point at which to start the line.
Definition: qgscallout.h:608
QgsCallout::QgsCalloutContext::originalFeatureCrs
QgsCoordinateReferenceSystem originalFeatureCrs
Contains the CRS of the original feature associated with this callout.
Definition: qgscallout.h:256
QgsBalloonCallout::wedgeWidthMapUnitScale
const QgsMapUnitScale & wedgeWidthMapUnitScale() const
Returns the map unit scale for the wedge width.
Definition: qgscallout.h:1074
QgsUnitTypes::RenderUnit
RenderUnit
Rendering size units.
Definition: qgsunittypes.h:167
QgsCallout::AnchorPoint
AnchorPoint
Feature's anchor point position.
Definition: qgscallout.h:111
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:34
QgsCallout
Abstract base class for callout renderers.
Definition: qgscallout.h:52
QgsCallout::CornerRadius
@ CornerRadius
Balloon callout corner radius (since QGIS 3.20)
Definition: qgscallout.h:99
QgsCallout::Curvature
@ Curvature
Curvature of curved line callouts (since QGIS 3.20)
Definition: qgscallout.h:95
QgsPoint
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:48
QgsSimpleLineCallout::setOffsetFromAnchorUnit
void setOffsetFromAnchorUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the offset from anchor distance.
Definition: qgscallout.h:622
qgsreadwritecontext.h
QgsBalloonCallout::wedgeWidth
double wedgeWidth() const
Returns the width of the wedge shape at the side it connects with the label.
Definition: qgscallout.h:1030
QgsCallout::WedgeWidth
@ WedgeWidth
Balloon callout wedge width (since QGIS 3.20)
Definition: qgscallout.h:98
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:59
QgsCallout::QgsCalloutContext::positions
QList< QgsCalloutPosition > positions() const
Returns the list of rendered callout positions.
Definition: qgscallout.h:283
QgsCallout::OriginY
@ OriginY
Y-coordinate of callout origin (label anchor) (since QGIS 3.20)
Definition: qgscallout.h:92
QgsSimpleLineCallout::setOffsetFromLabel
void setOffsetFromLabel(double distance)
Sets the offset distance from label area at which to end the line.
Definition: qgscallout.h:659
QgsCallout::dataDefinedProperties
const QgsPropertyCollection & dataDefinedProperties() const
Returns a reference to the callout's property collection, used for data defined overrides.
Definition: qgscallout.h:339
QgsCallout::anchorPoint
AnchorPoint anchorPoint() const
Returns the feature's anchor point position.
Definition: qgscallout.h:361
QgsUnitTypes::RenderMillimeters
@ RenderMillimeters
Millimeters.
Definition: qgsunittypes.h:169
QgsCallout::LabelCentroid
@ LabelCentroid
The labe's centroid.
Definition: qgscallout.h:126
QgsSimpleLineCallout::create
static QgsCallout * create(const QVariantMap &properties=QVariantMap(), const QgsReadWriteContext &context=QgsReadWriteContext())
Creates a new QgsSimpleLineCallout, using the settings serialized in the properties map (correspondin...
Definition: qgscallout.cpp:554
QgsCallout::LabelBottomMiddle
@ LabelBottomMiddle
Bottom middle of the label's boundary.
Definition: qgscallout.h:133
QgsCallout::Margins
@ Margins
Margin from text (since QGIS 3.20)
Definition: qgscallout.h:97
QgsBalloonCallout::setWedgeWidth
void setWedgeWidth(double width)
Sets the width of the wedge shape at the side it connects with the label.
Definition: qgscallout.h:1040
QgsSimpleLineCallout::clone
QgsSimpleLineCallout * clone() const override
Duplicates a callout by creating a deep copy of the callout.
Definition: qgscallout.cpp:566
QgsCallout::type
virtual QString type() const =0
Returns a unique string representing the callout type.
QgsCallout::blendMode
QPainter::CompositionMode blendMode() const
Returns the blending mode used for drawing callouts.
Definition: qgscallout.h:428
QgsCurvedLineCallout::CounterClockwise
@ CounterClockwise
Curve lines in a counter-clockwise direction.
Definition: qgscallout.h:801
QgsCallout::AnchorPointPosition
@ AnchorPointPosition
Feature's anchor point position.
Definition: qgscallout.h:89
QgsCallout::PointOnExterior
@ PointOnExterior
A point on the surface's outline closest to the label is used as anchor for polygon geometries.
Definition: qgscallout.h:114
QgsCallout::LabelMiddleRight
@ LabelMiddleRight
Middle right of the label's boundary.
Definition: qgscallout.h:131
QgsSimpleLineCallout::setOffsetFromLabelMapUnitScale
void setOffsetFromLabelMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the offset from label area.
Definition: qgscallout.h:681
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsCallout::LabelTopLeft
@ LabelTopLeft
Top left corner of the label's boundary.
Definition: qgscallout.h:127
QgsSimpleLineCallout::createCalloutLine
virtual QgsCurve * createCalloutLine(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.
Definition: qgscallout.cpp:743
QgsSimpleLineCallout::setMinimumLengthUnit
void setMinimumLengthUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the minimum length of callout lines.
Definition: qgscallout.h:577
SIP_DEPRECATED
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
SIP_CONVERT_TO_SUBCLASS_CODE
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:186
QgsSimpleLineCallout::minimumLength
double minimumLength() const
Returns the minimum length of callout lines.
Definition: qgscallout.h:563
QgsPropertiesDefinition
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.
Definition: qgspropertycollection.h:29
AnchorPoint
record about vertex coordinates and index of anchor to which it is snapped
Definition: qgsgeometrysnappersinglesource.cpp:29
QgsBalloonCallout::setCornerRadiusMapUnitScale
void setCornerRadiusMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the corner radius.
Definition: qgscallout.h:1119
QgsSimpleLineCallout::offsetFromLabel
double offsetFromLabel() const
Returns the offset distance from label area at which to end the line.
Definition: qgscallout.h:652
qgsexpressioncontext.h
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsBalloonCallout::cornerRadius
double cornerRadius() const
Returns the corner radius of the balloon shapes.
Definition: qgscallout.h:1084
QgsCallout::DestinationX
@ DestinationX
X-coordinate of callout destination (feature anchor) (since QGIS 3.20)
Definition: qgscallout.h:93
QgsCallout::LabelAnchorPointPosition
@ LabelAnchorPointPosition
Label's anchor point position.
Definition: qgscallout.h:90
QgsCallout::setDataDefinedProperties
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the callout's property collection, used for data defined overrides.
Definition: qgscallout.h:349
QgsCallout::setBlendMode
void setBlendMode(QPainter::CompositionMode mode)
Sets the blending mode used for drawing callouts.
Definition: qgscallout.h:435
QgsCalloutPosition
Represents the calculated placement of a map label callout line.
Definition: qgscalloutposition.h:32
QgsBalloonCallout::setMarginsUnit
void setMarginsUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the margins between the outside of the callout frame and the label's bounding recta...
Definition: qgscallout.h:1012
QgsBalloonCallout::setOffsetFromAnchor
void setOffsetFromAnchor(double distance)
Sets the offset distance from the anchor point at which to start the line.
Definition: qgscallout.h:950
qgis_sip.h
QgsCallout::labelAnchorPoint
LabelAnchorPoint labelAnchorPoint() const
Returns the label's anchor point position.
Definition: qgscallout.h:394
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsLineSymbol
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgslinesymbol.h:29
QgsCallout::DrawCalloutToAllParts
@ DrawCalloutToAllParts
Whether callout lines should be drawn to all feature parts.
Definition: qgscallout.h:88
QgsMargins
The QgsMargins class defines the four margins of a rectangle.
Definition: qgsmargins.h:37
qgscalloutposition.h
QgsCallout::Centroid
@ Centroid
The surface's centroid is used as anchor for polygon geometries.
Definition: qgscallout.h:116
QgsBalloonCallout::setWedgeWidthUnit
void setWedgeWidthUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the wedge width.
Definition: qgscallout.h:1048
qgscoordinatetransform.h
QgsSimpleLineCallout::offsetFromAnchorMapUnitScale
const QgsMapUnitScale & offsetFromAnchorMapUnitScale() const
Returns the map unit scale for the offset from anchor.
Definition: qgscallout.h:645
QgsSimpleLineCallout::setMinimumLength
void setMinimumLength(double length)
Sets the minimum length of callout lines.
Definition: qgscallout.h:570
QgsCallout::setLabelAnchorPoint
void setLabelAnchorPoint(LabelAnchorPoint anchor)
Sets the label's anchor point position.
Definition: qgscallout.h:402
QgsBalloonCallout::offsetFromAnchorUnit
QgsUnitTypes::RenderUnit offsetFromAnchorUnit() const
Returns the units for the offset from anchor point.
Definition: qgscallout.h:964
QgsSimpleLineCallout::setOffsetFromAnchorMapUnitScale
void setOffsetFromAnchorMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the offset from anchor.
Definition: qgscallout.h:637
QgsMapUnitScale
Struct for storing maximum and minimum scales for measurements in map units.
Definition: qgsmapunitscale.h:36
QgsSimpleLineCallout
A simple direct line callout style.
Definition: qgscallout.h:510
QgsBalloonCallout::offsetFromAnchorMapUnitScale
const QgsMapUnitScale & offsetFromAnchorMapUnitScale() const
Returns the map unit scale for the offset from anchor.
Definition: qgscallout.h:980
QgsCallout::QgsCalloutContext::addCalloutPosition
void addCalloutPosition(const QgsCalloutPosition &position)
Adds a rendered callout position.
Definition: qgscallout.h:276
QgsCallout::readProperties
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 ...
Definition: qgscallout.cpp:90
QgsSimpleLineCallout::setDrawCalloutToAllParts
void setDrawCalloutToAllParts(bool drawToAllParts)
Sets whether callout lines should be drawn to all feature parts.
Definition: qgscallout.h:703
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:211
QgsCallout::OriginX
@ OriginX
X-coordinate of callout origin (label anchor) (since QGIS 3.20)
Definition: qgscallout.h:91
QgsAbstractGeometry
Abstract base class for all geometries.
Definition: qgsabstractgeometry.h:79
QgsSimpleLineCallout::setOffsetFromLabelUnit
void setOffsetFromLabelUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the offset from label area distance.
Definition: qgscallout.h:666
QgsBalloonCallout::marginsUnit
QgsUnitTypes::RenderUnit marginsUnit() const
Returns the units for the margins between the outside of the callout frame and the label's bounding r...
Definition: qgscallout.h:1020
QgsCallout::Orientation
@ Orientation
Orientation of curved line callouts (since QGIS 3.20)
Definition: qgscallout.h:96
QgsCallout::DrawOrder
DrawOrder
Options for draw order (stacking) of callouts.
Definition: qgscallout.h:104
QgsPointXY
A class to represent a 2D point.
Definition: qgspointxy.h:58
QgsCallout::properties
virtual QVariantMap properties(const QgsReadWriteContext &context) const
Returns the properties describing the callout encoded in a string format.
Definition: qgscallout.cpp:79
QgsBalloonCallout::setOffsetFromAnchorMapUnitScale
void setOffsetFromAnchorMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the offset from anchor.
Definition: qgscallout.h:972
QgsPropertyCollection
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
Definition: qgspropertycollection.h:318
QgsSimpleLineCallout::offsetFromLabelMapUnitScale
const QgsMapUnitScale & offsetFromLabelMapUnitScale() const
Returns the map unit scale for the minimum callout length.
Definition: qgscallout.h:689
QgsBalloonCallout::setCornerRadius
void setCornerRadius(double radius)
Sets the radius of the corners for the balloon shapes.
Definition: qgscallout.h:1094
QgsCallout::LabelBottomLeft
@ LabelBottomLeft
Bottom left corner of the label's boundary.
Definition: qgscallout.h:132
QgsManhattanLineCallout
Draws straight (right angled) lines as callouts.
Definition: qgscallout.h:747
QgsSimpleLineCallout::minimumLengthMapUnitScale
const QgsMapUnitScale & minimumLengthMapUnitScale() const
Returns the map unit scale for the minimum callout length.
Definition: qgscallout.h:600
QgsSimpleLineCallout::offsetFromAnchorUnit
QgsUnitTypes::RenderUnit offsetFromAnchorUnit() const
Returns the units for the offset from anchor point.
Definition: qgscallout.h:629
QgsGeometry
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:124
QgsCallout::draw
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.
QgsSimpleLineCallout::minimumLengthUnit
QgsUnitTypes::RenderUnit minimumLengthUnit() const
Returns the units for the minimum length of callout lines.
Definition: qgscallout.h:584
QgsCurvedLineCallout
Draws curved lines as callouts.
Definition: qgscallout.h:790
QgsSimpleLineCallout::operator=
QgsSimpleLineCallout & operator=(const QgsSimpleLineCallout &)=delete
QgsCallout::referencedFields
virtual QSet< QString > referencedFields(const QgsRenderContext &context) const
Returns the set of attributes referenced by the callout.
Definition: qgscallout.cpp:137
QgsBalloonCallout
A cartoon talking bubble callout style.
Definition: qgscallout.h:890
QgsCallout::MinimumCalloutLength
@ MinimumCalloutLength
Minimum length of callouts.
Definition: qgscallout.h:85
QgsFillSymbol
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
Definition: qgsfillsymbol.h:29
qgspropertycollection.h
QgsCallout::LabelMiddleLeft
@ LabelMiddleLeft
Middle left of the label's boundary.
Definition: qgscallout.h:130
QgsBalloonCallout::margins
const QgsMargins & margins() const
Returns the margins between the outside of the callout frame and the label's bounding rectangle.
Definition: qgscallout.h:992
QgsCallout::LabelBottomRight
@ LabelBottomRight
Bottom right corner of the label's boundary.
Definition: qgscallout.h:134
QgsCallout::DestinationY
@ DestinationY
Y-coordinate of callout destination (feature anchor) (since QGIS 3.20)
Definition: qgscallout.h:94
qgsmapunitscale.h
QgsCallout::QgsCalloutContext
Contains additional contextual information about the context in which a callout is being rendered.
Definition: qgscallout.h:245
QgsCallout::LabelTopMiddle
@ LabelTopMiddle
Top middle of the label's boundary.
Definition: qgscallout.h:128
QgsSimpleLineCallout::type
QString type() const override
Returns a unique string representing the callout type.
Definition: qgscallout.cpp:561
QgsCallout::startRender
virtual void startRender(QgsRenderContext &context)
Prepares the callout for rendering on the specified render context.
Definition: qgscallout.cpp:123
QgsCallout::stopRender
virtual void stopRender(QgsRenderContext &context)
Finalises the callout after a set of rendering operations on the specified render context.
Definition: qgscallout.cpp:127
QgsBalloonCallout::wedgeWidthUnit
QgsUnitTypes::RenderUnit wedgeWidthUnit() const
Returns the units for the wedge width.
Definition: qgscallout.h:1056
QgsBalloonCallout::setOffsetFromAnchorUnit
void setOffsetFromAnchorUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the offset from anchor distance.
Definition: qgscallout.h:957
QgsCallout::Property
Property
Data definable properties.
Definition: qgscallout.h:83
QgsSimpleLineCallout::drawCalloutToAllParts
bool drawCalloutToAllParts() const
Returns true if callout lines should be drawn to all feature parts.
Definition: qgscallout.h:696
QgsBalloonCallout::setCornerRadiusUnit
void setCornerRadiusUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the corner radius.
Definition: qgscallout.h:1102
QgsCoordinateTransform
Class for doing transforms between two map coordinate systems.
Definition: qgscoordinatetransform.h:57
QgsCallout::OrderBelowAllLabels
@ OrderBelowAllLabels
Render callouts below all labels.
Definition: qgscallout.h:106
QgsCallout::OrderBelowIndividualLabels
@ OrderBelowIndividualLabels
Render callouts below their individual associated labels, some callouts may be drawn over other label...
Definition: qgscallout.h:107
QgsBalloonCallout::cornerRadiusMapUnitScale
const QgsMapUnitScale & cornerRadiusMapUnitScale() const
Returns the map unit scale for the corner radius.
Definition: qgscallout.h:1128
QgsCallout::clone
virtual QgsCallout * clone() const =0
Duplicates a callout by creating a deep copy of the callout.
MathUtils::angle
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
Definition: MathUtils.cpp:786
SIP_END
#define SIP_END
Definition: qgis_sip.h:203
QgsCallout::LabelAnchorPoint
LabelAnchorPoint
Label's anchor point position.
Definition: qgscallout.h:123
QgsBalloonCallout::setWedgeWidthMapUnitScale
void setWedgeWidthMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale for the wedge width.
Definition: qgscallout.h:1065
QgsCallout::OffsetFromLabel
@ OffsetFromLabel
Distance to offset lines from label area.
Definition: qgscallout.h:87
QgsSimpleLineCallout::setOffsetFromAnchor
void setOffsetFromAnchor(double distance)
Sets the offset distance from the anchor point at which to start the line.
Definition: qgscallout.h:615
QgsBalloonCallout::offsetFromAnchor
double offsetFromAnchor() const
Returns the offset distance from the anchor point at which to start the line.
Definition: qgscallout.h:943
QgsCallout::setAnchorPoint
void setAnchorPoint(AnchorPoint anchor)
Sets the feature's anchor point position.
Definition: qgscallout.h:368
QgsCallout::dataDefinedProperties
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the callout's property collection, used for data defined overrides.
Definition: qgscallout.h:331
QgsCallout::enabled
bool enabled() const
Returns true if the the callout is enabled.
Definition: qgscallout.h:319
QgsCallout::PointOnSurface
@ PointOnSurface
A point guaranteed to be on the surface is used as anchor for polygon geometries.
Definition: qgscallout.h:115
QgsCurvedLineCallout::Orientation
Orientation
Curve orientation.
Definition: qgscallout.h:797
QgsCallout::LabelTopRight
@ LabelTopRight
Top right corner of the label's boundary.
Definition: qgscallout.h:129
QgsCurvedLineCallout::Automatic
@ Automatic
Automatically choose most cartographically pleasing orientation based on label and callout arrangemen...
Definition: qgscallout.h:799
qgsmargins.h