]> sigrok.org Git - pulseview.git/commitdiff
AnalogSignal: Add conversion type and display type
authorSoeren Apel <redacted>
Wed, 22 Mar 2017 22:07:41 +0000 (23:07 +0100)
committerSoeren Apel <redacted>
Wed, 22 Mar 2017 22:07:41 +0000 (23:07 +0100)
pv/view/analogsignal.cpp
pv/view/analogsignal.hpp

index 04f0a7fb84b97207b09a63f9143abe36293f54ae..1fe902251594e5e93dd9d40d2be71bbc4b39b617 100644 (file)
@@ -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
index a27f669681659f61c84cb7a7c737d00a5b17752a..5283a2c5e569d949ad9112da048432eeb7c87120 100644 (file)
@@ -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<data::SignalBase> 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_;
 };