]> sigrok.org Git - pulseview.git/commitdiff
Added zoom limits
authorJoel Holdsworth <redacted>
Sat, 7 Jul 2012 07:54:32 +0000 (08:54 +0100)
committerJoel Holdsworth <redacted>
Mon, 3 Sep 2012 12:59:06 +0000 (13:59 +0100)
sigview.cpp
sigview.h

index dea3cbc1255bc646307cbd39448be239c0982fae..c46476a30f386920b799e68580b1c31f4c0b2cf2 100644 (file)
@@ -35,6 +35,9 @@
 using namespace boost;
 using namespace std;
 
 using namespace boost;
 using namespace std;
 
+const double SigView::MaxScale = 1e9;
+const double SigView::MinScale = 1e-15;
+
 const int SigView::SignalHeight = 50;
 const int SigView::LabelMarginWidth = 70;
 const int SigView::RulerHeight = 30;
 const int SigView::SignalHeight = 50;
 const int SigView::LabelMarginWidth = 70;
 const int SigView::RulerHeight = 30;
@@ -165,6 +168,7 @@ void SigView::wheelEvent(QWheelEvent *event)
        const double x = event->x() - LabelMarginWidth;
        const double cursor_offset = _offset + _scale * x;
        _scale *= powf(3.0/2.0, -event->delta() / 120);
        const double x = event->x() - LabelMarginWidth;
        const double cursor_offset = _offset + _scale * x;
        _scale *= powf(3.0/2.0, -event->delta() / 120);
+       _scale = max(min(_scale, MaxScale), MinScale);
        _offset = cursor_offset - _scale * x;
        update();
 }
        _offset = cursor_offset - _scale * x;
        update();
 }
index 2d450df21c0822374d36aa0bdccd9cf2b24f7b6a..aae9e67e37c7d4fb4b837989df63ade658f62709 100644 (file)
--- a/sigview.h
+++ b/sigview.h
@@ -33,6 +33,9 @@ class SigView : public QGLWidget
        Q_OBJECT
 
 private:
        Q_OBJECT
 
 private:
+       static const double MaxScale;
+       static const double MinScale;
+
        static const int SignalHeight;
        static const int LabelMarginWidth;
        static const int RulerHeight;
        static const int SignalHeight;
        static const int LabelMarginWidth;
        static const int RulerHeight;