+void AnalogSignal::paint_conversion_thresholds(QPainter &p,
+ ViewItemPaintParams &pp)
+{
+ if (!base_->enabled() || !base_->logic_data())
+ return;
+
+ // TODO Register a change handler instead of querying this with every repaint
+ GlobalSettings settings;
+ const bool show_conversion_thresholds =
+ settings.value(GlobalSettings::Key_View_ShowConversionThresholds).toBool();
+
+ if (!show_conversion_thresholds)
+ return;
+
+ const vector<double> thresholds = base_->get_conversion_thresholds();
+ const int y = get_visual_y();
+
+ p.setRenderHint(QPainter::Antialiasing, false);
+
+ p.setPen(ThresholdColor);
+
+ if (thresholds.size() == 2) {
+ // Draw as hatched block because two thresholds denote lower/upper level
+ const double thr_y0 = y - thresholds[0] * scale_;
+ const double thr_y1 = y - thresholds[1] * scale_;
+ p.fillRect(QRect(pp.left(), thr_y0, pp.right(), thr_y1 - thr_y0),
+ QBrush(ThresholdColor, Qt::BDiagPattern));
+ } else {
+ // Draw as individual lines
+ for (const double thr : thresholds) {
+ const double thr_y = y - thr * scale_;
+ p.drawLine(QPointF(pp.left(), thr_y), QPointF(pp.right(), thr_y));
+ }
+ }
+
+ p.setRenderHint(QPainter::Antialiasing, true);
+}
+