From: Soeren Apel Date: Wed, 22 Mar 2017 22:07:41 +0000 (+0100) Subject: AnalogSignal: Add conversion type and display type X-Git-Tag: pulseview-0.4.0~134 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=a970015f3aac1e13a5ed2e19a60ac304b1397d1c;p=pulseview.git AnalogSignal: Add conversion type and display type --- diff --git a/pv/view/analogsignal.cpp b/pv/view/analogsignal.cpp index 04f0a7fb..1fe90225 100644 --- a/pv/view/analogsignal.cpp +++ b/pv/view/analogsignal.cpp @@ -87,6 +87,8 @@ AnalogSignal::AnalogSignal( pos_vdivs_(1), neg_vdivs_(1), resolution_(0), + conversion_type_(data::SignalBase::NoConversion), + display_type_(DisplayBoth), autoranging_(true) { pv::data::Analog* analog_data = @@ -109,6 +111,8 @@ void AnalogSignal::save_settings(QSettings &settings) const settings.setValue("pos_vdivs", pos_vdivs_); settings.setValue("neg_vdivs", neg_vdivs_); settings.setValue("scale_index", scale_index_); + settings.setValue("conversion_type", conversion_type_); + settings.setValue("display_type", display_type_); settings.setValue("autoranging", autoranging_); } @@ -125,6 +129,12 @@ void AnalogSignal::restore_settings(QSettings &settings) update_scale(); } + if (settings.contains("conversion_type")) + conversion_type_ = (data::SignalBase::ConversionType)(settings.value("conversion_type").toInt()); + + if (settings.contains("display_type")) + display_type_ = (DisplayType)(settings.value("display_type").toInt()); + if (settings.contains("autoranging")) autoranging_ = settings.value("autoranging").toBool(); } @@ -468,7 +478,7 @@ void AnalogSignal::populate_popup_form(QWidget *parent, QFormLayout *form) resolution_cb_->insertItem(0, label, QVariant(i)); } - const int cur_idx = resolution_cb_->findData(QVariant(scale_index_)); + int cur_idx = resolution_cb_->findData(QVariant(scale_index_)); resolution_cb_->setCurrentIndex(cur_idx); connect(resolution_cb_, SIGNAL(currentIndexChanged(int)), @@ -490,6 +500,33 @@ void AnalogSignal::populate_popup_form(QWidget *parent, QFormLayout *form) layout->addRow(tr("Autoranging"), autoranging_cb); + // Add the conversion type dropdown + conversion_cb_ = new QComboBox(); + + conversion_cb_->addItem("none", data::SignalBase::NoConversion); + conversion_cb_->addItem("to logic via threshold", data::SignalBase::A2LConversionByTreshold); + conversion_cb_->addItem("to logic via schmitt-trigger", data::SignalBase::A2LConversionBySchmittTrigger); + + cur_idx = conversion_cb_->findData(QVariant(conversion_type_)); + conversion_cb_->setCurrentIndex(cur_idx); + + layout->addRow(tr("Conversion"), conversion_cb_); + + connect(conversion_cb_, SIGNAL(currentIndexChanged(int)), + this, SLOT(on_conversion_changed(int))); + + // Add the display type dropdown + display_type_cb_ = new QComboBox(); + + display_type_cb_->addItem(tr("Analog"), DisplayAnalog); + display_type_cb_->addItem(tr("Converted"), DisplayConverted); + display_type_cb_->addItem(tr("Both"), DisplayBoth); + + cur_idx = display_type_cb_->findData(QVariant(display_type_)); + display_type_cb_->setCurrentIndex(cur_idx); + + layout->addRow(tr("Traces to show:"), display_type_cb_); + form->addRow(layout); } @@ -555,6 +592,12 @@ void AnalogSignal::on_autoranging_changed(int state) } } +void AnalogSignal::on_conversion_changed(int index) +{ + conversion_type_ = (data::SignalBase::ConversionType)(conversion_cb_->itemData(index).toInt()); + base_->set_conversion_type(conversion_type_); +} + } // namespace TraceView } // namespace views } // namespace pv diff --git a/pv/view/analogsignal.hpp b/pv/view/analogsignal.hpp index a27f6696..5283a2c5 100644 --- a/pv/view/analogsignal.hpp +++ b/pv/view/analogsignal.hpp @@ -55,6 +55,12 @@ private: static const int MaxScaleIndex, MinScaleIndex; static const int InfoTextMarginRight, InfoTextMarginBottom; + enum DisplayType { + DisplayAnalog = 0, + DisplayConverted = 1, + DisplayBoth = 2 + }; + public: AnalogSignal(pv::Session &session, shared_ptr base); @@ -144,8 +150,10 @@ private Q_SLOTS: void on_autoranging_changed(int state); + void on_conversion_changed(int index); + private: - QComboBox *resolution_cb_; + QComboBox *resolution_cb_, *conversion_cb_, *display_type_cb_; float scale_; int scale_index_; @@ -155,6 +163,8 @@ private: int pos_vdivs_, neg_vdivs_; // divs per positive/negative side float resolution_; // e.g. 10 for 10 V/div + data::SignalBase::ConversionType conversion_type_; + DisplayType display_type_; bool autoranging_; };