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