From d66028ed0deab25a3902ea605e16385192f6e1f0 Mon Sep 17 00:00:00 2001 From: Thomas Breloff Date: Thu, 23 Jun 2016 17:00:08 -0400 Subject: [PATCH] glvisualize: support for path/path3d with or without markers, 3d markers are spheres --- src/backends/glvisualize.jl | 48 +++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/src/backends/glvisualize.jl b/src/backends/glvisualize.jl index 6c1641b5..937e4c8c 100644 --- a/src/backends/glvisualize.jl +++ b/src/backends/glvisualize.jl @@ -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)