]> sigrok.org Git - pulseview.git/commitdiff
Link signals to probes
authorJoel Holdsworth <redacted>
Sat, 4 May 2013 08:13:43 +0000 (09:13 +0100)
committerJoel Holdsworth <redacted>
Sun, 19 May 2013 08:45:59 +0000 (09:45 +0100)
pv/sigsession.cpp
pv/view/analogsignal.cpp
pv/view/analogsignal.h
pv/view/logicsignal.cpp
pv/view/logicsignal.h
pv/view/signal.cpp
pv/view/signal.h

index bda4b0d32c38c03fe5d7c26a5645ae03f85b64cc..0de7c4a7a3bddec86a758bb3d99cf93db7251b37 100644 (file)
@@ -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<view::Signal>(
-                                               new view::LogicSignal(
-                                                       probe->name,
-                                                       _logic_data,
-                                                       probe->index));
+                                               new view::LogicSignal(probe,
+                                                       _logic_data));
                                        break;
 
                                case SR_PROBE_ANALOG:
                                        signal = shared_ptr<view::Signal>(
-                                               new view::AnalogSignal(
-                                                       probe->name,
-                                                       _analog_data,
-                                                       probe->index));
+                                               new view::AnalogSignal(probe,
+                                                       _analog_data));
                                        break;
                                }
 
index 367b5890d7d6ef46f078c732cd579a2b4a5daa09..f4a665c2ec49f225a5c8f246937e713923f89295 100644 (file)
@@ -41,13 +41,13 @@ const QColor AnalogSignal::SignalColours[4] = {
 
 const float AnalogSignal::EnvelopeThreshold = 256.0f;
 
-AnalogSignal::AnalogSignal(QString name, shared_ptr<data::Analog> data,
-       int probe_index) :
-       Signal(name),
+AnalogSignal::AnalogSignal(const sr_probe *const probe,
+       shared_ptr<data::Analog> 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<pv::data::AnalogSnapshot> > &snapshots =
index 5ebf501619e4c6a48473b0f89959b5374ae27520..666aec9893aa767e17e739ac7a8b168de1eac104 100644 (file)
@@ -42,8 +42,8 @@ private:
        static const float EnvelopeThreshold;
 
 public:
-       AnalogSignal(QString name,
-               boost::shared_ptr<pv::data::Analog> data, int probe_index);
+       AnalogSignal(const sr_probe *const probe,
+               boost::shared_ptr<pv::data::Analog> data);
 
        virtual ~AnalogSignal();
 
index 21c9abbc8f8af78580ebe111c8654db865bb0273..e1f0377e9307d0b25d3104f47fd409c9014d5b8d 100644 (file)
@@ -52,14 +52,12 @@ const QColor LogicSignal::SignalColours[10] = {
        QColor(0xEE, 0xEE, 0xEC),       // White
 };
 
-LogicSignal::LogicSignal(QString name, shared_ptr<data::Logic> data,
-       int probe_index) :
-       Signal(name),
-       _probe_index(probe_index),
+LogicSignal::LogicSignal(const sr_probe *const probe,
+       shared_ptr<data::Logic> 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<int64_t, bool> > 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
index c4ae755152ca6b997843b07cb6e7f1fadb32cbcb..927e96ab079e0daeda534eb706bab4e2ea8764d3 100644 (file)
@@ -45,9 +45,8 @@ private:
        static const QColor SignalColours[10];
 
 public:
-       LogicSignal(QString name,
-               boost::shared_ptr<pv::data::Logic> data,
-               int probe_index);
+       LogicSignal(const sr_probe *const probe,
+               boost::shared_ptr<pv::data::Logic> data);
 
        virtual ~LogicSignal();
 
@@ -72,7 +71,6 @@ private:
                float x_offset, float y_offset);
 
 private:
-       int _probe_index;
        boost::shared_ptr<pv::data::Logic> _data;
 };
 
index 48e47f27aa9a49304dddc6d1feef879463183cf4..cdbb65b1638e5ac145c1aaa66cf6c3d99bf12971 100644 (file)
@@ -20,6 +20,7 @@
 
 #include <extdef.h>
 
+#include <assert.h>
 #include <math.h>
 
 #include <QApplication>
@@ -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);
index 250d3ff36bf04c90ba542629e062f3aba8d99cd2..b53d05393e814e28e1212a0862c0309823ae992c 100644 (file)
@@ -31,6 +31,8 @@
 
 #include <stdint.h>
 
+#include <libsigrok/libsigrok.h>
+
 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;