diff options
author | Tim Moore <timoore@redhat.com> | 2009-07-29 13:11:10 +0200 |
---|---|---|
committer | Tim Moore <timoore@redhat.com> | 2009-09-30 20:25:36 +0200 |
commit | bb91631807ad833a92d011895ad7ca1872e02745 (patch) | |
tree | cf3c8f2611a27ade0f0b792c40a0533dc030145e /grapher/GraphWidget.cxx | |
parent | 27993a166c3ff2c33f778da4d96726666aadfab9 (diff) | |
download | systemtap-steved-bb91631807ad833a92d011895ad7ca1872e02745.tar.gz systemtap-steved-bb91631807ad833a92d011895ad7ca1872e02745.tar.xz systemtap-steved-bb91631807ad833a92d011895ad7ca1872e02745.zip |
Draw multiple graphs
* grapher/Graph.cxx (Graph constructor): Initialize graph dimensions.
(draw): Don't clear the drawing area.
* grapher/GraphWidget.hxx (GraphWidget): Add dimensions and
on_size_request() method.
* grapher/GraphWidget.cxx (GraphWidget constructor): Initialize
dimensions.
(addGraph): New method.
(on_size_request): New method to pass widget's size to parent widgets
* grapher/grapher.cxx (GrapherWindow constructor): add "add graph"
action.
(addGraph): New method.
Diffstat (limited to 'grapher/GraphWidget.cxx')
-rw-r--r-- | grapher/GraphWidget.cxx | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/grapher/GraphWidget.cxx b/grapher/GraphWidget.cxx index 53c7645d..c4613fd7 100644 --- a/grapher/GraphWidget.cxx +++ b/grapher/GraphWidget.cxx @@ -12,7 +12,7 @@ namespace systemtap using namespace std::tr1; GraphWidget::GraphWidget() - : _trackingDrag(false) + : _trackingDrag(false), _width(600), _height(200) { add_events(Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::SCROLL_MASK); @@ -33,8 +33,6 @@ namespace systemtap .connect(sigc::mem_fun(*this, &GraphWidget::on_scroll_event), false); // Temporary testing of multiple graphs shared_ptr<Graph> graph(new Graph); - graph->_graphHeight = 180; - graph->_graphWidth = 580; _graphs.push_back(graph); } @@ -46,6 +44,22 @@ namespace systemtap { _graphs[0]->addGraphData(data); } + + void GraphWidget::addGraph() + { + shared_ptr<Graph> graph(new Graph); + double x = 0.0; + double y = 0.0; + if (!_graphs.empty()) + { + _graphs.back()->getOrigin(x, y); + y += _graphs.back()->_height + 10; + _height = y + graph->_height; + } + graph->setOrigin(x, y); + _graphs.push_back(graph); + queue_resize(); + } bool GraphWidget::on_expose_event(GdkEventExpose* event) { @@ -174,4 +188,10 @@ namespace systemtap queue_draw(); return true; } + + void GraphWidget::on_size_request(Gtk::Requisition* req) + { + req->width = _width; + req->height = _height; + } } |