-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #133 from Gnimuc/makie
Makie integration
- Loading branch information
Showing
11 changed files
with
407 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "CImGui" | ||
uuid = "5d785b6c-b76f-510e-a07c-3070796c7e87" | ||
authors = ["Yupei Qi <[email protected]>"] | ||
version = "2.0.0" | ||
version = "2.1.0" | ||
|
||
[deps] | ||
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82" | ||
|
@@ -10,15 +10,18 @@ CSyntax = "ea656a56-6ca6-5dda-bba5-7b6963a5f74c" | |
|
||
[weakdeps] | ||
GLFW = "f7f18e0c-5ee9-5ccd-a5bf-e8befd85ed98" | ||
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a" | ||
ModernGL = "66fc600b-dfda-50eb-8b99-91cfa97b1301" | ||
|
||
[extensions] | ||
GlfwOpenGLBackend = ["GLFW", "ModernGL"] | ||
MakieIntegration = ["GLFW", "ModernGL", "GLMakie"] | ||
|
||
[compat] | ||
CEnum = "0.4, 0.5" | ||
CImGuiPack_jll = "0.3.0" | ||
CSyntax = "0.4" | ||
GLFW = "3" | ||
GLMakie = "0.10.5" | ||
ModernGL = "1" | ||
julia = "1.9" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
```@meta | ||
CurrentModule = CImGui | ||
``` | ||
|
||
# Makie integration | ||
|
||
We currently have *very experimental* [Makie](https://docs.makie.org/stable) | ||
support through | ||
[GLMakie](https://docs.makie.org/stable/explanations/backends/glmakie). GLMakie | ||
mostly works around a `Screen{T}` object to display a scene, where `T` is some | ||
OpenGL-supporting window. GLMakie sets this to a `GLFW.Window`, but we've made a | ||
custom window type to represent a single `Figure` to be drawn in ImGui. What we | ||
get from GLMakie is a framebuffer with a color image texture attachment, and | ||
that's displayed by us as an image. | ||
|
||
```@docs | ||
MakieFigure | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import GLFW | ||
using GLMakie | ||
import GLMakie.Makie as Makie | ||
import CImGui as ig | ||
import CImGui.CSyntax: @c | ||
import ModernGL as gl | ||
|
||
|
||
ig.set_backend(:GlfwOpenGL3) | ||
|
||
function generate_data(type::Symbol=:random, N=1000) | ||
if type === :random | ||
[Point2f(i, rand()) for i in 1:N] | ||
end | ||
end | ||
|
||
function HelpMarker(msg) | ||
ig.TextDisabled("(?)"); | ||
|
||
if ig.IsItemHovered() && ig.BeginTooltip() | ||
ig.PushTextWrapPos(ig.GetFontSize() * 35.0); | ||
ig.TextUnformatted(msg); | ||
ig.PopTextWrapPos(); | ||
ig.EndTooltip(); | ||
end | ||
end | ||
|
||
function makie_demo(; engine=nothing) | ||
# Create a plot | ||
f = Figure() | ||
scene = Makie.get_scene(f) | ||
ax1 = Axis(f[1, 1]; title="Random data") | ||
data = Observable(generate_data()) | ||
lines!(ax1, data) | ||
data2 = Observable(generate_data()) | ||
ax2 = Axis(f[2, 1]) | ||
lines!(ax2, data2) | ||
|
||
ctx = ig.CreateContext() | ||
io = ig.GetIO() | ||
io.ConfigFlags = unsafe_load(io.ConfigFlags) | ig.lib.ImGuiConfigFlags_DockingEnable | ||
io.ConfigFlags = unsafe_load(io.ConfigFlags) | ig.lib.ImGuiConfigFlags_ViewportsEnable | ||
|
||
ax1_tight_spacing = true | ||
auto_resize_x = true | ||
auto_resize_y = false | ||
|
||
# Start the GUI | ||
ig.render(ctx; engine, window_size=(1280, 760), window_title="ImGui Window") do | ||
ig.Begin("Makie demo") | ||
|
||
if ig.Button("Random data") | ||
data[] = generate_data() | ||
end | ||
|
||
@c ig.Checkbox("Ax1 tight tick spacing", &ax1_tight_spacing) | ||
ig.SameLine() | ||
HelpMarker(""" | ||
Try zooming into the top plot, if this option is disabled | ||
the axis will not resize itself to stop clipping the tick labels on the Y axis. | ||
""") | ||
|
||
@c ig.Checkbox("Auto resize X", &auto_resize_x) | ||
ig.SameLine() | ||
@c ig.Checkbox("Auto resize Y", &auto_resize_y) | ||
|
||
if ig.MakieFigure("plot", f; auto_resize_x, auto_resize_y) | ||
if ax1_tight_spacing | ||
Makie.tight_ticklabel_spacing!(ax1) | ||
end | ||
|
||
Makie.tight_ticklabel_spacing!(ax2) | ||
end | ||
|
||
ig.Text("Mouse position in scene: $(scene.events.mouseposition[])") | ||
ig.Text("Scene size: $(size(scene))") | ||
ig.Text("Mouse position in ax1: $(mouseposition(ax1))") | ||
|
||
ig.End() | ||
end | ||
end | ||
|
||
# Run automatically if the script is launched from the command-line | ||
if !isempty(Base.PROGRAM_FILE) | ||
makie_demo() | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
38eadb5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
38eadb5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/111969
Tip: Release Notes
Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.
To add them here just re-invoke and the PR will be updated.
Tagging
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: