QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
17 #ifndef QGSLAYOUTITEM_H
18 #define QGSLAYOUTITEM_H
20 #include "qgis_core.h"
28 #include <QGraphicsRectItem>
103 double mViewScaleFactor = 1.0;
138 switch ( sipCpp->type() )
141 case QGraphicsItem::UserType + 101:
142 sipType = sipType_QgsLayoutItemGroup;
145 case QGraphicsItem::UserType + 102:
146 sipType = sipType_QgsLayoutItemPage;
149 case QGraphicsItem::UserType + 103:
150 sipType = sipType_QgsLayoutItemMap;
153 case QGraphicsItem::UserType + 104:
154 sipType = sipType_QgsLayoutItemPicture;
157 case QGraphicsItem::UserType + 105:
158 sipType = sipType_QgsLayoutItemLabel;
161 case QGraphicsItem::UserType + 106:
162 sipType = sipType_QgsLayoutItemLegend;
165 case QGraphicsItem::UserType + 107:
166 sipType = sipType_QgsLayoutItemShape;
169 case QGraphicsItem::UserType + 108:
170 sipType = sipType_QgsLayoutItemPolygon;
173 case QGraphicsItem::UserType + 109:
174 sipType = sipType_QgsLayoutItemPolyline;
177 case QGraphicsItem::UserType + 110:
178 sipType = sipType_QgsLayoutItemScaleBar;
181 case QGraphicsItem::UserType + 111:
182 sipType = sipType_QgsLayoutFrame;
196 Q_PROPERTY(
bool locked READ isLocked WRITE setLocked NOTIFY lockChanged )
218 UndoIncrementalMove = 1,
301 FlagOverridesPaint = 1 << 1,
303 Q_DECLARE_FLAGS( Flags, Flag )
319 virtual void cleanup();
326 int type()
const override;
340 virtual QString
uuid()
const {
return mUuid; }
346 virtual Flags itemFlags()
const;
354 QString
id()
const {
return mId; }
362 virtual void setId(
const QString &
id );
370 virtual QString displayName()
const;
375 virtual void setSelected(
bool selected );
383 virtual void setVisibility(
bool visible );
390 void setLocked(
bool locked );
404 bool isGroupMember()
const;
438 virtual ExportLayerBehavior exportLayerBehavior()
const;
453 Q_DECL_DEPRECATED
virtual int numberExportLayers() const
SIP_DEPRECATED;
462 virtual
void startLayeredExport();
471 virtual
void stopLayeredExport();
480 virtual
bool nextExportPart();
499 QPainter::CompositionMode compositionMode = QPainter::CompositionMode_SourceOver;
505 double opacity = 1.0;
525 void paint( QPainter *painter,
const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget )
override;
573 virtual void attemptResize(
const QgsLayoutSize &size,
bool includesFrame =
false );
600 virtual void attemptMove(
const QgsLayoutPoint &point,
bool useReferencePoint =
true,
bool includesFrame =
false,
int page = -1 );
617 void attemptSetSceneRect(
const QRectF &rect,
bool includesFrame =
false );
631 void attemptMoveBy(
double deltaX,
double deltaY );
654 QPointF pagePos()
const;
680 double itemRotation()
const;
689 bool writeXml( QDomElement &parentElement, QDomDocument &document,
const QgsReadWriteContext &context )
const;
706 bool readXml(
const QDomElement &itemElement,
const QDomDocument &document,
const QgsReadWriteContext &context );
716 virtual void finalizeRestoreFromXml();
727 bool frameEnabled()
const {
return mFrame; }
736 virtual void setFrameEnabled(
bool drawFrame );
745 void setFrameStrokeColor(
const QColor &color );
790 void setFrameJoinStyle( Qt::PenJoinStyle style );
804 void setBackgroundEnabled(
bool drawBackground );
819 void setBackgroundColor(
const QColor &color );
825 QPainter::CompositionMode
blendMode()
const {
return mBlendMode; }
831 void setBlendMode( QPainter::CompositionMode mode );
849 void setItemOpacity(
double opacity );
855 bool excludeFromExports()
const;
861 void setExcludeFromExports(
bool exclude );
872 virtual bool containsAdvancedEffects()
const;
879 virtual bool requiresRasterization()
const;
891 virtual double estimatedFrameBleed()
const;
902 virtual QRectF rectWithFrame()
const;
910 virtual void moveContent(
double dx,
double dy );
918 virtual void setMoveContentPreviewOffset(
double dx,
double dy );
926 virtual void zoomContent(
double factor, QPointF point );
936 void beginCommand(
const QString &commandText, UndoCommand command = UndoNone );
950 void cancelCommand();
955 bool shouldDrawItem()
const;
981 virtual void invalidateCache();
986 virtual void redraw();
1005 virtual void setItemRotation(
double rotation,
bool adjustPosition =
true );
1012 virtual void rotateItem(
double angle, QPointF transformOrigin );
1019 void frameChanged();
1031 void rotationChanged(
double newRotation );
1036 void sizePositionChanged();
1043 void backgroundTaskCountChanged(
int count );
1052 virtual void drawDebugRect( QPainter *painter );
1096 virtual QSizeF applyItemSizeConstraint( QSizeF targetSize );
1105 void refreshItemSize();
1112 void refreshItemPosition();
1124 void refreshItemRotation( QPointF *origin =
nullptr );
1131 void refreshOpacity(
bool updateItem =
true );
1138 void refreshFrame(
bool updateItem =
true );
1145 void refreshBackgroundColor(
bool updateItem =
true );
1150 void refreshBlendMode();
1156 QPointF adjustPointForReferencePosition( QPointF point, QSizeF size, ReferencePoint reference )
const;
1161 QPointF positionAtReferencePoint( ReferencePoint reference )
const;
1177 virtual bool writePropertiesToElement( QDomElement &element, QDomDocument &document,
const QgsReadWriteContext &context )
const;
1194 virtual bool readPropertiesFromElement(
const QDomElement &element,
const QDomDocument &document,
const QgsReadWriteContext &context );
1204 bool mLayoutManagesZValue =
false;
1213 QString mTemplateUuid;
1216 QString mParentGroupUuid;
1218 ReferencePoint mReferencePoint = UpperLeft;
1224 double mItemRotation = 0.0;
1227 bool mExcludeFromExports =
false;
1233 bool mEvaluatedExcludeFromExports =
false;
1236 QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
1237 std::unique_ptr< QgsLayoutEffect > mEffect;
1240 double mOpacity = 1.0;
1241 double mEvaluatedOpacity = 1.0;
1243 QImage mItemCachedImage;
1244 double mItemCacheDpi = -1;
1246 bool mIsLocked =
false;
1249 bool mFrame =
false;
1251 QColor mFrameColor = QColor( 0, 0, 0 );
1255 Qt::PenJoinStyle mFrameJoinStyle = Qt::MiterJoin;
1258 bool mBackground =
true;
1260 QColor mBackgroundColor = QColor( 255, 255, 255 );
1262 bool mBlockUndoCommands =
false;
1264 void initConnectionsToLayout();
1267 void preparePainter( QPainter *painter );
1268 bool shouldDrawAntialiased()
const;
1269 bool shouldDrawDebugRect()
const;
1270 QSizeF applyMinimumSize( QSizeF targetSize );
1271 QSizeF applyFixedSize( QSizeF targetSize );
1274 double applyDataDefinedRotation(
double rotation );
1275 void updateStoredItemPosition();
1276 QPointF itemPositionAtReferencePoint( ReferencePoint reference, QSizeF size )
const;
1277 void setScenePos( QPointF destinationPos );
1278 bool shouldBlockUndoCommands()
const;
1280 void applyDataDefinedOrientation(
double &width,
double &height,
const QgsExpressionContext &context );
1282 friend class TestQgsLayoutItem;
1283 friend class TestQgsLayoutView;
1289 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsLayoutItem::Flags )
1291 #endif //QGSLAYOUTITEM_H
double viewScaleFactor() const
Returns the current view zoom (scale factor).
@ UndoLegendSymbolSpace
Legend symbol spacing.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
double itemOpacity() const
Returns the item's opacity.
QString id() const
Returns the item's ID name.
virtual QgsAbstractLayoutUndoCommand * createCommand(const QString &text, int id=0, QUndoCommand *parent=nullptr)=0
Creates a new layout undo command with the specified text and parent.
Layout item for basic filled shapes (e.g. rectangles, ellipses).
UndoCommand
Layout item undo commands, used for collapsing undo commands.
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
Item representing the paper in a layout.
virtual void refresh()
Refreshes the object, causing a recalculation of any property overrides.
@ UndoPictureStrokeColor
Picture stroke color.
@ UndoScaleBarStrokeColor
Scalebar stroke color.
@ UndoLegendBoxSpace
Legend box space.
@ UndoLegendText
Legend text.
@ MiddleRight
Middle right of item.
virtual QIcon icon() const
Returns the item's icon.
@ UndoShapeStyle
Shape symbol style.
@ UndoMapGridAnnotationFontColor
Map frame annotation color.
@ UndoLabelFontColor
Label color.
@ UndoArrowHeadStrokeColor
Arrow head stroke color.
@ UndoPictureStrokeWidth
Picture stroke width.
@ CanGroupWithAnyOtherItem
Item can be placed on a layer with any other item (default behavior)
@ UndoScaleBarUnitText
Scalebar unit text.
@ MiddleLeft
Middle left of item.
@ UndoScaleBarMapUnitsSegment
Scalebar map units per segment.
QString mapTheme
Associated map theme, or an empty string if this export layer does not need to be associated with a m...
@ UndoPictureNorthOffset
Picture north offset.
@ UndoStrokeColor
Stroke color adjustment.
@ UndoZoomContent
Item content zoomed.
@ UndoLegendTitleFont
Legend title font.
@ UndoScaleBarBoxContentSpace
Scalebar box context space.
@ UndoIncrementalResize
Incremental resize.
ReferencePoint
Fixed position reference point.
@ UndoLegendRasterStrokeWidth
Legend raster stroke width.
QgsLayoutSize sizeWithUnits() const
Returns the item's current size, including units.
Flag
Flags for controlling how an item behaves.
virtual QgsLayoutSize minimumSize() const
Returns the minimum allowed size of the item, if applicable, or an empty size if item can be freely r...
@ UndoLegendLineSpacing
Legend line spacing.
@ UndoBackgroundColor
Background color adjustment.
@ UndoMapGridIntervalRange
Grid interval range.
@ UndoLegendItemFont
Legend item font.
@ UndoMapAnnotationDistance
Map frame annotation distance.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
@ UndoScaleBarSegmentSize
Scalebar segment size.
bool hasBackground() const
Returns true if the item has a background.
@ UndoGridFramePenColor
Map grid frame pen color.
@ AllProperties
All properties for item.
@ UndoSetId
Change item ID.
@ UndoArrowHeadWidth
Arrow head width.
QColor backgroundColor() const
Returns the background color for this item.
@ UndoLabelText
Label text.
QgsLayoutMeasurement frameStrokeWidth() const
Returns the frame's stroke width.
Contains details of a particular export layer relating to a layout item.
QString name
User-friendly name for the export layer.
ExportLayerBehavior
Behavior of item when exporting to layered outputs.
QgsCompositionConverter class converts a QGIS 2.x composition to a QGIS 3.x layout.
@ UndoScaleBarSegmentsLeft
Scalebar segments left.
@ UndoLegendLayerSpace
Legend layer spacing.
Qt::PenJoinStyle frameJoinStyle() const
Returns the join style used for drawing the item's frame.
@ UndoRotation
Rotation adjustment.
@ UndoLegendIconSymbolSpace
Legend icon symbol space.
@ UndoLegendColumnCount
Legend column count.
QgsLayoutPoint positionWithUnits() const
Returns the item's current position, including units.
@ UndoLegendFontColor
Legend font color.
@ UndoAtlasMargin
Map atlas margin changed.
@ UndoScaleBarFillColor
Scalebar fill color.
@ UndoScaleBarFillColor2
Scalebar secondary fill color.
ReferencePoint referencePoint() const
Returns the reference point for positioning of the layout item.
@ UndoScaleBarSubdivisions
Scalebar number of subdivisions.
@ UndoScaleBarSegments
Scalebar number of segments.
@ UndoMapGridMarkerSymbol
Grid marker symbol.
@ MustPlaceInOwnLayer
Item must be placed in its own individual layer.
@ ItemContainsSubLayers
Item contains multiple sublayers which must be individually exported.
@ UndoMapRotation
Map rotation changed.
@ UndoScaleBarLabelBarSize
Scalebar label bar size.
@ UndoLabelMargin
Label margin.
Base class for graphical items within a QgsLayout.
@ UndoStrokeWidth
Stroke width adjustment.
@ UndoLegendSymbolHeight
Legend symbol height.
@ UndoMapGridLineSymbol
Grid line symbol.
@ UndoScaleBarFontColor
Scalebar font color.
@ LowerRight
Lower right corner of item.
@ UndoLegendColumnSpace
Legend column space.
@ LowerLeft
Lower left corner of item.
@ UndoLegendSymbolWidth
Legend symbol width.
QgsExpressionContext createExpressionContext() const override
Creates an expression context relating to the objects' current state.
Layout graphical items for displaying a map.
QPainter::CompositionMode blendMode() const
Returns the item's composition blending mode.
@ UndoArrowHeadFillColor
Arrow head fill color.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
virtual QString uuid() const
Returns the item identification string.
@ UndoOpacity
Opacity adjustment.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
@ UndoPictureRotation
Picture rotation.
@ UndoLabelFont
Label font.
@ UndoLegendWmsLegendHeight
Legend WMS height.
@ UpperRight
Upper right corner of item.
@ UndoShapeCornerRadius
Shape corner radius.
@ UndoScaleBarSubdivisionsHeight
Scalebar subdivisions height.
@ UndoLegendGroupFont
Legend group font.
This class provides a method of storing sizes, consisting of a width and height, for use in QGIS layo...
@ UndoLegendTitleSpaceBottom
Legend title space.
QColor frameStrokeColor() const
Returns the frame's stroke color.
@ UpperMiddle
Upper center of item.
@ LayoutMillimeters
Millimeters.
@ UndoMapGridFrameFill1Color
Map grid frame fill color 1.
const QgsRenderContext & renderContext() const
Returns a reference to the context's render context.
@ UndoOverviewStyle
Map overview style.
@ UndoScaleBarHeight
Scalebar height.
@ UndoLegendWmsLegendWidth
Legend WMS width.
QString mapLayerId
Associated map layer ID, or an empty string if this export layer is not associated with a map layer.
@ UndoCustomCommand
Base id for plugin based item undo commands.
This class provides a method of storing points, consisting of an x and y coordinate,...
@ UndoScaleBarLineWidth
Scalebar line width.
@ UndoLegendRasterStrokeColor
Legend raster stroke color.
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
@ UndoMapGridFrameFill2Color
Map grid frame fill color 2.
@ CanGroupWithItemsOfSameType
Item can only be placed on layers with other items of the same type, but multiple items of this type ...
@ UpperLeft
Upper left corner of item.
@ UndoLegendLayerFont
Legend layer font.
This class provides a method of storing measurements for use in QGIS layouts using a variety of diffe...
bool isLocked() const
Returns true if the item is locked, and cannot be interacted with using the mouse.
@ UndoArrowStrokeWidth
Arrow stroke width.
@ UndoLegendGroupSpace
Legend group spacing.
DataDefinedProperty
Data defined properties for different item types.
@ UndoMapLabelMargin
Margin for labels from edge of map.
@ LowerMiddle
Lower center of item.
virtual QgsLayoutSize fixedSize() const
Returns the fixed size of the item, if applicable, or an empty size if item can be freely resized.
@ UndoPictureFillColor
Picture fill color.