264 Q_DECLARE_FLAGS( FrameSideFlags, FrameSideFlag )
283 void draw( QPainter *painter )
override;
303 void setBlendMode(
const QPainter::CompositionMode mode ) { mBlendMode = mode; }
309 QPainter::CompositionMode
blendMode()
const {
return mBlendMode; }
311 bool usesAdvancedEffects()
const override;
317 double maxExtension()
const;
325 void calculateMaxExtension(
double &top,
double &right,
double &bottom,
double &left )
const;
327 void setEnabled(
bool enabled )
override;
338 void setUnits( GridUnit unit );
353 void setIntervalX(
double interval );
369 void setIntervalY(
double interval );
385 void setOffsetX(
double offset );
393 double offsetX()
const {
return mGridOffsetX; }
401 void setOffsetY(
double offset );
409 double offsetY()
const {
return mGridOffsetY; }
431 void setMinimumIntervalWidth(
double width );
453 void setMaximumIntervalWidth(
double width );
464 void setStyle( GridStyle style );
478 void setCrossLength(
const double length );
494 void setGridLineWidth(
double width );
503 void setGridLineColor(
const QColor &color );
601 Q_DECL_DEPRECATED
void setAnnotationFont(
const QFont &font )
SIP_DEPRECATED;
617 Q_DECL_DEPRECATED
void setAnnotationFontColor( const QColor &color )
SIP_DEPRECATED;
625 Q_DECL_DEPRECATED QColor annotationFontColor() const
SIP_DEPRECATED;
648 void setAnnotationDisplay( DisplayMode display, BorderSide border );
658 DisplayMode annotationDisplay( BorderSide border )
const;
665 void setAnnotationPosition( AnnotationPosition position, BorderSide side );
672 AnnotationPosition annotationPosition( BorderSide side )
const;
678 void setAnnotationFrameDistance(
const double distance );
690 void setAnnotationDirection( AnnotationDirection direction, BorderSide side );
696 void setAnnotationDirection( AnnotationDirection direction );
703 AnnotationDirection annotationDirection( BorderSide border )
const;
722 void setAnnotationExpression(
const QString &expression );
751 void setFrameDivisions( DisplayMode divisions, BorderSide side );
757 DisplayMode frameDivisions( BorderSide side )
const;
766 void setFrameSideFlags( QgsLayoutItemMapGrid::FrameSideFlags flags );
785 QgsLayoutItemMapGrid::FrameSideFlags frameSideFlags()
const;
796 bool testFrameSideFlag( FrameSideFlag flag )
const;
804 void setFrameWidth(
const double width );
932 void setFrameMargin(
const double margin );
947 void setFramePenSize(
const double width );
1008 void refresh()
override;
1023 struct GridExtension
1025 GridExtension() =
default;
1028 double bottom = 0.0;
1034 void UpdateBorder(
BorderSide border,
double value )
1039 left = std::max( left, value );
1042 right = std::max( right, value );
1045 top = std::max( top, value );
1048 bottom = std::max( bottom, value );
1056 void UpdateAll(
double value )
1058 left = std::max( left, value );
1059 right = std::max( right, value );
1060 top = std::max( top, value );
1061 bottom = std::max( bottom, value );
1065 struct GridLineAnnotation
1067 BorderSide border =
Left;
1082 GridLineAnnotation startAnnotation;
1083 GridLineAnnotation endAnnotation;
1085 mutable QList< GridLine > mGridLines;
1088 mutable bool mTransformDirty =
true;
1093 double mGridIntervalX = 0.0;
1095 double mGridIntervalY = 0.0;
1097 double mGridOffsetX = 0.0;
1099 double mGridOffsetY = 0.0;
1105 int mGridAnnotationPrecision = 3;
1107 bool mShowGridAnnotation =
false;
1128 double mAnnotationFrameDistance = 1.0;
1140 QString mGridAnnotationExpressionString;
1141 mutable std::unique_ptr< QgsExpression > mGridAnnotationExpression;
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;
1155 double mRotatedTicksMinimumAngle = 0.0;
1156 double mRotatedTicksMarginToCorner = 0.0;
1157 bool mRotatedAnnotationsEnabled =
false;
1159 double mRotatedAnnotationsMinimumAngle = 0.0;
1160 double mRotatedAnnotationsMarginToCorner = 0.0;
1162 double mMinimumIntervalWidth = 50;
1163 double mMaximumIntervalWidth = 100;
1174 std::unique_ptr< QgsLineSymbol > mGridLineSymbol;
1175 std::unique_ptr< QgsMarkerSymbol > mGridMarkerSymbol;
1179 GridUnit mGridUnit = MapUnit;
1181 QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
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;
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;
1211 void updateGridLinesAnnotationsPositions()
const;
1217 void drawGridFrame( QPainter *p, GridExtension *extension =
nullptr )
const;
1232 void drawCoordinateAnnotation(
QgsRenderContext &context, GridLineAnnotation annot,
const QString &annotationString, AnnotationCoordinate coordinateType, GridExtension *extension =
nullptr )
const;
1234 QString gridAnnotationString(
double value, AnnotationCoordinate coord,
QgsExpressionContext &expressionContext )
const;
1240 int xGridLines()
const;
1246 int yGridLines()
const;
1254 void drawGridLine(
const QPolygonF &line,
QgsRenderContext &context )
const;
1260 void drawGridFrameBorder( QPainter *p, BorderSide border,
double *extension =
nullptr )
const;
1267 BorderSide borderForLineCoord( QPointF p, AnnotationCoordinate coordinateType )
const;
1272 static QList<QPolygonF> trimLinesToMap(
const QPolygonF &line,
const QgsRectangle &rect );
1274 QPolygonF scalePolygon(
const QPolygonF &polygon,
double scale )
const;
1277 void drawGridCrsTransform(
QgsRenderContext &context,
double dotsPerMM,
bool calculateLinesOnly =
false )
const;
1279 void drawGridNoTransform(
QgsRenderContext &context,
double dotsPerMM,
bool calculateLinesOnly =
false )
const;
1281 void createDefaultGridLineSymbol();
1283 void createDefaultGridMarkerSymbol();
1287 void drawGridFrameZebra( QPainter *p, GridExtension *extension =
nullptr )
const;
1289 void drawGridFrameZebraBorder( QPainter *p, BorderSide border,
double *extension =
nullptr )
const;
1291 void drawGridFrameTicks( QPainter *p, GridExtension *extension =
nullptr )
const;
1293 void drawGridFrameLine( QPainter *p, GridExtension *extension =
nullptr )
const;
1295 void calculateCrsTransformLines()
const;
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();
1303 double mapWidth()
const;
1305 friend class TestQgsLayoutMapGrid;