From bb91631807ad833a92d011895ad7ca1872e02745 Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Wed, 29 Jul 2009 13:11:10 +0200 Subject: 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. --- grapher/GraphWidget.cxx | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'grapher/GraphWidget.cxx') 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(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(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; + } } -- cgit