QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Attributes | List of all members
QgsLayoutItemMapItem Class Referenceabstract

An item which is drawn inside a QgsLayoutItemMap, e.g., a grid or map overview. More...

#include <qgslayoutitemmapitem.h>

Inheritance diagram for QgsLayoutItemMapItem:
Inheritance graph
[legend]

Public Types

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...
 

Public Member Functions

 QgsLayoutItemMapItem (const QString &name, QgsLayoutItemMap *map)
 Constructor for QgsLayoutItemMapItem, attached to the specified map.
 
virtual bool accept (QgsStyleEntityVisitorInterface *visitor) const
 Accepts the specified style entity visitor, causing it to visit all style entities associated with the map item.
 
QgsExpressionContext createExpressionContext () const override
 This method needs to be reimplemented in all classes which implement this interface and return an expression context.
 
virtual void draw (QPainter *painter)=0
 Draws the item on to a destination painter.
 
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.
 
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 'LayoutMapGrid' tag.
 
virtual void setEnabled (bool enabled)
 Controls whether the item will be drawn.
 
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.
 
virtual bool usesAdvancedEffects () const
 Returns true if the item is drawn using advanced effects, such as blend modes.
 
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 'LayoutMap' tag.
 
- 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
 

Protected Attributes

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
 

Additional Inherited Members

- Public Slots inherited from QgsLayoutObject
virtual void refresh ()
 Refreshes the object, causing a recalculation of any property overrides.
 
- Signals inherited from QgsLayoutObject
void changed ()
 Emitted when the object's properties change.
 
- 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.
 

Detailed Description

An item which is drawn inside a QgsLayoutItemMap, e.g., a grid or map overview.

Definition at line 32 of file qgslayoutitemmapitem.h.

Member Enumeration Documentation

◆ StackingPosition

Item stacking position, specifies where the in the map's stack the item should be rendered.

Enumerator
StackBelowMap 

Render below all map layers.

StackBelowMapLayer 

Render below a specific map layer (see stackingLayer())

StackAboveMapLayer 

Render above a specific map layer (see stackingLayer())

StackBelowMapLabels 

Render above all map layers, but below map labels.

StackAboveMapLabels 

Render above all map layers and labels.

Definition at line 39 of file qgslayoutitemmapitem.h.

Constructor & Destructor Documentation

◆ QgsLayoutItemMapItem()

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

Constructor for QgsLayoutItemMapItem, attached to the specified map.

The name argument gives a friendly display name for the item.

Definition at line 24 of file qgslayoutitemmapitem.cpp.

Member Function Documentation

◆ accept()

bool QgsLayoutItemMapItem::accept ( QgsStyleEntityVisitorInterface visitor) const
virtual

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 in QgsLayoutItemMapGrid, and QgsLayoutItemMapOverview.

Definition at line 133 of file qgslayoutitemmapitem.cpp.

◆ createExpressionContext()

QgsExpressionContext QgsLayoutItemMapItem::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 125 of file qgslayoutitemmapitem.cpp.

◆ draw()

virtual void QgsLayoutItemMapItem::draw ( QPainter *  painter)
pure virtual

Draws the item on to a destination painter.

Implemented in QgsLayoutItemMapGrid, and QgsLayoutItemMapOverview.

◆ enabled()

bool QgsLayoutItemMapItem::enabled ( ) const

Returns whether the item will be drawn.

See also
setEnabled()

Definition at line 105 of file qgslayoutitemmapitem.cpp.

◆ finalizeRestoreFromXml()

void QgsLayoutItemMapItem::finalizeRestoreFromXml ( )
virtual

Called after all pending items have been restored from XML.

Map items can use this method to run steps which must take place after all items have been restored to the layout, such as connecting to signals emitted by other items, which may not have existed in the layout at the time readXml() was called. E.g. an overview can use this to connect to its linked map item after restoration from XML.

See also
readXml()

Reimplemented in QgsLayoutItemMapOverview.

Definition at line 76 of file qgslayoutitemmapitem.cpp.

◆ id()

QString QgsLayoutItemMapItem::id ( ) const
inline

Returns the unique id for the map item.

Definition at line 99 of file qgslayoutitemmapitem.h.

◆ map()

const QgsLayoutItemMap * QgsLayoutItemMapItem::map ( ) const

Returns the layout item map for the item.

See also
setMap()

Definition at line 85 of file qgslayoutitemmapitem.cpp.

◆ mapLayer()

QgsMapLayer * QgsLayoutItemMapItem::mapLayer ( )
virtual

Returns the internal map layer used by this item, if available.

Since
QGIS 3.10.1

Reimplemented in QgsLayoutItemMapOverview.

Definition at line 138 of file qgslayoutitemmapitem.cpp.

◆ name()

QString QgsLayoutItemMapItem::name ( ) const

Returns the friendly display name for the item.

See also
setName()

Definition at line 95 of file qgslayoutitemmapitem.cpp.

◆ readXml()

bool QgsLayoutItemMapItem::readXml ( const QDomElement &  element,
const QDomDocument &  doc,
const QgsReadWriteContext context 
)
virtual

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

See also
writeXml()

Reimplemented in QgsLayoutItemMapGrid, and QgsLayoutItemMapOverview.

Definition at line 56 of file qgslayoutitemmapitem.cpp.

◆ setEnabled()

void QgsLayoutItemMapItem::setEnabled ( bool  enabled)
virtual

Controls whether the item will be drawn.

Set enabled to true to enable drawing of the item.

See also
enabled()

Reimplemented in QgsLayoutItemMapGrid.

Definition at line 100 of file qgslayoutitemmapitem.cpp.

◆ setMap()

void QgsLayoutItemMapItem::setMap ( QgsLayoutItemMap map)

Sets the corresponding layout map for the item.

See also
map()

Definition at line 80 of file qgslayoutitemmapitem.cpp.

◆ setName()

void QgsLayoutItemMapItem::setName ( const QString &  name)

Sets the friendly display name for the item.

See also
name()

Definition at line 90 of file qgslayoutitemmapitem.cpp.

◆ setStackingLayer()

void QgsLayoutItemMapItem::setStackingLayer ( QgsMapLayer layer)

Sets the item's stacking layer, which specifies where the in the map's stack the item should be rendered.

This setting is only used when stackingPosition() is StackBelowMapLayer or StackAboveMapLayer.

See also
stackingLayer()
setStackingPosition
Since
QGIS 3.6

Definition at line 120 of file qgslayoutitemmapitem.cpp.

◆ setStackingPosition()

void QgsLayoutItemMapItem::setStackingPosition ( StackingPosition  position)
inline

Sets the item's stacking position, which specifies where the in the map's stack the item should be rendered.

See also
stackingPosition()
setStackingLayer()
Since
QGIS 3.6

Definition at line 150 of file qgslayoutitemmapitem.h.

◆ stackingLayer()

QgsMapLayer * QgsLayoutItemMapItem::stackingLayer ( ) const

Returns the item's stacking layer, which specifies where the in the map's stack the item should be rendered.

This setting is only used when stackingPosition() is StackBelowMapLayer or StackAboveMapLayer.

See also
setStackingLayer()
stackingPosition()
Since
QGIS 3.6

Definition at line 115 of file qgslayoutitemmapitem.cpp.

◆ stackingPosition()

StackingPosition QgsLayoutItemMapItem::stackingPosition ( ) const
inline

Returns the item's stacking position, which specifies where the in the map's stack the item should be rendered.

See also
setStackingPosition()
stackingLayer()
Since
QGIS 3.6

Definition at line 139 of file qgslayoutitemmapitem.h.

◆ usesAdvancedEffects()

bool QgsLayoutItemMapItem::usesAdvancedEffects ( ) const
virtual

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

Reimplemented in QgsLayoutItemMapGrid, and QgsLayoutItemMapOverview.

Definition at line 110 of file qgslayoutitemmapitem.cpp.

◆ writeXml()

bool QgsLayoutItemMapItem::writeXml ( QDomElement &  element,
QDomDocument &  document,
const QgsReadWriteContext context 
) const
virtual

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

See also
readXml()

Reimplemented in QgsLayoutItemMapGrid, and QgsLayoutItemMapOverview.

Definition at line 34 of file qgslayoutitemmapitem.cpp.

Member Data Documentation

◆ mEnabled

bool QgsLayoutItemMapItem::mEnabled
protected

True if item is to be displayed on map.

Definition at line 212 of file qgslayoutitemmapitem.h.

◆ mMap

QgsLayoutItemMap* QgsLayoutItemMapItem::mMap = nullptr
protected

Associated map.

Definition at line 206 of file qgslayoutitemmapitem.h.

◆ mName

QString QgsLayoutItemMapItem::mName
protected

Friendly display name.

Definition at line 203 of file qgslayoutitemmapitem.h.

◆ mStackingLayer

QgsMapLayerRef QgsLayoutItemMapItem::mStackingLayer
protected

Definition at line 216 of file qgslayoutitemmapitem.h.

◆ mStackingPosition

StackingPosition QgsLayoutItemMapItem::mStackingPosition = StackBelowMapLabels
protected

Definition at line 214 of file qgslayoutitemmapitem.h.

◆ mUuid

QString QgsLayoutItemMapItem::mUuid
protected

Unique id.

Definition at line 209 of file qgslayoutitemmapitem.h.


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