# Migrating from GLMakie 0.4.7 to current

**URL:** <https://discourse.julialang.org/t/migrating-from-glmakie-0-4-7-to-current/79913>\
**Category:** General Usage\
**Tags:** question, package, makie\
**Created:** [April 23, 2022, 8:23pm UTC](https://discourse.julialang.org/t/migrating-from-glmakie-0-4-7-to-current/79913 "2022-04-23T20:23:41Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [April 23, 2022, 8:23pm UTC](https://discourse.julialang.org/t/migrating-from-glmakie-0-4-7-to-current/79913/1 "2022-04-23T20:23:41Z")

</div>

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

```julia
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?

---

<div class="post-metadata">

**Author:** ![icweaver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/icweaver/32/45764_2.png) [@icweaver](https://discourse.julialang.org/u/icweaver)\
**Post date:** [April 23, 2022, 8:54pm UTC](https://discourse.julialang.org/t/migrating-from-glmakie-0-4-7-to-current/79913/2 "2022-04-23T20:54:13Z")

</div>

I think `Node` is called `Observable` now

> <https://github.com/JuliaPlots/Makie.jl/blob/master/NEWS.md#v016>

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [April 23, 2022, 9:28pm UTC](https://discourse.julialang.org/t/migrating-from-glmakie-0-4-7-to-current/79913/3 "2022-04-23T21:28:57Z")

</div>

Thanks for the link!

I added these three lines:

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

```

and can load the module now. 🙂

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

I get the error:

```julia
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:

```julia
    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?

---

<div class="post-metadata">

**Author:** ![icweaver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/icweaver/32/45764_2.png) [@icweaver](https://discourse.julialang.org/u/icweaver)\
**Post date:** [April 23, 2022, 10:44pm UTC](https://discourse.julialang.org/t/migrating-from-glmakie-0-4-7-to-current/79913/4 "2022-04-23T22:44:09Z")

</div>

It looks like you might be using [older constructs](https://github.com/JuliaPlots/Makie.jl/issues/779) from the since deprecated/absorbed MakieLayout.jl/AbstractPlotting.jl?

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

```julia
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](https://makie.juliaplots.org/stable/examples/layoutables/axis3/index.html) and [LScene](https://makie.juliaplots.org/stable/examples/layoutables/lscene/) might also have some additional information that you are looking for, but not sure about your particular use case!

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [April 24, 2022, 10:27am UTC](https://discourse.julialang.org/t/migrating-from-glmakie-0-4-7-to-current/79913/5 "2022-04-24T10:27:27Z")

</div>

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:

```julia
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:

```julia
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](https://github.com/aenarete/KiteViewers.jl/tree/newmakie), the file to look at is the file “pure.jl”.

---

<div class="post-metadata">

**Author:** ![icweaver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/icweaver/32/45764_2.png) [@icweaver](https://discourse.julialang.org/u/icweaver)\
**Post date:** [April 24, 2022, 6:25pm UTC](https://discourse.julialang.org/t/migrating-from-glmakie-0-4-7-to-current/79913/6 "2022-04-24T18:25:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [April 24, 2022, 6:48pm UTC](https://discourse.julialang.org/t/migrating-from-glmakie-0-4-7-to-current/79913/7 "2022-04-24T18:48:11Z")

</div>

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

The constructor returns a Viewer3D struct.

```julia
# 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?

---

<div class="post-metadata">

**Author:** ![icweaver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/icweaver/32/45764_2.png) [@icweaver](https://discourse.julialang.org/u/icweaver)\
**Post date:** [April 24, 2022, 6:56pm UTC](https://discourse.julialang.org/t/migrating-from-glmakie-0-4-7-to-current/79913/8 "2022-04-24T18:56:14Z")

</div>

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!

 ![image](https://global.discourse-cdn.com/julialang/original/3X/7/e/7e6c1adf344f5c960b33cf0c0f08cfc8f1fa3f38.png)

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [April 24, 2022, 10:48pm UTC](https://discourse.julialang.org/t/migrating-from-glmakie-0-4-7-to-current/79913/9 "2022-04-24T22:48:42Z")

</div>

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

But when using the newmakie branch:

```julia
]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:

```julia
    # 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.

---

<div class="post-metadata">

**Author:** ![icweaver](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/icweaver/32/45764_2.png) [@icweaver](https://discourse.julialang.org/u/icweaver)\
**Post date:** [April 25, 2022, 12:12am UTC](https://discourse.julialang.org/t/migrating-from-glmakie-0-4-7-to-current/79913/10 "2022-04-25T00:12:03Z")

</div>

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 `layout` → `fig` gives me the following now:

```julia
    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:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/d/a/dae689f4162964606dac6c575611613cfdf6e1ed.png)

After:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/b/f/bfa602f5d63fa2c4072f3d2037ba52d26b8055d2.png)

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [April 25, 2022, 12:17am UTC](https://discourse.julialang.org/t/migrating-from-glmakie-0-4-7-to-current/79913/11 "2022-04-25T00:17:51Z")

</div>

Thanks for your quick response. 🙂

But I must sleep now, continue tomorrow.
