X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fviews%2Ftrace%2Fanalogsignal.cpp;h=ef6581fc1dd90ba46edfa27a2a886d3da914f471;hb=90ee1ed9a90bc0651f86ee4af07e0958572f86da;hp=58a186ecf0229cd28e7a2bd134f9e76613205667;hpb=1d150cd6ea6d9c465d607377bba435a065f104cd;p=pulseview.git diff --git a/pv/views/trace/analogsignal.cpp b/pv/views/trace/analogsignal.cpp index 58a186e..ef6581f 100644 --- a/pv/views/trace/analogsignal.cpp +++ b/pv/views/trace/analogsignal.cpp @@ -46,6 +46,7 @@ #include +using std::bind; using std::deque; using std::div; using std::div_t; @@ -54,6 +55,7 @@ using std::make_pair; using std::min; using std::numeric_limits; using std::pair; +using std::placeholders::_1; using std::shared_ptr; using std::vector; @@ -78,7 +80,7 @@ const QColor AnalogSignal::SamplingPointColour(0x77, 0x77, 0x77); 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) @@ -111,7 +113,13 @@ AnalogSignal::AnalogSignal( 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)]); @@ -198,15 +206,13 @@ void AnalogSignal::paint_back(QPainter &p, ViewItemPaintParams &pp) 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 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(); @@ -1070,6 +1076,14 @@ void AnalogSignal::on_display_type_changed(int index) 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