From: Joel Holdsworth Date: Sat, 4 May 2013 08:13:43 +0000 (+0100) Subject: Link signals to probes X-Git-Tag: pulseview-0.2.0~360 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=cec48d1618edd0f28f21d5351f53692876222e16;p=pulseview.git Link signals to probes --- diff --git a/pv/sigsession.cpp b/pv/sigsession.cpp index bda4b0d3..0de7c4a7 100644 --- a/pv/sigsession.cpp +++ b/pv/sigsession.cpp @@ -300,24 +300,18 @@ void SigSession::update_signals() const sr_probe *const probe = (const sr_probe *)l->data; assert(probe); - if (!probe->enabled) - continue; switch(probe->type) { case SR_PROBE_LOGIC: signal = shared_ptr( - new view::LogicSignal( - probe->name, - _logic_data, - probe->index)); + new view::LogicSignal(probe, + _logic_data)); break; case SR_PROBE_ANALOG: signal = shared_ptr( - new view::AnalogSignal( - probe->name, - _analog_data, - probe->index)); + new view::AnalogSignal(probe, + _analog_data)); break; } diff --git a/pv/view/analogsignal.cpp b/pv/view/analogsignal.cpp index 367b5890..f4a665c2 100644 --- a/pv/view/analogsignal.cpp +++ b/pv/view/analogsignal.cpp @@ -41,13 +41,13 @@ const QColor AnalogSignal::SignalColours[4] = { const float AnalogSignal::EnvelopeThreshold = 256.0f; -AnalogSignal::AnalogSignal(QString name, shared_ptr data, - int probe_index) : - Signal(name), +AnalogSignal::AnalogSignal(const sr_probe *const probe, + shared_ptr data) : + Signal(probe), _data(data), _scale(1.0f) { - _colour = SignalColours[probe_index % countof(SignalColours)]; + _colour = SignalColours[probe->index % countof(SignalColours)]; } AnalogSignal::~AnalogSignal() @@ -66,6 +66,9 @@ void AnalogSignal::paint(QPainter &p, int y, int left, int right, double scale, assert(_data); assert(right >= left); + if (!_probe->enabled) + return; + paint_axis(p, y, left, right); const deque< shared_ptr > &snapshots = diff --git a/pv/view/analogsignal.h b/pv/view/analogsignal.h index 5ebf5016..666aec98 100644 --- a/pv/view/analogsignal.h +++ b/pv/view/analogsignal.h @@ -42,8 +42,8 @@ private: static const float EnvelopeThreshold; public: - AnalogSignal(QString name, - boost::shared_ptr data, int probe_index); + AnalogSignal(const sr_probe *const probe, + boost::shared_ptr data); virtual ~AnalogSignal(); diff --git a/pv/view/logicsignal.cpp b/pv/view/logicsignal.cpp index 21c9abbc..e1f0377e 100644 --- a/pv/view/logicsignal.cpp +++ b/pv/view/logicsignal.cpp @@ -52,14 +52,12 @@ const QColor LogicSignal::SignalColours[10] = { QColor(0xEE, 0xEE, 0xEC), // White }; -LogicSignal::LogicSignal(QString name, shared_ptr data, - int probe_index) : - Signal(name), - _probe_index(probe_index), +LogicSignal::LogicSignal(const sr_probe *const probe, + shared_ptr data) : + Signal(probe), _data(data) { - assert(_probe_index >= 0); - _colour = SignalColours[_probe_index % countof(SignalColours)]; + _colour = SignalColours[probe->index % countof(SignalColours)]; } LogicSignal::~LogicSignal() @@ -75,10 +73,14 @@ void LogicSignal::paint(QPainter &p, int y, int left, int right, vector< pair > edges; + assert(_probe); assert(scale > 0); assert(_data); assert(right >= left); + if (!_probe->enabled) + return; + paint_axis(p, y, left, right); const float high_offset = y - View::SignalHeight + 0.5f; @@ -108,7 +110,7 @@ void LogicSignal::paint(QPainter &p, int y, int left, int right, snapshot->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), - samples_per_pixel / Oversampling, _probe_index); + samples_per_pixel / Oversampling, _probe->index); assert(edges.size() >= 2); // Paint the edges diff --git a/pv/view/logicsignal.h b/pv/view/logicsignal.h index c4ae7551..927e96ab 100644 --- a/pv/view/logicsignal.h +++ b/pv/view/logicsignal.h @@ -45,9 +45,8 @@ private: static const QColor SignalColours[10]; public: - LogicSignal(QString name, - boost::shared_ptr data, - int probe_index); + LogicSignal(const sr_probe *const probe, + boost::shared_ptr data); virtual ~LogicSignal(); @@ -72,7 +71,6 @@ private: float x_offset, float y_offset); private: - int _probe_index; boost::shared_ptr _data; }; diff --git a/pv/view/signal.cpp b/pv/view/signal.cpp index 48e47f27..cdbb65b1 100644 --- a/pv/view/signal.cpp +++ b/pv/view/signal.cpp @@ -20,6 +20,7 @@ #include +#include #include #include @@ -35,11 +36,13 @@ const int Signal::LabelHighlightRadius = 6; const QPen Signal::SignalAxisPen(QColor(128, 128, 128, 64)); -Signal::Signal(QString name) : - _name(name), +Signal::Signal(const sr_probe *const probe) : + _probe(probe), + _name(probe->name), _v_offset(0), _selected(false) { + assert(_probe); } QString Signal::get_name() const @@ -86,6 +89,9 @@ void Signal::paint_label(QPainter &p, int y, int right, bool hover) { p.setBrush(_colour); + if (!_probe->enabled) + return; + const QColor colour = get_colour(); compute_text_size(p); diff --git a/pv/view/signal.h b/pv/view/signal.h index 250d3ff3..b53d0539 100644 --- a/pv/view/signal.h +++ b/pv/view/signal.h @@ -31,6 +31,8 @@ #include +#include + namespace pv { namespace data { @@ -48,7 +50,7 @@ private: static const QPen SignalAxisPen; protected: - Signal(QString name); + Signal(const sr_probe *const probe); public: /** @@ -156,6 +158,8 @@ private: QRectF get_label_rect(int y, int right); protected: + const sr_probe *const _probe; + QString _name; QColor _colour; int _v_offset;