[rkward-cvs] SF.net SVN: rkward-code:[4750] trunk/rkward/rkward/rbackend/rkwarddevice
tfry at users.sf.net
tfry at users.sf.net
Mon May 13 12:02:46 UTC 2013
Revision: 4750
http://sourceforge.net/p/rkward/code/4750
Author: tfry
Date: 2013-05-13 12:02:45 +0000 (Mon, 13 May 2013)
Log Message:
-----------
Make sure to replicate line width calculations from devX11.c more diligently.
Most importantly, however, work around a Qt bug that makes QPainter::drawLine and QPainter::drawPolyline mismatch.
Modified Paths:
--------------
trunk/rkward/rkward/rbackend/rkwarddevice/rkgraphicsdevice.cpp
trunk/rkward/rkward/rbackend/rkwarddevice/rkgraphicsdevice_frontendtransmitter.cpp
trunk/rkward/rkward/rbackend/rkwarddevice/rkgraphicsdevice_frontendtransmitter.h
trunk/rkward/rkward/rbackend/rkwarddevice/rkgraphicsdevice_setup.cpp
Modified: trunk/rkward/rkward/rbackend/rkwarddevice/rkgraphicsdevice.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rkwarddevice/rkgraphicsdevice.cpp 2013-05-11 08:05:37 UTC (rev 4749)
+++ trunk/rkward/rkward/rbackend/rkwarddevice/rkgraphicsdevice.cpp 2013-05-13 12:02:45 UTC (rev 4750)
@@ -160,7 +160,15 @@
RK_TRACE (GRAPHICS_DEVICE);
painter.setPen (pen);
- painter.drawLine (x1, y1, x2, y2);
+ // HACK: There seems to be a bug in QPainter (Qt 4.8.4), which can shift connected lines (everything but the first polyline)
+ // towards the direction where the previous line came from. The result is that line drawn via drawLine() and drawPolyline() do
+ // not match, exactly. This is particularly evident for the plot frame.
+ // We hack around this, by doing all line drawing via drawPolyline.
+ QPointF points [2];
+ points[0] = QPointF (x1, y1);
+ points[1] = QPointF (x2, y2);
+ painter.drawPolyline (points, 2);
+// painter.drawLine (x1, y1, x2, y2);
triggerUpdate ();
}
Modified: trunk/rkward/rkward/rbackend/rkwarddevice/rkgraphicsdevice_frontendtransmitter.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rkwarddevice/rkgraphicsdevice_frontendtransmitter.cpp 2013-05-11 08:05:37 UTC (rev 4749)
+++ trunk/rkward/rkward/rbackend/rkwarddevice/rkgraphicsdevice_frontendtransmitter.cpp 2013-05-13 12:02:45 UTC (rev 4750)
@@ -35,6 +35,7 @@
#include "../../debug.h"
+double RKGraphicsDeviceFrontendTransmitter::lwdscale = 72/96;
RKGraphicsDeviceFrontendTransmitter::RKGraphicsDeviceFrontendTransmitter () : QObject () {
RK_TRACE (GRAPHICS_DEVICE);
@@ -104,7 +105,7 @@
instream >> lwd >> lty;
if (!col.isValid () || (lty == -1L)) return QPen (Qt::NoPen);
- lwd = qMax (1.0001, lwd); // minimum 1 px (+rounding margin!) as in X11 device
+ lwd = qMax (1.0, lwd); // minimum 1 px as in X11 device
QPen ret;
if (lty != 0) { // solid
QVector<qreal> dashes;
@@ -112,12 +113,13 @@
for (int i = 0; i < 8; ++i) {
if (!nlty) break;
quint8 j = nlty & 0xF;
- dashes.append (j * lwd * 96/72 + .5); // 96/72: value taken from X11 device
+ if (j < 1) j = 1;
+ dashes.append ((int) (j * lwd * RKGraphicsDeviceFrontendTransmitter::lwdscale + .5));
nlty >>= 4;
}
if (!dashes.isEmpty ()) ret.setDashPattern (dashes);
}
- ret.setWidthF (lwd);
+ ret.setWidth ((int) (lwd * RKGraphicsDeviceFrontendTransmitter::lwdscale + .5));
ret.setColor (col);
return ret;
}
@@ -196,7 +198,10 @@
} else if (opcode == RKDQueryResolution) {
QDesktopWidget *desktop = QApplication::desktop ();
streamer.outstream << (qint32) desktop->physicalDpiX () << (qint32) desktop->physicalDpiY ();
+ RK_DEBUG (GRAPHICS_DEVICE, DL_INFO, "DPI for device %d: %d by %d", devnum+1, desktop->physicalDpiX (), desktop->physicalDpiY ());
streamer.writeOutBuffer ();
+ // Actually, this is only needed once, but where to put it...
+ RKGraphicsDeviceFrontendTransmitter::lwdscale = desktop->physicalDpiX () / 96; // taken from devX11.c
} else {
if (devnum) RK_DEBUG (GRAPHICS_DEVICE, DL_ERROR, "Received transmission of type %d for unknown device number %d. Skippping.", opcode, devnum+1);
sendDummyReply (opcode);
Modified: trunk/rkward/rkward/rbackend/rkwarddevice/rkgraphicsdevice_frontendtransmitter.h
===================================================================
--- trunk/rkward/rkward/rbackend/rkwarddevice/rkgraphicsdevice_frontendtransmitter.h 2013-05-11 08:05:37 UTC (rev 4749)
+++ trunk/rkward/rkward/rbackend/rkwarddevice/rkgraphicsdevice_frontendtransmitter.h 2013-05-13 12:02:45 UTC (rev 4750)
@@ -32,6 +32,7 @@
RKGraphicsDeviceFrontendTransmitter ();
~RKGraphicsDeviceFrontendTransmitter ();
QString serverName () const { return server_name; };
+ static double lwdscale;
public slots:
void newData ();
void newConnection ();
Modified: trunk/rkward/rkward/rbackend/rkwarddevice/rkgraphicsdevice_setup.cpp
===================================================================
--- trunk/rkward/rkward/rbackend/rkwarddevice/rkgraphicsdevice_setup.cpp 2013-05-11 08:05:37 UTC (rev 4749)
+++ trunk/rkward/rkward/rbackend/rkwarddevice/rkgraphicsdevice_setup.cpp 2013-05-13 12:02:45 UTC (rev 4750)
@@ -139,7 +139,7 @@
dev->cra[1] = 1.2 * pointsize * (dpiy / RKGD_DPI);
dev->xCharOffset = 0.4900;
dev->yCharOffset = 0.3333;
- dev->yLineBias = 0.1;
+ dev->yLineBias = 0.2;
dev->ipr[0] = 1.0 / dpix;
dev->ipr[1] = 1.0 / dpiy;
/*
More information about the rkward-tracker
mailing list