for (const auto& channel : channels_) {
shared_ptr<view::LogicSignal> 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);
}
unordered_set< shared_ptr<SignalBase> > sigs;
for (const shared_ptr<view::Signal> s : session_.signals())
- sigs.insert(s->channel());
+ sigs.insert(s->base());
for (const shared_ptr<SignalBase> &sig : sigs)
signal_map[sig->channel()] = sig;
dynamic_pointer_cast<view::LogicSignal>(s);
if (l && QString::fromUtf8(pdch->name).
toLower().contains(
- s->channel()->name().toLower()))
+ s->base()->name().toLower()))
channels[pdch] = l;
}
const auto iter = std::find_if(
prev_sigs.cbegin(), prev_sigs.cend(),
[&](const shared_ptr<view::Signal> &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
asegment_list.push_back(asegments.front());
any_segment = asegments.front();
- achannel_list.push_back(signal->channel());
+ achannel_list.push_back(signal->base());
}
}
AnalogSignal::AnalogSignal(
pv::Session &session,
- shared_ptr<data::SignalBase> channel,
+ shared_ptr<data::SignalBase> base,
shared_ptr<data::Analog> data) :
- Signal(session, channel),
+ Signal(session, base),
data_(data),
scale_index_(4), // 20 per div
scale_index_drag_offset_(0),
vdivs_(1),
resolution_(0)
{
- channel_->set_colour(SignalColours[channel_->index() % countof(SignalColours)]);
+ base_->set_colour(SignalColours[base_->index() % countof(SignalColours)]);
update_scale();
}
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());
}
const int y = get_visual_y();
- if (!channel_->enabled())
+ if (!base_->enabled())
return;
paint_grid(p, y, pp.left(), pp.right());
// 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(),
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;
return;
p.setPen(QPen(Qt::NoPen));
- p.setBrush(channel_->colour());
+ p.setBrush(base_->colour());
QRectF *const rects = new QRectF[e.length];
QRectF *rect = rects;
public:
AnalogSignal(pv::Session &session,
- std::shared_ptr<data::SignalBase> channel,
+ std::shared_ptr<data::SignalBase> base,
std::shared_ptr<pv::data::Analog> data);
virtual ~AnalogSignal() = default;
vector< shared_ptr<Signal> > sig_list(sigs.begin(), sigs.end());
std::sort(sig_list.begin(), sig_list.end(),
[](const shared_ptr<Signal> &a, const shared_ptr<Signal> 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);
for (const shared_ptr<view::Signal> &s : sig_list) {
assert(s);
if (dynamic_pointer_cast<LogicSignal>(s) && s->enabled()) {
- selector->addItem(s->channel()->name(),
+ selector->addItem(s->base()->name(),
qVariantFromValue((void*)s.get()));
if (channel_iter != dec->channels().end() &&
LogicSignal::LogicSignal(
pv::Session &session,
shared_ptr<devices::Device> device,
- shared_ptr<data::SignalBase> channel,
+ shared_ptr<data::SignalBase> base,
shared_ptr<data::Logic> data) :
- Signal(session, channel),
+ Signal(session, base),
signal_height_(QFontMetrics(QApplication::font()).height() * 2),
device_(device),
data_(data),
{
shared_ptr<Trigger> 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. */
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();
}
vector< pair<int64_t, bool> > 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;
(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
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();
const auto &matches = stage->matches();
if (std::none_of(matches.begin(), matches.end(),
[&](shared_ptr<TriggerMatch> 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());
}
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_);
}
public:
LogicSignal(pv::Session &session,
std::shared_ptr<devices::Device> device,
- std::shared_ptr<data::SignalBase> channel,
+ std::shared_ptr<data::SignalBase> base,
std::shared_ptr<pv::data::Logic> data);
virtual ~LogicSignal() = default;
items_({scale_handle_}),
name_widget_(nullptr)
{
- assert(channel_);
+ assert(base_);
}
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<data::SignalBase> Signal::channel() const
+shared_ptr<data::SignalBase> Signal::base() const
{
- return channel_;
+ return base_;
}
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);
}
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);
void enable(bool enable = true);
- std::shared_ptr<data::SignalBase> channel() const;
+ std::shared_ptr<data::SignalBase> base() const;
/**
* Returns a list of row items owned by this object.
const QColor Trace::DarkGrayBGColour = QColor(0, 0, 0, 15*255/100);
Trace::Trace(std::shared_ptr<data::SignalBase> channel) :
- channel_(channel),
+ base_(channel),
coloured_bg_(true), // Default setting is set in MainWindow::setup_ui()
popup_(nullptr),
popup_form_(nullptr)
{
const int y = get_visual_y();
- p.setBrush(channel_->colour());
+ p.setBrush(base_->colour());
if (!enabled())
return;
}
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)
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);
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);
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&)));
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);
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)
void on_colouredit_changed(const QColor &colour);
protected:
- std::shared_ptr<data::SignalBase> channel_;
+ std::shared_ptr<data::SignalBase> base_;
bool coloured_bg_, coloured_bg_state_;
private:
unordered_map<shared_ptr<data::SignalBase>, shared_ptr<Signal> >
signal_map;
for (const shared_ptr<Signal> &sig : sigs)
- signal_map[sig->channel()] = sig;
+ signal_map[sig->base()] = sig;
// Populate channel groups
if (sr_dev)