@@ -42,6 +42,10 @@ to the old EnergyModelsX `case` dictionary.
4242 hovering objects to show information.
4343- **`use_geomakie::Bool=true`** toggles the use of GeoMakie for plotting geographical
4444 designs when the `case` contains geographical information.
45+ - **`pre_plot_sub_components::Bool=true`** toggles whether or not to pre-plot all
46+ sub-components of areas in the topology design. Setting this to `false` greatly
47+ enhances performance for large cases, as the components of an `Area` are then
48+ plotted on demand (on the `open` functionality).
4549
4650!!! warning "Reading model results from CSV-files"
4751 Reading model results from a directory (*i.e.*, `model::String` implying that the results
@@ -72,6 +76,7 @@ function GUI(
7276 tol:: Float64 = 1e-8 ,
7377 enable_data_inspector:: Bool = true ,
7478 use_geomakie:: Bool = true ,
79+ pre_plot_sub_components:: Bool = true ,
7580)
7681 # Generate the system topology:
7782 @info raw " Setting up the topology design structure"
@@ -82,6 +87,11 @@ function GUI(
8287 @info raw " Setting up the GUI"
8388 design:: EnergySystemDesign = root_design # variable to store current system (inkluding sub systems)
8489
90+ if expand_all && ! pre_plot_sub_components
91+ expand_all = false
92+ @warn " Incompatible EMGUI settings: `expand_all` is set to true but " *
93+ " `pre_plot_sub_components` is set to false. Setting `expand_all` to false."
94+ end
8595 # Set variables
8696 vars:: Dict{Symbol,Any} = Dict (
8797 :title => Observable (" top_level" ),
@@ -111,6 +121,7 @@ function GUI(
111121 :colormap => colormap,
112122 :tol => tol,
113123 :use_geomakie => use_geomakie,
124+ :pre_plot_sub_components => pre_plot_sub_components,
114125 :autolimits => Dict (
115126 :results_op => true ,
116127 :results_sc => true ,
@@ -137,7 +148,7 @@ function GUI(
137148 vars[:path_to_descriptive_names ] = path_to_descriptive_names
138149 vars[:descriptive_names_dict ] = descriptive_names_dict
139150
140- vars[:plot_widths ] = plot_widths
151+ vars[:plot_widths ] = Vec {2,Int64} ( plot_widths)
141152 vars[:hide_topo_ax_decorations ] = hide_topo_ax_decorations
142153 vars[:expand_all ] = expand_all
143154
@@ -149,30 +160,42 @@ function GUI(
149160
150161 # Create iterables for plotting objects in layers (z-direction) such that nodes are
151162 # neatly placed on top of each other and lines are beneath nodes
152- vars[:z_translate_lines ] = 10.0f0
153- vars[:z_translate_components ] = 50.0f0
163+ vars[:depth_shift_lines ] = 0.006f0
164+ vars[:depth_shift_components ] = 0.002f0
154165
155166 vars[:selected_systems ] = []
156167
157168 # Default text for the text area
158- vars[:default_text ] = string (
159- " Tips:\n " ,
160- " Keyboard shortcuts:\n " ,
161- " \t ctrl+left-click: Select multiple nodes.\n " ,
162- " \t right-click and drag: to pan\n " ,
163- " \t scroll wheel: zoom in or out\n " ,
164- " \t space: Enter the selected system\n " ,
165- " \t ctrl+s: Save\n " ,
166- " \t ctrl+r: Reset view\n " ,
167- " \t ctrl+w: Close window\n " ,
168- " \t Esc (or MouseButton4): Exit the current system and into the parent system\n " ,
169- " \t holding x while scrolling over plots will zoom in/out in the x-direction.\n " ,
170- " \t holding y while scrolling over plots will zoom in/out in the y-direction.\n\n " ,
171- " Left-clicking a component will put information about this component here.\n\n " ,
172- " Clicking a plot below enables you to pin this plot (hitting the `pin\n " ,
173- " current plot` button) for comparison with other plots.\n " ,
174- " Use the `Delete` button to unpin a selected plot." ,
175- )
169+ io = IOBuffer ()
170+ println (io, " Tips:" )
171+ println (io, " Keyboard shortcuts:" )
172+ println (io, " \t ctrl+left-click: Select multiple nodes." )
173+ println (io, " \t right-click and drag: to pan" )
174+ println (io, " \t scroll wheel: zoom in or out" )
175+ println (io, " \t space: Enter the selected system" )
176+ println (io, " \t ctrl+s: Save" )
177+ println (io, " \t ctrl+r: Reset view" )
178+ println (io, " \t ctrl+w: Close window" )
179+ println (
180+ io,
181+ " \t Esc (or MouseButton4): Exit the current system and into the parent system" ,
182+ )
183+ println (
184+ io,
185+ " \t holding x while scrolling over plots will zoom in/out in the x-direction." ,
186+ )
187+ println (
188+ io,
189+ " \t holding y while scrolling over plots will zoom in/out in the y-direction.\n " ,
190+ )
191+ println (
192+ io,
193+ " Left-clicking a component will put information about this component here.\n " ,
194+ )
195+ println (io, " Clicking a plot below enables you to pin this plot (hitting the `pin" )
196+ println (io, " current plot` button) for comparison with other plots." )
197+ print (io, " Use the `Delete` button to unpin a selected plot." )
198+ vars[:default_text ] = String (take! (io))
176199 vars[:info_text ] = Observable (vars[:default_text ])
177200 vars[:summary_text ] = Observable (" No model results" )
178201 vars[:dragging ] = Ref (false )
@@ -219,7 +242,9 @@ function GUI(
219242 notify (axes[:topo ]. finallimits)
220243
221244 # make sure all graphics is adapted to the spawned figure sizes
222- notify (get_toggle (gui, :expand_all ). active)
245+ if get_var (gui, :expand_all )
246+ notify (get_toggle (gui, :expand_all ). active)
247+ end
223248
224249 # Enable inspector (such that hovering objects shows information)
225250 # Linewidth set to zero as this boundary is slightly laggy on movement
@@ -305,7 +330,6 @@ function create_makie_objects(vars::Dict, design::EnergySystemDesign)
305330
306331 # Download the file if it doesn't exist in the temporary directory
307332 if ! isfile (local_file_path)
308- @debug " Trying to download file $url to $local_file_path "
309333 HTTP. download (url, local_file_path)
310334 end
311335
@@ -323,8 +347,9 @@ function create_makie_objects(vars::Dict, design::EnergySystemDesign)
323347 strokecolor = :gray50 ,
324348 strokewidth = 0.5 ,
325349 inspectable = false ,
350+ depth_shift = 1.0f0 - 2.0f-5 ,
351+ stroke_depth_shift = 1.0f0 - 3.0f-5 ,
326352 )
327- Makie. translate! (countries_plot, 0 , 0 , - 1 )
328353 ocean_coords = [(180 , - 90 ), (- 180 , - 90 ), (- 180 , 90 ), (180 , 90 )]
329354 ocean = poly! (
330355 ax,
@@ -333,8 +358,9 @@ function create_makie_objects(vars::Dict, design::EnergySystemDesign)
333358 strokewidth = 0.5 ,
334359 strokecolor = :gray50 ,
335360 inspectable = false ,
361+ depth_shift = 1.0f0 ,
362+ stroke_depth_shift = 1.0f0 - 1.0f-5 ,
336363 )
337- Makie. translate! (ocean, 0 , 0 , - 2 )
338364 else # The design does not use the EnergyModelsGeography package: Create a simple Makie axis
339365 ax = Axis (
340366 gridlayout_topology_ax[1 , 1 ];
@@ -411,7 +437,6 @@ function create_makie_objects(vars::Dict, design::EnergySystemDesign)
411437 labelsize = vars[:fontsize ],
412438 titlesize = vars[:fontsize ],
413439 )
414- Makie. translate! (topo_legend. blockscene, 0 , 0 , vars[:z_translate_components ] + 999 )
415440
416441 # Initiate an axis for displaying information about the selected node
417442 ax_info:: Makie.Axis = Axis (
@@ -638,11 +663,6 @@ function create_makie_objects(vars::Dict, design::EnergySystemDesign)
638663 :results => nothing , :topo => topo_legend,
639664 )
640665
641- # Ensure that menus are on top
642- for menu ∈ values (menus)
643- translate! (menu. blockscene, 0.0f0 , 0.0f0 , vars[:z_translate_components ] + 2000.0f0 )
644- end
645-
646666 # Collect all toggles into a dictionary
647667 toggles:: Dict{Symbol,Makie.Toggle} = Dict (:expand_all => expand_all_toggle)
648668
@@ -652,18 +672,13 @@ function create_makie_objects(vars::Dict, design::EnergySystemDesign)
652672 )
653673
654674 # Update the title of the figure
655- topo_title_obj = text! (
675+ text! (
656676 ax,
657677 vars[:topo_title_loc_x ],
658678 vars[:topo_title_loc_y ];
659679 text = vars[:title ],
660680 fontsize = vars[:fontsize ],
661- )
662- Makie. translate! (
663- topo_title_obj,
664- 0.0f0 ,
665- 0.0f0 ,
666- vars[:z_translate_components ] + 999.0f0 ,
681+ depth_shift = - 1.0f0 ,
667682 )
668683
669684 return fig, buttons, menus, toggles, axes, legends
0 commit comments