VR-Vantage
Loading...
Searching...
No Matches
imgui_plot.h
Go to the documentation of this file.
1#pragma once
2//#include <cstdint> //once we move up to c++11 we can use this header.
3#include <stdint.h>
4#include <imgui.h>
5
6namespace ImGui {
7// Use this structure to pass the plot data and settings into the Plot function
8struct PlotConfig {
9
11 : values()
12 , scale()
13 , tooltip()
14 , grid_x()
15 , grid_y()
16 , selection()
17 , v_lines()
18 , frame_size(0.f, 0.f)
19 , line_thickness(1.f)
20 , skip_small_lines(true)
21 , overlay_text(NULL)
22 {
23
24 }
25
26 struct Values {
28 : xs(NULL)
29 , ys(NULL)
30 , count(0)
31 , offset(0)
32 , color(0)
33 , ys_list(NULL)
34 , ys_count(NULL)
35 , colors(NULL)
36 {
37
38 }
39 // if necessary, you can provide x-axis values
40 const float *xs /*= NULL*/;
41 // array of y values. If null, use ys_list (below)
42 const float *ys /*= NULL*/;
43 // the number of values in each array
44 int count;
45 // at which offset to start plotting.
46 // Warning: count+offset must be <= length of array!
47 int offset /*= 0*/;
48 // Plot color. If 0, use ImGuiCol_PlotLines.
49 ImU32 color /*= 0*/;
50
51 // in case you need to draw multiple plots at once, use this instead of ys
52 const float **ys_list /*= NULL*/;
53 // the number of plots to draw
54 int ys_count /*= 0*/;
55 // colors for each plot
56 const ImU32* colors /*= NULL*/;
58 struct Scale {
60 : min(0)
61 , max(0)
62 , type(Linear)
63 {
64
65 }
66 // Minimum plot value
67 float min;
68 // Maximum plot value
69 float max;
70 enum Type {
73 };
74 // How to scale the x-axis
75 Type type /*= Linear*/;
77 struct Tooltip {
79 : show(false)
80 , format("%g: %8.4g")
81 {
82
83 }
84 bool show /*= false*/;
85 const char* format /*= "%g: %8.4g"*/;
87 struct Grid {
89 : show(false)
90 , size(100)
91 , subticks(10)
92 {
93
94 }
95 bool show /*= false*/;
96 float size /*= 100*/; // at which intervals to draw the grid
97 int subticks /*= 10*/; // how many subticks in each tick
99 struct Selection {
101 : show(false)
102 , start(NULL)
103 , length(NULL)
104 , sanitize_fn(NULL)
105 {
106
107 }
108 bool show /*= false*/;
109 uint32_t* start /*= NULL*/;
110 uint32_t* length /*= NULL*/;
111 // "Sanitize" function. Give it selection length, and it will return
112 // the "allowed" length. Useful for FFT, where selection must be
113 // of power of two
114 uint32_t(*sanitize_fn)(uint32_t) /*= NULL*/;
118 : show(false)
119 , indices(NULL)
120 , count(0)
121 {
122
123 }
124 bool show /*= false*/;
125 const size_t* indices /*= NULL*/; // at which indices to draw the lines
126 size_t count /*= 0*/;
128 ImVec2 frame_size /*= ImVec2(0.f, 0.f)*/;
129 float line_thickness /*= 1.f*/;
130 bool skip_small_lines /*= true*/;
131 const char* overlay_text /*= NULL*/;
132
133
134};
135// C++11
136//enum class PlotStatus {
141
142IMGUI_API PlotStatus Plot(const char* label, const PlotConfig& conf);
143}
unsigned int ImU32
Definition imgui.h:230
#define IMGUI_API
Definition imgui.h:78
Definition imgui.h:292
IMGUI_API PlotStatus Plot(const char *label, const PlotConfig &conf)
PlotStatus
Definition imgui_plot.h:137
@ nothing
Definition imgui_plot.h:138
@ selection_updated
Definition imgui_plot.h:139
int subticks
Definition imgui_plot.h:97
Grid()
Definition imgui_plot.h:88
bool show
Definition imgui_plot.h:95
float size
Definition imgui_plot.h:96
Type
Definition imgui_plot.h:70
@ Linear
Definition imgui_plot.h:71
@ Log10
Definition imgui_plot.h:72
Type type
Definition imgui_plot.h:75
float max
Definition imgui_plot.h:69
float min
Definition imgui_plot.h:67
Scale()
Definition imgui_plot.h:59
uint32_t * start
Definition imgui_plot.h:109
bool show
Definition imgui_plot.h:108
uint32_t(* sanitize_fn)(uint32_t)
Definition imgui_plot.h:114
Selection()
Definition imgui_plot.h:100
uint32_t * length
Definition imgui_plot.h:110
Tooltip()
Definition imgui_plot.h:78
const char * format
Definition imgui_plot.h:85
bool show
Definition imgui_plot.h:84
const float * xs
Definition imgui_plot.h:40
int ys_count
Definition imgui_plot.h:54
Values()
Definition imgui_plot.h:27
const float * ys
Definition imgui_plot.h:42
const ImU32 * colors
Definition imgui_plot.h:56
ImU32 color
Definition imgui_plot.h:49
int offset
Definition imgui_plot.h:47
int count
Definition imgui_plot.h:44
const float ** ys_list
Definition imgui_plot.h:52
VerticalLines()
Definition imgui_plot.h:117
const size_t * indices
Definition imgui_plot.h:125
bool show
Definition imgui_plot.h:124
size_t count
Definition imgui_plot.h:126
Definition imgui_plot.h:8
float line_thickness
Definition imgui_plot.h:129
struct ImGui::PlotConfig::Grid grid_x
const char * overlay_text
Definition imgui_plot.h:131
bool skip_small_lines
Definition imgui_plot.h:130
struct ImGui::PlotConfig::Values values
struct ImGui::PlotConfig::Tooltip tooltip
struct ImGui::PlotConfig::VerticalLines v_lines
PlotConfig()
Definition imgui_plot.h:10
struct ImGui::PlotConfig::Grid grid_y
ImVec2 frame_size
Definition imgui_plot.h:128
struct ImGui::PlotConfig::Selection selection
struct ImGui::PlotConfig::Scale scale
Definition imgui.h:263