mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Added SVG cache, started using it in Single Marker renderer
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@1781 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
c2de05b7b6
commit
309f689d5a
@ -1,8 +1,11 @@
|
||||
QGIS Change Log
|
||||
ChangeLog,v 1.159 2004/07/10 17:20:11 larsl Exp
|
||||
ChangeLog,v 1.160 2004/07/17 20:26:06 larsl Exp
|
||||
------------------------------------------------------------------------------
|
||||
Version 0.3 'Madison' .... development version
|
||||
|
||||
2004-07-17 [larsl] 0.4.0devel5
|
||||
** Added SVG cache and started using it in the Single Marker renderer
|
||||
|
||||
2004-07-10 [larsl] 0.4.0devel4
|
||||
** Added code to QgsProjectIo that saves and loads the provider key of a vector
|
||||
layer in the project file, so delimited text layers and GPX layers can be
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
dnl configure.in,v 1.162 2004/07/10 17:20:11 larsl Exp
|
||||
dnl configure.in,v 1.163 2004/07/17 20:26:06 larsl Exp
|
||||
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ dnl ---------------------------------------------------------------------------
|
||||
MAJOR_VERSION=0
|
||||
MINOR_VERSION=4
|
||||
MICRO_VERSION=0
|
||||
EXTRA_VERSION=4
|
||||
EXTRA_VERSION=5
|
||||
if test $EXTRA_VERSION -eq 0; then
|
||||
VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}
|
||||
else
|
||||
|
@ -88,6 +88,7 @@ headers = qgis.h \
|
||||
qgssimarenderer.h \
|
||||
qgssimadialog.h \
|
||||
qgssisydialog.h \
|
||||
qgssvgcache.h \
|
||||
qgssymbol.h \
|
||||
qgssymbologyutils.h \
|
||||
qgsvectorlayer.h \
|
||||
@ -232,6 +233,7 @@ qgis_SOURCES = main.cpp \
|
||||
qgssimarenderer.cpp \
|
||||
qgssinglesymrenderer.cpp \
|
||||
qgssisydialog.cpp \
|
||||
qgssvgcache.cpp \
|
||||
qgssymbol.cpp \
|
||||
qgssymbologyutils.cpp \
|
||||
qgsvectorlayer.cpp \
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include <qspinbox.h>
|
||||
#include "qgsoptions.h"
|
||||
#include "qgisapp.h"
|
||||
#include "qgssvgcache.h"
|
||||
/**
|
||||
* \class QgsOptions - Set user options and preferences
|
||||
* Constructor
|
||||
@ -44,6 +45,8 @@ QgsOptions::QgsOptions(QWidget *parent, const char *name) : QgsOptionsBase(paren
|
||||
cbxHideSplash->setChecked(hideSplashFlag);
|
||||
// set the current theme
|
||||
cmbTheme->setCurrentText(settings.readEntry("/qgis/theme"));
|
||||
// set the SVG oversampling factor
|
||||
spbSVGOversampling->setValue(QgsSVGCache::instance().getOversampling());
|
||||
// set the display update threshold
|
||||
spinBoxUpdateThreshold->setValue(settings.readNumEntry("/qgis/map/updateThreshold"));
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>479</width>
|
||||
<height>296</height>
|
||||
<height>363</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="caption">
|
||||
@ -184,6 +184,71 @@
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<widget class="QGroupBox" row="2" column="0">
|
||||
<property name="name">
|
||||
<cstring>groupBox5</cstring>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy>
|
||||
<hsizetype>7</hsizetype>
|
||||
<vsizetype>7</vsizetype>
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>SVG Options</string>
|
||||
</property>
|
||||
<grid>
|
||||
<property name="name">
|
||||
<cstring>unnamed</cstring>
|
||||
</property>
|
||||
<widget class="QLabel" row="0" column="0">
|
||||
<property name="name">
|
||||
<cstring>textLabel1_7</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>SVG oversampling factor</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" row="0" column="1">
|
||||
<property name="name">
|
||||
<cstring>spbSVGOversampling</cstring>
|
||||
</property>
|
||||
<property name="minValue">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
<spacer row="0" column="2">
|
||||
<property name="name">
|
||||
<cstring>spacer2</cstring>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint">
|
||||
<size>
|
||||
<width>180</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
<widget class="QLabel" row="1" column="0" rowspan="1" colspan="3">
|
||||
<property name="name">
|
||||
<cstring>textLabel1_5_2</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string><b>Note: </b>A higher value gives smoother SVG symbols, but can slow down rendering</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>WordBreak|AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
</grid>
|
||||
</widget>
|
||||
<widget class="QWidget">
|
||||
|
@ -9,6 +9,9 @@
|
||||
#include <qsettings.h>
|
||||
#include <qfiledialog.h>
|
||||
|
||||
#include "qgssvgcache.h"
|
||||
|
||||
|
||||
void QgsOptionsBase::init()
|
||||
{
|
||||
// read the current browser and set it
|
||||
@ -33,6 +36,8 @@ void QgsOptionsBase::saveOptions()
|
||||
settings.writeEntry("/qgis/hideSplash",cbxHideSplash->isChecked());
|
||||
settings.writeEntry("/qgis/theme",cmbTheme->currentText());
|
||||
settings.writeEntry("/qgis/map/updateThreshold", spinBoxUpdateThreshold->value());
|
||||
QgsSVGCache::instance().setOversampling(spbSVGOversampling->value());
|
||||
settings.writeEntry("/qgis/svgoversampling", spbSVGOversampling->value());
|
||||
accept();
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,10 @@
|
||||
#include "qgsrenderitem.h"
|
||||
#include "qgsdlgvectorlayerproperties.h"
|
||||
#include "qgslegenditem.h"
|
||||
#include "qgssvgcache.h"
|
||||
#include <qapplication.h>
|
||||
#include <qfiledialog.h>
|
||||
#include <qimage.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <qlineedit.h>
|
||||
#include <qpainter.h>
|
||||
@ -55,33 +57,12 @@ QgsSiMaDialog::QgsSiMaDialog(QgsVectorLayer* vectorlayer): QgsSiMaDialogBase(),
|
||||
QgsMarkerSymbol* sy=dynamic_cast < QgsMarkerSymbol* >(renderer->item()->getSymbol());
|
||||
if(sy)
|
||||
{
|
||||
QPicture pic;
|
||||
double scalefactor=sy->scaleFactor();
|
||||
mScaleSpin->setValue((int)(scalefactor*100.0));
|
||||
QString svgfile=sy->picture();
|
||||
pic.load(svgfile,"svg");
|
||||
|
||||
int width=(int)(pic.boundingRect().width()*scalefactor);
|
||||
int height=(int)(pic.boundingRect().height()*scalefactor);
|
||||
|
||||
//prevent 0 width or height, which would cause a crash
|
||||
if(width==0)
|
||||
{
|
||||
width=1;
|
||||
}
|
||||
if(height==0)
|
||||
{
|
||||
height=1;
|
||||
}
|
||||
|
||||
QPixmap pixmap(width,height);
|
||||
pixmap.fill();
|
||||
QPainter p(&pixmap);
|
||||
p.scale(scalefactor,scalefactor);
|
||||
p.drawPicture(0,0,pic);
|
||||
pmPreview->setPixmap(pixmap);
|
||||
pmPreview->setName(svgfile);
|
||||
|
||||
pmPreview->setPixmap(QgsSVGCache::instance().
|
||||
getPixmap(svgfile, scalefactor));
|
||||
pmPreview->setName(svgfile);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -162,8 +143,6 @@ void QgsSiMaDialog::apply()
|
||||
name = "";
|
||||
}
|
||||
|
||||
QPicture pic;
|
||||
pic.load(string,"svg");
|
||||
|
||||
QPixmap *pix = mVectorLayer->legendPixmap();
|
||||
|
||||
@ -173,31 +152,25 @@ void QgsSiMaDialog::apply()
|
||||
int bottomspace=5;
|
||||
int betweenspace=5;
|
||||
int rightspace=5;
|
||||
|
||||
int width = (int)(pic.boundingRect().width()*ms->scaleFactor()+fm.width(name)+leftspace+betweenspace+rightspace);
|
||||
int height = (int)((pic.boundingRect().height()*ms->scaleFactor() > fm.height()) ? pic.boundingRect().height()*ms->scaleFactor()+topspace+bottomspace : fm.height()+topspace+bottomspace);
|
||||
|
||||
//prevent 0 width or height, which would cause a crash
|
||||
if(width==0)
|
||||
{
|
||||
width=1;
|
||||
}
|
||||
if(height==0)
|
||||
{
|
||||
height=1;
|
||||
}
|
||||
|
||||
|
||||
// get the marker used, calculate width and height of the legend pixmap
|
||||
QPixmap symbolPix =
|
||||
QgsSVGCache::instance().getPixmap(string, ms->scaleFactor());
|
||||
int width = symbolPix.width() + fm.width(name) + leftspace +
|
||||
betweenspace + rightspace;
|
||||
int height = (symbolPix.height() > fm.height() ?
|
||||
symbolPix.height() + topspace+bottomspace :
|
||||
fm.height() + topspace+bottomspace);
|
||||
pix->resize(width, height);
|
||||
pix->fill();
|
||||
|
||||
|
||||
// paint symbol and layer name
|
||||
QPainter p(pix);
|
||||
p.scale(ms->scaleFactor(),ms->scaleFactor());
|
||||
p.drawPicture((int)(leftspace/ms->scaleFactor()),(int)(topspace/ms->scaleFactor()),pic);
|
||||
p.resetXForm();
|
||||
|
||||
p.drawPixmap(leftspace, topspace, symbolPix);
|
||||
p.setPen(Qt::black);
|
||||
p.setFont(f);
|
||||
p.drawText((int)(leftspace+betweenspace+pic.boundingRect().width()*ms->scaleFactor()), pix->height()-bottomspace,name);
|
||||
p.drawText(leftspace + betweenspace + symbolPix.width(),
|
||||
pix->height() - bottomspace,name);
|
||||
|
||||
mVectorLayer->updateItemPixmap();
|
||||
|
||||
@ -215,31 +188,11 @@ void QgsSiMaDialog::mIconView_selectionChanged(QIconViewItem * theIconViewItem)
|
||||
pmPreview->setName(svgfile);
|
||||
|
||||
//draw the SVG-Image on the button
|
||||
QPicture pic;
|
||||
double scalefactor=mScaleSpin->value()/100.0;
|
||||
pic.load(svgfile,"svg");
|
||||
|
||||
int width=(int)(pic.boundingRect().width()*scalefactor);
|
||||
int height=(int)(pic.boundingRect().height()*scalefactor);
|
||||
|
||||
//prevent 0 width or height, which would cause a crash
|
||||
if(width==0)
|
||||
{
|
||||
width=1;
|
||||
}
|
||||
if(height==0)
|
||||
{
|
||||
height=1;
|
||||
}
|
||||
|
||||
QPixmap pixmap(height,width);
|
||||
pixmap.fill();
|
||||
QPainter p(&pixmap);
|
||||
p.scale(scalefactor,scalefactor);
|
||||
p.drawPicture(0,0,pic);
|
||||
pmPreview->setPixmap(pixmap);
|
||||
|
||||
pmPreview->setPixmap(QgsSVGCache::instance().
|
||||
getPixmap(svgfile, scalefactor));
|
||||
}
|
||||
|
||||
void QgsSiMaDialog::mScaleSpin_valueChanged( int theSize)
|
||||
{
|
||||
#ifdef QGISDEBUG
|
||||
@ -249,31 +202,10 @@ void QgsSiMaDialog::mScaleSpin_valueChanged( int theSize)
|
||||
QString svgfile(pmPreview->name());
|
||||
if(!svgfile.isEmpty())
|
||||
{
|
||||
QPicture pic;
|
||||
//user enters scaling factor as a percentage
|
||||
double scalefactor=mScaleSpin->value()/100.0;
|
||||
pic.load(svgfile,"svg");
|
||||
|
||||
int width=pic.boundingRect().width();
|
||||
width=static_cast<int>(static_cast<double>(width)*scalefactor);
|
||||
int height=pic.boundingRect().height();
|
||||
height=static_cast<int>(static_cast<double>(height)*scalefactor);
|
||||
//prevent 0 width or height, which would cause a crash
|
||||
if(width==0)
|
||||
{
|
||||
width=1;
|
||||
}
|
||||
if(height==0)
|
||||
{
|
||||
height=1;
|
||||
}
|
||||
|
||||
QPixmap pixmap(width,height);
|
||||
pixmap.fill();
|
||||
QPainter p(&pixmap);
|
||||
p.scale(scalefactor,scalefactor);
|
||||
p.drawPicture(0,0,pic);
|
||||
pmPreview->setPixmap(pixmap);
|
||||
pmPreview->setPixmap(QgsSVGCache::instance().
|
||||
getPixmap(svgfile, scalefactor));
|
||||
}
|
||||
|
||||
}
|
||||
@ -301,17 +233,9 @@ void QgsSiMaDialog::visualizeMarkers(QString directory)
|
||||
#ifdef QGISDEBUG
|
||||
qWarning(*it);
|
||||
#endif
|
||||
|
||||
//use the QPixmap way, as the QPicture version does not seem to work properly
|
||||
QPicture pic;
|
||||
pic.load(mCurrentDir+"/"+(*it),"svg");
|
||||
QPixmap pix;
|
||||
pix.resize(pic.boundingRect().width(),pic.boundingRect().height());
|
||||
pix.fill();
|
||||
QPainter p(&pix);
|
||||
p.drawPicture(0,0,pic);
|
||||
QPixmap pix = QgsSVGCache::instance().getPixmap(mCurrentDir +
|
||||
"/" + (*it), 1);
|
||||
QIconViewItem* ivi=new QIconViewItem(mIconView,*it,pix);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include "qgssimarenderer.h"
|
||||
#include "qgssimadialog.h"
|
||||
#include "qgssvgcache.h"
|
||||
#include "qgsdlgvectorlayerproperties.h"
|
||||
#include "qgsvectorlayer.h"
|
||||
#include "qgsmarkersymbol.h"
|
||||
@ -68,12 +69,15 @@ void QgsSiMaRenderer::renderFeature(QPainter* p, QgsFeature* f, QPicture* pic, d
|
||||
QgsMarkerSymbol* ms=dynamic_cast<QgsMarkerSymbol*>(mItem->getSymbol());
|
||||
if(ms&&pic)
|
||||
{
|
||||
pic->load(ms->picture(),"svg");
|
||||
(*scalefactor)=ms->scaleFactor();
|
||||
QPainter painter(pic);
|
||||
painter.drawPixmap(0, 0, QgsSVGCache::instance().
|
||||
getPixmap(ms->picture(), ms->scaleFactor()));
|
||||
(*scalefactor) = 1;
|
||||
//pic->load(ms->picture(),"svg");
|
||||
//(*scalefactor)=ms->scaleFactor();
|
||||
if(selected)
|
||||
{
|
||||
QRect bound=pic->boundingRect();
|
||||
QPainter painter(pic);
|
||||
painter.setBrush(QColor(255,255,0));
|
||||
painter.drawRect(0,0,bound.width(),bound.height());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user