From: Soeren Apel Date: Tue, 16 Aug 2016 19:10:40 +0000 (+0200) Subject: Rename Trace::channel_ to Trace::base_, including dependencies X-Git-Tag: pulseview-0.4.0~275 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=73a25a6e488f1813c1cd12da085a16e4f91ed4da;p=pulseview.git Rename Trace::channel_ to Trace::base_, including dependencies --- diff --git a/pv/data/decode/decoder.cpp b/pv/data/decode/decoder.cpp index 1513b20b..bd1d307f 100644 --- a/pv/data/decode/decoder.cpp +++ b/pv/data/decode/decoder.cpp @@ -137,7 +137,7 @@ srd_decoder_inst* Decoder::create_decoder_inst(srd_session *session) const for (const auto& channel : channels_) { shared_ptr signal(channel.second); GVariant *const gvar = g_variant_new_int32( - signal->channel()->index()); + signal->base()->index()); g_variant_ref_sink(gvar); g_hash_table_insert(channels, channel.first->id, gvar); } diff --git a/pv/popups/channels.cpp b/pv/popups/channels.cpp index 7489b93f..f8f94d1a 100644 --- a/pv/popups/channels.cpp +++ b/pv/popups/channels.cpp @@ -83,7 +83,7 @@ Channels::Channels(Session &session, QWidget *parent) : unordered_set< shared_ptr > sigs; for (const shared_ptr s : session_.signals()) - sigs.insert(s->channel()); + sigs.insert(s->base()); for (const shared_ptr &sig : sigs) signal_map[sig->channel()] = sig; diff --git a/pv/session.cpp b/pv/session.cpp index 9c3a2c25..e1a1f010 100644 --- a/pv/session.cpp +++ b/pv/session.cpp @@ -299,7 +299,7 @@ bool Session::add_decoder(srd_decoder *const dec) dynamic_pointer_cast(s); if (l && QString::fromUtf8(pdch->name). toLower().contains( - s->channel()->name().toLower())) + s->base()->name().toLower())) channels[pdch] = l; } @@ -412,7 +412,7 @@ void Session::update_signals() const auto iter = std::find_if( prev_sigs.cbegin(), prev_sigs.cend(), [&](const shared_ptr &s) { - return s->channel()->channel() == channel; + return s->base()->channel() == channel; }); if (iter != prev_sigs.end()) { // Copy the signal from the old set to the new diff --git a/pv/storesession.cpp b/pv/storesession.cpp index f8ab2e69..00f6af63 100644 --- a/pv/storesession.cpp +++ b/pv/storesession.cpp @@ -151,7 +151,7 @@ bool StoreSession::start() asegment_list.push_back(asegments.front()); any_segment = asegments.front(); - achannel_list.push_back(signal->channel()); + achannel_list.push_back(signal->base()); } } diff --git a/pv/view/analogsignal.cpp b/pv/view/analogsignal.cpp index 8ccad390..cd57da06 100644 --- a/pv/view/analogsignal.cpp +++ b/pv/view/analogsignal.cpp @@ -71,9 +71,9 @@ const int AnalogSignal::InfoTextMarginBottom = 5; AnalogSignal::AnalogSignal( pv::Session &session, - shared_ptr channel, + shared_ptr base, shared_ptr data) : - Signal(session, channel), + Signal(session, base), data_(data), scale_index_(4), // 20 per div scale_index_drag_offset_(0), @@ -81,7 +81,7 @@ AnalogSignal::AnalogSignal( vdivs_(1), resolution_(0) { - channel_->set_colour(SignalColours[channel_->index() % countof(SignalColours)]); + base_->set_colour(SignalColours[base_->index() % countof(SignalColours)]); update_scale(); } @@ -127,7 +127,7 @@ void AnalogSignal::scale_handle_drag_release() void AnalogSignal::paint_back(QPainter &p, const ViewItemPaintParams &pp) { - if (channel_->enabled()) { + if (base_->enabled()) { Trace::paint_back(p, pp); paint_axis(p, pp, get_visual_y()); } @@ -140,7 +140,7 @@ void AnalogSignal::paint_mid(QPainter &p, const ViewItemPaintParams &pp) const int y = get_visual_y(); - if (!channel_->enabled()) + if (!base_->enabled()) return; paint_grid(p, y, pp.left(), pp.right()); @@ -186,7 +186,7 @@ void AnalogSignal::paint_fore(QPainter &p, const ViewItemPaintParams &pp) // Show the info section on the right side of the trace const QString infotext = QString("%1 V/div").arg(resolution_); - p.setPen(channel_->colour()); + p.setPen(base_->colour()); p.setFont(QApplication::font()); const QRectF bounding_rect = QRectF(pp.left(), @@ -235,7 +235,7 @@ void AnalogSignal::paint_trace(QPainter &p, const float *const samples = segment->get_samples(start, end); assert(samples); - p.setPen(channel_->colour()); + p.setPen(base_->colour()); QPointF *points = new QPointF[sample_count]; QPointF *point = points; @@ -267,7 +267,7 @@ void AnalogSignal::paint_envelope(QPainter &p, return; p.setPen(QPen(Qt::NoPen)); - p.setBrush(channel_->colour()); + p.setBrush(base_->colour()); QRectF *const rects = new QRectF[e.length]; QRectF *rect = rects; diff --git a/pv/view/analogsignal.hpp b/pv/view/analogsignal.hpp index 601ae110..f35fe79f 100644 --- a/pv/view/analogsignal.hpp +++ b/pv/view/analogsignal.hpp @@ -53,7 +53,7 @@ private: public: AnalogSignal(pv::Session &session, - std::shared_ptr channel, + std::shared_ptr base, std::shared_ptr data); virtual ~AnalogSignal() = default; diff --git a/pv/view/decodetrace.cpp b/pv/view/decodetrace.cpp index 3ece1303..2d9a6bf8 100644 --- a/pv/view/decodetrace.cpp +++ b/pv/view/decodetrace.cpp @@ -851,8 +851,8 @@ QComboBox* DecodeTrace::create_channel_selector( vector< shared_ptr > sig_list(sigs.begin(), sigs.end()); std::sort(sig_list.begin(), sig_list.end(), [](const shared_ptr &a, const shared_ptr b) { - return strnatcasecmp(a->channel()->name().toStdString(), - b->channel()->name().toStdString()) < 0; }); + return strnatcasecmp(a->base()->name().toStdString(), + b->base()->name().toStdString()) < 0; }); assert(decoder_stack_); const auto channel_iter = dec->channels().find(pdch); @@ -867,7 +867,7 @@ QComboBox* DecodeTrace::create_channel_selector( for (const shared_ptr &s : sig_list) { assert(s); if (dynamic_pointer_cast(s) && s->enabled()) { - selector->addItem(s->channel()->name(), + selector->addItem(s->base()->name(), qVariantFromValue((void*)s.get())); if (channel_iter != dec->channels().end() && diff --git a/pv/view/logicsignal.cpp b/pv/view/logicsignal.cpp index 7bb2ee0c..52a2d22d 100644 --- a/pv/view/logicsignal.cpp +++ b/pv/view/logicsignal.cpp @@ -99,9 +99,9 @@ QCache LogicSignal::pixmap_cache_; LogicSignal::LogicSignal( pv::Session &session, shared_ptr device, - shared_ptr channel, + shared_ptr base, shared_ptr data) : - Signal(session, channel), + Signal(session, base), signal_height_(QFontMetrics(QApplication::font()).height() * 2), device_(device), data_(data), @@ -114,7 +114,7 @@ LogicSignal::LogicSignal( { shared_ptr trigger; - channel_->set_colour(SignalColours[channel->index() % countof(SignalColours)]); + base_->set_colour(SignalColours[base->index() % countof(SignalColours)]); /* Populate this channel's trigger setting with whatever we * find in the current session trigger, if anything. */ @@ -122,7 +122,7 @@ LogicSignal::LogicSignal( if ((trigger = session_.session()->trigger())) for (auto stage : trigger->stages()) for (auto match : stage->matches()) - if (match->channel() == channel_->channel()) + if (match->channel() == base_->channel()) trigger_match_ = match->type(); } @@ -166,13 +166,13 @@ void LogicSignal::paint_mid(QPainter &p, const ViewItemPaintParams &pp) vector< pair > edges; - assert(channel_); + assert(base_); assert(data_); assert(owner_); const int y = get_visual_y(); - if (!channel_->enabled()) + if (!base_->enabled()) return; const float high_offset = y - signal_height_ + 0.5f; @@ -205,7 +205,7 @@ void LogicSignal::paint_mid(QPainter &p, const ViewItemPaintParams &pp) (int64_t)0), last_sample); segment->get_subsampled_edges(edges, start_sample, end_sample, - samples_per_pixel / Oversampling, channel_->index()); + samples_per_pixel / Oversampling, base_->index()); assert(edges.size() >= 2); // Paint the edges @@ -240,7 +240,7 @@ void LogicSignal::paint_mid(QPainter &p, const ViewItemPaintParams &pp) void LogicSignal::paint_fore(QPainter &p, const ViewItemPaintParams &pp) { // Draw the trigger marker - if (!trigger_match_ || !channel_->enabled()) + if (!trigger_match_ || !base_->enabled()) return; const int y = get_visual_y(); @@ -430,12 +430,12 @@ void LogicSignal::modify_trigger() const auto &matches = stage->matches(); if (std::none_of(matches.begin(), matches.end(), [&](shared_ptr match) { - return match->channel() != channel_->channel(); })) + return match->channel() != base_->channel(); })) continue; auto new_stage = new_trigger->add_stage(); for (auto match : stage->matches()) { - if (match->channel() == channel_->channel()) + if (match->channel() == base_->channel()) continue; new_stage->add_match(match->channel(), match->type()); } @@ -449,7 +449,7 @@ void LogicSignal::modify_trigger() if (new_trigger->stages().empty()) new_trigger->add_stage(); - new_trigger->stages().back()->add_match(channel_->channel(), + new_trigger->stages().back()->add_match(base_->channel(), trigger_match_); } diff --git a/pv/view/logicsignal.hpp b/pv/view/logicsignal.hpp index 9bd91ba9..14eeed4b 100644 --- a/pv/view/logicsignal.hpp +++ b/pv/view/logicsignal.hpp @@ -66,7 +66,7 @@ private: public: LogicSignal(pv::Session &session, std::shared_ptr device, - std::shared_ptr channel, + std::shared_ptr base, std::shared_ptr data); virtual ~LogicSignal() = default; diff --git a/pv/view/signal.cpp b/pv/view/signal.cpp index fc90eba1..a8de4d50 100644 --- a/pv/view/signal.cpp +++ b/pv/view/signal.cpp @@ -67,7 +67,7 @@ Signal::Signal(pv::Session &session, items_({scale_handle_}), name_widget_(nullptr) { - assert(channel_); + assert(base_); } void Signal::set_name(QString name) @@ -80,20 +80,20 @@ void Signal::set_name(QString name) bool Signal::enabled() const { - return channel_->enabled(); + return base_->enabled(); } void Signal::enable(bool enable) { - channel_->set_enabled(enable); + base_->set_enabled(enable); if (owner_) owner_->extents_changed(true, true); } -shared_ptr Signal::channel() const +shared_ptr Signal::base() const { - return channel_; + return base_; } const ViewItemOwner::item_list& Signal::child_items() const @@ -103,7 +103,7 @@ const ViewItemOwner::item_list& Signal::child_items() const void Signal::paint_back(QPainter &p, const ViewItemPaintParams &pp) { - if (channel_->enabled()) + if (base_->enabled()) Trace::paint_back(p, pp); } @@ -116,10 +116,10 @@ void Signal::populate_popup_form(QWidget *parent, QFormLayout *form) for (unsigned int i = 0; i < countof(ChannelNames); i++) name_widget_->insertItem(i, ChannelNames[i]); - const int index = name_widget_->findText(channel_->name(), Qt::MatchExactly); + const int index = name_widget_->findText(base_->name(), Qt::MatchExactly); if (index == -1) { - name_widget_->insertItem(0, channel_->name()); + name_widget_->insertItem(0, base_->name()); name_widget_->setCurrentIndex(0); } else { name_widget_->setCurrentIndex(index); diff --git a/pv/view/signal.hpp b/pv/view/signal.hpp index 36d87d45..72c97e1d 100644 --- a/pv/view/signal.hpp +++ b/pv/view/signal.hpp @@ -66,7 +66,7 @@ public: void enable(bool enable = true); - std::shared_ptr channel() const; + std::shared_ptr base() const; /** * Returns a list of row items owned by this object. diff --git a/pv/view/trace.cpp b/pv/view/trace.cpp index d6a4fec6..d9cccdb6 100644 --- a/pv/view/trace.cpp +++ b/pv/view/trace.cpp @@ -45,7 +45,7 @@ const QColor Trace::BrightGrayBGColour = QColor(0, 0, 0, 10*255/100); const QColor Trace::DarkGrayBGColour = QColor(0, 0, 0, 15*255/100); Trace::Trace(std::shared_ptr channel) : - channel_(channel), + base_(channel), coloured_bg_(true), // Default setting is set in MainWindow::setup_ui() popup_(nullptr), popup_form_(nullptr) @@ -65,7 +65,7 @@ void Trace::paint_label(QPainter &p, const QRect &rect, bool hover) { const int y = get_visual_y(); - p.setBrush(channel_->colour()); + p.setBrush(base_->colour()); if (!enabled()) return; @@ -96,23 +96,23 @@ void Trace::paint_label(QPainter &p, const QRect &rect, bool hover) } p.setPen(Qt::transparent); - p.setBrush(hover ? channel_->colour().lighter() : channel_->colour()); + p.setBrush(hover ? base_->colour().lighter() : base_->colour()); p.drawPolygon(points, countof(points)); - p.setPen(channel_->colour().lighter()); + p.setPen(base_->colour().lighter()); p.setBrush(Qt::transparent); p.drawPolygon(highlight_points, countof(highlight_points)); - p.setPen(channel_->colour().darker()); + p.setPen(base_->colour().darker()); p.setBrush(Qt::transparent); p.drawPolygon(points, countof(points)); // Paint the text - p.setPen(select_text_colour(channel_->colour())); + p.setPen(select_text_colour(base_->colour())); p.setFont(QApplication::font()); p.drawText(QRectF(r.x(), r.y(), r.width() - label_arrow_length, r.height()), - Qt::AlignCenter | Qt::AlignVCenter, channel_->name()); + Qt::AlignCenter | Qt::AlignVCenter, base_->name()); } QMenu* Trace::create_context_menu(QWidget *parent) @@ -144,7 +144,7 @@ QRectF Trace::label_rect(const QRectF &rect) const QFontMetrics m(QApplication::font()); const QSize text_size( - m.boundingRect(QRect(), 0, channel_->name()).width(), m.height()); + m.boundingRect(QRect(), 0, base_->name()).width(), m.height()); const QSizeF label_size( text_size.width() + LabelPadding.width() * 2, ceilf((text_size.height() + LabelPadding.height() * 2) / 2) * 2); @@ -159,7 +159,7 @@ QRectF Trace::label_rect(const QRectF &rect) const void Trace::paint_back(QPainter &p, const ViewItemPaintParams &pp) { if (coloured_bg_) - p.setBrush(channel_->bgcolour()); + p.setBrush(base_->bgcolour()); else p.setBrush(bgcolour_state_ ? BrightGrayBGColour : DarkGrayBGColour); @@ -192,7 +192,7 @@ void Trace::add_colour_option(QWidget *parent, QFormLayout *form) ColourButton *const colour_button = new ColourButton( TracePalette::Rows, TracePalette::Cols, parent); colour_button->set_palette(TracePalette::Colours); - colour_button->set_colour(channel_->colour()); + colour_button->set_colour(base_->colour()); connect(colour_button, SIGNAL(selected(const QColor&)), this, SLOT(on_colouredit_changed(const QColor&))); @@ -222,7 +222,7 @@ void Trace::create_popup_form() void Trace::populate_popup_form(QWidget *parent, QFormLayout *form) { QLineEdit *const name_edit = new QLineEdit(parent); - name_edit->setText(channel_->name()); + name_edit->setText(base_->name()); connect(name_edit, SIGNAL(textChanged(const QString&)), this, SLOT(on_nameedit_changed(const QString&))); form->addRow(tr("Name"), name_edit); @@ -232,12 +232,12 @@ void Trace::populate_popup_form(QWidget *parent, QFormLayout *form) void Trace::set_name(QString name) { - channel_->set_name(name); + base_->set_name(name); } void Trace::set_colour(QColor colour) { - channel_->set_colour(colour); + base_->set_colour(colour); } void Trace::on_name_changed(const QString &text) diff --git a/pv/view/trace.hpp b/pv/view/trace.hpp index 397ec7c0..0a6735f5 100644 --- a/pv/view/trace.hpp +++ b/pv/view/trace.hpp @@ -127,7 +127,7 @@ private Q_SLOTS: void on_colouredit_changed(const QColor &colour); protected: - std::shared_ptr channel_; + std::shared_ptr base_; bool coloured_bg_, coloured_bg_state_; private: diff --git a/pv/view/view.cpp b/pv/view/view.cpp index e7308ddf..570e7b76 100644 --- a/pv/view/view.cpp +++ b/pv/view/view.cpp @@ -976,7 +976,7 @@ void View::signals_changed() unordered_map, shared_ptr > signal_map; for (const shared_ptr &sig : sigs) - signal_map[sig->channel()] = sig; + signal_map[sig->base()] = sig; // Populate channel groups if (sr_dev)