Skip to content

Commit 92fa416

Browse files
calvertdwperrymacmurraySpaiR
authored
[API] Include ImPlot (#56)
* Add implot submodule. * Add implot to generateLibs * Add _implot.h * Add placeholder ImPlot java classes. * Create demo window. * Try to show the ImPlot demo in the window. * Create ImPlot context. * Fix final check. * Implement ImPlotFlags. * Implement the rest of the enums. * Make classes final. * Implement ImPlotContext and related methods * Added more methods to ImPlot wrapper (mostly plot utils) * Implement ImPlotPoint * Implement ImPlotRange * Switch native method to static in ImPlotPoint * Implement ImPlotLimits * Finish ImPlot Plot Utils bindings * Implement more ImPlot methods (Miscellaneous) * Implement more ImPlot methods (Legend utils/tools) * Implement more ImPlot methods (Drag and drop utils) * Implement more ImPlot methods (Plot tools) * Implement more ImPlot methods (most plot items) * Fix compile error (casting to double and not Double) * Fix ImDrawData.getCmdListCmdBufferTextureId() * Implement more ImPlot methods (rest of plot items) (except for PlotImage, which is not currently supported) * Fix ImGui binding problems due to API changes * Adhere to style guidelines. * Fix imguizmo submodule * Fix API * Implement ImPlotStyle * Implement more ImPlot methods (Plot and Item styling) * Implement remainder of ImPlot methods (Colormaps) * Modify ImPlot example program * Fix ImPlot example program bug * ImPlot bugfixes * Update ImPlot Demo * Revert merge errors. * Make the submodules the version on master. * Fix URL/style in ExampleImPlot * Fix merge conflicts with example ImPlot context creation * Remove unneccesary static block for field declarations * Revert libimgui-java64.so * Change construction to use define (vs passing a pointer) * Fixed memory leaks Changed ImPlotLimits, ImPlotRange, and ImPlotPoint to extend ImGuiStructDestroyable instead of ImGuiStruct so user-created instances can be destroyed. Methods that create instances that must be destroyed manually specify this in the docs. * Fix style violations * Fix compile error * Replace exception type Co-authored-by: Perry MacMurray <[email protected]> Co-authored-by: Perry <[email protected]> Co-authored-by: SpaiR <[email protected]>
1 parent 2c6f52a commit 92fa416

23 files changed

+2931
-1
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@
1010
[submodule "include/imguizmo"]
1111
path = include/imguizmo
1212
url = https://github.com/CedricGuillemet/ImGuizmo.git
13+
[submodule "include/implot"]
14+
path = include/implot
15+
url = https://github.com/epezent/implot.git

buildSrc/src/main/groovy/imgui/generate/GenerateLibs.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class GenerateLibs extends DefaultTask {
4646

4747
// Copy ImGui h/cpp files
4848
project.copy { CopySpec spec ->
49-
['include/imgui', 'include/imnodes', 'include/imgui-node-editor', 'include/imguizmo'].each {
49+
['include/imgui', 'include/imnodes', 'include/imgui-node-editor', 'include/imguizmo', 'include/implot'].each {
5050
spec.from(project.rootProject.file(it)) { CopySpec s -> s.include('*.h', '*.cpp', '*.inl') }
5151
}
5252
spec.from(project.rootProject.file('imgui-binding/src/main/native'))
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import imgui.extension.implot.ImPlot;
2+
import imgui.extension.implot.ImPlotContext;
3+
import imgui.flag.ImGuiCond;
4+
import imgui.internal.ImGui;
5+
import imgui.type.ImBoolean;
6+
7+
import java.awt.*;
8+
import java.net.URI;
9+
10+
public class ExampleImPlot {
11+
private static final String URL = "https://github.com/epezent/implot/tree/555ff68";
12+
private static final ImBoolean showDemo = new ImBoolean(false);
13+
14+
private static final Integer[] xs = {0, 1, 2, 3, 4, 5};
15+
private static final Integer[] ys = {0, 1, 2, 3, 4, 5};
16+
17+
private final static ImPlotContext IMPLOT_CONTEXT;
18+
19+
static {
20+
IMPLOT_CONTEXT = ImPlot.createContext();
21+
}
22+
23+
public static void show(ImBoolean showImPlotWindow) {
24+
ImGui.setNextWindowSize(500, 400, ImGuiCond.Once);
25+
ImGui.setNextWindowPos(ImGui.getMainViewport().getPosX() + 100, ImGui.getMainViewport().getPosY() + 100, ImGuiCond.Once);
26+
if (ImGui.begin("ImPlot Demo", showImPlotWindow)) {
27+
ImGui.text("This a demo for ImPlot");
28+
29+
ImGui.alignTextToFramePadding();
30+
ImGui.text("Repo:");
31+
ImGui.sameLine();
32+
if (ImGui.button(URL)) {
33+
try {
34+
Desktop.getDesktop().browse(new URI(URL));
35+
} catch (Exception e) {
36+
e.printStackTrace();
37+
}
38+
}
39+
40+
ImGui.checkbox("Show ImPlot Built-In Demo", showDemo);
41+
42+
if (ImPlot.beginPlot("Example Plot")) {
43+
ImPlot.plotLine("Line", xs, ys);
44+
ImPlot.plotBars("Bars", xs, ys);
45+
ImPlot.endPlot();
46+
}
47+
48+
if (ImPlot.beginPlot("Example Scatterplot")) {
49+
ImPlot.plotScatter("Scatter", xs, ys);
50+
ImPlot.endPlot();
51+
}
52+
53+
if (showDemo.get()) {
54+
ImPlot.showDemoWindow(showDemo);
55+
}
56+
}
57+
58+
ImGui.end();
59+
}
60+
}

example/src/main/java/Extra.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ public class Extra {
77
private static final ImBoolean SHOW_IMNODES_DEMO_WINDOW = new ImBoolean(false);
88
private static final ImBoolean SHOW_IMGUI_NODE_EDITOR_DEMO_WINDOW = new ImBoolean(false);
99
private static final ImBoolean SHOW_DRAG_N_DROP_WINDOW = new ImBoolean(false);
10+
private static final ImBoolean SHOW_IMPLOT_DEMO_WINDOW = new ImBoolean(false);
1011
private static final ImBoolean SHOW_IMGUIZMO_DEMO = new ImBoolean(false);
1112

1213
private static final Graph GRAPH = new Graph();
@@ -17,6 +18,7 @@ public static void show(final Application app) {
1718
ImGui.checkbox("Show ImNodes Demo Window", SHOW_IMNODES_DEMO_WINDOW);
1819
ImGui.checkbox("Show imgui-node-editor Demo Window", SHOW_IMGUI_NODE_EDITOR_DEMO_WINDOW);
1920
ImGui.checkbox("Show Drag'N'Drop Demo Window", SHOW_DRAG_N_DROP_WINDOW);
21+
ImGui.checkbox("Show ImPlot Demo Window", SHOW_IMPLOT_DEMO_WINDOW);
2022
ImGui.checkbox("Show ImGuizmo Demo Window", SHOW_IMGUIZMO_DEMO);
2123

2224
if (SHOW_DEMO_WINDOW.get()) {
@@ -38,5 +40,9 @@ public static void show(final Application app) {
3840
if (SHOW_DRAG_N_DROP_WINDOW.get()) {
3941
ExampleDragAndDrop.show(SHOW_DRAG_N_DROP_WINDOW);
4042
}
43+
44+
if (SHOW_IMPLOT_DEMO_WINDOW.get()) {
45+
ExampleImPlot.show(SHOW_IMPLOT_DEMO_WINDOW);
46+
}
4147
}
4248
}

example/src/main/java/Main.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import imgui.app.Application;
33
import imgui.app.Configuration;
44
import imgui.extension.imnodes.ImNodes;
5+
import imgui.extension.implot.ImPlot;
6+
import imgui.extension.implot.ImPlotContext;
57
import imgui.flag.ImGuiConfigFlags;
68
import imgui.flag.ImGuiInputTextFlags;
79
import imgui.type.ImString;

0 commit comments

Comments
 (0)