[QGIS Commit] r8430 - in trunk/qgis/src: app/legend core/symbology
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Wed May 14 08:57:40 EDT 2008
Author: timlinux
Date: 2008-05-14 08:57:40 -0400 (Wed, 14 May 2008)
New Revision: 8430
Modified:
trunk/qgis/src/app/legend/qgslegenditem.cpp
trunk/qgis/src/app/legend/qgslegendsymbologyitem.cpp
trunk/qgis/src/core/symbology/qgssymbol.cpp
Log:
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
Modified: trunk/qgis/src/app/legend/qgslegenditem.cpp
===================================================================
--- trunk/qgis/src/app/legend/qgslegenditem.cpp 2008-05-14 12:54:19 UTC (rev 8429)
+++ trunk/qgis/src/app/legend/qgslegenditem.cpp 2008-05-14 12:57:40 UTC (rev 8430)
@@ -20,7 +20,6 @@
#include "qgslegenditem.h"
#include <iostream>
#include <QCoreApplication>
-#include <QIcon>
#include "qgslegend.h"
Modified: trunk/qgis/src/app/legend/qgslegendsymbologyitem.cpp
===================================================================
--- trunk/qgis/src/app/legend/qgslegendsymbologyitem.cpp 2008-05-14 12:54:19 UTC (rev 8429)
+++ trunk/qgis/src/app/legend/qgslegendsymbologyitem.cpp 2008-05-14 12:57:40 UTC (rev 8430)
@@ -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;
}
Modified: trunk/qgis/src/core/symbology/qgssymbol.cpp
===================================================================
--- trunk/qgis/src/core/symbology/qgssymbol.cpp 2008-05-14 12:54:19 UTC (rev 8429)
+++ trunk/qgis/src/core/symbology/qgssymbol.cpp 2008-05-14 12:57:40 UTC (rev 8430)
@@ -245,23 +245,60 @@
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,
More information about the QGIS-commit
mailing list