17 #ifndef QGSLAYOUTITEM_H 18 #define QGSLAYOUTITEM_H 20 #include "qgis_core.h" 27 #include <QGraphicsRectItem> 102 double mViewScaleFactor = 1.0;
133 switch ( sipCpp->type() )
136 case QGraphicsItem::UserType + 101:
137 sipType = sipType_QgsLayoutItemGroup;
140 case QGraphicsItem::UserType + 102:
141 sipType = sipType_QgsLayoutItemPage;
144 case QGraphicsItem::UserType + 103:
145 sipType = sipType_QgsLayoutItemMap;
148 case QGraphicsItem::UserType + 104:
149 sipType = sipType_QgsLayoutItemPicture;
152 case QGraphicsItem::UserType + 105:
153 sipType = sipType_QgsLayoutItemLabel;
156 case QGraphicsItem::UserType + 106:
157 sipType = sipType_QgsLayoutItemLegend;
160 case QGraphicsItem::UserType + 107:
161 sipType = sipType_QgsLayoutItemShape;
164 case QGraphicsItem::UserType + 108:
165 sipType = sipType_QgsLayoutItemPolygon;
168 case QGraphicsItem::UserType + 109:
169 sipType = sipType_QgsLayoutItemPolyline;
172 case QGraphicsItem::UserType + 110:
173 sipType = sipType_QgsLayoutItemScaleBar;
176 case QGraphicsItem::UserType + 111:
177 sipType = sipType_QgsLayoutFrame;
187 Q_PROPERTY(
bool locked READ isLocked WRITE setLocked NOTIFY lockChanged )
209 UndoIncrementalMove = 1,
296 virtual void cleanup();
303 int type()
const override;
317 virtual QString
uuid()
const {
return mUuid; }
325 QString
id()
const {
return mId; }
333 virtual void setId(
const QString &
id );
341 virtual QString displayName()
const;
346 virtual void setSelected(
bool selected );
354 virtual void setVisibility(
const bool visible );
361 void setLocked(
const bool locked );
375 bool isGroupMember()
const;
406 void paint( QPainter *painter,
const QStyleOptionGraphicsItem *itemStyle, QWidget *pWidget )
override;
454 virtual void attemptResize(
const QgsLayoutSize &size,
bool includesFrame =
false );
481 virtual void attemptMove(
const QgsLayoutPoint &point,
bool useReferencePoint =
true,
bool includesFrame =
false,
int page = -1 );
498 void attemptSetSceneRect(
const QRectF &rect,
bool includesFrame =
false );
512 void attemptMoveBy(
double deltaX,
double deltaY );
535 QPointF pagePos()
const;
561 double itemRotation()
const;
570 bool writeXml( QDomElement &parentElement, QDomDocument &document,
const QgsReadWriteContext &context )
const;
587 bool readXml(
const QDomElement &itemElement,
const QDomDocument &document,
const QgsReadWriteContext &context );
597 virtual void finalizeRestoreFromXml();
617 virtual void setFrameEnabled(
bool drawFrame );
626 void setFrameStrokeColor(
const QColor &color );
671 void setFrameJoinStyle(
const Qt::PenJoinStyle style );
685 void setBackgroundEnabled(
bool drawBackground );
700 void setBackgroundColor(
const QColor &color );
706 QPainter::CompositionMode
blendMode()
const {
return mBlendMode; }
712 void setBlendMode(
const QPainter::CompositionMode mode );
730 void setItemOpacity(
double opacity );
736 bool excludeFromExports()
const;
742 void setExcludeFromExports(
bool exclude );
753 virtual bool containsAdvancedEffects()
const;
760 virtual bool requiresRasterization()
const;
772 virtual double estimatedFrameBleed()
const;
783 virtual QRectF rectWithFrame()
const;
791 virtual void moveContent(
double dx,
double dy );
799 virtual void setMoveContentPreviewOffset(
double dx,
double dy );
807 virtual void zoomContent(
double factor, QPointF point );
817 void beginCommand(
const QString &commandText,
UndoCommand command = UndoNone );
831 void cancelCommand();
836 bool shouldDrawItem()
const;
851 virtual void invalidateCache();
856 virtual void redraw();
875 virtual void setItemRotation(
double rotation,
bool adjustPosition =
true );
882 virtual void rotateItem(
const double angle,
const QPointF &transformOrigin );
901 void rotationChanged(
double newRotation );
906 void sizePositionChanged();
915 virtual void drawDebugRect( QPainter *painter );
959 virtual QSizeF applyItemSizeConstraint(
const QSizeF &targetSize );
968 void refreshItemSize();
975 void refreshItemPosition();
987 void refreshItemRotation( QPointF *origin =
nullptr );
994 void refreshOpacity(
bool updateItem =
true );
1001 void refreshFrame(
bool updateItem =
true );
1008 void refreshBackgroundColor(
bool updateItem =
true );
1013 void refreshBlendMode();
1019 QPointF adjustPointForReferencePosition(
const QPointF &point,
const QSizeF &size,
const ReferencePoint &reference )
const;
1024 QPointF positionAtReferencePoint(
const ReferencePoint &reference )
const;
1040 virtual bool writePropertiesToElement( QDomElement &element, QDomDocument &document,
const QgsReadWriteContext &context )
const;
1057 virtual bool readPropertiesFromElement(
const QDomElement &element,
const QDomDocument &document,
const QgsReadWriteContext &context );
1067 bool mLayoutManagesZValue =
false;
1076 QString mTemplateUuid;
1079 QString mParentGroupUuid;
1087 double mItemRotation = 0.0;
1090 bool mExcludeFromExports =
false;
1096 bool mEvaluatedExcludeFromExports =
false;
1099 QPainter::CompositionMode mBlendMode = QPainter::CompositionMode_SourceOver;
1100 std::unique_ptr< QgsLayoutEffect > mEffect;
1103 double mOpacity = 1.0;
1105 QImage mItemCachedImage;
1106 double mItemCacheDpi = -1;
1108 bool mIsLocked =
false;
1111 bool mFrame =
false;
1113 QColor mFrameColor = QColor( 0, 0, 0 );
1117 Qt::PenJoinStyle mFrameJoinStyle = Qt::MiterJoin;
1120 bool mBackground =
true;
1122 QColor mBackgroundColor = QColor( 255, 255, 255 );
1124 bool mBlockUndoCommands =
false;
1126 void initConnectionsToLayout();
1129 void preparePainter( QPainter *painter );
1130 bool shouldDrawAntialiased()
const;
1131 bool shouldDrawDebugRect()
const;
1133 QSizeF applyMinimumSize(
const QSizeF &targetSize );
1134 QSizeF applyFixedSize(
const QSizeF &targetSize );
1137 double applyDataDefinedRotation(
const double rotation );
1138 void updateStoredItemPosition();
1139 QPointF itemPositionAtReferencePoint(
const ReferencePoint reference,
const QSizeF &size )
const;
1140 void setScenePos(
const QPointF &destinationPos );
1141 bool shouldBlockUndoCommands()
const;
1143 void applyDataDefinedOrientation(
double &width,
double &height,
const QgsExpressionContext &context );
1145 friend class TestQgsLayoutItem;
1146 friend class TestQgsLayoutView;
1152 #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)
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.
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.