working on Immerse subplot support

This commit is contained in:
Thomas Breloff 2015-09-15 23:27:00 -04:00
parent 9b0a645a05
commit aabf811fe7
2 changed files with 31 additions and 29 deletions

View File

@ -43,8 +43,11 @@ function Base.display(::ImmersePackage, plt::Plot)
plt.o = (fig, gplt) plt.o = (fig, gplt)
end end
# display a new Figure object to force a redraw # # display a new Figure object to force a redraw
display(Immerse.Figure(fig.canvas, gplt)) # display(Immerse.Figure(fig.canvas, gplt))
Immerse.figure(fig.figno; displayfig = false)
display(gplt)
end end
# ------------------------------- # -------------------------------
@ -66,16 +69,20 @@ end
function buildSubplotObject!(::ImmersePackage, subplt::Subplot) function buildSubplotObject!(::ImmersePackage, subplt::Subplot)
# box, tb, c = createPlotGuiComponents() # create the Gtk window with vertical box vsep
vsep = Gtk.ShortNames.@Box(:v) d = subplt.initargs
w,h = d[:size]
vsep = Gtk.GtkBoxLeaf(:v)
win = Gtk.GtkWindowLeaf(vsep, d[:windowtitle], w, h)
# now we create the GUI # add the plot boxes
i = 0 i = 0
rows = [] rows = []
figindices = []
for rowcnt in subplt.layout.rowcounts for rowcnt in subplt.layout.rowcounts
# create a new row and add it to the main Box vsep # create a new row and add it to the main Box vsep
row = Gtk.ShortNames.@Box(:h) row = Gtk.GtkBoxLeaf(:h)
push!(vsep, row) push!(vsep, row)
# now add the plot components to the row # now add the plot components to the row
@ -84,24 +91,22 @@ function buildSubplotObject!(::ImmersePackage, subplt::Subplot)
# get the components... box is the main plot GtkBox, and canvas is the GtkCanvas where it's plotted # get the components... box is the main plot GtkBox, and canvas is the GtkCanvas where it's plotted
box, toolbar, canvas = Immerse.createPlotGuiComponents() box, toolbar, canvas = Immerse.createPlotGuiComponents()
# create and save the Figure
plt.o = (figure(canvas), plt.o[2])
# add the plot's box to the row # add the plot's box to the row
push!(row, box) push!(row, box)
# create the figure and store the index returned for destruction later
figidx = Immerse.figure(canvas)
push!(figindices, figidx)
fig = Immerse.figure(figidx)
plt.o = (fig, plt.o[2])
end end
# push!(rows, Gadfly.hstack([getGadflyContext(plt.plotter, plt) for plt in subplt.plts[(1:rowcnt) + i]]...))
i += rowcnt i += rowcnt
end end
d = subplt.initargs # destructor... clean up plots
w,h = d[:size] Gtk.on_signal_destroy((x...) -> [Immerse.dropfig(_display,i) for i in figindices], win)
win = Gtk.ShortNames.@GtkWindow(vsep, d[:windowtitle], w, h)
guidata[win, :toolbar] = tb
if closecb !== nothing
Gtk.ShortNames.on_signal_destroy(closecb, win)
end
showall(win)
subplt.o = win subplt.o = win
end end
@ -115,15 +120,13 @@ end
function Base.display(::ImmersePackage, subplt::Subplot) function Base.display(::ImmersePackage, subplt::Subplot)
# fig, gctx = subplt.o # display the plots by creating a fresh Immerse.Figure object from the GtkCanvas and Gadfly.Plot
# if fig == nothing for plt in subplt.plts
# fig = createImmerseFigure(subplt.initargs) fig, gplt = plt.o
# subplt.o = (fig, gctx) Immerse.figure(fig.figno; displayfig = false)
# end display(gplt)
# display(Immerse.Figure(fig.canvas, gplt))
# newfig = Immerse.Figure(fig.canvas) end
# newfig.cc = buildGadflySubplotContext(subplt)
# display(newfig)
# o is the window... show it # o is the window... show it
showall(subplt.o) showall(subplt.o)

View File

@ -118,9 +118,8 @@ function plotter()
elseif currentPackageSymbol == :immerse elseif currentPackageSymbol == :immerse
try try
@eval import Immerse, Gadfly, Gtk.ShortNames @eval import Immerse, Gadfly, Gtk
@eval export Immerse, Gadfly @eval export Immerse, Gadfly
global const GTK = Gtk.ShortNames
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