Initial interractive zoom support
[pulseview.git] / sigview.cpp
index 565e67e2eb8a4d968c5fcf8d0be78727168797a3..df1eefec2745fec15041766a4777d086d6e114eb 100644 (file)
@@ -23,6 +23,8 @@
 #include "sigsession.h"
 #include "signal.h"
 
+#include <QMouseEvent>
+
 #include <boost/foreach.hpp>
 
 using namespace boost;
@@ -32,7 +34,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 +74,7 @@ void SigView::paintGL()
        BOOST_FOREACH(const shared_ptr<Signal> s, sigs)
        {
                assert(s);
-               s->paint(*this, rect);
+               s->paint(*this, rect, _scale, _offset);
                rect.translate(0, SignalHeight);
        }
 }
@@ -80,3 +84,31 @@ void SigView::dataUpdated()
        update();
 }
 
+void SigView::mouseMoveEvent(QMouseEvent *event)
+{
+       assert(event);
+}
+
+void SigView::mousePressEvent(QMouseEvent *event)
+{
+       assert(event);
+}
+
+void SigView::mouseReleaseEvent(QMouseEvent *event)
+{
+       assert(event);
+
+       switch(event->button())
+       {
+       case Qt::LeftButton:
+               _scale = (_scale * 2) / 3;
+               break;
+
+       case Qt::RightButton:
+               _scale = (_scale * 3) / 2;
+               break;
+       }
+
+       updateGL();
+}
+