From: Joel Holdsworth Date: Sat, 16 Mar 2013 10:11:37 +0000 (+0000) Subject: Added a scale factor to AnalogSignal X-Git-Tag: pulseview-0.1.0~76 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=785fd8d138e5866ade499c02ea405b8852fee113;p=pulseview.git Added a scale factor to AnalogSignal --- diff --git a/pv/view/analogsignal.cpp b/pv/view/analogsignal.cpp index 03b05955..75b5d3df 100644 --- a/pv/view/analogsignal.cpp +++ b/pv/view/analogsignal.cpp @@ -42,11 +42,17 @@ const QColor AnalogSignal::SignalColours[4] = { AnalogSignal::AnalogSignal(QString name, shared_ptr 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); diff --git a/pv/view/analogsignal.h b/pv/view/analogsignal.h index 6e4199ac..bb4a2109 100644 --- a/pv/view/analogsignal.h +++ b/pv/view/analogsignal.h @@ -42,6 +42,8 @@ public: AnalogSignal(QString name, boost::shared_ptr 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 _data; + float _scale; }; } // namespace view