QGIS API Documentation 4.1.0-Master (659fe69c07c)
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:
53
63
70 void removeGrid( const QString &gridId );
71
78 void moveGridUp( const QString &gridId );
79
86 void moveGridDown( const QString &gridId );
87
91 QgsLayoutItemMapGrid *grid( const QString &gridId ) const;
92
96 QgsLayoutItemMapGrid *grid( int index ) const;
97
102 QgsLayoutItemMapGrid &operator[]( int index ); // cppcheck-suppress duplInheritedMember
103
107 QList< QgsLayoutItemMapGrid * > asList() const; // cppcheck-suppress duplInheritedMember
108
109 bool readXml( const QDomElement &elem, const QDomDocument &doc, const QgsReadWriteContext &context ) override;
110
116 double maxGridExtension() const;
117
124 void calculateMaxGridExtension( double &top, double &right, double &bottom, double &left ) const;
125};
126
127//
128// QgsLayoutItemMapGrid
129//
130
139{
140 Q_OBJECT
141
142 public:
148 QgsLayoutItemMapGrid( const QString &name, QgsLayoutItemMap *map );
150
151 void draw( QPainter *painter ) override;
152 bool writeXml( QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
153 bool readXml( const QDomElement &itemElem, const QDomDocument &doc, const QgsReadWriteContext &context ) override;
154
160
165 QgsCoordinateReferenceSystem crs() const { return mCRS; }
166
171 void setBlendMode( const QPainter::CompositionMode mode ) { mBlendMode = mode; }
172
177 QPainter::CompositionMode blendMode() const { return mBlendMode; }
178
179 bool usesAdvancedEffects() const override;
180
185 double maxExtension() const;
186
193 void calculateMaxExtension( double &top, double &right, double &bottom, double &left ) const;
194
195 void setEnabled( bool enabled ) override;
196
197 //
198 // GRID UNITS
199 //
200
206 void setUnits( Qgis::MapGridUnit unit );
207
213 Qgis::MapGridUnit units() const { return mGridUnit; }
214
221 void setIntervalX( double interval );
222
229 double intervalX() const { return mGridIntervalX; }
230
237 void setIntervalY( double interval );
238
245 double intervalY() const { return mGridIntervalY; }
246
253 void setOffsetX( double offset );
254
261 double offsetX() const { return mGridOffsetX; }
262
269 void setOffsetY( double offset );
270
277 double offsetY() const { return mGridOffsetY; }
278
288 double minimumIntervalWidth() const { return mMinimumIntervalWidth; }
289
299 void setMinimumIntervalWidth( double width );
300
310 double maximumIntervalWidth() const { return mMaximumIntervalWidth; }
311
321 void setMaximumIntervalWidth( double width );
322
323 //
324 // GRID APPEARANCE
325 //
326
332 void setStyle( Qgis::MapGridStyle style );
333
339 Qgis::MapGridStyle style() const { return mGridStyle; }
340
346 void setCrossLength( const double length );
347
353 double crossLength() const { return mCrossLength; }
354
362 void setGridLineWidth( double width );
363
371 void setGridLineColor( const QColor &color );
372
381 void setLineSymbol( QgsLineSymbol *symbol SIP_TRANSFER );
382
391 const QgsLineSymbol *lineSymbol() const SIP_SKIP;
392
400 QgsLineSymbol *lineSymbol();
401
410 void setMarkerSymbol( QgsMarkerSymbol *symbol SIP_TRANSFER );
411
420 const QgsMarkerSymbol *markerSymbol() const SIP_SKIP;
421
429 QgsMarkerSymbol *markerSymbol();
430
431 //
432 // ANNOTATIONS
433 //
434
439 void setAnnotationEnabled( const bool enabled ) { mShowGridAnnotation = enabled; }
440
445 bool annotationEnabled() const { return mShowGridAnnotation; }
446
453 void setAnnotationTextFormat( const QgsTextFormat &format ) { mAnnotationFormat = format; }
454
461 QgsTextFormat annotationTextFormat() const { return mAnnotationFormat; }
462
469 Q_DECL_DEPRECATED void setAnnotationFont( const QFont &font ) SIP_DEPRECATED;
470
477 Q_DECL_DEPRECATED QFont annotationFont() const SIP_DEPRECATED;
478
485 Q_DECL_DEPRECATED void setAnnotationFontColor( const QColor &color ) SIP_DEPRECATED;
486
493 Q_DECL_DEPRECATED QColor annotationFontColor() const SIP_DEPRECATED;
494
500 void setAnnotationPrecision( const int precision ) { mGridAnnotationPrecision = precision; }
501
507 int annotationPrecision() const { return mGridAnnotationPrecision; }
508
516 void setAnnotationDisplay( Qgis::MapGridComponentVisibility display, Qgis::MapGridBorderSide border );
517
526 Qgis::MapGridComponentVisibility annotationDisplay( Qgis::MapGridBorderSide border ) const;
527
533 void setAnnotationPosition( Qgis::MapGridAnnotationPosition position, Qgis::MapGridBorderSide side );
534
540 Qgis::MapGridAnnotationPosition annotationPosition( Qgis::MapGridBorderSide side ) const;
541
546 void setAnnotationFrameDistance( const double distance );
547
552 double annotationFrameDistance() const { return mAnnotationFrameDistance; }
553
558 void setAnnotationDirection( Qgis::MapGridAnnotationDirection direction, Qgis::MapGridBorderSide side );
559
564 void setAnnotationDirection( Qgis::MapGridAnnotationDirection direction );
565
571 Qgis::MapGridAnnotationDirection annotationDirection( Qgis::MapGridBorderSide border ) const;
572
577 void setAnnotationFormat( const Qgis::MapGridAnnotationFormat format ) { mGridAnnotationFormat = format; }
578
583 Qgis::MapGridAnnotationFormat annotationFormat() const { return mGridAnnotationFormat; }
584
590 void setAnnotationExpression( const QString &expression );
591
597 QString annotationExpression() const { return mGridAnnotationExpressionString; }
598
599 //
600 // GRID FRAME
601 //
602
607 void setFrameStyle( const Qgis::MapGridFrameStyle style ) { mGridFrameStyle = style; }
608
613 Qgis::MapGridFrameStyle frameStyle() const { return mGridFrameStyle; }
614
619 void setFrameDivisions( Qgis::MapGridComponentVisibility divisions, Qgis::MapGridBorderSide side );
620
626
634 void setFrameSideFlags( Qgis::MapGridFrameSideFlags flags );
635
644 void setFrameSideFlag( Qgis::MapGridFrameSideFlag flag, bool on = true );
645
653 Qgis::MapGridFrameSideFlags frameSideFlags() const;
654
664 bool testFrameSideFlag( Qgis::MapGridFrameSideFlag flag ) const;
665
672 void setFrameWidth( const double width );
673
680 double frameWidth() const { return mGridFrameWidth; }
681
687 void setRotatedTicksEnabled( const bool state ) { mRotatedTicksEnabled = state; }
688
694 bool rotatedTicksEnabled() const { return mRotatedTicksEnabled; }
695
701 void setRotatedTicksLengthMode( const Qgis::MapGridTickLengthMode mode ) { mRotatedTicksLengthMode = mode; }
702
708 Qgis::MapGridTickLengthMode rotatedTicksLengthMode() const { return mRotatedTicksLengthMode; }
709
715 void setRotatedTicksMinimumAngle( const double angle ) { mRotatedTicksMinimumAngle = angle; }
716
722 double rotatedTicksMinimumAngle() const { return mRotatedTicksMinimumAngle; }
723
729 void setRotatedTicksMarginToCorner( const double margin ) { mRotatedTicksMarginToCorner = margin; }
730
736 double rotatedTicksMarginToCorner() const { return mRotatedTicksMarginToCorner; }
737
743 void setRotatedAnnotationsEnabled( const bool state ) { mRotatedAnnotationsEnabled = state; }
744
750 bool rotatedAnnotationsEnabled() const { return mRotatedAnnotationsEnabled; }
751
757 void setRotatedAnnotationsLengthMode( const Qgis::MapGridTickLengthMode mode ) { mRotatedAnnotationsLengthMode = mode; }
758
764 Qgis::MapGridTickLengthMode rotatedAnnotationsLengthMode() const { return mRotatedAnnotationsLengthMode; }
765
771 void setRotatedAnnotationsMinimumAngle( const double angle ) { mRotatedAnnotationsMinimumAngle = angle; }
772
778 double rotatedAnnotationsMinimumAngle() const { return mRotatedAnnotationsMinimumAngle; }
779
785 void setRotatedAnnotationsMarginToCorner( const double margin ) { mRotatedAnnotationsMarginToCorner = margin; }
786
792 double rotatedAnnotationsMarginToCorner() const { return mRotatedAnnotationsMarginToCorner; }
793
800 void setFrameMargin( const double margin );
801
808 double frameMargin() const { return mGridFrameMargin; }
809
815 void setFramePenSize( const double width );
816
822 double framePenSize() const { return mGridFramePenThickness; }
823
831 void setFramePenColor( const QColor &color ) { mGridFramePenColor = color; }
832
840 QColor framePenColor() const { return mGridFramePenColor; }
841
848 void setFrameFillColor1( const QColor &color ) { mGridFrameFillColor1 = color; }
849
856 QColor frameFillColor1() const { return mGridFrameFillColor1; }
857
864 void setFrameFillColor2( const QColor &color ) { mGridFrameFillColor2 = color; }
865
872 QColor frameFillColor2() const { return mGridFrameFillColor2; }
873
880 Qgis::TextHorizontalAlignment horizontalAlignment() const;
881
888 void setHorizontalAlignment( Qgis::TextHorizontalAlignment alignment );
889
890 QgsExpressionContext createExpressionContext() const override;
891 bool accept( QgsStyleEntityVisitorInterface *visitor ) const override;
892 void refresh() override;
893
899 void copyProperties( const QgsLayoutItemMapGrid *other );
900
901 signals:
902
909
910 private:
911 QgsLayoutItemMapGrid() = delete;
912
913 static constexpr int MAX_GRID_LINES = 1000;
914 static constexpr int MAX_GRID_ANNOTATIONS = 1000;
915 static constexpr int MAX_GRID_TICKS = 5000;
916 static constexpr int MAX_GRID_FRAME_OBJECTS = std::max( MAX_GRID_TICKS, MAX_GRID_ANNOTATIONS );
917 static constexpr int MAX_GRID_OBJECTS = std::max( MAX_GRID_LINES, MAX_GRID_FRAME_OBJECTS );
918
919 struct GridExtension
920 {
921 GridExtension() = default;
922 double top = 0.0;
923 double right = 0.0;
924 double bottom = 0.0;
925 double left = 0.0;
926
930 void UpdateBorder( Qgis::MapGridBorderSide border, double value )
931 {
932 switch ( border )
933 {
935 left = std::max( left, value );
936 break;
938 right = std::max( right, value );
939 break;
941 top = std::max( top, value );
942 break;
944 bottom = std::max( bottom, value );
945 break;
946 }
947 }
948
952 void UpdateAll( double value )
953 {
954 left = std::max( left, value );
955 right = std::max( right, value );
956 top = std::max( top, value );
957 bottom = std::max( bottom, value );
958 }
959 };
960
961 static constexpr double GRID_LINE_CLOSE_TO_EDGE_TOLERANCE_MAP_UNITS = 0.00001;
962
963 // we need a little bit of tolerance for showing annotations right at the extremities of their edges,
964 // as we don't want to omit annotations right at the map edges if rounding errors have occurred in the position math
965 static constexpr double ANNOTATION_CLOSE_TO_EDGE_TOLERANCE_MM = 0.01;
966
967 struct GridLineAnnotation
968 {
969 Qgis::MapGridBorderSide border = Qgis::MapGridBorderSide::Left; // border on which the annotation is
970 QVector2D position; // position on the frame
971 QVector2D vector; // vector towards map center
972 double angle = 0; // the (acute) angle formed between the vector and the border
973 };
974
979 struct GridLine
980 {
981 QPolygonF line; // the actual line, can be straight with two points or curved if transformed
982 double coordinate; // the coordinate value
983 Qgis::MapGridAnnotationType coordinateType; // whether it's a latitude or longitude line
984 GridLineAnnotation startAnnotation; // the annotation on the start point
985 GridLineAnnotation endAnnotation; // the annotation on the end point
986 };
987 mutable QList< GridLine > mGridLines;
988
990 mutable bool mTransformDirty = true;
991
995 double mGridIntervalX = 0.0;
997 double mGridIntervalY = 0.0;
999 double mGridOffsetX = 0.0;
1001 double mGridOffsetY = 0.0;
1002
1004 QgsTextFormat mAnnotationFormat;
1005
1007 int mGridAnnotationPrecision = 3;
1009 bool mShowGridAnnotation = false;
1010
1012
1021
1030
1032 double mAnnotationFrameDistance = 1.0;
1033
1043
1044 QString mGridAnnotationExpressionString;
1045 mutable std::unique_ptr< QgsExpression > mGridAnnotationExpression;
1046
1048
1049 Qgis::MapGridFrameSideFlags mGridFrameSides;
1050 double mGridFrameWidth = 2.0;
1051 double mGridFramePenThickness = 0.3;
1052 QColor mGridFramePenColor = QColor( 0, 0, 0 );
1053 QColor mGridFrameFillColor1 = Qt::white;
1054 QColor mGridFrameFillColor2 = Qt::black;
1055 double mCrossLength = 3.0;
1056 double mGridFrameMargin = 0.0;
1057 bool mRotatedTicksEnabled = false;
1059 double mRotatedTicksMinimumAngle = 0.0;
1060 double mRotatedTicksMarginToCorner = 0.0;
1061 bool mRotatedAnnotationsEnabled = false;
1063 double mRotatedAnnotationsMinimumAngle = 0.0;
1064 double mRotatedAnnotationsMarginToCorner = 0.0;
1065
1066 double mMinimumIntervalWidth = 50;
1067 double mMaximumIntervalWidth = 100;
1068
1077
1078 std::unique_ptr< QgsLineSymbol > mGridLineSymbol;
1079 std::unique_ptr< QgsMarkerSymbol > mGridMarkerSymbol;
1080
1081 QgsCoordinateReferenceSystem mCRS;
1082
1084
1085 QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
1086
1087 mutable QList< QPair< double, QPolygonF > > mTransformedXLines;
1088 mutable QList< QPair< double, QPolygonF > > mTransformedYLines;
1089 mutable QList< QgsPointXY > mTransformedIntersections;
1090 QRectF mPrevPaintRect;
1091 mutable QPolygonF mPrevMapPolygon;
1092
1093 bool mEvaluatedEnabled = true;
1094 double mEvaluatedIntervalX = 0;
1095 double mEvaluatedIntervalY = 0;
1096 double mEvaluatedOffsetX = 0;
1097 double mEvaluatedOffsetY = 0;
1098 double mEvaluatedGridFrameWidth = 0;
1099 double mEvaluatedGridFrameMargin = 0;
1100 double mEvaluatedAnnotationFrameDistance = 0;
1101 double mEvaluatedCrossLength = 0;
1102 double mEvaluatedGridFrameLineThickness = 0;
1103 std::unique_ptr< QgsProperty > mDrawAnnotationProperty;
1112
1113 mutable int mCurrentComponentDrawCount = 0;
1114
1118 void updateGridLinesAnnotationsPositions() const;
1119
1124 void drawGridFrame( QPainter *p, GridExtension *extension = nullptr ) const;
1125
1133 void drawCoordinateAnnotations( QgsRenderContext &context, QgsExpressionContext &expressionContext, GridExtension *extension = nullptr ) const;
1134
1139 void drawCoordinateAnnotation( QgsRenderContext &context, GridLineAnnotation annot, const QString &annotationString, Qgis::MapGridAnnotationType coordinateType, GridExtension *extension = nullptr ) const;
1140
1141 QString gridAnnotationString( double value, Qgis::MapGridAnnotationType coord, QgsExpressionContext &expressionContext, bool isGeographic ) const;
1142
1146 void calculateXGridLines() const;
1147
1151 void calculateYGridLines() const;
1152
1153 int xGridLinesCrsTransform( const QgsRectangle &bbox, const QgsCoordinateTransform &t ) const;
1154
1155 int yGridLinesCrsTransform( const QgsRectangle &bbox, const QgsCoordinateTransform &t ) const;
1156
1157 void drawGridLine( const QLineF &line, QgsRenderContext &context ) const;
1158
1159 void drawGridLine( const QPolygonF &line, QgsRenderContext &context ) const;
1160
1165 void drawGridFrameBorder( QPainter *p, Qgis::MapGridBorderSide border, double *extension = nullptr ) const;
1166
1172 Qgis::MapGridBorderSide borderForLineCoord( QPointF p, Qgis::MapGridAnnotationType coordinateType ) const;
1173
1175 int crsGridParams( QgsRectangle &crsRect, QgsCoordinateTransform &inverseTransform ) const;
1176
1177 static QList<QPolygonF> trimLinesToMap( const QPolygonF &line, const QgsRectangle &rect );
1178
1179 QPolygonF scalePolygon( const QPolygonF &polygon, double scale ) const;
1180
1182 void drawGridCrsTransform( QgsRenderContext &context, double dotsPerMM, bool calculateLinesOnly = false ) const;
1183
1184 void drawGridNoTransform( QgsRenderContext &context, double dotsPerMM, bool calculateLinesOnly = false ) const;
1185
1186 void createDefaultGridLineSymbol();
1187
1188 void createDefaultGridMarkerSymbol();
1189
1190 void drawGridMarker( QPointF point, QgsRenderContext &context ) const;
1191
1192 void drawGridFrameZebra( QPainter *p, GridExtension *extension = nullptr ) const;
1193
1194 void drawGridFrameZebraBorder( QPainter *p, Qgis::MapGridBorderSide border, double *extension = nullptr ) const;
1195
1196 void drawGridFrameTicks( QPainter *p, GridExtension *extension = nullptr ) const;
1197
1198 void drawGridFrameLine( QPainter *p, GridExtension *extension = nullptr ) const;
1199
1200 void calculateCrsTransformLines() const;
1201
1202 bool shouldShowDivisionForSide( Qgis::MapGridAnnotationType coordinate, Qgis::MapGridBorderSide side ) const;
1203 bool shouldShowAnnotationForSide( Qgis::MapGridAnnotationType coordinate, Qgis::MapGridBorderSide side ) const;
1204 bool shouldShowForDisplayMode( Qgis::MapGridAnnotationType coordinate, Qgis::MapGridComponentVisibility mode ) const;
1205 void refreshDataDefinedProperties();
1206
1208 double mapWidth() const;
1209
1211
1212 // Needs access to evaluated properties to compute frame bleed
1213 friend class QgsLayoutItemMap;
1214};
1215
1216
1217#endif // QGSLAYOUTITEMMAPGRID_H
MapGridTickLengthMode
Map grid tick length mode (useful for rotated grids).
Definition qgis.h:5927
@ OrthogonalTicks
Align ticks orthogonaly.
Definition qgis.h:5928
QFlags< MapGridFrameSideFlag > MapGridFrameSideFlags
Flags for controlling which side of the map a frame is drawn on.
Definition qgis.h:5957
MapGridAnnotationPosition
Position for map grid annotations.
Definition qgis.h:5837
@ OutsideMapFrame
Draw annotations outside the map frame.
Definition qgis.h:5839
MapGridUnit
Units for map grid values.
Definition qgis.h:5789
@ MapUnits
Grid units follow map units.
Definition qgis.h:5790
MapGridBorderSide
Border sides for map grid annotations.
Definition qgis.h:5891
@ Bottom
Bottom border.
Definition qgis.h:5894
@ Right
Right border.
Definition qgis.h:5893
@ Left
Left border.
Definition qgis.h:5892
@ Top
Top border.
Definition qgis.h:5895
MapGridFrameSideFlag
Flags for controlling which side of the map a frame is drawn on.
Definition qgis.h:5942
MapGridComponentVisibility
Visibility display settings for map grid annotations and frames.
Definition qgis.h:5821
@ ShowAll
Show both latitude and longitude annotations/divisions.
Definition qgis.h:5822
MapGridStyle
Map grid drawing styles.
Definition qgis.h:5805
@ Lines
Draw lines for grid.
Definition qgis.h:5806
MapGridAnnotationType
Annotation coordinate type.
Definition qgis.h:5968
MapGridFrameStyle
Style for map grid frames.
Definition qgis.h:5907
@ NoFrame
Disable grid frame.
Definition qgis.h:5908
MapGridAnnotationDirection
Direction of grid annotations.
Definition qgis.h:5851
@ Horizontal
Draw annotations horizontally.
Definition qgis.h:5852
TextHorizontalAlignment
Text horizontal alignment.
Definition qgis.h:3111
@ Center
Center align.
Definition qgis.h:3113
MapGridAnnotationFormat
Format for displaying map grid annotations.
Definition qgis.h:5870
@ Decimal
Decimal degrees, use - for S/W coordinates.
Definition qgis.h:5871
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