QGIS API Documentation  3.17.0-Master (a035f434f4)
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 "qgssymbol.h"
25 #include "qgstextformat.h"
26 #include <QPainter>
27 #include <QVector2D>
28 
31 class QgsLayoutItemMap;
32 class QDomDocument;
33 class QDomElement;
34 class QPainter;
35 class QgsRenderContext;
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 
282  void draw( QPainter *painter ) override;
283  bool writeXml( QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context ) const override;
284  bool readXml( const QDomElement &itemElem, const QDomDocument &doc, const QgsReadWriteContext &context ) override;
285 
290  void setCrs( const QgsCoordinateReferenceSystem &crs );
291 
296  QgsCoordinateReferenceSystem crs() const { return mCRS; }
297 
302  void setBlendMode( const QPainter::CompositionMode mode ) { mBlendMode = mode; }
303 
308  QPainter::CompositionMode blendMode() const { return mBlendMode; }
309 
310  bool usesAdvancedEffects() const override;
311 
316  double maxExtension() const;
317 
324  void calculateMaxExtension( double &top, double &right, double &bottom, double &left ) const;
325 
326  void setEnabled( bool enabled ) override;
327 
328  //
329  // GRID UNITS
330  //
331 
337  void setUnits( GridUnit unit );
338 
344  GridUnit units() const { return mGridUnit; }
345 
352  void setIntervalX( double interval );
353 
360  double intervalX() const { return mGridIntervalX; }
361 
368  void setIntervalY( double interval );
369 
376  double intervalY() const { return mGridIntervalY; }
377 
384  void setOffsetX( double offset );
385 
392  double offsetX() const { return mGridOffsetX; }
393 
400  void setOffsetY( double offset );
401 
408  double offsetY() const { return mGridOffsetY; }
409 
419  double minimumIntervalWidth() const { return mMinimumIntervalWidth; }
420 
430  void setMinimumIntervalWidth( double width );
431 
441  double maximumIntervalWidth() const { return mMaximumIntervalWidth; }
442 
452  void setMaximumIntervalWidth( double width );
453 
454  //
455  // GRID APPEARANCE
456  //
457 
463  void setStyle( GridStyle style );
464 
470  GridStyle style() const { return mGridStyle; }
471 
477  void setCrossLength( const double length );
478 
484  double crossLength() const { return mCrossLength; }
485 
493  void setGridLineWidth( double width );
494 
502  void setGridLineColor( const QColor &color );
503 
512  void setLineSymbol( QgsLineSymbol *symbol SIP_TRANSFER );
513 
522  const QgsLineSymbol *lineSymbol() const; SIP_SKIP
523 
531  QgsLineSymbol *lineSymbol();
532 
541  void setMarkerSymbol( QgsMarkerSymbol *symbol SIP_TRANSFER );
542 
551  const QgsMarkerSymbol *markerSymbol() const; SIP_SKIP
552 
560  QgsMarkerSymbol *markerSymbol();
561 
562  //
563  // ANNOTATIONS
564  //
565 
570  void setAnnotationEnabled( const bool enabled ) { mShowGridAnnotation = enabled; }
571 
576  bool annotationEnabled() const { return mShowGridAnnotation; }
577 
584  void setAnnotationTextFormat( const QgsTextFormat &format ) { mAnnotationFormat = format; }
585 
592  QgsTextFormat annotationTextFormat() const { return mAnnotationFormat; }
593 
600  Q_DECL_DEPRECATED void setAnnotationFont( const QFont &font ) SIP_DEPRECATED;
601 
608  Q_DECL_DEPRECATED QFont annotationFont() const SIP_DEPRECATED;
609 
616  Q_DECL_DEPRECATED void setAnnotationFontColor( const QColor &color ) SIP_DEPRECATED;
617 
624  Q_DECL_DEPRECATED QColor annotationFontColor() const SIP_DEPRECATED;
625 
631  void setAnnotationPrecision( const int precision ) { mGridAnnotationPrecision = precision; }
632 
638  int annotationPrecision() const { return mGridAnnotationPrecision; }
639 
647  void setAnnotationDisplay( DisplayMode display, BorderSide border );
648 
657  DisplayMode annotationDisplay( BorderSide border ) const;
658 
664  void setAnnotationPosition( AnnotationPosition position, BorderSide side );
665 
671  AnnotationPosition annotationPosition( BorderSide side ) const;
672 
677  void setAnnotationFrameDistance( const double distance );
678 
683  double annotationFrameDistance() const { return mAnnotationFrameDistance; }
684 
689  void setAnnotationDirection( AnnotationDirection direction, BorderSide side );
690 
695  void setAnnotationDirection( AnnotationDirection direction );
696 
702  AnnotationDirection annotationDirection( BorderSide border ) const;
703 
708  void setAnnotationFormat( const AnnotationFormat format ) { mGridAnnotationFormat = format; }
709 
714  AnnotationFormat annotationFormat() const { return mGridAnnotationFormat; }
715 
721  void setAnnotationExpression( const QString &expression ) { mGridAnnotationExpressionString = expression; mGridAnnotationExpression.reset(); }
722 
728  QString annotationExpression() const { return mGridAnnotationExpressionString; }
729 
730  //
731  // GRID FRAME
732  //
733 
738  void setFrameStyle( const FrameStyle style ) { mGridFrameStyle = style; }
739 
744  FrameStyle frameStyle() const { return mGridFrameStyle; }
745 
750  void setFrameDivisions( DisplayMode divisions, BorderSide side );
751 
756  DisplayMode frameDivisions( BorderSide side ) const;
757 
765  void setFrameSideFlags( QgsLayoutItemMapGrid::FrameSideFlags flags );
766 
775  void setFrameSideFlag( QgsLayoutItemMapGrid::FrameSideFlag flag, bool on = true );
776 
784  QgsLayoutItemMapGrid::FrameSideFlags frameSideFlags() const;
785 
795  bool testFrameSideFlag( FrameSideFlag flag ) const;
796 
803  void setFrameWidth( const double width );
804 
811  double frameWidth() const { return mGridFrameWidth; }
812 
818  void setRotatedTicksEnabled( const bool state ) { mRotatedTicksEnabled = state; }
819 
825  double rotatedTicksEnabled() const { return mRotatedTicksEnabled; }
826 
832  void setRotatedTicksLengthMode( const TickLengthMode mode ) { mRotatedTicksLengthMode = mode; }
833 
839  TickLengthMode rotatedTicksLengthMode() const { return mRotatedTicksLengthMode; }
840 
846  void setRotatedTicksMinimumAngle( const double angle ) { mRotatedTicksMinimumAngle = angle; }
847 
853  double rotatedTicksMinimumAngle() const { return mRotatedTicksMinimumAngle; }
854 
860  void setRotatedTicksMarginToCorner( const double margin ) { mRotatedTicksMarginToCorner = margin; }
861 
867  double rotatedTicksMarginToCorner() const { return mRotatedTicksMarginToCorner; }
868 
874  void setRotatedAnnotationsEnabled( const bool state ) { mRotatedAnnotationsEnabled = state; }
875 
881  double rotatedAnnotationsEnabled() const { return mRotatedAnnotationsEnabled; }
882 
888  void setRotatedAnnotationsLengthMode( const TickLengthMode mode ) { mRotatedAnnotationsLengthMode = mode; }
889 
895  TickLengthMode rotatedAnnotationsLengthMode() const { return mRotatedAnnotationsLengthMode; }
896 
902  void setRotatedAnnotationsMinimumAngle( const double angle ) { mRotatedAnnotationsMinimumAngle = angle; }
903 
909  double rotatedAnnotationsMinimumAngle() const { return mRotatedAnnotationsMinimumAngle; }
910 
916  void setRotatedAnnotationsMarginToCorner( const double margin ) { mRotatedAnnotationsMarginToCorner = margin; }
917 
923  double rotatedAnnotationsMarginToCorner() const { return mRotatedAnnotationsMarginToCorner; }
924 
931  void setFrameMargin( const double margin );
932 
939  double frameMargin() const { return mGridFrameMargin; }
940 
946  void setFramePenSize( const double width );
947 
953  double framePenSize() const { return mGridFramePenThickness; }
954 
962  void setFramePenColor( const QColor &color ) { mGridFramePenColor = color; }
963 
971  QColor framePenColor() const {return mGridFramePenColor;}
972 
979  void setFrameFillColor1( const QColor &color ) { mGridFrameFillColor1 = color; }
980 
987  QColor frameFillColor1() const { return mGridFrameFillColor1; }
988 
995  void setFrameFillColor2( const QColor &color ) { mGridFrameFillColor2 = color; }
996 
1003  QColor frameFillColor2() const { return mGridFrameFillColor2; }
1004 
1006  bool accept( QgsStyleEntityVisitorInterface *visitor ) const override;
1007  void refresh() override;
1008 
1009  signals:
1010 
1016  void crsChanged();
1017 
1018  private:
1019 
1020  QgsLayoutItemMapGrid() = delete;
1021 
1022  struct GridExtension
1023  {
1024  GridExtension() = default;
1025  double top = 0.0;
1026  double right = 0.0;
1027  double bottom = 0.0;
1028  double left = 0.0;
1029 
1033  void UpdateBorder( BorderSide border, double value )
1034  {
1035  switch ( border )
1036  {
1038  left = std::max( left, value );
1039  break;
1041  right = std::max( right, value );
1042  break;
1044  top = std::max( top, value );
1045  break;
1047  bottom = std::max( bottom, value );
1048  break;
1049  }
1050  }
1051 
1055  void UpdateAll( double value )
1056  {
1057  left = std::max( left, value );
1058  right = std::max( right, value );
1059  top = std::max( top, value );
1060  bottom = std::max( bottom, value );
1061  }
1062  };
1063 
1064  struct GridLineAnnotation
1065  {
1066  BorderSide border = Left; // border on which the annotation is
1067  QVector2D position; // position on the frame
1068  QVector2D vector; // vector towards map center
1069  double angle = 0; // the (acute) angle formed between the vector and the border
1070  };
1071 
1076  struct GridLine
1077  {
1078  QPolygonF line; // the actual line, can be straight with two points or curved if transformed
1079  double coordinate; // the coordinate value
1080  QgsLayoutItemMapGrid::AnnotationCoordinate coordinateType; // whether it's a latitude or longitude line
1081  GridLineAnnotation startAnnotation; // the annotation on the start point
1082  GridLineAnnotation endAnnotation; // the annotation on the end point
1083  };
1084  mutable QList< GridLine > mGridLines;
1085 
1087  mutable bool mTransformDirty = true;
1088 
1092  double mGridIntervalX = 0.0;
1094  double mGridIntervalY = 0.0;
1096  double mGridOffsetX = 0.0;
1098  double mGridOffsetY = 0.0;
1099 
1101  QgsTextFormat mAnnotationFormat;
1102 
1104  int mGridAnnotationPrecision = 3;
1106  bool mShowGridAnnotation = false;
1107 
1109  DisplayMode mLeftGridAnnotationDisplay = QgsLayoutItemMapGrid::ShowAll;
1111  DisplayMode mRightGridAnnotationDisplay = QgsLayoutItemMapGrid::ShowAll;
1113  DisplayMode mTopGridAnnotationDisplay = QgsLayoutItemMapGrid::ShowAll;
1115  DisplayMode mBottomGridAnnotationDisplay = QgsLayoutItemMapGrid::ShowAll;
1116 
1118  AnnotationPosition mLeftGridAnnotationPosition = QgsLayoutItemMapGrid::OutsideMapFrame;
1120  AnnotationPosition mRightGridAnnotationPosition = QgsLayoutItemMapGrid::OutsideMapFrame;
1122  AnnotationPosition mTopGridAnnotationPosition = QgsLayoutItemMapGrid::OutsideMapFrame;
1124  AnnotationPosition mBottomGridAnnotationPosition = QgsLayoutItemMapGrid::OutsideMapFrame;
1125 
1127  double mAnnotationFrameDistance = 1.0;
1128 
1130  AnnotationDirection mLeftGridAnnotationDirection = QgsLayoutItemMapGrid::Horizontal;
1132  AnnotationDirection mRightGridAnnotationDirection = QgsLayoutItemMapGrid::Horizontal;
1134  AnnotationDirection mTopGridAnnotationDirection = QgsLayoutItemMapGrid::Horizontal;
1136  AnnotationDirection mBottomGridAnnotationDirection = QgsLayoutItemMapGrid::Horizontal;
1137  AnnotationFormat mGridAnnotationFormat = QgsLayoutItemMapGrid::Decimal;
1138 
1139  QString mGridAnnotationExpressionString;
1140  mutable std::unique_ptr< QgsExpression > mGridAnnotationExpression;
1141 
1142  FrameStyle mGridFrameStyle = QgsLayoutItemMapGrid::NoFrame;
1143 
1144  FrameSideFlags mGridFrameSides;
1145  double mGridFrameWidth = 2.0;
1146  double mGridFramePenThickness = 0.3;
1147  QColor mGridFramePenColor = QColor( 0, 0, 0 );
1148  QColor mGridFrameFillColor1 = Qt::white;
1149  QColor mGridFrameFillColor2 = Qt::black;
1150  double mCrossLength = 3.0;
1151  double mGridFrameMargin = 0.0;
1152  bool mRotatedTicksEnabled = false;
1153  TickLengthMode mRotatedTicksLengthMode = QgsLayoutItemMapGrid::OrthogonalTicks;
1154  double mRotatedTicksMinimumAngle = 0.0;
1155  double mRotatedTicksMarginToCorner = 0.0;
1156  bool mRotatedAnnotationsEnabled = false;
1157  TickLengthMode mRotatedAnnotationsLengthMode = QgsLayoutItemMapGrid::OrthogonalTicks;
1158  double mRotatedAnnotationsMinimumAngle = 0.0;
1159  double mRotatedAnnotationsMarginToCorner = 0.0;
1160 
1161  double mMinimumIntervalWidth = 50;
1162  double mMaximumIntervalWidth = 100;
1163 
1165  DisplayMode mLeftFrameDivisions = QgsLayoutItemMapGrid::ShowAll;
1167  DisplayMode mRightFrameDivisions = QgsLayoutItemMapGrid::ShowAll;
1169  DisplayMode mTopFrameDivisions = QgsLayoutItemMapGrid::ShowAll;
1171  DisplayMode mBottomFrameDivisions = QgsLayoutItemMapGrid::ShowAll;
1172 
1173  std::unique_ptr< QgsLineSymbol > mGridLineSymbol;
1174  std::unique_ptr< QgsMarkerSymbol > mGridMarkerSymbol;
1175 
1177 
1178  GridUnit mGridUnit = MapUnit;
1179 
1180  QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
1181 
1182  mutable QList< QPair< double, QPolygonF > > mTransformedXLines;
1183  mutable QList< QPair< double, QPolygonF > > mTransformedYLines;
1184  mutable QList< QgsPointXY > mTransformedIntersections;
1185  QRectF mPrevPaintRect;
1186  mutable QPolygonF mPrevMapPolygon;
1187 
1188  bool mEvaluatedEnabled = true;
1189  double mEvaluatedIntervalX = 0;
1190  double mEvaluatedIntervalY = 0;
1191  double mEvaluatedOffsetX = 0;
1192  double mEvaluatedOffsetY = 0;
1193  double mEvaluatedGridFrameWidth = 0;
1194  double mEvaluatedGridFrameMargin = 0;
1195  double mEvaluatedAnnotationFrameDistance = 0;
1196  double mEvaluatedCrossLength = 0;
1197  double mEvaluatedGridFrameLineThickness = 0;
1198  DisplayMode mEvaluatedLeftGridAnnotationDisplay = QgsLayoutItemMapGrid::ShowAll;
1199  DisplayMode mEvaluatedRightGridAnnotationDisplay = QgsLayoutItemMapGrid::ShowAll;
1200  DisplayMode mEvaluatedTopGridAnnotationDisplay = QgsLayoutItemMapGrid::ShowAll;
1201  DisplayMode mEvaluatedBottomGridAnnotationDisplay = QgsLayoutItemMapGrid::ShowAll;
1202  DisplayMode mEvaluatedLeftFrameDivisions = QgsLayoutItemMapGrid::ShowAll;
1203  DisplayMode mEvaluatedRightFrameDivisions = QgsLayoutItemMapGrid::ShowAll;
1204  DisplayMode mEvaluatedTopFrameDivisions = QgsLayoutItemMapGrid::ShowAll;
1205  DisplayMode mEvaluatedBottomFrameDivisions = QgsLayoutItemMapGrid::ShowAll;
1206 
1210  void updateGridLinesAnnotationsPositions() const;
1211 
1216  void drawGridFrame( QPainter *p, GridExtension *extension = nullptr ) const;
1217 
1225  void drawCoordinateAnnotations( QgsRenderContext &context, QgsExpressionContext &expressionContext, GridExtension *extension = nullptr ) const;
1226 
1231  void drawCoordinateAnnotation( QgsRenderContext &context, GridLineAnnotation annot, const QString &annotationString, AnnotationCoordinate coordinateType, GridExtension *extension = nullptr ) const;
1232 
1233  QString gridAnnotationString( double value, AnnotationCoordinate coord, QgsExpressionContext &expressionContext ) const;
1234 
1239  int xGridLines() const;
1240 
1245  int yGridLines() const;
1246 
1247  int xGridLinesCrsTransform( const QgsRectangle &bbox, const QgsCoordinateTransform &t ) const;
1248 
1249  int yGridLinesCrsTransform( const QgsRectangle &bbox, const QgsCoordinateTransform &t ) const;
1250 
1251  void drawGridLine( const QLineF &line, QgsRenderContext &context ) const;
1252 
1253  void drawGridLine( const QPolygonF &line, QgsRenderContext &context ) const;
1254 
1259  void drawGridFrameBorder( QPainter *p, BorderSide border, double *extension = nullptr ) const;
1260 
1266  BorderSide borderForLineCoord( QPointF p, AnnotationCoordinate coordinateType ) const;
1267 
1269  int crsGridParams( QgsRectangle &crsRect, QgsCoordinateTransform &inverseTransform ) const;
1270 
1271  static QList<QPolygonF> trimLinesToMap( const QPolygonF &line, const QgsRectangle &rect );
1272 
1273  QPolygonF scalePolygon( const QPolygonF &polygon, double scale ) const;
1274 
1276  void drawGridCrsTransform( QgsRenderContext &context, double dotsPerMM, bool calculateLinesOnly = false ) const;
1277 
1278  void drawGridNoTransform( QgsRenderContext &context, double dotsPerMM, bool calculateLinesOnly = false ) const;
1279 
1280  void createDefaultGridLineSymbol();
1281 
1282  void createDefaultGridMarkerSymbol();
1283 
1284  void drawGridMarker( QPointF point, QgsRenderContext &context ) const;
1285 
1286  void drawGridFrameZebra( QPainter *p, GridExtension *extension = nullptr ) const;
1287 
1288  void drawGridFrameZebraBorder( QPainter *p, BorderSide border, double *extension = nullptr ) const;
1289 
1290  void drawGridFrameTicks( QPainter *p, GridExtension *extension = nullptr ) const;
1291 
1292  void drawGridFrameLine( QPainter *p, GridExtension *extension = nullptr ) const;
1293 
1294  void calculateCrsTransformLines() const;
1295 
1296  bool shouldShowDivisionForSide( AnnotationCoordinate coordinate, BorderSide side ) const;
1297  bool shouldShowAnnotationForSide( AnnotationCoordinate coordinate, BorderSide side ) const;
1298  bool shouldShowForDisplayMode( AnnotationCoordinate coordinate, DisplayMode mode ) const;
1299  void refreshDataDefinedProperties();
1300 
1302  double mapWidth() const;
1303 
1304  friend class TestQgsLayoutMapGrid;
1305 
1306 };
1307 
1308 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsLayoutItemMapGrid::FrameSideFlags )
1309 
1310 #endif // QGSLAYOUTITEMMAPGRID_H
void setAnnotationExpression(const QString &expression)
Sets the expression used for drawing grid annotations.
double offsetY() const
Returns the offset for grid lines in the y-direction.
The class is used as a container of context for various read/write operations on other objects...
TickLengthMode
Tick length mode (useful for rotated grids)
int precision
A rectangle specified with double values.
Definition: qgsrectangle.h:41
double intervalX() const
Returns the interval between grid lines in the x-direction.
Degree/minutes/seconds, use NSEW suffix.
bool annotationEnabled() const
Returns whether annotations are shown for the grid.
double rotatedAnnotationsMarginToCorner() const
Gets the margin to corners (in canvas units) below which outwards facing ticks are not drawn...
void setFrameFillColor1(const QColor &color)
Sets the first fill color used for the grid frame.
QColor framePenColor() const
Retrieves the color of the stroke drawn in the grid frame.
double framePenSize() const
Retrieves the width of the stroke drawn in the grid frame.
void setAnnotationTextFormat(const QgsTextFormat &format)
Sets the text format to use when rendering grid annotations.
void setRotatedAnnotationsLengthMode(const TickLengthMode mode)
Sets the annotation length calculation mode.
void setRotatedTicksEnabled(const bool state)
Enable/disable ticks rotation for rotated or reprojected grids.
FrameSideFlag
Flags for controlling which side of the map a frame is drawn on.
An item which is drawn inside a QgsLayoutItemMap, e.g., a grid or map overview.
Draw annotations vertically, ascending.
TickLengthMode rotatedAnnotationsLengthMode() const
Returns the grid frame style.
Draw annotations parallel to tick (above the line)
QgsTextFormat annotationTextFormat() const
Returns the text format used when rendering grid annotations.
A collection of map items which are drawn above the map content in a QgsLayoutItemMap.
FrameStyle
Style for grid frame.
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.
DisplayMode
Display settings for grid annotations and frames.
double intervalY() const
Returns the interval between grid lines in the y-direction.
void setBlendMode(const QPainter::CompositionMode mode)
Sets the blending mode used for drawing the grid.
double crossLength() const
Retrieves the length (in layout units) of the cross segments drawn for the grid.
Grid units in millimeters.
Degree/minutes, use - for S/W coordinates.
double offsetX() const
Returns the offset for grid lines in the x-direction.
double maximumIntervalWidth() const
Returns the maximum width (in millimeters) for grid segments.
double frameMargin() const
Sets the grid frame Margin (in layout units).
const QgsCoordinateReferenceSystem & crs
Degree/minutes, use NSEW suffix.
An interface for classes which can visit style entity (e.g.
double rotatedAnnotationsMinimumAngle() const
Gets the minimum angle (in degrees) below which annotated are not drawn.
int annotationPrecision() const
Returns the coordinate precision for grid annotations, which is the number of decimal places shown wh...
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
A marker symbol type, for rendering Point and MultiPoint geometries.
Definition: qgssymbol.h:985
QPainter::CompositionMode blendMode() const
Retrieves the blending mode used for drawing the grid.
TickLengthMode rotatedTicksLengthMode() const
Returns the grid frame style.
A line symbol type, for rendering LineString and MultiLineString geometries.
Definition: qgssymbol.h:1185
virtual bool usesAdvancedEffects() const
Returns true if the item is drawn using advanced effects, such as blend modes.
Draw line crosses at intersections of grid lines.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
Draw annotations parallel to tick (under the line)
void setRotatedAnnotationsEnabled(const bool state)
Enable/disable annotations rotation for rotated or reprojected grids.
Tick markers drawn inside map frame.
Layout graphical items for displaying a map.
A collection of grids which is drawn above the map content in a QgsLayoutItemMap. ...
Draw annotations horizontally.
AnnotationFormat annotationFormat() const
Returns the format for drawing grid annotations.
Grid units in centimeters.
void setRotatedTicksMinimumAngle(const double angle)
Sets the minimum angle (in degrees) below which ticks are not drawn.
#define SIP_SKIP
Definition: qgis_sip.h:126
void setFrameFillColor2(const QColor &color)
Sets the second fill color used for the grid frame.
virtual bool readXml(const QDomElement &element, const QDomDocument &doc, const QgsReadWriteContext &context)=0
Sets the item stack&#39;s state from a DOM document, where element is a DOM node corresponding to a &#39;Layo...
Decimal degrees, use - for S/W coordinates.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QColor frameFillColor1() const
Retrieves the first fill color for the grid frame.
QString annotationExpression() const
Returns the expression used for drawing grid annotations.
void setFramePenColor(const QColor &color)
Sets the color of the stroke drawn in the grid frame.
Decimal degrees, use NSEW suffix.
#define SIP_TRANSFER
Definition: qgis_sip.h:36
bool enabled() const
Returns whether the item will be drawn.
Show latitude/y annotations/divisions only.
void setAnnotationEnabled(const bool enabled)
Sets whether annotations should be shown for the grid.
void setFrameStyle(const FrameStyle style)
Sets the grid frame style.
Dynamically sized, based on a on-page size range.
virtual void draw(QPainter *painter)=0
Draws the item on to a destination painter.
Annotations follow the boundary direction.
AnnotationFormat
Format for displaying grid annotations.
double rotatedTicksMinimumAngle() const
Gets the minimum angle (in degrees) below which ticks are not drawn.
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
double annotationFrameDistance() const
Returns the distance between the map frame and annotations.
QgsLayoutItemMapItem & operator[](int index)
Returns a reference to an item at the specified index within the stack.
An individual grid which is drawn above the map content in a QgsLayoutItemMap.
AnnotationDirection
Direction of grid annotations.
GridUnit
Unit for grid values.
Show both latitude and longitude annotations/divisions.
AnnotationPosition
Position for grid annotations.
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 &#39;Layout...
AnnotationCoordinate
Annotation coordinate type.
QList< QgsLayoutItemMapItem *> asList() const
Returns a list of QgsLayoutItemMapItems contained by the stack.
double minimumIntervalWidth() const
Returns the minimum width (in millimeters) for grid segments.
void setAnnotationPrecision(const int precision)
Sets the coordinate precision for grid annotations.
BorderSide
Border sides for annotations.
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified style entity visitor, causing it to visit all style entities associated with th...
void setRotatedAnnotationsMarginToCorner(const double margin)
Sets the margin to corners (in canvas units) below which outwards facing ticks are not drawn...
void setRotatedAnnotationsMinimumAngle(const double angle)
Sets the minimum angle (in degrees) below which annotated are not drawn.
Draw annotations parallel to tick (on the line)
Contains information about the context of a rendering operation.
Degree/minutes/seconds, with minutes using leading zeros where required.
Draw annotations vertically, descending.
Show longitude/x annotations/divisions only.
void setAnnotationFormat(const AnnotationFormat format)
Sets the format for drawing grid annotations.
Draw markers at intersections of grid lines.
FrameStyle frameStyle() const
Returns the grid frame style.
Black/white pattern, with nautical style diagonals on corners.
Degree/minutes, with minutes using leading zeros where required.
This class represents a coordinate reference system (CRS).
double frameWidth() const
Gets the grid frame width in layout units.
Class for doing transforms between two map coordinate systems.
double rotatedTicksMarginToCorner() const
Gets the margin to corners (in canvas units) below which outwards facing ticks are not drawn...
GridUnit units() const
Returns the units used for grid measurements such as the interval and offset for grid lines...
GridStyle
Grid drawing style.
Simple solid line frame, with nautical style diagonals on corners.
Tick markers drawn both inside and outside the map frame.
virtual void refresh()
Refreshes the object, causing a recalculation of any property overrides.
Container for all settings relating to text rendering.
Definition: qgstextformat.h:39
void setRotatedTicksLengthMode(const TickLengthMode mode)
Sets the tick length calculation mode.
virtual void setEnabled(bool enabled)
Controls whether the item will be drawn.
GridStyle style() const
Returns the grid&#39;s style, which controls how the grid is drawn over the map&#39;s contents.
Draw annotations outside the map frame.
QColor frameFillColor2() const
Retrieves the second fill color for the grid frame.
Grid units follow map units.
double rotatedTicksEnabled() const
Gets whether ticks rotation for rotated or reprojected grids is enabled.
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 &#39;LayoutMa...
QgsCoordinateReferenceSystem crs() const
Retrieves the CRS for the grid.
void setRotatedTicksMarginToCorner(const double margin)
Sets the margin to corners (in canvas units) below which outwards facing ticks are not drawn...
double rotatedAnnotationsEnabled() const
Gets whether annotations rotation for rotated or reprojected grids is enabled.
Degree/minutes/seconds, use - for S/W coordinates.
Tick markers drawn outside map frame.