diff options
author | Tim Moore <timoore@redhat.com> | 2009-12-22 23:30:56 +0100 |
---|---|---|
committer | Tim Moore <timoore@redhat.com> | 2009-12-23 00:15:24 +0100 |
commit | 72195f6b17c0ed2e508c58bf3cadd5b9dc4e28ac (patch) | |
tree | cd1b20b74695e53d601583427e4ef7c0eb8604af /grapher | |
parent | 4fca37ae3561da7d0664e0f943146398a8e554dd (diff) | |
download | systemtap-steved-72195f6b17c0ed2e508c58bf3cadd5b9dc4e28ac.tar.gz systemtap-steved-72195f6b17c0ed2e508c58bf3cadd5b9dc4e28ac.tar.xz systemtap-steved-72195f6b17c0ed2e508c58bf3cadd5b9dc4e28ac.zip |
grapher: remove _zoomFactor from horizontal scaling calculation
This makes zooming more consistent and less buggy.
* grapher/Graph.cxx (Graph::draw): Set graph time spread using
_zoomFactor.
* grapher/Graph.hxx (Graph::getHorizontalScale): no _zoomFactor
* grapher/GraphWidget.cxx (on_motion_notify_event): Dragging increment
uses _zoomFactor.
(on_scroll_event): Set extents after changing the zoom factor with
the scroll wheel.
Diffstat (limited to 'grapher')
-rw-r--r-- | grapher/Graph.cxx | 2 | ||||
-rw-r--r-- | grapher/Graph.hxx | 2 | ||||
-rw-r--r-- | grapher/GraphWidget.cxx | 16 |
3 files changed, 14 insertions, 6 deletions
diff --git a/grapher/Graph.cxx b/grapher/Graph.cxx index 4d697ae6..079cd63e 100644 --- a/grapher/Graph.cxx +++ b/grapher/Graph.cxx @@ -44,7 +44,7 @@ void Graph::draw(Cairo::RefPtr<Cairo::Context> cr) // Find latest time. _right = _currentTime / 1000; // Assume 1 pixel = 5 milliseconds - _left = _right - 5000; + _left = _right - static_cast<int64_t>(5000 / _zoomFactor); } cr->save(); double horizScale = getHorizontalScale(); diff --git a/grapher/Graph.hxx b/grapher/Graph.hxx index 0853d988..7037efa9 100644 --- a/grapher/Graph.hxx +++ b/grapher/Graph.hxx @@ -57,7 +57,7 @@ public: */ double getHorizontalScale() { - return _zoomFactor * _graphWidth / static_cast<double>(_right - _left); + return _graphWidth / static_cast<double>(_right - _left); } protected: GraphDataList _datasets; diff --git a/grapher/GraphWidget.cxx b/grapher/GraphWidget.cxx index be1ebdcd..ce2f934f 100644 --- a/grapher/GraphWidget.cxx +++ b/grapher/GraphWidget.cxx @@ -241,8 +241,10 @@ bool GraphWidget::on_motion_notify_event(GdkEventMotion* event) const int width = allocation.get_width(); double motion = (_mouseX - _dragOriginX) / (double) width; double increment = motion * (_dragOrigLeft - _dragOrigRight); - _activeGraph->_left = _dragOrigLeft + increment; - _activeGraph->_right = _dragOrigRight + increment; + _activeGraph->_left + = _dragOrigLeft + increment / _activeGraph->_zoomFactor; + _activeGraph->_right + = _dragOrigRight + increment / _activeGraph->_zoomFactor; queue_draw(); } if (_hoverText && _hoverText->isVisible()) @@ -263,10 +265,16 @@ bool GraphWidget::on_scroll_event(GdkEventScroll* event) { if ((*gitr)->containsPoint(event->x, event->y)) { + double oldZoom = (*gitr)->_zoomFactor; if (event->direction == GDK_SCROLL_UP) - (*gitr)->_zoomFactor += .1; + (*gitr)->_zoomFactor *= 1.1; else if (event->direction == GDK_SCROLL_DOWN) - (*gitr)->_zoomFactor -= .1; + (*gitr)->_zoomFactor /= 1.1; + int64_t left, right; + double top, bottom; + (*gitr)->getExtents(left, right, top, bottom); + right = left - (left - right) * (oldZoom / (*gitr)->_zoomFactor); + (*gitr)->setExtents(left, right, top, bottom); queue_draw(); break; } |