diff options
author | Tim Moore <timoore@redhat.com> | 2009-12-07 12:43:56 +0100 |
---|---|---|
committer | Tim Moore <timoore@redhat.com> | 2009-12-07 12:43:56 +0100 |
commit | 5891de489db0e172162279247fb633a719fa3756 (patch) | |
tree | 2cda126a35ebe9ba130299455f515618b4ab898b | |
parent | e88061ec1fb047b65c247424dbadb10a85ff69ae (diff) | |
download | systemtap-steved-5891de489db0e172162279247fb633a719fa3756.tar.gz systemtap-steved-5891de489db0e172162279247fb633a719fa3756.tar.xz systemtap-steved-5891de489db0e172162279247fb633a719fa3756.zip |
option to display graph times relative to the start time
This avoids having humongous numbers displayed on the graphs' x
axis. Also, the dialog for adding a data set to a graph was cleaned
up.
* grapher/graph-dialog.glade: Add check box for display of relative
time and a label for the data set list. Force the list of data sets
to be larger.
* grapher/Graph.hxx (_timeBase): new member
* grapher/Graph.cxx (draw): Subtract _timeBase from displayed time
value.
* grapher/GraphWidget.hxx (DataModelColumns): Add a column for a data
set's title, which is optional at the moment.
* grapher/GraphWidget.hxx (_globalTimeBase, _timeBaseInitialized,
_relativeTimesButton, _displayRelativeTimes): new members
* grapher/GraphWidget.hxx (GraphWidget): Hook up check button for
displaying relative time.
(on_expose_event): Determine base time if needed; set base time in
graphs.
(onDataDialogOpen): Insert graph data set's name (key) and title
into the list of data sets.
-rw-r--r-- | grapher/Graph.cxx | 4 | ||||
-rw-r--r-- | grapher/Graph.hxx | 1 | ||||
-rw-r--r-- | grapher/GraphWidget.cxx | 46 | ||||
-rw-r--r-- | grapher/GraphWidget.hxx | 7 | ||||
-rw-r--r-- | grapher/graph-dialog.glade | 46 |
5 files changed, 98 insertions, 6 deletions
diff --git a/grapher/Graph.cxx b/grapher/Graph.cxx index b3429ef7..baa1182f 100644 --- a/grapher/Graph.cxx +++ b/grapher/Graph.cxx @@ -14,7 +14,7 @@ namespace systemtap _graphWidth(580), _graphHeight(180), _lineWidth(2), _autoScaling(true), _autoScrolling(true), _zoomFactor(1.0), _xOffset(20.0), _yOffset(0.0), - _playButton(new CairoPlayButton), + _playButton(new CairoPlayButton), _timeBase(0), _left(0), _right(1), _top(5.0), _bottom(0.0) { setOrigin(x, y); @@ -150,7 +150,7 @@ namespace systemtap cr->move_to(x, _yOffset); cr->line_to(x, _graphHeight); std::ostringstream stream; - stream << tickVal; + stream << (tickVal - _timeBase); Cairo::TextExtents extents; cr->get_text_extents(stream.str(), extents); // Room for this label? diff --git a/grapher/Graph.hxx b/grapher/Graph.hxx index 044a66d3..93e23deb 100644 --- a/grapher/Graph.hxx +++ b/grapher/Graph.hxx @@ -39,6 +39,7 @@ namespace systemtap double _xOffset; double _yOffset; std::tr1::shared_ptr<CairoPlayButton> _playButton; + int64_t _timeBase; DatasetList& getDatasets() { return _datasets; } int64_t getTimeAtPoint(double x); void window2GraphCoords(double x, double y, double& xgraph, double& ygraph); diff --git a/grapher/GraphWidget.cxx b/grapher/GraphWidget.cxx index cfec0adf..9d5e12f8 100644 --- a/grapher/GraphWidget.cxx +++ b/grapher/GraphWidget.cxx @@ -4,6 +4,9 @@ #include <math.h> #include <iostream> +#define __STDC_LIMIT_MACROS +#include <stdint.h> + #include <glibmm/timer.h> #include <cairomm/context.h> #include <libglademm.h> @@ -22,7 +25,7 @@ namespace systemtap GraphWidget::GraphWidget() : _trackingDrag(false), _width(600), _height(200), _mouseX(0.0), - _mouseY(0.0) + _mouseY(0.0), _globalTimeBase(0), _timeBaseInitialized(false) { add_events(Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::SCROLL_MASK); @@ -70,6 +73,14 @@ namespace systemtap _listStore = Gtk::ListStore::create(_dataColumns); _dataTreeView->set_model(_listStore); _dataTreeView->append_column("Data", _dataColumns._dataName); + _dataTreeView->append_column("Title", _dataColumns._dataTitle); + _refXmlDataDialog->get_widget("checkbutton1", _relativeTimesButton); + _relativeTimesButton->signal_clicked() + .connect(sigc::mem_fun(*this, + &GraphWidget::onRelativeTimesButtonClicked)); + // Set button's initial value from that in .glade file + _displayRelativeTimes = _relativeTimesButton->get_active(); + } catch (const Gnome::Glade::XmlError& ex ) { @@ -100,6 +111,7 @@ namespace systemtap shared_ptr<Graph> graph(new Graph(x, y)); _height = y + graph->_height; graph->setOrigin(x, y); + graph->_timeBase = _globalTimeBase; _graphs.push_back(graph); queue_resize(); } @@ -115,8 +127,29 @@ namespace systemtap cr->save(); cr->set_source_rgba(0.0, 0.0, 0.0, 1.0); cr->paint(); + if (!_timeBaseInitialized && !_graphData.empty()) + { + 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; + } + } for (GraphList::iterator g = _graphs.begin(); g != _graphs.end(); ++g) { + if (_displayRelativeTimes && _timeBaseInitialized) + (*g)->_timeBase = _globalTimeBase; + else + (*g)->_timeBase = 0.0; double x, y; (*g)->getOrigin(x, y); cr->save(); @@ -269,10 +302,9 @@ namespace systemtap { Gtk::TreeModel::iterator litr = _listStore->append(); Gtk::TreeModel::Row row = *litr; + row[_dataColumns._dataName] = (*itr)->name; if (!(*itr)->title.empty()) - row[_dataColumns._dataName] = (*itr)->title; - else - row[_dataColumns._dataName] = (*itr)->name; + row[_dataColumns._dataTitle] = (*itr)->title; row[_dataColumns._graphData] = *itr; } } @@ -326,4 +358,10 @@ namespace systemtap _hover_timeout_connection = Glib::signal_timeout() .connect(sigc::mem_fun(*this, &GraphWidget::onHoverTimeout), 1000); } + + void GraphWidget::onRelativeTimesButtonClicked() + { + _displayRelativeTimes = _relativeTimesButton->get_active(); + queue_draw(); + } } diff --git a/grapher/GraphWidget.hxx b/grapher/GraphWidget.hxx index 61d50e70..ea10720c 100644 --- a/grapher/GraphWidget.hxx +++ b/grapher/GraphWidget.hxx @@ -19,9 +19,11 @@ namespace systemtap DataModelColumns() { add(_dataName); + add(_dataTitle); add(_graphData); } Gtk::TreeModelColumn<Glib::ustring> _dataName; + Gtk::TreeModelColumn<Glib::ustring> _dataTitle; Gtk::TreeModelColumn<std::tr1::shared_ptr<GraphDataBase> > _graphData; }; @@ -72,8 +74,13 @@ namespace systemtap std::tr1::shared_ptr<CairoTextBox> _hoverText; double _mouseX; double _mouseY; + int64_t _globalTimeBase; + bool _timeBaseInitialized; std::tr1::shared_ptr<Graph> getGraphUnderPoint(double x, double y); void establishHoverTimeout(); + Gtk::CheckButton* _relativeTimesButton; + bool _displayRelativeTimes; + void onRelativeTimesButtonClicked(); }; } #endif // SYSTEMTAP_GRAPHWIDGET_H diff --git a/grapher/graph-dialog.glade b/grapher/graph-dialog.glade index cca2e0e3..85c10128 100644 --- a/grapher/graph-dialog.glade +++ b/grapher/graph-dialog.glade @@ -67,6 +67,31 @@ </child> <child> + <widget class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="label" translatable="yes">Data sets</property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">False</property> + <property name="selectable">False</property> + <property name="xalign">0</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> <widget class="GtkHBox" id="hbox1"> <property name="visible">True</property> <property name="homogeneous">False</property> @@ -83,6 +108,8 @@ <child> <widget class="GtkTreeView" id="treeview1"> + <property name="width_request">200</property> + <property name="height_request">100</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="headers_visible">False</property> @@ -159,6 +186,25 @@ <property name="fill">True</property> </packing> </child> + + <child> + <widget class="GtkCheckButton" id="checkbutton1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label" translatable="yes">Display relative times</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="active">True</property> + <property name="inconsistent">False</property> + <property name="draw_indicator">True</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> </widget> </child> </widget> |