p.drawPolygon(points, countof(points));
// Paint the text
- p.setPen((colour.lightness() > 64) ? Qt::black : Qt::white);
+ p.setPen(get_text_colour());
p.drawText(label_rect, Qt::AlignCenter | Qt::AlignVCenter, _name);
}
return _v_offset - _view->v_offset();
}
+QColor Trace::get_text_colour() const
+{
+ return (_colour.lightness() > 64) ? Qt::black : Qt::white;
+}
+
void Trace::paint_axis(QPainter &p, int y, int left, int right)
{
p.setPen(AxisPen);
*/
int get_y() const;
+ /**
+ * Gets the text colour.
+ * @remarks This colour is computed by comparing the lightness
+ * of the trace colour against a threshold to determine whether
+ * white or black would be more visible.
+ */
+ QColor get_text_colour() const;
+
/**
* Paints a zero axis across the viewport.
* @param p the QPainter to paint into.