Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Release notes

## Unversioned updates

### Enhancements

* Added the option `pre_plot_sub_components` to the `GUI`-constructor to skip preplotting hidden sub components of an area (the option is by default `true`). The components of an `Area` are then plotted on demand (on the `open` functionality). This greatly enhances performance for large cases.
* Improved general performance.

## Version 0.5.17 (2025-11-19)

### Bugfix
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "EnergyModelsGUI"
uuid = "737a7361-d3b7-40e9-b1ac-59bee4c5ea2d"
version = "0.5.17"
version = "0.5.18"
authors = ["Jon Vegard Venås <JonVegard.Venas@sintef.no>", "Magnus Askeland <Magnus.Askeland@sintef.no>", "Shweta Tiwari <Shweta.Tiwari@sintef.no>"]

[deps]
Expand Down
Binary file modified docs/src/figures/EMI_geography.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/src/figures/EMI_geography_Oslo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/EMI_geography.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ gui = GUI(
coarse_coast_lines = false,
scale_tot_opex = true,
scale_tot_capex = false,
pre_plot_sub_components = false,
)
1 change: 0 additions & 1 deletion examples/generate_examples.jl
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,6 @@ It will be repalced in the near future with a simplified example.
"""

function generate_example_data_geo()
@debug "Generate case data"
@info "Generate data coded dummy model for now (Investment Model)"

# Retrieve the products
Expand Down
11 changes: 2 additions & 9 deletions ext/EMGExt/EMGExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,8 @@ using TimeStruct
using EnergyModelsBase
using EnergyModelsInvestments
using EnergyModelsGeography

# Use GLMakie to get the GridLayout type
using GLMakie

using EnergyModelsGUI

using DataFrames

const TS = TimeStruct
const EMG = EnergyModelsGeography
const EMB = EnergyModelsBase
Expand All @@ -38,7 +32,7 @@ EMG.get_transmissions(system::EMGUI.SystemGeo) = EMGUI.get_connections(system)
Get all transmission modes of a `SystemGeo` `system`.
"""
function get_modes(system::EMGUI.SystemGeo)
transmission_modes = Vector{TransmissionMode}()
transmission_modes = TransmissionMode[]
for t ∈ get_transmissions(system)
append!(transmission_modes, modes(t))
end
Expand Down Expand Up @@ -70,15 +64,14 @@ Initialize a `SystemGeo` from a `Case`.
"""
function EMGUI.SystemGeo(case::Case)
areas = get_areas(case)
ref_element = areas[1]
return EMGUI.SystemGeo(
get_time_struct(case),
get_products(case),
get_elements_vec(case),
areas,
get_transmissions(case),
EMGUI.NothingElement(),
ref_element,
areas[1],
)
end

Expand Down
11 changes: 6 additions & 5 deletions src/datastructures.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ energy system designs in Julia.
- **`wall::Observable{Symbol}`** represents an aspect of the system's state, observed
for changes and represented as a Symbol.
- **`file::String`** is the filename or path associated with the `EnergySystemDesign`.
- **`plots::Vector{Any}`** is a vector with all Makie object associated with this object.
The value does not have to be provided.
- **`plots::Vector{Makie.AbstractPlot}`** is a vector with all Makie object associated with
this object.
- **`invest_data::ProcInvData`** stores processed investment data.
"""
mutable struct EnergySystemDesign <: AbstractGUIObj
Expand All @@ -152,7 +152,7 @@ mutable struct EnergySystemDesign <: AbstractGUIObj
wall::Observable{Symbol}
file::String
inv_data::ProcInvData
plots::Vector{Any}
plots::Vector{Makie.AbstractPlot}
end
function EnergySystemDesign(
system::AbstractSystem,
Expand Down Expand Up @@ -198,7 +198,8 @@ Mutable type for providing a flexible data structure for connections between
linked to.
- **`connection::AbstractElement`** is the EMX connection structure.
- **`colors::Vector{RGBA{Float32}}`** is the associated colors of the connection.
- **`plots::Vector{Any}`** is a vector with all Makie object associated with this object.
- **`plots::Vector{Makie.AbstractPlot}`** is a vector with all Makie object associated with
this object.
- **`invest_data::ProcInvData`** stores processed investment data.
"""
mutable struct Connection <: AbstractGUIObj
Expand All @@ -207,7 +208,7 @@ mutable struct Connection <: AbstractGUIObj
connection::AbstractElement
colors::Vector{RGBA{Float32}}
inv_data::ProcInvData
plots::Vector{Any}
plots::Vector{Makie.AbstractPlot}
end
function Connection(
from::EnergySystemDesign,
Expand Down
62 changes: 41 additions & 21 deletions src/setup_GUI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ function GUI(
tol::Float64 = 1e-8,
enable_data_inspector::Bool = true,
use_geomakie::Bool = true,
pre_plot_sub_components::Bool = true,
)
# Generate the system topology:
@info raw"Setting up the topology design structure"
Expand All @@ -82,6 +83,11 @@ function GUI(
@info raw"Setting up the GUI"
design::EnergySystemDesign = root_design # variable to store current system (inkluding sub systems)

if expand_all && !pre_plot_sub_components
expand_all = false
@warn("Incompatible EMGUI settings: `expand_all` is set to true but
`pre_plot_sub_components` is set to false. Setting `expand_all` to false.")
Comment thread
Zetison marked this conversation as resolved.
Outdated
Comment thread
Zetison marked this conversation as resolved.
Outdated
end
# Set variables
vars::Dict{Symbol,Any} = Dict(
:title => Observable("top_level"),
Expand Down Expand Up @@ -111,6 +117,7 @@ function GUI(
:colormap => colormap,
:tol => tol,
:use_geomakie => use_geomakie,
:pre_plot_sub_components => pre_plot_sub_components,
:autolimits => Dict(
:results_op => true,
:results_sc => true,
Expand All @@ -137,7 +144,7 @@ function GUI(
vars[:path_to_descriptive_names] = path_to_descriptive_names
vars[:descriptive_names_dict] = descriptive_names_dict

vars[:plot_widths] = plot_widths
vars[:plot_widths] = Vec{2,Int64}(plot_widths)
vars[:hide_topo_ax_decorations] = hide_topo_ax_decorations
vars[:expand_all] = expand_all

Expand All @@ -155,24 +162,36 @@ function GUI(
vars[:selected_systems] = []

# Default text for the text area
vars[:default_text] = string(
"Tips:\n",
"Keyboard shortcuts:\n",
"\tctrl+left-click: Select multiple nodes.\n",
"\tright-click and drag: to pan\n",
"\tscroll wheel: zoom in or out\n",
"\tspace: Enter the selected system\n",
"\tctrl+s: Save\n",
"\tctrl+r: Reset view\n",
"\tctrl+w: Close window\n",
"\tEsc (or MouseButton4): Exit the current system and into the parent system\n",
"\tholding x while scrolling over plots will zoom in/out in the x-direction.\n",
"\tholding y while scrolling over plots will zoom in/out in the y-direction.\n\n",
"Left-clicking a component will put information about this component here.\n\n",
"Clicking a plot below enables you to pin this plot (hitting the `pin\n",
"current plot` button) for comparison with other plots.\n",
"Use the `Delete` button to unpin a selected plot.",
)
io = IOBuffer()
println(io, "Tips:")
println(io, "Keyboard shortcuts:")
println(io, "\tctrl+left-click: Select multiple nodes.")
println(io, "\tright-click and drag: to pan")
println(io, "\tscroll wheel: zoom in or out")
println(io, "\tspace: Enter the selected system")
println(io, "\tctrl+s: Save")
println(io, "\tctrl+r: Reset view")
println(io, "\tctrl+w: Close window")
println(
io,
"\tEsc (or MouseButton4): Exit the current system and into the parent system",
)
println(
io,
"\tholding x while scrolling over plots will zoom in/out in the x-direction.",
)
println(
io,
"\tholding y while scrolling over plots will zoom in/out in the y-direction.\n",
)
println(
io,
"Left-clicking a component will put information about this component here.\n",
)
println(io, "Clicking a plot below enables you to pin this plot (hitting the `pin")
println(io, "current plot` button) for comparison with other plots.")
print(io, "Use the `Delete` button to unpin a selected plot.")
vars[:default_text] = String(take!(io))
vars[:info_text] = Observable(vars[:default_text])
vars[:summary_text] = Observable("No model results")
vars[:dragging] = Ref(false)
Expand Down Expand Up @@ -219,7 +238,9 @@ function GUI(
notify(axes[:topo].finallimits)

# make sure all graphics is adapted to the spawned figure sizes
notify(get_toggle(gui, :expand_all).active)
if get_var(gui, :expand_all)
notify(get_toggle(gui, :expand_all).active)
end

# Enable inspector (such that hovering objects shows information)
# Linewidth set to zero as this boundary is slightly laggy on movement
Expand Down Expand Up @@ -305,7 +326,6 @@ function create_makie_objects(vars::Dict, design::EnergySystemDesign)

# Download the file if it doesn't exist in the temporary directory
if !isfile(local_file_path)
@debug "Trying to download file $url to $local_file_path"
HTTP.download(url, local_file_path)
end

Expand Down
8 changes: 4 additions & 4 deletions src/setup_topology.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ function EnergySystemDesign(
end

# Initialize components and connections
components::Vector{EnergySystemDesign} = EnergySystemDesign[]
connections::Vector{Connection} = Connection[]
components = EnergySystemDesign[]
connections = Connection[]

# Create an observable for the coordinate xy that can be inherited as the coordinate
# parent_xy
xy::Observable{Point2f} = Observable(Point2f(x, y))
xy = Observable(Point2f(x, y))

# Create an iterator for the current system
elements = get_children(system)
Expand All @@ -78,7 +78,7 @@ function EnergySystemDesign(
# (constructed as an EnergySystemDesign) to `components`
if !isnothing(elements)
current_node::Int64 = 1
nodes_count::Int64 = length(get_children(system))
nodes_count = length(get_children(system))

# Loop through all components of `system`
for element ∈ elements
Expand Down
Loading
Loading