Skip to content
Snippets Groups Projects
Commit f0deb40e authored by xo30xoqa's avatar xo30xoqa
Browse files

Added a splash screen to show while model is initialised

Unfortunately, this is also still victim to a QML.jl bug :-(
parent 8809dedd
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
julia_version = "1.9.3" julia_version = "1.9.3"
manifest_format = "2.0" manifest_format = "2.0"
project_hash = "ef26157ea1ae4a93e96b1c8d299fd2a6058b6b45" project_hash = "5a2d131ebba9918c9648a958a8d008d9dd7bc967"
[[deps.AbstractFFTs]] [[deps.AbstractFFTs]]
deps = ["LinearAlgebra"] deps = ["LinearAlgebra"]
...@@ -195,10 +195,10 @@ uuid = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0" ...@@ -195,10 +195,10 @@ uuid = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
version = "0.8.13" version = "0.8.13"
[[deps.Cairo_jll]] [[deps.Cairo_jll]]
deps = ["Artifacts", "Bzip2_jll", "CompilerSupportLibraries_jll", "Fontconfig_jll", "FreeType2_jll", "Glib_jll", "JLLWrappers", "LZO_jll", "Libdl", "Pixman_jll", "Xorg_libXext_jll", "Xorg_libXrender_jll", "Zlib_jll", "libpng_jll"] deps = ["Artifacts", "Bzip2_jll", "CompilerSupportLibraries_jll", "Fontconfig_jll", "FreeType2_jll", "Glib_jll", "JLLWrappers", "LZO_jll", "Libdl", "Pixman_jll", "Pkg", "Xorg_libXext_jll", "Xorg_libXrender_jll", "Zlib_jll", "libpng_jll"]
git-tree-sha1 = "d3cc53959197e659a85f4fac191045245db8c39b" git-tree-sha1 = "4b859a208b2397a7a623a03449e4636bdb17bcf2"
uuid = "83423d85-b0ee-5818-9007-b63ccbeb887a" uuid = "83423d85-b0ee-5818-9007-b63ccbeb887a"
version = "1.18.0+0" version = "1.16.1+1"
[[deps.Calculus]] [[deps.Calculus]]
deps = ["LinearAlgebra"] deps = ["LinearAlgebra"]
...@@ -1890,9 +1890,9 @@ version = "0.16.0+0" ...@@ -1890,9 +1890,9 @@ version = "0.16.0+0"
[[deps.TiffImages]] [[deps.TiffImages]]
deps = ["ColorTypes", "DataStructures", "DocStringExtensions", "FileIO", "FixedPointNumbers", "IndirectArrays", "Inflate", "Mmap", "OffsetArrays", "PkgVersion", "ProgressMeter", "UUIDs"] deps = ["ColorTypes", "DataStructures", "DocStringExtensions", "FileIO", "FixedPointNumbers", "IndirectArrays", "Inflate", "Mmap", "OffsetArrays", "PkgVersion", "ProgressMeter", "UUIDs"]
git-tree-sha1 = "7fd97bd1c5b1ff53a291cbd351d1d3d6ff4da5a5" git-tree-sha1 = "34cc045dd0aaa59b8bbe86c644679bc57f1d5bd0"
uuid = "731e570b-9d59-4bfa-96dc-6df516fadf69" uuid = "731e570b-9d59-4bfa-96dc-6df516fadf69"
version = "0.6.7" version = "0.6.8"
[[deps.TranscodingStreams]] [[deps.TranscodingStreams]]
deps = ["Random", "Test"] deps = ["Random", "Test"]
......
...@@ -9,7 +9,6 @@ CxxWrap = "1f15a43c-97ca-5a2a-ae31-89f07a497df4" ...@@ -9,7 +9,6 @@ CxxWrap = "1f15a43c-97ca-5a2a-ae31-89f07a497df4"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549" FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a" GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
GeoStatsBase = "323cb8eb-fbf6-51c0-afd0-f8fba70507b2"
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326" GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
Observables = "510215fc-4207-5dde-b226-833fc4488ee2" Observables = "510215fc-4207-5dde-b226-833fc4488ee2"
...@@ -17,5 +16,3 @@ Persefone = "039acd1d-2a07-4b33-b082-83a1ff0fd136" ...@@ -17,5 +16,3 @@ Persefone = "039acd1d-2a07-4b33-b082-83a1ff0fd136"
QML = "2db162a6-7e43-52c3-8d84-290c1c42d82a" QML = "2db162a6-7e43-52c3-8d84-290c1c42d82a"
Qt6Base_jll = "c0090381-4147-56d7-9ebc-da0b1113ec56" Qt6Base_jll = "c0090381-4147-56d7-9ebc-da0b1113ec56"
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76" TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
TableTransforms = "0d432bfd-3ee1-4ac1-886a-39f05cc69a3e"
jlqml_jll = "6b5019fb-a83d-5b4e-a9f7-678a36c28df7"
...@@ -11,4 +11,3 @@ using PersefoneDesktop ...@@ -11,4 +11,3 @@ using PersefoneDesktop
ENV["QSG_RENDER_LOOP"] = "basic" ENV["QSG_RENDER_LOOP"] = "basic"
launch() launch()
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
## - https://github.com/barche/QmlJuliaExamples ## - https://github.com/barche/QmlJuliaExamples
## - https://doc.qt.io/qt-6/qtquick-index.html ## - https://doc.qt.io/qt-6/qtquick-index.html
global model::Union{AgentBasedModel,Missing} = missing global model = nothing
global landcovermap = nothing
#loadmodelobject(joinpath(dirname(@__FILE__), "../sampleinit.dat")) #initialise() #loadmodelobject(joinpath(dirname(@__FILE__), "../sampleinit.dat")) #initialise()
const running = Observable(false) const running = Observable(false)
const date = Observable(today()) const date = Observable(today())
...@@ -18,10 +19,11 @@ const runbuttontext = Observable(">>") ...@@ -18,10 +19,11 @@ const runbuttontext = Observable(">>")
const runbuttontip = Observable("Run") const runbuttontip = Observable("Run")
function newsimulation() function newsimulation()
global model global model, landcovermap
running[] = false running[] = false
progress[] = 0.0 progress[] = 0.0
model = initialise() #TODO configure model = initialise() #TODO configure
landcovermap = load(@param(world.landcovermap))
date[] = model.date date[] = model.date
println("Model initialised.") println("Model initialised.")
end end
...@@ -79,12 +81,12 @@ function togglerunning() ...@@ -79,12 +81,12 @@ function togglerunning()
end end
function render_map(screen) function render_map(screen)
global model global model, landcovermap
figure = visualisemap(model, date[]) figure = visualisemap(model, date[], landcovermap)
display(screen, figure.scene) display(screen, figure.scene)
end end
function render_map(screen) function render_plot(screen)
global model global model
figure = populationtrends(model) figure = populationtrends(model)
display(screen, figure.scene) display(screen, figure.scene)
...@@ -95,6 +97,7 @@ end ...@@ -95,6 +97,7 @@ end
@qmlfunction previousstep @qmlfunction previousstep
@qmlfunction togglerunning @qmlfunction togglerunning
@qmlfunction render_map @qmlfunction render_map
@qmlfunction render_plot
on(delay) do d on(delay) do d
println("Delay is now $(round(d, digits=1)) seconds.") println("Delay is now $(round(d, digits=1)) seconds.")
...@@ -104,12 +107,25 @@ on(running) do r ...@@ -104,12 +107,25 @@ on(running) do r
r ? println("Simulation started.") : println("Simulation stopped.") r ? println("Simulation started.") : println("Simulation stopped.")
end end
function splashscreen()
qmlfile = joinpath(dirname(@__FILE__), "splash.qml")
quick_view = init_qquickview()
set_source(quick_view, QUrlFromLocalFile(qmlfile))
QML.show(quick_view)
#XXX exec_async() is currently still broken, but should be fixed soon
# (https://github.com/JuliaGraphics/QML.jl/issues/174)
exec_async()
end
""" """
launch() launch()
The main function that creates the application. The main function that creates the application.
""" """
function launch() function launch()
global model
splashscreen()
newsimulation()
# absolute path in case working dir is overridden # absolute path in case working dir is overridden
qmlfile = joinpath(dirname(@__FILE__), "main.qml") qmlfile = joinpath(dirname(@__FILE__), "main.qml")
loadqml(qmlfile, loadqml(qmlfile,
......
...@@ -18,6 +18,7 @@ using ...@@ -18,6 +18,7 @@ using
Dates, Dates,
Makie, Makie,
Agents, Agents,
FileIO,
CxxWrap, CxxWrap,
GLMakie, GLMakie,
Persefone, Persefone,
......
...@@ -71,7 +71,6 @@ Distributed under the MIT license." ...@@ -71,7 +71,6 @@ Distributed under the MIT license."
/* } */ /* } */
ColumnLayout { ColumnLayout {
anchors.fill: parent
// the calendar is no longer a single widget, but needs to be // the calendar is no longer a single widget, but needs to be
// constructed manually :-( // constructed manually :-(
...@@ -118,6 +117,8 @@ Distributed under the MIT license." ...@@ -118,6 +117,8 @@ Distributed under the MIT license."
// bar and a speed slider // bar and a speed slider
footer: ToolBar { footer: ToolBar {
RowLayout { RowLayout {
//TODO change button texts to icons
// (https://doc.qt.io/qt-6/qtquickcontrols-icons.html)
id: controlBar id: controlBar
anchors.fill: parent anchors.fill: parent
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
......
src/persefonejl_logo_v3_splash.png

124 KiB

/// PersefoneDesktop - a GUI to the Persefone model of agriculture and ecosystems
///
/// This file creates the splash screen. Load it using a QQuickView.
///
import QtQuick
import QtQuick.Controls
import org.julialang
Rectangle {
width: 1200
height: 500
Image {
source: "persefonejl_logo_v3_splash.png"
fillMode: Image.PreserveAspectFit
}
Timer {
// Show the splash screen while the model object is initialised
//XXX is 15s a good time here?
interval: 15000; running: true; repeat: false
onTriggered: parent.Window.window.close()
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment