QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgslayoutitem.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslayoutitem.h
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 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17#ifndef QGSLAYOUTITEM_H
18#define QGSLAYOUTITEM_H
19
20#include "qgis_core.h"
22#include "qgslayoutobject.h"
23#include "qgslayoutpoint.h"
24#include "qgslayoutsize.h"
26#include "qgsrendercontext.h"
27
28#include <QGraphicsRectItem>
29#include <QIcon>
30#include <QPainter>
31
32class QgsLayout;
33class QPainter;
35class QgsLayoutEffect;
37
44{
45 public:
46
58
61
68 QgsRenderContext &renderContext() { return mRenderContext; }
69
78 const QgsRenderContext &renderContext() const SIP_SKIP { return mRenderContext; }
79
90 double viewScaleFactor() const { return mViewScaleFactor; }
91
92 private:
93
94#ifdef SIP_RUN
96#endif
97
98 QgsRenderContext &mRenderContext;
99 double mViewScaleFactor = 1.0;
100};
101
107class CORE_EXPORT QgsLayoutItem : public QgsLayoutObject, public QGraphicsRectItem, public QgsLayoutUndoObjectInterface
108{
109 //SIP_TYPEHEADER_INCLUDE( "qgslayoutitemgroup.h" );
110 //SIP_TYPEHEADER_INCLUDE( "qgslayoutitemmap.h" );
111 //SIP_TYPEHEADER_INCLUDE( "qgslayoutitempicture.h" );
112 //SIP_TYPEHEADER_INCLUDE( "qgslayoutitemlabel.h" );
113 //SIP_TYPEHEADER_INCLUDE( "qgslayoutitemlegend.h" );
114 //SIP_TYPEHEADER_INCLUDE( "qgslayoutitempolygon.h" );
115 //SIP_TYPEHEADER_INCLUDE( "qgslayoutitempolyline.h" );
116 //SIP_TYPEHEADER_INCLUDE( "qgslayoutitemscalebar.h" );
117 //SIP_TYPEHEADER_INCLUDE( "qgslayoutframe.h" );
118 //SIP_TYPEHEADER_INCLUDE( "qgslayoutitemshape.h" );
119 //SIP_TYPEHEADER_INCLUDE( "qgslayoutitempage.h" );
120 //SIP_TYPEHEADER_INCLUDE( "qgslayoutitemmarker.h" );
121 //SIP_TYPEHEADER_INCLUDE( "qgslayoutitemelevationprofile.h" );
122 //SIP_TYPEHEADER_INCLUDE( "qgslayoutitemchart.h" );
123
124#ifdef SIP_RUN
126
127 // FREAKKKKIIN IMPORTANT!!!!!!!!!!!
128 // IF YOU PUT SOMETHING HERE, PUT IT IN QgsLayoutObject CASTING *****ALSO******
129 // (it's not enough for it to be in only one of the places, as sip inconsistently
130 // decides which casting code to perform here)
131
132 // the conversions have to be static, because they're using multiple inheritance
133 // (seen in PyQt4 .sip files for some QGraphicsItem classes)
134 switch ( sipCpp->type() )
135 {
136 // really, these *should* use the constants from QgsLayoutItemRegistry, but sip doesn't like that!
137 case QGraphicsItem::UserType + 101:
138 sipType = sipType_QgsLayoutItemGroup;
139 *sipCppRet = static_cast<QgsLayoutItemGroup *>( sipCpp );
140 break;
141 case QGraphicsItem::UserType + 102:
142 sipType = sipType_QgsLayoutItemPage;
143 *sipCppRet = static_cast<QgsLayoutItemPage *>( sipCpp );
144 break;
145 case QGraphicsItem::UserType + 103:
146 sipType = sipType_QgsLayoutItemMap;
147 *sipCppRet = static_cast<QgsLayoutItemMap *>( sipCpp );
148 break;
149 case QGraphicsItem::UserType + 104:
150 sipType = sipType_QgsLayoutItemPicture;
151 *sipCppRet = static_cast<QgsLayoutItemPicture *>( sipCpp );
152 break;
153 case QGraphicsItem::UserType + 105:
154 sipType = sipType_QgsLayoutItemLabel;
155 *sipCppRet = static_cast<QgsLayoutItemLabel *>( sipCpp );
156 break;
157 case QGraphicsItem::UserType + 106:
158 sipType = sipType_QgsLayoutItemLegend;
159 *sipCppRet = static_cast<QgsLayoutItemLegend *>( sipCpp );
160 break;
161 case QGraphicsItem::UserType + 107:
162 sipType = sipType_QgsLayoutItemShape;
163 *sipCppRet = static_cast<QgsLayoutItemShape *>( sipCpp );
164 break;
165 case QGraphicsItem::UserType + 108:
166 sipType = sipType_QgsLayoutItemPolygon;
167 *sipCppRet = static_cast<QgsLayoutItemPolygon *>( sipCpp );
168 break;
169 case QGraphicsItem::UserType + 109:
170 sipType = sipType_QgsLayoutItemPolyline;
171 *sipCppRet = static_cast<QgsLayoutItemPolyline *>( sipCpp );
172 break;
173 case QGraphicsItem::UserType + 110:
174 sipType = sipType_QgsLayoutItemScaleBar;
175 *sipCppRet = static_cast<QgsLayoutItemScaleBar *>( sipCpp );
176 break;
177 case QGraphicsItem::UserType + 111:
178 sipType = sipType_QgsLayoutFrame;
179 *sipCppRet = static_cast<QgsLayoutFrame *>( sipCpp );
180 break;
181 case QGraphicsItem::UserType + 117:
182 sipType = sipType_QgsLayoutItemMarker;
183 *sipCppRet = static_cast<QgsLayoutItemMarker *>( sipCpp );
184 break;
185 case QGraphicsItem::UserType + 118:
186 sipType = sipType_QgsLayoutItemElevationProfile;
187 *sipCppRet = static_cast<QgsLayoutItemElevationProfile *>( sipCpp );
188 break;
189 case QGraphicsItem::UserType + 119:
190 sipType = sipType_QgsLayoutItemChart;
191 *sipCppRet = static_cast<QgsLayoutItemChart *>( sipCpp );
192 break;
193
194 // did you read that comment above? NO? Go read it now. You're about to break stuff.
195
196 default:
197 sipType = NULL;
198 }
199 SIP_END
200#endif
201
202
203 Q_OBJECT
204 Q_PROPERTY( bool locked READ isLocked WRITE setLocked NOTIFY lockChanged )
205
206 public:
207
221
224 {
225 UndoNone = -1,
327
329 };
330
341 Q_DECLARE_FLAGS( Flags, Flag )
342
343
349 explicit QgsLayoutItem( QgsLayout *layout, bool manageZValue = true );
350
351 ~QgsLayoutItem() override;
352
357 virtual void cleanup();
358
364 int type() const override;
365
369 virtual QIcon icon() const;
370
378 virtual QString uuid() const { return mUuid; }
379
384 virtual Flags itemFlags() const;
385
392 QString id() const { return mId; }
393
400 virtual void setId( const QString &id );
401
408 virtual QString displayName() const;
409
413 virtual void setSelected( bool selected );
414
421 virtual void setVisibility( bool visible );
422
428 void setLocked( bool locked );
429
435 bool isLocked() const { return mIsLocked; }
436
442 bool isGroupMember() const;
443
449 QgsLayoutItemGroup *parentGroup() const;
450
456 void setParentGroup( QgsLayoutItemGroup *group );
457
469
478 virtual ExportLayerBehavior exportLayerBehavior() const;
479
493 Q_DECL_DEPRECATED virtual int numberExportLayers() const SIP_DEPRECATED;
494
502 virtual void startLayeredExport();
503
511 virtual void stopLayeredExport();
512
520 virtual bool nextExportPart();
521
527 struct CORE_EXPORT ExportLayerDetail
528 {
530 QString name;
531
533 QString mapLayerId;
534
539 QPainter::CompositionMode compositionMode = QPainter::CompositionMode_SourceOver;
540
545 double opacity = 1.0;
546
548 QString mapTheme;
549
555 QString groupName;
556 };
557
566
572 void paint( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget ) override;
573
580 void setReferencePoint( ReferencePoint point );
581
588 ReferencePoint referencePoint() const { return mReferencePoint; }
589
596 virtual QgsLayoutSize fixedSize() const { return mFixedSize; }
597
604 virtual QgsLayoutSize minimumSize() const { return mMinimumSize; }
605
620 virtual void attemptResize( const QgsLayoutSize &size, bool includesFrame = false );
621
647 virtual void attemptMove( const QgsLayoutPoint &point, bool useReferencePoint = true, bool includesFrame = false, int page = -1 );
648
664 void attemptSetSceneRect( const QRectF &rect, bool includesFrame = false );
665
678 void attemptMoveBy( double deltaX, double deltaY );
679
688 QgsLayoutPoint positionWithUnits() const { return mItemPosition; }
689
694 int page() const;
695
701 QPointF pagePos() const;
702
708 QgsLayoutPoint pagePositionWithUnits() const;
709
715 QgsLayoutSize sizeWithUnits() const { return mItemSize; }
716
727 double itemRotation() const;
728
736 bool writeXml( QDomElement &parentElement, QDomDocument &document, const QgsReadWriteContext &context ) const;
737
753 bool readXml( const QDomElement &itemElement, const QDomDocument &document, const QgsReadWriteContext &context );
754
763 virtual void finalizeRestoreFromXml();
764
765 QgsAbstractLayoutUndoCommand *createCommand( const QString &text, int id, QUndoCommand *parent = nullptr ) override SIP_FACTORY;
766
774 bool frameEnabled() const { return mFrame; }
775
783 virtual void setFrameEnabled( bool drawFrame );
784
792 void setFrameStrokeColor( const QColor &color );
793
801 QColor frameStrokeColor() const { return mFrameColor; }
802
810 virtual void setFrameStrokeWidth( QgsLayoutMeasurement width );
811
819 QgsLayoutMeasurement frameStrokeWidth() const { return mFrameWidth; }
820
828 Qt::PenJoinStyle frameJoinStyle() const { return mFrameJoinStyle; }
829
837 void setFrameJoinStyle( Qt::PenJoinStyle style );
838
844 bool hasBackground() const { return mBackground; }
845
851 void setBackgroundEnabled( bool drawBackground );
852
860 QColor backgroundColor( bool useDataDefined = true ) const;
861
867 void setBackgroundColor( const QColor &color );
868
873 QPainter::CompositionMode blendMode() const { return mBlendMode; }
874
879 void setBlendMode( QPainter::CompositionMode mode );
880
888 double itemOpacity() const { return mOpacity; }
889
897 void setItemOpacity( double opacity );
898
903 bool excludeFromExports() const;
904
909 void setExcludeFromExports( bool exclude );
910
920 virtual bool containsAdvancedEffects() const;
921
927 virtual bool requiresRasterization() const;
928
939 virtual double estimatedFrameBleed() const;
940
950 virtual QRectF rectWithFrame() const;
951
958 virtual void moveContent( double dx, double dy );
959
966 virtual void setMoveContentPreviewOffset( double dx, double dy );
967
974 virtual void zoomContent( double factor, QPointF point );
975
984 void beginCommand( const QString &commandText, UndoCommand command = UndoNone );
985
991 void endCommand();
992
998 void cancelCommand();
999
1003 bool shouldDrawItem() const;
1004
1005 QgsExpressionContext createExpressionContext() const override;
1006
1016 virtual bool accept( QgsStyleEntityVisitorInterface *visitor ) const;
1017
1026 virtual QgsGeometry clipPath() const;
1027
1033 virtual bool isRefreshing() const;
1034
1035 public slots:
1036
1041 void refresh() override;
1042
1046 virtual void invalidateCache();
1047
1051 virtual void redraw();
1052
1059 virtual void refreshDataDefinedProperty( QgsLayoutObject::DataDefinedProperty property = QgsLayoutObject::DataDefinedProperty::AllProperties );
1060
1070 virtual void setItemRotation( double rotation, bool adjustPosition = true );
1071
1077 virtual void rotateItem( double angle, QPointF transformOrigin );
1078
1079 signals:
1080
1085
1092
1096 void rotationChanged( double newRotation );
1097
1102
1109
1118
1119 protected:
1120
1126 virtual void drawDebugRect( QPainter *painter );
1127
1134 virtual void draw( QgsLayoutItemRenderContext &context ) = 0;
1135
1143 virtual QPainterPath framePath() const;
1144
1150 virtual void drawFrame( QgsRenderContext &context );
1151
1157 virtual void drawBackground( QgsRenderContext &context );
1158
1164 void drawRefreshingOverlay( QPainter *painter, const QStyleOptionGraphicsItem *itemStyle );
1165
1172 virtual void setFixedSize( const QgsLayoutSize &size );
1173
1180 virtual void setMinimumSize( const QgsLayoutSize &size );
1181
1190 virtual QSizeF applyItemSizeConstraint( QSizeF targetSize );
1191
1199 void refreshItemSize();
1200
1206 void refreshItemPosition();
1207
1218 void refreshItemRotation( QPointF *origin = nullptr );
1219
1225 void refreshOpacity( bool updateItem = true );
1226
1232 void refreshFrame( bool updateItem = true );
1233
1239 void refreshBackgroundColor( bool updateItem = true );
1240
1244 void refreshBlendMode();
1245
1250 QPointF adjustPointForReferencePosition( QPointF point, QSizeF size, ReferencePoint reference ) const;
1251
1255 QPointF positionAtReferencePoint( ReferencePoint reference ) const;
1256
1262
1271 virtual bool writePropertiesToElement( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const;
1272
1288 virtual bool readPropertiesFromElement( const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context );
1289
1294
1295 private:
1296
1297 // true if layout manages the z value for this item
1298 bool mLayoutManagesZValue = false;
1299
1301 QString mId;
1302
1304 QString mUuid;
1305
1307 QString mTemplateUuid;
1308
1310 QString mParentGroupUuid;
1311
1312 ReferencePoint mReferencePoint = UpperLeft;
1313 QgsLayoutSize mFixedSize;
1314 QgsLayoutSize mMinimumSize;
1315
1316 QgsLayoutSize mItemSize;
1317 QgsLayoutPoint mItemPosition;
1318 double mItemRotation = 0.0;
1319
1321 bool mExcludeFromExports = false;
1322
1327 bool mEvaluatedExcludeFromExports = false;
1328
1330 QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
1332 QPainter::CompositionMode mEvaluatedBlendMode = QPainter::CompositionMode_SourceOver;
1333
1334 QPainter::CompositionMode blendModeForRender() const;
1335
1337 double mOpacity = 1.0;
1338 double mEvaluatedOpacity = 1.0;
1339
1340 QImage mItemCachedImage;
1341 double mItemCacheDpi = -1;
1342
1343 bool mIsLocked = false;
1344
1346 bool mFrame = false;
1348 QColor mFrameColor = QColor( 0, 0, 0 );
1352 Qt::PenJoinStyle mFrameJoinStyle = Qt::MiterJoin;
1353
1355 bool mBackground = true;
1357 QColor mBackgroundColor = QColor( 255, 255, 255 );
1358
1359 bool mBlockUndoCommands = false;
1360
1361 void initConnectionsToLayout();
1362
1364 void preparePainter( QPainter *painter );
1365 bool shouldDrawAntialiased() const;
1366 bool shouldDrawDebugRect() const;
1367 QSizeF applyMinimumSize( QSizeF targetSize );
1368 QSizeF applyFixedSize( QSizeF targetSize );
1369 QgsLayoutPoint applyDataDefinedPosition( const QgsLayoutPoint &position );
1370
1371 double applyDataDefinedRotation( double rotation );
1372 void updateStoredItemPosition();
1373 QPointF itemPositionAtReferencePoint( ReferencePoint reference, QSizeF size ) const;
1374 void setScenePos( QPointF destinationPos );
1375 bool shouldBlockUndoCommands() const;
1376
1377 void applyDataDefinedOrientation( double &width, double &height, const QgsExpressionContext &context );
1378
1379 friend class TestQgsLayoutItem;
1380 friend class TestQgsLayoutView;
1381 friend class QgsLayout;
1383 friend class QgsLayoutItemMap;
1387};
1388
1390
1391#endif //QGSLAYOUTITEM_H
@ Millimeters
Millimeters.
Definition qgis.h:5204
Base class for commands to undo/redo layout and layout object changes.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
A geometry is the spatial representation of a feature.
A QGraphicsEffect subclass used for rendering layout items onto a scene with custom composition modes...
Base class for frame items, which form a layout multiframe item.
A layout item subclass that renders chart plots.
A container for grouping several QgsLayoutItems.
A layout item subclass for text labels.
A layout item for showing marker symbols.
Item representing the paper in a layout.
A layout item subclass that displays SVG files or raster format images (jpg, png, ....
Layout item for node based polygon shapes.
Layout item for node based polyline shapes.
Contains settings and helpers relating to a render of a QgsLayoutItem.
QgsLayoutItemRenderContext & operator=(const QgsLayoutItemRenderContext &other)=delete
QgsLayoutItemRenderContext(QgsRenderContext &context, double viewScaleFactor=1.0)
Constructor for QgsLayoutItemRenderContext.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
double viewScaleFactor() const
Returns the current view zoom (scale factor).
QgsLayoutItemRenderContext(const QgsLayoutItemRenderContext &other)=delete
const QgsRenderContext & renderContext() const
Returns a reference to the context's render context.
A layout item subclass for scale bars.
Layout item for basic filled shapes (e.g.
virtual void drawDebugRect(QPainter *painter)
Draws a debugging rectangle of the item's current bounds within the specified painter.
virtual void drawFrame(QgsRenderContext &context)
Draws the frame around the item.
friend class QgsLayoutItemGroup
friend class QgsLayout
virtual QPainterPath framePath() const
Returns the path to use when drawing the item's frame or background.
virtual void cleanup()
Called just before a batch of items are deleted, allowing them to run cleanup tasks.
void drawRefreshingOverlay(QPainter *painter, const QStyleOptionGraphicsItem *itemStyle)
Draws a "refreshing" overlay icon on the item.
void refreshItemRotation(QPointF *origin=nullptr)
Refreshes an item's rotation by rechecking it against any possible overrides such as data defined rot...
QgsLayoutSize sizeWithUnits() const
Returns the item's current size, including units.
UndoCommand
Layout item undo commands, used for collapsing undo commands.
@ UndoScaleBarSubdivisionsHeight
Scalebar subdivisions height.
@ UndoPictureStrokeWidth
Picture stroke width.
@ UndoLegendMinSymbolSize
Legend minimum symbol size.
@ UndoArrowHeadStrokeColor
Arrow head stroke color.
@ UndoLegendTitleSpaceBottom
Legend title space.
@ UndoScaleBarLabelBarSize
Scalebar label bar size.
@ UndoLegendIconSymbolSpace
Legend icon symbol space.
@ UndoLegendLayerFont
Legend layer font.
@ UndoShapeCornerRadius
Shape corner radius.
@ UndoLegendLineSpacing
Legend line spacing.
@ UndoNone
No command suppression.
@ UndoLegendBoxSpace
Legend box space.
@ UndoScaleBarFillColor
Scalebar fill color.
@ UndoArrowHeadFillColor
Arrow head fill color.
@ UndoLegendRasterStrokeColor
Legend raster stroke color.
@ UndoLabelFontColor
Label color.
@ UndoIncrementalMove
Layout item incremental movement, e.g. as a result of a keypress.
@ UndoScaleBarMapUnitsSegment
Scalebar map units per segment.
@ UndoElevationProfileElevationMajorGridlines
Change elevation profile elevation axis major gridlines.
@ UndoLegendTitleFont
Legend title font.
@ UndoBackgroundColor
Background color adjustment.
@ UndoLegendFontColor
Legend font color.
@ UndoElevationProfileMaximumDistance
Change elevation profile maximum distance.
@ UndoScaleBarBoxContentSpace
Scalebar box context space.
@ UndoOverviewStyle
Map overview style.
@ UndoElevationProfileChartBackground
Change elevation profile chart background.
@ UndoGridFramePenColor
Map grid frame pen color.
@ UndoMapRotation
Map rotation changed.
@ UndoOpacity
Opacity adjustment.
@ UndoIncrementalResize
Incremental resize.
@ UndoArrowHeadWidth
Arrow head width.
@ UndoElevationProfileDistanceMinorGridlines
Change elevation profile distance axis minor gridlines.
@ UndoScaleBarSegmentSize
Scalebar segment size.
@ UndoMarginTop
Top margin.
@ UndoLegendItemFont
Legend item font.
@ UndoLegendWmsLegendWidth
Legend WMS width.
@ UndoMapGridIntervalRange
Grid interval range.
@ UndoLegendLayerSpace
Legend layer spacing.
@ UndoLabelMargin
Label margin.
@ UndoRotation
Rotation adjustment.
@ UndoLegendColumnSpace
Legend column space.
@ UndoPictureRotation
Picture rotation.
@ UndoStrokeWidth
Stroke width adjustment.
@ UndoScaleBarFillColor2
Scalebar secondary fill color.
@ UndoScaleBarHeight
Scalebar height.
@ UndoLegendMaxSymbolSize
Legend maximum symbol size.
@ UndoArrowStrokeWidth
Arrow stroke width.
@ UndoElevationProfileChartBorder
Change elevation profile chart border.
@ UndoMapGridLineSymbol
Grid line symbol.
@ UndoExportLayerName
Export layer name.
@ UndoZoomContent
Item content zoomed.
@ UndoScaleBarFontColor
Scalebar font color.
@ UndoElevationProfileMaximumElevation
Change elevation profile maximum elevation.
@ UndoMarginLeft
Left margin.
@ UndoLegendAutoWrapAfter
Legend auto wrap lines after distance.
@ UndoMarginRight
Right margin.
@ UndoMapGridMarkerSymbol
Grid marker symbol.
@ UndoAtlasMargin
Map atlas margin changed.
@ UndoPictureFillColor
Picture fill color.
@ UndoLegendSymbolSpace
Legend symbol spacing.
@ UndoMapGridFrameFill1Color
Map grid frame fill color 1.
@ UndoElevationProfileTolerance
Change elevation profile distance tolerance.
@ UndoElevationProfileElevationFormat
Change elevation profile elevation axis number format.
@ UndoLegendSymbolWidth
Legend symbol width.
@ UndoLegendColumnCount
Legend column count.
@ UndoScaleBarSegments
Scalebar number of segments.
@ UndoLegendSymbolHeight
Legend symbol height.
@ UndoElevationProfileMinimumElevation
Change elevation profile minimum elevation.
@ UndoElevationProfileDistanceLabels
Change elevation profile distance axis label interval.
@ UndoLegendGroupSpace
Legend group spacing.
@ UndoScaleBarSubdivisions
Scalebar number of subdivisions.
@ UndoMarginBottom
Bottom margin.
@ UndoSetId
Change item ID.
@ UndoLegendSubgroupIndent
Legend subgroup indent.
@ UndoScaleBarLineWidth
Scalebar line width.
@ UndoElevationProfileElevationFont
Change elevation profile elevation axis number font.
@ UndoLegendRasterStrokeWidth
Legend raster stroke width.
@ UndoLegendGroupIndent
Legend group indent.
@ UndoElevationProfileDistanceFormat
Change elevation profile distance axis number format.
@ UndoMapGridAnnotationFontColor
Map frame annotation color.
@ UndoPictureNorthOffset
Picture north offset.
@ UndoElevationProfileElevationMinorGridlines
Change elevation profile elevation axis minor gridlines.
@ UndoCustomCommand
Base id for plugin based item undo commands.
@ UndoLabelFont
Label font.
@ UndoPictureStrokeColor
Picture stroke color.
@ UndoElevationProfileDistanceFont
Change elevation profile distance axis number font.
@ UndoMapAnnotationDistance
Map frame annotation distance.
@ UndoScaleBarStrokeColor
Scalebar stroke color.
@ UndoShapeStyle
Shape symbol style.
@ UndoStrokeColor
Stroke color adjustment.
@ UndoElevationProfileElevationLabels
Change elevation profile elevation axis label interval.
@ UndoScaleBarSegmentsLeft
Scalebar segments left.
@ UndoElevationProfileDistanceMajorGridlines
Change elevation profile distance axis major gridlines.
@ UndoLegendText
Legend text.
@ UndoNodeMove
Node move.
@ UndoMapGridFrameFill2Color
Map grid frame fill color 2.
@ UndoScaleBarUnitText
Scalebar unit text.
@ UndoMapLabelMargin
Margin for labels from edge of map.
@ UndoLegendWmsLegendHeight
Legend WMS height.
@ UndoElevationProfileMinimumDistance
Change elevation profile minimum distance.
@ UndoLabelText
Label text.
@ UndoLegendGroupFont
Legend group font.
@ UndoElevationProfileSubsectionLines
Change elevation profile subsection indicator symbol.
QgsLayoutItem(QgsLayout *layout, bool manageZValue=true)
Constructor for QgsLayoutItem, with the specified parent layout.
QPointF adjustPointForReferencePosition(QPointF point, QSizeF size, ReferencePoint reference) const
Adjusts the specified point at which a reference position of the item sits and returns the top left c...
void rotationChanged(double newRotation)
Emitted on item rotation change.
virtual QgsLayoutItem::ExportLayerDetail exportLayerDetails() const
Returns the details for the specified current export layer.
virtual QIcon icon() const
Returns the item's icon.
void paint(QPainter *painter, const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget) override
Handles preparing a paint surface for the layout item and painting the item's content.
QgsLayoutMeasurement frameStrokeWidth() const
Returns the frame's stroke width.
bool isLocked() const
Returns true if the item is locked, and cannot be interacted with using the mouse.
double itemOpacity() const
Returns the item's opacity.
friend class TestQgsLayoutView
ReferencePoint referencePoint() const
Returns the reference point for positioning of the layout item.
QgsLayoutPoint positionWithUnits() const
Returns the item's current position, including units.
QgsLayoutPoint topLeftToReferencePoint(const QgsLayoutPoint &point) const
Returns the position for the reference point of the item, if the top-left of the item was placed at t...
ReferencePoint
Fixed position reference point.
@ LowerMiddle
Lower center of item.
@ MiddleLeft
Middle left of item.
@ Middle
Center of item.
@ UpperRight
Upper right corner of item.
@ LowerLeft
Lower left corner of item.
@ UpperLeft
Upper left corner of item.
@ UpperMiddle
Upper center of item.
@ MiddleRight
Middle right of item.
@ LowerRight
Lower right corner of item.
friend class QgsLayoutItemMap
virtual bool writePropertiesToElement(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
Stores item state within an XML DOM element.
void refreshItemSize()
Refreshes an item's size by rechecking it against any possible item fixed or minimum sizes.
void refreshBackgroundColor(bool updateItem=true)
Refresh item's background color, considering data defined colors.
void setLocked(bool locked)
Sets whether the item is locked, preventing mouse interactions with the item.
int type() const override
Returns a unique graphics item type identifier.
virtual void drawBackground(QgsRenderContext &context)
Draws the background for the item.
virtual QgsLayoutSize minimumSize() const
Returns the minimum allowed size of the item, if applicable, or an empty size if item can be freely r...
Flag
Flags for controlling how an item behaves.
@ FlagOverridesPaint
Item overrides the default layout item painting method.
@ FlagDisableSceneCaching
Item should not have QGraphicsItem caching enabled.
@ FlagProvidesClipPath
Item can act as a clipping path provider (see clipPath()).
virtual QgsLayoutSize fixedSize() const
Returns the fixed size of the item, if applicable, or an empty size if item can be freely resized.
void sizePositionChanged()
Emitted when the item's size or position changes.
void lockChanged()
Emitted if the item's lock status changes.
virtual QSizeF applyItemSizeConstraint(QSizeF targetSize)
Applies any item-specific size constraint handling to a given targetSize in layout units.
void refreshFrame(bool updateItem=true)
Refresh item's frame, considering data defined colors and frame size.
virtual QString uuid() const
Returns the item identification string.
QString id() const
Returns the item's ID name.
bool frameEnabled() const
Returns true if the item includes a frame.
friend class QgsCompositionConverter
void frameChanged()
Emitted if the item's frame style changes.
void setReferencePoint(ReferencePoint point)
Sets the reference point for positioning of the layout item.
virtual bool readPropertiesFromElement(const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context)
Sets item state from a DOM element.
ExportLayerBehavior
Behavior of item when exporting to layered outputs.
@ ItemContainsSubLayers
Item contains multiple sublayers which must be individually exported.
@ MustPlaceInOwnLayer
Item must be placed in its own individual layer.
@ CanGroupWithItemsOfSameType
Item can only be placed on layers with other items of the same type, but multiple items of this type ...
@ CanGroupWithAnyOtherItem
Item can be placed on a layer with any other item (default behavior).
void refreshBlendMode()
Refresh item's blend mode, considering data defined blend mode.
void clipPathChanged()
Emitted when the item's clipping path has changed.
QPointF positionAtReferencePoint(ReferencePoint reference) const
Returns the current position (in layout units) of a reference point for the item.
void refreshOpacity(bool updateItem=true)
Refresh item's opacity, considering data defined opacity.
bool hasBackground() const
Returns true if the item has a background.
friend class QgsLayoutItemLegend
QgsLayoutSize applyDataDefinedSize(const QgsLayoutSize &size)
Applies any present data defined size overrides to the specified layout size.
virtual void setMinimumSize(const QgsLayoutSize &size)
Sets the minimum allowed size for the layout item.
QFlags< Flag > Flags
friend class QgsLayoutItemElevationProfile
QColor frameStrokeColor() const
Returns the frame's stroke color.
void refreshItemPosition()
Refreshes an item's position by rechecking it against any possible overrides such as data defined pos...
virtual void setFixedSize(const QgsLayoutSize &size)
Sets a fixed size for the layout item, which prevents it from being freely resized.
QPainter::CompositionMode blendMode() const
Returns the item's composition blending mode.
virtual void draw(QgsLayoutItemRenderContext &context)=0
Draws the item's contents using the specified item render context.
friend class TestQgsLayoutItem
void backgroundTaskCountChanged(int count)
Emitted whenever the number of background tasks an item is executing changes.
Qt::PenJoinStyle frameJoinStyle() const
Returns the join style used for drawing the item's frame.
Provides a method of storing measurements for use in QGIS layouts using a variety of different measur...
const QgsLayout * layout() const
Returns the layout the object is attached to.
DataDefinedProperty
Data defined properties for different item types.
@ AllProperties
All properties for item.
QgsLayoutObject(QgsLayout *layout)
Constructor for QgsLayoutObject, with the specified parent layout.
Provides a method of storing points, consisting of an x and y coordinate, for use in QGIS layouts.
Provides a method of storing sizes, consisting of a width and height, for use in QGIS layouts.
Interface for layout objects which support undo/redo commands.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Definition qgslayout.h:50
A container for the context for various read/write operations on objects.
Contains information about the context of a rendering operation.
An interface for classes which can visit style entity (e.g.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition qgis_sip.h:199
#define SIP_DEPRECATED
Definition qgis_sip.h:114
#define SIP_FORCE
Definition qgis_sip.h:139
#define SIP_ENUM_BASETYPE(type)
Definition qgis_sip.h:275
#define SIP_SKIP
Definition qgis_sip.h:134
#define SIP_FACTORY
Definition qgis_sip.h:84
#define SIP_END
Definition qgis_sip.h:216
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsProjectionSelectionWidget::CrsOptions)
Contains details of a particular export layer relating to a layout item.
QPainter::CompositionMode compositionMode
Associated composition mode if this layer is associated with a map layer.
QString mapLayerId
Associated map layer ID, or an empty string if this export layer is not associated with a map layer.
double opacity
Associated opacity, if this layer is associated with a map layer.
QString name
User-friendly name for the export layer.
QString groupName
Associated group name, if this layer is associated with an export group.
QString mapTheme
Associated map theme, or an empty string if this export layer does not need to be associated with a m...