#include <libsigrokcxx/libsigrokcxx.hpp>
+using std::bind;
using std::deque;
using std::div;
using std::div_t;
using std::min;
using std::numeric_limits;
using std::pair;
+using std::placeholders::_1;
using std::shared_ptr;
using std::vector;
const QColor AnalogSignal::ThresholdColor = QColor(0, 0, 0, 30 * 256 / 100);
const QColor AnalogSignal::ThresholdColorLo = QColor(255, 0, 0, 8 * 256 / 100);
-const QColor AnalogSignal::ThresholdColorNe = QColor(0, 0, 0, 6 * 256 / 100);
+const QColor AnalogSignal::ThresholdColorNe = QColor(0, 0, 0, 10 * 256 / 100);
const QColor AnalogSignal::ThresholdColorHi = QColor(0, 255, 0, 8 * 256 / 100);
const int64_t AnalogSignal::TracePaintBlockSize = 1024 * 1024; // 4 MiB (due to float)
connect(analog_data, SIGNAL(min_max_changed(float, float)),
this, SLOT(on_min_max_changed(float, float)));
+ GlobalSettings::register_change_handler(GlobalSettings::Key_View_ConversionThresholdDispMode,
+ bind(&AnalogSignal::on_settingViewConversionThresholdDispMode_changed, this, _1));
+
GlobalSettings gs;
+ conversion_threshold_disp_mode_ =
+ gs.value(GlobalSettings::Key_View_ConversionThresholdDispMode).toInt();
+
div_height_ = gs.value(GlobalSettings::Key_View_DefaultDivHeight).toInt();
base_->set_colour(SignalColours[base_->index() % countof(SignalColours)]);
if (!base_->enabled())
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();
+ bool paint_thr_bg =
+ conversion_threshold_disp_mode_ == GlobalSettings::ConvThrDispMode_Background;
const vector<double> thresholds = base_->get_conversion_thresholds();
// Only display thresholds if we have some and we show analog samples
- if ((thresholds.size() > 0) && show_conversion_thresholds &&
+ if ((thresholds.size() > 0) && paint_thr_bg &&
((display_type_ == DisplayAnalog) || (display_type_ == DisplayBoth))) {
const int visual_y = get_visual_y();
owner_->row_item_appearance_changed(false, true);
}
+void AnalogSignal::on_settingViewConversionThresholdDispMode_changed(const QVariant new_value)
+{
+ conversion_threshold_disp_mode_ = new_value.toInt();
+
+ if (owner_)
+ owner_->row_item_appearance_changed(false, true);
+}
+
} // namespace trace
} // namespace views
} // namespace pv