From: Joel Holdsworth Date: Tue, 5 Jun 2012 10:20:06 +0000 (+0100) Subject: Added view scale and offset X-Git-Tag: pulseview-0.1.0~345 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=3b18c57d8f224791481e0b768065bd4d11a3d79e;p=pulseview.git Added view scale and offset --- diff --git a/logicsignal.cpp b/logicsignal.cpp index 7a86b7c6..09a65afc 100644 --- a/logicsignal.cpp +++ b/logicsignal.cpp @@ -28,7 +28,8 @@ LogicSignal::LogicSignal(QString name, boost::shared_ptr data, assert(_probe_index >= 0); } -void LogicSignal::paint(QGLWidget &widget, const QRect &rect) +void LogicSignal::paint(QGLWidget &widget, const QRect &rect, + uint64_t scale, int64_t offset) { glColor3f(1,0,0); glBegin(GL_POLYGON); diff --git a/logicsignal.h b/logicsignal.h index 91c70ab2..28c8247a 100644 --- a/logicsignal.h +++ b/logicsignal.h @@ -30,7 +30,16 @@ public: LogicSignal(QString name, boost::shared_ptr data, int probe_index); - void paint(QGLWidget &widget, const QRect &rect); + /** + * Paints the signal into a QGLWidget. + * @param widget the QGLWidget to paint into. + * @param rect the rectangular area to draw the trace into. + * @param scale the scale in femtoseconds per pixel. + * @param offset the time to show at the left hand edge of + * the view in femtoseconds. + **/ + void paint(QGLWidget &widget, const QRect &rect, uint64_t scale, + int64_t offset); private: int _probe_index; diff --git a/signal.h b/signal.h index ee051dca..2cec1299 100644 --- a/signal.h +++ b/signal.h @@ -36,7 +36,16 @@ protected: public: QString get_name() const; - virtual void paint(QGLWidget &widget, const QRect &rect) = 0; + /** + * Paints the signal into a QGLWidget. + * @param widget the QGLWidget to paint into. + * @param rect the rectangular area to draw the trace into. + * @param scale the scale in femtoseconds per pixel. + * @param offset the time to show at the left hand edge of + * the view in femtoseconds. + **/ + virtual void paint(QGLWidget &widget, const QRect &rect, + uint64_t scale, int64_t offset) = 0; protected: QString _name; diff --git a/sigview.cpp b/sigview.cpp index 565e67e2..53fbdeaa 100644 --- a/sigview.cpp +++ b/sigview.cpp @@ -32,7 +32,9 @@ const int SigView::SignalHeight = 50; SigView::SigView(SigSession &session, QWidget *parent) : QGLWidget(parent), - _session(session) + _session(session), + _scale(1000000000ULL), + _offset(0) { connect(&_session, SIGNAL(dataUpdated()), this, SLOT(dataUpdated())); @@ -70,7 +72,7 @@ void SigView::paintGL() BOOST_FOREACH(const shared_ptr s, sigs) { assert(s); - s->paint(*this, rect); + s->paint(*this, rect, _scale, _offset); rect.translate(0, SignalHeight); } } diff --git a/sigview.h b/sigview.h index b43ae9a5..2c7ba1dd 100644 --- a/sigview.h +++ b/sigview.h @@ -49,6 +49,9 @@ private slots: private: SigSession &_session; + + uint64_t _scale; + int64_t _offset; }; #endif // SIGVIEW_H