Use a BShape do draw the chart lines:

-> Significant speed up, since there is much less app_server communication.
-> Much improved looks, since the line is now drawn as one connected line.
   The StrokeLine(BPoint to) version cannot do this.
Hope I am not interfering, Ingo!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30676 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2009-05-08 20:20:21 +00:00
parent a786c139ef
commit 04080048df
@@ -7,6 +7,7 @@
#include <stdio.h>
#include <Shape.h>
#include <View.h>
#include "chart/ChartDataSource.h"
@@ -189,19 +190,23 @@ LineChartRenderer::Render(BView* view, BRect updateRect)
double scale = (double)fFrame.IntegerHeight() / sampleRange;
// draw
view->SetLineMode(B_ROUND_CAP, B_ROUND_JOIN);
for (int32 i = 0; DataSourceInfo* info = fDataSources.ItemAt(i); i++) {
printf("LineChartRenderer::Render(): %p\n", info);
view->SetHighColor(info->config.Color());
float bottom = fFrame.bottom;
view->MovePenTo(left + first,
bottom - ((info->samples[first] - minRange) * scale));
BShape shape;
shape.MoveTo(BPoint(left + first,
bottom - ((info->samples[first] - minRange) * scale)));
for (int32 i = first; i <= last; i++) {
view->StrokeLine(BPoint(float(left + i),
shape.LineTo(BPoint(float(left + i),
float(bottom - ((info->samples[i] - minRange) * scale))));
//printf(" %f: %f (%f)\n", info->samples[i] - minRange, float(bottom - ((info->samples[i] - minRange) * scale)), bottom);
}
view->SetHighColor(info->config.Color());
view->MovePenTo(B_ORIGIN);
view->StrokeShape(&shape);
}
}