+ // Enable or disable widgets depending on conversion state
+ conv_threshold_cb_->setEnabled(conv_type != SignalBase::NoConversion);
+ display_type_cb_->setEnabled(conv_type != SignalBase::NoConversion);
+
+ conv_threshold_cb_->clear();
+
+ vector < pair<QString, int> > presets = base_->get_conversion_presets();
+
+ // Prevent the combo box from firing the "edit text changed" signal
+ // as that would involuntarily select the first entry
+ conv_threshold_cb_->blockSignals(true);
+
+ // Set available options depending on chosen conversion
+ for (pair<QString, int> preset : presets)
+ conv_threshold_cb_->addItem(preset.first, preset.second);
+
+ map < QString, QVariant > options = base_->get_conversion_options();
+
+ if (conv_type == SignalBase::A2LConversionByThreshold) {
+ const vector<double> thresholds = base_->get_conversion_thresholds(
+ SignalBase::A2LConversionByThreshold, true);
+ conv_threshold_cb_->addItem(
+ QString("%1V").arg(QString::number(thresholds[0], 'f', 1)), -1);
+ }
+
+ if (conv_type == SignalBase::A2LConversionBySchmittTrigger) {
+ const vector<double> thresholds = base_->get_conversion_thresholds(
+ SignalBase::A2LConversionBySchmittTrigger, true);
+ conv_threshold_cb_->addItem(QString("%1V/%2V").arg(
+ QString::number(thresholds[0], 'f', 1),
+ QString::number(thresholds[1], 'f', 1)), -1);
+ }
+
+ int preset_id = base_->get_current_conversion_preset();
+ conv_threshold_cb_->setCurrentIndex(
+ conv_threshold_cb_->findData(preset_id));
+
+ conv_threshold_cb_->blockSignals(false);
+}
+
+vector<data::LogicSegment::EdgePair> AnalogSignal::get_nearest_level_changes(uint64_t sample_pos)
+{
+ assert(base_);
+ assert(owner_);
+
+ // Return if there's no logic data or we're showing only the analog trace
+ if (!base_->logic_data() || (display_type_ == DisplayAnalog))
+ return vector<data::LogicSegment::EdgePair>();
+
+ if (sample_pos == 0)
+ return vector<LogicSegment::EdgePair>();
+
+ shared_ptr<LogicSegment> segment = get_logic_segment_to_paint();
+ if (!segment || (segment->get_sample_count() == 0))
+ return vector<LogicSegment::EdgePair>();
+
+ const View *view = owner_->view();
+ assert(view);
+ const double samples_per_pixel = base_->get_samplerate() * view->scale();
+
+ vector<LogicSegment::EdgePair> edges;
+
+ segment->get_surrounding_edges(edges, sample_pos,
+ samples_per_pixel / LogicSignal::Oversampling, 0);
+
+ if (edges.empty())
+ return vector<LogicSegment::EdgePair>();
+
+ return edges;