summaryrefslogtreecommitdiffstats
path: root/grapher/GraphWidget.cxx
diff options
context:
space:
mode:
authorTim Moore <timoore@redhat.com>2009-12-22 11:35:38 +0100
committerTim Moore <timoore@redhat.com>2009-12-23 00:04:11 +0100
commite3a546d81cd115d7cd9105fc31ecccecfb48b71d (patch)
treeedaf59835ce9774b69c72ddbe9ec28dfb925b188 /grapher/GraphWidget.cxx
parent2d0ddea123e8d5d1113b80692689a80f37d46e6f (diff)
downloadsystemtap-steved-e3a546d81cd115d7cd9105fc31ecccecfb48b71d.tar.gz
systemtap-steved-e3a546d81cd115d7cd9105fc31ecccecfb48b71d.tar.xz
systemtap-steved-e3a546d81cd115d7cd9105fc31ecccecfb48b71d.zip
grapher: scroll continuously with time
Don't scale graph based on how much data will fit. This didn't work very well and resulted in distracting, weird scale changes. We now assume that scripts output their time (x axis) in milliseconds. * grapher/Graph.hxx (setCurrentTime): New function. * grapher/Graph.cxx (Graph::draw): Assume a fixed default scale of 1 pixel = 5 milliseconds and don't do any autoscaling. * grapher/GraphWidget.cxx (GraphWidget constructor): Set global time base on startup. (on_expose_event): Don't search graphs for earliest time. * grapher/GraphWidget.hxx (_timeBaseInitialized): delete * grapher/Time.hxx: new file; interface to timeval.
Diffstat (limited to 'grapher/GraphWidget.cxx')
-rw-r--r--grapher/GraphWidget.cxx25
1 files changed, 5 insertions, 20 deletions
diff --git a/grapher/GraphWidget.cxx b/grapher/GraphWidget.cxx
index db7493fb..be1ebdcd 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;