From 6197b0dc80c4f87000d26213293fe2cb72fbe081 Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Tue, 1 Dec 2009 19:05:09 +0100 Subject: Refactor drawing of different styles of graph into classes * grapher/GraphStyle.cxx: New file * grapher/GraphStyle.hxx: New file * grapher/Graph(draw): Move much drawing code to GraphStyle::draw --- grapher/GraphStyle.hxx | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 grapher/GraphStyle.hxx (limited to 'grapher/GraphStyle.hxx') diff --git a/grapher/GraphStyle.hxx b/grapher/GraphStyle.hxx new file mode 100644 index 00000000..4a0cd955 --- /dev/null +++ b/grapher/GraphStyle.hxx @@ -0,0 +1,43 @@ +#ifndef SYSTEMTAP_GRAPHSTYLE_HXX +#define SYSTEMTAP_GRAPHSTYLE_HXX 1 +#include + +#include + +namespace systemtap +{ + class GraphDataBase; + class Graph; + + class GraphStyle + { + public: + virtual void draw(std::tr1::shared_ptr graphData, + Graph* graph, Cairo::RefPtr cr) = 0; + }; + + class GraphStyleBar : public GraphStyle + { + public: + virtual void draw(std::tr1::shared_ptr graphData, + Graph* graph, Cairo::RefPtr cr); + static GraphStyleBar instance; + }; + + class GraphStyleDot : public GraphStyle + { + public: + virtual void draw(std::tr1::shared_ptr graphData, + Graph* graph, Cairo::RefPtr cr); + static GraphStyleDot instance; + }; + + class GraphStyleEvent : public GraphStyle + { + public: + virtual void draw(std::tr1::shared_ptr graphData, + Graph* graph, Cairo::RefPtr cr); + static GraphStyleEvent instance; + }; +} +#endif -- cgit From c10fce7d6aaa57a4f94f9d7aeea906597456f7ce Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Wed, 2 Dec 2009 19:27:07 +0100 Subject: Make the hover text conform to data displayed. Start of code to be more selective about the association between the hover text and the underling graph. Also, show the data set name in hover text. * grapher/GraphStyle.hxx (dataIndexAtPoint): New virtual function. * grapher/GraphStyle.cxx (dataIndexAtPoint): Implementation for bar graphs * grapher/GraphWidget.cxx (onHoverTimeout): Use dataIndexAtPoint. --- grapher/GraphStyle.hxx | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'grapher/GraphStyle.hxx') diff --git a/grapher/GraphStyle.hxx b/grapher/GraphStyle.hxx index 4a0cd955..9625f451 100644 --- a/grapher/GraphStyle.hxx +++ b/grapher/GraphStyle.hxx @@ -14,29 +14,40 @@ namespace systemtap public: virtual void draw(std::tr1::shared_ptr graphData, Graph* graph, Cairo::RefPtr cr) = 0; + virtual ssize_t dataIndexAtPoint(double x, double y, + std::tr1::shared_ptr + graphData, + std::tr1::shared_ptr graph) + { + return -1; + } }; class GraphStyleBar : public GraphStyle { public: - virtual void draw(std::tr1::shared_ptr graphData, - Graph* graph, Cairo::RefPtr cr); + void draw(std::tr1::shared_ptr graphData, + Graph* graph, Cairo::RefPtr cr); + static GraphStyleBar instance; + ssize_t dataIndexAtPoint(double x, double y, + std::tr1::shared_ptr graphData, + std::tr1::shared_ptr graph); }; class GraphStyleDot : public GraphStyle { public: - virtual void draw(std::tr1::shared_ptr graphData, - Graph* graph, Cairo::RefPtr cr); + void draw(std::tr1::shared_ptr graphData, + Graph* graph, Cairo::RefPtr cr); static GraphStyleDot instance; }; class GraphStyleEvent : public GraphStyle { public: - virtual void draw(std::tr1::shared_ptr graphData, - Graph* graph, Cairo::RefPtr cr); + void draw(std::tr1::shared_ptr graphData, + Graph* graph, Cairo::RefPtr cr); static GraphStyleEvent instance; }; } -- cgit