QGIS API Documentation  2.99.0-Master (6a61179)
Public Types | Public Slots | Signals | Public Member Functions | Protected 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, BlendMode,
  ExcludeFromExports, MapRotation, MapScale, MapXMin,
  MapYMin, MapXMax, MapYMax, MapAtlasMargin,
  MapLayers, MapStylePreset, PictureSource, SourceUrl
}
 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 ()
 
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...
 
QgsDataDefineddataDefinedProperty (const DataDefinedProperty property) const
 Returns a reference to the data defined settings for one of the item's data defined properties. 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 setDataDefinedProperty (const DataDefinedProperty property, const bool active, const bool useExpression, const QString &expression, const QString &field)
 Sets parameters for a data defined property for the item. More...
 
virtual bool writeXml (QDomElement &elem, QDomDocument &doc) const
 Stores item state in DOM element. More...
 
- Public Member Functions inherited from QgsExpressionContextGenerator
virtual ~QgsExpressionContextGenerator ()
 

Protected Member Functions

bool dataDefinedEvaluate (const QgsComposerObject::DataDefinedProperty property, QVariant &expressionValue, const QgsExpressionContext &context=QgsExpressionContext()) const
 Evaluate a data defined property and return the calculated value. More...
 

Protected Attributes

QgsCompositionmComposition
 
QgsObjectCustomProperties mCustomProperties
 Custom properties for object. More...
 
QMap< QgsComposerObject::DataDefinedProperty, QString > mDataDefinedNames
 Map of data defined properties for the item to string name to use when exporting item to xml. More...
 

Friends

class TestQgsComposerObject
 

Detailed Description

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

Definition at line 33 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.

BlendMode 

Item blend mode.

ExcludeFromExports 

Exclude item from exports.

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.

SourceUrl 

Html source url.

Definition at line 40 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 81 of file qgscomposerobject.h.

Constructor & Destructor Documentation

§ QgsComposerObject()

QgsComposerObject::QgsComposerObject ( QgsComposition composition)

Constructor.

Parameters
compositionparent composition

Definition at line 25 of file qgscomposerobject.cpp.

§ ~QgsComposerObject()

QgsComposerObject::~QgsComposerObject ( )
virtual

Definition at line 50 of file qgscomposerobject.cpp.

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 96 of file qgscomposerobject.h.

§ composition() [2/2]

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

Definition at line 99 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.

Note
added in QGIS 2.12

Implements QgsExpressionContextGenerator.

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

Definition at line 190 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()
Note
added in QGIS 2.12

Definition at line 185 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()
Note
added in QGIS 2.12

Definition at line 175 of file qgscomposerobject.cpp.

§ dataDefinedEvaluate()

bool QgsComposerObject::dataDefinedEvaluate ( const QgsComposerObject::DataDefinedProperty  property,
QVariant &  expressionValue,
const QgsExpressionContext context = QgsExpressionContext() 
) const
protected

Evaluate a data defined property and return the calculated value.

Returns
true if data defined property could be successfully evaluated
Parameters
propertydata defined property to evaluate
expressionValueQVariant for storing the evaluated value
contextexpression context for evaluating expressions. Must have feature and fields set to current atlas feature and coverage layer fields prior to calling this method.
Note
this method was added in version 2.5

Definition at line 149 of file qgscomposerobject.cpp.

§ dataDefinedProperty()

QgsDataDefined * QgsComposerObject::dataDefinedProperty ( const DataDefinedProperty  property) const

Returns a reference to the data defined settings for one of the item's data defined properties.

Parameters
propertydata defined property to return
Note
this method was added in version 2.5

Definition at line 88 of file qgscomposerobject.cpp.

§ itemChanged

void QgsComposerObject::itemChanged ( )
signal

Emitted when the item changes.

Signifies that the item widgets must update the gui elements.

§ 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 QgsComposerMapGrid, QgsComposerScaleBar, QgsComposerLegend, QgsComposerMap, QgsComposerArrow, QgsComposerMapOverview, QgsComposerLabel, QgsComposerPicture, QgsComposerNodesItem, QgsPaperItem, QgsComposerItemGroup, QgsComposerShape, QgsComposerMapItem, and QgsComposerFrame.

Definition at line 71 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
Note
this method was added in version 2.5

Definition at line 141 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()
Note
added in QGIS 2.12

Definition at line 180 of file qgscomposerobject.cpp.

§ repaint

void QgsComposerObject::repaint ( )
virtualslot

Triggers a redraw for the item.

Definition at line 136 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()
Note
added in QGIS 2.12

Definition at line 170 of file qgscomposerobject.cpp.

§ setDataDefinedProperty()

void QgsComposerObject::setDataDefinedProperty ( const DataDefinedProperty  property,
const bool  active,
const bool  useExpression,
const QString &  expression,
const QString &  field 
)

Sets parameters for a data defined property for the item.

Parameters
propertydata defined property to set
activetrue if data defined property is active, false if it is disabled
useExpressiontrue if the expression should be used
expressionexpression for data defined property
fieldfield name if the data defined property should take its value from a field
Note
this method was added in version 2.5

Definition at line 107 of file qgscomposerobject.cpp.

§ 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 QgsComposerMapGrid, QgsComposerScaleBar, QgsComposerLegend, QgsComposerMap, QgsComposerArrow, QgsComposerMapOverview, QgsComposerLabel, QgsComposerNodesItem, QgsComposerPicture, QgsPaperItem, QgsComposerFrame, QgsComposerItemGroup, QgsComposerShape, and QgsComposerMapItem.

Definition at line 55 of file qgscomposerobject.cpp.

Friends And Related Function Documentation

§ TestQgsComposerObject

friend class TestQgsComposerObject
friend

Definition at line 228 of file qgscomposerobject.h.

Member Data Documentation

§ mComposition

QgsComposition* QgsComposerObject::mComposition
protected

Definition at line 190 of file qgscomposerobject.h.

§ mCustomProperties

QgsObjectCustomProperties QgsComposerObject::mCustomProperties
protected

Custom properties for object.

Definition at line 196 of file qgscomposerobject.h.

§ mDataDefinedNames

QMap< QgsComposerObject::DataDefinedProperty, QString > QgsComposerObject::mDataDefinedNames
protected

Map of data defined properties for the item to string name to use when exporting item to xml.

Definition at line 193 of file qgscomposerobject.h.


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