54 double widthScaleFactor,
57 double fixedAspectRatio = 0,
58 const QMap<QString, QString> ¶meters = QMap<QString, QString>()
61 QgsSvgCacheEntry(
const QgsSvgCacheEntry &rh ) =
delete;
62 QgsSvgCacheEntry &
operator=(
const QgsSvgCacheEntry &rh ) =
delete;
65 double strokeWidth = 0;
66 double widthScaleFactor = 1.0;
69 double fixedAspectRatio = 0;
76 QColor fill = Qt::black;
77 QColor stroke = Qt::black;
78 QMap<QString, QString> parameters;
80 std::unique_ptr< QImage > image;
81 std::unique_ptr< QPicture > picture;
83 QByteArray svgContent;
90 bool isMissingImage =
false;
92 bool isEqual(
const QgsAbstractContentCacheEntry *other )
const override;
94 void dump()
const override;
159 const QColor &stroke,
161 double widthScaleFactor,
163 double fixedAspectRatio = 0,
164 bool blocking =
false,
165 const QMap<QString, QString> ¶meters = QMap<QString, QString>()
194 const QColor &stroke,
196 double widthScaleFactor,
197 bool forceVectorOutput =
false,
198 double fixedAspectRatio = 0,
199 bool blocking =
false,
200 const QMap<QString, QString> ¶meters = QMap<QString, QString>()
224 const QColor &stroke,
226 double widthScaleFactor,
227 double fixedAspectRatio = 0,
228 bool blocking =
false,
229 const QMap<QString, QString> ¶meters = QMap<QString, QString>()
239 const QString &path,
bool &hasFillParam, QColor &defaultFillColor,
bool &hasStrokeParam, QColor &defaultStrokeColor,
bool &hasStrokeWidthParam,
double &defaultStrokeWidth,
bool blocking =
false
272 bool &hasDefaultFillParam,
273 QColor &defaultFillColor,
274 bool &hasFillOpacityParam,
275 bool &hasDefaultFillOpacity,
276 double &defaultFillOpacity,
277 bool &hasStrokeParam,
278 bool &hasDefaultStrokeColor,
279 QColor &defaultStrokeColor,
280 bool &hasStrokeWidthParam,
281 bool &hasDefaultStrokeWidth,
282 double &defaultStrokeWidth,
283 bool &hasStrokeOpacityParam,
284 bool &hasDefaultStrokeOpacity,
285 double &defaultStrokeOpacity,
286 bool blocking =
false
303 QByteArray
getImageData(
const QString &path,
bool blocking =
false )
const;
325 const QColor &stroke,
327 double widthScaleFactor,
328 double fixedAspectRatio = 0,
329 bool blocking =
false,
330 const QMap<QString, QString> ¶meters = QMap<QString, QString>(),
331 bool *isMissingImage =
nullptr
338 const QColor &stroke,
340 double widthScaleFactor,
341 double fixedAspectRatio = 0,
342 bool blocking =
false,
343 const QMap<QString, QString> ¶meters = QMap<QString, QString>()
362 bool checkReply( QNetworkReply *reply,
const QString &path )
const override;
365 void replaceParamsAndCacheSvg( QgsSvgCacheEntry *entry,
bool blocking =
false );
366 void cacheImage( QgsSvgCacheEntry *entry );
367 void cachePicture( QgsSvgCacheEntry *entry,
bool forceVectorOutput =
false );
369 QgsSvgCacheEntry *cacheEntry(
373 const QColor &stroke,
375 double widthScaleFactor,
376 double fixedAspectRatio = 0,
377 const QMap<QString, QString> ¶meters = QMap<QString, QString>(),
378 bool blocking =
false,
379 bool *isMissingImage =
nullptr
383 void replaceElemParams( QDomElement &elem,
const QColor &fill,
const QColor &stroke,
double strokeWidth,
const QMap<QString, QString> ¶meters );
385 void containsElemParams(
386 const QDomElement &elem,
388 bool &hasDefaultFill,
390 bool &hasFillOpacityParam,
391 bool &hasDefaultFillOpacity,
392 double &defaultFillOpacity,
393 bool &hasStrokeParam,
394 bool &hasDefaultStroke,
395 QColor &defaultStroke,
396 bool &hasStrokeWidthParam,
397 bool &hasDefaultStrokeWidth,
398 double &defaultStrokeWidth,
399 bool &hasStrokeOpacityParam,
400 bool &hasDefaultStrokeOpacity,
401 double &defaultStrokeOpacity
405 double calcSizeScaleFactor( QgsSvgCacheEntry *entry,
const QDomElement &docElem, QSizeF &viewboxSize )
const;
411 QSize sizeForImage(
const QgsSvgCacheEntry &entry, QSizeF &viewBoxSize, QSizeF &scaledSize )
const;
416 QImage imageFromCachedPicture(
const QgsSvgCacheEntry &entry )
const;
419 QByteArray mMissingSvg;
421 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