[Kst] branches/work/kst/portto4/kst/src
Barth Netterfield
netterfield at astro.utoronto.ca
Fri Dec 30 22:59:42 UTC 2011
SVN commit 1270950 by netterfield:
Antialias curve drawing.
Fix truncation errors in some point types.
M +11 -0 libkstapp/plotitem.cpp
M +1 -5 libkstmath/curve.cpp
M +25 -23 libkstmath/curvepointsymbol.cpp
M +0 -1 widgets/dialogdefaults.cpp
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #1270949:1270950
@@ -1009,6 +1009,7 @@
#if BENCHMARK > 1
b_3 = benchtmp.elapsed();
#endif
+
paintMajorTicks(painter);
#if BENCHMARK > 1
b_4 = benchtmp.elapsed();
@@ -1266,6 +1267,7 @@
if (xAxis()->drawAxisMajorGridLines()) {
painter->save();
painter->setPen(QPen(QBrush(_xAxis->axisMajorGridLineColor()), _xAxis->axisMajorGridLineWidth(), _xAxis->axisMajorGridLineStyle()));
+ painter->setRenderHint(QPainter::Antialiasing);
painter->drawLines(_xMajorGridLines);
painter->restore();
}
@@ -1273,6 +1275,7 @@
if (yAxis()->drawAxisMajorGridLines()) {
painter->save();
painter->setPen(QPen(QBrush(_yAxis->axisMajorGridLineColor()), _yAxis->axisMajorGridLineWidth(), _yAxis->axisMajorGridLineStyle()));
+ painter->setRenderHint(QPainter::Antialiasing);
painter->drawLines(_yMajorGridLines);
painter->restore();
}
@@ -1283,6 +1286,7 @@
if (xAxis()->drawAxisMinorGridLines()) {
painter->save();
painter->setPen(QPen(QBrush(_xAxis->axisMinorGridLineColor()), _xAxis->axisMinorGridLineWidth(), _xAxis->axisMinorGridLineStyle()));
+ painter->setRenderHint(QPainter::Antialiasing);
painter->drawLines(_xMinorGridLines);
painter->restore();
}
@@ -1290,6 +1294,7 @@
if (yAxis()->drawAxisMinorGridLines()) {
painter->save();
painter->setPen(QPen(QBrush(_yAxis->axisMinorGridLineColor()), _yAxis->axisMinorGridLineWidth(), _yAxis->axisMinorGridLineStyle()));
+ painter->setRenderHint(QPainter::Antialiasing);
painter->drawLines(_yMinorGridLines);
painter->restore();
}
@@ -1297,6 +1302,8 @@
void PlotItem::paintMajorTicks(QPainter *painter) {
+ painter->save();
+ painter->setRenderHint(QPainter::Antialiasing);
if (xAxis()->drawAxisMajorTicks()) {
painter->drawLines(_xMajorTickLines);
}
@@ -1304,10 +1311,13 @@
if (yAxis()->drawAxisMajorTicks()) {
painter->drawLines(_yMajorTickLines);
}
+ painter->restore();
}
void PlotItem::paintMinorTicks(QPainter *painter) {
+ painter->save();
+ painter->setRenderHint(QPainter::Antialiasing);
if (xAxis()->drawAxisMinorTicks()) {
painter->drawLines(_xMinorTickLines);
}
@@ -1315,6 +1325,7 @@
if (yAxis()->drawAxisMinorTicks()) {
painter->drawLines(_yMinorTickLines);
}
+ painter->restore();
}
--- branches/work/kst/portto4/kst/src/libkstmath/curve.cpp #1270949:1270950
@@ -666,16 +666,12 @@
QPainter *p = context.painter;
p->save();
- //p->setRenderHint(QPainter::Antialiasing);
+ p->setRenderHint(QPainter::Antialiasing);
Qt::PenStyle style = Kst::LineStyle[lineStyle()];
if (hasBars()) {
- //if (barStyle() == 1) { // filled
p->setPen(QPen(barFillColor(), _width, style));
- //} else {
- //p->setPen(QPen(color(), _width, style));
- //}
foreach(const QRectF& rect, _filledRects) {
p->fillRect(rect, barFillColor());
--- branches/work/kst/portto4/kst/src/libkstmath/curvepointsymbol.cpp #1270949:1270950
@@ -34,9 +34,9 @@
}
if (lineSize == 0 || lineSize == 1) {
- s = 3;
+ s = 3.0;
} else {
- s = ( 3 * lineSize ) / 2;
+ s = ( 3.0 * lineSize ) / 2.0;
}
switch (Type) {
@@ -46,16 +46,16 @@
break;
case 1:
p->setBrush(Qt::NoBrush);
- p->drawRect(QRectF(x-s, y-s, 2*s, 2*s));
+ p->drawRect(QRectF(x-s, y-s, 2.0*s, 2.0*s));
break;
case 2:
p->setBrush(Qt::NoBrush);
- p->drawEllipse(x-s, y-s, 2*s, 2*s);
+ p->drawEllipse(QPointF(x,y), s, s);
break;
case 3:
p->setBrush(Qt::SolidPattern);
p->setBrush(p->pen().color());
- p->drawEllipse(x-s, y-s, 2*s, 2*s);
+ p->drawEllipse(QPointF(x,y), s, s);
break;
case 4:
{
@@ -68,9 +68,9 @@
break;
case 5:
{
- QPolygon pts(3);
+ QPolygonF pts;
- pts.putPoints( 0, 3, int(x-s), int(y+s), int(x), int(y-s), int(x+s), int(y+s) );
+ pts << QPointF(x-s, y+s) << QPointF(x,y-s) << QPointF(x+s,y+s);
p->setBrush(Qt::NoBrush);
p->drawPolygon(pts);
}
@@ -78,7 +78,7 @@
case 6:
p->setBrush(Qt::SolidPattern);
p->setBrush(p->pen().color());
- p->drawRect(QRectF(x-s, y-s, 2*s+1, 2*s+1));
+ p->drawRect(QRectF(x-s, y-s, 2.0*s+1.0, 2.0*s+1.0));
break;
case 7:
p->drawLine(QLineF(x-s, y, x+s, y));
@@ -92,9 +92,8 @@
break;
case 9:
{
- QPolygon pts(3);
-
- pts.putPoints( 0, 3, int(x-s), int(y-s), int(x), int(y+s), int(x+s), int(y-s) );
+ QPolygonF pts;
+ pts << QPointF(x-s, y-s) << QPointF(x, y+s) << QPointF(x+s, y-s);
p->setBrush(Qt::SolidPattern);
p->setBrush(p->pen().color());
p->drawPolygon(pts);
@@ -102,9 +101,10 @@
break;
case 10:
{
- QPolygon pts(3);
+ QPolygonF pts;
- pts.putPoints( 0, 3, int(x-s), int(y+s), int(x), int(y-s), int(x+s), int(y+s) );
+ pts << QPointF(x-s, y+s) << QPointF(x, y-s) << QPointF(x+s,y+s);
+
p->setBrush(Qt::SolidPattern);
p->setBrush(p->pen().color());
p->drawPolygon(pts);
@@ -112,24 +112,26 @@
break;
case 11:
{
- QPolygon pts(4);
+ QPolygonF pts;
- pts.putPoints( 0, 4, int(x+s), int(y),
- int(x), int(y+s),
- int(x-s), int(y),
- int(x), int(y-s) );
+ pts << QPointF(x+s, y)
+ << QPointF(x, y+s)
+ << QPointF(x-s, y)
+ << QPointF(x, y-s);
+
p->setBrush(Qt::NoBrush);
p->drawPolygon(pts);
}
break;
case 12:
{
- QPolygon pts(4);
+ QPolygonF pts;
- pts.putPoints( 0, 4, int(x+s), int(y),
- int(x), int(y+s),
- int(x-s), int(y),
- int(x), int(y-s) );
+ pts << QPointF(x+s, y)
+ << QPointF(x, y+s)
+ << QPointF(x-s, y)
+ << QPointF(x, y-s);
+
p->setBrush(Qt::SolidPattern);
p->setBrush(p->pen().color());
p->drawPolygon(pts);
--- branches/work/kst/portto4/kst/src/widgets/dialogdefaults.cpp #1270949:1270950
@@ -27,7 +27,6 @@
_dialogDefaults->setValue("genVector/min", V->min());
_dialogDefaults->setValue("genVector/max", V->max());
_dialogDefaults->setValue("genVector/length", V->length());
- qDebug() << "set gen vector defaults:" << V->min() << V->max();
}
void setDataMatrixDefaults(DataMatrixPtr M) {
More information about the Kst
mailing list