rip it out
This commit is contained in:
parent
e7f1803412
commit
91eacd21a7
@ -268,7 +268,6 @@ function _precompile_()
|
|||||||
Base.precompile(Tuple{typeof(bbox),Float64,Float64,Float64,Float64})
|
Base.precompile(Tuple{typeof(bbox),Float64,Float64,Float64,Float64})
|
||||||
Base.precompile(Tuple{typeof(build_layout),GridLayout,Int64,Vector{Plot}})
|
Base.precompile(Tuple{typeof(build_layout),GridLayout,Int64,Vector{Plot}})
|
||||||
Base.precompile(Tuple{typeof(convert_to_polar),StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}},Vector{Float64},Tuple{Int64, Float64}})
|
Base.precompile(Tuple{typeof(convert_to_polar),StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}},Vector{Float64},Tuple{Int64, Float64}})
|
||||||
Base.precompile(Tuple{typeof(create_grid),Expr})
|
|
||||||
Base.precompile(Tuple{typeof(error_coords),Vector{Float64},Vector{Float64},Vector{Float64},Vararg{Vector{Float64}, N} where N})
|
Base.precompile(Tuple{typeof(error_coords),Vector{Float64},Vector{Float64},Vector{Float64},Vararg{Vector{Float64}, N} where N})
|
||||||
Base.precompile(Tuple{typeof(error_coords),Vector{Float64},Vector{Float64},Vector{Float64}})
|
Base.precompile(Tuple{typeof(error_coords),Vector{Float64},Vector{Float64},Vector{Float64}})
|
||||||
Base.precompile(Tuple{typeof(error_zipit),Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}}})
|
Base.precompile(Tuple{typeof(error_zipit),Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}}})
|
||||||
|
|||||||
@ -25,7 +25,7 @@ using SparseArrays
|
|||||||
using FFMPEG
|
using FFMPEG
|
||||||
|
|
||||||
@reexport using RecipesBase
|
@reexport using RecipesBase
|
||||||
import RecipesBase: plot, plot!, animate, is_explicit
|
import RecipesBase: plot, plot!, animate, is_explicit, grid
|
||||||
using Base.Meta
|
using Base.Meta
|
||||||
@reexport using PlotUtils
|
@reexport using PlotUtils
|
||||||
@reexport using PlotThemes
|
@reexport using PlotThemes
|
||||||
@ -42,7 +42,6 @@ export
|
|||||||
grid,
|
grid,
|
||||||
bbox,
|
bbox,
|
||||||
plotarea,
|
plotarea,
|
||||||
@layout,
|
|
||||||
KW,
|
KW,
|
||||||
|
|
||||||
wrap,
|
wrap,
|
||||||
|
|||||||
131
src/layouts.jl
131
src/layouts.jl
@ -578,137 +578,6 @@ function build_layout(layout::GridLayout, n::Integer, plts::AVec{Plot})
|
|||||||
layout, subplots, spmap
|
layout, subplots, spmap
|
||||||
end
|
end
|
||||||
|
|
||||||
# ----------------------------------------------------------------------
|
|
||||||
# @layout macro
|
|
||||||
|
|
||||||
function add_layout_pct!(kw::AKW, v::Expr, idx::Integer, nidx::Integer)
|
|
||||||
# dump(v)
|
|
||||||
# something like {0.2w}?
|
|
||||||
if v.head == :call && v.args[1] == :*
|
|
||||||
num = v.args[2]
|
|
||||||
if length(v.args) == 3 && isa(num, Number)
|
|
||||||
units = v.args[3]
|
|
||||||
if units == :h
|
|
||||||
return kw[:h] = num * pct
|
|
||||||
elseif units == :w
|
|
||||||
return kw[:w] = num * pct
|
|
||||||
elseif units in (:pct, :px, :mm, :cm, :inch)
|
|
||||||
idx == 1 && (kw[:w] = v)
|
|
||||||
(idx == 2 || nidx == 1) && (kw[:h] = v)
|
|
||||||
# return kw[idx == 1 ? :w : :h] = v
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
error("Couldn't match layout curly (idx=$idx): $v")
|
|
||||||
end
|
|
||||||
|
|
||||||
function add_layout_pct!(kw::AKW, v::Number, idx::Integer)
|
|
||||||
# kw[idx == 1 ? :w : :h] = v*pct
|
|
||||||
idx == 1 && (kw[:w] = v * pct)
|
|
||||||
(idx == 2 || nidx == 1) && (kw[:h] = v * pct)
|
|
||||||
end
|
|
||||||
|
|
||||||
isrow(v) = isa(v, Expr) && v.head in (:hcat, :row)
|
|
||||||
iscol(v) = isa(v, Expr) && v.head == :vcat
|
|
||||||
rowsize(v) = isrow(v) ? length(v.args) : 1
|
|
||||||
|
|
||||||
function create_grid(expr::Expr)
|
|
||||||
if iscol(expr)
|
|
||||||
create_grid_vcat(expr)
|
|
||||||
elseif isrow(expr)
|
|
||||||
:(
|
|
||||||
let cell = Matrix(undef, 1, $(length(expr.args)))
|
|
||||||
$(
|
|
||||||
[
|
|
||||||
:(cell[1, $i] = $(create_grid(v))) for
|
|
||||||
(i, v) in enumerate(expr.args)
|
|
||||||
]...
|
|
||||||
)
|
|
||||||
cell
|
|
||||||
end
|
|
||||||
)
|
|
||||||
|
|
||||||
elseif expr.head == :curly
|
|
||||||
create_grid_curly(expr)
|
|
||||||
else
|
|
||||||
# if it's something else, just return that (might be an existing layout?)
|
|
||||||
esc(expr)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function create_grid_vcat(expr::Expr)
|
|
||||||
rowsizes = map(rowsize, expr.args)
|
|
||||||
rmin, rmax = extrema(rowsizes)
|
|
||||||
if rmin > 0 && rmin == rmax
|
|
||||||
# we have a grid... build the whole thing
|
|
||||||
# note: rmin is the number of columns
|
|
||||||
nr = length(expr.args)
|
|
||||||
nc = rmin
|
|
||||||
body = Expr(:block)
|
|
||||||
for r in 1:nr
|
|
||||||
arg = expr.args[r]
|
|
||||||
if isrow(arg)
|
|
||||||
for (c, item) in enumerate(arg.args)
|
|
||||||
push!(body.args, :(cell[$r, $c] = $(create_grid(item))))
|
|
||||||
end
|
|
||||||
else
|
|
||||||
push!(body.args, :(cell[$r, 1] = $(create_grid(arg))))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
:(
|
|
||||||
let cell = Matrix(undef, $nr, $nc)
|
|
||||||
$body
|
|
||||||
cell
|
|
||||||
end
|
|
||||||
)
|
|
||||||
else
|
|
||||||
# otherwise just build one row at a time
|
|
||||||
:(
|
|
||||||
let cell = Matrix(undef, $(length(expr.args)), 1)
|
|
||||||
$(
|
|
||||||
[
|
|
||||||
:(cell[$i, 1] = $(create_grid(v))) for
|
|
||||||
(i, v) in enumerate(expr.args)
|
|
||||||
]...
|
|
||||||
)
|
|
||||||
cell
|
|
||||||
end
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function create_grid_curly(expr::Expr)
|
|
||||||
kw = KW()
|
|
||||||
for (i, arg) in enumerate(expr.args[2:end])
|
|
||||||
add_layout_pct!(kw, arg, i, length(expr.args) - 1)
|
|
||||||
end
|
|
||||||
s = expr.args[1]
|
|
||||||
if isa(s, Expr) && s.head == :call && s.args[1] == :grid
|
|
||||||
create_grid(
|
|
||||||
:(grid(
|
|
||||||
$(s.args[2:end]...),
|
|
||||||
width = $(get(kw, :w, QuoteNode(:auto))),
|
|
||||||
height = $(get(kw, :h, QuoteNode(:auto))),
|
|
||||||
)),
|
|
||||||
)
|
|
||||||
elseif isa(s, Symbol)
|
|
||||||
:((
|
|
||||||
label = $(QuoteNode(s)),
|
|
||||||
width = $(get(kw, :w, QuoteNode(:auto))),
|
|
||||||
height = $(get(kw, :h, QuoteNode(:auto))),
|
|
||||||
))
|
|
||||||
else
|
|
||||||
error("Unknown use of curly brackets: $expr")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function create_grid(s::Symbol)
|
|
||||||
:((label = $(QuoteNode(s)), blank = $(s == :_)))
|
|
||||||
end
|
|
||||||
|
|
||||||
macro layout(mat::Expr)
|
|
||||||
create_grid(mat)
|
|
||||||
end
|
|
||||||
|
|
||||||
# -------------------------------------------------------------------------
|
# -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user