QGIS API Documentation 3.99.0-Master (c03dd32cbdd)
Loading...
Searching...
No Matches
qgslayoutitemmapgrid.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslayoutitemmapgrid.h
3 ----------------------
4 begin : October 2017
5 copyright : (C) 2017 by Marco Hugentobler, Nyall Dawson
6 email : marco dot hugentobler at sourcepole dot ch
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
18#ifndef QGSLAYOUTITEMMAPGRID_H
19#define QGSLAYOUTITEMMAPGRID_H
20
21#include "qgis_core.h"
22#include "qgis_sip.h"
24#include "qgstextformat.h"
25
26#include <QPainter>
27#include <QVector2D>
28
32class QDomDocument;
33class QDomElement;
34class QPainter;
36class QgsLineSymbol;
37
47{
48 public:
49
54
64
71 void removeGrid( const QString &gridId );
72
79 void moveGridUp( const QString &gridId );
80
87 void moveGridDown( const QString &gridId );
88
92 QgsLayoutItemMapGrid *grid( const QString &gridId ) const;
93
97 QgsLayoutItemMapGrid *grid( int index ) const;
98
103 QgsLayoutItemMapGrid &operator[]( int index ); // cppcheck-suppress duplInheritedMember
104
108 QList< QgsLayoutItemMapGrid * > asList() const; // cppcheck-suppress duplInheritedMember
109
110 bool readXml( const QDomElement &elem, const QDomDocument &doc, const QgsReadWriteContext &context ) override;
111
117 double maxGridExtension() const;
118
125 void calculateMaxGridExtension( double &top, double &right, double &bottom, double &left ) const;
126};
127
128//
129// QgsLayoutItemMapGrid
130//
131
140{
141
142 Q_OBJECT
143
144 public:
145
151 QgsLayoutItemMapGrid( const QString &name, QgsLayoutItemMap *map );
153
154 void draw( QPainter *painter ) override;
155 bool writeXml( QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
156 bool readXml( const QDomElement &itemElem, const QDomDocument &doc, const QgsReadWriteContext &context ) override;
157
163
168 QgsCoordinateReferenceSystem crs() const { return mCRS; }
169
174 void setBlendMode( const QPainter::CompositionMode mode ) { mBlendMode = mode; }
175
180 QPainter::CompositionMode blendMode() const { return mBlendMode; }
181
182 bool usesAdvancedEffects() const override;
183
188 double maxExtension() const;
189
196 void calculateMaxExtension( double &top, double &right, double &bottom, double &left ) const;
197
198 void setEnabled( bool enabled ) override;
199
200 //
201 // GRID UNITS
202 //
203
209 void setUnits( Qgis::MapGridUnit unit );
210
216 Qgis::MapGridUnit units() const { return mGridUnit; }
217
224 void setIntervalX( double interval );
225
232 double intervalX() const { return mGridIntervalX; }
233
240 void setIntervalY( double interval );
241
248 double intervalY() const { return mGridIntervalY; }
249
256 void setOffsetX( double offset );
257
264 double offsetX() const { return mGridOffsetX; }
265
272 void setOffsetY( double offset );
273
280 double offsetY() const { return mGridOffsetY; }
281
291 double minimumIntervalWidth() const { return mMinimumIntervalWidth; }
292
302 void setMinimumIntervalWidth( double width );
303
313 double maximumIntervalWidth() const { return mMaximumIntervalWidth; }
314
324 void setMaximumIntervalWidth( double width );
325
326 //
327 // GRID APPEARANCE
328 //
329
335 void setStyle( Qgis::MapGridStyle style );
336
342 Qgis::MapGridStyle style() const { return mGridStyle; }
343
349 void setCrossLength( const double length );
350
356 double crossLength() const { return mCrossLength; }
357
365 void setGridLineWidth( double width );
366
374 void setGridLineColor( const QColor &color );
375
384 void setLineSymbol( QgsLineSymbol *symbol SIP_TRANSFER );
385
394 const QgsLineSymbol *lineSymbol() const; SIP_SKIP
395
403 QgsLineSymbol *lineSymbol();
404
413 void setMarkerSymbol( QgsMarkerSymbol *symbol SIP_TRANSFER );
414
423 const QgsMarkerSymbol *markerSymbol() const; SIP_SKIP
424
432 QgsMarkerSymbol *markerSymbol();
433
434 //
435 // ANNOTATIONS
436 //
437
442 void setAnnotationEnabled( const bool enabled ) { mShowGridAnnotation = enabled; }
443
448 bool annotationEnabled() const { return mShowGridAnnotation; }
449
456 void setAnnotationTextFormat( const QgsTextFormat &format ) { mAnnotationFormat = format; }
457
464 QgsTextFormat annotationTextFormat() const { return mAnnotationFormat; }
465
472 Q_DECL_DEPRECATED void setAnnotationFont( const QFont &font ) SIP_DEPRECATED;
473
480 Q_DECL_DEPRECATED QFont annotationFont() const SIP_DEPRECATED;
481
488 Q_DECL_DEPRECATED void setAnnotationFontColor( const QColor &color ) SIP_DEPRECATED;
489
496 Q_DECL_DEPRECATED QColor annotationFontColor() const SIP_DEPRECATED;
497
503 void setAnnotationPrecision( const int precision ) { mGridAnnotationPrecision = precision; }
504
510 int annotationPrecision() const { return mGridAnnotationPrecision; }
511
519 void setAnnotationDisplay( Qgis::MapGridComponentVisibility display, Qgis::MapGridBorderSide border );
520
529 Qgis::MapGridComponentVisibility annotationDisplay( Qgis::MapGridBorderSide border ) const;
530
536 void setAnnotationPosition( Qgis::MapGridAnnotationPosition position, Qgis::MapGridBorderSide side );
537
543 Qgis::MapGridAnnotationPosition annotationPosition( Qgis::MapGridBorderSide side ) const;
544
549 void setAnnotationFrameDistance( const double distance );
550
555 double annotationFrameDistance() const { return mAnnotationFrameDistance; }
556
561 void setAnnotationDirection( Qgis::MapGridAnnotationDirection direction, Qgis::MapGridBorderSide side );
562
567 void setAnnotationDirection( Qgis::MapGridAnnotationDirection direction );
568
574 Qgis::MapGridAnnotationDirection annotationDirection( Qgis::MapGridBorderSide border ) const;
575
580 void setAnnotationFormat( const Qgis::MapGridAnnotationFormat format ) { mGridAnnotationFormat = format; }
581
586 Qgis::MapGridAnnotationFormat annotationFormat() const { return mGridAnnotationFormat; }
587
593 void setAnnotationExpression( const QString &expression );
594
600 QString annotationExpression() const { return mGridAnnotationExpressionString; }
601
602 //
603 // GRID FRAME
604 //
605
610 void setFrameStyle( const Qgis::MapGridFrameStyle style ) { mGridFrameStyle = style; }
611
616 Qgis::MapGridFrameStyle frameStyle() const { return mGridFrameStyle; }
617
622 void setFrameDivisions( Qgis::MapGridComponentVisibility divisions, Qgis::MapGridBorderSide side );
623
629
637 void setFrameSideFlags( Qgis::MapGridFrameSideFlags flags );
638
647 void setFrameSideFlag( Qgis::MapGridFrameSideFlag flag, bool on = true );
648
656 Qgis::MapGridFrameSideFlags frameSideFlags() const;
657
667 bool testFrameSideFlag( Qgis::MapGridFrameSideFlag flag ) const;
668
675 void setFrameWidth( const double width );
676
683 double frameWidth() const { return mGridFrameWidth; }
684
690 void setRotatedTicksEnabled( const bool state ) { mRotatedTicksEnabled = state; }
691
697 bool rotatedTicksEnabled() const { return mRotatedTicksEnabled; }
698
704 void setRotatedTicksLengthMode( const Qgis::MapGridTickLengthMode mode ) { mRotatedTicksLengthMode = mode; }
705
711 Qgis::MapGridTickLengthMode rotatedTicksLengthMode() const { return mRotatedTicksLengthMode; }
712
718 void setRotatedTicksMinimumAngle( const double angle ) { mRotatedTicksMinimumAngle = angle; }
719
725 double rotatedTicksMinimumAngle() const { return mRotatedTicksMinimumAngle; }
726
732 void setRotatedTicksMarginToCorner( const double margin ) { mRotatedTicksMarginToCorner = margin; }
733
739 double rotatedTicksMarginToCorner() const { return mRotatedTicksMarginToCorner; }
740
746 void setRotatedAnnotationsEnabled( const bool state ) { mRotatedAnnotationsEnabled = state; }
747
753 bool rotatedAnnotationsEnabled() const { return mRotatedAnnotationsEnabled; }
754
760 void setRotatedAnnotationsLengthMode( const Qgis::MapGridTickLengthMode mode ) { mRotatedAnnotationsLengthMode = mode; }
761
767 Qgis::MapGridTickLengthMode rotatedAnnotationsLengthMode() const { return mRotatedAnnotationsLengthMode; }
768
774 void setRotatedAnnotationsMinimumAngle( const double angle ) { mRotatedAnnotationsMinimumAngle = angle; }
775
781 double rotatedAnnotationsMinimumAngle() const { return mRotatedAnnotationsMinimumAngle; }
782
788 void setRotatedAnnotationsMarginToCorner( const double margin ) { mRotatedAnnotationsMarginToCorner = margin; }
789
795 double rotatedAnnotationsMarginToCorner() const { return mRotatedAnnotationsMarginToCorner; }
796
803 void setFrameMargin( const double margin );
804
811 double frameMargin() const { return mGridFrameMargin; }
812
818 void setFramePenSize( const double width );
819
825 double framePenSize() const { return mGridFramePenThickness; }
826
834 void setFramePenColor( const QColor &color ) { mGridFramePenColor = color; }
835
843 QColor framePenColor() const {return mGridFramePenColor;}
844
851 void setFrameFillColor1( const QColor &color ) { mGridFrameFillColor1 = color; }
852
859 QColor frameFillColor1() const { return mGridFrameFillColor1; }
860
867 void setFrameFillColor2( const QColor &color ) { mGridFrameFillColor2 = color; }
868
875 QColor frameFillColor2() const { return mGridFrameFillColor2; }
876
883 Qgis::TextHorizontalAlignment horizontalAlignment() const;
884
891 void setHorizontalAlignment( Qgis::TextHorizontalAlignment alignment );
892
893 QgsExpressionContext createExpressionContext() const override;
894 bool accept( QgsStyleEntityVisitorInterface *visitor ) const override;
895 void refresh() override;
896
902 void copyProperties( const QgsLayoutItemMapGrid *other );
903
904 signals:
905
912
913 private:
914
915 QgsLayoutItemMapGrid() = delete;
916
917 struct GridExtension
918 {
919 GridExtension() = default;
920 double top = 0.0;
921 double right = 0.0;
922 double bottom = 0.0;
923 double left = 0.0;
924
928 void UpdateBorder( Qgis::MapGridBorderSide border, double value )
929 {
930 switch ( border )
931 {
933 left = std::max( left, value );
934 break;
936 right = std::max( right, value );
937 break;
939 top = std::max( top, value );
940 break;
942 bottom = std::max( bottom, value );
943 break;
944 }
945 }
946
950 void UpdateAll( double value )
951 {
952 left = std::max( left, value );
953 right = std::max( right, value );
954 top = std::max( top, value );
955 bottom = std::max( bottom, value );
956 }
957 };
958
959 struct GridLineAnnotation
960 {
961 Qgis::MapGridBorderSide border = Qgis::MapGridBorderSide::Left; // border on which the annotation is
962 QVector2D position; // position on the frame
963 QVector2D vector; // vector towards map center
964 double angle = 0; // the (acute) angle formed between the vector and the border
965 };
966
971 struct GridLine
972 {
973 QPolygonF line; // the actual line, can be straight with two points or curved if transformed
974 double coordinate; // the coordinate value
975 Qgis::MapGridAnnotationType coordinateType; // whether it's a latitude or longitude line
976 GridLineAnnotation startAnnotation; // the annotation on the start point
977 GridLineAnnotation endAnnotation; // the annotation on the end point
978 };
979 mutable QList< GridLine > mGridLines;
980
982 mutable bool mTransformDirty = true;
983
987 double mGridIntervalX = 0.0;
989 double mGridIntervalY = 0.0;
991 double mGridOffsetX = 0.0;
993 double mGridOffsetY = 0.0;
994
996 QgsTextFormat mAnnotationFormat;
997
999 int mGridAnnotationPrecision = 3;
1001 bool mShowGridAnnotation = false;
1002
1004
1013
1022
1024 double mAnnotationFrameDistance = 1.0;
1025
1035
1036 QString mGridAnnotationExpressionString;
1037 mutable std::unique_ptr< QgsExpression > mGridAnnotationExpression;
1038
1040
1041 Qgis::MapGridFrameSideFlags mGridFrameSides;
1042 double mGridFrameWidth = 2.0;
1043 double mGridFramePenThickness = 0.3;
1044 QColor mGridFramePenColor = QColor( 0, 0, 0 );
1045 QColor mGridFrameFillColor1 = Qt::white;
1046 QColor mGridFrameFillColor2 = Qt::black;
1047 double mCrossLength = 3.0;
1048 double mGridFrameMargin = 0.0;
1049 bool mRotatedTicksEnabled = false;
1051 double mRotatedTicksMinimumAngle = 0.0;
1052 double mRotatedTicksMarginToCorner = 0.0;
1053 bool mRotatedAnnotationsEnabled = false;
1055 double mRotatedAnnotationsMinimumAngle = 0.0;
1056 double mRotatedAnnotationsMarginToCorner = 0.0;
1057
1058 double mMinimumIntervalWidth = 50;
1059 double mMaximumIntervalWidth = 100;
1060
1069
1070 std::unique_ptr< QgsLineSymbol > mGridLineSymbol;
1071 std::unique_ptr< QgsMarkerSymbol > mGridMarkerSymbol;
1072
1073 QgsCoordinateReferenceSystem mCRS;
1074
1076
1077 QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
1078
1079 mutable QList< QPair< double, QPolygonF > > mTransformedXLines;
1080 mutable QList< QPair< double, QPolygonF > > mTransformedYLines;
1081 mutable QList< QgsPointXY > mTransformedIntersections;
1082 QRectF mPrevPaintRect;
1083 mutable QPolygonF mPrevMapPolygon;
1084
1085 bool mEvaluatedEnabled = true;
1086 double mEvaluatedIntervalX = 0;
1087 double mEvaluatedIntervalY = 0;
1088 double mEvaluatedOffsetX = 0;
1089 double mEvaluatedOffsetY = 0;
1090 double mEvaluatedGridFrameWidth = 0;
1091 double mEvaluatedGridFrameMargin = 0;
1092 double mEvaluatedAnnotationFrameDistance = 0;
1093 double mEvaluatedCrossLength = 0;
1094 double mEvaluatedGridFrameLineThickness = 0;
1095 std::unique_ptr< QgsProperty > mDrawAnnotationProperty;
1104
1108 void updateGridLinesAnnotationsPositions() const;
1109
1114 void drawGridFrame( QPainter *p, GridExtension *extension = nullptr ) const;
1115
1123 void drawCoordinateAnnotations( QgsRenderContext &context, QgsExpressionContext &expressionContext, GridExtension *extension = nullptr ) const;
1124
1129 void drawCoordinateAnnotation( QgsRenderContext &context, GridLineAnnotation annot, const QString &annotationString, Qgis::MapGridAnnotationType coordinateType, GridExtension *extension = nullptr ) const;
1130
1131 QString gridAnnotationString( double value, Qgis::MapGridAnnotationType coord, QgsExpressionContext &expressionContext, bool isGeographic ) const;
1132
1137 int xGridLines() const;
1138
1143 int yGridLines() const;
1144
1145 int xGridLinesCrsTransform( const QgsRectangle &bbox, const QgsCoordinateTransform &t ) const;
1146
1147 int yGridLinesCrsTransform( const QgsRectangle &bbox, const QgsCoordinateTransform &t ) const;
1148
1149 void drawGridLine( const QLineF &line, QgsRenderContext &context ) const;
1150
1151 void drawGridLine( const QPolygonF &line, QgsRenderContext &context ) const;
1152
1157 void drawGridFrameBorder( QPainter *p, Qgis::MapGridBorderSide border, double *extension = nullptr ) const;
1158
1164 Qgis::MapGridBorderSide borderForLineCoord( QPointF p, Qgis::MapGridAnnotationType coordinateType ) const;
1165
1167 int crsGridParams( QgsRectangle &crsRect, QgsCoordinateTransform &inverseTransform ) const;
1168
1169 static QList<QPolygonF> trimLinesToMap( const QPolygonF &line, const QgsRectangle &rect );
1170
1171 QPolygonF scalePolygon( const QPolygonF &polygon, double scale ) const;
1172
1174 void drawGridCrsTransform( QgsRenderContext &context, double dotsPerMM, bool calculateLinesOnly = false ) const;
1175
1176 void drawGridNoTransform( QgsRenderContext &context, double dotsPerMM, bool calculateLinesOnly = false ) const;
1177
1178 void createDefaultGridLineSymbol();
1179
1180 void createDefaultGridMarkerSymbol();
1181
1182 void drawGridMarker( QPointF point, QgsRenderContext &context ) const;
1183
1184 void drawGridFrameZebra( QPainter *p, GridExtension *extension = nullptr ) const;
1185
1186 void drawGridFrameZebraBorder( QPainter *p, Qgis::MapGridBorderSide border, double *extension = nullptr ) const;
1187
1188 void drawGridFrameTicks( QPainter *p, GridExtension *extension = nullptr ) const;
1189
1190 void drawGridFrameLine( QPainter *p, GridExtension *extension = nullptr ) const;
1191
1192 void calculateCrsTransformLines() const;
1193
1194 bool shouldShowDivisionForSide( Qgis::MapGridAnnotationType coordinate, Qgis::MapGridBorderSide side ) const;
1195 bool shouldShowAnnotationForSide( Qgis::MapGridAnnotationType coordinate, Qgis::MapGridBorderSide side ) const;
1196 bool shouldShowForDisplayMode( Qgis::MapGridAnnotationType coordinate, Qgis::MapGridComponentVisibility mode ) const;
1197 void refreshDataDefinedProperties();
1198
1200 double mapWidth() const;
1201
1203
1204 // Needs access to evaluated properties to compute frame bleed
1205 friend class QgsLayoutItemMap;
1206
1207};
1208
1209
1210#endif // QGSLAYOUTITEMMAPGRID_H
MapGridTickLengthMode
Map grid tick length mode (useful for rotated grids).
Definition qgis.h:5607
@ OrthogonalTicks
Align ticks orthogonaly.
Definition qgis.h:5608
QFlags< MapGridFrameSideFlag > MapGridFrameSideFlags
Flags for controlling which side of the map a frame is drawn on.
Definition qgis.h:5637
MapGridAnnotationPosition
Position for map grid annotations.
Definition qgis.h:5517
@ OutsideMapFrame
Draw annotations outside the map frame.
Definition qgis.h:5519
MapGridUnit
Units for map grid values.
Definition qgis.h:5469
@ MapUnits
Grid units follow map units.
Definition qgis.h:5470
MapGridBorderSide
Border sides for map grid annotations.
Definition qgis.h:5571
@ Bottom
Bottom border.
Definition qgis.h:5574
@ Right
Right border.
Definition qgis.h:5573
@ Left
Left border.
Definition qgis.h:5572
@ Top
Top border.
Definition qgis.h:5575
MapGridFrameSideFlag
Flags for controlling which side of the map a frame is drawn on.
Definition qgis.h:5622
MapGridComponentVisibility
Visibility display settings for map grid annotations and frames.
Definition qgis.h:5501
@ ShowAll
Show both latitude and longitude annotations/divisions.
Definition qgis.h:5502
MapGridStyle
Map grid drawing styles.
Definition qgis.h:5485
@ Lines
Draw lines for grid.
Definition qgis.h:5486
MapGridAnnotationType
Annotation coordinate type.
Definition qgis.h:5648
MapGridFrameStyle
Style for map grid frames.
Definition qgis.h:5587
@ NoFrame
Disable grid frame.
Definition qgis.h:5588
MapGridAnnotationDirection
Direction of grid annotations.
Definition qgis.h:5531
@ Horizontal
Draw annotations horizontally.
Definition qgis.h:5532
TextHorizontalAlignment
Text horizontal alignment.
Definition qgis.h:3002
@ Center
Center align.
Definition qgis.h:3004
MapGridAnnotationFormat
Format for displaying map grid annotations.
Definition qgis.h:5550
@ Decimal
Decimal degrees, use - for S/W coordinates.
Definition qgis.h:5551
Represents a coordinate reference system (CRS).
Handles coordinate transforms between two coordinate systems.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void calculateMaxGridExtension(double &top, double &right, double &bottom, double &left) const
Calculates the maximum distance grids within the stack extend beyond the QgsLayoutItemMap's item rect...
void removeGrid(const QString &gridId)
Removes a grid with matching gridId from the stack and deletes the corresponding QgsLayoutItemMapGrid...
double maxGridExtension() const
Calculates the maximum distance grids within the stack extend beyond the QgsLayoutItemMap's item rect...
void addGrid(QgsLayoutItemMapGrid *grid)
Adds a new map grid to the stack and takes ownership of the grid.
QgsLayoutItemMapGrid * grid(const QString &gridId) const
Returns a reference to a grid with matching gridId within the stack.
void moveGridUp(const QString &gridId)
Moves a grid with matching gridId up the stack, causing it to be rendered above other grids.
void moveGridDown(const QString &gridId)
Moves a grid with matching gridId down the stack, causing it to be rendered below other grids.
QgsLayoutItemMapGridStack(QgsLayoutItemMap *map)
Constructor for QgsLayoutItemMapGridStack, attached to the specified map.
An individual grid which is drawn above the map content in a QgsLayoutItemMap.
void setRotatedTicksLengthMode(const Qgis::MapGridTickLengthMode mode)
Sets the tick length calculation mode.
bool rotatedAnnotationsEnabled() const
Gets whether annotations rotation for rotated or reprojected grids is enabled.
QString annotationExpression() const
Returns the expression used for drawing grid annotations.
double rotatedTicksMarginToCorner() const
Gets the margin to corners (in canvas units) below which outwards facing ticks are not drawn.
void setFrameFillColor2(const QColor &color)
Sets the second fill color used for the grid frame.
void setFrameStyle(const Qgis::MapGridFrameStyle style)
Sets the grid frame style.
double frameWidth() const
Gets the grid frame width in layout units.
void draw(QPainter *painter) override
Draws the item on to a destination painter.
double crossLength() const
Retrieves the length (in layout units) of the cross segments drawn for the grid.
void setRotatedTicksMinimumAngle(const double angle)
Sets the minimum angle (in degrees) below which ticks are not drawn.
QPainter::CompositionMode blendMode() const
Retrieves the blending mode used for drawing the grid.
void setAnnotationEnabled(const bool enabled)
Sets whether annotations should be shown for the grid.
QgsTextFormat annotationTextFormat() const
Returns the text format used when rendering grid annotations.
double framePenSize() const
Retrieves the width of the stroke drawn in the grid frame.
void setFramePenColor(const QColor &color)
Sets the color of the stroke drawn in the grid frame.
void setRotatedTicksEnabled(const bool state)
Enable/disable ticks rotation for rotated or reprojected grids.
Qgis::MapGridUnit units() const
Returns the units used for grid measurements such as the interval and offset for grid lines.
Qgis::MapGridStyle style() const
Returns the grid's style, which controls how the grid is drawn over the map's contents.
double rotatedTicksMinimumAngle() const
Gets the minimum angle (in degrees) below which ticks are not drawn.
Qgis::MapGridTickLengthMode rotatedAnnotationsLengthMode() const
Returns the annotation length calculation mode.
Qgis::MapGridFrameStyle frameStyle() const
Returns the grid frame style.
double offsetY() const
Returns the offset for grid lines in the y-direction.
void crsChanged()
Emitted whenever the grid's CRS is changed.
void setRotatedAnnotationsMinimumAngle(const double angle)
Sets the minimum angle (in degrees) below which annotations are not drawn.
double rotatedAnnotationsMinimumAngle() const
Gets the minimum angle (in degrees) below which annotations are not drawn.
void setAnnotationTextFormat(const QgsTextFormat &format)
Sets the text format to use when rendering grid annotations.
QgsLayoutItemMapGrid(const QString &name, QgsLayoutItemMap *map)
Constructor for QgsLayoutItemMapGrid.
Qgis::MapGridTickLengthMode rotatedTicksLengthMode() const
Returns the grid frame style.
~QgsLayoutItemMapGrid() override
void setBlendMode(const QPainter::CompositionMode mode)
Sets the blending mode used for drawing the grid.
bool annotationEnabled() const
Returns whether annotations are shown for the grid.
QColor framePenColor() const
Retrieves the color of the stroke drawn in the grid frame.
void setRotatedTicksMarginToCorner(const double margin)
Sets the margin to corners (in canvas units) below which outwards facing ticks are not drawn.
void setAnnotationPrecision(const int precision)
Sets the coordinate precision for grid annotations.
QColor frameFillColor2() const
Retrieves the second fill color for the grid frame.
void setRotatedAnnotationsLengthMode(const Qgis::MapGridTickLengthMode mode)
Sets the annotation length calculation mode.
QgsCoordinateReferenceSystem crs() const
Retrieves the CRS for the grid.
void setRotatedAnnotationsMarginToCorner(const double margin)
Sets the margin to corners (in canvas units) below which outwards facing annotations are not drawn.
double rotatedAnnotationsMarginToCorner() const
Gets the margin to corners (in canvas units) below which outwards facing annotations are not drawn.
double offsetX() const
Returns the offset for grid lines in the x-direction.
bool rotatedTicksEnabled() const
Gets whether ticks rotation for rotated or reprojected grids is enabled.
double annotationFrameDistance() const
Returns the distance between the map frame and annotations.
double intervalY() const
Returns the interval between grid lines in the y-direction.
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets the crs for the grid.
double minimumIntervalWidth() const
Returns the minimum width (in millimeters) for grid segments.
QColor frameFillColor1() const
Retrieves the first fill color for the grid frame.
void setRotatedAnnotationsEnabled(const bool state)
Enable/disable annotations rotation for rotated or reprojected grids.
void setAnnotationFormat(const Qgis::MapGridAnnotationFormat format)
Sets the format for drawing grid annotations.
void setFrameFillColor1(const QColor &color)
Sets the first fill color used for the grid frame.
double frameMargin() const
Sets the grid frame Margin (in layout units).
Qgis::MapGridAnnotationFormat annotationFormat() const
Returns the format for drawing grid annotations.
int annotationPrecision() const
Returns the coordinate precision for grid annotations, which is the number of decimal places shown wh...
double maximumIntervalWidth() const
Returns the maximum width (in millimeters) for grid segments.
double intervalX() const
Returns the interval between grid lines in the x-direction.
virtual bool writeXml(QDomElement &element, QDomDocument &doc, const QgsReadWriteContext &context) const
Stores the state of the item stack in a DOM node, where element is the DOM element corresponding to a...
virtual bool readXml(const QDomElement &element, const QDomDocument &doc, const QgsReadWriteContext &context)=0
Sets the item stack's state from a DOM document, where element is a DOM node corresponding to a 'Layo...
QList< QgsLayoutItemMapItem * > asList() const
Returns a list of QgsLayoutItemMapItems contained by the stack.
QgsLayoutItemMapItemStack(QgsLayoutItemMap *map)
Constructor for QgsLayoutItemMapItemStack, attached to the specified map.
QgsLayoutItemMapItem & operator[](int index)
Returns a reference to an item at the specified index within the stack.
QString name() const
Returns the friendly display name for the item.
QgsLayoutItemMapItem(const QString &name, QgsLayoutItemMap *map)
Constructor for QgsLayoutItemMapItem, attached to the specified map.
bool enabled() const
Returns whether the item will be drawn.
const QgsLayoutItemMap * map() const
Returns the layout item map for the item.
Layout graphical items for displaying a map.
A line symbol type, for rendering LineString and MultiLineString geometries.
A marker symbol type, for rendering Point and MultiPoint geometries.
A container for the context for various read/write operations on objects.
Contains information about the context of a rendering operation.
An interface for classes which can visit style entity (e.g.
Container for all settings relating to text rendering.
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).
#define SIP_DEPRECATED
Definition qgis_sip.h:113
#define SIP_SKIP
Definition qgis_sip.h:133
#define SIP_TRANSFER
Definition qgis_sip.h:35