1/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
2/* If you are missing that file, acquire a complete release at teeworlds.com. */
3
4#ifndef ENGINE_CLIENT_GRAPH_H
5#define ENGINE_CLIENT_GRAPH_H
6
7#include <base/color.h>
8
9#include <engine/shared/ringbuffer.h>
10
11#include <cstddef>
12
13class IGraphics;
14class ITextRender;
15
16class CGraph
17{
18private:
19 class CEntry
20 {
21 public:
22 int64_t m_Time;
23 float m_Value;
24 ColorRGBA m_Color;
25 bool m_ApplyColor;
26 };
27 CEntry *m_pFirstScaled = nullptr;
28 int64_t m_RenderedTotalTime = 0;
29 float m_Average;
30 float m_MinAxis, m_MaxAxis;
31 float m_MinValue, m_MaxValue;
32 float m_MinRange, m_MaxRange;
33 CDynamicRingBuffer<CEntry> m_Entries;
34 int m_Precision;
35 bool m_SummaryStats;
36
37 void RenderDataLines(IGraphics *pGraphics, float x, float y, float w, float h);
38
39public:
40 CGraph(int MaxEntries, int Precision, bool SummaryStats);
41
42 void Init(float Min, float Max);
43 void SetMin(float Min);
44 void SetMax(float Max);
45
46 void Scale(int64_t WantedTotalTime);
47 void Add(float Value, ColorRGBA Color = ColorRGBA(1.0f, 1.0f, 1.0f, 0.75f));
48 void InsertAt(int64_t Time, float Value, ColorRGBA Color = ColorRGBA(1.0f, 1.0f, 1.0f, 0.75f));
49 void Render(IGraphics *pGraphics, ITextRender *pTextRender, float x, float y, float w, float h, const char *pDescription);
50};
51
52#endif
53