working on glvisualize
This commit is contained in:
parent
2bca9ca9ec
commit
1ecd9f9e19
@ -50,10 +50,15 @@ end
|
|||||||
|
|
||||||
|
|
||||||
function _create_backend_figure(plt::Plot{GLVisualizeBackend})
|
function _create_backend_figure(plt::Plot{GLVisualizeBackend})
|
||||||
# init a window
|
# init a screen
|
||||||
window = GLVisualize.glscreen()
|
screen = if isdefined(GLVisualize, :ROOT_SCREEN)
|
||||||
@async GLVisualize.renderloop(window)
|
GLVisualize.ROOT_SCREEN
|
||||||
window
|
else
|
||||||
|
s = GLVisualize.glscreen()
|
||||||
|
@async GLVisualize.renderloop(s)
|
||||||
|
s
|
||||||
|
end
|
||||||
|
empty!(screen)
|
||||||
end
|
end
|
||||||
|
|
||||||
function gl_relative_size(plt::Plot{GLVisualizeBackend}, msize::Number)
|
function gl_relative_size(plt::Plot{GLVisualizeBackend}, msize::Number)
|
||||||
@ -65,8 +70,14 @@ function gl_marker(shape::Symbol, msize::Number, _3d::Bool)
|
|||||||
GeometryTypes.HyperSphere((_3d ? Point3f0 : Point2f0)(0), msize)
|
GeometryTypes.HyperSphere((_3d ? Point3f0 : Point2f0)(0), msize)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function gl_color(c, a)
|
||||||
|
c = convertColor(c, a)[1]
|
||||||
|
@show typeof(c)
|
||||||
|
RGBA{Float32}(c)
|
||||||
|
end
|
||||||
|
|
||||||
function gl_display(plt::Plot{GLVisualizeBackend})
|
function gl_display(plt::Plot{GLVisualizeBackend})
|
||||||
window = plt.o
|
screen = plt.o
|
||||||
for sp in plt.subplots
|
for sp in plt.subplots
|
||||||
# TODO: setup subplot
|
# TODO: setup subplot
|
||||||
|
|
||||||
@ -81,7 +92,7 @@ function gl_display(plt::Plot{GLVisualizeBackend})
|
|||||||
ismatrix(y) || (y = repmat(y, 1, length(x)))
|
ismatrix(y) || (y = repmat(y, 1, length(x)))
|
||||||
z = transpose_z(d, map(Float32, d[:z].surf), false)
|
z = transpose_z(d, map(Float32, d[:z].surf), false)
|
||||||
viz = GLVisualize.visualize((x, y, z), :surface)
|
viz = GLVisualize.visualize((x, y, z), :surface)
|
||||||
GLVisualize.view(viz, window, camera = :perspective)
|
GLVisualize.view(viz, screen, camera = :perspective)
|
||||||
|
|
||||||
else
|
else
|
||||||
points = if is3d(st)
|
points = if is3d(st)
|
||||||
@ -90,12 +101,14 @@ function gl_display(plt::Plot{GLVisualizeBackend})
|
|||||||
else
|
else
|
||||||
Point2f0[Point2f0(xi,yi) for (xi,yi) in zip(x, y)]
|
Point2f0[Point2f0(xi,yi) for (xi,yi) in zip(x, y)]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
camera = is3d(st) ? :perspective : :orthographic_pixel
|
||||||
|
|
||||||
# markers?
|
# markers?
|
||||||
if st in (:scatter, :scatter3d) || d[:markershape] != :none
|
if st in (:scatter, :scatter3d) || d[:markershape] != :none
|
||||||
marker = gl_marker(d[:markershape], msize, is3d(st))
|
marker = gl_marker(d[:markershape], msize, is3d(st))
|
||||||
viz = GLVisualize.visualize((marker, points))
|
viz = GLVisualize.visualize((marker, points), color = gl_color(d[:markercolor], d[:markeralpha]))
|
||||||
GLVisualize.view(viz, window, camera = :perspective)
|
GLVisualize.view(viz, screen, camera = camera)
|
||||||
|
|
||||||
# TODO: might need to switch to these forms later?
|
# TODO: might need to switch to these forms later?
|
||||||
# GLVisualize.visualize((marker ,(x, y, z)))
|
# GLVisualize.visualize((marker ,(x, y, z)))
|
||||||
@ -108,24 +121,28 @@ function gl_display(plt::Plot{GLVisualizeBackend})
|
|||||||
lw = d[:linewidth]
|
lw = d[:linewidth]
|
||||||
if !(st in (:scatter, :scatter3d)) && lw > 0
|
if !(st in (:scatter, :scatter3d)) && lw > 0
|
||||||
viz = GLVisualize.visualize(points, :lines) #, color=colors, model=rotation)
|
viz = GLVisualize.visualize(points, :lines) #, color=colors, model=rotation)
|
||||||
GLVisualize.view(viz, window, camera = :perspective)
|
GLVisualize.view(viz, screen, camera = camera)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# GLAbstraction.center!(window)
|
# GLAbstraction.center!(screen)
|
||||||
|
|
||||||
# TODO: render one frame at a time? (no renderloop)
|
# TODO: render one frame at a time? (no renderloop)
|
||||||
# GLWindow.render_frame(window)
|
# GLWindow.render_frame(screen)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
|
|
||||||
|
function _update_plot_object(plt::Plot{GLVisualizeBackend})
|
||||||
|
gl_display(plt)
|
||||||
|
end
|
||||||
|
|
||||||
# function _writemime(io::IO, ::MIME"image/png", plt::AbstractPlot{GLVisualizeBackend})
|
# function _writemime(io::IO, ::MIME"image/png", plt::AbstractPlot{GLVisualizeBackend})
|
||||||
# # TODO: write a png to io
|
# # TODO: write a png to io
|
||||||
# end
|
# end
|
||||||
|
|
||||||
function _display(plt::Plot{GLVisualizeBackend})
|
# function _display(plt::Plot{GLVisualizeBackend})
|
||||||
gl_display(plt)
|
# gl_display(plt)
|
||||||
end
|
# end
|
||||||
|
|||||||
@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
abstract ColorScheme
|
abstract ColorScheme
|
||||||
|
|
||||||
|
Base.getindex(scheme::ColorScheme, i::Integer) = getColor(scheme, i)
|
||||||
|
|
||||||
export
|
export
|
||||||
cgrad
|
cgrad
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user