-
-
Notifications
You must be signed in to change notification settings - Fork 73
Expand file tree
/
Copy pathimplot3d_demo.cpp
More file actions
2118 lines (1834 loc) · 80.5 KB
/
implot3d_demo.cpp
File metadata and controls
2118 lines (1834 loc) · 80.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2024-2026 Breno Cunha Queiroz
// ImPlot3D v0.4 WIP
// Acknowledgments:
// ImPlot3D is heavily inspired by ImPlot
// (https://github.com/epezent/implot) by Evan Pezent,
// and follows a similar code style and structure to
// maintain consistency with ImPlot's API.
// Table of Contents:
// [SECTION] User Namespace
// [SECTION] Helpers
// [SECTION] Plots
// [SECTION] Axes
// [SECTION] Tools
// [SECTION] Custom
// [SECTION] Config
// [SECTION] Demo Window
// [SECTION] Style Editor
// [SECTION] User Namespace Implementation
// We define this to avoid accidentally using the deprecated API
#ifndef IMPLOT_DISABLE_OBSOLETE_FUNCTIONS
#define IMPLOT_DISABLE_OBSOLETE_FUNCTIONS
#endif
#include "implot3d.h"
#include "implot3d_internal.h"
//-----------------------------------------------------------------------------
// [SECTION] User Namespace
//-----------------------------------------------------------------------------
// Encapsulates examples for customizing ImPlot3D
namespace MyImPlot3D {
// Example for Custom Styles section
void StyleSeaborn();
} // namespace MyImPlot3D
namespace ImPlot3D {
//-----------------------------------------------------------------------------
// [SECTION] Helpers
//-----------------------------------------------------------------------------
#define CHECKBOX_FLAG(flags, flag) ImGui::CheckboxFlags(#flag, (unsigned int*)&flags, flag)
static void HelpMarker(const char* desc) {
ImGui::TextDisabled("(?)");
if (ImGui::BeginItemTooltip()) {
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
ImGui::TextUnformatted(desc);
ImGui::PopTextWrapPos();
ImGui::EndTooltip();
}
}
// Utility structure for realtime plot
struct ScrollingBuffer {
int MaxSize;
int Offset;
ImVector<float> Data;
ScrollingBuffer(int max_size = 2000) {
MaxSize = max_size;
Offset = 0;
Data.reserve(MaxSize);
}
void AddPoint(float x) {
if (Data.size() < MaxSize)
Data.push_back(x);
else {
Data[Offset] = x;
Offset = (Offset + 1) % MaxSize;
}
}
void Erase() {
if (Data.size() > 0) {
Data.shrink(0);
Offset = 0;
}
}
};
// Custom axis formatter that adds metric prefixes (G, M, k, m, u, n)
int MetricFormatter(double value, char* buff, int size, void* data) {
const char* unit = (const char*)data;
static double v[] = {1000000000, 1000000, 1000, 1, 0.001, 0.000001, 0.000000001};
static const char* p[] = {"G", "M", "k", "", "m", "u", "n"};
if (value == 0) {
return snprintf(buff, size, "0 %s", unit);
}
for (int i = 0; i < 7; ++i) {
if (fabs(value) >= v[i]) {
return snprintf(buff, size, "%g %s%s", value / v[i], p[i], unit);
}
}
return snprintf(buff, size, "%g %s%s", value / v[6], p[6], unit);
}
//-----------------------------------------------------------------------------
// [SECTION] Plots
//-----------------------------------------------------------------------------
void DemoLinePlots() {
static float xs1[1001], ys1[1001], zs1[1001];
for (int i = 0; i < 1001; i++) {
xs1[i] = i * 0.001f;
ys1[i] = 0.5f + 0.5f * cosf(50 * (xs1[i] + (float)ImGui::GetTime() / 10));
zs1[i] = 0.5f + 0.5f * sinf(50 * (xs1[i] + (float)ImGui::GetTime() / 10));
}
static double xs2[20], ys2[20], zs2[20];
for (int i = 0; i < 20; i++) {
xs2[i] = i * 1 / 19.0f;
ys2[i] = xs2[i] * xs2[i];
zs2[i] = xs2[i] * ys2[i];
}
if (ImPlot3D::BeginPlot("Line Plots")) {
ImPlot3D::SetupAxes("x", "y", "z");
ImPlot3D::PlotLine("f(x)", xs1, ys1, zs1, 1001);
ImPlot3D::PlotLine("g(x)", xs2, ys2, zs2, 20, {ImPlot3DProp_Marker, ImPlot3DMarker_Circle, ImPlot3DProp_Flags, ImPlot3DLineFlags_Segments});
ImPlot3D::EndPlot();
}
}
void DemoScatterPlots() {
srand(0);
static float xs1[100], ys1[100], zs1[100];
for (int i = 0; i < 100; i++) {
xs1[i] = i * 0.01f;
ys1[i] = xs1[i] + 0.1f * ((float)rand() / (float)RAND_MAX);
zs1[i] = xs1[i] + 0.1f * ((float)rand() / (float)RAND_MAX);
}
static float xs2[50], ys2[50], zs2[50];
for (int i = 0; i < 50; i++) {
xs2[i] = 0.25f + 0.2f * ((float)rand() / (float)RAND_MAX);
ys2[i] = 0.50f + 0.2f * ((float)rand() / (float)RAND_MAX);
zs2[i] = 0.75f + 0.2f * ((float)rand() / (float)RAND_MAX);
}
if (ImPlot3D::BeginPlot("Scatter Plots")) {
ImPlot3D::PlotScatter("Data 1", xs1, ys1, zs1, 100);
ImPlot3DSpec spec;
spec.Marker = ImPlot3DMarker_Square;
spec.MarkerSize = 6;
spec.MarkerLineColor = ImPlot3D::GetColormapColor(1);
spec.MarkerFillColor = ImPlot3D::GetColormapColor(1);
spec.FillAlpha = 0.25f;
ImPlot3D::PlotScatter("Data 2", xs2, ys2, zs2, 50, spec);
ImPlot3D::EndPlot();
}
}
void DemoTrianglePlots() {
// Pyramid coordinates
// Apex
float ax = 0.0f, ay = 0.0f, az = 1.0f;
// Square base corners
float cx[4] = {-0.5f, 0.5f, 0.5f, -0.5f};
float cy[4] = {-0.5f, -0.5f, 0.5f, 0.5f};
float cz[4] = {0.0f, 0.0f, 0.0f, 0.0f};
// We have 6 triangles (18 vertices) total:
// Sides:
// T1: apex, corner0, corner1
// T2: apex, corner1, corner2
// T3: apex, corner2, corner3
// T4: apex, corner3, corner0
// Base (two triangles form a square):
// T5: corner0, corner1, corner2
// T6: corner0, corner2, corner3
static float xs[18], ys[18], zs[18];
int i = 0;
// Helper lambda to append a vertex
auto AddVertex = [&](float X, float Y, float Z) {
xs[i] = X;
ys[i] = Y;
zs[i] = Z;
i++;
};
// Triangle 1
AddVertex(ax, ay, az);
AddVertex(cx[0], cy[0], cz[0]);
AddVertex(cx[1], cy[1], cz[1]);
// Triangle 2
AddVertex(ax, ay, az);
AddVertex(cx[1], cy[1], cz[1]);
AddVertex(cx[2], cy[2], cz[2]);
// Triangle 3
AddVertex(ax, ay, az);
AddVertex(cx[2], cy[2], cz[2]);
AddVertex(cx[3], cy[3], cz[3]);
// Triangle 4
AddVertex(ax, ay, az);
AddVertex(cx[3], cy[3], cz[3]);
AddVertex(cx[0], cy[0], cz[0]);
// Triangle 5 (base)
AddVertex(cx[0], cy[0], cz[0]);
AddVertex(cx[1], cy[1], cz[1]);
AddVertex(cx[2], cy[2], cz[2]);
// Triangle 6 (base)
AddVertex(cx[0], cy[0], cz[0]);
AddVertex(cx[2], cy[2], cz[2]);
AddVertex(cx[3], cy[3], cz[3]);
// Now we have 18 vertices in xs, ys, zs forming the pyramid
// Triangle flags
static ImPlot3DTriangleFlags flags = ImPlot3DTriangleFlags_None;
CHECKBOX_FLAG(flags, ImPlot3DTriangleFlags_NoLines);
CHECKBOX_FLAG(flags, ImPlot3DTriangleFlags_NoFill);
CHECKBOX_FLAG(flags, ImPlot3DTriangleFlags_NoMarkers);
if (ImPlot3D::BeginPlot("Triangle Plots")) {
ImPlot3D::SetupAxesLimits(-1, 1, -1, 1, -0.5, 1.5);
// Setup pyramid colors
ImPlot3DSpec spec;
spec.FillColor = ImPlot3D::GetColormapColor(0);
spec.LineColor = ImPlot3D::GetColormapColor(1);
spec.Marker = ImPlot3DMarker_Square;
spec.MarkerSize = 3;
spec.Flags = flags;
// Plot pyramid
ImPlot3D::PlotTriangle("Pyramid", xs, ys, zs, 6 * 3, spec); // 6 triangles, 3 vertices each = 18
ImPlot3D::EndPlot();
}
}
void DemoQuadPlots() {
static float xs[6 * 4], ys[6 * 4], zs[6 * 4];
// clang-format off
// Initialize the cube vertices for +x and -x faces
// +x face
xs[0] = 1; ys[0] = -1; zs[0] = -1;
xs[1] = 1; ys[1] = 1; zs[1] = -1;
xs[2] = 1; ys[2] = 1; zs[2] = 1;
xs[3] = 1; ys[3] = -1; zs[3] = 1;
// -x face
xs[4] = -1; ys[4] = -1; zs[4] = -1;
xs[5] = -1; ys[5] = 1; zs[5] = -1;
xs[6] = -1; ys[6] = 1; zs[6] = 1;
xs[7] = -1; ys[7] = -1; zs[7] = 1;
// Initialize the cube vertices for +y and -y faces
// +y face
xs[8] = -1; ys[8] = 1; zs[8] = -1;
xs[9] = 1; ys[9] = 1; zs[9] = -1;
xs[10] = 1; ys[10] = 1; zs[10] = 1;
xs[11] = -1; ys[11] = 1; zs[11] = 1;
// -y face
xs[12] = -1; ys[12] = -1; zs[12] = -1;
xs[13] = 1; ys[13] = -1; zs[13] = -1;
xs[14] = 1; ys[14] = -1; zs[14] = 1;
xs[15] = -1; ys[15] = -1; zs[15] = 1;
// Initialize the cube vertices for +z and -z faces
// +z face
xs[16] = -1; ys[16] = -1; zs[16] = 1;
xs[17] = 1; ys[17] = -1; zs[17] = 1;
xs[18] = 1; ys[18] = 1; zs[18] = 1;
xs[19] = -1; ys[19] = 1; zs[19] = 1;
// -z face
xs[20] = -1; ys[20] = -1; zs[20] = -1;
xs[21] = 1; ys[21] = -1; zs[21] = -1;
xs[22] = 1; ys[22] = 1; zs[22] = -1;
xs[23] = -1; ys[23] = 1; zs[23] = -1;
// clang-format on
// Quad flags
static ImPlot3DQuadFlags flags = ImPlot3DQuadFlags_None;
CHECKBOX_FLAG(flags, ImPlot3DQuadFlags_NoLines);
CHECKBOX_FLAG(flags, ImPlot3DQuadFlags_NoFill);
CHECKBOX_FLAG(flags, ImPlot3DQuadFlags_NoMarkers);
if (ImPlot3D::BeginPlot("Quad Plots")) {
ImPlot3D::SetupAxesLimits(-1.5, 1.5, -1.5, 1.5, -1.5, 1.5);
ImPlot3DSpec spec;
spec.Marker = ImPlot3DMarker_Square;
spec.MarkerSize = 3;
spec.Flags = flags;
// Render +x and -x faces
static ImVec4 colorX(0.8f, 0.2f, 0.2f, 0.8f); // Red
spec.FillColor = colorX;
spec.LineColor = colorX;
ImPlot3D::PlotQuad("X", &xs[0], &ys[0], &zs[0], 8, spec);
// Render +y and -y faces
static ImVec4 colorY(0.2f, 0.8f, 0.2f, 0.8f); // Green
spec.FillColor = colorY;
spec.LineColor = colorY;
ImPlot3D::PlotQuad("Y", &xs[8], &ys[8], &zs[8], 8, spec);
// Render +z and -z faces
static ImVec4 colorZ(0.2f, 0.2f, 0.8f, 0.8f); // Blue
spec.FillColor = colorZ;
spec.LineColor = colorZ;
ImPlot3D::PlotQuad("Z", &xs[16], &ys[16], &zs[16], 8, spec);
ImPlot3D::EndPlot();
}
}
void DemoSurfacePlots() {
constexpr int N = 20;
static float xs[N * N], ys[N * N], zs[N * N];
static float t = 0.0f;
t += ImGui::GetIO().DeltaTime;
// Define the range for X and Y
constexpr float min_val = -1.0f;
constexpr float max_val = 1.0f;
constexpr float step = (max_val - min_val) / (N - 1);
// Populate the xs, ys, and zs arrays
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
int idx = i * N + j;
xs[idx] = min_val + j * step; // X values are constant along rows
ys[idx] = min_val + i * step; // Y values are constant along columns
zs[idx] = ImSin(2 * t + ImSqrt((xs[idx] * xs[idx] + ys[idx] * ys[idx]))); // z = sin(2t + sqrt(x^2 + y^2))
}
}
// Choose fill color
ImGui::Text("Fill color");
static int selected_fill = 1; // Colormap by default
static ImVec4 solid_color = ImVec4(0.8f, 0.8f, 0.2f, 0.6f);
const char* colormaps[] = {"Viridis", "Plasma", "Hot", "Cool", "Pink", "Jet", "Twilight", "RdBu", "BrBG", "PiYG", "Spectral", "Greys"};
static int sel_colormap = 5; // Jet by default
{
ImGui::Indent();
// Choose solid color
ImGui::RadioButton("Solid", &selected_fill, 0);
if (selected_fill == 0) {
ImGui::SameLine();
ImGui::ColorEdit4("##SurfaceSolidColor", (float*)&solid_color);
}
// Choose colormap
ImGui::RadioButton("Colormap", &selected_fill, 1);
if (selected_fill == 1) {
ImGui::SameLine();
ImGui::Combo("##SurfaceColormap", &sel_colormap, colormaps, IM_ARRAYSIZE(colormaps));
}
ImGui::Unindent();
}
// Choose range
static bool custom_range = false;
static float range_min = -1.0f;
static float range_max = 1.0f;
ImGui::Checkbox("Custom range", &custom_range);
{
ImGui::Indent();
if (!custom_range)
ImGui::BeginDisabled();
ImGui::SliderFloat("Range min", &range_min, -1.0f, range_max - 0.01f);
ImGui::SliderFloat("Range max", &range_max, range_min + 0.01f, 1.0f);
if (!custom_range)
ImGui::EndDisabled();
ImGui::Unindent();
}
// Select flags
static ImPlot3DSurfaceFlags flags = ImPlot3DSurfaceFlags_NoMarkers;
CHECKBOX_FLAG(flags, ImPlot3DSurfaceFlags_NoLines);
CHECKBOX_FLAG(flags, ImPlot3DSurfaceFlags_NoFill);
CHECKBOX_FLAG(flags, ImPlot3DSurfaceFlags_NoMarkers);
// Begin the plot
if (selected_fill == 1)
ImPlot3D::PushColormap(colormaps[sel_colormap]);
if (ImPlot3D::BeginPlot("Surface Plots", ImVec2(-1, 0), ImPlot3DFlags_NoClip)) {
ImPlot3D::SetupAxesLimits(-1, 1, -1, 1, -1.5, 1.5);
ImPlot3DSpec spec;
spec.FillAlpha = 0.8f;
spec.Flags = flags;
spec.Marker = ImPlot3DMarker_Square;
spec.LineColor = ImPlot3D::GetColormapColor(1);
if (selected_fill == 0)
spec.FillColor = solid_color;
// Plot the surface
if (custom_range)
ImPlot3D::PlotSurface("Wave Surface", xs, ys, zs, N, N, (double)range_min, (double)range_max, spec);
else
ImPlot3D::PlotSurface("Wave Surface", xs, ys, zs, N, N, 0.0, 0.0, spec);
// End the plot
ImPlot3D::EndPlot();
}
if (selected_fill == 1)
ImPlot3D::PopColormap();
}
void DemoMeshPlots() {
static int mesh_id = 0;
ImGui::Combo("Mesh", &mesh_id, "Duck\0Sphere\0Cube\0\0");
// Choose line color
static ImVec4 line_color = ImVec4(0.5f, 0.5f, 0.2f, 0.6f);
ImGui::ColorEdit4("Line Color##Mesh", (float*)&line_color);
// Choose fill color
static ImVec4 fill_color = ImVec4(0.8f, 0.8f, 0.2f, 0.6f);
ImGui::ColorEdit4("Fill Color##Mesh", (float*)&fill_color);
// Choose marker color
static ImVec4 marker_color = ImVec4(0.5f, 0.5f, 0.2f, 0.6f);
ImGui::ColorEdit4("Marker Color##Mesh", (float*)&marker_color);
// Mesh flags
static ImPlot3DMeshFlags flags = ImPlot3DMeshFlags_NoMarkers;
CHECKBOX_FLAG(flags, ImPlot3DMeshFlags_NoLines);
CHECKBOX_FLAG(flags, ImPlot3DMeshFlags_NoFill);
CHECKBOX_FLAG(flags, ImPlot3DMeshFlags_NoMarkers);
if (ImPlot3D::BeginPlot("Mesh Plots")) {
ImPlot3D::SetupAxesLimits(-1, 1, -1, 1, -1, 1);
ImPlot3DSpec spec;
spec.Flags = flags;
// Set fill style
spec.FillColor = fill_color;
// Set line style
spec.LineColor = line_color;
// Set marker style
spec.Marker = ImPlot3DMarker_Square;
spec.MarkerSize = 3.0f;
spec.MarkerLineColor = marker_color;
spec.MarkerFillColor = marker_color;
// Plot mesh
if (mesh_id == 0)
ImPlot3D::PlotMesh("Duck", duck_vtx, duck_idx, DUCK_VTX_COUNT, DUCK_IDX_COUNT, spec);
else if (mesh_id == 1)
ImPlot3D::PlotMesh("Sphere", sphere_vtx, sphere_idx, SPHERE_VTX_COUNT, SPHERE_IDX_COUNT, spec);
else if (mesh_id == 2)
ImPlot3D::PlotMesh("Cube", cube_vtx, cube_idx, CUBE_VTX_COUNT, CUBE_IDX_COUNT, spec);
ImPlot3D::EndPlot();
}
}
void DemoImagePlots() {
ImGui::BulletText("Below we are displaying the font texture, which is the only texture we have\naccess to in this demo.");
ImGui::BulletText("Use the 'ImTextureID' type as storage to pass pointers or identifiers to your\nown texture data.");
ImGui::BulletText("See ImGui Wiki page 'Image Loading and Displaying Examples'.");
static ImVec4 tint1(1, 1, 1, 1);
static ImVec4 tint2(1, 1, 1, 1);
static ImPlot3DPoint center1(0, 0, 1);
static ImPlot3DPoint axis_u1(1, 0, 0);
static ImPlot3DPoint axis_v1(0, 1, 0);
static ImVec2 uv0_1(0, 0), uv1_1(1, 1);
static ImPlot3DPoint p0(-1, -1, 0);
static ImPlot3DPoint p1(1, -1, 0);
static ImPlot3DPoint p2(1, 1, 0);
static ImPlot3DPoint p3(-1, 1, 0);
static ImVec2 uv0(0, 0), uv1(1, 0), uv2(1, 1), uv3(0, 1);
// Spacing
ImGui::Dummy(ImVec2(0, 10));
// Image 1 Controls
if (ImGui::TreeNodeEx("Image 1 Controls: Center + Axes")) {
float center1_f[3] = {(float)center1.x, (float)center1.y, (float)center1.z};
if (ImGui::SliderFloat3("Center", center1_f, -2, 2, "%.1f")) {
center1 = ImPlot3DPoint(center1_f[0], center1_f[1], center1_f[2]);
}
float axis_u1_f[3] = {(float)axis_u1.x, (float)axis_u1.y, (float)axis_u1.z};
if (ImGui::SliderFloat3("Axis U", axis_u1_f, -2, 2, "%.1f")) {
axis_u1 = ImPlot3DPoint(axis_u1_f[0], axis_u1_f[1], axis_u1_f[2]);
}
float axis_v1_f[3] = {(float)axis_v1.x, (float)axis_v1.y, (float)axis_v1.z};
if (ImGui::SliderFloat3("Axis V", axis_v1_f, -2, 2, "%.1f")) {
axis_v1 = ImPlot3DPoint(axis_v1_f[0], axis_v1_f[1], axis_v1_f[2]);
}
ImGui::SliderFloat2("UV0", &uv0_1.x, 0, 1, "%.2f");
ImGui::SliderFloat2("UV1", &uv1_1.x, 0, 1, "%.2f");
ImGui::ColorEdit4("Tint", &tint1.x);
ImGui::TreePop();
}
// Image 2 Controls
if (ImGui::TreeNodeEx("Image 2 Controls: Full Quad")) {
float p0_f[3] = {(float)p0.x, (float)p0.y, (float)p0.z};
if (ImGui::SliderFloat3("P0", p0_f, -2, 2, "%.1f")) {
p0 = ImPlot3DPoint(p0_f[0], p0_f[1], p0_f[2]);
}
float p1_f[3] = {(float)p1.x, (float)p1.y, (float)p1.z};
if (ImGui::SliderFloat3("P1", p1_f, -2, 2, "%.1f")) {
p1 = ImPlot3DPoint(p1_f[0], p1_f[1], p1_f[2]);
}
float p2_f[3] = {(float)p2.x, (float)p2.y, (float)p2.z};
if (ImGui::SliderFloat3("P2", p2_f, -2, 2, "%.1f")) {
p2 = ImPlot3DPoint(p2_f[0], p2_f[1], p2_f[2]);
}
float p3_f[3] = {(float)p3.x, (float)p3.y, (float)p3.z};
if (ImGui::SliderFloat3("P3", p3_f, -2, 2, "%.1f")) {
p3 = ImPlot3DPoint(p3_f[0], p3_f[1], p3_f[2]);
}
ImGui::SliderFloat2("UV0", &uv0.x, 0, 1, "%.2f");
ImGui::SliderFloat2("UV1", &uv1.x, 0, 1, "%.2f");
ImGui::SliderFloat2("UV2", &uv2.x, 0, 1, "%.2f");
ImGui::SliderFloat2("UV3", &uv3.x, 0, 1, "%.2f");
ImGui::ColorEdit4("Tint##2", &tint2.x);
ImGui::TreePop();
}
// Plot
if (ImPlot3D::BeginPlot("Image Plot", ImVec2(-1, 0), ImPlot3DFlags_NoClip)) {
#ifdef IMGUI_HAS_TEXTURES
// We use the font atlas ImTextureRef for this demo, but in your real code when you submit
// an image that you have loaded yourself, you would normally have a ImTextureID which works
// just as well (as ImTextureRef can be constructed from ImTextureID).
ImTextureRef tex = ImGui::GetIO().Fonts->TexRef;
#else
ImTextureID tex = ImGui::GetIO().Fonts->TexID;
#endif
ImPlot3D::PlotImage("Image 1", tex, center1, axis_u1, axis_v1, uv0_1, uv1_1, tint1);
ImPlot3D::PlotImage("Image 2", tex, p0, p1, p2, p3, uv0, uv1, uv2, uv3, tint2);
ImPlot3D::EndPlot();
}
}
void DemoRealtimePlots() {
ImGui::BulletText("Move your mouse to change the data!");
static ScrollingBuffer sdata1, sdata2, sdata3;
static ImPlot3DAxisFlags flags = ImPlot3DAxisFlags_NoTickLabels;
static float t = 0.0f;
static float last_t = -1.0f;
if (ImPlot3D::BeginPlot("Scrolling Plot")) {
// Pool mouse data every 10 ms
t += ImGui::GetIO().DeltaTime;
if (t - last_t > 0.01f) {
last_t = t;
ImVec2 mouse = ImGui::GetMousePos();
if (ImAbs(mouse.x) < 1e4f && ImAbs(mouse.y) < 1e4f) {
ImVec2 plot_center = ImPlot3D::GetFramePos();
plot_center.x += ImPlot3D::GetFrameSize().x / 2;
plot_center.y += ImPlot3D::GetFrameSize().y / 2;
sdata1.AddPoint(t);
sdata2.AddPoint(mouse.x - plot_center.x);
sdata3.AddPoint(mouse.y - plot_center.y);
}
}
ImPlot3D::SetupAxes("Time", "Mouse X", "Mouse Y", flags, flags, flags);
ImPlot3D::SetupAxisLimits(ImAxis3D_X, t - 10.0, t, ImPlot3DCond_Always);
ImPlot3D::SetupAxisLimits(ImAxis3D_Y, -400, 400, ImPlot3DCond_Once);
ImPlot3D::SetupAxisLimits(ImAxis3D_Z, -400, 400, ImPlot3DCond_Once);
ImPlot3D::PlotLine("Mouse", &sdata1.Data[0], &sdata2.Data[0], &sdata3.Data[0], sdata1.Data.size(),
{ImPlot3DProp_Offset, sdata1.Offset, ImPlot3DProp_Stride, sizeof(float)});
ImPlot3D::EndPlot();
}
}
void DemoPlotFlags() {
static ImPlot3DFlags flags = ImPlot3DFlags_None;
CHECKBOX_FLAG(flags, ImPlot3DFlags_NoTitle);
ImGui::SameLine();
ImGui::TextDisabled("(?)");
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Hide plot title");
}
CHECKBOX_FLAG(flags, ImPlot3DFlags_NoLegend);
ImGui::SameLine();
ImGui::TextDisabled("(?)");
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Hide plot legend");
}
CHECKBOX_FLAG(flags, ImPlot3DFlags_NoMouseText);
ImGui::SameLine();
ImGui::TextDisabled("(?)");
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Hide mouse position in plot coordinates");
}
CHECKBOX_FLAG(flags, ImPlot3DFlags_NoClip);
ImGui::SameLine();
ImGui::TextDisabled("(?)");
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Disable 3D box clipping");
}
CHECKBOX_FLAG(flags, ImPlot3DFlags_NoMenus);
ImGui::SameLine();
ImGui::TextDisabled("(?)");
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("The user will not be able to open context menus");
}
CHECKBOX_FLAG(flags, ImPlot3DFlags_Equal);
ImGui::SameLine();
ImGui::TextDisabled("(?)");
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("X, Y, and Z axes will be constrained to have the same units/pixel");
}
CHECKBOX_FLAG(flags, ImPlot3DFlags_NoRotate);
ImGui::SameLine();
ImGui::TextDisabled("(?)");
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Lock rotation interaction");
}
CHECKBOX_FLAG(flags, ImPlot3DFlags_NoPan);
ImGui::SameLine();
ImGui::TextDisabled("(?)");
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Lock panning/translation interaction");
}
CHECKBOX_FLAG(flags, ImPlot3DFlags_NoZoom);
ImGui::SameLine();
ImGui::TextDisabled("(?)");
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Lock zooming interaction");
}
CHECKBOX_FLAG(flags, ImPlot3DFlags_NoInputs);
ImGui::SameLine();
ImGui::TextDisabled("(?)");
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Disable all user inputs");
}
if (ImPlot3D::BeginPlot("Plot Flags Demo", ImVec2(-1, 0), flags)) {
ImPlot3D::SetupAxes("X-axis", "Y-axis", "Z-axis");
ImPlot3D::SetupAxesLimits(-10, 10, -10, 10, -5, 5);
// Generate some sample data for demonstration
static float x[100], y[100], z[100];
static bool first = true;
if (first) {
for (int i = 0; i < 100; i++) {
float t = i * 0.1f;
x[i] = 3.0f * cosf(t);
y[i] = 3.0f * sinf(t);
z[i] = t - 5.0f;
}
first = false;
}
ImPlot3D::PlotLine("Helix", x, y, z, 100);
// Add some scatter points to show equal scaling effect
float scatter_x[8] = {-10, 10, -10, 10, -10, 10, -10, 10};
float scatter_y[8] = {-10, -10, 10, 10, -10, -10, 10, 10};
float scatter_z[8] = {-5, -5, -5, -5, 5, 5, 5, 5};
ImPlot3D::PlotScatter("Cube corners", scatter_x, scatter_y, scatter_z, 8);
ImPlot3D::EndPlot();
}
}
void DemoOffsetAndStride() {
static const int k_spirals = 11;
static const int k_points_per = 50;
static const int k_size = 3 * k_points_per * k_spirals;
static double interleaved_data[k_size];
for (int p = 0; p < k_points_per; ++p) {
for (int s = 0; s < k_spirals; ++s) {
double r = (double)s / (k_spirals - 1) * 0.2 + 0.2;
double theta = (double)p / k_points_per * 6.28;
interleaved_data[p * 3 * k_spirals + 3 * s + 0] = 0.5 + r * cos(theta);
interleaved_data[p * 3 * k_spirals + 3 * s + 1] = 0.5 + r * sin(theta);
interleaved_data[p * 3 * k_spirals + 3 * s + 2] = 0.5 + 0.5 * sin(2.0 * theta);
}
}
static int offset = 0;
ImGui::BulletText("Offsetting is useful for realtime plots (see above) and circular buffers.");
ImGui::BulletText("Striding is useful for interleaved data (e.g. audio) or plotting structs.");
ImGui::BulletText("Here, all spiral data is stored in a single interleaved buffer:");
ImGui::BulletText("[s0.x0 s0.y0 s0.z0 ... sn.x0 sn.y0 sn.z0 s0.x1 s0.y1 s0.z1 ... sn.x1 sn.y1 sn.z1 ... sn.xm sn.ym sn.zm]");
ImGui::BulletText("The offset value indicates which spiral point index is considered the first.");
ImGui::BulletText("Offsets can be negative and/or larger than the actual data count.");
ImGui::SliderInt("Offset", &offset, -2 * k_points_per, 2 * k_points_per);
if (ImPlot3D::BeginPlot("##strideoffset", ImVec2(-1, 0))) {
ImPlot3D::PushColormap(ImPlot3DColormap_Jet);
char buff[32];
for (int s = 0; s < k_spirals; ++s) {
snprintf(buff, sizeof(buff), "Spiral %d", s);
ImPlot3DSpec spec;
spec.Offset = offset;
spec.Stride = 3 * k_spirals * sizeof(double);
ImPlot3D::PlotLine(buff, &interleaved_data[s * 3 + 0], &interleaved_data[s * 3 + 1], &interleaved_data[s * 3 + 2], k_points_per, spec);
}
ImPlot3D::EndPlot();
ImPlot3D::PopColormap();
}
}
void DemoLegendOptions() {
static ImPlot3DLocation loc = ImPlot3DLocation_East;
ImGui::CheckboxFlags("North", (unsigned int*)&loc, ImPlot3DLocation_North);
ImGui::SameLine();
ImGui::CheckboxFlags("South", (unsigned int*)&loc, ImPlot3DLocation_South);
ImGui::SameLine();
ImGui::CheckboxFlags("West", (unsigned int*)&loc, ImPlot3DLocation_West);
ImGui::SameLine();
ImGui::CheckboxFlags("East", (unsigned int*)&loc, ImPlot3DLocation_East);
static ImPlot3DLegendFlags flags = 0;
CHECKBOX_FLAG(flags, ImPlot3DLegendFlags_Horizontal);
ImGui::SameLine();
ImGui::TextDisabled("(?)");
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Legend entries will be displayed horizontally");
}
CHECKBOX_FLAG(flags, ImPlot3DLegendFlags_NoButtons);
ImGui::SameLine();
ImGui::TextDisabled("(?)");
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Legend icons will not function as hide/show buttons");
}
CHECKBOX_FLAG(flags, ImPlot3DLegendFlags_NoHighlightItem);
ImGui::SameLine();
ImGui::TextDisabled("(?)");
if (ImGui::IsItemHovered()) {
ImGui::SetTooltip("Plot items will not be highlighted when their legend entry is hovered");
}
ImGui::SliderFloat2("LegendPadding", (float*)&ImPlot3D::GetStyle().LegendPadding, 0.0f, 20.0f, "%.0f");
ImGui::SliderFloat2("LegendInnerPadding", (float*)&ImPlot3D::GetStyle().LegendInnerPadding, 0.0f, 10.0f, "%.0f");
ImGui::SliderFloat2("LegendSpacing", (float*)&ImPlot3D::GetStyle().LegendSpacing, 0.0f, 5.0f, "%.0f");
if (ImPlot3D::BeginPlot("Legend Options Demo", ImVec2(-1, 0))) {
ImPlot3D::SetupAxes("X-Axis", "Y-Axis", "Z-Axis");
ImPlot3D::SetupAxesLimits(-1, 1, -1, 1, -1, 1);
ImPlot3D::SetupLegend(loc, flags);
// Generate some 3D line data
static float t = 0;
t += ImGui::GetIO().DeltaTime * 0.5f;
constexpr int count = 50;
static float xs1[count], ys1[count], zs1[count];
static float xs2[count], ys2[count], zs2[count];
static float xs3[count], ys3[count], zs3[count];
for (int i = 0; i < count; i++) {
float phase = i * 0.1f + t;
xs1[i] = 0.8f * cosf(phase);
ys1[i] = 0.8f * sinf(phase);
zs1[i] = 0.5f * sinf(phase * 2);
xs2[i] = 0.6f * cosf(phase + 1.0f);
ys2[i] = 0.6f * sinf(phase + 1.0f);
zs2[i] = -0.3f * cosf(phase * 1.5f);
xs3[i] = 0.4f * sinf(phase);
ys3[i] = 0.4f * cosf(phase);
zs3[i] = 0.7f * cosf(phase * 0.8f);
}
ImPlot3D::PlotLine("Helix A", xs1, ys1, zs1, count);
ImPlot3D::PlotLine("Helix B##IDText", xs2, ys2, zs2, count); // Text after ## used for ID only
ImPlot3D::PlotLine("##NotListed", xs3, ys3, zs3, count); // Plotted, but not added to legend
ImPlot3D::EndPlot();
}
}
void DemoMarkersAndText() {
static float mk_size = ImPlot3D::GetStyle().MarkerSize;
static float mk_weight = ImPlot3D::GetStyle().LineWeight;
ImGui::DragFloat("Marker Size", &mk_size, 0.1f, 2.0f, 10.0f, "%.2f px");
ImGui::DragFloat("Marker Weight", &mk_weight, 0.05f, 0.5f, 3.0f, "%.2f px");
if (ImPlot3D::BeginPlot("##MarkerStyles", ImVec2(-1, 0), ImPlot3DFlags_CanvasOnly)) {
ImPlot3D::SetupAxes(nullptr, nullptr, nullptr, ImPlot3DAxisFlags_NoDecorations, ImPlot3DAxisFlags_NoDecorations,
ImPlot3DAxisFlags_NoDecorations);
ImPlot3D::SetupAxesLimits(-0.5, 1.5, -0.5, 1.5, 0, ImPlot3DMarker_COUNT + 1);
float xs[2] = {0, 0};
float ys[2] = {0, 0};
float zs[2] = {ImPlot3DMarker_COUNT, ImPlot3DMarker_COUNT + 1};
// Filled markers
for (int m = 0; m < ImPlot3DMarker_COUNT; ++m) {
xs[1] = xs[0] + ImCos(zs[0] / float(ImPlot3DMarker_COUNT) * 2 * IM_PI) * 0.5f;
ys[1] = ys[0] + ImSin(zs[0] / float(ImPlot3DMarker_COUNT) * 2 * IM_PI) * 0.5f;
ImGui::PushID(m);
ImPlot3D::PlotLine("##Filled", xs, ys, zs, 2,
{ImPlot3DProp_Marker, m, ImPlot3DProp_MarkerSize, mk_size, ImPlot3DProp_LineWeight, mk_weight});
ImGui::PopID();
zs[0]--;
zs[1]--;
}
xs[0] = 1;
ys[0] = 1;
zs[0] = ImPlot3DMarker_COUNT;
zs[1] = zs[0] + 1;
// Open markers
for (int m = 0; m < ImPlot3DMarker_COUNT; ++m) {
xs[1] = xs[0] + ImCos(zs[0] / float(ImPlot3DMarker_COUNT) * 2 * IM_PI) * 0.5f;
ys[1] = ys[0] - ImSin(zs[0] / float(ImPlot3DMarker_COUNT) * 2 * IM_PI) * 0.5f;
ImGui::PushID(m);
ImPlot3D::PlotLine("##Open", xs, ys, zs, 2,
{ImPlot3DProp_Marker, m, ImPlot3DProp_MarkerSize, mk_size, ImPlot3DProp_LineWeight, mk_weight, ImPlot3DProp_FillColor,
ImVec4(0, 0, 0, 0)});
ImGui::PopID();
zs[0]--;
zs[1]--;
}
ImPlot3D::PlotText("Filled Markers", 0.0, 0.0, 6.0);
ImPlot3D::PlotText("Open Markers", 1.0, 1.0, 6.0);
ImPlot3D::PushStyleColor(ImPlot3DCol_InlayText, ImVec4(1, 0, 1, 1));
ImPlot3D::PlotText("Rotated Text", 0.5, 0.5, 6.0, IM_PI / 4, ImVec2(0, 0));
ImPlot3D::PopStyleColor();
ImPlot3D::EndPlot();
}
}
void DemoNaNValues() {
static bool include_nan = true;
static ImPlot3DLineFlags flags = 0;
float data1[5] = {0.0f, 0.25f, 0.5f, 0.75f, 1.0f};
float data2[5] = {0.0f, 0.25f, 0.5f, 0.75f, 1.0f};
float data3[5] = {0.0f, 0.25f, 0.5f, 0.75f, 1.0f};
if (include_nan)
data1[2] = NAN;
ImGui::Checkbox("Include NaN", &include_nan);
ImGui::SameLine();
ImGui::CheckboxFlags("Skip NaN", (unsigned int*)&flags, ImPlot3DLineFlags_SkipNaN);
if (ImPlot3D::BeginPlot("##NaNValues")) {
ImPlot3D::PlotLine("Line", data1, data2, data3, 5, {ImPlot3DProp_Flags, flags, ImPlot3DProp_Marker, ImPlot3DMarker_Square});
ImPlot3D::EndPlot();
}
}
//-----------------------------------------------------------------------------
// [SECTION] Axes
//-----------------------------------------------------------------------------
void DemoBoxScale() {
constexpr int N = 100;
float xs[N], ys[N], zs[N];
for (int i = 0; i < N; i++) {
float t = i / (float)(N - 1);
xs[i] = sinf(t * 2.0f * IM_PI);
ys[i] = cosf(t * 4.0f * IM_PI);
zs[i] = t * 2.0f - 1.0f;
}
static float scale[3] = {1.0f, 1.0f, 1.0f};
ImGui::SliderFloat3("Box Scale", scale, 0.1f, 2.0f, "%.2f");
if (ImPlot3D::BeginPlot("##BoxScale")) {
ImPlot3D::SetupBoxScale(scale[0], scale[1], scale[2]);
ImPlot3D::PlotLine("3D Curve", xs, ys, zs, N);
ImPlot3D::EndPlot();
}
}
void DemoBoxRotation() {
double origin[2] = {0.0, 0.0};
double axis[2] = {0.0, 1.0};
// Sliders for rotation angles
static float elevation = 45.0f;
static float azimuth = -135.0f;
static bool animate = false;
ImGui::Text("Rotation");
bool changed = false;
if (ImGui::SliderFloat("Elevation", &elevation, -90.0f, 90.0f, "%.1f degrees"))
changed = true;
if (ImGui::SliderFloat("Azimuth", &azimuth, -180.0f, 180.0f, "%.1f degrees"))
changed = true;
ImGui::Checkbox("Animate", &animate);
ImGui::Text("Initial Rotation");
ImGui::SameLine();
HelpMarker("The rotation will be reset to the initial rotation when you double right-click");
static float init_elevation = 45.0f;
static float init_azimuth = -135.0f;
ImGui::SliderFloat("Initial Elevation", &init_elevation, -90.0f, 90.0f, "%.1f degrees");
ImGui::SliderFloat("Initial Azimuth", &init_azimuth, -180.0f, 180.0f, "%.1f degrees");
if (ImPlot3D::BeginPlot("##BoxRotation")) {
ImPlot3D::SetupAxesLimits(-1, 1, -1, 1, -1, 1, ImPlot3DCond_Always);
// Set initial rotation
ImPlot3D::SetupBoxInitialRotation(init_elevation, init_azimuth);
// Set the rotation using the specified elevation and azimuth
if (changed)
ImPlot3D::SetupBoxRotation(elevation, azimuth, animate, ImPlot3DCond_Always);
// Plot axis lines
ImPlot3D::PlotLine("X-Axis", axis, origin, origin, 2, {ImPlot3DProp_LineColor, ImVec4(0.8f, 0.2f, 0.2f, 1)});
ImPlot3D::PlotLine("Y-Axis", origin, axis, origin, 2, {ImPlot3DProp_LineColor, ImVec4(0.2f, 0.8f, 0.2f, 1)});
ImPlot3D::PlotLine("Z-Axis", origin, origin, axis, 2, {ImPlot3DProp_LineColor, ImVec4(0.2f, 0.2f, 0.8f, 1)});
ImPlot3D::EndPlot();
}
}
void Demo_LogScale() {
static double xs[1001], ys1[1001], ys2[1001], ys3[1001], zs[1001];
for (int i = 0; i < 1001; i++) {
xs[i] = i * 0.1;
ys1[i] = sin(xs[i]) + 1;
ys2[i] = log(xs[i]);
ys3[i] = pow(10.0, xs[i]);
zs[i] = 0.0;
}
if (ImPlot3D::BeginPlot("Log Plot 3D", ImVec2(-1, 0))) {
ImPlot3D::SetupAxisScale(ImAxis3D_X, ImPlot3DScale_Log10);
ImPlot3D::SetupAxesLimits(0.1, 100, 0, 10, -1, 1);
ImPlot3D::PlotLine("f(x) = x", xs, xs, zs, 1001);
ImPlot3D::PlotLine("f(x) = sin(x)+1", xs, ys1, zs, 1001);
ImPlot3D::PlotLine("f(x) = log(x)", xs, ys2, zs, 1001);
ImPlot3D::PlotLine("f(x) = 10^x", xs, ys3, zs, 21);
ImPlot3D::EndPlot();
}
}
void Demo_SymmetricLogScale() {
static double xs[1001], ys1[1001], ys2[1001], zs[1001];
for (int i = 0; i < 1001; i++) {
xs[i] = i * 0.1f - 50;
ys1[i] = sin(xs[i]);
ys2[i] = i * 0.002 - 1;
zs[i] = 0.0;
}
if (ImPlot3D::BeginPlot("SymLog Plot", ImVec2(-1, 0))) {
ImPlot3D::SetupAxisScale(ImAxis3D_X, ImPlot3DScale_SymLog);
ImPlot3D::PlotLine("f(x) = a*x+b", xs, ys2, zs, 1001);
ImPlot3D::PlotLine("f(x) = sin(x)", xs, ys1, zs, 1001);
ImPlot3D::EndPlot();
}
}
void DemoTickLabels() {
static bool custom_fmt = true;
static bool custom_ticks = false;
static bool custom_labels = true;
ImGui::Checkbox("Show Custom Format", &custom_fmt);
ImGui::SameLine();
ImGui::Checkbox("Show Custom Ticks", &custom_ticks);
if (custom_ticks) {
ImGui::SameLine();
ImGui::Checkbox("Show Custom Labels", &custom_labels);
}
const double pi = 3.14;
const char* pi_str[] = {"PI"};