From 14eb23b75be2e9ebc2cdda842e6e787b3e50efd5 Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Tue, 28 Jul 2009 12:27:23 +0200 Subject: Draw graphs inside a scrolled window * grapher/grapher.cxx (GrapherWindow, GrapherWindow constructor): Add ScrolledWindow object and display it. Make GraphWidget its child. --- grapher/grapher.cxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'grapher') diff --git a/grapher/grapher.cxx b/grapher/grapher.cxx index a0d35017..95ac232d 100644 --- a/grapher/grapher.cxx +++ b/grapher/grapher.cxx @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -27,6 +28,7 @@ public: GrapherWindow(); virtual ~GrapherWindow() {} Gtk::VBox m_Box; + Gtk::ScrolledWindow scrolled; GraphWidget w; protected: virtual void on_menu_file_quit(); @@ -70,10 +72,11 @@ GrapherWindow::GrapherWindow() std::cerr << "building menus failed: " << ex.what(); } Gtk::Widget* pMenubar = m_refUIManager->get_widget("/MenuBar"); + scrolled.add(w); if(pMenubar) m_Box.pack_start(*pMenubar, Gtk::PACK_SHRINK); - m_Box.pack_start(w, Gtk::PACK_EXPAND_WIDGET); - w.show(); + m_Box.pack_start(scrolled, Gtk::PACK_EXPAND_WIDGET); + scrolled.show(); show_all_children(); -- cgit From 688a8322340c2d7738472270a455fbfe5587a2d2 Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Tue, 28 Jul 2009 12:59:52 +0200 Subject: Fix graph attribute parsing buglet * grapher/StapParser.cxx (findTaggedValue): Extract value substring after tag. --- grapher/StapParser.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'grapher') diff --git a/grapher/StapParser.cxx b/grapher/StapParser.cxx index d70c75b6..47dfbe30 100644 --- a/grapher/StapParser.cxx +++ b/grapher/StapParser.cxx @@ -58,7 +58,7 @@ vector commaSplit(const string& inStr, size_t pos = 0) { size_t found; if ((found = src.find(tag)) != string::npos) - result = src.substr(strlen(tag)); + result = src.substr(found + strlen(tag)); return found; } @@ -152,7 +152,7 @@ vector commaSplit(const string& inStr, size_t pos = 0) shared_ptr gdata = itr->second; string decl; // Hack: scan from the beginning of dataString again - if (findTaggedValue(dataString, "%Title", decl) + if (findTaggedValue(dataString, "%Title:", decl) != string::npos) { gdata->title = decl; -- cgit From ae98ab3529e00906645c9a2d0a30f36d9d534f3e Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Wed, 29 Jul 2009 10:49:06 +0200 Subject: Initialize CairoWidget origin of graph * grapher/Graph.hxx (Graph constructor): add origin arguments * grapher/Graph.cxx: ditto * grapher/GraphWidget.cxx (on_expose_event): Use CairoWidget origin to position graphs. --- grapher/Graph.cxx | 6 ++++-- grapher/Graph.hxx | 2 +- grapher/GraphWidget.cxx | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) (limited to 'grapher') diff --git a/grapher/Graph.cxx b/grapher/Graph.cxx index ec5e4035..e1ea01f6 100644 --- a/grapher/Graph.cxx +++ b/grapher/Graph.cxx @@ -9,11 +9,13 @@ namespace systemtap using namespace std; using namespace std::tr1; - Graph::Graph() - : _lineWidth(2), _autoScaling(true), _autoScrolling(true), + Graph::Graph(double x, double y) + : _graphX(0), _graphY(0), + _lineWidth(2), _autoScaling(true), _autoScrolling(true), _zoomFactor(1.0), _playButton(new CairoPlayButton), _left(0.0), _right(1.0), _top(5.0), _bottom(0.0) { + setOrigin(x, y); } diff --git a/grapher/Graph.hxx b/grapher/Graph.hxx index 1cc1892d..aad63767 100644 --- a/grapher/Graph.hxx +++ b/grapher/Graph.hxx @@ -12,7 +12,7 @@ namespace systemtap { public: friend class GraphWidget; - Graph(); + Graph(double x = 0.0, double y = 0.0); virtual void draw(Cairo::RefPtr cr); virtual bool containsPoint(double x, double y); double getLineWidth() { return _lineWidth; } diff --git a/grapher/GraphWidget.cxx b/grapher/GraphWidget.cxx index 4a1e0918..53c7645d 100644 --- a/grapher/GraphWidget.cxx +++ b/grapher/GraphWidget.cxx @@ -70,8 +70,10 @@ namespace systemtap cr->paint(); for (GraphList::iterator g = _graphs.begin(); g != _graphs.end(); ++g) { + double x, y; + (*g)->getOrigin(x, y); cr->save(); - cr->translate((*g)->_graphX, (*g)->_graphY); + cr->translate(x, y); (*g)->draw(cr); cr->restore(); } -- cgit