17#ifndef QGSLAYOUTITEMPICTURE_H
18#define QGSLAYOUTITEMPICTURE_H
25#include <QSvgRenderer>
64 int type()
const override;
65 QIcon
icon()
const override;
93 QString picturePath()
const;
128 NorthMode northMode()
const;
135 void setNorthMode( NorthMode mode );
142 double northOffset()
const;
149 void setNorthOffset(
double offset );
186 void setSvgFillColor(
const QColor &color );
203 void setSvgStrokeColor(
const QColor &color );
219 void setSvgStrokeWidth(
double width );
253 bool isMissingImage()
const;
262 QString evaluatedPath()
const;
268 QMap<QString, QgsProperty> svgDynamicParameters()
const;
274 void setSvgDynamicParameters(
const QMap<QString, QgsProperty> ¶meters );
283 void setPictureRotation(
double rotation );
302 void recalculateSize();
322 QSizeF pictureSize();
331 QSize mDefaultSvgSize;
334 double mPictureRotation = 0;
336 QString mRotationMapUuid;
339 double mPictureWidth = 0.0;
341 double mPictureHeight = 0.0;
346 QColor mSvgFillColor = QColor( 255, 255, 255 );
347 QColor mSvgStrokeColor = QColor( 0, 0, 0 );
348 double mSvgStrokeWidth = 0.2;
350 bool mHasExpressionError =
false;
351 bool mLoaded =
false;
352 bool mLoadingSvg =
false;
353 bool mIsMissingImage =
false;
354 QString mEvaluatedPath;
359 void loadPicture(
const QVariant &data );
365 QRect clippedImageRect(
double &boundRectWidthMM,
double &boundRectHeightMM, QSize imageRectPixels );
370 void loadRemotePicture(
const QString &url );
375 void loadLocalPicture(
const QString &path );
377 void loadPictureUsingCache(
const QString &path );
384 void updateNorthArrowRotation(
double rotation );
PictureFormat
Picture formats.
@ Unknown
Invalid or unknown image type.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Handles parsing and evaluation of expressions (formerly called "search strings").
Layout graphical items for displaying a map.
A layout item subclass that displays SVG files or raster format images (jpg, png, ....
double pictureRotation() const
Returns the rotation used for drawing the picture within the item's frame, in degrees clockwise.
QColor svgStrokeColor() const
Returns the stroke color used for parametrized SVG files.
QgsLayoutItemPicture(QgsLayout *layout)
Constructor for QgsLayoutItemPicture, with the specified parent layout.
QgsLayoutItem::ReferencePoint pictureAnchor() const
Returns the picture's current anchor, which controls how it is placed within the picture item's frame...
double svgStrokeWidth() const
Returns the stroke width (in layout units) used for parametrized SVG files.
Qgis::PictureFormat originalMode() const
Returns the original set picture mode (image format).
void pictureRotationChanged(double newRotation)
Emitted on picture rotation change.
ResizeMode resizeMode() const
Returns the resize mode used for drawing the picture within the layout item's frame.
Qgis::PictureFormat mode() const
Returns the current picture mode (image format), FormatUnknown if given picture format is unknown.
NorthMode
Method for syncing rotation to a map's North direction.
@ GridNorth
Align to grid north.
@ TrueNorth
Align to true north.
friend class TestQgsCompositionConverter
friend class QgsCompositionConverter
QColor svgFillColor() const
Returns the fill color used for parametrized SVG files.
ResizeMode
Controls how pictures are scaled within the item's frame.
@ FrameToImageSize
Sets size of frame to match original size of image without scaling.
@ ZoomResizeFrame
Enlarges image to fit frame, then resizes frame to fit resultant image.
@ Clip
Draws image at original size and clips any portion which falls outside frame.
@ Stretch
Stretches image to fit frame, ignores aspect ratio.
@ Zoom
Enlarges image to fit frame while maintaining aspect ratio of picture.
Contains settings and helpers relating to a render of a QgsLayoutItem.
virtual void refreshDataDefinedProperty(QgsLayoutObject::DataDefinedProperty property=QgsLayoutObject::DataDefinedProperty::AllProperties)
Refreshes a data defined property for the item by reevaluating the property's value and redrawing the...
QgsLayoutItem(QgsLayout *layout, bool manageZValue=true)
Constructor for QgsLayoutItem, with the specified parent layout.
virtual QIcon icon() const
Returns the item's icon.
ReferencePoint
Fixed position reference point.
@ UpperLeft
Upper left corner of item.
virtual bool writePropertiesToElement(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
Stores item state within an XML DOM element.
virtual void finalizeRestoreFromXml()
Called after all pending items have been restored from XML.
int type() const override
Returns a unique graphics item type identifier.
virtual QSizeF applyItemSizeConstraint(QSizeF targetSize)
Applies any item-specific size constraint handling to a given targetSize in layout units.
virtual bool readPropertiesFromElement(const QDomElement &element, const QDomDocument &document, const QgsReadWriteContext &context)
Sets item state from a DOM element.
virtual void draw(QgsLayoutItemRenderContext &context)=0
Draws the item's contents using the specified item render context.
An object which handles north-arrow type behavior for layout items.
DataDefinedProperty
Data defined properties for different item types.
@ AllProperties
All properties for item.
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
A container for the context for various read/write operations on objects.