From f1ce98f1aa2a3dbbf91f2854c1e7cd78ffaf0369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Vegard=20Ven=C3=A5s?= Date: Thu, 7 Aug 2025 15:12:28 +0200 Subject: [PATCH 1/2] For fields of elements of Dict type with keys of Resource type, only require description of the super-field (and set the resource in parantheses) --- src/utils_GUI/GUI_utils.jl | 7 +++--- src/utils_GUI/results_axis_utils.jl | 36 ++++++++++++++++++----------- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/src/utils_GUI/GUI_utils.jl b/src/utils_GUI/GUI_utils.jl index 2a8720d..c8d84ca 100644 --- a/src/utils_GUI/GUI_utils.jl +++ b/src/utils_GUI/GUI_utils.jl @@ -403,7 +403,8 @@ function initialize_available_data!(gui) structure = String(nameof(typeof(element))) name = "$field_name" key_str = "structures.$structure.$name" - add_description!(field, name, key_str, "", element, available_data, gui) + selection = Vector{Any}([element]) + add_description!(field, name, key_str, "", selection, available_data, gui) end append!(get_available_data(gui)[element], available_data) end @@ -539,10 +540,10 @@ function update_descriptive_names!(gui::GUI) # Search through EMX packages if icons are available there for package ∈ emx_packages - package_path::Union{String,Nothing} = Base.find_package(package) + package_path::Union{String,Nothing} = dirname(dirname(Base.find_package(package))) if !isnothing(package_path) path_to_descriptive_names_ext = joinpath( - package_path, "..", "..", "ext", "EMGUIExt", "descriptive_names.yml", + package_path, "ext", "EMGUIExt", "descriptive_names.yml", ) if isfile(path_to_descriptive_names_ext) descriptive_names_dict_ext_file = YAML.load_file( diff --git a/src/utils_GUI/results_axis_utils.jl b/src/utils_GUI/results_axis_utils.jl index 3e6bac3..c640e39 100644 --- a/src/utils_GUI/results_axis_utils.jl +++ b/src/utils_GUI/results_axis_utils.jl @@ -27,7 +27,7 @@ end name::String, key_str::String, pre_desc::String, - element, + selection::Vector, available_data::Vector{Dict}, gui::GUI, ) @@ -39,14 +39,14 @@ function add_description!( name::String, key_str::String, pre_desc::String, - element, + selection::Vector, available_data::Vector{Dict}, gui::GUI, ) container = Dict( :name => name, :is_jump_data => false, - :selection => [element], + :selection => selection, :field_data => field, :description => create_description(gui, key_str; pre_desc), ) @@ -59,7 +59,7 @@ end name::String, key_str::String, pre_desc::String, - element, + selection::Vector, available_data::Vector{Dict}, gui::GUI, ) @@ -72,15 +72,23 @@ function add_description!( name::String, key_str::String, pre_desc::String, - element, + selection::Vector, available_data::Vector{Dict}, gui::GUI, ) for (dictname, dictvalue) ∈ field - name_field = "$name.$dictname" - key_str_field = "$key_str.$dictname" + name_field = "$name" + key_str_field = "$key_str" + ext_selection = deepcopy(selection) + if isa(dictname, Resource) + push!(ext_selection, dictname) + else + name_field *= ".$dictname" + key_str_field *= ".$dictname" + end add_description!( - dictvalue, name_field, key_str_field, pre_desc, element, available_data, gui, + dictvalue, name_field, key_str_field, pre_desc, ext_selection, available_data, + gui, ) end end @@ -91,7 +99,7 @@ end name::String, key_str::String, pre_desc::String, - element, + selection::Vector, available_data::Vector{Dict}, gui::GUI, ) @@ -104,7 +112,7 @@ function add_description!( name::String, key_str::String, pre_desc::String, - element, + selection::Vector, available_data::Vector{Dict}, gui::GUI, ) @@ -113,7 +121,7 @@ function add_description!( name_field = "$name.$data_type" key_str_field = "$key_str.$data_type" add_description!( - data, name_field, key_str_field, pre_desc, element, available_data, gui, + data, name_field, key_str_field, pre_desc, selection, available_data, gui, ) end end @@ -137,7 +145,7 @@ function add_description!( name::String, key_str::String, pre_desc::String, - element, + selection::Vector, available_data::Vector{Dict}, gui::GUI, ) @@ -153,7 +161,7 @@ function add_description!( pre_desc_sub = "$pre_desc$name_field_type: " key_str = "structures.$name_field_type.$sub_field_name" add_description!( - sub_field, name_field, key_str, pre_desc_sub, element, available_data, gui, + sub_field, name_field, key_str, pre_desc_sub, selection, available_data, gui, ) end end @@ -305,7 +313,7 @@ function create_label(selection::Dict{Symbol,Any}) label *= selection[:name] end otherRes::Bool = false - if length(selection) > 1 + if length(selection[:selection]) > 1 for select ∈ selection[:selection] if isa(select, Resource) if !otherRes From 73313f0fd3023d27b747fdc196ab896a01b9279e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20Vegard=20Ven=C3=A5s?= Date: Mon, 11 Aug 2025 12:18:36 +0200 Subject: [PATCH 2/2] Fix mistake --- src/utils_GUI/results_axis_utils.jl | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/utils_GUI/results_axis_utils.jl b/src/utils_GUI/results_axis_utils.jl index c640e39..30bf80b 100644 --- a/src/utils_GUI/results_axis_utils.jl +++ b/src/utils_GUI/results_axis_utils.jl @@ -313,22 +313,20 @@ function create_label(selection::Dict{Symbol,Any}) label *= selection[:name] end otherRes::Bool = false - if length(selection[:selection]) > 1 - for select ∈ selection[:selection] - if isa(select, Resource) - if !otherRes - label *= " (" - otherRes = true - end - label *= "$(select)" - if select != selection[:selection][end] - label *= ", " - end + for select ∈ selection[:selection] + if isa(select, Resource) + if !otherRes + label *= " (" + otherRes = true + end + label *= "$(select)" + if select != selection[:selection][end] + label *= ", " end end - if otherRes - label *= ")" - end + end + if otherRes + label *= ")" end return label end