2017-06-06 11:03:05 +02:00
/************************************************************************
* This file has been generated automatically from *
* *
2017-08-06 13:39:03 +02:00
* src/core/symbology/qgssvgcache.h *
2017-06-06 11:03:05 +02:00
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
2012-09-24 02:28:15 +02:00
2018-12-03 11:15:13 +10:00
class QgsSvgCache : QgsAbstractContentCacheBase
2012-09-24 02:28:15 +02:00
{
2017-06-06 11:03:05 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
A cache for images / pictures derived from svg files. This class supports parameter replacement in svg files
2017-06-06 11:03:05 +02:00
according to the svg params specification (http://www.w3.org/TR/2009/WD-SVGParamPrimer-20090616/). Supported are
the parameters 'fill-color', 'pen-color', 'outline-width', 'stroke-width'. E.g. <circle fill="param(fill-color red)" stroke="param(pen-color black)" stroke-width="param(outline-width 1)"
2017-12-15 10:36:55 -04:00
QgsSvgCache is not usually directly created, but rather accessed through
2017-12-19 11:43:52 -04:00
:py:func:`QgsApplication.svgCache()`
2012-09-24 02:28:15 +02:00
%End
2017-06-06 11:03:05 +02:00
%TypeHeaderCode
#include "qgssvgcache.h"
%End
2012-09-24 02:28:15 +02:00
public:
2017-05-03 07:45:22 +02:00
QgsSvgCache( QObject *parent /TransferThis/ = 0 );
2017-06-06 11:03:05 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Constructor for QgsSvgCache.
2017-06-06 11:03:05 +02:00
%End
2016-12-28 16:09:05 +10:00
2017-06-06 11:03:05 +02:00
QImage svgAsImage( const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth,
2019-10-11 06:08:17 +02:00
double widthScaleFactor, bool &fitsInCache, double fixedAspectRatio = 0, bool blocking = false );
2017-06-06 11:03:05 +02:00
%Docstring
2018-05-26 18:44:30 +10:00
Gets SVG as QImage.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param path: Absolute path to SVG file.
:param size: size of cached image
:param fill: color of fill
:param stroke: color of stroke
:param strokeWidth: width of stroke
:param widthScaleFactor: width scale factor
:param fitsInCache:
:param fixedAspectRatio: fixed aspect ratio (optional)
2019-10-11 06:08:17 +02:00
:param blocking: forces to wait for loading before returning image (optional). WARNING: the
blocking parameter must NEVER be ``True`` from GUI based applications (like the main QGIS
application) or crashes will result. Only for use in external scripts or QGIS server.
2017-06-06 11:03:05 +02:00
%End
2017-04-27 14:26:21 +08:00
2017-06-06 11:03:05 +02:00
QPicture svgAsPicture( const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth,
2019-10-11 06:08:17 +02:00
double widthScaleFactor, bool forceVectorOutput = false, double fixedAspectRatio = 0, bool blocking = false );
2017-06-06 11:03:05 +02:00
%Docstring
2018-05-26 18:44:30 +10:00
Gets SVG as QPicture&.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param path: Absolute path to SVG file.
:param size: size of cached image
:param fill: color of fill
:param stroke: color of stroke
:param strokeWidth: width of stroke
:param widthScaleFactor: width scale factor
:param forceVectorOutput:
:param fixedAspectRatio: fixed aspect ratio (optional)
2019-10-11 06:08:17 +02:00
:param blocking: forces to wait for loading before returning image (optional). WARNING: the
blocking parameter must NEVER be ``True`` from GUI based applications (like the main QGIS
application) or crashes will result. Only for use in external scripts or QGIS server.
2017-06-06 11:03:05 +02:00
%End
2015-11-15 14:41:11 +11:00
2017-06-06 11:03:05 +02:00
QSizeF svgViewboxSize( const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth,
2019-10-11 06:08:17 +02:00
double widthScaleFactor, double fixedAspectRatio = 0, bool blocking = false );
2017-06-06 11:03:05 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Calculates the viewbox size of a (possibly cached) SVG file.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param path: Absolute path to SVG file.
:param size: size of cached image
:param fill: color of fill
:param stroke: color of stroke
:param strokeWidth: width of stroke
:param widthScaleFactor: width scale factor
:param fixedAspectRatio: fixed aspect ratio (optional)
2019-10-11 06:08:17 +02:00
:param blocking: forces to wait for loading before returning image (optional). WARNING: the
blocking parameter must NEVER be ``True`` from GUI based applications (like the main QGIS
application) or crashes will result. Only for use in external scripts or QGIS server.
2017-12-15 10:36:55 -04:00
:return: viewbox size set in SVG file
2017-06-06 11:03:05 +02:00
.. versionadded:: 2.14
%End
2012-09-24 02:28:15 +02:00
2017-06-06 11:03:05 +02:00
void containsParams( const QString &path, bool &hasFillParam, QColor &defaultFillColor, bool &hasStrokeParam, QColor &defaultStrokeColor, bool &hasStrokeWidthParam,
2019-10-11 06:08:17 +02:00
double &defaultStrokeWidth, bool blocking = false ) const;
2017-06-06 11:03:05 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Tests if an svg file contains parameters for fill, stroke color, stroke width. If yes, possible default values are returned. If there are several
2019-10-11 06:08:17 +02:00
default values in the svg file, only the first one is considered. Blocking forces to wait for loading before returning image (optional). WARNING: the
blocking parameter must NEVER be ``True`` from GUI based applications (like the main QGIS application) or crashes will result. Only for use in external
scripts or QGIS server.*
2017-06-06 11:03:05 +02:00
%End
2012-09-24 02:28:15 +02:00
2017-06-06 11:03:05 +02:00
void containsParams( const QString &path, bool &hasFillParam, bool &hasDefaultFillParam, QColor &defaultFillColor,
bool &hasFillOpacityParam, bool &hasDefaultFillOpacity, double &defaultFillOpacity,
bool &hasStrokeParam, bool &hasDefaultStrokeColor, QColor &defaultStrokeColor,
bool &hasStrokeWidthParam, bool &hasDefaultStrokeWidth, double &defaultStrokeWidth,
2019-10-11 06:08:17 +02:00
bool &hasStrokeOpacityParam, bool &hasDefaultStrokeOpacity, double &defaultStrokeOpacity,
bool blocking = false ) const /PyName=containsParamsV3/;
2017-06-06 11:03:05 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Tests if an svg file contains parameters for fill, stroke color, stroke width. If yes, possible default values are returned. If there are several
default values in the svg file, only the first one is considered.
2017-12-15 21:36:08 -04:00
2017-12-15 10:36:55 -04:00
:param path: path to SVG file
2019-02-26 19:54:09 +10:00
:param hasFillParam: will be ``True`` if fill param present in SVG
:param hasDefaultFillParam: will be ``True`` if fill param has a default value specified
2017-12-15 10:36:55 -04:00
:param defaultFillColor: will be set to default fill color specified in SVG, if present
2019-02-26 19:54:09 +10:00
:param hasFillOpacityParam: will be ``True`` if fill opacity param present in SVG
:param hasDefaultFillOpacity: will be ``True`` if fill opacity param has a default value specified
2017-12-15 10:36:55 -04:00
:param defaultFillOpacity: will be set to default fill opacity specified in SVG, if present
2019-02-26 19:54:09 +10:00
:param hasStrokeParam: will be ``True`` if stroke param present in SVG
:param hasDefaultStrokeColor: will be ``True`` if stroke param has a default value specified
2017-12-15 10:36:55 -04:00
:param defaultStrokeColor: will be set to default stroke color specified in SVG, if present
2019-02-26 19:54:09 +10:00
:param hasStrokeWidthParam: will be ``True`` if stroke width param present in SVG
:param hasDefaultStrokeWidth: will be ``True`` if stroke width param has a default value specified
2017-12-15 10:36:55 -04:00
:param defaultStrokeWidth: will be set to default stroke width specified in SVG, if present
2019-02-26 19:54:09 +10:00
:param hasStrokeOpacityParam: will be ``True`` if stroke opacity param present in SVG
:param hasDefaultStrokeOpacity: will be ``True`` if stroke opacity param has a default value specified
2017-12-15 10:36:55 -04:00
:param defaultStrokeOpacity: will be set to default stroke opacity specified in SVG, if present
2019-10-11 06:08:17 +02:00
:param blocking: forces to wait for loading before returning image (optional). WARNING: the
blocking parameter must NEVER be ``True`` from GUI based applications (like the main QGIS
application) or crashes will result. Only for use in external scripts or QGIS server.
2017-12-15 10:36:55 -04:00
2017-06-06 11:03:05 +02:00
.. note::
available in Python bindings as containsParamsV3
2017-12-15 10:36:55 -04:00
2017-06-06 11:03:05 +02:00
.. versionadded:: 2.14
%End
2015-10-11 22:54:13 +11:00
2019-10-11 06:08:17 +02:00
QByteArray getImageData( const QString &path, bool blocking = false ) const;
2017-06-06 11:03:05 +02:00
%Docstring
2019-10-11 06:08:17 +02:00
Gets the SVG content corresponding to the given ``path``.
``path`` may be a local file, remote (HTTP) url, or a base 64 encoded string (with a "base64:" prefix).
The class default missingContent byte array is returned if the ``path`` could not be resolved or is broken. If
the ``path`` corresponds to a remote URL, then class default fetchingContent will be returned while the content
is in the process of being fetched.
The ``blocking`` boolean forces to wait for loading before returning result. The content is loaded
in the same thread to ensure provided the remote content. WARNING: the ``blocking`` parameter must NEVER
be ``True`` from GUI based applications (like the main QGIS application) or crashes will result. Only for
use in external scripts or QGIS server.
2017-06-06 11:03:05 +02:00
%End
2014-01-26 18:35:21 +01:00
2019-10-11 06:08:17 +02:00
2017-06-06 11:03:05 +02:00
QByteArray svgContent( const QString &path, double size, const QColor &fill, const QColor &stroke, double strokeWidth,
2019-10-11 06:08:17 +02:00
double widthScaleFactor, double fixedAspectRatio = 0, bool blocking = false );
2017-06-06 11:03:05 +02:00
%Docstring
2019-10-11 06:08:17 +02:00
Gets the SVG content corresponding to the given ``path``.
``path`` may be a local file, remote (HTTP) url, or a base 64 encoded string (with a "base64:" prefix).
The parameters ``size``, ``strokeWidth`` for width of stroke, ``widthScaleFactor`` for width scale factor,
``fill`` for color of fill, ``stroke`` for color of stroke and ``fixedAspectRatio`` for fixed aspect ratio (optional)
are needed to get the entry from cache or creates a new entry if it does not exist already.
The ``blocking`` boolean forces to wait for loading before returning image. The content is loaded
in the same thread to ensure provided the image. WARNING: the ``blocking`` parameter must NEVER
be ``True`` from GUI based applications (like the main QGIS application) or crashes will result. Only for
use in external scripts or QGIS server.
2017-06-06 11:03:05 +02:00
%End
2015-06-19 22:22:16 +02:00
2014-01-26 18:35:21 +01:00
signals:
2018-12-03 11:15:13 +10:00
void statusChanged( const QString &statusQString ) /Deprecated/;
2017-06-06 11:03:05 +02:00
%Docstring
2018-12-03 11:15:13 +10:00
Emit a signal to be caught by qgisapp and display a msg on status bar.
2019-10-15 13:17:38 +02:00
.. deprecated::
Deprecated since QGIS 3.6 -- no longer emitted.
2018-03-29 15:34:19 +10:00
%End
void remoteSvgFetched( const QString &url );
%Docstring
Emitted when the cache has finished retrieving an SVG file from a remote ``url``.
.. versionadded:: 3.2
2017-06-06 11:03:05 +02:00
%End
2014-01-26 18:35:21 +01:00
2018-12-03 11:15:13 +10:00
protected:
virtual bool checkReply( QNetworkReply *reply, const QString &path ) const;
2012-09-24 02:28:15 +02:00
};
2017-06-06 11:03:05 +02:00
/************************************************************************
* This file has been generated automatically from *
* *
2017-08-06 13:39:03 +02:00
* src/core/symbology/qgssvgcache.h *
2017-06-06 11:03:05 +02:00
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/