mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Started to implement svg cache
This commit is contained in:
parent
a21e1db988
commit
651259a80c
@ -37,6 +37,7 @@ SET(QGIS_CORE_SRCS
|
||||
symbology-ng/qgsvectorcolorrampv2.cpp
|
||||
symbology-ng/qgsstylev2.cpp
|
||||
symbology-ng/qgssymbologyv2conversion.cpp
|
||||
symbology-ng/qgssvgcache.cpp
|
||||
|
||||
qgis.cpp
|
||||
qgsapplication.cpp
|
||||
|
59
src/core/symbology-ng/qgssvgcache.cpp
Normal file
59
src/core/symbology-ng/qgssvgcache.cpp
Normal file
@ -0,0 +1,59 @@
|
||||
/***************************************************************************
|
||||
qgssvgcache.h
|
||||
------------------------------
|
||||
begin : 2011
|
||||
copyright : (C) 2011 by Marco Hugentobler
|
||||
email : marco dot hugentobler at sourcepole dot ch
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "qgssvgcache.h"
|
||||
|
||||
QgsSvgCache* QgsSvgCache::mInstance = 0;
|
||||
|
||||
QgsSvgCache* QgsSvgCache::instance()
|
||||
{
|
||||
if ( !mInstance )
|
||||
{
|
||||
mInstance = new QgsSvgCache();
|
||||
}
|
||||
return mInstance;
|
||||
}
|
||||
|
||||
QgsSvgCache::QgsSvgCache()
|
||||
{
|
||||
}
|
||||
|
||||
QgsSvgCache::~QgsSvgCache()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
const QImage& QgsSvgCache::svgAsImage( const QString& file, double size, const QColor& fill, const QColor& outline, double outlineWidth ) const
|
||||
{
|
||||
}
|
||||
|
||||
const QPicture& QgsSvgCache::svgAsPicture( const QString& file, double size, const QColor& fill, const QColor& outline, double outlineWidth ) const
|
||||
{
|
||||
}
|
||||
|
||||
void QgsSvgCache::insertSVG( const QString& file, double size, const QColor& fill, const QColor& outline, double outlineWidth )
|
||||
{
|
||||
}
|
||||
|
||||
void QgsSvgCache::cacheImage( QgsSvgCacheEntry )
|
||||
{
|
||||
}
|
||||
|
||||
void QgsSvgCache::cachePicture( QgsSvgCacheEntry )
|
||||
{
|
||||
}
|
||||
|
73
src/core/symbology-ng/qgssvgcache.h
Normal file
73
src/core/symbology-ng/qgssvgcache.h
Normal file
@ -0,0 +1,73 @@
|
||||
/***************************************************************************
|
||||
qgssvgcache.h
|
||||
------------------------------
|
||||
begin : 2011
|
||||
copyright : (C) 2011 by Marco Hugentobler
|
||||
email : marco dot hugentobler at sourcepole dot ch
|
||||
***************************************************************************/
|
||||
|
||||
/***************************************************************************
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef QGSSVGCACHE_H
|
||||
#define QGSSVGCACHE_H
|
||||
|
||||
#include <QColor>
|
||||
#include <QDateTime>
|
||||
#include <QMap>
|
||||
#include <QMultiHash>
|
||||
#include <QString>
|
||||
|
||||
class QImage;
|
||||
class QPicture;
|
||||
|
||||
struct QgsSvgCacheEntry
|
||||
{
|
||||
QString file;
|
||||
double size;
|
||||
double outlineWidth;
|
||||
QColor fill;
|
||||
QColor outline;
|
||||
QImage* image;
|
||||
QPicture* picture;
|
||||
QDateTime lastUsed;
|
||||
};
|
||||
|
||||
/**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)"*/
|
||||
class QgsSvgCache
|
||||
{
|
||||
public:
|
||||
|
||||
static QgsSvgCache* instance();
|
||||
~QgsSvgCache();
|
||||
|
||||
const QImage& svgAsImage( const QString& file, double size, const QColor& fill, const QColor& outline, double outlineWidth ) const;
|
||||
const QPicture& svgAsPicture( const QString& file, double size, const QColor& fill, const QColor& outline, double outlineWidth ) const;
|
||||
|
||||
protected:
|
||||
QgsSvgCache();
|
||||
|
||||
void insertSVG( const QString& file, double size, const QColor& fill, const QColor& outline, double outlineWidth );
|
||||
void cacheImage( QgsSvgCacheEntry );
|
||||
void cachePicture( QgsSvgCacheEntry );
|
||||
|
||||
private:
|
||||
static QgsSvgCache* mInstance;
|
||||
|
||||
/**Entries sorted by last used time*/
|
||||
QMap< QDateTime, QgsSvgCacheEntry > mEntries;
|
||||
/**Entry pointers accessible by file name*/
|
||||
QMultiHash< QString, QgsSvgCacheEntry* > mEntryLookup;
|
||||
/**Estimated total size of all images and pictures*/
|
||||
double mTotalSize;
|
||||
};
|
||||
|
||||
#endif // QGSSVGCACHE_H
|
Loading…
x
Reference in New Issue
Block a user