working on immerse
This commit is contained in:
parent
2207ae6617
commit
e6c8344970
@ -41,6 +41,7 @@ PLOT_DEFAULTS[:xticks] = true
|
||||
PLOT_DEFAULTS[:yticks] = true
|
||||
PLOT_DEFAULTS[:size] = (600,400)
|
||||
PLOT_DEFAULTS[:windowtitle] = "Plots.jl"
|
||||
PLOT_DEFAULTS[:show] = true
|
||||
|
||||
PLOT_DEFAULTS[:args] = [] # additional args to pass to the backend
|
||||
PLOT_DEFAULTS[:kwargs] = [] # additional keyword args to pass to the backend
|
||||
|
||||
@ -6,6 +6,13 @@ immutable ImmersePackage <: PlottingPackage end
|
||||
immerse!() = plotter!(:immerse)
|
||||
|
||||
|
||||
function createImmerseFigure(d::Dict)
|
||||
# d[:show] || return # return nothing when we're not showing
|
||||
w,h = d[:size]
|
||||
figidx = Immerse.figure(; name = d[:windowtitle], width = w, height = h)
|
||||
Immerse.Figure(figidx)
|
||||
end
|
||||
|
||||
|
||||
# create a blank Gadfly.Plot object
|
||||
function plot(pkg::ImmersePackage; kw...)
|
||||
@ -14,10 +21,16 @@ function plot(pkg::ImmersePackage; kw...)
|
||||
# create the underlying Gadfly.Plot object
|
||||
gplt = createGadflyPlotObject(d)
|
||||
|
||||
# create the figure. Immerse just returns the index of the Figure in the GadflyDisplay... call Figure(figidx) to get the object
|
||||
w,h = d[:size]
|
||||
figidx = Immerse.figure(; name = d[:windowtitle], width = w, height = h)
|
||||
fig = Immerse.Figure(figidx)
|
||||
# create the figure (or not). Immerse just returns the index of the Figure in the GadflyDisplay... call Figure(figidx) to get the object
|
||||
fig = d[:show] ? createImmerseFigure(d) : nothing
|
||||
# if d[:show]
|
||||
# # w,h = d[:size]
|
||||
# # figidx = Immerse.figure(; name = d[:windowtitle], width = w, height = h)
|
||||
# # fig = Immerse.Figure(figidx)
|
||||
# fig = createImmerseFigure(d)
|
||||
# else
|
||||
# fig = nothing
|
||||
# end
|
||||
|
||||
# save both the Immerse.Figure and the Gadfly.Plot
|
||||
Plot((fig,gplt), pkg, 0, d, Dict[])
|
||||
@ -27,13 +40,20 @@ end
|
||||
# plot one data series
|
||||
function plot!(::ImmersePackage, plt::Plot; kw...)
|
||||
d = Dict(kw)
|
||||
addGadflySeries!(plt.o[2], d)
|
||||
gplt = plt.o[2]
|
||||
addGadflySeries!(gplt, d)
|
||||
push!(plt.seriesargs, d)
|
||||
plt
|
||||
end
|
||||
|
||||
function Base.display(::ImmersePackage, plt::Plot)
|
||||
display(plt.o[2])
|
||||
println("disp1")
|
||||
fig, gplt = plt.o
|
||||
if fig == nothing
|
||||
fig = createImmerseFigure(plt.initargs)
|
||||
end
|
||||
newfig = Immerse.Figure(fig.canvas, gplt)
|
||||
display(newfig)
|
||||
end
|
||||
|
||||
# -------------------------------
|
||||
@ -41,7 +61,8 @@ end
|
||||
function savepng(::ImmersePackage, plt::PlottingObject, fn::String;
|
||||
w = 6 * Immerse.inch,
|
||||
h = 4 * Immerse.inch)
|
||||
Immerse.draw(Immerse.PNG(fn, w, h), plt.o)
|
||||
gctx = plt.o[2]
|
||||
Gadfly.draw(Gadfly.PNG(fn, w, h), gctx)
|
||||
end
|
||||
|
||||
|
||||
@ -57,12 +78,22 @@ function buildSubplotObject!(::ImmersePackage, subplt::Subplot)
|
||||
end
|
||||
gctx = Gadfly.vstack(rows...)
|
||||
|
||||
figidx = Immerse.figure()
|
||||
fig = Immerse.Figure(figidx)
|
||||
(fig, gctx)
|
||||
fig = subplt.initargs[:show] ? createImmerseFigure(subplt.initargs) : nothing
|
||||
# fig = createImmerseFigure(subplt.initargs)
|
||||
|
||||
subplt.o = (fig, gctx)
|
||||
end
|
||||
|
||||
|
||||
function Base.display(::ImmersePackage, subplt::Subplot)
|
||||
display(subplt.o[2])
|
||||
println("disp2")
|
||||
# display(subplt.o[1])
|
||||
fig, gctx = subplt.o
|
||||
if fig == nothing
|
||||
fig = createImmerseFigure(subplt.initargs)
|
||||
end
|
||||
# newfig = Immerse.Figure(fig.canvas, gctx)
|
||||
fig.cc = gctx
|
||||
# error(fig)
|
||||
display(fig)
|
||||
end
|
||||
|
||||
@ -71,11 +71,14 @@ function subplot(args...; kw...)
|
||||
|
||||
# initialize the individual plots
|
||||
pkg = plotter()
|
||||
kw0 = getPlotKeywordArgs(kw, 1, 0)
|
||||
plts = Plot[plot(pkg; kw0..., show=false) for i in 1:length(layout)]
|
||||
tmpd = getPlotKeywordArgs(kw, 1, 0)
|
||||
shouldShow = tmpd[:show]
|
||||
tmpd[:show] = false
|
||||
plts = Plot[plot(pkg; tmpd...) for i in 1:length(layout)]
|
||||
tmpd[:show] = shouldShow
|
||||
|
||||
# create the object and do the plotting
|
||||
subplt = Subplot(nothing, plts, pkg, length(layout), 0, layout)
|
||||
subplt = Subplot(nothing, plts, pkg, length(layout), 0, layout, tmpd)
|
||||
subplot!(subplt, args...; kw...)
|
||||
|
||||
subplt
|
||||
@ -103,6 +106,7 @@ function subplot!(subplt::Subplot, args...; kw...)
|
||||
for (i,d) in enumerate(kwList)
|
||||
subplt.n += 1
|
||||
plt = getplot(subplt) # get the Plot object where this series will be drawn
|
||||
d[:show] = false
|
||||
plot!(plt; d...)
|
||||
end
|
||||
|
||||
@ -114,8 +118,9 @@ function subplot!(subplt::Subplot, args...; kw...)
|
||||
|
||||
# do we want to show it?
|
||||
d = Dict(kw)
|
||||
@show d
|
||||
if haskey(d, :show) && d[:show]
|
||||
draw(subplt)
|
||||
display(subplt)
|
||||
end
|
||||
|
||||
subplt
|
||||
|
||||
@ -29,4 +29,5 @@ type Subplot <: PlottingObject
|
||||
p::Int # number of plots
|
||||
n::Int # number of series
|
||||
layout::SubplotLayout
|
||||
initargs::Dict
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user