Trace/AnalogSignal: Improve contrast and precision of the trace lines
authorSoeren Apel <soeren@apelpie.net>
Wed, 13 Apr 2016 17:45:22 +0000 (19:45 +0200)
committerSoeren Apel <soeren@apelpie.net>
Wed, 13 Apr 2016 17:45:22 +0000 (19:45 +0200)
pv/view/analogsignal.cpp
pv/view/trace.cpp

index 7e5bcd11facdb6d1a81368c27fd866da1afc6ff9..e0add7aaedc64e7a116ea2bc4229dd4e25ab6583 100644 (file)
@@ -58,8 +58,8 @@ const QColor AnalogSignal::SignalColours[4] = {
        QColor(0x4E, 0x9A, 0x06)        // Green
 };
 
        QColor(0x4E, 0x9A, 0x06)        // Green
 };
 
-const QColor AnalogSignal::GridMajorColor = QColor(0xB0, 0xB0, 0xB0);
-const QColor AnalogSignal::GridMinorColor = QColor(0xD0, 0xD0, 0xD0);
+const QColor AnalogSignal::GridMajorColor = QColor(0, 0, 0, 40*256/100);
+const QColor AnalogSignal::GridMinorColor = QColor(0, 0, 0, 20*256/100);
 
 const float AnalogSignal::EnvelopeThreshold = 256.0f;
 
 
 const float AnalogSignal::EnvelopeThreshold = 256.0f;
 
@@ -200,16 +200,18 @@ void AnalogSignal::paint_fore(QPainter &p, const ViewItemPaintParams &pp)
 
 void AnalogSignal::paint_grid(QPainter &p, int y, int left, int right)
 {
 
 void AnalogSignal::paint_grid(QPainter &p, int y, int left, int right)
 {
-       p.setPen(QPen(GridMajorColor, 0.5, Qt::DashLine));
+       p.setRenderHint(QPainter::Antialiasing, false);
+
+       p.setPen(QPen(GridMajorColor, 1, Qt::DashLine));
        for (int i = 1; i <= vdivs_; i++) {
        for (int i = 1; i <= vdivs_; i++) {
-               const int dy = i * div_height_;
+               const float dy = i * div_height_;
                p.drawLine(QLineF(left, y - dy, right, y - dy));
                p.drawLine(QLineF(left, y + dy, right, y + dy));
        }
 
                p.drawLine(QLineF(left, y - dy, right, y - dy));
                p.drawLine(QLineF(left, y + dy, right, y + dy));
        }
 
-       p.setPen(QPen(GridMinorColor, 0.5, Qt::DashLine));
+       p.setPen(QPen(GridMinorColor, 1, Qt::DashLine));
        for (int i = 0; i < vdivs_; i++) {
        for (int i = 0; i < vdivs_; i++) {
-               const int dy = i * div_height_;
+               const float dy = i * div_height_;
                const float dy25 = dy + (0.25 * div_height_);
                const float dy50 = dy + (0.50 * div_height_);
                const float dy75 = dy + (0.75 * div_height_);
                const float dy25 = dy + (0.25 * div_height_);
                const float dy50 = dy + (0.50 * div_height_);
                const float dy75 = dy + (0.75 * div_height_);
@@ -220,6 +222,8 @@ void AnalogSignal::paint_grid(QPainter &p, int y, int left, int right)
                p.drawLine(QLineF(left, y - dy75, right, y - dy75));
                p.drawLine(QLineF(left, y + dy75, right, y + dy75));
        }
                p.drawLine(QLineF(left, y - dy75, right, y - dy75));
                p.drawLine(QLineF(left, y + dy75, right, y + dy75));
        }
+
+       p.setRenderHint(QPainter::Antialiasing, true);
 }
 
 void AnalogSignal::paint_trace(QPainter &p,
 }
 
 void AnalogSignal::paint_trace(QPainter &p,
index 264541cf18c09f4ca9e5e7b9aebe4431209c22e4..fd6107f63acc9e643518226525593b012ac61485 100644 (file)
@@ -38,7 +38,7 @@
 namespace pv {
 namespace view {
 
 namespace pv {
 namespace view {
 
-const QPen Trace::AxisPen(QColor(128, 128, 128, 64));
+const QPen Trace::AxisPen(QColor(0, 0, 0, 30*256/100));
 const int Trace::LabelHitPadding = 2;
 
 const QColor Trace::DarkBGColour(235, 235, 235);    // Quite light grey
 const int Trace::LabelHitPadding = 2;
 
 const QColor Trace::DarkBGColour(235, 235, 235);    // Quite light grey
@@ -196,8 +196,12 @@ void Trace::paint_back(QPainter &p, const ViewItemPaintParams &pp)
 
 void Trace::paint_axis(QPainter &p, const ViewItemPaintParams &pp, int y)
 {
 
 void Trace::paint_axis(QPainter &p, const ViewItemPaintParams &pp, int y)
 {
+       p.setRenderHint(QPainter::Antialiasing, false);
+
        p.setPen(AxisPen);
        p.setPen(AxisPen);
-       p.drawLine(QPointF(pp.left(), y + 0.5f), QPointF(pp.right(), y + 0.5f));
+       p.drawLine(QPointF(pp.left(), y), QPointF(pp.right(), y));
+
+       p.setRenderHint(QPainter::Antialiasing, true);
 }
 
 void Trace::add_colour_option(QWidget *parent, QFormLayout *form)
 }
 
 void Trace::add_colour_option(QWidget *parent, QFormLayout *form)