QGIS API Documentation  2.99.0-Master (f867b65)
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | List of all members
QgsComposerObject Class Reference

A base class for objects which belong to a map composition. More...

#include <qgscomposerobject.h>

Inheritance diagram for QgsComposerObject:
Inheritance graph
[legend]

Public Types

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

virtual void refreshDataDefinedProperty (const DataDefinedProperty property=AllProperties, const QgsExpressionContext *context=nullptr)
 Refreshes a data defined property for the item by reevaluating the property's value and redrawing the item with this new value. More...
 
virtual void repaint ()
 Triggers a redraw for the item. More...
 

Signals

void itemChanged ()
 Emitted when the item changes. More...
 

Public Member Functions

 QgsComposerObject (QgsComposition *composition)
 Constructor. More...
 
virtual ~QgsComposerObject ()=default
 
const QgsCompositioncomposition () const
 Returns the composition the item is attached to. More...
 
QgsCompositioncomposition ()
 
virtual QgsExpressionContext createExpressionContext () const
 Creates an expression context relating to the objects' current state. More...
 
QStringList customProperties () const
 Return 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...
 
virtual bool readXml (const QDomElement &itemElem, const QDomDocument &doc)
 Sets item state from DOM element. 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...
 
virtual bool writeXml (QDomElement &elem, QDomDocument &doc) const
 Stores item state in DOM element. More...
 
- Public Member Functions inherited from QgsExpressionContextGenerator
virtual ~QgsExpressionContextGenerator ()=default
 

Static Public Member Functions

static const QgsPropertiesDefinitionpropertyDefinitions ()
 Returns the composer object property definitions. More...
 

Protected Attributes

QgsCompositionmComposition = nullptr
 
QgsObjectCustomProperties mCustomProperties
 Custom properties for object. More...
 
QgsPropertyCollection mDataDefinedProperties
 

Friends

class TestQgsComposerObject
 

Detailed Description

A base class for objects which belong to a map composition.

Definition at line 35 of file qgscomposerobject.h.

Member Enumeration Documentation

◆ DataDefinedProperty

Data defined properties for different item types.

Enumerator
NoProperty 

No property.

AllProperties 

All properties for item.

TestProperty 

Dummy property with no effect on item.

PresetPaperSize 

Preset paper size for composition.

PaperWidth 

Paper width.

PaperHeight 

Paper height.

NumPages 

Number of pages in composition.

PaperOrientation 

Paper orientation.

PageNumber 

Page number for item placement.

PositionX 

X position on page.

PositionY 

Y position on page.

ItemWidth 

Width of item.

ItemHeight 

Height of item.

ItemRotation 

Rotation of item.

Transparency 

Item transparency (deprecated)

Opacity 

Item opacity.

BlendMode 

Item blend mode.

ExcludeFromExports 

Exclude item from exports.

FrameColor 

Item frame color.

BackgroundColor 

Item background color.

MapRotation 

Map rotation.

MapScale 

Map scale.

MapXMin 

Map extent x minimum.

MapYMin 

Map extent y minimum.

MapXMax 

Map extent x maximum.

MapYMax 

Map extent y maximum.

MapAtlasMargin 

Map atlas margin.

MapLayers 

Map layer set.

MapStylePreset 

Layer and style map theme.

PictureSource 

Picture source url.

PictureSvgBackgroundColor 

SVG background color.

PictureSvgStrokeColor 

SVG stroke color.

PictureSvgStrokeWidth 

SVG stroke width.

SourceUrl 

Html source url.

LegendTitle 

Legend title.

LegendColumnCount 

Legend column count.

ScalebarFillColor 

Scalebar fill color.

ScalebarFillColor2 

Scalebar secondary fill color.

ScalebarLineColor 

Scalebar line color.

ScalebarLineWidth 

Scalebar line width.

Definition at line 42 of file qgscomposerobject.h.

◆ PropertyValueType

Specifies whether the value returned by a function should be the original, user set value, or the current evaluated value for the property.

This may differ if a property has a data defined expression active.

Enumerator
EvaluatedValue 

Return the current evaluated value for the property.

OriginalValue 

Return the original, user set value.

Definition at line 97 of file qgscomposerobject.h.

Constructor & Destructor Documentation

◆ QgsComposerObject()

QgsComposerObject::QgsComposerObject ( QgsComposition composition)

Constructor.

Parameters
compositionparent composition

Definition at line 88 of file qgscomposerobject.cpp.

◆ ~QgsComposerObject()

virtual QgsComposerObject::~QgsComposerObject ( )
virtualdefault

Member Function Documentation

◆ composition() [1/2]

const QgsComposition* QgsComposerObject::composition ( ) const
inline

Returns the composition the item is attached to.

Returns
QgsComposition for item.

Definition at line 118 of file qgscomposerobject.h.

◆ composition() [2/2]

QgsComposition* QgsComposerObject::composition ( )
inline
Note
not available in Python bindings

Definition at line 121 of file qgscomposerobject.h.

◆ createExpressionContext()

QgsExpressionContext QgsComposerObject::createExpressionContext ( ) const
virtual

Creates an expression context relating to the objects' current state.

The context includes scopes for global, project and composition properties.

Since
QGIS 2.12

Implements QgsExpressionContextGenerator.

Reimplemented in QgsComposerMapGrid, QgsComposerItem, QgsComposerMap, QgsComposerAttributeTableV2, and QgsComposerFrame.

Definition at line 200 of file qgscomposerobject.cpp.

◆ customProperties()

QStringList QgsComposerObject::customProperties ( ) const

Return list of keys stored in custom properties for the object.

See also
setCustomProperty()
customProperty()
removeCustomProperty()
Since
QGIS 2.12

Definition at line 195 of file qgscomposerobject.cpp.

◆ customProperty()

QVariant QgsComposerObject::customProperty ( const QString &  key,
const QVariant &  defaultValue = QVariant() 
) const

Read a custom property from the object.

Parameters
keyproperty key
defaultValuedefault value to return if property with matching key does not exist
Returns
value of matching property
See also
setCustomProperty()
removeCustomProperty()
customProperties()
Since
QGIS 2.12

Definition at line 185 of file qgscomposerobject.cpp.

◆ dataDefinedProperties() [1/2]

QgsPropertyCollection& QgsComposerObject::dataDefinedProperties ( )
inline

Returns a reference to the object's property collection, used for data defined overrides.

Since
QGIS 3.0
See also
setDataDefinedProperties()

Definition at line 139 of file qgscomposerobject.h.

◆ dataDefinedProperties() [2/2]

const QgsPropertyCollection& QgsComposerObject::dataDefinedProperties ( ) const
inline

Returns a reference to the object's property collection, used for data defined overrides.

Since
QGIS 3.0
See also
setDataDefinedProperties()

Definition at line 145 of file qgscomposerobject.h.

◆ itemChanged

void QgsComposerObject::itemChanged ( )
signal

Emitted when the item changes.

Signifies that the item widgets must update the gui elements.

◆ propertyDefinitions()

const QgsPropertiesDefinition & QgsComposerObject::propertyDefinitions ( )
static

Returns the composer object property definitions.

Since
QGIS 3.0

Definition at line 82 of file qgscomposerobject.cpp.

◆ readXml()

bool QgsComposerObject::readXml ( const QDomElement &  itemElem,
const QDomDocument &  doc 
)
virtual

Sets item state from DOM element.

Parameters
itemElemis DOM node corresponding to item tag
docis DOM document

Reimplemented in QgsComposerScaleBar, QgsComposerMap, QgsComposerMapGrid, QgsComposerLegend, QgsComposerArrow, QgsComposerMapOverview, QgsComposerLabel, QgsComposerPicture, QgsComposerNodesItem, QgsPaperItem, QgsComposerItemGroup, QgsComposerShape, QgsComposerMapItem, and QgsComposerFrame.

Definition at line 130 of file qgscomposerobject.cpp.

◆ refreshDataDefinedProperty

void QgsComposerObject::refreshDataDefinedProperty ( const DataDefinedProperty  property = AllProperties,
const QgsExpressionContext context = nullptr 
)
virtualslot

Refreshes a data defined property for the item by reevaluating the property's value and redrawing the item with this new value.

Parameters
propertydata defined property to refresh. If property is set to QgsComposerItem::AllProperties then all data defined properties for the item will be refreshed.
contextexpression context for evaluating data defined expressions
Since
QGIS 2.5

Definition at line 166 of file qgscomposerobject.cpp.

◆ removeCustomProperty()

void QgsComposerObject::removeCustomProperty ( const QString &  key)

Remove a custom property from the object.

Parameters
keyproperty key
See also
setCustomProperty()
customProperty()
customProperties()
Since
QGIS 2.12

Definition at line 190 of file qgscomposerobject.cpp.

◆ repaint

void QgsComposerObject::repaint ( )
virtualslot

Triggers a redraw for the item.

Definition at line 161 of file qgscomposerobject.cpp.

◆ setCustomProperty()

void QgsComposerObject::setCustomProperty ( const QString &  key,
const QVariant &  value 
)

Set a custom property for the object.

Parameters
keyproperty key. If a property with the same key already exists it will be overwritten.
valueproperty value
See also
customProperty()
removeCustomProperty()
customProperties()
Since
QGIS 2.12

Definition at line 180 of file qgscomposerobject.cpp.

◆ setDataDefinedProperties()

void QgsComposerObject::setDataDefinedProperties ( const QgsPropertyCollection collection)
inline

Sets the objects's property collection, used for data defined overrides.

Parameters
collectionproperty collection. Existing properties will be replaced.
Since
QGIS 3.0
See also
dataDefinedProperties()

Definition at line 152 of file qgscomposerobject.h.

◆ writeXml()

bool QgsComposerObject::writeXml ( QDomElement &  elem,
QDomDocument &  doc 
) const
virtual

Stores item state in DOM element.

Parameters
elemis DOM element corresponding to item tag
docis the DOM document

Reimplemented in QgsComposerScaleBar, QgsComposerMap, QgsComposerMapGrid, QgsComposerLegend, QgsComposerArrow, QgsComposerMapOverview, QgsComposerLabel, QgsComposerNodesItem, QgsComposerPicture, QgsPaperItem, QgsComposerFrame, QgsComposerItemGroup, QgsComposerShape, and QgsComposerMapItem.

Definition at line 113 of file qgscomposerobject.cpp.

Friends And Related Function Documentation

◆ TestQgsComposerObject

friend class TestQgsComposerObject
friend

Definition at line 242 of file qgscomposerobject.h.

Member Data Documentation

◆ mComposition

QgsComposition* QgsComposerObject::mComposition = nullptr
protected

Definition at line 215 of file qgscomposerobject.h.

◆ mCustomProperties

QgsObjectCustomProperties QgsComposerObject::mCustomProperties
protected

Custom properties for object.

Definition at line 218 of file qgscomposerobject.h.

◆ mDataDefinedProperties

QgsPropertyCollection QgsComposerObject::mDataDefinedProperties
protected

Definition at line 220 of file qgscomposerobject.h.


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