X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fanalogsignal.cpp;h=1fe902251594e5e93dd9d40d2be71bbc4b39b617;hp=3c3e5d0571a36a896c91441fe9ef27321bd83cbe;hb=a970015f3aac1e13a5ed2e19a60ac304b1397d1c;hpb=8de1e1b2fb1bcaaa21f08b7bba412b0839d6c4d2 diff --git a/pv/view/analogsignal.cpp b/pv/view/analogsignal.cpp index 3c3e5d05..1fe90225 100644 --- a/pv/view/analogsignal.cpp +++ b/pv/view/analogsignal.cpp @@ -42,11 +42,15 @@ #include +using std::deque; +using std::div; +using std::div_t; using std::max; using std::make_pair; using std::min; +using std::numeric_limits; +using std::pair; using std::shared_ptr; -using std::deque; namespace pv { namespace views { @@ -83,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 = @@ -105,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_); } @@ -121,11 +129,17 @@ 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(); } -std::pair AnalogSignal::v_extents() const +pair AnalogSignal::v_extents() const { const int ph = pos_vdivs_ * div_height_; const int nh = neg_vdivs_ * div_height_; @@ -309,7 +323,8 @@ void AnalogSignal::paint_trace(QPainter &p, GlobalSettings settings; const bool show_sampling_points = settings.value(GlobalSettings::Key_View_ShowSamplingPoints).toBool(); - if (show_sampling_points) { + + if (show_sampling_points && (samples_per_pixel < 0.25)) { p.setPen(SamplingPointColour); p.drawRects(sampling_points, points_count); } @@ -367,9 +382,8 @@ float AnalogSignal::get_resolution(int scale_index) { const float seq[] = {1.0f, 2.0f, 5.0f}; - const int offset = std::numeric_limits::max() / (2 * countof(seq)); - const std::div_t d = std::div( - (int)(scale_index + countof(seq) * offset), + const int offset = numeric_limits::max() / (2 * countof(seq)); + const div_t d = div((int)(scale_index + countof(seq) * offset), countof(seq)); return powf(10.0f, d.quot - offset) * seq[d.rem]; @@ -393,7 +407,7 @@ void AnalogSignal::perform_autoranging(bool force_update) double min = 0, max = 0; for (shared_ptr segment : segments) { - std::pair mm = segment->get_min_max(); + pair mm = segment->get_min_max(); min = std::min(min, mm.first); max = std::max(max, mm.second); } @@ -464,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)), @@ -486,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); } @@ -551,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