Skip to content

Commit

Permalink
Bug fix and gui enhancement:
Browse files Browse the repository at this point in the history
 - 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/qgis@8430 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
timlinux committed May 14, 2008
1 parent de5d38e commit b6ee23c
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 16 deletions.
1 change: 0 additions & 1 deletion src/app/legend/qgslegenditem.cpp
Expand Up @@ -20,7 +20,6 @@
#include "qgslegenditem.h"
#include <iostream>
#include <QCoreApplication>
#include <QIcon>
#include "qgslegend.h"


Expand Down
11 changes: 9 additions & 2 deletions src/app/legend/qgslegendsymbologyitem.cpp
Expand Up @@ -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;
}
Expand Down
63 changes: 50 additions & 13 deletions src/core/symbology/qgssymbol.cpp
Expand Up @@ -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,
Expand Down

0 comments on commit b6ee23c

Please sign in to comment.