QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
Loading...
Searching...
No Matches
qgslayoutobject.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgslayoutobject.cpp
3 -------------------
4 begin : June 2017
5 copyright : (C) 2017 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include "qgslayoutobject.h"
19
21#include "qgslayout.h"
23
24#include <QPainter>
25#include <QString>
26
27#include "moc_qgslayoutobject.cpp"
28
29using namespace Qt::StringLiterals;
30
31QgsPropertiesDefinition QgsLayoutObject::sPropertyDefinitions;
32
33void QgsLayoutObject::initPropertyDefinitions()
34{
35 if ( !sPropertyDefinitions.isEmpty() )
36 return;
37
38 sPropertyDefinitions = QgsPropertiesDefinition {
39 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::TestProperty ), QgsPropertyDefinition( "dataDefinedProperty", QgsPropertyDefinition::DataTypeString, "invalid property", QString() ) },
41 QgsPropertyDefinition(
42 "dataDefinedPaperSize",
44 QObject::tr( "Paper size" ),
45 QObject::tr( "string " )
46 + QLatin1String(
47 "[<b>A5</b>|<b>A4</b>|<b>A3</b>|<b>A2</b>|<b>A1</b>|<b>A0</b>"
48 "|<b>B5</b>|<b>B4</b>|<b>B3</b>|<b>B2</b>|<b>B1</b>|<b>B0</b>"
49 "|<b>Legal</b>|<b>Ansi A</b>|<b>Ansi B</b>|<b>Ansi C</b>|<b>Ansi D</b>|<b>Ansi E</b>"
50 "|<b>Arch A</b>|<b>Arch B</b>|<b>Arch C</b>|<b>Arch D</b>|<b>Arch E</b>|<b>Arch E1</b>]"
51 )
52 ) },
53 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::PaperWidth ), QgsPropertyDefinition( "dataDefinedPaperWidth", QObject::tr( "Page width" ), QgsPropertyDefinition::DoublePositive ) },
54 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::PaperHeight ), QgsPropertyDefinition( "dataDefinedPaperHeight", QObject::tr( "Page height" ), QgsPropertyDefinition::DoublePositive ) },
55 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::NumPages ), QgsPropertyDefinition( "dataDefinedNumPages", QObject::tr( "Number of pages" ), QgsPropertyDefinition::IntegerPositive ) },
57 QgsPropertyDefinition( "dataDefinedPaperOrientation", QgsPropertyDefinition::DataTypeString, QObject::tr( "Symbol size" ), QObject::tr( "string " ) + "[<b>portrait</b>|<b>landscape</b>]"_L1 ) },
58 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::PageNumber ), QgsPropertyDefinition( "dataDefinedPageNumber", QObject::tr( "Page number" ), QgsPropertyDefinition::IntegerPositive ) },
59 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::PositionX ), QgsPropertyDefinition( "dataDefinedPositionX", QObject::tr( "Position (X)" ), QgsPropertyDefinition::Double ) },
60 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::PositionY ), QgsPropertyDefinition( "dataDefinedPositionY", QObject::tr( "Position (Y)" ), QgsPropertyDefinition::Double ) },
61 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::ItemWidth ), QgsPropertyDefinition( "dataDefinedWidth", QObject::tr( "Width" ), QgsPropertyDefinition::DoublePositive ) },
62 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::ItemHeight ), QgsPropertyDefinition( "dataDefinedHeight", QObject::tr( "Height" ), QgsPropertyDefinition::DoublePositive ) },
63 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::ItemRotation ), QgsPropertyDefinition( "dataDefinedRotation", QObject::tr( "Rotation angle" ), QgsPropertyDefinition::Rotation ) },
64 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::Transparency ), QgsPropertyDefinition( "dataDefinedTransparency", QObject::tr( "Transparency" ), QgsPropertyDefinition::Opacity ) },
65 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::Opacity ), QgsPropertyDefinition( "dataDefinedOpacity", QObject::tr( "Opacity" ), QgsPropertyDefinition::Opacity ) },
66 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::BlendMode ), QgsPropertyDefinition( "dataDefinedBlendMode", QObject::tr( "Blend mode" ), QgsPropertyDefinition::BlendMode ) },
68 QgsPropertyDefinition( "dataDefinedExcludeExports", QObject::tr( "Exclude item from exports" ), QgsPropertyDefinition::Boolean ) },
69 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::FrameColor ), QgsPropertyDefinition( "dataDefinedFrameColor", QObject::tr( "Frame color" ), QgsPropertyDefinition::ColorWithAlpha ) },
71 QgsPropertyDefinition( "dataDefinedBackgroundColor", QObject::tr( "Background color" ), QgsPropertyDefinition::ColorWithAlpha ) },
72 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::MarginLeft ), QgsPropertyDefinition( "dataDefinedMarginLeft", QObject::tr( "Left margin" ), QgsPropertyDefinition::DoublePositive ) },
73 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::MarginTop ), QgsPropertyDefinition( "dataDefinedMarginTop", QObject::tr( "Top margin" ), QgsPropertyDefinition::DoublePositive ) },
74 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::MarginRight ), QgsPropertyDefinition( "dataDefinedMarginRight", QObject::tr( "Right margin" ), QgsPropertyDefinition::DoublePositive ) },
76 QgsPropertyDefinition( "dataDefinedMarginBottom", QObject::tr( "Bottom margin" ), QgsPropertyDefinition::DoublePositive ) },
77 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::MapRotation ), QgsPropertyDefinition( "dataDefinedMapRotation", QObject::tr( "Map rotation" ), QgsPropertyDefinition::Rotation ) },
78 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::MapScale ), QgsPropertyDefinition( "dataDefinedMapScale", QObject::tr( "Map scale" ), QgsPropertyDefinition::DoublePositive ) },
79 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::MapXMin ), QgsPropertyDefinition( "dataDefinedMapXMin", QObject::tr( "Extent minimum X" ), QgsPropertyDefinition::Double ) },
80 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::MapYMin ), QgsPropertyDefinition( "dataDefinedMapYMin", QObject::tr( "Extent minimum Y" ), QgsPropertyDefinition::Double ) },
81 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::MapXMax ), QgsPropertyDefinition( "dataDefinedMapXMax", QObject::tr( "Extent maximum X" ), QgsPropertyDefinition::Double ) },
82 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::MapYMax ), QgsPropertyDefinition( "dataDefinedMapYMax", QObject::tr( "Extent maximum Y" ), QgsPropertyDefinition::Double ) },
84 QgsPropertyDefinition( "dataDefinedMapLabelMargin", QObject::tr( "Label margin" ), QgsPropertyDefinition::DoublePositive ) },
86 QgsPropertyDefinition( "dataDefinedMapAtlasMargin", QObject::tr( "Atlas margin" ), QgsPropertyDefinition::DoublePositive ) },
88 QgsPropertyDefinition( "dataDefinedMapLayers", QgsPropertyDefinition::DataTypeString, QObject::tr( "Map Layers" ), tr( "list of map layer names separated by | characters" ) ) },
90 QgsPropertyDefinition( "dataDefinedMapStylePreset", QgsPropertyDefinition::DataTypeString, QObject::tr( "Map theme" ), tr( "name of an existing map theme (case-sensitive)" ) ) },
91 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::MapGridEnabled ), QgsPropertyDefinition( "dataDefinedMapGridEnabled", QObject::tr( "Grid enabled" ), QgsPropertyDefinition::Boolean ) },
93 QgsPropertyDefinition( "dataDefinedMapGridIntervalX", QObject::tr( "Grid interval X" ), QgsPropertyDefinition::DoublePositive ) },
95 QgsPropertyDefinition( "dataDefinedMapGridIntervalY", QObject::tr( "Grid interval Y" ), QgsPropertyDefinition::DoublePositive ) },
96 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::MapGridOffsetX ), QgsPropertyDefinition( "dataDefinedMapGridOffsetX", QObject::tr( "Grid offset X" ), QgsPropertyDefinition::Double ) },
97 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::MapGridOffsetY ), QgsPropertyDefinition( "dataDefinedMapGridOffsetY", QObject::tr( "Grid offset Y" ), QgsPropertyDefinition::Double ) },
99 QgsPropertyDefinition( "dataDefinedMapGridFrameSize", QObject::tr( "Grid frame size" ), QgsPropertyDefinition::DoublePositive ) },
101 QgsPropertyDefinition( "dataDefinedMapGridFrameLineThickness", QObject::tr( "Grid frame line thickness" ), QgsPropertyDefinition::DoublePositive ) },
103 QgsPropertyDefinition( "dataDefinedMapGridCrossSize", QObject::tr( "Grid cross size" ), QgsPropertyDefinition::DoublePositive ) },
105 QgsPropertyDefinition( "dataDefinedMapGridFrameMargin", QObject::tr( "Grid frame margin" ), QgsPropertyDefinition::DoublePositive ) },
107 QgsPropertyDefinition( "dataDefinedMapGridLabelDistance", QObject::tr( "Grid label distance" ), QgsPropertyDefinition::DoublePositive ) },
109 QgsPropertyDefinition( "dataDefinedMapGridAnnotationDisplayLeft", QgsPropertyDefinition::DataTypeString, QObject::tr( "Map grid annotation display left" ), QObject::tr( "string " ) + "[<b>all</b>|<b>x_only</b>|<b>y_only</b>|<b>disabled</b>]"_L1 ) },
111 QgsPropertyDefinition( "dataDefinedMapGridAnnotationDisplayRight", QgsPropertyDefinition::DataTypeString, QObject::tr( "Map grid annotation display right" ), QObject::tr( "string " ) + "[<b>all</b>|<b>x_only</b>|<b>y_only</b>|<b>disabled</b>]"_L1 ) },
113 QgsPropertyDefinition( "dataDefinedMapGridAnnotationDisplayTop", QgsPropertyDefinition::DataTypeString, QObject::tr( "Map grid annotation display top" ), QObject::tr( "string " ) + "[<b>all</b>|<b>x_only</b>|<b>y_only</b>|<b>disabled</b>]"_L1 ) },
115 QgsPropertyDefinition( "dataDefinedMapGridAnnotationDisplayBottom", QgsPropertyDefinition::DataTypeString, QObject::tr( "Map grid annotation display bottom" ), QObject::tr( "string " ) + "[<b>all</b>|<b>x_only</b>|<b>y_only</b>|<b>disabled</b>]"_L1 ) },
117 QgsPropertyDefinition( "dataDefinedMapGridFrameDivisionsLeft", QgsPropertyDefinition::DataTypeString, QObject::tr( "Map grid frame divisions display left" ), QObject::tr( "string " ) + "[<b>all</b>|<b>x_only</b>|<b>y_only</b>|<b>disabled</b>]"_L1 ) },
119 QgsPropertyDefinition( "dataDefinedMapGridFrameDivisionsRight", QgsPropertyDefinition::DataTypeString, QObject::tr( "Map grid frame divisions display right" ), QObject::tr( "string " ) + "[<b>all</b>|<b>x_only</b>|<b>y_only</b>|<b>disabled</b>]"_L1 ) },
121 QgsPropertyDefinition( "dataDefinedMapGridFrameDivisionsTop", QgsPropertyDefinition::DataTypeString, QObject::tr( "Map grid frame divisions display top" ), QObject::tr( "string " ) + "[<b>all</b>|<b>x_only</b>|<b>y_only</b>|<b>disabled</b>]"_L1 ) },
123 QgsPropertyDefinition( "dataDefinedMapGridFrameDivisionsBottom", QgsPropertyDefinition::DataTypeString, QObject::tr( "Map grid frame divisions display bottom" ), QObject::tr( "string " ) + "[<b>all</b>|<b>x_only</b>|<b>y_only</b>|<b>disabled</b>]"_L1 ) },
125 QgsPropertyDefinition( "dataDefinedMapGridDrawAnnotation", QObject::tr( "Draw map grid annotation" ), QgsPropertyDefinition::Boolean, QString(), QObject::tr( "Allows control over the visibility of individual grid annotations" ) ) },
126 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::MapCrs ),
127 QgsPropertyDefinition(
128 "dataDefinedCrs",
130 QObject::tr( "Map CRS" ),
131 QObject::tr( "string representing a CRS, either an authority/id pair (e.g. 'EPSG:4326'), a proj string prefixes by \"PROJ:\" (e.g. 'PROJ: +proj=...') or a WKT string prefixed by \"WKT:\" (e.g. 'WKT:GEOGCRS[\"WGS 84\"...]')" )
132 ) },
134 QgsPropertyDefinition( "dataDefinedStartDateTime", QObject::tr( "Temporal range start date / time" ), QgsPropertyDefinition::DateTime ) },
136 QgsPropertyDefinition( "dataDefinedEndDateTime", QObject::tr( "Temporal range end date / time" ), QgsPropertyDefinition::DateTime ) },
137 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::MapZRangeLower ), QgsPropertyDefinition( "dataDefinedZRangeLower", QObject::tr( "Z range lower limit" ), QgsPropertyDefinition::Double ) },
138 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::MapZRangeUpper ), QgsPropertyDefinition( "dataDefinedZRangeUpper", QObject::tr( "Z range upper limit" ), QgsPropertyDefinition::Double ) },
139 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::PictureSource ), QgsPropertyDefinition( "dataDefinedSource", QObject::tr( "Picture source (URL)" ), QgsPropertyDefinition::String ) },
140 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::SourceUrl ), QgsPropertyDefinition( "dataDefinedSourceUrl", QObject::tr( "Source URL" ), QgsPropertyDefinition::String ) },
142 QgsPropertyDefinition( "dataDefinedSvgBackgroundColor", QObject::tr( "SVG background color" ), QgsPropertyDefinition::ColorWithAlpha ) },
144 QgsPropertyDefinition( "dataDefinedSvgStrokeColor", QObject::tr( "SVG stroke color" ), QgsPropertyDefinition::ColorWithAlpha ) },
146 QgsPropertyDefinition( "dataDefinedSvgStrokeWidth", QObject::tr( "SVG stroke width" ), QgsPropertyDefinition::StrokeWidth ) },
147 { static_cast< int >( QgsLayoutObject::DataDefinedProperty::LegendTitle ), QgsPropertyDefinition( "dataDefinedLegendTitle", QObject::tr( "Legend title" ), QgsPropertyDefinition::String ) },
149 QgsPropertyDefinition( "dataDefinedLegendColumns", QObject::tr( "Number of columns" ), QgsPropertyDefinition::IntegerPositiveGreaterZero ) },
151 QgsPropertyDefinition( "dataDefinedLegendAutoWrapWidth", QObject::tr( "Text wrapping width in mm" ), QgsPropertyDefinition::DoublePositive ) },
153 QgsPropertyDefinition( "dataDefinedScalebarFill", QObject::tr( "Fill color" ), QgsPropertyDefinition::ColorWithAlpha ) },
155 QgsPropertyDefinition( "dataDefinedScalebarFill2", QObject::tr( "Secondary fill color" ), QgsPropertyDefinition::ColorWithAlpha ) },
157 QgsPropertyDefinition( "dataDefinedScalebarLineColor", QObject::tr( "Line color" ), QgsPropertyDefinition::ColorWithAlpha ) },
159 QgsPropertyDefinition( "dataDefinedScalebarLineWidth", QObject::tr( "Line width" ), QgsPropertyDefinition::StrokeWidth ) },
161 QgsPropertyDefinition( "dataDefinedAttributeTableSourceLayer", QObject::tr( "Table source layer" ), QgsPropertyDefinition::String ) },
163 QgsPropertyDefinition( "dataDefinedScaleBarLeftSegments", QObject::tr( "Segments to the left of 0" ), QgsPropertyDefinition::IntegerPositive ) },
165 QgsPropertyDefinition( "dataDefinedScaleBarRightSegments", QObject::tr( "Segments to the right of 0" ), QgsPropertyDefinition::IntegerPositive ) },
167 QgsPropertyDefinition( "dataDefinedScalebarSegmentWidth", QObject::tr( "Length of a segment in map units" ), QgsPropertyDefinition::DoublePositive ) },
169 QgsPropertyDefinition( "dataDefinedScalebarMinWidth", QObject::tr( "Minimum length of a segment in mm" ), QgsPropertyDefinition::DoublePositive ) },
171 QgsPropertyDefinition( "dataDefinedScalebarMaxWidth", QObject::tr( "Maximum length of a segment in mm" ), QgsPropertyDefinition::DoublePositive ) },
173 QgsPropertyDefinition( "dataDefinedScalebarHeight", QObject::tr( "Scalebar height in mm" ), QgsPropertyDefinition::DoublePositive ) },
175 QgsPropertyDefinition( "dataDefinedScalebarSubdivisionHeight", QObject::tr( "Subdivision height in mm" ), QgsPropertyDefinition::DoublePositive ) },
177 QgsPropertyDefinition( "dataDefinedScalebarRightSegmentSubdivisions", QObject::tr( "Number of subdivisions in segments to the right of 0" ), QgsPropertyDefinition::IntegerPositive ) },
179 QgsPropertyDefinition( "dataDefinedElevationProfileTolerance", QObject::tr( "Tolerance" ), QgsPropertyDefinition::DoublePositive ) },
181 QgsPropertyDefinition( "dataDefinedElevationProfileDistanceMajorInterval", QObject::tr( "Major grid line interval for elevation axis" ), QgsPropertyDefinition::DoublePositive ) },
183 QgsPropertyDefinition( "dataDefinedElevationProfileDistanceMinorInterval", QObject::tr( "Minor grid line interval for elevation axis" ), QgsPropertyDefinition::DoublePositive ) },
185 QgsPropertyDefinition( "dataDefinedElevationProfileDistanceLabelInterval", QObject::tr( "Label interval for elevation axis" ), QgsPropertyDefinition::DoublePositive ) },
187 QgsPropertyDefinition( "dataDefinedElevationProfileElevationMajorInterval", QObject::tr( "Major grid line interval for distance axis" ), QgsPropertyDefinition::DoublePositive ) },
189 QgsPropertyDefinition( "dataDefinedElevationProfileElevationMinorInterval", QObject::tr( "Minor grid line interval for distance axis" ), QgsPropertyDefinition::DoublePositive ) },
191 QgsPropertyDefinition( "dataDefinedElevationProfileElevationLabelInterval", QObject::tr( "Label interval for distance axis" ), QgsPropertyDefinition::DoublePositive ) },
193 QgsPropertyDefinition( "dataDefinedElevationProfileMinimumDistance", QObject::tr( "Minimum distance" ), QgsPropertyDefinition::DoublePositive ) },
195 QgsPropertyDefinition( "dataDefinedElevationProfileMaximumDistance", QObject::tr( "Maximum distance" ), QgsPropertyDefinition::DoublePositive ) },
197 QgsPropertyDefinition( "dataDefinedElevationProfileMinimumElevation", QObject::tr( "Minimum elevation" ), QgsPropertyDefinition::Double ) },
199 QgsPropertyDefinition( "dataDefinedElevationProfileMaximumElevation", QObject::tr( "Maximum elevation" ), QgsPropertyDefinition::Double ) },
200 };
201}
202
204{
205 QgsLayoutObject::initPropertyDefinitions();
206 return sPropertyDefinitions;
207}
208
210{
211 switch ( property )
212 {
215 return true;
216
305 return false;
306 }
307 return false;
308}
309
311 : QObject( nullptr )
312 , mLayout( layout )
313{
314 initPropertyDefinitions();
315
316 if ( mLayout )
317 {
319 connect( &mLayout->reportContext(), &QgsLayoutReportContext::changed, this, &QgsLayoutObject::refresh );
320 }
321}
322
324{
325 return mLayout.data();
326}
327
329{
330 return mLayout.data();
331}
332
333void QgsLayoutObject::setCustomProperty( const QString &key, const QVariant &value )
334{
335 mCustomProperties.setValue( key, value );
336}
337
338QVariant QgsLayoutObject::customProperty( const QString &key, const QVariant &defaultValue ) const
339{
340 return mCustomProperties.value( key, defaultValue );
341}
342
344{
345 mCustomProperties.remove( key );
346}
347
349{
350 return mCustomProperties.keys();
351}
352
354{
355 if ( mLayout )
356 {
357 return mLayout->createExpressionContext();
358 }
359 else
360 {
362 }
363}
364
365bool QgsLayoutObject::writeObjectPropertiesToElement( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext & ) const
366{
367 if ( parentElement.isNull() )
368 {
369 return false;
370 }
371
372 //create object element
373 QDomElement objectElement = document.createElement( u"LayoutObject"_s );
374
375 QDomElement ddPropsElement = document.createElement( u"dataDefinedProperties"_s );
376 mDataDefinedProperties.writeXml( ddPropsElement, sPropertyDefinitions );
377 objectElement.appendChild( ddPropsElement );
378
379 //custom properties
380 mCustomProperties.writeXml( objectElement, document );
381
382 parentElement.appendChild( objectElement );
383 return true;
384}
385
386bool QgsLayoutObject::readObjectPropertiesFromElement( const QDomElement &parentElement, const QDomDocument &document, const QgsReadWriteContext & )
387{
388 Q_UNUSED( document )
389 if ( parentElement.isNull() )
390 {
391 return false;
392 }
393
394 const QDomNodeList objectNodeList = parentElement.elementsByTagName( u"LayoutObject"_s );
395 if ( objectNodeList.size() < 1 )
396 {
397 return false;
398 }
399 const QDomElement objectElement = objectNodeList.at( 0 ).toElement();
400
401 const QDomNode propsNode = objectElement.namedItem( u"dataDefinedProperties"_s );
402 if ( !propsNode.isNull() )
403 {
404 mDataDefinedProperties.readXml( propsNode.toElement(), sPropertyDefinitions );
405 }
406
407 //custom properties
408 mCustomProperties.readXml( objectElement );
409
410 return true;
411}
static QgsExpressionContextScope * globalScope()
Creates a new scope which contains variables and functions relating to the global QGIS context.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
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.
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the layout object property definitions.
QgsObjectCustomProperties mCustomProperties
Custom properties for object.
QgsPropertyCollection mDataDefinedProperties
bool readObjectPropertiesFromElement(const QDomElement &parentElement, const QDomDocument &document, const QgsReadWriteContext &context)
Sets object properties from a DOM element.
const QgsLayout * layout() const
Returns the layout the object is attached to.
void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for the object.
virtual void refresh()
Refreshes the object, causing a recalculation of any property overrides.
QPointer< QgsLayout > mLayout
QgsExpressionContext createExpressionContext() const override
Creates an expression context relating to the objects' current state.
void removeCustomProperty(const QString &key)
Remove a custom property from the object.
DataDefinedProperty
Data defined properties for different item types.
@ MapZRangeUpper
Map frame Z-range lower value.
@ ScalebarMinimumWidth
Scalebar segment minimum width.
@ MapGridFrameDivisionsBottom
Map frame division display bottom.
@ MapGridFrameDivisionsTop
Map frame division display top.
@ ExcludeFromExports
Exclude item from exports.
@ PaperWidth
Paper width (deprecated).
@ StartDateTime
Temporal range's start DateTime.
@ MapZRangeLower
Map frame Z-range lower value.
@ MapGridAnnotationDisplayLeft
Map annotation display left.
@ TestProperty
Dummy property with no effect on item.
@ MapGridFrameMargin
Map grid frame margin.
@ MapStylePreset
Layer and style map theme.
@ PageNumber
Page number for item placement.
@ MapGridDrawAnnotation
Map annotation visibility (for individual annotations).
@ MapGridAnnotationDisplayRight
Map annotation display right.
@ NumPages
Number of pages in composition (deprecated).
@ ElevationProfileMaximumDistance
Maximum distance value for elevation profile.
@ PaperHeight
Paper height (deprecated).
@ ScalebarRightSegments
Number of segments on the right of 0.
@ ScalebarLineColor
Scalebar line color (deprecated, use data defined properties on scalebar line symbol instead).
@ MapGridAnnotationDisplayTop
Map annotation display top.
@ ElevationProfileElevationMinorInterval
Minor grid line interval for elevation profile elevation axis.
@ MapGridAnnotationDisplayBottom
Map annotation display bottom.
@ LegendAutoWrapWidth
Legend text automatic wrapping width.
@ MapGridFrameDivisionsRight
Map frame division display right.
@ ScalebarRightSegmentSubdivisions
Number of subdivisions per segment on right of 0.
@ ElevationProfileDistanceMinorInterval
Minor grid line interval for elevation profile distance axis.
@ Transparency
Item transparency (deprecated).
@ MapGridLabelDistance
Map grid label distance.
@ ElevationProfileMinimumDistance
Minimum distance value for elevation profile.
@ ElevationProfileMaximumElevation
Maximum elevation value for elevation profile.
@ ScalebarMaximumWidth
Scalebar segment maximum width.
@ ElevationProfileDistanceLabelInterval
Label interval for elevation profile distance axis.
@ ElevationProfileTolerance
Tolerance distance for elevation profiles.
@ EndDateTime
Temporal range's end DateTime.
@ ScalebarFillColor2
Scalebar secondary fill color (deprecated, use data defined properties on scalebar fill symbol 2 inst...
@ ScalebarSubdivisionHeight
Scalebar subdivision height.
@ ElevationProfileMinimumElevation
Minimum elevation value for elevation profile.
@ BackgroundColor
Item background color.
@ PresetPaperSize
Preset paper size for composition.
@ ScalebarFillColor
Scalebar fill color (deprecated, use data defined properties on scalebar fill symbol 1 instead).
@ ScalebarLineWidth
Scalebar line width (deprecated, use data defined properties on scalebar line symbol instead).
@ PictureSvgBackgroundColor
SVG background color.
@ AttributeTableSourceLayer
Attribute table source layer.
@ ScalebarLeftSegments
Number of segments on the left of 0.
@ ElevationProfileElevationLabelInterval
Label interval for elevation profile elevation axis.
@ MapGridFrameLineThickness
Map grid frame line thickness.
@ ElevationProfileDistanceMajorInterval
Major grid line interval for elevation profile distance axis.
@ ScalebarSegmentWidth
Scalebar width in map units of a single segment.
@ ElevationProfileElevationMajorInterval
Major grid line interval for elevation profile elevation axis.
@ MapGridFrameDivisionsLeft
Map frame division display left.
@ AllProperties
All properties for item.
QgsLayoutObject(QgsLayout *layout)
Constructor for QgsLayoutObject, with the specified parent layout.
bool writeObjectPropertiesToElement(QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context) const
Stores object properties within an XML DOM element.
static bool propertyAssociatesWithParentMultiframe(DataDefinedProperty property)
Returns true if the specified property key is normally associated with the parent QgsLayoutMultiFrame...
void changed()
Emitted certain settings in the context is changed, e.g.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition qgslayout.h:50
void refreshed()
Emitted when the layout has been refreshed and items should also be refreshed and updated.
@ Double
Double value (including negative values).
Definition qgsproperty.h:56
@ StrokeWidth
Line stroke width.
Definition qgsproperty.h:71
@ String
Any string value.
Definition qgsproperty.h:60
@ DateTime
DateTime value.
Definition qgsproperty.h:78
@ BlendMode
Blend mode.
Definition qgsproperty.h:66
@ Boolean
Boolean value.
Definition qgsproperty.h:52
@ IntegerPositiveGreaterZero
Non-zero positive integer values.
Definition qgsproperty.h:55
@ IntegerPositive
Positive integer values (including 0).
Definition qgsproperty.h:54
@ Opacity
Opacity (0-100).
Definition qgsproperty.h:61
@ Rotation
Rotation (value between 0-360 degrees).
Definition qgsproperty.h:59
@ ColorWithAlpha
Color with alpha channel.
Definition qgsproperty.h:63
@ DoublePositive
Positive double value (including 0).
Definition qgsproperty.h:57
@ DataTypeString
Property requires a string value.
Definition qgsproperty.h:91
A container for the context for various read/write operations on objects.
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.