glvisualize: support for path/path3d with or without markers, 3d markers are spheres
This commit is contained in:
parent
1cf33044bc
commit
d66028ed0d
@ -29,7 +29,7 @@ supported_args(::GLVisualizeBackend) = merge_with_base_supported([
|
||||
# :clims,
|
||||
# :inset_subplots,
|
||||
])
|
||||
supported_types(::GLVisualizeBackend) = [:surface, :scatter, :scatter3d]
|
||||
supported_types(::GLVisualizeBackend) = [:surface, :scatter, :scatter3d, :path, :path3d]
|
||||
supported_styles(::GLVisualizeBackend) = [:auto, :solid]
|
||||
supported_markers(::GLVisualizeBackend) = [:none, :auto, :circle]
|
||||
supported_scales(::GLVisualizeBackend) = [:identity]
|
||||
@ -61,8 +61,8 @@ function gl_relative_size(plt::Plot{GLVisualizeBackend}, msize::Number)
|
||||
Float32(msize / winsz)
|
||||
end
|
||||
|
||||
function gl_marker(shape::Symbol, msize::Number)
|
||||
GeometryTypes.Circle(Point2f0(0), msize)
|
||||
function gl_marker(shape::Symbol, msize::Number, _3d::Bool)
|
||||
GeometryTypes.HyperSphere((_3d ? Point3f0 : Point2f0)(0), msize)
|
||||
end
|
||||
|
||||
function gl_display(plt::Plot{GLVisualizeBackend})
|
||||
@ -73,36 +73,44 @@ function gl_display(plt::Plot{GLVisualizeBackend})
|
||||
for series in series_list(sp)
|
||||
d = series.d
|
||||
st = d[:seriestype]
|
||||
x, y, z = map(Float32, d[:x]), map(Float32, d[:y]), d[:z]
|
||||
x, y = map(Float32, d[:x]), map(Float32, d[:y])
|
||||
msize = gl_relative_size(plt, d[:markersize])
|
||||
|
||||
viz = if st == :surface
|
||||
ismatrix(x) || (x = repmat(x', length(y), 1))
|
||||
ismatrix(y) || (y = repmat(y, 1, length(x)))
|
||||
z = transpose_z(d, map(Float32, z.surf), false)
|
||||
GLVisualize.visualize((x, y, z), :surface)
|
||||
z = transpose_z(d, map(Float32, d[:z].surf), false)
|
||||
viz = GLVisualize.visualize((x, y, z), :surface)
|
||||
GLVisualize.view(viz, window, camera = :perspective)
|
||||
|
||||
elseif st in (:scatter, :scatter3d)
|
||||
marker = gl_marker(d[:markershape], msize)
|
||||
@show marker msize
|
||||
# GLVisualize.visualize((marker ,(x, y, z)))
|
||||
else
|
||||
points = if is3d(st)
|
||||
z = map(Float32, z)
|
||||
z = map(Float32, d[:z])
|
||||
Point3f0[Point3f0(xi,yi,zi) for (xi,yi,zi) in zip(x, y, z)]
|
||||
else
|
||||
Point2f0[Point2f0(xi,yi) for (xi,yi) in zip(x, y)]
|
||||
end
|
||||
GLVisualize.visualize((marker, points))
|
||||
#GLVisualize.visualize((marker , map(Point3f0, zip(x, y, z),
|
||||
# billboard=true
|
||||
#))
|
||||
|
||||
# markers?
|
||||
if st in (:scatter, :scatter3d) || d[:markershape] != :none
|
||||
marker = gl_marker(d[:markershape], msize, is3d(st))
|
||||
viz = GLVisualize.visualize((marker, points))
|
||||
GLVisualize.view(viz, window, camera = :perspective)
|
||||
|
||||
else
|
||||
error("Series type $st not supported by GLVisualize")
|
||||
# TODO: might need to switch to these forms later?
|
||||
# GLVisualize.visualize((marker ,(x, y, z)))
|
||||
#GLVisualize.visualize((marker , map(Point3f0, zip(x, y, z),
|
||||
# billboard=true
|
||||
#))
|
||||
end
|
||||
|
||||
# paths
|
||||
lw = d[:linewidth]
|
||||
if !(st in (:scatter, :scatter3d)) && lw > 0
|
||||
viz = GLVisualize.visualize(points, :lines) #, color=colors, model=rotation)
|
||||
GLVisualize.view(viz, window, camera = :perspective)
|
||||
end
|
||||
end
|
||||
|
||||
GLVisualize.view(viz, window, camera = :perspective)
|
||||
|
||||
end
|
||||
end
|
||||
# GLAbstraction.center!(window)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user