Skip to content

Commit c07ccc0

Browse files
Added plotLines() and plotHistogram() (#53)
1 parent a449d53 commit c07ccc0

File tree

3 files changed

+91
-1
lines changed

3 files changed

+91
-1
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
zig-out
44

55
# Ignore some special OS files
6-
*.DS_Store
6+
*.DS_Store

src/gui.zig

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,6 +1828,66 @@ pub const textLink = zguiTextLink;
18281828

18291829
extern fn zguiTextLinkOpenURL(label: [*:0]const u8, url: ?[*:0]const u8) void;
18301830
pub const textLinkOpenURL = zguiTextLinkOpenURL;
1831+
//--------------------------------------------------------------------------------------------------
1832+
const PlotArgs = struct {
1833+
v: [*]f32,
1834+
v_count: c_int,
1835+
v_offset: c_int = 0,
1836+
overlay: ?[:0]const u8 = null,
1837+
scale_min: f32 = f32_max,
1838+
scale_max: f32 = f32_max,
1839+
graph_size: [2]f32 = .{ 0, 0 },
1840+
stride: c_int = @sizeOf(f32),
1841+
};
1842+
pub fn plotLines(label: [*:0]const u8, args: PlotArgs) void {
1843+
zguiPlotLines(
1844+
label,
1845+
args.v,
1846+
args.v_count,
1847+
args.v_offset,
1848+
if (args.overlay) |o| o else null,
1849+
args.scale_min,
1850+
args.scale_max,
1851+
&args.graph_size,
1852+
args.stride,
1853+
);
1854+
}
1855+
extern fn zguiPlotLines(
1856+
label: [*:0]const u8,
1857+
v: [*]f32,
1858+
v_count: c_int,
1859+
v_offset: c_int,
1860+
overlay: ?[*:0]const u8,
1861+
scale_min: f32,
1862+
scale_max: f32,
1863+
graph_size: *const [2]f32,
1864+
stride: c_int,
1865+
) void;
1866+
1867+
pub fn plotHistogram(label: [*:0]const u8, args: PlotArgs) void {
1868+
zguiPlotHistogram(
1869+
label,
1870+
args.v,
1871+
args.v_count,
1872+
args.v_offset,
1873+
if (args.overlay) |o| o else null,
1874+
args.scale_min,
1875+
args.scale_max,
1876+
&args.graph_size,
1877+
args.stride,
1878+
);
1879+
}
1880+
extern fn zguiPlotHistogram(
1881+
label: [*:0]const u8,
1882+
v: [*]f32,
1883+
v_count: c_int,
1884+
v_offset: c_int,
1885+
overlay: ?[*:0]const u8,
1886+
scale_min: f32,
1887+
scale_max: f32,
1888+
graph_size: *const [2]f32,
1889+
stride: c_int,
1890+
) void;
18311891

18321892
//--------------------------------------------------------------------------------------------------
18331893
//

src/zgui.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1977,6 +1977,36 @@ extern "C"
19771977
{
19781978
ImGui::CloseCurrentPopup();
19791979
}
1980+
1981+
ZGUI_API void zguiPlotLines(
1982+
const char* label,
1983+
const float* values,
1984+
int values_count,
1985+
int values_offset,
1986+
const char* overlay_text,
1987+
float scale_min,
1988+
float scale_max,
1989+
float graph_size[2],
1990+
int stride)
1991+
{
1992+
ImGui::PlotLines(label, values, values_count, values_offset, overlay_text, scale_min, scale_max, ImVec2(graph_size[0], graph_size[1]), stride);
1993+
}
1994+
1995+
1996+
ZGUI_API void zguiPlotHistogram(
1997+
const char* label,
1998+
const float* values,
1999+
int values_count,
2000+
int values_offset,
2001+
const char* overlay_text,
2002+
float scale_min,
2003+
float scale_max,
2004+
float graph_size[2],
2005+
int stride)
2006+
{
2007+
ImGui::PlotHistogram(label, values, values_count, values_offset, overlay_text, scale_min, scale_max, ImVec2(graph_size[0], graph_size[1]), stride);
2008+
}
2009+
19802010
//--------------------------------------------------------------------------------------------------
19812011
//
19822012
// Tables

0 commit comments

Comments
 (0)