diff options
author | Tim Moore <timoore@redhat.com> | 2009-12-21 10:46:57 +0100 |
---|---|---|
committer | Tim Moore <timoore@redhat.com> | 2009-12-21 10:46:57 +0100 |
commit | 32902edf1f17bb62144f21ed38ae085bd2755e9f (patch) | |
tree | 7b9c8b185baf80b03e5509cc05ede7cf2f490910 /grapher/GraphStyle.cxx | |
parent | 261135850dbd4a2efd7d4cbd3d0e3dcde46688ee (diff) | |
download | systemtap-steved-32902edf1f17bb62144f21ed38ae085bd2755e9f.tar.gz systemtap-steved-32902edf1f17bb62144f21ed38ae085bd2755e9f.tar.xz systemtap-steved-32902edf1f17bb62144f21ed38ae085bd2755e9f.zip |
change namespace indentation to 0
A silly change, but this works better with other tools, like git
diff. I should have started the C++ files this way.
Diffstat (limited to 'grapher/GraphStyle.cxx')
-rw-r--r-- | grapher/GraphStyle.cxx | 328 |
1 files changed, 164 insertions, 164 deletions
diff --git a/grapher/GraphStyle.cxx b/grapher/GraphStyle.cxx index 69ff4089..6bf4e109 100644 --- a/grapher/GraphStyle.cxx +++ b/grapher/GraphStyle.cxx @@ -13,179 +13,179 @@ namespace systemtap { - using namespace std; - using namespace tr1; +using namespace std; +using namespace tr1; - typedef pair<GraphDataBase::TimeList::iterator, - GraphDataBase::TimeList::iterator> TimeListPair; +typedef pair<GraphDataBase::TimeList::iterator, + GraphDataBase::TimeList::iterator> TimeListPair; - GraphStyleBar GraphStyleBar::instance; +GraphStyleBar GraphStyleBar::instance; - void GraphStyleBar::draw(std::tr1::shared_ptr<GraphDataBase> graphData, - Graph* graph, Cairo::RefPtr<Cairo::Context> cr) - { - shared_ptr<GraphData<double> > realData - = dynamic_pointer_cast<GraphData<double> >(graphData); - if (!realData) - return; - int64_t left, right; - double top, bottom; - graph->getExtents(left, right, top, bottom); - double horizScale = (graph->_zoomFactor * graph->_graphWidth - / static_cast<double>(right - left)); - GraphDataBase::TimeList::iterator lower - = lower_bound(graphData->times.begin(), graphData->times.end(), left); - GraphDataBase::TimeList::iterator upper - = upper_bound(graphData->times.begin(), graphData->times.end(), right); - for (GraphDataBase::TimeList::iterator ditr = lower, de = upper; - ditr != de; - ++ditr) - { - size_t dataIndex = ditr - graphData->times.begin(); - cr->set_source_rgba(graphData->color[0], graphData->color[1], - graphData->color[2], 1.0); - cr->move_to((*ditr - left) * horizScale, 0); - cr->line_to((*ditr - left) * horizScale, - realData->data[dataIndex] * graph->_graphHeight - / graphData->scale); - cr->stroke(); - } - } +void GraphStyleBar::draw(std::tr1::shared_ptr<GraphDataBase> graphData, + Graph* graph, Cairo::RefPtr<Cairo::Context> cr) +{ + shared_ptr<GraphData<double> > realData + = dynamic_pointer_cast<GraphData<double> >(graphData); + if (!realData) + return; + int64_t left, right; + double top, bottom; + graph->getExtents(left, right, top, bottom); + double horizScale = (graph->_zoomFactor * graph->_graphWidth + / static_cast<double>(right - left)); + GraphDataBase::TimeList::iterator lower + = lower_bound(graphData->times.begin(), graphData->times.end(), left); + GraphDataBase::TimeList::iterator upper + = upper_bound(graphData->times.begin(), graphData->times.end(), right); + for (GraphDataBase::TimeList::iterator ditr = lower, de = upper; + ditr != de; + ++ditr) + { + size_t dataIndex = ditr - graphData->times.begin(); + cr->set_source_rgba(graphData->color[0], graphData->color[1], + graphData->color[2], 1.0); + cr->move_to((*ditr - left) * horizScale, 0); + cr->line_to((*ditr - left) * horizScale, + realData->data[dataIndex] * graph->_graphHeight + / graphData->scale); + cr->stroke(); + } +} - ssize_t GraphStyleBar::dataIndexAtPoint(double x, double y, - shared_ptr<GraphDataBase> graphData, - shared_ptr<Graph> graph) - { - shared_ptr<GraphData<double> > realData - = dynamic_pointer_cast<GraphData<double> >(graphData); - if (!realData || graphData->times.empty()) - return -1; - int64_t left, right; - double top, bottom; - graph->getExtents(left, right, top, bottom); - double t = graph->getTimeAtPoint(x); - TimeListPair range - = equal_range(graphData->times.begin(), graphData->times.end(), t); - if (range.first == graphData->times.end()) - return -1; - size_t dataIndex = distance(graphData->times.begin(), range.first); - double val = realData->data[dataIndex]; - double ycoord = val * graph->_graphHeight / graphData->scale; - if (y >= graph->_yOffset + graph->_graphHeight - ycoord) - return static_cast<ssize_t>(dataIndex); - else - return -1; - } +ssize_t GraphStyleBar::dataIndexAtPoint(double x, double y, + shared_ptr<GraphDataBase> graphData, + shared_ptr<Graph> graph) +{ + shared_ptr<GraphData<double> > realData + = dynamic_pointer_cast<GraphData<double> >(graphData); + if (!realData || graphData->times.empty()) + return -1; + int64_t left, right; + double top, bottom; + graph->getExtents(left, right, top, bottom); + double t = graph->getTimeAtPoint(x); + TimeListPair range + = equal_range(graphData->times.begin(), graphData->times.end(), t); + if (range.first == graphData->times.end()) + return -1; + size_t dataIndex = distance(graphData->times.begin(), range.first); + double val = realData->data[dataIndex]; + double ycoord = val * graph->_graphHeight / graphData->scale; + if (y >= graph->_yOffset + graph->_graphHeight - ycoord) + return static_cast<ssize_t>(dataIndex); + else + return -1; +} - GraphStyleDot GraphStyleDot::instance; +GraphStyleDot GraphStyleDot::instance; - void GraphStyleDot::draw(std::tr1::shared_ptr<GraphDataBase> graphData, - Graph* graph, Cairo::RefPtr<Cairo::Context> cr) - { - shared_ptr<GraphData<double> > realData - = dynamic_pointer_cast<GraphData<double> >(graphData); - if (!realData) - return; - int64_t left, right; - double top, bottom; - graph->getExtents(left, right, top, bottom); - double horizScale = (graph->_zoomFactor * graph->_graphWidth - / static_cast<double>(right - left)); - GraphDataBase::TimeList::iterator lower - = lower_bound(graphData->times.begin(), graphData->times.end(), left); - GraphDataBase::TimeList::iterator upper - = upper_bound(graphData->times.begin(), graphData->times.end(), right); - cr->set_source_rgba(graphData->color[0], graphData->color[1], - graphData->color[2], 1.0); +void GraphStyleDot::draw(std::tr1::shared_ptr<GraphDataBase> graphData, + Graph* graph, Cairo::RefPtr<Cairo::Context> cr) +{ + shared_ptr<GraphData<double> > realData + = dynamic_pointer_cast<GraphData<double> >(graphData); + if (!realData) + return; + int64_t left, right; + double top, bottom; + graph->getExtents(left, right, top, bottom); + double horizScale = (graph->_zoomFactor * graph->_graphWidth + / static_cast<double>(right - left)); + GraphDataBase::TimeList::iterator lower + = lower_bound(graphData->times.begin(), graphData->times.end(), left); + GraphDataBase::TimeList::iterator upper + = upper_bound(graphData->times.begin(), graphData->times.end(), right); + cr->set_source_rgba(graphData->color[0], graphData->color[1], + graphData->color[2], 1.0); - for (GraphDataBase::TimeList::iterator ditr = lower, de = upper; - ditr != de; - ++ditr) - { - size_t dataIndex = ditr - graphData->times.begin(); - cr->arc((*ditr - left) * horizScale, - (realData->data[dataIndex] - * graph->_graphHeight / graphData->scale), - graph->_lineWidth / 2.0, 0.0, M_PI * 2.0); - cr->fill(); - } - } + for (GraphDataBase::TimeList::iterator ditr = lower, de = upper; + ditr != de; + ++ditr) + { + size_t dataIndex = ditr - graphData->times.begin(); + cr->arc((*ditr - left) * horizScale, + (realData->data[dataIndex] + * graph->_graphHeight / graphData->scale), + graph->_lineWidth / 2.0, 0.0, M_PI * 2.0); + cr->fill(); + } +} - GraphStyleEvent GraphStyleEvent::instance; +GraphStyleEvent GraphStyleEvent::instance; - void GraphStyleEvent::draw(std::tr1::shared_ptr<GraphDataBase> graphData, - Graph* graph, Cairo::RefPtr<Cairo::Context> cr) - { - shared_ptr<GraphData<string> > stringData - = dynamic_pointer_cast<GraphData<string> >(graphData); - if (!stringData) - return; - int64_t left, right; - double top, bottom; - graph->getExtents(left, right, top, bottom); - double horizScale = (graph->_zoomFactor * graph->_graphWidth - / static_cast<double>(right - left)); - double eventHeight = graph->_graphHeight * (graphData->scale / 100.0); - cr->save(); - cr->set_line_width(3 * graph->_lineWidth); - cr->set_source_rgba(graphData->color[0], graphData->color[1], - graphData->color[2], .33); - cr->move_to(0, eventHeight); - cr->line_to(graph->_graphWidth, eventHeight); - cr->stroke(); - cr->restore(); - GraphDataBase::TimeList::iterator lower - = lower_bound(graphData->times.begin(), graphData->times.end(), left); - GraphDataBase::TimeList::iterator upper - = upper_bound(graphData->times.begin(), graphData->times.end(), right); - for (GraphDataBase::TimeList::iterator ditr = lower, de = upper; - ditr != de; - ++ditr) - { - // size_t dataIndex = ditr - graphData->times.begin(); - double eventHeight = graph->_graphHeight * (graphData->scale / 100.0); - cr->save(); - cr->set_source_rgba(graphData->color[0], graphData->color[1], - graphData->color[2], 1.0); - cr->rectangle((*ditr - left) * horizScale - 1.5 * graph->_lineWidth, - eventHeight - 1.5 * graph->_lineWidth, - 3.0 * graph->_lineWidth, 3.0 * graph->_lineWidth); - cr->fill(); - cr->restore(); - } - } +void GraphStyleEvent::draw(std::tr1::shared_ptr<GraphDataBase> graphData, + Graph* graph, Cairo::RefPtr<Cairo::Context> cr) +{ + shared_ptr<GraphData<string> > stringData + = dynamic_pointer_cast<GraphData<string> >(graphData); + if (!stringData) + return; + int64_t left, right; + double top, bottom; + graph->getExtents(left, right, top, bottom); + double horizScale = (graph->_zoomFactor * graph->_graphWidth + / static_cast<double>(right - left)); + double eventHeight = graph->_graphHeight * (graphData->scale / 100.0); + cr->save(); + cr->set_line_width(3 * graph->_lineWidth); + cr->set_source_rgba(graphData->color[0], graphData->color[1], + graphData->color[2], .33); + cr->move_to(0, eventHeight); + cr->line_to(graph->_graphWidth, eventHeight); + cr->stroke(); + cr->restore(); + GraphDataBase::TimeList::iterator lower + = lower_bound(graphData->times.begin(), graphData->times.end(), left); + GraphDataBase::TimeList::iterator upper + = upper_bound(graphData->times.begin(), graphData->times.end(), right); + for (GraphDataBase::TimeList::iterator ditr = lower, de = upper; + ditr != de; + ++ditr) + { + // size_t dataIndex = ditr - graphData->times.begin(); + double eventHeight = graph->_graphHeight * (graphData->scale / 100.0); + cr->save(); + cr->set_source_rgba(graphData->color[0], graphData->color[1], + graphData->color[2], 1.0); + cr->rectangle((*ditr - left) * horizScale - 1.5 * graph->_lineWidth, + eventHeight - 1.5 * graph->_lineWidth, + 3.0 * graph->_lineWidth, 3.0 * graph->_lineWidth); + cr->fill(); + cr->restore(); + } +} - ssize_t GraphStyleEvent::dataIndexAtPoint(double x, double y, - shared_ptr<GraphDataBase> graphData, - shared_ptr<Graph> graph) - { - shared_ptr<GraphData<string> > stringData - = dynamic_pointer_cast<GraphData<string> >(graphData); - if (!stringData || graphData->times.empty()) - return -1; - int64_t left, right; - double top, bottom; - graph->getExtents(left, right, top, bottom); - double horizScale = (graph->_zoomFactor * graph->_graphWidth - / static_cast<double>(right - left)); - double eventHeight = graph->_graphHeight * (graphData->scale / 100.0); - GraphDataBase::TimeList::iterator lower - = lower_bound(graphData->times.begin(), graphData->times.end(), left); - GraphDataBase::TimeList::iterator upper - = upper_bound(graphData->times.begin(), graphData->times.end(), right); - // easier to transform x,y into graph coordinates - double xgraph, ygraph; - graph->window2GraphCoords(x, y, xgraph, ygraph); - double yrect = eventHeight - 1.5 * graph->_lineWidth; - for (GraphDataBase::TimeList::iterator ditr = lower, de = upper; - ditr != de; - ++ditr) - { - double xrect = (*ditr - left) * horizScale - 1.5 * graph->_lineWidth; - if (xrect <= xgraph && xgraph < xrect + 3.0 * graph->_lineWidth - && yrect <= ygraph && ygraph < yrect + 3.0 * graph->_lineWidth) - return static_cast<ssize_t>(distance(lower, ditr)); - } +ssize_t GraphStyleEvent::dataIndexAtPoint(double x, double y, + shared_ptr<GraphDataBase> graphData, + shared_ptr<Graph> graph) +{ + shared_ptr<GraphData<string> > stringData + = dynamic_pointer_cast<GraphData<string> >(graphData); + if (!stringData || graphData->times.empty()) return -1; - } + int64_t left, right; + double top, bottom; + graph->getExtents(left, right, top, bottom); + double horizScale = (graph->_zoomFactor * graph->_graphWidth + / static_cast<double>(right - left)); + double eventHeight = graph->_graphHeight * (graphData->scale / 100.0); + GraphDataBase::TimeList::iterator lower + = lower_bound(graphData->times.begin(), graphData->times.end(), left); + GraphDataBase::TimeList::iterator upper + = upper_bound(graphData->times.begin(), graphData->times.end(), right); + // easier to transform x,y into graph coordinates + double xgraph, ygraph; + graph->window2GraphCoords(x, y, xgraph, ygraph); + double yrect = eventHeight - 1.5 * graph->_lineWidth; + for (GraphDataBase::TimeList::iterator ditr = lower, de = upper; + ditr != de; + ++ditr) + { + double xrect = (*ditr - left) * horizScale - 1.5 * graph->_lineWidth; + if (xrect <= xgraph && xgraph < xrect + 3.0 * graph->_lineWidth + && yrect <= ygraph && ygraph < yrect + 3.0 * graph->_lineWidth) + return static_cast<ssize_t>(distance(lower, ditr)); + } + return -1; +} } |