-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Figure will be drawn to the main window when DataInspector is triggered #151
Comments
I cannot reproduce this, it works ok on my machine: Codeimport 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]
elseif type === :sine
[Point2f(i, sin(i * 0.1) + 0.5) for i in 1:N]
end
end
function makie_demo(; engine=nothing, spawn=1)
# 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, label="Random data")
lines!(ax1, generate_data(:sine), label="Sin")
data2 = Observable(generate_data())
axislegend(ax1)
ax2 = Axis(f[2, 1])
lines!(ax2, data2)
DataInspector(f)
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
auto_resize_x = true
auto_resize_y = false
tooltip = true
stats = true
stream_data = false
data_task = nothing
function live_data(obs::Observable)
obs_data = obs[]
while stream_data
push!(obs_data, Point2f(length(obs_data), rand()))
obs[] = obs_data
autolimits!(ax1)
sleep(0.01)
end
data_task = nothing
end
# Start the GUI
ig.render(ctx; engine, window_size=(1280, 760), window_title="ImGui Window", opengl_version=v"3.3", spawn) do
ig.Begin("Makie demo")
if ig.Button("Random data")
data[] = generate_data()
end
@c ig.Checkbox("Auto resize X", &auto_resize_x)
ig.SameLine()
@c ig.Checkbox("Auto resize Y", &auto_resize_y)
ig.SameLine()
@c ig.Checkbox("Draw tooltip", &tooltip)
ig.SameLine()
@c ig.Checkbox("Show render times", &stats)
ig.SameLine()
@c ig.Checkbox("Stream data", &stream_data)
if stream_data && isnothing(data_task)
data_task = errormonitor(Threads.@spawn live_data(data))
end
ig.MakieFigure("plot", f; auto_resize_x, auto_resize_y, tooltip, stats)
ig.Text("Mouse position in scene: $(scene.events.mouseposition[])")
ig.Text("Scene size: $(size(scene))")
# These extra transformations are necessary to handle non-linear axis
# scales. See: https://github.com/MakieOrg/Makie.jl/pull/4090.
x, y = mouseposition(ax1)
x = Makie.inverse_transform(ax1.xscale[])(x)
y = Makie.inverse_transform(ax1.yscale[])(y)
ig.Text("Mouse position in ax1: ($x, $y)")
ig.Text("Thread ID: $(Threads.threadid())")
ig.SameLine()
ig.HelpMarker("""
On some platforms it may be possible (but not recommended!)
to run on a thread that isn't thread 1. Call `makie_demo(;
spawn=...)` to try running the demo on a different thread.""")
ig.End()
end
end
# Run automatically if the script is launched from the command-line
if !isempty(Base.PROGRAM_FILE)
makie_demo()
end You'll need to give an MWE and more details, like the package versions and hardware differences between the working/non-working machines. |
One thing to try would be checking that these lines are computing the right image size: CImGui.jl/ext/MakieIntegration.jl Lines 161 to 165 in 65e82eb
Another would be to hard-code the framebuffer size we report to GLMakie to see if that changes the size of the plot when it's being scaled up like that: CImGui.jl/ext/MakieIntegration.jl Line 41 in 65e82eb
|
I just found that it does not happen to GLMakie's version >= 0.10.10. I used v"0.10.9" before. |
Oh, interesting 🤔 Can confirm switching to 0.10.9 reproduces the issue for me as well. From looking at the changelog I'm not sure what fixed it, the only changes in the DataInspector seem to come from MakieOrg/Makie.jl#4317 but they don't look particularly related. |
I just tested that the update here solved the problem. Perhaps due to too many events that cannot be processed, the excess parts will be rendered using GLMakie's renderloop again. https://github.com/MakieOrg/Makie.jl/blob/e90c042d16b461e67b750e5ce53790e732281dba/src/interaction/inspector.jl#L281C5-L293C42 |
This issue does not occur in every computers. Adding "DataInspector(f)" to the makie_demo.jl reproduces this bug.
The text was updated successfully, but these errors were encountered: