Migrating from GLMakie 0.4.7 to current

I am trying to migrate my package GitHub - aenarete/KiteViewers.jl: 3D viewer for airborne wind energy systems (not registered) from GLMakie 0.4.7 to the current version.
The first error I see is:

julia> using KiteViewers
[ Info: Precompiling KiteViewers [2e593061-95e7-45e4-95f4-df0491f2e601]
ERROR: LoadError: UndefVarError: Node not defined
Stacktrace:
  [1] top-level scope
    @ ~/repos/KiteViewers.jl/src/pure.jl:92
  [2] include(mod::Module, _path::String)
    @ Base ./Base.jl:418
  [3] include(x::String)
    @ KiteViewers ~/repos/KiteViewers.jl/src/KiteViewers.jl:1
  [4] top-level scope
    @ ~/repos/KiteViewers.jl/src/KiteViewers.jl:9
  [5] include

How can I fix this error?

I think Node is called Observable now

Thanks for the link!

I added these three lines:

const Node = Observable
const Quaternionf0 = Quaternionf
const RGBf0 = RGBf

and can load the module now. :slight_smile:

Next problem:
When I execute include ("test/test_steering.jl")

I get the error:

julia> @time include("test/test_steering.jl")
Precompiling project...
  1 dependency successfully precompiled in 14 seconds (207 already precompiled)
ERROR: LoadError: UndefVarError: layoutscene not defined
Stacktrace:
 [1] Viewer3D()
   @ KiteViewers ~/repos/KiteViewers/src/pure.jl:40
 [2] top-level scope
   @ ~/repos/KiteViewers/test/test_steering.jl:23
 [3] include
   @ ./client.jl:451 [inlined]
 [4] top-level scope
   @ ./timing.jl:220 [inlined]
 [5] top-level scope
   @ ./REPL[1]:0
in expression starting at /home/ufechner/repos/KiteViewers/test/test_steering.jl:23

I could not find layoutscene mentioned as depreciated in NEWS.md .

Any idea what happened to it?

I guess I have to rewrite the following two lines:

    scene, layout = layoutscene(resolution = (840, 900), backgroundcolor = RGBf0(0.7, 0.8, 1))
    scene3D = LScene(scene, scenekw = (show_axis=false, limits = Rect(-7,-10.0,0, 11,10,11), resolution = (800, 800)), raw=false)

But how?

It looks like you might be using older constructs from the since deprecated/absorbed MakieLayout.jl/AbstractPlotting.jl?

I would re-write those two lines as the following:

fig = Figure(resolution=(840, 900), backgroundcolor=RGBf(0.7, 0.8, 1))
scene3D = LScene(fig[1, 1], scenekw=(show_axis=false, limits=Rect(-7,-10.0,0, 11,10,11), resolution=(800, 800)), raw=false)

The docs on Axis3 and LScene might also have some additional information that you are looking for, but not sure about your particular use case!

Thanks for the tip!

I adapted your idea to my code and was able to fix the syntax errors. This is how far I got:

function Viewer3D()
    # old code, working with GLMakie 4.7 
    # scene, layout = layoutscene(resolution = (840, 900), backgroundcolor = RGBf0(0.7, 0.8, 1))
    # scene3D = LScene(scene, scenekw = (show_axis=false, limits = Rect(-7,-10.0,0, 11,10,11), resolution = (800, 800)), raw=false)
    
    fig = Figure(resolution=(840, 900), backgroundcolor=RGBf(0.7, 0.8, 1))
    # just a try
    scene = fig[1,1]
    scene3D = LScene(scene, scenekw=(show_axis=false, limits=Rect(-7,-10.0,0, 11,10,11), resolution=(800, 800)), raw=false)
    
    create_coordinate_system(scene3D)
    cam = cameracontrols(scene3D.scene)

    FLYING[1] = false
    PLAYING[1] = false
    GUI_ACTIVE[1] = true

    reset_view(cam, scene3D)

    textsize[]  = TEXT_SIZE
    textsize2[] = AXIS_LABEL_SIZE
    text!(scene3D, "z", position = Point3f0(0, 0, 14.6), textsize = textsize2, align = (:center, :center), show_axis = false)
    text!(scene3D, "x", position = Point3f0(17, 0,0), textsize = textsize2, align = (:center, :center), show_axis = false)
    text!(scene3D, "y", position = Point3f0( 0, 14.5, 0), textsize = textsize2, align = (:center, :center), show_axis = false)

    text!(scene, status, position = Point2f0( 20, 0), textsize = TEXT_SIZE, align = (:left, :bottom), show_axis = false)
    status[]="Stopped"

    # layout[1, 1] = scene3D
    # layout[2, 1] = buttongrid = GridLayout(tellwidth = false)

    # l_sublayout = GridLayout()
    # layout[1:3, 1] = l_sublayout
    # l_sublayout[:v] = [scene3D, buttongrid]
    btn_RESET       = Button(scene, label = "RESET")
    btn_ZOOM_in     = Button(scene, label = "Zoom +")
    btn_ZOOM_out    = Button(scene, label = "Zoom -")
    btn_PLAY_PAUSE  = Button(scene, label = @lift($running ? "PAUSE" : " PLAY  "))
    btn_STOP        = Button(scene, label = "STOP")
    sw = Toggle(scene, active = false)
    label = Label(scene, "repeat")
    
    # buttongrid[1, 1:7] = [btn_PLAY_PAUSE, btn_ZOOM_in, btn_ZOOM_out, btn_RESET, btn_STOP, sw, label]

    gl_screen = display(scene)
    # old code, working with GLMakie 4.7 
    # Viewer3D(scene, layout, scene3D, cam, gl_screen, btn_RESET, btn_ZOOM_in, btn_ZOOM_out)
    Viewer3D(scene3D, cam, btn_RESET, btn_ZOOM_in, btn_ZOOM_out)
end

But if I run:

using KiteViewers
viewer=Viewer3D()

nothing happens, I mean no Window pops up as it did when using GLMakie 0.4.7.

What am I doing wrong?

You can find my full code at GitHub - aenarete/KiteViewers.jl at newmakie, the file to look at is the file “pure.jl”.

Not sure, but is your final Viewer3D call returning fig? By the way, are you using a private repo by any chance? Following your link takes to me to a 404 page

Sorry for publishing a dead link, it should work now… :grinning:

The constructor returns a Viewer3D struct.

# struct that stores the state of the 3D viewer
mutable struct Viewer3D
    # scene::Scene
    # layout::GridLayout
    scene3D::LScene
    cam::Camera3D
    # screen::GLMakie.Screen
    btn_RESET::Button
    btn_ZOOM_in::Button
    btn_ZOOM_out::Button
end

Works fine in the main branch with the old GLMakie…

Do I need to return a Figure now to see something?

Ah, no worries. I don’t know what the norm was for 0.4.7, but AFAICT, needing to return a Figure is required these days across all backends

Edit: Ah, I see that you are calling display inside your constructor for Viewer3D. I think that should be fine then, and it seems to display a figure alright on my end!

Well, this works with GLMakie 0.4.7 but not with the newest GLMakie.

But when using the newmakie branch:

]add https://github.com/aenarete/KiteViewers.jl#newmakie
using KiteViewers
viewer=Viewer3D();

Does display a Window.

But the output is rubish.

So how can I translate the following lines:

    # layout[1, 1] = scene3D
    # layout[2, 1] = buttongrid = GridLayout(tellwidth = false)

    # l_sublayout = GridLayout()
    # layout[1:3, 1] = l_sublayout
    # l_sublayout[:v] = [scene3D, buttongrid]

UPDATE:
Adding the package as explained above did not work due to missing config files, but now it should work.

So it should be easy to reproduce my problem.

Oh whoops, forgot to check what env I was using, sorry about that. Yep, I am able to reproduce your issue now. I think it just looks like a width problem. Allowing it to adjust with your buttongrid and swapping layoutfig gives me the following now:

    fig[1, 1] = scene3D
    fig[2, 1] = buttongrid = GridLayout(tellwidth=true)

    l_sublayout = GridLayout()
    fig[1:3, 1] = l_sublayout
    l_sublayout[:v] = [scene3D, buttongrid]

    buttongrid[1, 1:7] = [btn_PLAY_PAUSE, btn_ZOOM_in, btn_ZOOM_out, btn_RESET, btn_STOP, sw, label]

Before:

After:

Thanks for your quick response. :slight_smile:

But I must sleep now, continue tomorrow.