262 Q_DECLARE_FLAGS( FrameSideFlags, FrameSideFlag )
281 void draw( QPainter *painter )
override;
301 void setBlendMode(
const QPainter::CompositionMode mode ) { mBlendMode = mode; }
307 QPainter::CompositionMode
blendMode()
const {
return mBlendMode; }
309 bool usesAdvancedEffects()
const override;
315 double maxExtension()
const;
323 void calculateMaxExtension(
double &top,
double &right,
double &bottom,
double &left )
const;
325 void setEnabled(
bool enabled )
override;
336 void setUnits( GridUnit unit );
351 void setIntervalX(
double interval );
367 void setIntervalY(
double interval );
383 void setOffsetX(
double offset );
391 double offsetX()
const {
return mGridOffsetX; }
399 void setOffsetY(
double offset );
407 double offsetY()
const {
return mGridOffsetY; }
429 void setMinimumIntervalWidth(
double width );
451 void setMaximumIntervalWidth(
double width );
462 void setStyle( GridStyle style );
476 void setCrossLength(
const double length );
492 void setGridLineWidth(
double width );
501 void setGridLineColor(
const QColor &color );
599 Q_DECL_DEPRECATED
void setAnnotationFont(
const QFont &font )
SIP_DEPRECATED;
615 Q_DECL_DEPRECATED
void setAnnotationFontColor( const QColor &color )
SIP_DEPRECATED;
623 Q_DECL_DEPRECATED QColor annotationFontColor() const
SIP_DEPRECATED;
646 void setAnnotationDisplay( DisplayMode display, BorderSide border );
656 DisplayMode annotationDisplay( BorderSide border )
const;
663 void setAnnotationPosition( AnnotationPosition position, BorderSide side );
670 AnnotationPosition annotationPosition( BorderSide side )
const;
676 void setAnnotationFrameDistance(
const double distance );
688 void setAnnotationDirection( AnnotationDirection direction, BorderSide side );
694 void setAnnotationDirection( AnnotationDirection direction );
701 AnnotationDirection annotationDirection( BorderSide border )
const;
720 void setAnnotationExpression(
const QString &expression );
749 void setFrameDivisions( DisplayMode divisions, BorderSide side );
755 DisplayMode frameDivisions( BorderSide side )
const;
764 void setFrameSideFlags( QgsLayoutItemMapGrid::FrameSideFlags flags );
783 QgsLayoutItemMapGrid::FrameSideFlags frameSideFlags()
const;
794 bool testFrameSideFlag( FrameSideFlag flag )
const;
802 void setFrameWidth(
const double width );
930 void setFrameMargin(
const double margin );
945 void setFramePenSize(
const double width );
1006 void refresh()
override;
1021 struct GridExtension
1023 GridExtension() =
default;
1026 double bottom = 0.0;
1032 void UpdateBorder(
BorderSide border,
double value )
1037 left = std::max( left, value );
1040 right = std::max( right, value );
1043 top = std::max( top, value );
1046 bottom = std::max( bottom, value );
1054 void UpdateAll(
double value )
1056 left = std::max( left, value );
1057 right = std::max( right, value );
1058 top = std::max( top, value );
1059 bottom = std::max( bottom, value );
1063 struct GridLineAnnotation
1065 BorderSide border =
Left;
1080 GridLineAnnotation startAnnotation;
1081 GridLineAnnotation endAnnotation;
1083 mutable QList< GridLine > mGridLines;
1086 mutable bool mTransformDirty =
true;
1091 double mGridIntervalX = 0.0;
1093 double mGridIntervalY = 0.0;
1095 double mGridOffsetX = 0.0;
1097 double mGridOffsetY = 0.0;
1103 int mGridAnnotationPrecision = 3;
1105 bool mShowGridAnnotation =
false;
1126 double mAnnotationFrameDistance = 1.0;
1138 QString mGridAnnotationExpressionString;
1139 mutable std::unique_ptr< QgsExpression > mGridAnnotationExpression;
1143 FrameSideFlags mGridFrameSides;
1144 double mGridFrameWidth = 2.0;
1145 double mGridFramePenThickness = 0.3;
1146 QColor mGridFramePenColor = QColor( 0, 0, 0 );
1147 QColor mGridFrameFillColor1 = Qt::white;
1148 QColor mGridFrameFillColor2 = Qt::black;
1149 double mCrossLength = 3.0;
1150 double mGridFrameMargin = 0.0;
1151 bool mRotatedTicksEnabled =
false;
1153 double mRotatedTicksMinimumAngle = 0.0;
1154 double mRotatedTicksMarginToCorner = 0.0;
1155 bool mRotatedAnnotationsEnabled =
false;
1157 double mRotatedAnnotationsMinimumAngle = 0.0;
1158 double mRotatedAnnotationsMarginToCorner = 0.0;
1160 double mMinimumIntervalWidth = 50;
1161 double mMaximumIntervalWidth = 100;
1172 std::unique_ptr< QgsLineSymbol > mGridLineSymbol;
1173 std::unique_ptr< QgsMarkerSymbol > mGridMarkerSymbol;
1177 GridUnit mGridUnit = MapUnit;
1179 QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
1181 mutable QList< QPair< double, QPolygonF > > mTransformedXLines;
1182 mutable QList< QPair< double, QPolygonF > > mTransformedYLines;
1183 mutable QList< QgsPointXY > mTransformedIntersections;
1184 QRectF mPrevPaintRect;
1185 mutable QPolygonF mPrevMapPolygon;
1187 bool mEvaluatedEnabled =
true;
1188 double mEvaluatedIntervalX = 0;
1189 double mEvaluatedIntervalY = 0;
1190 double mEvaluatedOffsetX = 0;
1191 double mEvaluatedOffsetY = 0;
1192 double mEvaluatedGridFrameWidth = 0;
1193 double mEvaluatedGridFrameMargin = 0;
1194 double mEvaluatedAnnotationFrameDistance = 0;
1195 double mEvaluatedCrossLength = 0;
1196 double mEvaluatedGridFrameLineThickness = 0;
1209 void updateGridLinesAnnotationsPositions()
const;
1215 void drawGridFrame( QPainter *p, GridExtension *extension =
nullptr )
const;
1230 void drawCoordinateAnnotation(
QgsRenderContext &context, GridLineAnnotation annot,
const QString &annotationString, AnnotationCoordinate coordinateType, GridExtension *extension =
nullptr )
const;
1232 QString gridAnnotationString(
double value, AnnotationCoordinate coord,
QgsExpressionContext &expressionContext )
const;
1238 int xGridLines()
const;
1244 int yGridLines()
const;
1252 void drawGridLine(
const QPolygonF &line,
QgsRenderContext &context )
const;
1258 void drawGridFrameBorder( QPainter *p, BorderSide border,
double *extension =
nullptr )
const;
1265 BorderSide borderForLineCoord( QPointF p, AnnotationCoordinate coordinateType )
const;
1270 static QList<QPolygonF> trimLinesToMap(
const QPolygonF &line,
const QgsRectangle &rect );
1272 QPolygonF scalePolygon(
const QPolygonF &polygon,
double scale )
const;
1275 void drawGridCrsTransform(
QgsRenderContext &context,
double dotsPerMM,
bool calculateLinesOnly =
false )
const;
1277 void drawGridNoTransform(
QgsRenderContext &context,
double dotsPerMM,
bool calculateLinesOnly =
false )
const;
1279 void createDefaultGridLineSymbol();
1281 void createDefaultGridMarkerSymbol();
1285 void drawGridFrameZebra( QPainter *p, GridExtension *extension =
nullptr )
const;
1287 void drawGridFrameZebraBorder( QPainter *p, BorderSide border,
double *extension =
nullptr )
const;
1289 void drawGridFrameTicks( QPainter *p, GridExtension *extension =
nullptr )
const;
1291 void drawGridFrameLine( QPainter *p, GridExtension *extension =
nullptr )
const;
1293 void calculateCrsTransformLines()
const;
1295 bool shouldShowDivisionForSide( AnnotationCoordinate coordinate, BorderSide side )
const;
1296 bool shouldShowAnnotationForSide( AnnotationCoordinate coordinate, BorderSide side )
const;
1297 bool shouldShowForDisplayMode( AnnotationCoordinate coordinate, DisplayMode mode )
const;
1298 void refreshDataDefinedProperties();
1301 double mapWidth()
const;
1303 friend class TestQgsLayoutMapGrid;