QGIS API Documentation 3.41.0-Master (fda2aa46e9a)
Loading...
Searching...
No Matches
Classes | Public Types | Signals | Public Member Functions | Friends | List of all members
QgsLayoutItemMapGrid Class Reference

An individual grid which is drawn above the map content in a QgsLayoutItemMap. More...

#include <qgslayoutitemmapgrid.h>

Inheritance diagram for QgsLayoutItemMapGrid:
Inheritance graph
[legend]

Public Types

enum  AnnotationCoordinate { Longitude = 0 , Latitude }
 Annotation coordinate type. More...
 
enum  AnnotationDirection {
  Horizontal = 0 , Vertical , VerticalDescending , BoundaryDirection ,
  AboveTick , OnTick , UnderTick
}
 Direction of grid annotations. More...
 
enum  AnnotationFormat {
  Decimal = 0 , DegreeMinute , DegreeMinuteSecond , DecimalWithSuffix ,
  DegreeMinuteNoSuffix , DegreeMinutePadded , DegreeMinuteSecondNoSuffix , DegreeMinuteSecondPadded ,
  CustomFormat
}
 Format for displaying grid annotations. More...
 
enum  AnnotationPosition { InsideMapFrame = 0 , OutsideMapFrame }
 Position for grid annotations. More...
 
enum  BorderSide { Left , Right , Bottom , Top }
 Border sides for annotations. More...
 
enum  DisplayMode { ShowAll = 0 , LatitudeOnly , LongitudeOnly , HideAll }
 Display settings for grid annotations and frames. More...
 
enum  FrameSideFlag { FrameLeft = 0x01 , FrameRight = 0x02 , FrameTop = 0x04 , FrameBottom = 0x08 }
 Flags for controlling which side of the map a frame is drawn on. More...
 
typedef QFlags< FrameSideFlagFrameSideFlags
 
enum  FrameStyle {
  NoFrame = 0 , Zebra , InteriorTicks , ExteriorTicks ,
  InteriorExteriorTicks , LineBorder , LineBorderNautical , ZebraNautical
}
 Style for grid frame. More...
 
enum  GridStyle { Solid = 0 , Cross , Markers , FrameAnnotationsOnly }
 Grid drawing style. More...
 
enum  GridUnit { MapUnit , MM , CM , DynamicPageSizeBased }
 Unit for grid values. More...
 
enum  TickLengthMode { OrthogonalTicks = 0 , NormalizedTicks }
 Tick length mode (useful for rotated grids) More...
 
- Public Types inherited from QgsLayoutItemMapItem
enum  StackingPosition {
  StackBelowMap , StackBelowMapLayer , StackAboveMapLayer , StackBelowMapLabels ,
  StackAboveMapLabels
}
 Item stacking position, specifies where the in the map's stack the item should be rendered. More...
 
- Public Types inherited from QgsLayoutObject
enum class  DataDefinedProperty : int {
  NoProperty = 0 , AllProperties , TestProperty , PresetPaperSize ,
  PaperWidth , PaperHeight , NumPages , PaperOrientation ,
  PageNumber , PositionX , PositionY , ItemWidth ,
  ItemHeight , ItemRotation , Transparency , Opacity ,
  BlendMode , ExcludeFromExports , FrameColor , BackgroundColor ,
  MarginLeft , MarginTop , MarginRight , MarginBottom ,
  MapRotation , MapScale , MapXMin , MapYMin ,
  MapXMax , MapYMax , MapAtlasMargin , MapLayers ,
  MapStylePreset , MapLabelMargin , MapGridEnabled , MapGridIntervalX ,
  MapGridIntervalY , MapGridOffsetX , MapGridOffsetY , MapGridFrameSize ,
  MapGridFrameMargin , MapGridLabelDistance , MapGridCrossSize , MapGridFrameLineThickness ,
  MapGridAnnotationDisplayLeft , MapGridAnnotationDisplayRight , MapGridAnnotationDisplayTop , MapGridAnnotationDisplayBottom ,
  MapGridFrameDivisionsLeft , MapGridFrameDivisionsRight , MapGridFrameDivisionsTop , MapGridFrameDivisionsBottom ,
  MapCrs , StartDateTime , EndDateTime , MapZRangeLower ,
  MapZRangeUpper , PictureSource , PictureSvgBackgroundColor , PictureSvgStrokeColor ,
  PictureSvgStrokeWidth , SourceUrl , LegendTitle , LegendColumnCount ,
  ScalebarLeftSegments , ScalebarRightSegments , ScalebarSegmentWidth , ScalebarMinimumWidth ,
  ScalebarMaximumWidth , ScalebarHeight , ScalebarRightSegmentSubdivisions , ScalebarSubdivisionHeight ,
  ScalebarFillColor , ScalebarFillColor2 , ScalebarLineColor , ScalebarLineWidth ,
  AttributeTableSourceLayer , ElevationProfileTolerance , ElevationProfileDistanceMajorInterval , ElevationProfileDistanceMinorInterval ,
  ElevationProfileDistanceLabelInterval , ElevationProfileElevationMajorInterval , ElevationProfileElevationMinorInterval , ElevationProfileElevationLabelInterval ,
  ElevationProfileMinimumDistance , ElevationProfileMaximumDistance , ElevationProfileMinimumElevation , ElevationProfileMaximumElevation
}
 Data defined properties for different item types. More...
 
enum  PropertyValueType { EvaluatedValue = 0 , OriginalValue }
 Specifies whether the value returned by a function should be the original, user set value, or the current evaluated value for the property. More...
 

Signals

void crsChanged ()
 Emitted whenever the grid's CRS is changed.
 
- Signals inherited from QgsLayoutObject
void changed ()
 Emitted when the object's properties change.
 

Public Member Functions

 QgsLayoutItemMapGrid (const QString &name, QgsLayoutItemMap *map)
 Constructor for QgsLayoutItemMapGrid.
 
 ~QgsLayoutItemMapGrid () override
 
bool accept (QgsStyleEntityVisitorInterface *visitor) const override
 Accepts the specified style entity visitor, causing it to visit all style entities associated with the map item.
 
AnnotationDirection annotationDirection (BorderSide border) const
 Returns the direction for drawing frame annotations, on the specified side of the map.
 
DisplayMode annotationDisplay (BorderSide border) const
 Returns the display mode for the grid annotations on a specified side of the map frame.
 
bool annotationEnabled () const
 Returns whether annotations are shown for the grid.
 
QString annotationExpression () const
 Returns the expression used for drawing grid annotations.
 
Q_DECL_DEPRECATED QFont annotationFont () const
 Returns the font used for drawing grid annotations.
 
Q_DECL_DEPRECATED QColor annotationFontColor () const
 Returns the font color used for drawing grid annotations.
 
AnnotationFormat annotationFormat () const
 Returns the format for drawing grid annotations.
 
double annotationFrameDistance () const
 Returns the distance between the map frame and annotations.
 
AnnotationPosition annotationPosition (BorderSide side) const
 Returns the position for the grid annotations on a specified side of the map frame.
 
int annotationPrecision () const
 Returns the coordinate precision for grid annotations, which is the number of decimal places shown when drawing grid annotations.
 
QgsTextFormat annotationTextFormat () const
 Returns the text format used when rendering grid annotations.
 
QPainter::CompositionMode blendMode () const
 Retrieves the blending mode used for drawing the grid.
 
void calculateMaxExtension (double &top, double &right, double &bottom, double &left) const
 Calculates the maximum distance the grid extends beyond the QgsLayoutItemMap's item rect.
 
void copyProperties (const QgsLayoutItemMapGrid *other)
 Copies properties from specified map grid.
 
QgsExpressionContext createExpressionContext () const override
 This method needs to be reimplemented in all classes which implement this interface and return an expression context.
 
double crossLength () const
 Retrieves the length (in layout units) of the cross segments drawn for the grid.
 
QgsCoordinateReferenceSystem crs () const
 Retrieves the CRS for the grid.
 
void draw (QPainter *painter) override
 Draws the item on to a destination painter.
 
DisplayMode frameDivisions (BorderSide side) const
 Returns the type of grid divisions which are used for frames on a specified side of the map.
 
QColor frameFillColor1 () const
 Retrieves the first fill color for the grid frame.
 
QColor frameFillColor2 () const
 Retrieves the second fill color for the grid frame.
 
double frameMargin () const
 Sets the grid frame Margin (in layout units).
 
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.
 
QgsLayoutItemMapGrid::FrameSideFlags frameSideFlags () const
 Returns the flags which control which sides of the map item the grid frame is drawn on.
 
FrameStyle frameStyle () const
 Returns the grid frame style.
 
double frameWidth () const
 Gets the grid frame width in layout units.
 
double intervalX () const
 Returns the interval between grid lines in the x-direction.
 
double intervalY () const
 Returns the interval between grid lines in the y-direction.
 
QgsLineSymbollineSymbol ()
 Returns the line symbol used for drawing grid lines.
 
const QgsLineSymbollineSymbol () const
 Returns the line symbol used for drawing grid lines.
 
QgsMarkerSymbolmarkerSymbol ()
 Returns the marker symbol used for drawing grid points.
 
const QgsMarkerSymbolmarkerSymbol () const
 Returns the marker symbol used for drawing grid points.
 
double maxExtension () const
 Calculates the maximum distance the grid extends beyond the QgsLayoutItemMap's item rect (in layout units).
 
double maximumIntervalWidth () const
 Returns the maximum width (in millimeters) for grid segments.
 
double minimumIntervalWidth () const
 Returns the minimum width (in millimeters) for grid segments.
 
double offsetX () const
 Returns the offset for grid lines in the x-direction.
 
double offsetY () const
 Returns the offset for grid lines in the y-direction.
 
bool readXml (const QDomElement &itemElem, const QDomDocument &doc, const QgsReadWriteContext &context) override
 Sets the map item state from a DOM document, where element is the DOM node corresponding to a 'LayoutMapGrid' tag.
 
void refresh () override
 Refreshes the object, causing a recalculation of any property overrides.
 
double rotatedAnnotationsEnabled () const
 Gets whether annotations rotation for rotated or reprojected grids is enabled.
 
TickLengthMode rotatedAnnotationsLengthMode () const
 Returns the annotation length calculation mode.
 
double rotatedAnnotationsMarginToCorner () const
 Gets the margin to corners (in canvas units) below which outwards facing annotations are not drawn.
 
double rotatedAnnotationsMinimumAngle () const
 Gets the minimum angle (in degrees) below which annotations are not drawn.
 
double rotatedTicksEnabled () const
 Gets whether ticks rotation for rotated or reprojected grids is enabled.
 
TickLengthMode rotatedTicksLengthMode () const
 Returns the grid frame style.
 
double rotatedTicksMarginToCorner () const
 Gets the margin to corners (in canvas units) below which outwards facing ticks are not drawn.
 
double rotatedTicksMinimumAngle () const
 Gets the minimum angle (in degrees) below which ticks are not drawn.
 
void setAnnotationDirection (AnnotationDirection direction)
 Sets the direction for drawing all frame annotations.
 
void setAnnotationDirection (AnnotationDirection direction, BorderSide side)
 Sets the direction for drawing frame annotations for the specified map side.
 
void setAnnotationDisplay (DisplayMode display, BorderSide border)
 Sets what types of grid annotations should be drawn for a specified side of the map frame, or whether grid annotations should be disabled for the side.
 
void setAnnotationEnabled (const bool enabled)
 Sets whether annotations should be shown for the grid.
 
void setAnnotationExpression (const QString &expression)
 Sets the expression used for drawing grid annotations.
 
Q_DECL_DEPRECATED void setAnnotationFont (const QFont &font)
 Sets the font used for drawing grid annotations.
 
Q_DECL_DEPRECATED void setAnnotationFontColor (const QColor &color)
 Sets the font color used for drawing grid annotations.
 
void setAnnotationFormat (const AnnotationFormat format)
 Sets the format for drawing grid annotations.
 
void setAnnotationFrameDistance (const double distance)
 Sets the distance between the map frame and annotations.
 
void setAnnotationPosition (AnnotationPosition position, BorderSide side)
 Sets the position for the grid annotations on a specified side of the map frame.
 
void setAnnotationPrecision (const int precision)
 Sets the coordinate precision for grid annotations.
 
void setAnnotationTextFormat (const QgsTextFormat &format)
 Sets the text format to use when rendering grid annotations.
 
void setBlendMode (const QPainter::CompositionMode mode)
 Sets the blending mode used for drawing the grid.
 
void setCrossLength (const double length)
 Sets the length (in layout units) of the cross segments drawn for the grid.
 
void setCrs (const QgsCoordinateReferenceSystem &crs)
 Sets the crs for the grid.
 
void setEnabled (bool enabled) override
 Controls whether the item will be drawn.
 
void setFrameDivisions (DisplayMode divisions, BorderSide side)
 Sets what type of grid divisions should be used for frames on a specified side of the map.
 
void setFrameFillColor1 (const QColor &color)
 Sets the first fill color used for the grid frame.
 
void setFrameFillColor2 (const QColor &color)
 Sets the second fill color used for the grid frame.
 
void setFrameMargin (const double margin)
 Sets the grid frame margin (in layout units).
 
void setFramePenColor (const QColor &color)
 Sets the color of the stroke drawn in the grid frame.
 
void setFramePenSize (const double width)
 Sets the width of the stroke drawn in the grid frame.
 
void setFrameSideFlag (QgsLayoutItemMapGrid::FrameSideFlag flag, bool on=true)
 Sets whether the grid frame is drawn for a certain side of the map item.
 
void setFrameSideFlags (QgsLayoutItemMapGrid::FrameSideFlags flags)
 Sets flags for grid frame sides.
 
void setFrameStyle (const FrameStyle style)
 Sets the grid frame style.
 
void setFrameWidth (const double width)
 Sets the grid frame width (in layout units).
 
void setGridLineColor (const QColor &color)
 Sets the color of grid lines.
 
void setGridLineWidth (double width)
 Sets the width of grid lines (in layout units).
 
void setIntervalX (double interval)
 Sets the interval between grid lines in the x-direction.
 
void setIntervalY (double interval)
 Sets the interval between grid lines in the y-direction.
 
void setLineSymbol (QgsLineSymbol *symbol)
 Sets the line symbol used for drawing grid lines.
 
void setMarkerSymbol (QgsMarkerSymbol *symbol)
 Sets the marker symbol used for drawing grid points.
 
void setMaximumIntervalWidth (double width)
 Sets the maximum width (in millimeters) for grid segments.
 
void setMinimumIntervalWidth (double width)
 Sets the minimum width (in millimeters) for grid segments.
 
void setOffsetX (double offset)
 Sets the offset for grid lines in the x-direction.
 
void setOffsetY (double offset)
 Sets the offset for grid lines in the y-direction.
 
void setRotatedAnnotationsEnabled (const bool state)
 Enable/disable annotations rotation for rotated or reprojected grids.
 
void setRotatedAnnotationsLengthMode (const TickLengthMode mode)
 Sets the annotation length calculation mode.
 
void setRotatedAnnotationsMarginToCorner (const double margin)
 Sets the margin to corners (in canvas units) below which outwards facing annotations are not drawn.
 
void setRotatedAnnotationsMinimumAngle (const double angle)
 Sets the minimum angle (in degrees) below which annotations are not drawn.
 
void setRotatedTicksEnabled (const bool state)
 Enable/disable ticks rotation for rotated or reprojected grids.
 
void setRotatedTicksLengthMode (const TickLengthMode mode)
 Sets the tick length calculation mode.
 
void setRotatedTicksMarginToCorner (const double margin)
 Sets the margin to corners (in canvas units) below which outwards facing ticks are not drawn.
 
void setRotatedTicksMinimumAngle (const double angle)
 Sets the minimum angle (in degrees) below which ticks are not drawn.
 
void setStyle (GridStyle style)
 Sets the grid style, which controls how the grid is drawn over the map's contents.
 
void setUnits (GridUnit unit)
 Sets the unit to use for grid measurements such as the interval and offset for grid lines.
 
GridStyle style () const
 Returns the grid's style, which controls how the grid is drawn over the map's contents.
 
bool testFrameSideFlag (FrameSideFlag flag) const
 Tests whether the grid frame should be drawn on a specified side of the map item.
 
GridUnit units () const
 Returns the units used for grid measurements such as the interval and offset for grid lines.
 
bool usesAdvancedEffects () const override
 Returns true if the item is drawn using advanced effects, such as blend modes.
 
bool writeXml (QDomElement &elem, QDomDocument &doc, const QgsReadWriteContext &context) const override
 Stores map item state in a DOM element, where element is the DOM element corresponding to a 'LayoutMap' tag.
 
- Public Member Functions inherited from QgsLayoutItemMapItem
 QgsLayoutItemMapItem (const QString &name, QgsLayoutItemMap *map)
 Constructor for QgsLayoutItemMapItem, attached to the specified map.
 
QgsExpressionContext createExpressionContext () const override
 This method needs to be reimplemented in all classes which implement this interface and return an expression context.
 
bool enabled () const
 Returns whether the item will be drawn.
 
virtual void finalizeRestoreFromXml ()
 Called after all pending items have been restored from XML.
 
QString id () const
 Returns the unique id for the map item.
 
const QgsLayoutItemMapmap () const
 Returns the layout item map for the item.
 
virtual QgsMapLayermapLayer ()
 Returns the internal map layer used by this item, if available.
 
QString name () const
 Returns the friendly display name for the item.
 
void setMap (QgsLayoutItemMap *map)
 Sets the corresponding layout map for the item.
 
void setName (const QString &name)
 Sets the friendly display name for the item.
 
void setStackingLayer (QgsMapLayer *layer)
 Sets the item's stacking layer, which specifies where the in the map's stack the item should be rendered.
 
void setStackingPosition (StackingPosition position)
 Sets the item's stacking position, which specifies where the in the map's stack the item should be rendered.
 
QgsMapLayerstackingLayer () const
 Returns the item's stacking layer, which specifies where the in the map's stack the item should be rendered.
 
StackingPosition stackingPosition () const
 Returns the item's stacking position, which specifies where the in the map's stack the item should be rendered.
 
- Public Member Functions inherited from QgsLayoutObject
 QgsLayoutObject (QgsLayout *layout)
 Constructor for QgsLayoutObject, with the specified parent layout.
 
QgsExpressionContext createExpressionContext () const override
 Creates an expression context relating to the objects' current state.
 
QStringList customProperties () const
 Returns list of keys stored in custom properties for the object.
 
QVariant customProperty (const QString &key, const QVariant &defaultValue=QVariant()) const
 Read a custom property from the object.
 
QgsPropertyCollectiondataDefinedProperties ()
 Returns a reference to the object's property collection, used for data defined overrides.
 
const QgsPropertyCollectiondataDefinedProperties () const
 Returns a reference to the object's property collection, used for data defined overrides.
 
QgsLayoutlayout ()
 Returns the layout the object is attached to.
 
const QgsLayoutlayout () const
 Returns the layout the object is attached to.
 
void removeCustomProperty (const QString &key)
 Remove a custom property from the object.
 
void setCustomProperty (const QString &key, const QVariant &value)
 Set a custom property for the object.
 
void setDataDefinedProperties (const QgsPropertyCollection &collection)
 Sets the objects's property collection, used for data defined overrides.
 
- Public Member Functions inherited from QgsExpressionContextGenerator
virtual ~QgsExpressionContextGenerator ()=default
 

Friends

class QgsLayoutItemMap
 
class TestQgsLayoutMapGrid
 

Additional Inherited Members

- Public Slots inherited from QgsLayoutObject
- Static Public Member Functions inherited from QgsLayoutObject
static bool propertyAssociatesWithParentMultiframe (DataDefinedProperty property)
 Returns true if the specified property key is normally associated with the parent QgsLayoutMultiFrame object instead of a child QgsLayoutFrame object.
 
static const QgsPropertiesDefinitionpropertyDefinitions ()
 Returns the layout object property definitions.
 
- Protected Member Functions inherited from QgsLayoutObject
bool readObjectPropertiesFromElement (const QDomElement &parentElement, const QDomDocument &document, const QgsReadWriteContext &context)
 Sets object properties from a DOM element.
 
bool writeObjectPropertiesToElement (QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context) const
 Stores object properties within an XML DOM element.
 
- Protected Attributes inherited from QgsLayoutItemMapItem
bool mEnabled
 True if item is to be displayed on map.
 
QgsLayoutItemMapmMap = nullptr
 Associated map.
 
QString mName
 Friendly display name.
 
QgsMapLayerRef mStackingLayer
 
StackingPosition mStackingPosition = StackBelowMapLabels
 
QString mUuid
 Unique id.
 
- Protected Attributes inherited from QgsLayoutObject
QgsObjectCustomProperties mCustomProperties
 Custom properties for object.
 
QgsPropertyCollection mDataDefinedProperties
 
QPointer< QgsLayoutmLayout
 

Detailed Description

An individual grid which is drawn above the map content in a QgsLayoutItemMap.

See also
QgsLayoutItemMapGridStack

Definition at line 138 of file qgslayoutitemmapgrid.h.

Member Typedef Documentation

◆ FrameSideFlags

Definition at line 262 of file qgslayoutitemmapgrid.h.

Member Enumeration Documentation

◆ AnnotationCoordinate

Annotation coordinate type.

Enumerator
Longitude 

Coordinate is a longitude value.

Latitude 

Coordinate is a latitude value.

Definition at line 267 of file qgslayoutitemmapgrid.h.

◆ AnnotationDirection

Direction of grid annotations.

Enumerator
Horizontal 

Draw annotations horizontally.

Vertical 

Draw annotations vertically, ascending.

VerticalDescending 

Draw annotations vertically, descending.

BoundaryDirection 

Annotations follow the boundary direction.

AboveTick 

Draw annotations parallel to tick (above the line)

OnTick 

Draw annotations parallel to tick (on the line)

UnderTick 

Draw annotations parallel to tick (under the line)

Definition at line 190 of file qgslayoutitemmapgrid.h.

◆ AnnotationFormat

Format for displaying grid annotations.

Enumerator
Decimal 

Decimal degrees, use - for S/W coordinates.

DegreeMinute 

Degree/minutes, use NSEW suffix.

DegreeMinuteSecond 

Degree/minutes/seconds, use NSEW suffix.

DecimalWithSuffix 

Decimal degrees, use NSEW suffix.

DegreeMinuteNoSuffix 

Degree/minutes, use - for S/W coordinates.

DegreeMinutePadded 

Degree/minutes, with minutes using leading zeros where required.

DegreeMinuteSecondNoSuffix 

Degree/minutes/seconds, use - for S/W coordinates.

DegreeMinuteSecondPadded 

Degree/minutes/seconds, with minutes using leading zeros where required.

CustomFormat 

Custom expression-based format.

Definition at line 204 of file qgslayoutitemmapgrid.h.

◆ AnnotationPosition

Position for grid annotations.

Enumerator
InsideMapFrame 

Draw annotations inside the map frame.

OutsideMapFrame 

Draw annotations outside the map frame.

Definition at line 181 of file qgslayoutitemmapgrid.h.

◆ BorderSide

Border sides for annotations.

Enumerator
Left 

Left border.

Right 

Right border.

Bottom 

Bottom border.

Top 

Top border.

Definition at line 220 of file qgslayoutitemmapgrid.h.

◆ DisplayMode

Display settings for grid annotations and frames.

Enumerator
ShowAll 

Show both latitude and longitude annotations/divisions.

LatitudeOnly 

Show latitude/y annotations/divisions only.

LongitudeOnly 

Show longitude/x annotations/divisions only.

HideAll 

No annotations.

Definition at line 170 of file qgslayoutitemmapgrid.h.

◆ FrameSideFlag

Flags for controlling which side of the map a frame is drawn on.

Enumerator
FrameLeft 

Left side of map.

FrameRight 

Right side of map.

FrameTop 

Top side of map.

FrameBottom 

Bottom side of map.

Definition at line 255 of file qgslayoutitemmapgrid.h.

◆ FrameStyle

Style for grid frame.

Enumerator
NoFrame 

Disable grid frame.

Zebra 

Black/white pattern.

InteriorTicks 

Tick markers drawn inside map frame.

ExteriorTicks 

Tick markers drawn outside map frame.

InteriorExteriorTicks 

Tick markers drawn both inside and outside the map frame.

LineBorder 

Simple solid line frame.

LineBorderNautical 

Simple solid line frame, with nautical style diagonals on corners.

ZebraNautical 

Black/white pattern, with nautical style diagonals on corners.

Definition at line 231 of file qgslayoutitemmapgrid.h.

◆ GridStyle

Grid drawing style.

Enumerator
Solid 
Cross 

Draw line crosses at intersections of grid lines.

Markers 

Draw markers at intersections of grid lines.

FrameAnnotationsOnly 

No grid lines over the map, only draw frame and annotations.

Definition at line 159 of file qgslayoutitemmapgrid.h.

◆ GridUnit

Unit for grid values.

Enumerator
MapUnit 

Grid units follow map units.

MM 

Grid units in millimeters.

CM 

Grid units in centimeters.

DynamicPageSizeBased 

Dynamically sized, based on a on-page size range.

Definition at line 148 of file qgslayoutitemmapgrid.h.

◆ TickLengthMode

Tick length mode (useful for rotated grids)

Enumerator
OrthogonalTicks 

Align ticks orthogonaly.

NormalizedTicks 

Constant tick lengths.

Definition at line 246 of file qgslayoutitemmapgrid.h.

Constructor & Destructor Documentation

◆ QgsLayoutItemMapGrid()

QgsLayoutItemMapGrid::QgsLayoutItemMapGrid ( const QString &  name,
QgsLayoutItemMap map 
)

Constructor for QgsLayoutItemMapGrid.

Parameters
namefriendly display name for grid
mapQgsLayoutItemMap the grid is attached to

Definition at line 189 of file qgslayoutitemmapgrid.cpp.

◆ ~QgsLayoutItemMapGrid()

QgsLayoutItemMapGrid::~QgsLayoutItemMapGrid ( )
overridedefault

Member Function Documentation

◆ accept()

bool QgsLayoutItemMapGrid::accept ( QgsStyleEntityVisitorInterface visitor) const
overridevirtual

Accepts the specified style entity visitor, causing it to visit all style entities associated with the map item.

Returns true if the visitor should continue visiting other objects, or false if visiting should be canceled.

Since
QGIS 3.10

Reimplemented from QgsLayoutItemMapItem.

Definition at line 2405 of file qgslayoutitemmapgrid.cpp.

◆ annotationDirection()

QgsLayoutItemMapGrid::AnnotationDirection QgsLayoutItemMapGrid::annotationDirection ( BorderSide  border) const

Returns the direction for drawing frame annotations, on the specified side of the map.

See also
setAnnotationDirection()

Definition at line 2509 of file qgslayoutitemmapgrid.cpp.

◆ annotationDisplay()

QgsLayoutItemMapGrid::DisplayMode QgsLayoutItemMapGrid::annotationDisplay ( const QgsLayoutItemMapGrid::BorderSide  border) const

Returns the display mode for the grid annotations on a specified side of the map frame.

This property also specifies whether annotations have been disabled from a side of the map frame.

Parameters
borderside of map for annotations
Returns
display mode for grid annotations
See also
setAnnotationDisplay()

Definition at line 2171 of file qgslayoutitemmapgrid.cpp.

◆ annotationEnabled()

bool QgsLayoutItemMapGrid::annotationEnabled ( ) const
inline

Returns whether annotations are shown for the grid.

See also
setAnnotationEnabled()

Definition at line 575 of file qgslayoutitemmapgrid.h.

◆ annotationExpression()

QString QgsLayoutItemMapGrid::annotationExpression ( ) const
inline

Returns the expression used for drawing grid annotations.

This is only used when annotationFormat() is QgsLayoutItemMapGrid::CustomFormat.

See also
setAnnotationExpression()

Definition at line 727 of file qgslayoutitemmapgrid.h.

◆ annotationFont()

QFont QgsLayoutItemMapGrid::annotationFont ( ) const

Returns the font used for drawing grid annotations.

Shortcut for annotationTextFormat().font().

See also
setAnnotationFont()
Deprecated:
QGIS 3.40. Use annotationTextFormat() instead.

Definition at line 2129 of file qgslayoutitemmapgrid.cpp.

◆ annotationFontColor()

QColor QgsLayoutItemMapGrid::annotationFontColor ( ) const

Returns the font color used for drawing grid annotations.

Shortcut for annotationTextFormat().color() and annotationTextFormat().opacity().

See also
setAnnotationFontColor()
Deprecated:
QGIS 3.40. Use annotationTextFormat() instead.

Definition at line 2139 of file qgslayoutitemmapgrid.cpp.

◆ annotationFormat()

AnnotationFormat QgsLayoutItemMapGrid::annotationFormat ( ) const
inline

Returns the format for drawing grid annotations.

See also
setAnnotationFormat()

Definition at line 713 of file qgslayoutitemmapgrid.h.

◆ annotationFrameDistance()

double QgsLayoutItemMapGrid::annotationFrameDistance ( ) const
inline

Returns the distance between the map frame and annotations.

Units are in layout units.

See also
setAnnotationFrameDistance()

Definition at line 682 of file qgslayoutitemmapgrid.h.

◆ annotationPosition()

QgsLayoutItemMapGrid::AnnotationPosition QgsLayoutItemMapGrid::annotationPosition ( const QgsLayoutItemMapGrid::BorderSide  border) const

Returns the position for the grid annotations on a specified side of the map frame.

See also
setAnnotationPosition()

Definition at line 2487 of file qgslayoutitemmapgrid.cpp.

◆ annotationPrecision()

int QgsLayoutItemMapGrid::annotationPrecision ( ) const
inline

Returns the coordinate precision for grid annotations, which is the number of decimal places shown when drawing grid annotations.

See also
setAnnotationPrecision()

Definition at line 637 of file qgslayoutitemmapgrid.h.

◆ annotationTextFormat()

QgsTextFormat QgsLayoutItemMapGrid::annotationTextFormat ( ) const
inline

Returns the text format used when rendering grid annotations.

See also
setAnnotationTextFormat()
Since
QGIS 3.16

Definition at line 591 of file qgslayoutitemmapgrid.h.

◆ blendMode()

QPainter::CompositionMode QgsLayoutItemMapGrid::blendMode ( ) const
inline

Retrieves the blending mode used for drawing the grid.

See also
setBlendMode()

Definition at line 307 of file qgslayoutitemmapgrid.h.

◆ calculateMaxExtension()

void QgsLayoutItemMapGrid::calculateMaxExtension ( double &  top,
double &  right,
double &  bottom,
double &  left 
) const

Calculates the maximum distance the grid extends beyond the QgsLayoutItemMap's item rect.

This method calculates the distance for each side of the map item separately.

See also
maxExtension()

Definition at line 2197 of file qgslayoutitemmapgrid.cpp.

◆ copyProperties()

void QgsLayoutItemMapGrid::copyProperties ( const QgsLayoutItemMapGrid other)

Copies properties from specified map grid.

Since
QGIS 3.38

Definition at line 2648 of file qgslayoutitemmapgrid.cpp.

◆ createExpressionContext()

QgsExpressionContext QgsLayoutItemMapGrid::createExpressionContext ( ) const
overridevirtual

This method needs to be reimplemented in all classes which implement this interface and return an expression context.

Implements QgsExpressionContextGenerator.

Definition at line 2395 of file qgslayoutitemmapgrid.cpp.

◆ crossLength()

double QgsLayoutItemMapGrid::crossLength ( ) const
inline

Retrieves the length (in layout units) of the cross segments drawn for the grid.

This is only used for grids with QgsLayoutItemMapGrid::Cross styles.

See also
setCrossLength()

Definition at line 483 of file qgslayoutitemmapgrid.h.

◆ crs()

QgsCoordinateReferenceSystem QgsLayoutItemMapGrid::crs ( ) const
inline

Retrieves the CRS for the grid.

See also
setCrs()

Definition at line 295 of file qgslayoutitemmapgrid.h.

◆ crsChanged

void QgsLayoutItemMapGrid::crsChanged ( )
signal

Emitted whenever the grid's CRS is changed.

Since
QGIS 3.18

◆ draw()

void QgsLayoutItemMapGrid::draw ( QPainter *  painter)
overridevirtual

Draws the item on to a destination painter.

Implements QgsLayoutItemMapItem.

Definition at line 599 of file qgslayoutitemmapgrid.cpp.

◆ frameDivisions()

QgsLayoutItemMapGrid::DisplayMode QgsLayoutItemMapGrid::frameDivisions ( const QgsLayoutItemMapGrid::BorderSide  border) const

Returns the type of grid divisions which are used for frames on a specified side of the map.

See also
setFrameDivisions()

Definition at line 2562 of file qgslayoutitemmapgrid.cpp.

◆ frameFillColor1()

QColor QgsLayoutItemMapGrid::frameFillColor1 ( ) const
inline

Retrieves the first fill color for the grid frame.

See also
setFrameFillColor1()
framePenColor()
frameFillColor2()

Definition at line 986 of file qgslayoutitemmapgrid.h.

◆ frameFillColor2()

QColor QgsLayoutItemMapGrid::frameFillColor2 ( ) const
inline

Retrieves the second fill color for the grid frame.

See also
setFrameFillColor2()
framePenColor()
frameFillColor1()

Definition at line 1002 of file qgslayoutitemmapgrid.h.

◆ frameMargin()

double QgsLayoutItemMapGrid::frameMargin ( ) const
inline

Sets the grid frame Margin (in layout units).

This property controls distance between the map frame and the grid frame.

See also
setFrameMargin()
Since
QGIS 3.6

Definition at line 938 of file qgslayoutitemmapgrid.h.

◆ framePenColor()

QColor QgsLayoutItemMapGrid::framePenColor ( ) const
inline

Retrieves the color of the stroke drawn in the grid frame.

See also
setFramePenColor()
framePenSize()
frameFillColor1()
frameFillColor2()

Definition at line 970 of file qgslayoutitemmapgrid.h.

◆ framePenSize()

double QgsLayoutItemMapGrid::framePenSize ( ) const
inline

Retrieves the width of the stroke drawn in the grid frame.

See also
setFramePenSize()
framePenColor()

Definition at line 952 of file qgslayoutitemmapgrid.h.

◆ frameSideFlags()

QgsLayoutItemMapGrid::FrameSideFlags QgsLayoutItemMapGrid::frameSideFlags ( ) const

Returns the flags which control which sides of the map item the grid frame is drawn on.

See also
setFrameSideFlags()
setFrameSideFlag()
testFrameSideFlag()

Definition at line 2390 of file qgslayoutitemmapgrid.cpp.

◆ frameStyle()

FrameStyle QgsLayoutItemMapGrid::frameStyle ( ) const
inline

Returns the grid frame style.

See also
setFrameStyle()

Definition at line 743 of file qgslayoutitemmapgrid.h.

◆ frameWidth()

double QgsLayoutItemMapGrid::frameWidth ( ) const
inline

Gets the grid frame width in layout units.

This property controls how wide the grid frame is. The size of the line outlines drawn in the frame can be retrieved via the framePenSize method.

See also
setFrameWidth()

Definition at line 810 of file qgslayoutitemmapgrid.h.

◆ intervalX()

double QgsLayoutItemMapGrid::intervalX ( ) const
inline

Returns the interval between grid lines in the x-direction.

The units are retrieved through the units() method.

See also
setIntervalX()
intervalY()

Definition at line 359 of file qgslayoutitemmapgrid.h.

◆ intervalY()

double QgsLayoutItemMapGrid::intervalY ( ) const
inline

Returns the interval between grid lines in the y-direction.

The units are retrieved through the units() method.

See also
setIntervalY()
intervalX()

Definition at line 375 of file qgslayoutitemmapgrid.h.

◆ lineSymbol() [1/2]

QgsLineSymbol * QgsLayoutItemMapGrid::lineSymbol ( )

Returns the line symbol used for drawing grid lines.

This is only used for grids with QgsLayoutItemMapGrid::Solid or QgsLayoutItemMapGrid::Cross styles.

See also
setLineSymbol()
markerSymbol()
style()

Definition at line 2094 of file qgslayoutitemmapgrid.cpp.

◆ lineSymbol() [2/2]

const QgsLineSymbol * QgsLayoutItemMapGrid::lineSymbol ( ) const

Returns the line symbol used for drawing grid lines.

This is only used for grids with QgsLayoutItemMapGrid::Solid or QgsLayoutItemMapGrid::Cross styles.

See also
setLineSymbol()
markerSymbol()
style()
Note
not available in Python bindings

Definition at line 2089 of file qgslayoutitemmapgrid.cpp.

◆ markerSymbol() [1/2]

QgsMarkerSymbol * QgsLayoutItemMapGrid::markerSymbol ( )

Returns the marker symbol used for drawing grid points.

This is only used for grids with a QgsLayoutItemMapGrid::Markers style.

See also
setMarkerSymbol()
lineSymbol()
style()

Definition at line 2109 of file qgslayoutitemmapgrid.cpp.

◆ markerSymbol() [2/2]

const QgsMarkerSymbol * QgsLayoutItemMapGrid::markerSymbol ( ) const

Returns the marker symbol used for drawing grid points.

This is only used for grids with a QgsLayoutItemMapGrid::Markers style.

See also
setMarkerSymbol()
lineSymbol()
style()
Note
not available in Python bindings

Definition at line 2104 of file qgslayoutitemmapgrid.cpp.

◆ maxExtension()

double QgsLayoutItemMapGrid::maxExtension ( ) const

Calculates the maximum distance the grid extends beyond the QgsLayoutItemMap's item rect (in layout units).

Definition at line 2187 of file qgslayoutitemmapgrid.cpp.

◆ maximumIntervalWidth()

double QgsLayoutItemMapGrid::maximumIntervalWidth ( ) const
inline

Returns the maximum width (in millimeters) for grid segments.

This property is only effective if the units() is set to DynamicPageSizeBased.

See also
units()
setMaximumIntervalWidth()
minimumIntervalWidth()
Since
QGIS 3.10

Definition at line 440 of file qgslayoutitemmapgrid.h.

◆ minimumIntervalWidth()

double QgsLayoutItemMapGrid::minimumIntervalWidth ( ) const
inline

Returns the minimum width (in millimeters) for grid segments.

This property is only effective if the units() is set to DynamicPageSizeBased.

See also
units()
setMinimumIntervalWidth()
maximumIntervalWidth()
Since
QGIS 3.10

Definition at line 418 of file qgslayoutitemmapgrid.h.

◆ offsetX()

double QgsLayoutItemMapGrid::offsetX ( ) const
inline

Returns the offset for grid lines in the x-direction.

The units are retrieved through the units() method.

See also
setOffsetX()
offsetY()

Definition at line 391 of file qgslayoutitemmapgrid.h.

◆ offsetY()

double QgsLayoutItemMapGrid::offsetY ( ) const
inline

Returns the offset for grid lines in the y-direction.

The units are retrieved through the units() method.

See also
setOffsetY()
offsetX()

Definition at line 407 of file qgslayoutitemmapgrid.h.

◆ readXml()

bool QgsLayoutItemMapGrid::readXml ( const QDomElement &  element,
const QDomDocument &  doc,
const QgsReadWriteContext context 
)
overridevirtual

Sets the map item state from a DOM document, where element is the DOM node corresponding to a 'LayoutMapGrid' tag.

See also
writeXml()

Reimplemented from QgsLayoutItemMapItem.

Definition at line 330 of file qgslayoutitemmapgrid.cpp.

◆ refresh()

void QgsLayoutItemMapGrid::refresh ( )
overridevirtual

Refreshes the object, causing a recalculation of any property overrides.

Reimplemented from QgsLayoutObject.

Definition at line 2423 of file qgslayoutitemmapgrid.cpp.

◆ rotatedAnnotationsEnabled()

double QgsLayoutItemMapGrid::rotatedAnnotationsEnabled ( ) const
inline

Gets whether annotations rotation for rotated or reprojected grids is enabled.

See also
setRotatedAnnotationsEnabled()
Since
QGIS 3.16

Definition at line 880 of file qgslayoutitemmapgrid.h.

◆ rotatedAnnotationsLengthMode()

TickLengthMode QgsLayoutItemMapGrid::rotatedAnnotationsLengthMode ( ) const
inline

Returns the annotation length calculation mode.

See also
setRotatedAnnotationsLengthMode()
Since
QGIS 3.16

Definition at line 894 of file qgslayoutitemmapgrid.h.

◆ rotatedAnnotationsMarginToCorner()

double QgsLayoutItemMapGrid::rotatedAnnotationsMarginToCorner ( ) const
inline

Gets the margin to corners (in canvas units) below which outwards facing annotations are not drawn.

See also
setRotatedAnnotationsMarginToCorner()
Since
QGIS 3.16

Definition at line 922 of file qgslayoutitemmapgrid.h.

◆ rotatedAnnotationsMinimumAngle()

double QgsLayoutItemMapGrid::rotatedAnnotationsMinimumAngle ( ) const
inline

Gets the minimum angle (in degrees) below which annotations are not drawn.

See also
setRotatedAnnotationsMinimumAngle()
Since
QGIS 3.16

Definition at line 908 of file qgslayoutitemmapgrid.h.

◆ rotatedTicksEnabled()

double QgsLayoutItemMapGrid::rotatedTicksEnabled ( ) const
inline

Gets whether ticks rotation for rotated or reprojected grids is enabled.

See also
setRotatedTicksEnabled()
Since
QGIS 3.16

Definition at line 824 of file qgslayoutitemmapgrid.h.

◆ rotatedTicksLengthMode()

TickLengthMode QgsLayoutItemMapGrid::rotatedTicksLengthMode ( ) const
inline

Returns the grid frame style.

See also
setRotatedTicksLengthMode()
Since
QGIS 3.16

Definition at line 838 of file qgslayoutitemmapgrid.h.

◆ rotatedTicksMarginToCorner()

double QgsLayoutItemMapGrid::rotatedTicksMarginToCorner ( ) const
inline

Gets the margin to corners (in canvas units) below which outwards facing ticks are not drawn.

See also
setRotatedTicksMarginToCorner()
Since
QGIS 3.16

Definition at line 866 of file qgslayoutitemmapgrid.h.

◆ rotatedTicksMinimumAngle()

double QgsLayoutItemMapGrid::rotatedTicksMinimumAngle ( ) const
inline

Gets the minimum angle (in degrees) below which ticks are not drawn.

See also
setRotatedTicksMinimumAngle()
Since
QGIS 3.16

Definition at line 852 of file qgslayoutitemmapgrid.h.

◆ setAnnotationDirection() [1/2]

void QgsLayoutItemMapGrid::setAnnotationDirection ( AnnotationDirection  direction)

Sets the direction for drawing all frame annotations.

See also
annotationDirection()

Definition at line 2454 of file qgslayoutitemmapgrid.cpp.

◆ setAnnotationDirection() [2/2]

void QgsLayoutItemMapGrid::setAnnotationDirection ( const QgsLayoutItemMapGrid::AnnotationDirection  direction,
const QgsLayoutItemMapGrid::BorderSide  border 
)

Sets the direction for drawing frame annotations for the specified map side.

See also
annotationDirection()

Definition at line 2352 of file qgslayoutitemmapgrid.cpp.

◆ setAnnotationDisplay()

void QgsLayoutItemMapGrid::setAnnotationDisplay ( const QgsLayoutItemMapGrid::DisplayMode  display,
const QgsLayoutItemMapGrid::BorderSide  border 
)

Sets what types of grid annotations should be drawn for a specified side of the map frame, or whether grid annotations should be disabled for the side.

Parameters
displaydisplay mode for annotations
borderside of map for annotations
See also
annotationDisplay()

Definition at line 2144 of file qgslayoutitemmapgrid.cpp.

◆ setAnnotationEnabled()

void QgsLayoutItemMapGrid::setAnnotationEnabled ( const bool  enabled)
inline

Sets whether annotations should be shown for the grid.

See also
annotationEnabled()

Definition at line 569 of file qgslayoutitemmapgrid.h.

◆ setAnnotationExpression()

void QgsLayoutItemMapGrid::setAnnotationExpression ( const QString &  expression)

Sets the expression used for drawing grid annotations.

This is only used when annotationFormat() is QgsLayoutItemMapGrid::CustomFormat.

See also
annotationExpression()

Definition at line 2530 of file qgslayoutitemmapgrid.cpp.

◆ setAnnotationFont()

void QgsLayoutItemMapGrid::setAnnotationFont ( const QFont &  font)

Sets the font used for drawing grid annotations.

Shortcut for annotationTextFormat().setFont().

See also
annotationFont()
Deprecated:
QGIS 3.40. Use setAnnotationTextFormat() instead.

Definition at line 2114 of file qgslayoutitemmapgrid.cpp.

◆ setAnnotationFontColor()

void QgsLayoutItemMapGrid::setAnnotationFontColor ( const QColor &  color)

Sets the font color used for drawing grid annotations.

Shortcut for annotationTextFormat().setColor() and annotationTextFormat().setOpacity().

See also
annotationFontColor()
Deprecated:
QGIS 3.40. Use setAnnotationTextFormat() instead.

Definition at line 2134 of file qgslayoutitemmapgrid.cpp.

◆ setAnnotationFormat()

void QgsLayoutItemMapGrid::setAnnotationFormat ( const AnnotationFormat  format)
inline

Sets the format for drawing grid annotations.

See also
annotationFormat()

Definition at line 707 of file qgslayoutitemmapgrid.h.

◆ setAnnotationFrameDistance()

void QgsLayoutItemMapGrid::setAnnotationFrameDistance ( const double  distance)

Sets the distance between the map frame and annotations.

Units are layout units.

See also
annotationFrameDistance()

Definition at line 2503 of file qgslayoutitemmapgrid.cpp.

◆ setAnnotationPosition()

void QgsLayoutItemMapGrid::setAnnotationPosition ( AnnotationPosition  position,
BorderSide  side 
)

Sets the position for the grid annotations on a specified side of the map frame.

See also
annotationPosition()

Definition at line 2462 of file qgslayoutitemmapgrid.cpp.

◆ setAnnotationPrecision()

void QgsLayoutItemMapGrid::setAnnotationPrecision ( const int  precision)
inline

Sets the coordinate precision for grid annotations.

The precision indicates the number of decimal places to show when drawing grid annotations.

See also
annotationPrecision()

Definition at line 630 of file qgslayoutitemmapgrid.h.

◆ setAnnotationTextFormat()

void QgsLayoutItemMapGrid::setAnnotationTextFormat ( const QgsTextFormat format)
inline

Sets the text format to use when rendering grid annotations.

See also
annotationTextFormat()
Since
QGIS 3.16

Definition at line 583 of file qgslayoutitemmapgrid.h.

◆ setBlendMode()

void QgsLayoutItemMapGrid::setBlendMode ( const QPainter::CompositionMode  mode)
inline

Sets the blending mode used for drawing the grid.

See also
blendMode()

Definition at line 301 of file qgslayoutitemmapgrid.h.

◆ setCrossLength()

void QgsLayoutItemMapGrid::setCrossLength ( const double  length)

Sets the length (in layout units) of the cross segments drawn for the grid.

This is only used for grids with QgsLayoutItemMapGrid::Cross styles.

See also
crossLength()

Definition at line 2346 of file qgslayoutitemmapgrid.cpp.

◆ setCrs()

void QgsLayoutItemMapGrid::setCrs ( const QgsCoordinateReferenceSystem crs)

Sets the crs for the grid.

See also
crs()

Definition at line 449 of file qgslayoutitemmapgrid.cpp.

◆ setEnabled()

void QgsLayoutItemMapGrid::setEnabled ( bool  enabled)
overridevirtual

Controls whether the item will be drawn.

Set enabled to true to enable drawing of the item.

See also
enabled()

Reimplemented from QgsLayoutItemMapItem.

Definition at line 2254 of file qgslayoutitemmapgrid.cpp.

◆ setFrameDivisions()

void QgsLayoutItemMapGrid::setFrameDivisions ( const QgsLayoutItemMapGrid::DisplayMode  divisions,
const QgsLayoutItemMapGrid::BorderSide  border 
)

Sets what type of grid divisions should be used for frames on a specified side of the map.

See also
frameDivisions()

Definition at line 2536 of file qgslayoutitemmapgrid.cpp.

◆ setFrameFillColor1()

void QgsLayoutItemMapGrid::setFrameFillColor1 ( const QColor &  color)
inline

Sets the first fill color used for the grid frame.

See also
frameFillColor1()
setFramePenColor()
setFrameFillColor2()

Definition at line 978 of file qgslayoutitemmapgrid.h.

◆ setFrameFillColor2()

void QgsLayoutItemMapGrid::setFrameFillColor2 ( const QColor &  color)
inline

Sets the second fill color used for the grid frame.

See also
frameFillColor2()
setFramePenColor()
setFrameFillColor1()

Definition at line 994 of file qgslayoutitemmapgrid.h.

◆ setFrameMargin()

void QgsLayoutItemMapGrid::setFrameMargin ( const double  margin)

Sets the grid frame margin (in layout units).

This property controls distance between the map frame and the grid frame.

See also
frameMargin()
Since
QGIS 3.6

Definition at line 2442 of file qgslayoutitemmapgrid.cpp.

◆ setFramePenColor()

void QgsLayoutItemMapGrid::setFramePenColor ( const QColor &  color)
inline

Sets the color of the stroke drawn in the grid frame.

See also
framePenColor()
setFramePenSize()
setFrameFillColor1()
setFrameFillColor2()

Definition at line 961 of file qgslayoutitemmapgrid.h.

◆ setFramePenSize()

void QgsLayoutItemMapGrid::setFramePenSize ( const double  width)

Sets the width of the stroke drawn in the grid frame.

See also
framePenSize()
setFramePenColor()

Definition at line 2448 of file qgslayoutitemmapgrid.cpp.

◆ setFrameSideFlag()

void QgsLayoutItemMapGrid::setFrameSideFlag ( QgsLayoutItemMapGrid::FrameSideFlag  flag,
bool  on = true 
)

Sets whether the grid frame is drawn for a certain side of the map item.

Parameters
flagflag for grid frame side
onset to true to draw grid frame on that side of the map
See also
setFrameSideFlags()
frameSideFlags()
testFrameSideFlag()

Definition at line 2382 of file qgslayoutitemmapgrid.cpp.

◆ setFrameSideFlags()

void QgsLayoutItemMapGrid::setFrameSideFlags ( QgsLayoutItemMapGrid::FrameSideFlags  flags)

Sets flags for grid frame sides.

Setting these flags controls which sides of the map item the grid frame is drawn on.

See also
setFrameSideFlag()
frameSideFlags()
testFrameSideFlag()

Definition at line 2377 of file qgslayoutitemmapgrid.cpp.

◆ setFrameStyle()

void QgsLayoutItemMapGrid::setFrameStyle ( const FrameStyle  style)
inline

Sets the grid frame style.

See also
frameStyle()

Definition at line 737 of file qgslayoutitemmapgrid.h.

◆ setFrameWidth()

void QgsLayoutItemMapGrid::setFrameWidth ( const double  width)

Sets the grid frame width (in layout units).

This property controls how wide the grid frame is. The size of the line outlines drawn in the frame is controlled through the setFramePenSize method.

See also
frameWidth()

Definition at line 2436 of file qgslayoutitemmapgrid.cpp.

◆ setGridLineColor()

void QgsLayoutItemMapGrid::setGridLineColor ( const QColor &  color)

Sets the color of grid lines.

This is only used for grids with QgsLayoutItemMapGrid::Solid or QgsLayoutItemMapGrid::Cross styles. For more control over grid line appearance, use setLineSymbol instead.

See also
setLineSymbol()
setGridLineWidth()

Definition at line 244 of file qgslayoutitemmapgrid.cpp.

◆ setGridLineWidth()

void QgsLayoutItemMapGrid::setGridLineWidth ( double  width)

Sets the width of grid lines (in layout units).

This is only used for grids with QgsLayoutItemMapGrid::Solid or QgsLayoutItemMapGrid::Cross styles. For more control over grid line appearance, use setLineSymbol instead.

See also
setLineSymbol()
setGridLineColor()

Definition at line 236 of file qgslayoutitemmapgrid.cpp.

◆ setIntervalX()

void QgsLayoutItemMapGrid::setIntervalX ( double  interval)

Sets the interval between grid lines in the x-direction.

The units are controlled through the setUnits method

See also
setIntervalY()
intervalX()

Definition at line 2270 of file qgslayoutitemmapgrid.cpp.

◆ setIntervalY()

void QgsLayoutItemMapGrid::setIntervalY ( double  interval)

Sets the interval between grid lines in the y-direction.

The units are controlled through the setUnits method

See also
setIntervalX()
intervalY()

Definition at line 2281 of file qgslayoutitemmapgrid.cpp.

◆ setLineSymbol()

void QgsLayoutItemMapGrid::setLineSymbol ( QgsLineSymbol symbol)

Sets the line symbol used for drawing grid lines.

This is only used for grids with QgsLayoutItemMapGrid::Solid or QgsLayoutItemMapGrid::Cross styles. Ownership of symbol is transferred to the grid.

See also
lineSymbol()
setMarkerSymbol()
setStyle()

Definition at line 2084 of file qgslayoutitemmapgrid.cpp.

◆ setMarkerSymbol()

void QgsLayoutItemMapGrid::setMarkerSymbol ( QgsMarkerSymbol symbol)

Sets the marker symbol used for drawing grid points.

This is only used for grids with a QgsLayoutItemMapGrid::Markers style. Ownership of symbol is transferred to the grid.

See also
markerSymbol()
setLineSymbol()
setStyle()

Definition at line 2099 of file qgslayoutitemmapgrid.cpp.

◆ setMaximumIntervalWidth()

void QgsLayoutItemMapGrid::setMaximumIntervalWidth ( double  width)

Sets the maximum width (in millimeters) for grid segments.

This property is only effective if the units() is set to DynamicPageSizeBased.

See also
maximumIntervalWidth()
setMinimumIntervalWidth()
setUnits()
Since
QGIS 3.10

Definition at line 2325 of file qgslayoutitemmapgrid.cpp.

◆ setMinimumIntervalWidth()

void QgsLayoutItemMapGrid::setMinimumIntervalWidth ( double  width)

Sets the minimum width (in millimeters) for grid segments.

This property is only effective if the units() is set to DynamicPageSizeBased.

See also
minimumIntervalWidth()
setMaximumIntervalWidth()
setUnits()
Since
QGIS 3.10

Definition at line 2314 of file qgslayoutitemmapgrid.cpp.

◆ setOffsetX()

void QgsLayoutItemMapGrid::setOffsetX ( double  offset)

Sets the offset for grid lines in the x-direction.

The units are controlled through the setUnits method.

See also
setOffsetY()
offsetX()

Definition at line 2292 of file qgslayoutitemmapgrid.cpp.

◆ setOffsetY()

void QgsLayoutItemMapGrid::setOffsetY ( double  offset)

Sets the offset for grid lines in the y-direction.

The units are controlled through the setUnits method.

See also
setOffsetX()
offsetY()

Definition at line 2303 of file qgslayoutitemmapgrid.cpp.

◆ setRotatedAnnotationsEnabled()

void QgsLayoutItemMapGrid::setRotatedAnnotationsEnabled ( const bool  state)
inline

Enable/disable annotations rotation for rotated or reprojected grids.

See also
rotatedAnnotationsEnabled()
Since
QGIS 3.16

Definition at line 873 of file qgslayoutitemmapgrid.h.

◆ setRotatedAnnotationsLengthMode()

void QgsLayoutItemMapGrid::setRotatedAnnotationsLengthMode ( const TickLengthMode  mode)
inline

Sets the annotation length calculation mode.

See also
rotatedAnnotationsLengthMode()
Since
QGIS 3.16

Definition at line 887 of file qgslayoutitemmapgrid.h.

◆ setRotatedAnnotationsMarginToCorner()

void QgsLayoutItemMapGrid::setRotatedAnnotationsMarginToCorner ( const double  margin)
inline

Sets the margin to corners (in canvas units) below which outwards facing annotations are not drawn.

See also
rotatedAnnotationsMarginToCorner()
Since
QGIS 3.16

Definition at line 915 of file qgslayoutitemmapgrid.h.

◆ setRotatedAnnotationsMinimumAngle()

void QgsLayoutItemMapGrid::setRotatedAnnotationsMinimumAngle ( const double  angle)
inline

Sets the minimum angle (in degrees) below which annotations are not drawn.

See also
rotatedAnnotationsMinimumAngle()
Since
QGIS 3.16

Definition at line 901 of file qgslayoutitemmapgrid.h.

◆ setRotatedTicksEnabled()

void QgsLayoutItemMapGrid::setRotatedTicksEnabled ( const bool  state)
inline

Enable/disable ticks rotation for rotated or reprojected grids.

See also
rotatedTicksEnabled()
Since
QGIS 3.16

Definition at line 817 of file qgslayoutitemmapgrid.h.

◆ setRotatedTicksLengthMode()

void QgsLayoutItemMapGrid::setRotatedTicksLengthMode ( const TickLengthMode  mode)
inline

Sets the tick length calculation mode.

See also
rotatedTicksLengthMode()
Since
QGIS 3.16

Definition at line 831 of file qgslayoutitemmapgrid.h.

◆ setRotatedTicksMarginToCorner()

void QgsLayoutItemMapGrid::setRotatedTicksMarginToCorner ( const double  margin)
inline

Sets the margin to corners (in canvas units) below which outwards facing ticks are not drawn.

See also
rotatedTicksMarginToCorner()
Since
QGIS 3.16

Definition at line 859 of file qgslayoutitemmapgrid.h.

◆ setRotatedTicksMinimumAngle()

void QgsLayoutItemMapGrid::setRotatedTicksMinimumAngle ( const double  angle)
inline

Sets the minimum angle (in degrees) below which ticks are not drawn.

See also
rotatedTicksMinimumAngle()
Since
QGIS 3.16

Definition at line 845 of file qgslayoutitemmapgrid.h.

◆ setStyle()

void QgsLayoutItemMapGrid::setStyle ( const QgsLayoutItemMapGrid::GridStyle  style)

Sets the grid style, which controls how the grid is drawn over the map's contents.

See also
style()

Definition at line 2336 of file qgslayoutitemmapgrid.cpp.

◆ setUnits()

void QgsLayoutItemMapGrid::setUnits ( const QgsLayoutItemMapGrid::GridUnit  unit)

Sets the unit to use for grid measurements such as the interval and offset for grid lines.

See also
units

Definition at line 2260 of file qgslayoutitemmapgrid.cpp.

◆ style()

GridStyle QgsLayoutItemMapGrid::style ( ) const
inline

Returns the grid's style, which controls how the grid is drawn over the map's contents.

See also
setStyle()

Definition at line 469 of file qgslayoutitemmapgrid.h.

◆ testFrameSideFlag()

bool QgsLayoutItemMapGrid::testFrameSideFlag ( QgsLayoutItemMapGrid::FrameSideFlag  flag) const

Tests whether the grid frame should be drawn on a specified side of the map item.

Parameters
flagflag for grid frame side
Returns
true if grid frame should be drawn for that side of the map
See also
setFrameSideFlags()
setFrameSideFlag()
frameSideFlags()

Definition at line 2431 of file qgslayoutitemmapgrid.cpp.

◆ units()

GridUnit QgsLayoutItemMapGrid::units ( ) const
inline

Returns the units used for grid measurements such as the interval and offset for grid lines.

See also
setUnits()

Definition at line 343 of file qgslayoutitemmapgrid.h.

◆ usesAdvancedEffects()

bool QgsLayoutItemMapGrid::usesAdvancedEffects ( ) const
overridevirtual

Returns true if the item is drawn using advanced effects, such as blend modes.

Reimplemented from QgsLayoutItemMapItem.

Definition at line 459 of file qgslayoutitemmapgrid.cpp.

◆ writeXml()

bool QgsLayoutItemMapGrid::writeXml ( QDomElement &  element,
QDomDocument &  document,
const QgsReadWriteContext context 
) const
overridevirtual

Stores map item state in a DOM element, where element is the DOM element corresponding to a 'LayoutMap' tag.

See also
readXml()

Reimplemented from QgsLayoutItemMapItem.

Definition at line 252 of file qgslayoutitemmapgrid.cpp.

Friends And Related Symbol Documentation

◆ QgsLayoutItemMap

friend class QgsLayoutItemMap
friend

Definition at line 1313 of file qgslayoutitemmapgrid.h.

◆ TestQgsLayoutMapGrid

friend class TestQgsLayoutMapGrid
friend

Definition at line 1310 of file qgslayoutitemmapgrid.h.


The documentation for this class was generated from the following files: