QGIS API Documentation  2.6.0-Brighton
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
QgsSvgCache Class Reference

A cache for images / pictures derived from svg files. More...

#include <qgssvgcache.h>

Signals

void statusChanged (const QString &theStatusQString)
 Emit a signal to be caught by qgisapp and display a msg on status bar.

Public Member Functions

 ~QgsSvgCache ()
const QImage & svgAsImage (const QString &file, double size, const QColor &fill, const QColor &outline, double outlineWidth, double widthScaleFactor, double rasterScaleFactor, bool &fitsInCache)
 Get SVG as QImage.
const QPicture & svgAsPicture (const QString &file, double size, const QColor &fill, const QColor &outline, double outlineWidth, double widthScaleFactor, double rasterScaleFactor, bool forceVectorOutput=false)
 Get SVG as QPicture&.
void containsParams (const QString &path, bool &hasFillParam, QColor &defaultFillColor, bool &hasOutlineParam, QColor &defaultOutlineColor, bool &hasOutlineWidthParam, double &defaultOutlineWidth) const
 Tests if an svg file contains parameters for fill, outline color, outline width.
QByteArray getImageData (const QString &path) const
 Get image data.

Static Public Member Functions

static QgsSvgCacheinstance ()

Protected Member Functions

 QgsSvgCache (QObject *parent=0)
 protected constructor
QgsSvgCacheEntryinsertSVG (const QString &file, double size, const QColor &fill, const QColor &outline, double outlineWidth, double widthScaleFactor, double rasterScaleFactor)
 Creates new cache entry and returns pointer to it.
void replaceParamsAndCacheSvg (QgsSvgCacheEntry *entry)
void cacheImage (QgsSvgCacheEntry *entry)
void cachePicture (QgsSvgCacheEntry *entry, bool forceVectorOutput=false)
QgsSvgCacheEntrycacheEntry (const QString &file, double size, const QColor &fill, const QColor &outline, double outlineWidth, double widthScaleFactor, double rasterScaleFactor)
 Returns entry from cache or creates a new entry if it does not exist already.
void trimToMaximumSize ()
 Removes the least used items until the maximum size is under the limit.
void takeEntryFromList (QgsSvgCacheEntry *entry)

Detailed Description

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 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)"

Constructor & Destructor Documentation

QgsSvgCache::~QgsSvgCache ( )
QgsSvgCache::QgsSvgCache ( QObject *  parent = 0)
protected

protected constructor

Member Function Documentation

QgsSvgCacheEntry * QgsSvgCache::cacheEntry ( const QString &  file,
double  size,
const QColor &  fill,
const QColor &  outline,
double  outlineWidth,
double  widthScaleFactor,
double  rasterScaleFactor 
)
protected

Returns entry from cache or creates a new entry if it does not exist already.

void QgsSvgCache::cacheImage ( QgsSvgCacheEntry entry)
protected
void QgsSvgCache::cachePicture ( QgsSvgCacheEntry entry,
bool  forceVectorOutput = false 
)
protected
void QgsSvgCache::containsParams ( const QString &  path,
bool &  hasFillParam,
QColor &  defaultFillColor,
bool &  hasOutlineParam,
QColor &  defaultOutlineColor,
bool &  hasOutlineWidthParam,
double &  defaultOutlineWidth 
) const

Tests if an svg file contains parameters for fill, outline color, outline width.

If yes, possible default values are returned. If there are several default values in the svg file, only the first one is considered

QByteArray QgsSvgCache::getImageData ( const QString &  path) const

Get image data.

QgsSvgCacheEntry * QgsSvgCache::insertSVG ( const QString &  file,
double  size,
const QColor &  fill,
const QColor &  outline,
double  outlineWidth,
double  widthScaleFactor,
double  rasterScaleFactor 
)
protected

Creates new cache entry and returns pointer to it.

Parameters
fileAbsolute or relative path to SVG file. If the path is relative the file is searched by QgsSymbolLayerV2Utils::symbolNameToPath() in SVG paths. in settings svg/searchPathsForSVG
sizesize of cached image
fillcolor of fill
outlinecolor of outline
outlineWidthwidth of outline
widthScaleFactorwidth scale factor
rasterScaleFactorraster scale factor
QgsSvgCache * QgsSvgCache::instance ( )
static
void QgsSvgCache::replaceParamsAndCacheSvg ( QgsSvgCacheEntry entry)
protected
void QgsSvgCache::statusChanged ( const QString &  theStatusQString)
signal

Emit a signal to be caught by qgisapp and display a msg on status bar.

const QImage & QgsSvgCache::svgAsImage ( const QString &  file,
double  size,
const QColor &  fill,
const QColor &  outline,
double  outlineWidth,
double  widthScaleFactor,
double  rasterScaleFactor,
bool &  fitsInCache 
)

Get SVG as QImage.

Parameters
fileAbsolute or relative path to SVG file.
sizesize of cached image
fillcolor of fill
outlinecolor of outline
outlineWidthwidth of outline
widthScaleFactorwidth scale factor
rasterScaleFactorraster scale factor
fitsInCache
const QPicture & QgsSvgCache::svgAsPicture ( const QString &  file,
double  size,
const QColor &  fill,
const QColor &  outline,
double  outlineWidth,
double  widthScaleFactor,
double  rasterScaleFactor,
bool  forceVectorOutput = false 
)

Get SVG as QPicture&.

Parameters
fileAbsolute or relative path to SVG file.
sizesize of cached image
fillcolor of fill
outlinecolor of outline
outlineWidthwidth of outline
widthScaleFactorwidth scale factor
rasterScaleFactorraster scale factor
forceVectorOutput
void QgsSvgCache::takeEntryFromList ( QgsSvgCacheEntry entry)
protected
void QgsSvgCache::trimToMaximumSize ( )
protected

Removes the least used items until the maximum size is under the limit.


The documentation for this class was generated from the following files: