X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fview%2Fdecodetrace.cpp;h=ec441df40e055b5545f745fbe4a773904602c38b;hp=0a624c311d9df9693ee0e5482957ec20fd3b2275;hb=7df44935d55572baa53fce9ce4e8e3258b2d5ecb;hpb=aca9aa834c742ba70f49d1ac3eb2d1e02e759416 diff --git a/pv/view/decodetrace.cpp b/pv/view/decodetrace.cpp index 0a624c31..ec441df4 100644 --- a/pv/view/decodetrace.cpp +++ b/pv/view/decodetrace.cpp @@ -170,13 +170,13 @@ pair DecodeTrace::v_extents() const return make_pair(-row_height, row_height * row_count); } -void DecodeTrace::paint_back(QPainter &p, const ViewItemPaintParams &pp) +void DecodeTrace::paint_back(QPainter &p, ViewItemPaintParams &pp) { Trace::paint_back(p, pp); paint_axis(p, pp, get_visual_y()); } -void DecodeTrace::paint_mid(QPainter &p, const ViewItemPaintParams &pp) +void DecodeTrace::paint_mid(QPainter &p, ViewItemPaintParams &pp) { using namespace pv::data::decode; @@ -248,7 +248,7 @@ void DecodeTrace::paint_mid(QPainter &p, const ViewItemPaintParams &pp) max_visible_rows_ = max(max_visible_rows_, (int)visible_rows_.size()); } -void DecodeTrace::paint_fore(QPainter &p, const ViewItemPaintParams &pp) +void DecodeTrace::paint_fore(QPainter &p, ViewItemPaintParams &pp) { using namespace pv::data::decode; @@ -333,6 +333,7 @@ void DecodeTrace::populate_popup_form(QWidget *parent, QFormLayout *form) QPushButton *const stack_button = new QPushButton(tr("Stack Decoder"), parent); stack_button->setMenu(decoder_menu); + stack_button->setToolTip(tr("Stack a higher-level decoder on top of this one")); QHBoxLayout *stack_button_box = new QHBoxLayout; stack_button_box->addWidget(stack_button, 0, Qt::AlignRight); @@ -483,11 +484,17 @@ void DecodeTrace::draw_annotation_block( annotations.begin(), annotations.end(), [&](const Annotation &a) { return a.format() == format; }); + const QRectF rect(start, top, end - start, bottom - top); + const int r = h / 4; + + p.setPen(QPen(Qt::NoPen)); + p.setBrush(Qt::white); + p.drawRoundedRect(rect, r, r); + p.setPen((single_format ? OutlineColours[colour] : Qt::gray)); p.setBrush(QBrush((single_format ? Colours[colour] : Qt::gray), Qt::Dense4Pattern)); - p.drawRoundedRect( - QRectF(start, top, end - start, bottom - top), h / 4, h / 4); + p.drawRoundedRect(rect, r, r); } void DecodeTrace::draw_instant(const pv::data::decode::Annotation &a, QPainter &p, @@ -783,7 +790,10 @@ void DecodeTrace::create_decoder_form(int index, pv::widgets::DecoderGroupBox *const group = new pv::widgets::DecoderGroupBox( - QString::fromUtf8(decoder->name), nullptr, decoder_deletable); + QString::fromUtf8(decoder->name), + tr("%1:\n%2").arg(QString::fromUtf8(decoder->longname), + QString::fromUtf8(decoder->desc)), + nullptr, decoder_deletable); group->set_decoder_visible(dec->shown()); if (decoder_deletable) { @@ -802,14 +812,24 @@ void DecodeTrace::create_decoder_form(int index, for (l = decoder->channels; l; l = l->next) { const struct srd_channel *const pdch = (struct srd_channel *)l->data; + QComboBox *const combo = create_channel_selector(parent, dec, pdch); + QComboBox *const combo_initial_pin = create_channel_selector_initial_pin(parent, dec, pdch); + connect(combo, SIGNAL(currentIndexChanged(int)), this, SLOT(on_channel_selected(int))); + connect(combo_initial_pin, SIGNAL(currentIndexChanged(int)), + this, SLOT(on_initial_pin_selected(int))); + + QHBoxLayout *const hlayout = new QHBoxLayout; + hlayout->addWidget(combo); + hlayout->addWidget(combo_initial_pin); + decoder_form->addRow(tr("%1 (%2) *") .arg(QString::fromUtf8(pdch->name), - QString::fromUtf8(pdch->desc)), combo); + QString::fromUtf8(pdch->desc)), hlayout); - const ChannelSelector s = {combo, dec, pdch}; + const ChannelSelector s = {combo, combo_initial_pin, dec, pdch}; channel_selectors_.push_back(s); } @@ -817,14 +837,24 @@ void DecodeTrace::create_decoder_form(int index, for (l = decoder->opt_channels; l; l = l->next) { const struct srd_channel *const pdch = (struct srd_channel *)l->data; + QComboBox *const combo = create_channel_selector(parent, dec, pdch); + QComboBox *const combo_initial_pin = create_channel_selector_initial_pin(parent, dec, pdch); + connect(combo, SIGNAL(currentIndexChanged(int)), this, SLOT(on_channel_selected(int))); + connect(combo_initial_pin, SIGNAL(currentIndexChanged(int)), + this, SLOT(on_initial_pin_selected(int))); + + QHBoxLayout *const hlayout = new QHBoxLayout; + hlayout->addWidget(combo); + hlayout->addWidget(combo_initial_pin); + decoder_form->addRow(tr("%1 (%2)") .arg(QString::fromUtf8(pdch->name), - QString::fromUtf8(pdch->desc)), combo); + QString::fromUtf8(pdch->desc)), hlayout); - const ChannelSelector s = {combo, dec, pdch}; + const ChannelSelector s = {combo, combo_initial_pin, dec, pdch}; channel_selectors_.push_back(s); } @@ -881,6 +911,24 @@ QComboBox* DecodeTrace::create_channel_selector( return selector; } +QComboBox* DecodeTrace::create_channel_selector_initial_pin(QWidget *parent, + const shared_ptr &dec, const srd_channel *const pdch) +{ + QComboBox *selector = new QComboBox(parent); + + selector->addItem("0", qVariantFromValue((int)SRD_INITIAL_PIN_LOW)); + selector->addItem("1", qVariantFromValue((int)SRD_INITIAL_PIN_HIGH)); + selector->addItem("X", qVariantFromValue((int)SRD_INITIAL_PIN_SAME_AS_SAMPLE0)); + + // Default to index 2 (SRD_INITIAL_PIN_SAME_AS_SAMPLE0). + const int idx = (!dec->initial_pins()) ? 2 : dec->initial_pins()->data[pdch->order]; + selector->setCurrentIndex(idx); + + selector->setToolTip("Initial (assumed) pin value before the first sample"); + + return selector; +} + void DecodeTrace::commit_decoder_channels(shared_ptr &dec) { assert(dec); @@ -890,6 +938,10 @@ void DecodeTrace::commit_decoder_channels(shared_ptr &dec const unordered_set< shared_ptr > sigs(session_.signalbases()); + GArray *const initial_pins = g_array_sized_new(FALSE, TRUE, + sizeof(uint8_t), channel_selectors_.size()); + g_array_set_size(initial_pins, channel_selectors_.size()); + for (const ChannelSelector &s : channel_selectors_) { if (s.decoder_ != dec) break; @@ -903,9 +955,15 @@ void DecodeTrace::commit_decoder_channels(shared_ptr &dec channel_map[s.pdch_] = sig; break; } + + int selection_initial_pin = s.combo_initial_pin_->itemData( + s.combo_initial_pin_->currentIndex()).value(); + + initial_pins->data[s.pdch_->order] = selection_initial_pin; } dec->set_channels(channel_map); + dec->set_initial_pins(initial_pins); } void DecodeTrace::commit_channels() @@ -940,6 +998,11 @@ void DecodeTrace::on_channel_selected(int) commit_channels(); } +void DecodeTrace::on_initial_pin_selected(int) +{ + commit_channels(); +} + void DecodeTrace::on_stack_decoder(srd_decoder *decoder) { shared_ptr decoder_stack = base_->decoder_stack();