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:
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <Shape.h>
|
||||||
#include <View.h>
|
#include <View.h>
|
||||||
|
|
||||||
#include "chart/ChartDataSource.h"
|
#include "chart/ChartDataSource.h"
|
||||||
@@ -189,19 +190,23 @@ LineChartRenderer::Render(BView* view, BRect updateRect)
|
|||||||
double scale = (double)fFrame.IntegerHeight() / sampleRange;
|
double scale = (double)fFrame.IntegerHeight() / sampleRange;
|
||||||
|
|
||||||
// draw
|
// draw
|
||||||
|
view->SetLineMode(B_ROUND_CAP, B_ROUND_JOIN);
|
||||||
for (int32 i = 0; DataSourceInfo* info = fDataSources.ItemAt(i); i++) {
|
for (int32 i = 0; DataSourceInfo* info = fDataSources.ItemAt(i); i++) {
|
||||||
printf("LineChartRenderer::Render(): %p\n", info);
|
printf("LineChartRenderer::Render(): %p\n", info);
|
||||||
view->SetHighColor(info->config.Color());
|
|
||||||
|
|
||||||
float bottom = fFrame.bottom;
|
float bottom = fFrame.bottom;
|
||||||
view->MovePenTo(left + first,
|
BShape shape;
|
||||||
bottom - ((info->samples[first] - minRange) * scale));
|
shape.MoveTo(BPoint(left + first,
|
||||||
|
bottom - ((info->samples[first] - minRange) * scale)));
|
||||||
|
|
||||||
for (int32 i = first; i <= last; i++) {
|
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))));
|
float(bottom - ((info->samples[i] - minRange) * scale))));
|
||||||
//printf(" %f: %f (%f)\n", info->samples[i] - minRange, float(bottom - ((info->samples[i] - minRange) * scale)), bottom);
|
//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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user