From: Soeren Apel Date: Sun, 20 Aug 2017 14:18:50 +0000 (+0200) Subject: Convert threshold display setting to a multi-value choice X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=90ee1ed9a90bc0651f86ee4af07e0958572f86da;p=pulseview.git Convert threshold display setting to a multi-value choice --- diff --git a/pv/dialogs/settings.cpp b/pv/dialogs/settings.cpp index 76966f4c..1730e7ba 100644 --- a/pv/dialogs/settings.cpp +++ b/pv/dialogs/settings.cpp @@ -23,6 +23,7 @@ #include #include +#include #include #include #include @@ -169,11 +170,17 @@ QWidget *Settings::get_view_settings_form(QWidget *parent) const cb = create_checkbox(GlobalSettings::Key_View_ShowAnalogMinorGrid, SLOT(on_view_showAnalogMinorGrid_changed(int))); - trace_view_layout->addRow(tr("Show analog minor grid in addition to vdiv grid"), cb); - - cb = create_checkbox(GlobalSettings::Key_View_ShowConversionThresholds, - SLOT(on_view_showConversionThresholds_changed(int))); - trace_view_layout->addRow(tr("Show conversion thresholds in analog traces"), cb); + trace_view_layout->addRow(tr("Show analog minor grid in addition to div grid"), cb); + + QComboBox *thr_disp_mode_cb = new QComboBox(); + thr_disp_mode_cb->addItem(tr("None"), GlobalSettings::ConvThrDispMode_None); + thr_disp_mode_cb->addItem(tr("Background"), GlobalSettings::ConvThrDispMode_Background); + thr_disp_mode_cb->addItem(tr("Dots"), GlobalSettings::ConvThrDispMode_Dots); + thr_disp_mode_cb->setCurrentIndex( + settings.value(GlobalSettings::Key_View_ConversionThresholdDispMode).toInt()); + connect(thr_disp_mode_cb, SIGNAL(currentIndexChanged(int)), + this, SLOT(on_view_conversionThresholdDispMode_changed(int))); + trace_view_layout->addRow(tr("Conversion threshold display mode (analog traces only)"), thr_disp_mode_cb); QSpinBox *default_div_height_sb = new QSpinBox(); default_div_height_sb->setRange(20, 1000); @@ -441,10 +448,10 @@ void Settings::on_view_showAnalogMinorGrid_changed(int state) settings.setValue(GlobalSettings::Key_View_ShowAnalogMinorGrid, state ? true : false); } -void Settings::on_view_showConversionThresholds_changed(int state) +void Settings::on_view_conversionThresholdDispMode_changed(int state) { GlobalSettings settings; - settings.setValue(GlobalSettings::Key_View_ShowConversionThresholds, state ? true : false); + settings.setValue(GlobalSettings::Key_View_ConversionThresholdDispMode, state); } void Settings::on_view_defaultDivHeight_changed(int value) diff --git a/pv/dialogs/settings.hpp b/pv/dialogs/settings.hpp index 11277f7a..72c96125 100644 --- a/pv/dialogs/settings.hpp +++ b/pv/dialogs/settings.hpp @@ -56,7 +56,7 @@ private Q_SLOTS: void on_view_stickyScrolling_changed(int state); void on_view_showSamplingPoints_changed(int state); void on_view_showAnalogMinorGrid_changed(int state); - void on_view_showConversionThresholds_changed(int state); + void on_view_conversionThresholdDispMode_changed(int state); void on_view_defaultDivHeight_changed(int value); void on_view_defaultLogicHeight_changed(int value); void on_dec_initialStateConfigurable_changed(int state); diff --git a/pv/globalsettings.cpp b/pv/globalsettings.cpp index 895dda54..eabe4d3c 100644 --- a/pv/globalsettings.cpp +++ b/pv/globalsettings.cpp @@ -36,7 +36,7 @@ const QString GlobalSettings::Key_View_ColouredBG = "View_ColouredBG"; const QString GlobalSettings::Key_View_StickyScrolling = "View_StickyScrolling"; const QString GlobalSettings::Key_View_ShowSamplingPoints = "View_ShowSamplingPoints"; const QString GlobalSettings::Key_View_ShowAnalogMinorGrid = "View_ShowAnalogMinorGrid"; -const QString GlobalSettings::Key_View_ShowConversionThresholds = "View_ShowConversionThresholds"; +const QString GlobalSettings::Key_View_ConversionThresholdDispMode = "View_ConversionThresholdDispMode"; const QString GlobalSettings::Key_View_DefaultDivHeight = "View_DefaultDivHeight"; const QString GlobalSettings::Key_View_DefaultLogicHeight = "View_DefaultLogicHeight"; const QString GlobalSettings::Key_Dec_InitialStateConfigurable = "Dec_InitialStateConfigurable"; diff --git a/pv/globalsettings.hpp b/pv/globalsettings.hpp index 201c5e20..9cf2978b 100644 --- a/pv/globalsettings.hpp +++ b/pv/globalsettings.hpp @@ -46,11 +46,17 @@ public: static const QString Key_View_StickyScrolling; static const QString Key_View_ShowSamplingPoints; static const QString Key_View_ShowAnalogMinorGrid; - static const QString Key_View_ShowConversionThresholds; + static const QString Key_View_ConversionThresholdDispMode; static const QString Key_View_DefaultDivHeight; static const QString Key_View_DefaultLogicHeight; static const QString Key_Dec_InitialStateConfigurable; + enum ConvThrDispMode { + ConvThrDispMode_None = 0, + ConvThrDispMode_Background, + ConvThrDispMode_Dots + }; + public: GlobalSettings(); diff --git a/pv/views/trace/analogsignal.cpp b/pv/views/trace/analogsignal.cpp index a78d6554..ef6581fc 100644 --- a/pv/views/trace/analogsignal.cpp +++ b/pv/views/trace/analogsignal.cpp @@ -113,12 +113,12 @@ 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_ShowConversionThresholds, - bind(&AnalogSignal::on_settingViewShowConversionThresholds_changed, this, _1)); + GlobalSettings::register_change_handler(GlobalSettings::Key_View_ConversionThresholdDispMode, + bind(&AnalogSignal::on_settingViewConversionThresholdDispMode_changed, this, _1)); GlobalSettings gs; - show_conversion_thresholds_ = - gs.value(GlobalSettings::Key_View_ShowConversionThresholds).toBool(); + conversion_threshold_disp_mode_ = + gs.value(GlobalSettings::Key_View_ConversionThresholdDispMode).toInt(); div_height_ = gs.value(GlobalSettings::Key_View_DefaultDivHeight).toInt(); @@ -206,10 +206,13 @@ void AnalogSignal::paint_back(QPainter &p, ViewItemPaintParams &pp) if (!base_->enabled()) return; + 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(); @@ -1073,9 +1076,9 @@ void AnalogSignal::on_display_type_changed(int index) owner_->row_item_appearance_changed(false, true); } -void AnalogSignal::on_settingViewShowConversionThresholds_changed(const QVariant new_value) +void AnalogSignal::on_settingViewConversionThresholdDispMode_changed(const QVariant new_value) { - show_conversion_thresholds_ = new_value.toBool(); + conversion_threshold_disp_mode_ = new_value.toInt(); if (owner_) owner_->row_item_appearance_changed(false, true); diff --git a/pv/views/trace/analogsignal.hpp b/pv/views/trace/analogsignal.hpp index a36efce4..ffaac266 100644 --- a/pv/views/trace/analogsignal.hpp +++ b/pv/views/trace/analogsignal.hpp @@ -173,7 +173,7 @@ private Q_SLOTS: void on_display_type_changed(int index); - void on_settingViewShowConversionThresholds_changed(const QVariant new_value); + void on_settingViewConversionThresholdDispMode_changed(const QVariant new_value); private: QComboBox *resolution_cb_, *conversion_cb_, *conv_threshold_cb_, @@ -190,7 +190,7 @@ private: DisplayType display_type_; bool autoranging_; - bool show_conversion_thresholds_; + int conversion_threshold_disp_mode_; }; } // namespace trace