From b80ba991003d76e1abdfeab7b77268c2ff7f54cc Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Sun, 26 Apr 2020 20:49:02 +0200 Subject: [PATCH] move remaining const to backends.jl --- src/backends.jl | 20 ++++++++++++++++++++ src/backends/hdf5.jl | 18 ------------------ src/backends/pgfplotsx.jl | 2 -- src/backends/unicodeplots.jl | 14 ++++++-------- 4 files changed, 26 insertions(+), 28 deletions(-) diff --git a/src/backends.jl b/src/backends.jl index 35b0853a..078468f6 100644 --- a/src/backends.jl +++ b/src/backends.jl @@ -568,6 +568,9 @@ const _unicodeplots_style = [:auto, :solid] const _unicodeplots_marker = [:none, :auto, :circle] const _unicodeplots_scale = [:identity] +# Additional constants +const _canvas_type = Ref(:auto) + # ------------------------------------------------------------------------------ # hdf5 @@ -612,6 +615,20 @@ const _hdf5_style = [:auto, :solid, :dash, :dot, :dashdot] const _hdf5_marker = vcat(_allMarkers, :pixel) const _hdf5_scale = [:identity, :ln, :log2, :log10] +# Additional constants +#Dict has problems using "Types" as keys. Initialize in "_initialize_backend": +const HDF5PLOT_MAP_STR2TELEM = Dict{String, Type}() +const HDF5PLOT_MAP_TELEM2STR = Dict{Type, String}() + +#Don't really like this global variable... Very hacky +const HDF5PLOT_PLOTREF = HDF5Plot_PlotRef(nothing) + +#Simple sub-structures that can just be written out using _hdf5plot_gwritefields: +const HDF5PLOT_SIMPLESUBSTRUCT = Union{Font, BoundingBox, + GridLayout, RootLayout, ColorGradient, SeriesAnnotations, PlotText, + Shape, +} + # ------------------------------------------------------------------------------ # inspectdr @@ -800,3 +817,6 @@ const _pgfplotsx_marker = [ ] const _pgfplotsx_scale = [:identity, :ln, :log2, :log10] is_marker_supported(::PGFPlotsXBackend, shape::Shape) = true + +# additional constants +const _pgfplotsx_series_ids = KW() diff --git a/src/backends/hdf5.jl b/src/backends/hdf5.jl index e967a143..327d11c5 100644 --- a/src/backends/hdf5.jl +++ b/src/backends/hdf5.jl @@ -41,24 +41,6 @@ mutable struct HDF5Plot_PlotRef ref::Union{Plot, Nothing} end - -#==Useful constants -===============================================================================# - -#Dict has problems using "Types" as keys. Initialize in "_initialize_backend": -const HDF5PLOT_MAP_STR2TELEM = Dict{String, Type}() -const HDF5PLOT_MAP_TELEM2STR = Dict{Type, String}() - -#Don't really like this global variable... Very hacky -const HDF5PLOT_PLOTREF = HDF5Plot_PlotRef(nothing) - -#Simple sub-structures that can just be written out using _hdf5plot_gwritefields: -const HDF5PLOT_SIMPLESUBSTRUCT = Union{Font, BoundingBox, - GridLayout, RootLayout, ColorGradient, SeriesAnnotations, PlotText, - Shape, -} - - #== ===============================================================================# is_marker_supported(::HDF5Backend, shape::Shape) = true diff --git a/src/backends/pgfplotsx.jl b/src/backends/pgfplotsx.jl index 629655f1..55a2d376 100644 --- a/src/backends/pgfplotsx.jl +++ b/src/backends/pgfplotsx.jl @@ -605,8 +605,6 @@ pgfx_get_linestyle(k) = get( "solid", ) -const _pgfplotsx_series_ids = KW() - pgfx_get_marker(k) = get( ( none = "none", diff --git a/src/backends/unicodeplots.jl b/src/backends/unicodeplots.jl index a66e8d56..f0042436 100644 --- a/src/backends/unicodeplots.jl +++ b/src/backends/unicodeplots.jl @@ -7,15 +7,13 @@ warn_on_unsupported_args(::UnicodePlotsBackend, plotattributes::KW) = nothing # -------------------------------------------------------------------------------------- -const _canvas_type = Ref(:auto) - function _canvas_map() - KW( - :braille => UnicodePlots.BrailleCanvas, - :ascii => UnicodePlots.AsciiCanvas, - :block => UnicodePlots.BlockCanvas, - :dot => UnicodePlots.DotCanvas, - :density => UnicodePlots.DensityCanvas, + ( + braille = UnicodePlots.BrailleCanvas, + ascii = UnicodePlots.AsciiCanvas, + block = UnicodePlots.BlockCanvas, + dot = UnicodePlots.DotCanvas, + density = UnicodePlots.DensityCanvas, ) end