X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Flogicsignal.cpp;h=d529cabfb80eab75edcb8ccce37d1b5033dd2f1a;hp=c6b7cffa361253495c2a2d7c541de7920660a292;hb=bf9146988d2298e1750142dccdcf597ef13d6606;hpb=08d9c3caec0a3ad1c624af685f948e17b91d278a diff --git a/pv/view/logicsignal.cpp b/pv/view/logicsignal.cpp index c6b7cffa..d529cabf 100644 --- a/pv/view/logicsignal.cpp +++ b/pv/view/logicsignal.cpp @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -49,7 +50,6 @@ using std::vector; using sigrok::Channel; using sigrok::ConfigKey; -using sigrok::Device; using sigrok::Error; using sigrok::Trigger; using sigrok::TriggerStage; @@ -99,18 +99,18 @@ QCache LogicSignal::pixmap_cache_; LogicSignal::LogicSignal( pv::Session &session, - shared_ptr device, + shared_ptr device, shared_ptr channel, shared_ptr data) : Signal(session, channel), device_(device), data_(data), - trigger_none_(NULL), - trigger_rising_(NULL), - trigger_high_(NULL), - trigger_falling_(NULL), - trigger_low_(NULL), - trigger_change_(NULL) + trigger_none_(nullptr), + trigger_rising_(nullptr), + trigger_high_(nullptr), + trigger_falling_(nullptr), + trigger_low_(nullptr), + trigger_change_(nullptr) { shared_ptr trigger; @@ -140,6 +140,11 @@ shared_ptr LogicSignal::logic_data() const return data_; } +void LogicSignal::set_logic_data(std::shared_ptr data) +{ + data_ = data; +} + std::pair LogicSignal::v_extents() const { return make_pair(-SignalHeight - SignalMargin, SignalMargin); @@ -184,15 +189,18 @@ void LogicSignal::paint_mid(QPainter &p, const ViewItemPaintParams &pp) samplerate = 1.0; const double pixels_offset = pp.pixels_offset(); - const double start_time = segment->start_time(); + const pv::util::Timestamp& start_time = segment->start_time(); const int64_t last_sample = segment->get_sample_count() - 1; const double samples_per_pixel = samplerate * pp.scale(); - const double start = samplerate * (pp.offset() - start_time); - const double end = start + samples_per_pixel * pp.width(); + const pv::util::Timestamp start = samplerate * (pp.offset() - start_time); + const pv::util::Timestamp end = start + samples_per_pixel * pp.width(); - segment->get_subsampled_edges(edges, - min(max((int64_t)floor(start), (int64_t)0), last_sample), - min(max((int64_t)ceil(end), (int64_t)0), last_sample), + const int64_t start_sample = min(max(floor(start).convert_to(), + (int64_t)0), last_sample); + const uint64_t end_sample = min(max(ceil(end).convert_to(), + (int64_t)0), last_sample); + + segment->get_subsampled_edges(edges, start_sample, end_sample, samples_per_pixel / Oversampling, channel_->index()); assert(edges.size() >= 2); @@ -316,13 +324,14 @@ void LogicSignal::init_trigger_actions(QWidget *parent) const vector LogicSignal::get_trigger_types() const { - const auto keys = device_->config_keys(ConfigKey::DEVICE_OPTIONS); + const auto sr_dev = device_->device(); + const auto keys = sr_dev->config_keys(ConfigKey::DEVICE_OPTIONS); const auto iter = keys.find(ConfigKey::TRIGGER_MATCH); if (iter != keys.end() && (*iter).second.find(sigrok::LIST) != (*iter).second.end()) { try { const Glib::VariantContainerBase gvar = - device_->config_list(ConfigKey::TRIGGER_MATCH); + sr_dev->config_list(ConfigKey::TRIGGER_MATCH); return Glib::VariantBase::cast_dynamic< Glib::Variant>>(gvar).get(); } catch (Error e) { @@ -384,21 +393,23 @@ void LogicSignal::populate_popup_form(QWidget *parent, QFormLayout *form) { Signal::populate_popup_form(parent, form); - trigger_bar_ = new QToolBar(parent); - init_trigger_actions(trigger_bar_); - trigger_bar_->addAction(trigger_none_); - trigger_none_->setChecked(!trigger_match_); - const vector trig_types = get_trigger_types(); - for (auto type_id : trig_types) { - const TriggerMatchType *const type = - TriggerMatchType::get(type_id); - QAction *const action = action_from_trigger_type(type); - trigger_bar_->addAction(action); - action->setChecked(trigger_match_ == type); - } - form->addRow(tr("Trigger"), trigger_bar_); + if (!trig_types.empty()) { + trigger_bar_ = new QToolBar(parent); + init_trigger_actions(trigger_bar_); + trigger_bar_->addAction(trigger_none_); + trigger_none_->setChecked(!trigger_match_); + + for (auto type_id : trig_types) { + const TriggerMatchType *const type = + TriggerMatchType::get(type_id); + QAction *const action = action_from_trigger_type(type); + trigger_bar_->addAction(action); + action->setChecked(trigger_match_ == type); + } + form->addRow(tr("Trigger"), trigger_bar_); + } } void LogicSignal::modify_trigger() @@ -409,7 +420,7 @@ void LogicSignal::modify_trigger() if (trigger) { for (auto stage : trigger->stages()) { const auto &matches = stage->matches(); - if (std::none_of(begin(matches), end(matches), + if (std::none_of(matches.begin(), matches.end(), [&](shared_ptr match) { return match->channel() != channel_; })) continue;