diff options
Diffstat (limited to 'grapher/GraphWidget.cxx')
-rw-r--r-- | grapher/GraphWidget.cxx | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/grapher/GraphWidget.cxx b/grapher/GraphWidget.cxx index db7493fb..ce2f934f 100644 --- a/grapher/GraphWidget.cxx +++ b/grapher/GraphWidget.cxx @@ -23,6 +23,7 @@ #include "GraphWidget.hxx" #include "CairoWidget.hxx" +#include "Time.hxx" namespace systemtap { @@ -33,7 +34,7 @@ using namespace std::tr1; GraphWidget::GraphWidget() : _trackingDrag(false), _width(600), _height(200), _mouseX(0.0), - _mouseY(0.0), _globalTimeBase(0), _timeBaseInitialized(false) + _mouseY(0.0), _globalTimeBase(Time::getAbs() / 1000) { add_events(Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::SCROLL_MASK); @@ -157,27 +158,11 @@ bool GraphWidget::on_expose_event(GdkEventExpose* event) cr->save(); cr->set_source_rgba(0.0, 0.0, 0.0, 1.0); cr->paint(); - if (!_timeBaseInitialized && !getGraphData().empty()) - { - GraphDataList& graphData = getGraphData(); - int64_t earliest = INT64_MAX; - for (GraphDataList::iterator gd = graphData.begin(), - end = graphData.end(); - gd != end; - ++gd) - { - if (!(*gd)->times.empty() && (*gd)->times[0] < earliest) - earliest = (*gd)->times[0]; - } - if (earliest != INT64_MAX) - { - _globalTimeBase = earliest; - _timeBaseInitialized = true; - } - } + int64_t currentTime = Time::getAbs(); + Graph::setCurrentTime(currentTime); for (GraphList::iterator g = _graphs.begin(); g != _graphs.end(); ++g) { - if (_displayRelativeTimes && _timeBaseInitialized) + if (_displayRelativeTimes) (*g)->_timeBase = _globalTimeBase; else (*g)->_timeBase = 0.0; @@ -256,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()) @@ -278,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; } |