Skip to content
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

Makie render function not called #189

Closed
veddox opened this issue Oct 17, 2023 · 2 comments
Closed

Makie render function not called #189

veddox opened this issue Oct 17, 2023 · 2 comments

Comments

@veddox
Copy link

veddox commented Oct 17, 2023

I'm struggling getting the Makie integration to work. Although I can run the two examples (makie.jl and makie-plot.jl) just fine, my own code only gives me a blank window:

using CxxWrap
using Observables
using QML
using GLMakie
using FileIO
using Persefone

ENV["QSG_RENDER_LOOP"] = "basic"
QML.setGraphicsApi(QML.OpenGL)

global model = initialise()

function render_map(screen)
    global model
    println("Updating map")
    figure = visualisemap(model)
    display(screen, figure.scene)
end

qmlfile = joinpath(dirname(@__FILE__), "mwe.qml")
loadqml(qmlfile,
        render_map_callback = @safe_cfunction(render_map,Cvoid,(Any,)))
println("Launched MWE.")
exec()
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import org.julialang

ApplicationWindow {
	id: makieWindow
	title: "Makie integration"
	width: 1024
	height: 768
	visible: true

	MakieViewport {
		id: mapviewport
		Layout.fillWidth: true
		Layout.fillHeight: true
		renderFunction: render_map_callback
		
		Component.onCompleted: {
			mapviewport.update()
		}

	}

}

visualisemap() is a function that returns a Makie figure; if I call this directly, GLMakie plots it as expected.

My output shows no errors, simply an empty window. As I do not see the "Updating map" debug statement printed, I assume the render function is never called.

I'm using the main branch of QML.jl, GLMakie 0.6.13 and Makie 0.17.13

@barche
Copy link
Collaborator

barche commented Oct 17, 2023

The problem here is with the QML, in the makie example we use a ColumnLayout, hence the Layout. options make sense there. Without a layout, you should use the anchors:

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import org.julialang

ApplicationWindow {
	id: makieWindow
	title: "Makie integration"
	width: 1024
	height: 768
	visible: true

	MakieViewport {
		id: mapviewport
		anchors.fill: parent
		renderFunction: render_map_callback
	}

}

Ref: https://doc.qt.io/qt-6.5/qtquick-positioning-anchors.html

@veddox
Copy link
Author

veddox commented Oct 18, 2023

Ah, that was it! I had eventually figured out that it must be something to do with layouts, but didn't know enough to understand what. Thanks for the pointer!

@veddox veddox closed this as completed Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants