QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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 Member Functions

 QgsLayoutItemMapItem (const QString &name, QgsLayoutItemMap *map)
 Constructor for QgsLayoutItemMapItem, attached to the specified map. More...
 
virtual void draw (QPainter *painter)=0
 Draws the item on to a destination painter. More...
 
bool enabled () const
 Returns whether the item will be drawn. More...
 
virtual void finalizeRestoreFromXml ()
 Called after all pending items have been restored from XML. More...
 
QString id () const
 Returns the unique id for the map item. More...
 
const QgsLayoutItemMapmap () const
 Returns the layout item map for the item. More...
 
QString name () const
 Returns the friendly display name for the item. More...
 
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. More...
 
void setEnabled (bool enabled)
 Controls whether the item will be drawn. More...
 
void setMap (QgsLayoutItemMap *map)
 Sets the corresponding layout map for the item. More...
 
void setName (const QString &name)
 Sets the friendly display name for the item. More...
 
virtual bool usesAdvancedEffects () const
 Returns true if the item is drawn using advanced effects, such as blend modes. More...
 
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. More...
 
- Public Member Functions inherited from QgsLayoutObject
 QgsLayoutObject (QgsLayout *layout)
 Constructor for QgsLayoutObject, with the specified parent layout. More...
 
QgsExpressionContext createExpressionContext () const override
 Creates an expression context relating to the objects' current state. More...
 
QStringList customProperties () const
 Returns list of keys stored in custom properties for the object. More...
 
QVariant customProperty (const QString &key, const QVariant &defaultValue=QVariant()) const
 Read a custom property from the object. More...
 
QgsPropertyCollectiondataDefinedProperties ()
 Returns a reference to the object's property collection, used for data defined overrides. More...
 
const QgsPropertyCollectiondataDefinedProperties () const
 Returns a reference to the object's property collection, used for data defined overrides. More...
 
const QgsLayoutlayout () const
 Returns the layout the object is attached to. More...
 
QgsLayoutlayout ()
 Returns the layout the object is attached to. More...
 
void removeCustomProperty (const QString &key)
 Remove a custom property from the object. More...
 
void setCustomProperty (const QString &key, const QVariant &value)
 Set a custom property for the object. More...
 
void setDataDefinedProperties (const QgsPropertyCollection &collection)
 Sets the objects's property collection, used for data defined overrides. More...
 
- Public Member Functions inherited from QgsExpressionContextGenerator
virtual ~QgsExpressionContextGenerator ()=default
 

Protected Attributes

bool mEnabled
 True if item is to be displayed on map. More...
 
QgsLayoutItemMapmMap = nullptr
 Associated map. More...
 
QString mName
 Friendly display name. More...
 
QString mUuid
 Unique id. More...
 
- Protected Attributes inherited from QgsLayoutObject
QgsObjectCustomProperties mCustomProperties
 Custom properties for object. More...
 
QgsPropertyCollection mDataDefinedProperties
 
QPointer< QgsLayoutmLayout
 

Additional Inherited Members

- Public Types inherited from QgsLayoutObject
enum  DataDefinedProperty {
  NoProperty = 0, AllProperties, TestProperty, PresetPaperSize,
  PaperWidth, PaperHeight, NumPages, PaperOrientation,
  PageNumber, PositionX, PositionY, ItemWidth,
  ItemHeight, ItemRotation, Transparency, Opacity,
  BlendMode, ExcludeFromExports, FrameColor, BackgroundColor,
  MapRotation, MapScale, MapXMin, MapYMin,
  MapXMax, MapYMax, MapAtlasMargin, MapLayers,
  MapStylePreset, PictureSource, PictureSvgBackgroundColor, PictureSvgStrokeColor,
  PictureSvgStrokeWidth, SourceUrl, LegendTitle, LegendColumnCount,
  ScalebarFillColor, ScalebarFillColor2, ScalebarLineColor, ScalebarLineWidth,
  AttributeTableSourceLayer
}
 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 Slots inherited from QgsLayoutObject
virtual void refresh ()
 Refreshes the object, causing a recalculation of any property overrides. More...
 
- Signals inherited from QgsLayoutObject
void changed ()
 Emitted when the object's properties change. More...
 
- Static Public Member Functions inherited from QgsLayoutObject
static const QgsPropertiesDefinitionpropertyDefinitions ()
 Returns the layout object property definitions. More...
 
- Protected Member Functions inherited from QgsLayoutObject
bool readObjectPropertiesFromElement (const QDomElement &parentElement, const QDomDocument &document, const QgsReadWriteContext &context)
 Sets object properties from a DOM element. More...
 
bool writeObjectPropertiesToElement (QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context) const
 Stores object properties within an XML DOM element. More...
 

Detailed Description

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

Since
QGIS 3.0

Definition at line 32 of file qgslayoutitemmapitem.h.

Constructor & Destructor Documentation

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 22 of file qgslayoutitemmapitem.cpp.

Member Function Documentation

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

Draws the item on to a destination painter.

Implemented in QgsLayoutItemMapGrid, and QgsLayoutItemMapOverview.

bool QgsLayoutItemMapItem::enabled ( ) const

Returns whether the item will be drawn.

See also
setEnabled()

Definition at line 79 of file qgslayoutitemmapitem.cpp.

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 50 of file qgslayoutitemmapitem.cpp.

QString QgsLayoutItemMapItem::id ( ) const
inline

Returns the unique id for the map item.

Definition at line 89 of file qgslayoutitemmapitem.h.

const QgsLayoutItemMap * QgsLayoutItemMapItem::map ( ) const

Returns the layout item map for the item.

See also
setMap()

Definition at line 59 of file qgslayoutitemmapitem.cpp.

QString QgsLayoutItemMapItem::name ( ) const

Returns the friendly display name for the item.

See also
setName()

Definition at line 69 of file qgslayoutitemmapitem.cpp.

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 41 of file qgslayoutitemmapitem.cpp.

void QgsLayoutItemMapItem::setEnabled ( bool  enabled)

Controls whether the item will be drawn.

Set enabled to true to enable drawing of the item.

See also
enabled()

Definition at line 74 of file qgslayoutitemmapitem.cpp.

void QgsLayoutItemMapItem::setMap ( QgsLayoutItemMap map)

Sets the corresponding layout map for the item.

See also
map()

Definition at line 54 of file qgslayoutitemmapitem.cpp.

void QgsLayoutItemMapItem::setName ( const QString &  name)

Sets the friendly display name for the item.

See also
name()

Definition at line 64 of file qgslayoutitemmapitem.cpp.

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 84 of file qgslayoutitemmapitem.cpp.

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 32 of file qgslayoutitemmapitem.cpp.

Member Data Documentation

bool QgsLayoutItemMapItem::mEnabled
protected

True if item is to be displayed on map.

Definition at line 132 of file qgslayoutitemmapitem.h.

QgsLayoutItemMap* QgsLayoutItemMapItem::mMap = nullptr
protected

Associated map.

Definition at line 126 of file qgslayoutitemmapitem.h.

QString QgsLayoutItemMapItem::mName
protected

Friendly display name.

Definition at line 123 of file qgslayoutitemmapitem.h.

QString QgsLayoutItemMapItem::mUuid
protected

Unique id.

Definition at line 129 of file qgslayoutitemmapitem.h.


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