Skip to content
Permalink
Browse files
Bug fix and gui enhancement:
 - remove rendering artifacts in legend item icons (dont use argb premultified!)
 - show polygon icons as a squiggly polygon so the edges arent clipped (and hopefull people find it more attractive)
 - show line icons as a curve



git-svn-id: http://svn.osgeo.org/qgis/trunk@8430 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed May 14, 2008
1 parent cc7b4fa commit 03aed535a25e8f337b549750b84b5591341352f5
Showing with 59 additions and 16 deletions.
  1. +0 −1 src/app/legend/qgslegenditem.cpp
  2. +9 −2 src/app/legend/qgslegendsymbologyitem.cpp
  3. +50 −13 src/core/symbology/qgssymbol.cpp
@@ -20,7 +20,6 @@
#include "qgslegenditem.h"
#include <iostream>
#include <QCoreApplication>
#include <QIcon>
#include "qgslegend.h"


@@ -21,12 +21,19 @@
#include "qgslegendsymbologyitem.h"

QgsLegendSymbologyItem::QgsLegendSymbologyItem(QTreeWidgetItem * theItem,QString theString, int pixmapWidth, int pixmapHeight)
: QgsLegendItem(theItem, theString), mPixmapWidth(pixmapWidth), mPixmapHeight(pixmapHeight), mLegend(0)
: QgsLegendItem(theItem, theString),
mPixmapWidth(pixmapWidth),
mPixmapHeight(pixmapHeight),
mLegend(0)
{
mType = LEGEND_SYMBOL_ITEM;
}

QgsLegendSymbologyItem::QgsLegendSymbologyItem(int pixmapWidth, int pixmapHeight): QgsLegendItem(), mPixmapWidth(pixmapWidth), mPixmapHeight(pixmapHeight), mLegend(0)
QgsLegendSymbologyItem::QgsLegendSymbologyItem(int pixmapWidth, int pixmapHeight)
: QgsLegendItem(),
mPixmapWidth(pixmapWidth),
mPixmapHeight(pixmapHeight),
mLegend(0)
{
mType = LEGEND_SYMBOL_ITEM;
}
@@ -245,23 +245,60 @@ int QgsSymbol::pointSize() const

QImage QgsSymbol::getLineSymbolAsImage()
{
QImage img(15, 15, QImage::Format_ARGB32_Premultiplied);
img.fill(QColor(255,255,255,0).rgba());
QPainter p(&img);
p.setPen(mPen);
p.drawLine(0, 0, 15, 15);
return img; //this is ok because of qts sharing mechanism
//Note by Tim: dont use premultiplied - it causes
//artifacts on the output icon!
QImage img(15, 15,QImage::Format_ARGB32 );//QImage::Format_ARGB32_Premultiplied);
img.fill(QColor(255,255,255,255).rgba());
QPainter p(&img);
p.setRenderHints(QPainter::Antialiasing);
p.setPen(mPen);


QPainterPath myPath;
myPath.moveTo(0, 0);
myPath.cubicTo(15, 0, 5, 7, 15, 15);
p.drawPath(myPath);
//p.drawLine(0, 0, 15, 15);
return img; //this is ok because of qts sharing mechanism
}

QImage QgsSymbol::getPolygonSymbolAsImage()
{
QImage img(15, 15, QImage::Format_ARGB32_Premultiplied);
img.fill(QColor(255,255,255,0).rgba());
QPainter p(&img);
p.setPen(mPen);
p.setBrush(mBrush);
p.drawRect(0, 0, 15, 15);
return img; //this is ok because of qts sharing mechanism
//Note by Tim: dont use premultiplied - it causes
//artifacts on the output icon!
QImage img(15, 15,QImage::Format_ARGB32); //, QImage::Format_ARGB32_Premultiplied);
img.fill(QColor(255,255,255,255).rgba());
QPainter p(&img);
p.setRenderHints(QPainter::Antialiasing);
p.setPen(mPen);
p.setBrush(mBrush);
QPolygon myPolygon;
//leave a little white space around so
//dont draw at 0,0,15,15
myPolygon << QPoint(2, 2)
<< QPoint(1, 5)
<< QPoint(1, 10)
<< QPoint(2, 12)
<< QPoint(5, 13)
<< QPoint(6, 13)
<< QPoint(8, 12)
<< QPoint(8, 12)
<< QPoint(10, 12)
<< QPoint(12, 13)
<< QPoint(13, 11)
<< QPoint(12, 8)
<< QPoint(11, 6)
<< QPoint(12, 5)
<< QPoint(13, 2)
<< QPoint(11, 1)
<< QPoint(10, 1)
<< QPoint(8, 2)
<< QPoint(6, 4)
<< QPoint(4, 2)
;
p.drawPolygon(myPolygon);
//p.drawRect(1, 1, 14, 14);
return img; //this is ok because of qts sharing mechanism
}

QImage QgsSymbol::getCachedPointSymbolAsImage( double widthScale,

0 comments on commit 03aed53

Please sign in to comment.