51 QgsSvgCacheEntry(
const QString &path,
double size,
double strokeWidth,
double widthScaleFactor,
const QColor &fill,
const QColor &stroke,
52 double fixedAspectRatio = 0,
const QMap<QString, QString> ¶meters = QMap<QString, QString>() ) ;
54 QgsSvgCacheEntry(
const QgsSvgCacheEntry &rh ) =
delete;
55 QgsSvgCacheEntry &
operator=(
const QgsSvgCacheEntry &rh ) =
delete;
58 double strokeWidth = 0;
59 double widthScaleFactor = 1.0;
62 double fixedAspectRatio = 0;
69 QColor fill = Qt::black;
70 QColor stroke = Qt::black;
71 QMap<QString, QString> parameters;
73 std::unique_ptr< QImage > image;
74 std::unique_ptr< QPicture > picture;
76 QByteArray svgContent;
83 bool isMissingImage =
false;
85 bool isEqual(
const QgsAbstractContentCacheEntry *other )
const override;
87 void dump()
const override;
150 QImage
svgAsImage(
const QString &path,
double size,
const QColor &fill,
const QColor &stroke,
double strokeWidth,
151 double widthScaleFactor,
bool &fitsInCache,
double fixedAspectRatio = 0,
bool blocking =
false,
152 const QMap<QString, QString> ¶meters = QMap<QString, QString>() );
176 QPicture
svgAsPicture(
const QString &path,
double size,
const QColor &fill,
const QColor &stroke,
double strokeWidth,
177 double widthScaleFactor,
bool forceVectorOutput =
false,
double fixedAspectRatio = 0,
bool blocking =
false,
178 const QMap<QString, QString> ¶meters = QMap<QString, QString>() );
197 QSizeF
svgViewboxSize(
const QString &path,
double size,
const QColor &fill,
const QColor &stroke,
double strokeWidth,
198 double widthScaleFactor,
double fixedAspectRatio = 0,
bool blocking =
false,
const QMap<QString, QString> ¶meters = QMap<QString, QString>() );
206 void containsParams(
const QString &path,
bool &hasFillParam, QColor &defaultFillColor,
bool &hasStrokeParam, QColor &defaultStrokeColor,
bool &hasStrokeWidthParam,
207 double &defaultStrokeWidth,
bool blocking =
false )
const;
236 void containsParams(
const QString &path,
bool &hasFillParam,
bool &hasDefaultFillParam, QColor &defaultFillColor,
237 bool &hasFillOpacityParam,
bool &hasDefaultFillOpacity,
double &defaultFillOpacity,
238 bool &hasStrokeParam,
bool &hasDefaultStrokeColor, QColor &defaultStrokeColor,
239 bool &hasStrokeWidthParam,
bool &hasDefaultStrokeWidth,
double &defaultStrokeWidth,
240 bool &hasStrokeOpacityParam,
bool &hasDefaultStrokeOpacity,
double &defaultStrokeOpacity,
241 bool blocking =
false )
const SIP_PYNAME( containsParamsV3 );
257 QByteArray
getImageData(
const QString &path,
bool blocking =
false )
const;
275 QByteArray
svgContent(
const QString &path,
double size,
const QColor &fill,
const QColor &stroke,
double strokeWidth,
276 double widthScaleFactor,
double fixedAspectRatio = 0,
bool blocking =
false,
const QMap<QString, QString> ¶meters = QMap<QString, QString>(),
bool *isMissingImage =
nullptr );
278 QByteArray
svgContent(
const QString &path,
double size,
const QColor &fill,
const QColor &stroke,
double strokeWidth,
279 double widthScaleFactor,
double fixedAspectRatio = 0,
bool blocking =
false,
const QMap<QString, QString> ¶meters = QMap<QString, QString>() );
298 bool checkReply( QNetworkReply *reply,
const QString &path )
const override;
302 void replaceParamsAndCacheSvg( QgsSvgCacheEntry *entry,
bool blocking =
false );
303 void cacheImage( QgsSvgCacheEntry *entry );
304 void cachePicture( QgsSvgCacheEntry *entry,
bool forceVectorOutput =
false );
306 QgsSvgCacheEntry *cacheEntry(
const QString &path,
double size,
const QColor &fill,
const QColor &stroke,
double strokeWidth,
307 double widthScaleFactor,
double fixedAspectRatio = 0,
const QMap<QString, QString> ¶meters = QMap<QString, QString>(),
bool blocking =
false,
bool *isMissingImage =
nullptr );
310 void replaceElemParams( QDomElement &elem,
const QColor &fill,
const QColor &stroke,
double strokeWidth,
const QMap<QString, QString> ¶meters );
312 void containsElemParams(
const QDomElement &elem,
313 bool &hasFillParam,
bool &hasDefaultFill, QColor &defaultFill,
314 bool &hasFillOpacityParam,
bool &hasDefaultFillOpacity,
double &defaultFillOpacity,
315 bool &hasStrokeParam,
bool &hasDefaultStroke, QColor &defaultStroke,
316 bool &hasStrokeWidthParam,
bool &hasDefaultStrokeWidth,
double &defaultStrokeWidth,
317 bool &hasStrokeOpacityParam,
bool &hasDefaultStrokeOpacity,
double &defaultStrokeOpacity )
const SIP_PYNAME( containsParamsV3 );
320 double calcSizeScaleFactor( QgsSvgCacheEntry *entry,
const QDomElement &docElem, QSizeF &viewboxSize )
const;
326 QSize sizeForImage(
const QgsSvgCacheEntry &entry, QSizeF &viewBoxSize, QSizeF &scaledSize )
const;
331 QImage imageFromCachedPicture(
const QgsSvgCacheEntry &entry )
const;
334 QByteArray mMissingSvg;
336 QByteArray mFetchingSvg;
A QObject derived base class for QgsAbstractContentCache.
Base class for entries in a QgsAbstractContentCache.
virtual int dataSize() const =0
Returns the memory usage in bytes for the entry.
virtual void dump() const =0
Dumps debugging strings containing the item's properties.
QgsAbstractContentCacheEntry & operator=(const QgsAbstractContentCacheEntry &rh)=delete
virtual bool isEqual(const QgsAbstractContentCacheEntry *other) const =0
Tests whether this entry matches another entry.
QgsAbstractContentCache(QObject *parent=nullptr, const QString &typeString=QString(), long maxCacheSize=20000000, int fileModifiedCheckTimeout=30000)
A cache for images / pictures derived from SVG files.
QSizeF svgViewboxSize(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, double fixedAspectRatio=0, bool blocking=false, const QMap< QString, QString > ¶meters=QMap< QString, QString >())
Calculates the viewbox size of a (possibly cached) SVG file.
Q_DECL_DEPRECATED void statusChanged(const QString &statusQString)
Emit a signal to be caught by qgisapp and display a msg on status bar.
QByteArray getImageData(const QString &path, bool blocking=false) const
Gets the SVG content corresponding to the given path.
QPicture svgAsPicture(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, bool forceVectorOutput=false, double fixedAspectRatio=0, bool blocking=false, const QMap< QString, QString > ¶meters=QMap< QString, QString >())
Returns an SVG drawing as a QPicture.
QgsSvgCache(QObject *parent=nullptr)
Constructor for QgsSvgCache.
bool checkReply(QNetworkReply *reply, const QString &path) const override
Runs additional checks on a network reply to ensure that the reply content is consistent with that re...
void containsParams(const QString &path, bool &hasFillParam, QColor &defaultFillColor, bool &hasStrokeParam, QColor &defaultStrokeColor, bool &hasStrokeWidthParam, double &defaultStrokeWidth, bool blocking=false) const
Tests if an SVG file contains parameters for fill, stroke color, stroke width.
void remoteSvgFetched(const QString &url)
Emitted when the cache has finished retrieving an SVG file from a remote url.
QImage svgAsImage(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, bool &fitsInCache, double fixedAspectRatio=0, bool blocking=false, const QMap< QString, QString > ¶meters=QMap< QString, QString >())
Returns an SVG drawing as a QImage.
QByteArray svgContent(const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth, double widthScaleFactor, double fixedAspectRatio=0, bool blocking=false, const QMap< QString, QString > ¶meters=QMap< QString, QString >(), bool *isMissingImage=nullptr)
Gets the SVG content corresponding to the given path.
friend class TestQgsSvgCache