1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
27
28
33
34
35
36
41
42
43
44
45
46
51
52
57
73
74
75
76
77
78
79
80
81
82
87
88
89
90
91
/* ... */
#include <gui/graph_screen/GraphDots.hpp>
using namespace touchgfx;
GraphDots::GraphDots() :
AbstractGraph(), startAngle(0), angleStep(30)
{
}{ ... }
void GraphDots::setDotShape(int dotStartAngle, int dotAngleStep)
{
startAngle = dotStartAngle;
angleStep = dotAngleStep;
}{ ... }
bool GraphDots::drawCanvasWidget(const Rect& invalidatedArea) const
{
if (numPoints < 2)
{
return true;
}if (numPoints < 2) { ... }
int firstIndex = 0;
int lastIndex = numPoints - 1;
while (firstIndex < lastIndex &&
invalidatedArea.x > (widgetXindex(firstIndex + 1) + lineWidth / 2).to<int>())
{
firstIndex++;
}while (firstIndex < lastIndex && invalidatedArea.x > (widgetXindex(firstIndex + 1) + lineWidth / 2).to()) { ... }
while (lastIndex > firstIndex &&
invalidatedArea.right() < (widgetXindex(lastIndex - 1) - lineWidth / 2).to<int>())
{
lastIndex--;
}while (lastIndex > firstIndex && invalidatedArea.right() < (widgetXindex(lastIndex - 1) - lineWidth / 2).to()) { ... }
if (firstIndex < lastIndex)
{
Canvas canvas(this, invalidatedArea);
for (int index = firstIndex; index <= lastIndex; index++)
{
CWRUtil::Q5 circleCenterX, circleCenterY;
circleCenterX = widgetXindex(index);
circleCenterY = widgetYindex(index);
canvas.moveTo(circleCenterX + ((lineWidth * CWRUtil::sine(startAngle)) / 2), circleCenterY - ((lineWidth * CWRUtil::cosine(startAngle)) / 2));
for (int angle = startAngle + angleStep; (angle % 360) != startAngle; angle += angleStep)
{
canvas.lineTo(circleCenterX + ((lineWidth * CWRUtil::sine(angle)) / 2), circleCenterY - ((lineWidth * CWRUtil::cosine(angle)) / 2));
}for (int angle = startAngle + angleStep; (angle % 360) != startAngle; angle += angleStep) { ... }
}for (int index = firstIndex; index <= lastIndex; index++) { ... }
return canvas.render();
}if (firstIndex < lastIndex) { ... }
return true;
...}
Rect GraphDots::getMinimalRectContainingIndices(int firstIndex, int lastIndex) const
{
int minX = (widgetXindex(firstIndex) - lineWidth / 2).to<int>();
int maxX = (widgetXindex(lastIndex) + lineWidth / 2).to<int>();
int minY = (widgetYindex(firstIndex) - lineWidth / 2).to<int>();
int maxY = (widgetYindex(firstIndex) + lineWidth / 2).to<int>();
for (int index = firstIndex + 1; index <= lastIndex; index++)
{
minY = MIN(minY, (widgetYindex(index) - lineWidth / 2).to<int>());
maxY = MAX(maxY, (widgetYindex(index) + lineWidth / 2).to<int>());
}for (int index = firstIndex + 1; index <= lastIndex; index++) { ... }
Rect minimalRect = Rect(minX, minY, maxX - minX + 1, maxY - minY + 1);
return minimalRect;
...}