mirror of
				https://github.com/qgis/QGIS.git
				synced 2025-11-04 00:04:25 -05:00 
			
		
		
		
	
		
			
				
	
	
		
			248 lines
		
	
	
		
			11 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			248 lines
		
	
	
		
			11 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
/************************************************************************
 | 
						|
 * This file has been generated automatically from                      *
 | 
						|
 *                                                                      *
 | 
						|
 * src/core/symbology/qgssvgcache.h                                     *
 | 
						|
 *                                                                      *
 | 
						|
 * Do not edit manually ! Edit header and run scripts/sipify.pl again   *
 | 
						|
 ************************************************************************/
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
 | 
						|
class QgsSvgCache : QgsAbstractContentCacheBase
 | 
						|
{
 | 
						|
%Docstring
 | 
						|
A cache for images / pictures derived from SVG files
 | 
						|
 | 
						|
This class supports parameter replacement in SVG files according to the SVG params specification
 | 
						|
(http://www.w3.org/TR/2009/WD-SVGParamPrimer-20090616/).
 | 
						|
 | 
						|
Supported parameters are:
 | 
						|
 | 
						|
- ``param``(fill): fill color (with no opacity value)
 | 
						|
- ``param``(fill-opacity): fill color opacity
 | 
						|
- ``param``(outline): outline color (with no opacity value)
 | 
						|
- ``param``(outline-opacity): outline color opacity
 | 
						|
- ``param``(outline-width): width of outline strokes
 | 
						|
 | 
						|
E.g:
 | 
						|
 | 
						|
<circle fill="param(fill-color red)" stroke="param(pen-color black)" stroke-width="param(outline-width 1)"
 | 
						|
 | 
						|
.. note::
 | 
						|
 | 
						|
   :py:class:`QgsSvgCache` is not usually directly created, but rather accessed through :py:func:`QgsApplication.svgCache()`.
 | 
						|
%End
 | 
						|
 | 
						|
%TypeHeaderCode
 | 
						|
#include "qgssvgcache.h"
 | 
						|
%End
 | 
						|
  public:
 | 
						|
 | 
						|
    QgsSvgCache( QObject *parent /TransferThis/ = 0 );
 | 
						|
%Docstring
 | 
						|
Constructor for QgsSvgCache.
 | 
						|
%End
 | 
						|
 | 
						|
    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>() );
 | 
						|
%Docstring
 | 
						|
Returns an SVG drawing as a QImage.
 | 
						|
 | 
						|
: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)
 | 
						|
:param blocking: forces to wait for loading before returning image (optional).
 | 
						|
:param parameters: is a map of parameters to dynamically replace content in SVG.
 | 
						|
 | 
						|
.. 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.
 | 
						|
%End
 | 
						|
 | 
						|
    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>() );
 | 
						|
%Docstring
 | 
						|
Returns an SVG drawing as a QPicture.
 | 
						|
 | 
						|
: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)
 | 
						|
:param blocking: forces to wait for loading before returning image (optional)
 | 
						|
:param parameters: is a map of parameters to dynamically replace content in SVG.
 | 
						|
 | 
						|
.. note::
 | 
						|
 | 
						|
   The returned QPicture contains the SVG file centered over the picture origin. I.e. if it is rendered
 | 
						|
   using QPainter.drawPicture( QPointF( 5, 10 ), picture ) it will be drawn centered over the point (5, 10).
 | 
						|
   Appropriate translation to the destination painter based on the picture's boundingRect may need to be applied
 | 
						|
   if rendering the SVG using the top-left or other reference point is desired.
 | 
						|
 | 
						|
 | 
						|
.. 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.
 | 
						|
%End
 | 
						|
 | 
						|
    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>() );
 | 
						|
%Docstring
 | 
						|
Calculates the viewbox size of a (possibly cached) SVG file.
 | 
						|
 | 
						|
: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)
 | 
						|
:param blocking: forces to wait for loading before returning image (optional).
 | 
						|
:param parameters: is a map of parameters to dynamically replace content in SVG.
 | 
						|
 | 
						|
:return: viewbox size set in SVG file
 | 
						|
 | 
						|
.. 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.
 | 
						|
 | 
						|
.. versionadded:: 2.14
 | 
						|
%End
 | 
						|
 | 
						|
    void containsParams( const QString &path, bool &hasFillParam, QColor &defaultFillColor, bool &hasStrokeParam, QColor &defaultStrokeColor, bool &hasStrokeWidthParam,
 | 
						|
                         double &defaultStrokeWidth, bool blocking = false ) const;
 | 
						|
%Docstring
 | 
						|
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. 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.
 | 
						|
%End
 | 
						|
 | 
						|
    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,
 | 
						|
                         bool &hasStrokeOpacityParam, bool &hasDefaultStrokeOpacity, double &defaultStrokeOpacity,
 | 
						|
                         bool blocking = false ) const /PyName=containsParamsV3/;
 | 
						|
%Docstring
 | 
						|
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.
 | 
						|
 | 
						|
:param path: path to SVG file
 | 
						|
:param hasFillParam: will be ``True`` if fill param present in SVG
 | 
						|
:param hasDefaultFillParam: will be ``True`` if fill param has a default value specified
 | 
						|
:param defaultFillColor: will be set to default fill color specified in SVG, if present
 | 
						|
: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
 | 
						|
:param defaultFillOpacity: will be set to default fill opacity specified in SVG, if present
 | 
						|
:param hasStrokeParam: will be ``True`` if stroke param present in SVG
 | 
						|
:param hasDefaultStrokeColor: will be ``True`` if stroke param has a default value specified
 | 
						|
:param defaultStrokeColor: will be set to default stroke color specified in SVG, if present
 | 
						|
: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
 | 
						|
:param defaultStrokeWidth: will be set to default stroke width specified in SVG, if present
 | 
						|
: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
 | 
						|
:param defaultStrokeOpacity: will be set to default stroke opacity specified in SVG, if present
 | 
						|
:param blocking: forces to wait for loading before returning image (optional).
 | 
						|
 | 
						|
.. note::
 | 
						|
 | 
						|
   Available in Python bindings as containsParamsV3
 | 
						|
 | 
						|
.. 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.
 | 
						|
 | 
						|
 | 
						|
.. versionadded:: 2.14
 | 
						|
%End
 | 
						|
 | 
						|
    QByteArray getImageData( const QString &path, bool blocking = false ) const;
 | 
						|
%Docstring
 | 
						|
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.
 | 
						|
%End
 | 
						|
 | 
						|
    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>() );
 | 
						|
%Docstring
 | 
						|
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.
 | 
						|
%End
 | 
						|
 | 
						|
  signals:
 | 
						|
 | 
						|
 void statusChanged( const QString  &statusQString ) /Deprecated/;
 | 
						|
%Docstring
 | 
						|
Emit a signal to be caught by qgisapp and display a msg on status bar.
 | 
						|
 | 
						|
.. deprecated::
 | 
						|
   Deprecated since QGIS 3.6 -- no longer emitted.
 | 
						|
%End
 | 
						|
 | 
						|
    void remoteSvgFetched( const QString &url );
 | 
						|
%Docstring
 | 
						|
Emitted when the cache has finished retrieving an SVG file from a remote ``url``.
 | 
						|
 | 
						|
.. versionadded:: 3.2
 | 
						|
%End
 | 
						|
 | 
						|
  protected:
 | 
						|
 | 
						|
    virtual bool checkReply( QNetworkReply *reply, const QString &path ) const;
 | 
						|
 | 
						|
 | 
						|
};
 | 
						|
 | 
						|
/************************************************************************
 | 
						|
 * This file has been generated automatically from                      *
 | 
						|
 *                                                                      *
 | 
						|
 * src/core/symbology/qgssvgcache.h                                     *
 | 
						|
 *                                                                      *
 | 
						|
 * Do not edit manually ! Edit header and run scripts/sipify.pl again   *
 | 
						|
 ************************************************************************/
 |