QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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"
23 #include "qgslayoutitemmapitem.h"
24 #include "qgstextformat.h"
25 #include <QPainter>
26 #include <QVector2D>
27 
30 class QgsLayoutItemMap;
31 class QDomDocument;
32 class QDomElement;
33 class QPainter;
34 class QgsRenderContext;
35 class QgsLineSymbol;
36 
47 {
48  public:
49 
54 
63  void addGrid( QgsLayoutItemMapGrid *grid SIP_TRANSFER );
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 );
104 
108  QList< QgsLayoutItemMapGrid * > asList() const;
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 class CORE_EXPORT QgsLayoutItemMapGrid : public QgsLayoutItemMapItem
141 {
142 
143  Q_OBJECT
144 
145  public:
146 
150  enum GridUnit
151  {
153  MM,
154  CM,
156  };
157 
162  {
163  Solid = 0,
166  FrameAnnotationsOnly
167  };
168 
173  {
174  ShowAll = 0,
177  HideAll
178  };
179 
184  {
185  InsideMapFrame = 0,
187  };
188 
193  {
194  Horizontal = 0,
201  };
202 
207  {
208  Decimal = 0,
216  CustomFormat
217  };
218 
223  {
227  Top,
228  };
229 
234  {
235  NoFrame = 0,
243  };
244 
249  {
250  OrthogonalTicks = 0,
252  };
253 
258  {
259  FrameLeft = 0x01,
260  FrameRight = 0x02,
261  FrameTop = 0x04,
262  FrameBottom = 0x08
263  };
264  Q_DECLARE_FLAGS( FrameSideFlags, FrameSideFlag )
265 
266 
270  {
271  Longitude = 0,
272  Latitude
273  };
274 
280  QgsLayoutItemMapGrid( const QString &name, QgsLayoutItemMap *map );
281  ~QgsLayoutItemMapGrid() override;
282 
283  void draw( QPainter *painter ) override;
284  bool writeXml( QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
285  bool readXml( const QDomElement &itemElem, const QDomDocument &doc, const QgsReadWriteContext &context ) override;
286 
291  void setCrs( const QgsCoordinateReferenceSystem &crs );
292 
297  QgsCoordinateReferenceSystem crs() const { return mCRS; }
298 
303  void setBlendMode( const QPainter::CompositionMode mode ) { mBlendMode = mode; }
304 
309  QPainter::CompositionMode blendMode() const { return mBlendMode; }
310 
311  bool usesAdvancedEffects() const override;
312 
317  double maxExtension() const;
318 
325  void calculateMaxExtension( double &top, double &right, double &bottom, double &left ) const;
326 
327  void setEnabled( bool enabled ) override;
328 
329  //
330  // GRID UNITS
331  //
332 
338  void setUnits( GridUnit unit );
339 
345  GridUnit units() const { return mGridUnit; }
346 
353  void setIntervalX( double interval );
354 
361  double intervalX() const { return mGridIntervalX; }
362 
369  void setIntervalY( double interval );
370 
377  double intervalY() const { return mGridIntervalY; }
378 
385  void setOffsetX( double offset );
386 
393  double offsetX() const { return mGridOffsetX; }
394 
401  void setOffsetY( double offset );
402 
409  double offsetY() const { return mGridOffsetY; }
410 
420  double minimumIntervalWidth() const { return mMinimumIntervalWidth; }
421 
431  void setMinimumIntervalWidth( double width );
432 
442  double maximumIntervalWidth() const { return mMaximumIntervalWidth; }
443 
453  void setMaximumIntervalWidth( double width );
454 
455  //
456  // GRID APPEARANCE
457  //
458 
464  void setStyle( GridStyle style );
465 
471  GridStyle style() const { return mGridStyle; }
472 
478  void setCrossLength( const double length );
479 
485  double crossLength() const { return mCrossLength; }
486 
494  void setGridLineWidth( double width );
495 
503  void setGridLineColor( const QColor &color );
504 
513  void setLineSymbol( QgsLineSymbol *symbol SIP_TRANSFER );
514 
523  const QgsLineSymbol *lineSymbol() const; SIP_SKIP
524 
532  QgsLineSymbol *lineSymbol();
533 
542  void setMarkerSymbol( QgsMarkerSymbol *symbol SIP_TRANSFER );
543 
552  const QgsMarkerSymbol *markerSymbol() const; SIP_SKIP
553 
561  QgsMarkerSymbol *markerSymbol();
562 
563  //
564  // ANNOTATIONS
565  //
566 
571  void setAnnotationEnabled( const bool enabled ) { mShowGridAnnotation = enabled; }
572 
577  bool annotationEnabled() const { return mShowGridAnnotation; }
578 
585  void setAnnotationTextFormat( const QgsTextFormat &format ) { mAnnotationFormat = format; }
586 
593  QgsTextFormat annotationTextFormat() const { return mAnnotationFormat; }
594 
601  Q_DECL_DEPRECATED void setAnnotationFont( const QFont &font ) SIP_DEPRECATED;
602 
609  Q_DECL_DEPRECATED QFont annotationFont() const SIP_DEPRECATED;
610 
617  Q_DECL_DEPRECATED void setAnnotationFontColor( const QColor &color ) SIP_DEPRECATED;
618 
625  Q_DECL_DEPRECATED QColor annotationFontColor() const SIP_DEPRECATED;
626 
632  void setAnnotationPrecision( const int precision ) { mGridAnnotationPrecision = precision; }
633 
639  int annotationPrecision() const { return mGridAnnotationPrecision; }
640 
648  void setAnnotationDisplay( DisplayMode display, BorderSide border );
649 
658  DisplayMode annotationDisplay( BorderSide border ) const;
659 
665  void setAnnotationPosition( AnnotationPosition position, BorderSide side );
666 
672  AnnotationPosition annotationPosition( BorderSide side ) const;
673 
678  void setAnnotationFrameDistance( const double distance );
679 
684  double annotationFrameDistance() const { return mAnnotationFrameDistance; }
685 
690  void setAnnotationDirection( AnnotationDirection direction, BorderSide side );
691 
696  void setAnnotationDirection( AnnotationDirection direction );
697 
703  AnnotationDirection annotationDirection( BorderSide border ) const;
704 
709  void setAnnotationFormat( const AnnotationFormat format ) { mGridAnnotationFormat = format; }
710 
715  AnnotationFormat annotationFormat() const { return mGridAnnotationFormat; }
716 
722  void setAnnotationExpression( const QString &expression ) { mGridAnnotationExpressionString = expression; mGridAnnotationExpression.reset(); }
723 
729  QString annotationExpression() const { return mGridAnnotationExpressionString; }
730 
731  //
732  // GRID FRAME
733  //
734 
739  void setFrameStyle( const FrameStyle style ) { mGridFrameStyle = style; }
740 
745  FrameStyle frameStyle() const { return mGridFrameStyle; }
746 
751  void setFrameDivisions( DisplayMode divisions, BorderSide side );
752 
757  DisplayMode frameDivisions( BorderSide side ) const;
758 
766  void setFrameSideFlags( QgsLayoutItemMapGrid::FrameSideFlags flags );
767 
776  void setFrameSideFlag( QgsLayoutItemMapGrid::FrameSideFlag flag, bool on = true );
777 
785  QgsLayoutItemMapGrid::FrameSideFlags frameSideFlags() const;
786 
796  bool testFrameSideFlag( FrameSideFlag flag ) const;
797 
804  void setFrameWidth( const double width );
805 
812  double frameWidth() const { return mGridFrameWidth; }
813 
819  void setRotatedTicksEnabled( const bool state ) { mRotatedTicksEnabled = state; }
820 
826  double rotatedTicksEnabled() const { return mRotatedTicksEnabled; }
827 
833  void setRotatedTicksLengthMode( const TickLengthMode mode ) { mRotatedTicksLengthMode = mode; }
834 
840  TickLengthMode rotatedTicksLengthMode() const { return mRotatedTicksLengthMode; }
841 
847  void setRotatedTicksMinimumAngle( const double angle ) { mRotatedTicksMinimumAngle = angle; }
848 
854  double rotatedTicksMinimumAngle() const { return mRotatedTicksMinimumAngle; }
855 
861  void setRotatedTicksMarginToCorner( const double margin ) { mRotatedTicksMarginToCorner = margin; }
862 
868  double rotatedTicksMarginToCorner() const { return mRotatedTicksMarginToCorner; }
869 
875  void setRotatedAnnotationsEnabled( const bool state ) { mRotatedAnnotationsEnabled = state; }
876 
882  double rotatedAnnotationsEnabled() const { return mRotatedAnnotationsEnabled; }
883 
889  void setRotatedAnnotationsLengthMode( const TickLengthMode mode ) { mRotatedAnnotationsLengthMode = mode; }
890 
896  TickLengthMode rotatedAnnotationsLengthMode() const { return mRotatedAnnotationsLengthMode; }
897 
903  void setRotatedAnnotationsMinimumAngle( const double angle ) { mRotatedAnnotationsMinimumAngle = angle; }
904 
910  double rotatedAnnotationsMinimumAngle() const { return mRotatedAnnotationsMinimumAngle; }
911 
917  void setRotatedAnnotationsMarginToCorner( const double margin ) { mRotatedAnnotationsMarginToCorner = margin; }
918 
924  double rotatedAnnotationsMarginToCorner() const { return mRotatedAnnotationsMarginToCorner; }
925 
932  void setFrameMargin( const double margin );
933 
940  double frameMargin() const { return mGridFrameMargin; }
941 
947  void setFramePenSize( const double width );
948 
954  double framePenSize() const { return mGridFramePenThickness; }
955 
963  void setFramePenColor( const QColor &color ) { mGridFramePenColor = color; }
964 
972  QColor framePenColor() const {return mGridFramePenColor;}
973 
980  void setFrameFillColor1( const QColor &color ) { mGridFrameFillColor1 = color; }
981 
988  QColor frameFillColor1() const { return mGridFrameFillColor1; }
989 
996  void setFrameFillColor2( const QColor &color ) { mGridFrameFillColor2 = color; }
997 
1004  QColor frameFillColor2() const { return mGridFrameFillColor2; }
1005 
1007  bool accept( QgsStyleEntityVisitorInterface *visitor ) const override;
1008  void refresh() override;
1009 
1010  signals:
1011 
1017  void crsChanged();
1018 
1019  private:
1020 
1021  QgsLayoutItemMapGrid() = delete;
1022 
1023  struct GridExtension
1024  {
1025  GridExtension() = default;
1026  double top = 0.0;
1027  double right = 0.0;
1028  double bottom = 0.0;
1029  double left = 0.0;
1030 
1034  void UpdateBorder( BorderSide border, double value )
1035  {
1036  switch ( border )
1037  {
1039  left = std::max( left, value );
1040  break;
1042  right = std::max( right, value );
1043  break;
1045  top = std::max( top, value );
1046  break;
1048  bottom = std::max( bottom, value );
1049  break;
1050  }
1051  }
1052 
1056  void UpdateAll( double value )
1057  {
1058  left = std::max( left, value );
1059  right = std::max( right, value );
1060  top = std::max( top, value );
1061  bottom = std::max( bottom, value );
1062  }
1063  };
1064 
1065  struct GridLineAnnotation
1066  {
1067  BorderSide border = Left; // border on which the annotation is
1068  QVector2D position; // position on the frame
1069  QVector2D vector; // vector towards map center
1070  double angle = 0; // the (acute) angle formed between the vector and the border
1071  };
1072 
1077  struct GridLine
1078  {
1079  QPolygonF line; // the actual line, can be straight with two points or curved if transformed
1080  double coordinate; // the coordinate value
1081  QgsLayoutItemMapGrid::AnnotationCoordinate coordinateType; // whether it's a latitude or longitude line
1082  GridLineAnnotation startAnnotation; // the annotation on the start point
1083  GridLineAnnotation endAnnotation; // the annotation on the end point
1084  };
1085  mutable QList< GridLine > mGridLines;
1086 
1088  mutable bool mTransformDirty = true;
1089 
1091  GridStyle mGridStyle = QgsLayoutItemMapGrid::Solid;
1093  double mGridIntervalX = 0.0;
1095  double mGridIntervalY = 0.0;
1097  double mGridOffsetX = 0.0;
1099  double mGridOffsetY = 0.0;
1100 
1102  QgsTextFormat mAnnotationFormat;
1103 
1105  int mGridAnnotationPrecision = 3;
1107  bool mShowGridAnnotation = false;
1108 
1110  DisplayMode mLeftGridAnnotationDisplay = QgsLayoutItemMapGrid::ShowAll;
1112  DisplayMode mRightGridAnnotationDisplay = QgsLayoutItemMapGrid::ShowAll;
1114  DisplayMode mTopGridAnnotationDisplay = QgsLayoutItemMapGrid::ShowAll;
1116  DisplayMode mBottomGridAnnotationDisplay = QgsLayoutItemMapGrid::ShowAll;
1117 
1119  AnnotationPosition mLeftGridAnnotationPosition = QgsLayoutItemMapGrid::OutsideMapFrame;
1121  AnnotationPosition mRightGridAnnotationPosition = QgsLayoutItemMapGrid::OutsideMapFrame;
1123  AnnotationPosition mTopGridAnnotationPosition = QgsLayoutItemMapGrid::OutsideMapFrame;
1125  AnnotationPosition mBottomGridAnnotationPosition = QgsLayoutItemMapGrid::OutsideMapFrame;
1126 
1128  double mAnnotationFrameDistance = 1.0;
1129 
1131  AnnotationDirection mLeftGridAnnotationDirection = QgsLayoutItemMapGrid::Horizontal;
1133  AnnotationDirection mRightGridAnnotationDirection = QgsLayoutItemMapGrid::Horizontal;
1135  AnnotationDirection mTopGridAnnotationDirection = QgsLayoutItemMapGrid::Horizontal;
1137  AnnotationDirection mBottomGridAnnotationDirection = QgsLayoutItemMapGrid::Horizontal;
1138  AnnotationFormat mGridAnnotationFormat = QgsLayoutItemMapGrid::Decimal;
1139 
1140  QString mGridAnnotationExpressionString;
1141  mutable std::unique_ptr< QgsExpression > mGridAnnotationExpression;
1142 
1143  FrameStyle mGridFrameStyle = QgsLayoutItemMapGrid::NoFrame;
1144 
1145  FrameSideFlags mGridFrameSides;
1146  double mGridFrameWidth = 2.0;
1147  double mGridFramePenThickness = 0.3;
1148  QColor mGridFramePenColor = QColor( 0, 0, 0 );
1149  QColor mGridFrameFillColor1 = Qt::white;
1150  QColor mGridFrameFillColor2 = Qt::black;
1151  double mCrossLength = 3.0;
1152  double mGridFrameMargin = 0.0;
1153  bool mRotatedTicksEnabled = false;
1154  TickLengthMode mRotatedTicksLengthMode = QgsLayoutItemMapGrid::OrthogonalTicks;
1155  double mRotatedTicksMinimumAngle = 0.0;
1156  double mRotatedTicksMarginToCorner = 0.0;
1157  bool mRotatedAnnotationsEnabled = false;
1158  TickLengthMode mRotatedAnnotationsLengthMode = QgsLayoutItemMapGrid::OrthogonalTicks;
1159  double mRotatedAnnotationsMinimumAngle = 0.0;
1160  double mRotatedAnnotationsMarginToCorner = 0.0;
1161 
1162  double mMinimumIntervalWidth = 50;
1163  double mMaximumIntervalWidth = 100;
1164 
1166  DisplayMode mLeftFrameDivisions = QgsLayoutItemMapGrid::ShowAll;
1168  DisplayMode mRightFrameDivisions = QgsLayoutItemMapGrid::ShowAll;
1170  DisplayMode mTopFrameDivisions = QgsLayoutItemMapGrid::ShowAll;
1172  DisplayMode mBottomFrameDivisions = QgsLayoutItemMapGrid::ShowAll;
1173 
1174  std::unique_ptr< QgsLineSymbol > mGridLineSymbol;
1175  std::unique_ptr< QgsMarkerSymbol > mGridMarkerSymbol;
1176 
1178 
1179  GridUnit mGridUnit = MapUnit;
1180 
1181  QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
1182 
1183  mutable QList< QPair< double, QPolygonF > > mTransformedXLines;
1184  mutable QList< QPair< double, QPolygonF > > mTransformedYLines;
1185  mutable QList< QgsPointXY > mTransformedIntersections;
1186  QRectF mPrevPaintRect;
1187  mutable QPolygonF mPrevMapPolygon;
1188 
1189  bool mEvaluatedEnabled = true;
1190  double mEvaluatedIntervalX = 0;
1191  double mEvaluatedIntervalY = 0;
1192  double mEvaluatedOffsetX = 0;
1193  double mEvaluatedOffsetY = 0;
1194  double mEvaluatedGridFrameWidth = 0;
1195  double mEvaluatedGridFrameMargin = 0;
1196  double mEvaluatedAnnotationFrameDistance = 0;
1197  double mEvaluatedCrossLength = 0;
1198  double mEvaluatedGridFrameLineThickness = 0;
1199  DisplayMode mEvaluatedLeftGridAnnotationDisplay = QgsLayoutItemMapGrid::ShowAll;
1200  DisplayMode mEvaluatedRightGridAnnotationDisplay = QgsLayoutItemMapGrid::ShowAll;
1201  DisplayMode mEvaluatedTopGridAnnotationDisplay = QgsLayoutItemMapGrid::ShowAll;
1202  DisplayMode mEvaluatedBottomGridAnnotationDisplay = QgsLayoutItemMapGrid::ShowAll;
1203  DisplayMode mEvaluatedLeftFrameDivisions = QgsLayoutItemMapGrid::ShowAll;
1204  DisplayMode mEvaluatedRightFrameDivisions = QgsLayoutItemMapGrid::ShowAll;
1205  DisplayMode mEvaluatedTopFrameDivisions = QgsLayoutItemMapGrid::ShowAll;
1206  DisplayMode mEvaluatedBottomFrameDivisions = QgsLayoutItemMapGrid::ShowAll;
1207 
1211  void updateGridLinesAnnotationsPositions() const;
1212 
1217  void drawGridFrame( QPainter *p, GridExtension *extension = nullptr ) const;
1218 
1226  void drawCoordinateAnnotations( QgsRenderContext &context, QgsExpressionContext &expressionContext, GridExtension *extension = nullptr ) const;
1227 
1232  void drawCoordinateAnnotation( QgsRenderContext &context, GridLineAnnotation annot, const QString &annotationString, AnnotationCoordinate coordinateType, GridExtension *extension = nullptr ) const;
1233 
1234  QString gridAnnotationString( double value, AnnotationCoordinate coord, QgsExpressionContext &expressionContext ) const;
1235 
1240  int xGridLines() const;
1241 
1246  int yGridLines() const;
1247 
1248  int xGridLinesCrsTransform( const QgsRectangle &bbox, const QgsCoordinateTransform &t ) const;
1249 
1250  int yGridLinesCrsTransform( const QgsRectangle &bbox, const QgsCoordinateTransform &t ) const;
1251 
1252  void drawGridLine( const QLineF &line, QgsRenderContext &context ) const;
1253 
1254  void drawGridLine( const QPolygonF &line, QgsRenderContext &context ) const;
1255 
1260  void drawGridFrameBorder( QPainter *p, BorderSide border, double *extension = nullptr ) const;
1261 
1267  BorderSide borderForLineCoord( QPointF p, AnnotationCoordinate coordinateType ) const;
1268 
1270  int crsGridParams( QgsRectangle &crsRect, QgsCoordinateTransform &inverseTransform ) const;
1271 
1272  static QList<QPolygonF> trimLinesToMap( const QPolygonF &line, const QgsRectangle &rect );
1273 
1274  QPolygonF scalePolygon( const QPolygonF &polygon, double scale ) const;
1275 
1277  void drawGridCrsTransform( QgsRenderContext &context, double dotsPerMM, bool calculateLinesOnly = false ) const;
1278 
1279  void drawGridNoTransform( QgsRenderContext &context, double dotsPerMM, bool calculateLinesOnly = false ) const;
1280 
1281  void createDefaultGridLineSymbol();
1282 
1283  void createDefaultGridMarkerSymbol();
1284 
1285  void drawGridMarker( QPointF point, QgsRenderContext &context ) const;
1286 
1287  void drawGridFrameZebra( QPainter *p, GridExtension *extension = nullptr ) const;
1288 
1289  void drawGridFrameZebraBorder( QPainter *p, BorderSide border, double *extension = nullptr ) const;
1290 
1291  void drawGridFrameTicks( QPainter *p, GridExtension *extension = nullptr ) const;
1292 
1293  void drawGridFrameLine( QPainter *p, GridExtension *extension = nullptr ) const;
1294 
1295  void calculateCrsTransformLines() const;
1296 
1297  bool shouldShowDivisionForSide( AnnotationCoordinate coordinate, BorderSide side ) const;
1298  bool shouldShowAnnotationForSide( AnnotationCoordinate coordinate, BorderSide side ) const;
1299  bool shouldShowForDisplayMode( AnnotationCoordinate coordinate, DisplayMode mode ) const;
1300  void refreshDataDefinedProperties();
1301 
1303  double mapWidth() const;
1304 
1305  friend class TestQgsLayoutMapGrid;
1306 
1307 };
1308 
1309 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsLayoutItemMapGrid::FrameSideFlags )
1310 
1311 #endif // QGSLAYOUTITEMMAPGRID_H
QgsLayoutItemMapGrid::rotatedAnnotationsLengthMode
TickLengthMode rotatedAnnotationsLengthMode() const
Returns the grid frame style.
Definition: qgslayoutitemmapgrid.h:896
QgsLayoutItemMapGrid::TickLengthMode
TickLengthMode
Tick length mode (useful for rotated grids)
Definition: qgslayoutitemmapgrid.h:248
QgsLayoutItemMapGrid::intervalX
double intervalX() const
Returns the interval between grid lines in the x-direction.
Definition: qgslayoutitemmapgrid.h:361
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:406
QgsLayoutItemMapItem::setEnabled
virtual void setEnabled(bool enabled)
Controls whether the item will be drawn.
Definition: qgslayoutitemmapitem.cpp:99
QgsLayoutItemMapGrid::Zebra
@ Zebra
Black/white pattern.
Definition: qgslayoutitemmapgrid.h:236
QgsLayoutItemMapGrid
An individual grid which is drawn above the map content in a QgsLayoutItemMap.
Definition: qgslayoutitemmapgrid.h:140
QgsLayoutItemMapGrid::InteriorTicks
@ InteriorTicks
Tick markers drawn inside map frame.
Definition: qgslayoutitemmapgrid.h:237
QgsLayoutItemMapGrid::VerticalDescending
@ VerticalDescending
Draw annotations vertically, descending.
Definition: qgslayoutitemmapgrid.h:196
QgsLayoutItemMapGrid::LongitudeOnly
@ LongitudeOnly
Show longitude/x annotations/divisions only.
Definition: qgslayoutitemmapgrid.h:176
QgsLayoutItemMapItemStack::readXml
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...
QgsLayoutItemMapGrid::style
GridStyle style() const
Returns the grid's style, which controls how the grid is drawn over the map's contents.
Definition: qgslayoutitemmapgrid.h:471
QgsLayoutObject::refresh
virtual void refresh()
Refreshes the object, causing a recalculation of any property overrides.
Definition: qgslayoutobject.h:332
QgsLayoutItemMapGrid::DynamicPageSizeBased
@ DynamicPageSizeBased
Dynamically sized, based on a on-page size range.
Definition: qgslayoutitemmapgrid.h:155
QgsLayoutItemMapGrid::setRotatedTicksEnabled
void setRotatedTicksEnabled(const bool state)
Enable/disable ticks rotation for rotated or reprojected grids.
Definition: qgslayoutitemmapgrid.h:819
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:34
QgsLayoutItemMapGrid::annotationExpression
QString annotationExpression() const
Returns the expression used for drawing grid annotations.
Definition: qgslayoutitemmapgrid.h:729
QgsLayoutItemMapGrid::rotatedAnnotationsMarginToCorner
double rotatedAnnotationsMarginToCorner() const
Gets the margin to corners (in canvas units) below which outwards facing ticks are not drawn.
Definition: qgslayoutitemmapgrid.h:924
QgsLayoutItemMapGrid::OutsideMapFrame
@ OutsideMapFrame
Draw annotations outside the map frame.
Definition: qgslayoutitemmapgrid.h:186
QgsLayoutItemMapItem::draw
virtual void draw(QPainter *painter)=0
Draws the item on to a destination painter.
QgsLayoutItemMapItem::createExpressionContext
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
Definition: qgslayoutitemmapitem.cpp:124
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:105
QgsLayoutItemMapGrid::ExteriorTicks
@ ExteriorTicks
Tick markers drawn outside map frame.
Definition: qgslayoutitemmapgrid.h:238
QgsLayoutItemMapGrid::ShowAll
@ ShowAll
Show both latitude and longitude annotations/divisions.
Definition: qgslayoutitemmapgrid.h:174
QgsLayoutItemMapGrid::framePenColor
QColor framePenColor() const
Retrieves the color of the stroke drawn in the grid frame.
Definition: qgslayoutitemmapgrid.h:972
QgsLayoutItemMapGrid::rotatedTicksLengthMode
TickLengthMode rotatedTicksLengthMode() const
Returns the grid frame style.
Definition: qgslayoutitemmapgrid.h:840
QgsLayoutItemMapGrid::setBlendMode
void setBlendMode(const QPainter::CompositionMode mode)
Sets the blending mode used for drawing the grid.
Definition: qgslayoutitemmapgrid.h:303
QgsLayoutItemMapGrid::FrameSideFlag
FrameSideFlag
Flags for controlling which side of the map a frame is drawn on.
Definition: qgslayoutitemmapgrid.h:257
QgsLayoutItemMapGrid::GridStyle
GridStyle
Grid drawing style.
Definition: qgslayoutitemmapgrid.h:161
QgsLayoutItemMapGrid::maximumIntervalWidth
double maximumIntervalWidth() const
Returns the maximum width (in millimeters) for grid segments.
Definition: qgslayoutitemmapgrid.h:442
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:59
QgsLayoutItemMapItem
An item which is drawn inside a QgsLayoutItemMap, e.g., a grid or map overview.
Definition: qgslayoutitemmapitem.h:33
QgsStyleEntityVisitorInterface
An interface for classes which can visit style entity (e.g. symbol) nodes (using the visitor pattern)...
Definition: qgsstyleentityvisitor.h:33
QgsLayoutItemMapGrid::annotationFormat
AnnotationFormat annotationFormat() const
Returns the format for drawing grid annotations.
Definition: qgslayoutitemmapgrid.h:715
QgsLayoutItemMapItemStack
A collection of map items which are drawn above the map content in a QgsLayoutItemMap....
Definition: qgslayoutitemmapitem.h:230
QgsLayoutItemMapGrid::ZebraNautical
@ ZebraNautical
Black/white pattern, with nautical style diagonals on corners.
Definition: qgslayoutitemmapgrid.h:242
QgsLayoutItemMapGrid::setFramePenColor
void setFramePenColor(const QColor &color)
Sets the color of the stroke drawn in the grid frame.
Definition: qgslayoutitemmapgrid.h:963
QgsLayoutItemMapGrid::DegreeMinutePadded
@ DegreeMinutePadded
Degree/minutes, with minutes using leading zeros where required.
Definition: qgslayoutitemmapgrid.h:213
QgsLayoutItemMapGrid::intervalY
double intervalY() const
Returns the interval between grid lines in the y-direction.
Definition: qgslayoutitemmapgrid.h:377
QgsLayoutItemMapGrid::setRotatedTicksMarginToCorner
void setRotatedTicksMarginToCorner(const double margin)
Sets the margin to corners (in canvas units) below which outwards facing ticks are not drawn.
Definition: qgslayoutitemmapgrid.h:861
QgsLayoutItemMapGrid::CM
@ CM
Grid units in centimeters.
Definition: qgslayoutitemmapgrid.h:154
QgsLayoutItemMapGrid::rotatedAnnotationsMinimumAngle
double rotatedAnnotationsMinimumAngle() const
Gets the minimum angle (in degrees) below which annotated are not drawn.
Definition: qgslayoutitemmapgrid.h:910
QgsLayoutItemMapGrid::annotationPrecision
int annotationPrecision() const
Returns the coordinate precision for grid annotations, which is the number of decimal places shown wh...
Definition: qgslayoutitemmapgrid.h:639
QgsLayoutItemMapGrid::DisplayMode
DisplayMode
Display settings for grid annotations and frames.
Definition: qgslayoutitemmapgrid.h:172
QgsLayoutItemMapGrid::offsetX
double offsetX() const
Returns the offset for grid lines in the x-direction.
Definition: qgslayoutitemmapgrid.h:393
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:41
QgsLayoutItemMapGrid::BoundaryDirection
@ BoundaryDirection
Annotations follow the boundary direction.
Definition: qgslayoutitemmapgrid.h:197
QgsLayoutItemMapGrid::InteriorExteriorTicks
@ InteriorExteriorTicks
Tick markers drawn both inside and outside the map frame.
Definition: qgslayoutitemmapgrid.h:239
QgsLayoutItemMapGrid::setRotatedTicksLengthMode
void setRotatedTicksLengthMode(const TickLengthMode mode)
Sets the tick length calculation mode.
Definition: qgslayoutitemmapgrid.h:833
QgsLayoutItemMapGrid::setRotatedAnnotationsMarginToCorner
void setRotatedAnnotationsMarginToCorner(const double margin)
Sets the margin to corners (in canvas units) below which outwards facing ticks are not drawn.
Definition: qgslayoutitemmapgrid.h:917
QgsLayoutItemMapGrid::LatitudeOnly
@ LatitudeOnly
Show latitude/y annotations/divisions only.
Definition: qgslayoutitemmapgrid.h:175
QgsLayoutItemMapGrid::rotatedTicksMarginToCorner
double rotatedTicksMarginToCorner() const
Gets the margin to corners (in canvas units) below which outwards facing ticks are not drawn.
Definition: qgslayoutitemmapgrid.h:868
QgsLayoutItemMapGrid::NormalizedTicks
@ NormalizedTicks
Constant tick lengths.
Definition: qgslayoutitemmapgrid.h:251
SIP_DEPRECATED
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
QgsLayoutItemMapGrid::setRotatedAnnotationsLengthMode
void setRotatedAnnotationsLengthMode(const TickLengthMode mode)
Sets the annotation length calculation mode.
Definition: qgslayoutitemmapgrid.h:889
QgsTextFormat
Container for all settings relating to text rendering.
Definition: qgstextformat.h:40
QgsLayoutItemMapGrid::setAnnotationExpression
void setAnnotationExpression(const QString &expression)
Sets the expression used for drawing grid annotations.
Definition: qgslayoutitemmapgrid.h:722
precision
int precision
Definition: qgswfsgetfeature.cpp:103
QgsLayoutItemMapItemStack::operator[]
QgsLayoutItemMapItem & operator[](int index)
Returns a reference to an item at the specified index within the stack.
Definition: qgslayoutitemmapitem.cpp:237
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsLayoutItemMapGrid::setRotatedAnnotationsEnabled
void setRotatedAnnotationsEnabled(const bool state)
Enable/disable annotations rotation for rotated or reprojected grids.
Definition: qgslayoutitemmapgrid.h:875
QgsLayoutItemMapGrid::crs
QgsCoordinateReferenceSystem crs() const
Retrieves the CRS for the grid.
Definition: qgslayoutitemmapgrid.h:297
QgsLayoutItemMapGrid::rotatedAnnotationsEnabled
double rotatedAnnotationsEnabled() const
Gets whether annotations rotation for rotated or reprojected grids is enabled.
Definition: qgslayoutitemmapgrid.h:882
QgsLayoutItemMapGrid::GridUnit
GridUnit
Unit for grid values.
Definition: qgslayoutitemmapgrid.h:150
QgsMarkerSymbol
A marker symbol type, for rendering Point and MultiPoint geometries.
Definition: qgsmarkersymbol.h:30
QgsLayoutItemMapGrid::AnnotationDirection
AnnotationDirection
Direction of grid annotations.
Definition: qgslayoutitemmapgrid.h:192
QgsLayoutItemMapGrid::setRotatedTicksMinimumAngle
void setRotatedTicksMinimumAngle(const double angle)
Sets the minimum angle (in degrees) below which ticks are not drawn.
Definition: qgslayoutitemmapgrid.h:847
QgsLayoutItemMapGrid::MapUnit
@ MapUnit
Grid units follow map units.
Definition: qgslayoutitemmapgrid.h:152
qgis_sip.h
QgsLayoutItemMapGrid::setFrameFillColor1
void setFrameFillColor1(const QColor &color)
Sets the first fill color used for the grid frame.
Definition: qgslayoutitemmapgrid.h:980
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsLayoutItemMapGrid::LineBorderNautical
@ LineBorderNautical
Simple solid line frame, with nautical style diagonals on corners.
Definition: qgslayoutitemmapgrid.h:241
Q_DECLARE_OPERATORS_FOR_FLAGS
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsField::ConfigurationFlags) CORE_EXPORT QDataStream &operator<<(QDataStream &out
Writes the field to stream out. QGIS version compatibility is not guaranteed.
QgsLayoutItemMapGrid::DegreeMinuteSecondPadded
@ DegreeMinuteSecondPadded
Degree/minutes/seconds, with minutes using leading zeros where required.
Definition: qgslayoutitemmapgrid.h:215
QgsLineSymbol
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgslinesymbol.h:29
QgsLayoutItemMapGrid::Right
@ Right
Right border.
Definition: qgslayoutitemmapgrid.h:225
QgsLayoutItemMapItem::readXml
virtual bool readXml(const QDomElement &element, const QDomDocument &doc, const QgsReadWriteContext &context)
Sets the map item state from a DOM document, where element is the DOM node corresponding to a 'Layout...
Definition: qgslayoutitemmapitem.cpp:55
QgsLayoutItemMapGrid::annotationFrameDistance
double annotationFrameDistance() const
Returns the distance between the map frame and annotations.
Definition: qgslayoutitemmapgrid.h:684
QgsLayoutItemMapGrid::AnnotationPosition
AnnotationPosition
Position for grid annotations.
Definition: qgslayoutitemmapgrid.h:183
QgsLayoutItemMapGrid::setAnnotationFormat
void setAnnotationFormat(const AnnotationFormat format)
Sets the format for drawing grid annotations.
Definition: qgslayoutitemmapgrid.h:709
QgsLayoutItemMapItem::usesAdvancedEffects
virtual bool usesAdvancedEffects() const
Returns true if the item is drawn using advanced effects, such as blend modes.
Definition: qgslayoutitemmapitem.cpp:109
QgsLayoutItemMapGrid::frameFillColor1
QColor frameFillColor1() const
Retrieves the first fill color for the grid frame.
Definition: qgslayoutitemmapgrid.h:988
QgsLayoutItemMapGrid::BorderSide
BorderSide
Border sides for annotations.
Definition: qgslayoutitemmapgrid.h:222
QgsLayoutItemMapGrid::crossLength
double crossLength() const
Retrieves the length (in layout units) of the cross segments drawn for the grid.
Definition: qgslayoutitemmapgrid.h:485
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:211
QgsLayoutItemMapItemStack::asList
QList< QgsLayoutItemMapItem * > asList() const
Returns a list of QgsLayoutItemMapItems contained by the stack.
Definition: qgslayoutitemmapitem.cpp:242
QgsLayoutItemMapGrid::Solid
@ Solid
Definition: qgslayoutitemmapgrid.h:163
QgsLayoutItemMapGrid::rotatedTicksEnabled
double rotatedTicksEnabled() const
Gets whether ticks rotation for rotated or reprojected grids is enabled.
Definition: qgslayoutitemmapgrid.h:826
QgsLayoutItemMapGrid::Bottom
@ Bottom
Bottom border.
Definition: qgslayoutitemmapgrid.h:226
QgsLayoutItemMapGrid::Cross
@ Cross
Draw line crosses at intersections of grid lines.
Definition: qgslayoutitemmapgrid.h:164
QgsLayoutItemMap
Layout graphical items for displaying a map.
Definition: qgslayoutitemmap.h:317
QgsLayoutItemMapGrid::setFrameStyle
void setFrameStyle(const FrameStyle style)
Sets the grid frame style.
Definition: qgslayoutitemmapgrid.h:739
QgsLayoutItemMapGrid::setAnnotationTextFormat
void setAnnotationTextFormat(const QgsTextFormat &format)
Sets the text format to use when rendering grid annotations.
Definition: qgslayoutitemmapgrid.h:585
QgsLayoutItemMapGrid::frameWidth
double frameWidth() const
Gets the grid frame width in layout units.
Definition: qgslayoutitemmapgrid.h:812
QgsLayoutItemMapGrid::units
GridUnit units() const
Returns the units used for grid measurements such as the interval and offset for grid lines.
Definition: qgslayoutitemmapgrid.h:345
QgsLayoutItemMapGrid::Horizontal
@ Horizontal
Draw annotations horizontally.
Definition: qgslayoutitemmapgrid.h:194
QgsLayoutItemMapGrid::frameFillColor2
QColor frameFillColor2() const
Retrieves the second fill color for the grid frame.
Definition: qgslayoutitemmapgrid.h:1004
QgsLayoutItemMapGrid::rotatedTicksMinimumAngle
double rotatedTicksMinimumAngle() const
Gets the minimum angle (in degrees) below which ticks are not drawn.
Definition: qgslayoutitemmapgrid.h:854
QgsLayoutItemMapGrid::Vertical
@ Vertical
Draw annotations vertically, ascending.
Definition: qgslayoutitemmapgrid.h:195
QgsLayoutItemMapGrid::DegreeMinute
@ DegreeMinute
Degree/minutes, use NSEW suffix.
Definition: qgslayoutitemmapgrid.h:209
QgsLayoutItemMapGrid::DecimalWithSuffix
@ DecimalWithSuffix
Decimal degrees, use NSEW suffix.
Definition: qgslayoutitemmapgrid.h:211
QgsLayoutItemMapGrid::DegreeMinuteNoSuffix
@ DegreeMinuteNoSuffix
Degree/minutes, use - for S/W coordinates.
Definition: qgslayoutitemmapgrid.h:212
QgsLayoutItemMapItem::writeXml
virtual bool writeXml(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
Stores map item state in a DOM element, where element is the DOM element corresponding to a 'LayoutMa...
Definition: qgslayoutitemmapitem.cpp:33
QgsLayoutItemMapGrid::setRotatedAnnotationsMinimumAngle
void setRotatedAnnotationsMinimumAngle(const double angle)
Sets the minimum angle (in degrees) below which annotated are not drawn.
Definition: qgslayoutitemmapgrid.h:903
qgslayoutitemmapitem.h
QgsLayoutItemMapGrid::DegreeMinuteSecond
@ DegreeMinuteSecond
Degree/minutes/seconds, use NSEW suffix.
Definition: qgslayoutitemmapgrid.h:210
QgsLayoutItemMapGrid::NoFrame
@ NoFrame
Disable grid frame.
Definition: qgslayoutitemmapgrid.h:235
QgsLayoutItemMapGrid::Top
@ Top
Top border.
Definition: qgslayoutitemmapgrid.h:227
QgsLayoutItemMapGrid::AnnotationFormat
AnnotationFormat
Format for displaying grid annotations.
Definition: qgslayoutitemmapgrid.h:206
QgsLayoutItemMapGrid::DegreeMinuteSecondNoSuffix
@ DegreeMinuteSecondNoSuffix
Degree/minutes/seconds, use - for S/W coordinates.
Definition: qgslayoutitemmapgrid.h:214
QgsLayoutItemMapGrid::AboveTick
@ AboveTick
Draw annotations parallel to tick (above the line)
Definition: qgslayoutitemmapgrid.h:198
QgsLayoutItemMapGrid::Decimal
@ Decimal
Decimal degrees, use - for S/W coordinates.
Definition: qgslayoutitemmapgrid.h:208
QgsLayoutItemMapGrid::frameMargin
double frameMargin() const
Sets the grid frame Margin (in layout units).
Definition: qgslayoutitemmapgrid.h:940
QgsLayoutItemMapGrid::annotationTextFormat
QgsTextFormat annotationTextFormat() const
Returns the text format used when rendering grid annotations.
Definition: qgslayoutitemmapgrid.h:593
qgstextformat.h
QgsLayoutItemMapGrid::frameStyle
FrameStyle frameStyle() const
Returns the grid frame style.
Definition: qgslayoutitemmapgrid.h:745
QgsLayoutItemMapGrid::OrthogonalTicks
@ OrthogonalTicks
Align ticks orthogonaly.
Definition: qgslayoutitemmapgrid.h:250
QgsLayoutItemMapGrid::setFrameFillColor2
void setFrameFillColor2(const QColor &color)
Sets the second fill color used for the grid frame.
Definition: qgslayoutitemmapgrid.h:996
QgsLayoutItemMapGrid::Markers
@ Markers
Draw markers at intersections of grid lines.
Definition: qgslayoutitemmapgrid.h:165
QgsCoordinateTransform
Class for doing transforms between two map coordinate systems.
Definition: qgscoordinatetransform.h:57
QgsLayoutItemMapGrid::annotationEnabled
bool annotationEnabled() const
Returns whether annotations are shown for the grid.
Definition: qgslayoutitemmapgrid.h:577
QgsLayoutItemMapGridStack
A collection of grids which is drawn above the map content in a QgsLayoutItemMap. The grid stack cont...
Definition: qgslayoutitemmapgrid.h:46
QgsLayoutItemMapGrid::offsetY
double offsetY() const
Returns the offset for grid lines in the y-direction.
Definition: qgslayoutitemmapgrid.h:409
QgsLayoutItemMapItem::accept
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified style entity visitor, causing it to visit all style entities associated with th...
Definition: qgslayoutitemmapitem.cpp:132
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
QgsLayoutItemMapGrid::LineBorder
@ LineBorder
Simple solid line frame.
Definition: qgslayoutitemmapgrid.h:240
QgsLayoutItemMapGrid::AnnotationCoordinate
AnnotationCoordinate
Annotation coordinate type.
Definition: qgslayoutitemmapgrid.h:269
QgsLayoutItemMapGrid::blendMode
QPainter::CompositionMode blendMode() const
Retrieves the blending mode used for drawing the grid.
Definition: qgslayoutitemmapgrid.h:309
QgsLayoutItemMapGrid::UnderTick
@ UnderTick
Draw annotations parallel to tick (under the line)
Definition: qgslayoutitemmapgrid.h:200
QgsLayoutItemMapGrid::minimumIntervalWidth
double minimumIntervalWidth() const
Returns the minimum width (in millimeters) for grid segments.
Definition: qgslayoutitemmapgrid.h:420
QgsLayoutItemMapGrid::setAnnotationEnabled
void setAnnotationEnabled(const bool enabled)
Sets whether annotations should be shown for the grid.
Definition: qgslayoutitemmapgrid.h:571
Direction::Left
@ Left
QgsLayoutItemMapItem::enabled
bool enabled() const
Returns whether the item will be drawn.
Definition: qgslayoutitemmapitem.cpp:104
QgsLayoutItemMapGrid::FrameStyle
FrameStyle
Style for grid frame.
Definition: qgslayoutitemmapgrid.h:233
QgsLayoutItemMapGrid::OnTick
@ OnTick
Draw annotations parallel to tick (on the line)
Definition: qgslayoutitemmapgrid.h:199
QgsLayoutItemMapGrid::framePenSize
double framePenSize() const
Retrieves the width of the stroke drawn in the grid frame.
Definition: qgslayoutitemmapgrid.h:954
QgsLayoutItemMapGrid::Left
@ Left
Left border.
Definition: qgslayoutitemmapgrid.h:224
QgsLayoutItemMapGrid::MM
@ MM
Grid units in millimeters.
Definition: qgslayoutitemmapgrid.h:153