1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
26
27
28
29
34
35
36
37
38
39
44
45
50
51
52
53
54
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
81
82
83
/* ... */
#include <gui/graph_screen/GraphBelow.hpp>
using namespace touchgfx;
GraphBelow::~GraphBelow()
{
}{ ... }
bool GraphBelow::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);
canvas.moveTo(widgetXindex(firstIndex), widgetYindex(firstIndex));
for (int index = firstIndex + 1; index <= lastIndex; index++)
{
canvas.lineTo(widgetXindex(index), widgetYindex(index));
}for (int index = firstIndex + 1; index <= lastIndex; index++) { ... }
canvas.lineTo(widgetXindex(lastIndex), widgetY(0));
canvas.lineTo(widgetXindex(firstIndex), widgetY(0));
return canvas.render();
}if (firstIndex < lastIndex) { ... }
return true;
...}
Rect GraphBelow::getMinimalRectContainingIndices(int firstIndex, int lastIndex) const
{
int minX = widgetXindex(firstIndex).to<int>();
int maxX = widgetXindex(lastIndex).to<int>();
int zeroY = widgetY(0).to<int>();
int firstY = widgetYindex(firstIndex).to<int>();
int minY = MIN(zeroY, firstY);
int maxY = MAX(zeroY, firstY);
for (int index = firstIndex + 1; index <= lastIndex; index++)
{
int y = widgetYindex(index).to<int>();
minY = MIN(minY, y);
maxY = MAX(maxY, y);
}for (int index = firstIndex + 1; index <= lastIndex; index++) { ... }
return Rect(minX, minY, maxX - minX + 1, maxY - minY + 1);
...}