Skip to content

Commit

Permalink
- Add makie.jl to be used by Makie backends.
Browse files Browse the repository at this point in the history
- For backwards compatibilty to ModiaResult, also accept ENV["MODIA_PLOT_PACKAGE"] instead of ENV["SignalTablesPlotPackage"]
  to define plot package - at all places (some parts have been missing).
  • Loading branch information
MartinOtter committed Jul 4, 2022
1 parent 5f3b5b6 commit 514af2e
Show file tree
Hide file tree
Showing 6 changed files with 402 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "SignalTables"
uuid = "3201582d-3078-4276-ba5d-0a1254d79d7c"
authors = ["[email protected] <[email protected]>"]
version = "0.3.1"
version = "0.3.2"

[deps]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Expand Down
7 changes: 7 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,13 @@ are different to the Python 2.x version.

## Release Notes

### version 0.3.2

- Add makie.jl to be used by Makie backends.
- For backwards compatibilty to ModiaResult, also accept ENV["MODIA_PLOT_PACKAGE"] instead of ENV["SignalTablesPlotPackage"]
to define plot package - at all places (some parts have been missing).


### Version 0.3.1

- writeSignalTable(..): Do not store elements, that cannot be mapped to JSON + add _classVersion to signal table on file.
Expand Down
52 changes: 37 additions & 15 deletions src/PlotPackageDefinition.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ macro usingPlotPackage()
println("$expr")
return esc( :(using $PlotPackage) )
end

else
@info "No plot package activated. Using \"SilentNoPlot\"."
@goto USE_NO_PLOT
Expand Down Expand Up @@ -91,23 +91,47 @@ end
function usePlotPackage(plotPackage::String; pushPreviousOnStack=true)::Bool
success = true
if plotPackage == "NoPlot" || plotPackage == "SilentNoPlot"
if pushPreviousOnStack && haskey(ENV, "SignalTablesPlotPackage")
push!(PlotPackagesStack, ENV["SignalTablesPlotPackage"])
newPlot = true
if pushPreviousOnStack
if haskey(ENV, "SignalTablesPlotPackage")
push!(PlotPackagesStack, ENV["SignalTablesPlotPackage"])
elseif haskey(ENV, "MODIA_PLOT_PACKAGE")
push!(PlotPackagesStack, ENV["MODIA_PLOT_PACKAGE"])
newPlot=false
end
end
if plotPackage == "NoPlot"
ENV["SignalTablesPlotPackage"] = "NoPlot"
if newPlot
ENV["SignalTablesPlotPackage"] = "NoPlot"
else
ENV["MODIA_PLOT_PACKAGE"] = "NoPlot"
end
else
ENV["SignalTablesPlotPackage"] = "SilentNoPlot"
if newPlot
ENV["SignalTablesPlotPackage"] = "SilentNoPlot"
else
ENV["MODIA_PLOT_PACKAGE"] = "SilentNoPlot"
end
end
else
plotPackageName = "SignalTablesInterface_" * plotPackage
if plotPackage in AvailablePlotPackages
# Check that plotPackage is defined in current environment
if isinstalled(plotPackageName)
if pushPreviousOnStack && haskey(ENV, "SignalTablesPlotPackage")
push!(PlotPackagesStack, ENV["SignalTablesPlotPackage"])
newPlot = true
if pushPreviousOnStack
if haskey(ENV, "SignalTablesPlotPackage")
push!(PlotPackagesStack, ENV["SignalTablesPlotPackage"])
elseif haskey(ENV, "MODIA_PLOT_PACKAGE")
push!(PlotPackagesStack, ENV["MODIA_PLOT_PACKAGE"])
newPlot=false
end
end
if newPlot
ENV["SignalTablesPlotPackage"] = plotPackage
else
ENV["MODIA_PLOT_PACKAGE"] = plotPackage
end
ENV["SignalTablesPlotPackage"] = plotPackage
else
@warn "... usePlotPackage(\"$plotPackage\"): Call ignored, since package $plotPackageName is not in your current environment"
success = false
Expand All @@ -132,9 +156,9 @@ function usePreviousPlotPackage()::Bool
if length(PlotPackagesStack) > 0
plotPackage = pop!(PlotPackagesStack)
success = usePlotPackage(plotPackage, pushPreviousOnStack=false)
else
@warn "usePreviousPlotPackage(): Call ignored, because nothing saved."
success = false
#else
# @warn "usePreviousPlotPackage(): Call ignored, because nothing saved."
# success = false
end
return success
end
Expand All @@ -148,7 +172,5 @@ defined with [`usePlotPackage`](@ref).
For example, the function may return "GLMakie", "PyPlot" or "NoPlot" or
or "", if no PlotPackage is defined.
"""
currentPlotPackage() = haskey(ENV, "SignalTablesPlotPackage") ? ENV["SignalTablesPlotPackage"] : ""



currentPlotPackage() = haskey(ENV, "SignalTablesPlotPackage") ? ENV["SignalTablesPlotPackage"] :
(haskey(ENV, "MODIA_PLOT_PACKAGE") ? ENV["MODIA_PLOT_PACKAGE"] : "" )
2 changes: 1 addition & 1 deletion src/SignalTableFunctions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ the corresponding signals are encoded.
function encodeSignalTable(signalTable; signalNames=nothing)
if isSignalTable(signalTable)
jdict = OrderedDict{String,Any}("_class" => "SignalTable",
"_classVersion" => version)
"_classVersion" => version_SignalTable_JSON)
if isnothing(signalNames)
signalNames = getSignalNames(signalTable)
end
Expand Down
3 changes: 2 additions & 1 deletion src/SignalTables.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module SignalTables

const path = dirname(dirname(@__FILE__))
const version = "0.3.1" # version tag of SignalTables release without "v"
const version = "0.3.2"
const version_SignalTable_JSON = "0.3.1" # version tag to be stored in JSON files

using OrderedCollections
using Unitful
Expand Down
Loading

0 comments on commit 514af2e

Please sign in to comment.