working on immerse
This commit is contained in:
parent
a33f5fabd1
commit
51e38c80d8
@ -7,7 +7,6 @@ immerse!() = plotter!(:immerse)
|
|||||||
|
|
||||||
|
|
||||||
function createImmerseFigure(d::Dict)
|
function createImmerseFigure(d::Dict)
|
||||||
# d[:show] || return # return nothing when we're not showing
|
|
||||||
println("Creating immerse figure: ", d)
|
println("Creating immerse figure: ", d)
|
||||||
w,h = d[:size]
|
w,h = d[:size]
|
||||||
figidx = Immerse.figure(; name = d[:windowtitle], width = w, height = h)
|
figidx = Immerse.figure(; name = d[:windowtitle], width = w, height = h)
|
||||||
@ -22,21 +21,8 @@ function plot(pkg::ImmersePackage; kw...)
|
|||||||
# create the underlying Gadfly.Plot object
|
# create the underlying Gadfly.Plot object
|
||||||
gplt = createGadflyPlotObject(d)
|
gplt = createGadflyPlotObject(d)
|
||||||
|
|
||||||
# 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
|
|
||||||
fig = 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
|
# save both the Immerse.Figure and the Gadfly.Plot
|
||||||
Plot((fig,gplt), pkg, 0, d, Dict[])
|
Plot((nothing,gplt), pkg, 0, d, Dict[])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -51,13 +37,15 @@ end
|
|||||||
|
|
||||||
function Base.display(::ImmersePackage, plt::Plot)
|
function Base.display(::ImmersePackage, plt::Plot)
|
||||||
println("disp1")
|
println("disp1")
|
||||||
|
|
||||||
fig, gplt = plt.o
|
fig, gplt = plt.o
|
||||||
if fig == nothing
|
if fig == nothing
|
||||||
fig = createImmerseFigure(plt.initargs)
|
fig = createImmerseFigure(plt.initargs)
|
||||||
plt.o = (fig, gplt)
|
plt.o = (fig, gplt)
|
||||||
end
|
end
|
||||||
newfig = Immerse.Figure(fig.canvas, gplt)
|
|
||||||
display(newfig)
|
# display a new Figure object to force a redraw
|
||||||
|
display(Immerse.Figure(fig.canvas, gplt))
|
||||||
end
|
end
|
||||||
|
|
||||||
# -------------------------------
|
# -------------------------------
|
||||||
@ -67,13 +55,16 @@ function savepng(::ImmersePackage, plt::PlottingObject, fn::String;
|
|||||||
h = 4 * Immerse.inch)
|
h = 4 * Immerse.inch)
|
||||||
gctx = plt.o[2]
|
gctx = plt.o[2]
|
||||||
Gadfly.draw(Gadfly.PNG(fn, w, h), gctx)
|
Gadfly.draw(Gadfly.PNG(fn, w, h), gctx)
|
||||||
|
nothing
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# -------------------------------
|
# -------------------------------
|
||||||
|
|
||||||
# create the underlying object (each backend will do this differently)
|
# create the underlying object
|
||||||
function buildSubplotObject!(::ImmersePackage, subplt::Subplot)
|
function buildSubplotObject!(::ImmersePackage, subplt::Subplot)
|
||||||
|
|
||||||
|
# create my Compose.Context grid by hstacking and vstacking the Gadfly.Plot objects
|
||||||
i = 0
|
i = 0
|
||||||
rows = []
|
rows = []
|
||||||
for rowcnt in subplt.layout.rowcounts
|
for rowcnt in subplt.layout.rowcounts
|
||||||
@ -82,11 +73,8 @@ function buildSubplotObject!(::ImmersePackage, subplt::Subplot)
|
|||||||
end
|
end
|
||||||
gctx = Gadfly.vstack(rows...)
|
gctx = Gadfly.vstack(rows...)
|
||||||
|
|
||||||
# fig = subplt.initargs[:show] ? createImmerseFigure(subplt.initargs) : nothing
|
# save this for later
|
||||||
fig = nothing
|
subplt.o = (nothing, gctx)
|
||||||
# fig = createImmerseFigure(subplt.initargs)
|
|
||||||
|
|
||||||
subplt.o = (fig, gctx)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -99,14 +87,16 @@ function Base.display(::ImmersePackage, subplt::Subplot)
|
|||||||
subplt.o = (fig, gctx)
|
subplt.o = (fig, gctx)
|
||||||
end
|
end
|
||||||
|
|
||||||
fig.prepped = Gadfly.render_prepare(gctx)
|
# fig.prepped = Gadfly.render_prepare(gctx)
|
||||||
# Render in the current state
|
# # Render in the current state
|
||||||
fig.cc = render_finish(fig.prepped; dynamic=false)
|
# fig.cc = render_finish(fig.prepped; dynamic=false)
|
||||||
# Render the figure
|
# # Render the figure
|
||||||
display(fig.canvas, fig)
|
# display(fig.canvas, fig)
|
||||||
|
|
||||||
# fig.cc = gctx
|
fig.cc = gctx
|
||||||
# fig.prepped = nothing
|
# fig.prepped = nothing
|
||||||
|
|
||||||
# display(fig)
|
# display(fig.canvas, display(gctx))
|
||||||
|
|
||||||
|
display(fig)
|
||||||
end
|
end
|
||||||
|
|||||||
@ -87,6 +87,7 @@ function plotter()
|
|||||||
if currentPackageSymbol == :qwt
|
if currentPackageSymbol == :qwt
|
||||||
try
|
try
|
||||||
@eval import Qwt
|
@eval import Qwt
|
||||||
|
@eval export Qwt
|
||||||
catch
|
catch
|
||||||
error("Couldn't import Qwt. Install it with: Pkg.clone(\"https://github.com/tbreloff/Qwt.jl.git\")\n (Note: also requires pyqt and pyqwt)")
|
error("Couldn't import Qwt. Install it with: Pkg.clone(\"https://github.com/tbreloff/Qwt.jl.git\")\n (Note: also requires pyqt and pyqwt)")
|
||||||
end
|
end
|
||||||
@ -94,6 +95,7 @@ function plotter()
|
|||||||
elseif currentPackageSymbol == :gadfly
|
elseif currentPackageSymbol == :gadfly
|
||||||
try
|
try
|
||||||
@eval import Gadfly
|
@eval import Gadfly
|
||||||
|
@eval export Gadfly
|
||||||
catch
|
catch
|
||||||
error("Couldn't import Gadfly. Install it with: Pkg.add(\"Gadfly\")")
|
error("Couldn't import Gadfly. Install it with: Pkg.add(\"Gadfly\")")
|
||||||
end
|
end
|
||||||
@ -101,6 +103,7 @@ function plotter()
|
|||||||
elseif currentPackageSymbol == :unicodeplots
|
elseif currentPackageSymbol == :unicodeplots
|
||||||
try
|
try
|
||||||
@eval import UnicodePlots
|
@eval import UnicodePlots
|
||||||
|
@eval export UnicodePlots
|
||||||
catch
|
catch
|
||||||
error("Couldn't import UnicodePlots. Install it with: Pkg.add(\"UnicodePlots\")")
|
error("Couldn't import UnicodePlots. Install it with: Pkg.add(\"UnicodePlots\")")
|
||||||
end
|
end
|
||||||
@ -108,14 +111,15 @@ function plotter()
|
|||||||
elseif currentPackageSymbol == :pyplot
|
elseif currentPackageSymbol == :pyplot
|
||||||
try
|
try
|
||||||
@eval import PyPlot
|
@eval import PyPlot
|
||||||
|
@eval export PyPlot
|
||||||
catch
|
catch
|
||||||
error("Couldn't import PyPlot. Install it with: Pkg.add(\"PyPlot\")")
|
error("Couldn't import PyPlot. Install it with: Pkg.add(\"PyPlot\")")
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif currentPackageSymbol == :immerse
|
elseif currentPackageSymbol == :immerse
|
||||||
try
|
try
|
||||||
@eval import Immerse
|
@eval import Immerse, Gadfly
|
||||||
@eval import Gadfly
|
@eval export Immerse, Gadfly
|
||||||
catch
|
catch
|
||||||
error("Couldn't import Immerse. Install it with: Pkg.add(\"Immerse\")")
|
error("Couldn't import Immerse. Install it with: Pkg.add(\"Immerse\")")
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user