Nebula
Loading...
Searching...
No Matches
imguigraph.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
11//------------------------------------------------------------------------------
12
13#include "util/ringbuffer.h"
14#include "util/string.h"
15
16
17namespace Dynui
18{
19
20class Graph
21{
22public:
24 Graph(Util::String const& name, SizeT historySize);
25
27 void AddValue(float val);
29 void Draw();
30
31private:
33 static float ValueGetter(void* object, int idx);
34
35 float _min, _max;
37 float average;
42 bool scroll;
43};
44
45
46//------------------------------------------------------------------------------
49inline void
51{
52 if(val < FLT_MAX)
53 this->buffer.Add(val);
54}
55
56//------------------------------------------------------------------------------
59inline float
60Graph::ValueGetter(void* object, int idx)
61{
62 Graph * graph = (Graph*)object;
63 float val;
64 if (graph->scroll)
65 {
66 val = graph->buffer[idx];
67 }
68 else
69 {
70 val = graph->buffer.GetBuffer()[idx];
71 }
72 graph->frame_max = graph->frame_max < val ? val : graph->frame_max;
73 graph->frame_min = graph->frame_min > val ? val : graph->frame_min;
74 graph->averageSum += val;
75 return val;
76}
77
78}// namespace Dynui
79
80
Time Graph with predefined amount of entries.
Definition imguigraph.h:21
void AddValue(float val)
Definition imguigraph.h:50
float frame_max
Definition imguigraph.h:36
float _max
Definition imguigraph.h:35
Util::RingBuffer< float > buffer
Definition imguigraph.h:41
float average
Definition imguigraph.h:37
Util::String header
Definition imguigraph.h:40
float frame_min
Definition imguigraph.h:36
void Draw()
Definition imguigraph.cc:30
static float ValueGetter(void *object, int idx)
Definition imguigraph.h:60
bool scroll
Definition imguigraph.h:42
Graph(Util::String const &name, SizeT historySize)
Definition imguigraph.cc:18
Util::String name
Definition imguigraph.h:39
float averageSum
Definition imguigraph.h:38
float _min
Definition imguigraph.h:35
A ring buffer stores up to a maximum number of elements in a circular fashion.
Definition ringbuffer.h:21
TYPE * GetBuffer()
get real linear underlying buffer
Definition ringbuffer.h:368
void Add(const TYPE &elm)
add an element to the ring buffer
Definition ringbuffer.h:316
#define FLT_MAX
Definition csmutil.h:17
Imgui Profiler UI.
Definition imguiconsole.cc:277
Nebula's universal string class.
Definition string.h:50
int SizeT
Definition types.h:49