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,
298 FlagOverridesPaint = 1 << 1,
300 Q_DECLARE_FLAGS( Flags,
Flag )
316 virtual void cleanup();
323 int type()
const override;
337 virtual QString
uuid()
const {
return mUuid; }
343 virtual Flags itemFlags()
const;
351 QString
id()
const {
return mId; }
359 virtual void setId(
const QString &
id );
367 virtual QString displayName()
const;
372 virtual void setSelected(
bool selected );
380 virtual void setVisibility(
bool visible );
387 void setLocked(
bool locked );
401 bool isGroupMember()
const;
432 void paint( QPainter *painter,
const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget )
override;
480 virtual void attemptResize(
const QgsLayoutSize &size,
bool includesFrame =
false );
507 virtual void attemptMove(
const QgsLayoutPoint &point,
bool useReferencePoint =
true,
bool includesFrame =
false,
int page = -1 );
524 void attemptSetSceneRect(
const QRectF &rect,
bool includesFrame =
false );
538 void attemptMoveBy(
double deltaX,
double deltaY );
561 QPointF pagePos()
const;
587 double itemRotation()
const;
596 bool writeXml( QDomElement &parentElement, QDomDocument &document,
const QgsReadWriteContext &context )
const;
613 bool readXml(
const QDomElement &itemElement,
const QDomDocument &document,
const QgsReadWriteContext &context );
623 virtual void finalizeRestoreFromXml();
643 virtual void setFrameEnabled(
bool drawFrame );
652 void setFrameStrokeColor(
const QColor &color );
697 void setFrameJoinStyle( Qt::PenJoinStyle style );
711 void setBackgroundEnabled(
bool drawBackground );
726 void setBackgroundColor(
const QColor &color );
732 QPainter::CompositionMode
blendMode()
const {
return mBlendMode; }
738 void setBlendMode( QPainter::CompositionMode mode );
756 void setItemOpacity(
double opacity );
762 bool excludeFromExports()
const;
768 void setExcludeFromExports(
bool exclude );
779 virtual bool containsAdvancedEffects()
const;
786 virtual bool requiresRasterization()
const;
798 virtual double estimatedFrameBleed()
const;
809 virtual QRectF rectWithFrame()
const;
817 virtual void moveContent(
double dx,
double dy );
825 virtual void setMoveContentPreviewOffset(
double dx,
double dy );
833 virtual void zoomContent(
double factor, QPointF point );
843 void beginCommand(
const QString &commandText,
UndoCommand command = UndoNone );
857 void cancelCommand();
862 bool shouldDrawItem()
const;
877 virtual void invalidateCache();
882 virtual void redraw();
901 virtual void setItemRotation(
double rotation,
bool adjustPosition =
true );
908 virtual void rotateItem(
double angle, QPointF transformOrigin );
927 void rotationChanged(
double newRotation );
932 void sizePositionChanged();
941 virtual void drawDebugRect( QPainter *painter );
985 virtual QSizeF applyItemSizeConstraint( QSizeF targetSize );
994 void refreshItemSize();
1001 void refreshItemPosition();
1013 void refreshItemRotation( QPointF *origin =
nullptr );
1020 void refreshOpacity(
bool updateItem =
true );
1027 void refreshFrame(
bool updateItem =
true );
1034 void refreshBackgroundColor(
bool updateItem =
true );
1039 void refreshBlendMode();
1045 QPointF adjustPointForReferencePosition( QPointF point, QSizeF size,
ReferencePoint reference )
const;
1050 QPointF positionAtReferencePoint(
ReferencePoint reference )
const;
1066 virtual bool writePropertiesToElement( QDomElement &element, QDomDocument &document,
const QgsReadWriteContext &context )
const;
1083 virtual bool readPropertiesFromElement(
const QDomElement &element,
const QDomDocument &document,
const QgsReadWriteContext &context );
1093 bool mLayoutManagesZValue =
false;
1102 QString mTemplateUuid;
1105 QString mParentGroupUuid;
1113 double mItemRotation = 0.0;
1116 bool mExcludeFromExports =
false;
1122 bool mEvaluatedExcludeFromExports =
false;
1125 QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
1126 std::unique_ptr< QgsLayoutEffect > mEffect;
1129 double mOpacity = 1.0;
1130 double mEvaluatedOpacity = 1.0;
1132 QImage mItemCachedImage;
1133 double mItemCacheDpi = -1;
1135 bool mIsLocked =
false;
1138 bool mFrame =
false;
1140 QColor mFrameColor = QColor( 0, 0, 0 );
1144 Qt::PenJoinStyle mFrameJoinStyle = Qt::MiterJoin;
1147 bool mBackground =
true;
1149 QColor mBackgroundColor = QColor( 255, 255, 255 );
1151 bool mBlockUndoCommands =
false;
1153 void initConnectionsToLayout();
1156 void preparePainter( QPainter *painter );
1157 bool shouldDrawAntialiased()
const;
1158 bool shouldDrawDebugRect()
const;
1159 QSizeF applyMinimumSize( QSizeF targetSize );
1160 QSizeF applyFixedSize( QSizeF targetSize );
1163 double applyDataDefinedRotation(
double rotation );
1164 void updateStoredItemPosition();
1165 QPointF itemPositionAtReferencePoint(
ReferencePoint reference, QSizeF size )
const;
1166 void setScenePos( QPointF destinationPos );
1167 bool shouldBlockUndoCommands()
const;
1169 void applyDataDefinedOrientation(
double &width,
double &height,
const QgsExpressionContext &context );
1171 friend class TestQgsLayoutItem;
1172 friend class TestQgsLayoutView;
1178 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsLayoutItem::Flags )
1180 #endif //QGSLAYOUTITEM_H
The class is used as a container of context for various read/write operations on other objects...
QgsLayoutPoint positionWithUnits() const
Returns the item's current position, including units.
double viewScaleFactor() const
Returns the current view zoom (scale factor).
virtual QIcon icon() const
Returns the item's icon.
Map grid frame pen color.
QgsExpressionContext createExpressionContext() const override
Creates an expression context relating to the objects' current state.
Base class for graphical items within a QgsLayout.
Lower left corner of item.
Base class for commands to undo/redo layout and layout object changes.
A layout item subclass for text labels.
UndoCommand
Layout item undo commands, used for collapsing undo commands.
QgsLayoutSize sizeWithUnits() const
Returns the item's current size, including units.
bool frameEnabled() const
Returns true if the item includes a frame.
A container for grouping several QgsLayoutItems.
A layout item subclass that displays SVG files or raster format images (jpg, png, ...
Scalebar secondary fill color.
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
virtual QgsLayoutSize fixedSize() const
Returns the fixed size of the item, if applicable, or an empty size if item can be freely resized...
Layout item for node based polygon shapes.
Lower right corner of item.
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)
Margin for labels from edge of map.
QgsLayoutMeasurement frameStrokeWidth() const
Returns the frame's stroke width.
This class provides a method of storing points, consisting of an x and y coordinate, for use in QGIS layouts.
ReferencePoint
Fixed position reference point.
A QGraphicsEffect subclass used for rendering layout items onto a scene with custom composition modes...
Layout graphical items for displaying a map.
Layout item for node based polyline shapes.
Map grid frame fill color 1.
virtual QgsLayoutSize minimumSize() const
Returns the minimum allowed size of the item, if applicable, or an empty size if item can be freely r...
This class provides a method of storing measurements for use in QGIS layouts using a variety of diffe...
Upper right corner of item.
bool hasBackground() const
Returns true if the item has a background.
Legend raster stroke color.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
QColor backgroundColor() const
Returns the background color for this item.
Layout item for basic filled shapes (e.g.
Map grid frame fill color 2.
virtual int numberExportLayers() const
Returns the number of layers that this item requires for exporting during layered exports (e...
Scalebar map units per segment.
double itemOpacity() const
Returns the item's opacity.
QString id() const
Returns the item's ID name.
Base id for plugin based item undo commands.
Upper left corner of item.
QPainter::CompositionMode blendMode() const
Returns the item's composition blending mode.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
Flag
Flags for controlling how an item behaves.
QColor frameStrokeColor() const
Returns the frame's stroke color.
ReferencePoint referencePoint() const
Returns the reference point for positioning of the layout item.
Map frame annotation color.
Contains settings and helpers relating to a render of a QgsLayoutItem.
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.
Legend raster stroke width.
QgsCompositionConverter class converts a QGIS 2.x composition to a QGIS 3.x layout.
Contains information about the context of a rendering operation.
Map frame annotation distance.
Qt::PenJoinStyle frameJoinStyle() const
Returns the join style used for drawing the item's frame.
Scalebar box context space.
const QgsRenderContext & renderContext() const
Returns a reference to the context's render context.
virtual QString uuid() const
Returns the item identification string.
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Interface for layout objects which support undo/redo commands.
Background color adjustment.
A layout item subclass for scale bars.
A base class for objects which belong to a layout.
bool isLocked() const
Returns true if the item is locked, and cannot be interacted with using the mouse.
A layout item subclass for map legends.
virtual void refresh()
Refreshes the object, causing a recalculation of any property overrides.
This class provides a method of storing sizes, consisting of a width and height, for use in QGIS layo...
Scalebar number of segments.
DataDefinedProperty
Data defined properties for different item types.
Base class for frame items, which form a layout multiframe item.
Legend icon symbol space.
Item representing the paper in a layout.
Map atlas margin changed.