]> sigrok.org Git - pulseview.git/commitdiff
Added a scale factor to AnalogSignal
authorJoel Holdsworth <redacted>
Sat, 16 Mar 2013 10:11:37 +0000 (10:11 +0000)
committerJoel Holdsworth <redacted>
Thu, 21 Mar 2013 22:44:18 +0000 (22:44 +0000)
pv/view/analogsignal.cpp
pv/view/analogsignal.h

index 03b05955e4820f90bfd40e12058ccef2d7d60701..75b5d3dfd245bcc5b982a4545245461b7cf627af 100644 (file)
@@ -42,11 +42,17 @@ const QColor AnalogSignal::SignalColours[4] = {
 AnalogSignal::AnalogSignal(QString name, shared_ptr<data::Analog> data,
        int probe_index) :
        Signal(name),
-       _data(data)
+       _data(data),
+       _scale(1.0f)
 {
        _colour = SignalColours[probe_index % countof(SignalColours)];
 }
 
+void AnalogSignal::set_scale(float scale)
+{
+       _scale = scale;
+}
+
 void AnalogSignal::paint(QPainter &p, int y, int left, int right, double scale,
        double offset)
 {
@@ -90,7 +96,7 @@ void AnalogSignal::paint(QPainter &p, int y, int left, int right, double scale,
                const float x = (sample / samples_per_pixel -
                        pixels_offset) + left;
                *point++ = QPointF(x,
-                       samples[sample - start_sample] + y);
+                       y - samples[sample - start_sample] * _scale);
        }
 
        p.setPen(_colour);
index 6e4199acf16f7427382e8aeffee838791d8540e9..bb4a2109c0bd4d8d461434afae9a552ce39645da 100644 (file)
@@ -42,6 +42,8 @@ public:
        AnalogSignal(QString name,
                boost::shared_ptr<pv::data::Analog> data, int probe_index);
 
+       void set_scale(float scale);
+
        /**
         * Paints the signal with a QPainter
         * @param p the QPainter to paint into.
@@ -57,6 +59,7 @@ public:
 
 private:
        boost::shared_ptr<pv::data::Analog> _data;
+       float _scale;
 };
 
 } // namespace view