From 3b18c57d8f224791481e0b768065bd4d11a3d79e Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Tue, 5 Jun 2012 11:20:06 +0100 Subject: [PATCH] Added view scale and offset --- logicsignal.cpp | 3 ++- logicsignal.h | 11 ++++++++++- signal.h | 11 ++++++++++- sigview.cpp | 6 ++++-- sigview.h | 3 +++ 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/logicsignal.cpp b/logicsignal.cpp index 7a86b7c..09a65af 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 91c70ab..28c8247 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 ee051dc..2cec129 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 565e67e..53fbdea 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 b43ae9a..2c7ba1d 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 -- 2.30.2