From e9abb6d021a6dc03440f7039683a18562b8e8c48 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Tue, 11 Jun 2019 22:55:54 +0200 Subject: [PATCH 1/3] implement arrowstyle for GR --- src/backends/gr.jl | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/backends/gr.jl b/src/backends/gr.jl index 7e41bfeb..ae105ee6 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -84,12 +84,21 @@ gr_set_transparency(c, α) = gr_set_transparency(α) gr_set_transparency(c::Colorant, ::Nothing) = gr_set_transparency(c) gr_set_transparency(c::Colorant) = GR.settransparency(alpha(c)) +const _gr_arrow_map = Dict( + :simple => 1, + :hollow => 3, + :filled => 4, + :triangle => 5, + :filledtriangle => 6, +) +gr_set_arrowstyle(s::Symbol) = GR.setarrowstyle(get(_gr_arrow_map, s, 1)) + # -------------------------------------------------------------------------------------- # draw line segments, splitting x/y into contiguous/finite segments # note: this can be used for shapes by passing func `GR.fillarea` -function gr_polyline(x, y, func = GR.polyline; arrowside=:none) +function gr_polyline(x, y, func = GR.polyline; arrowside = :none, arrowstyle = :simple) iend = 0 n = length(x) while iend < n-1 @@ -118,9 +127,11 @@ function gr_polyline(x, y, func = GR.polyline; arrowside=:none) if istart > 0 && iend > 0 func(x[istart:iend], y[istart:iend]) if arrowside in (:head,:both) + gr_set_arrowstyle(arrowstyle) GR.drawarrow(x[iend-1], y[iend-1], x[iend], y[iend]) end if arrowside in (:tail,:both) + gr_set_arrowstyle(arrowstyle) GR.drawarrow(x[istart+1], y[istart+1], x[istart], y[istart]) end else @@ -1269,7 +1280,9 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) gr_set_line(get_linewidth(series, i), get_linestyle(series, i), lc) #, series[:linealpha]) gr_set_transparency(lc, get_linealpha(series, i)) arrowside = isa(series[:arrow], Arrow) ? series[:arrow].side : :none - gr_polyline(x[rng], y[rng]; arrowside = arrowside) + arrowstyle = isa(series[:arrow], Arrow) ? series[:arrow].style : :simple + gr_set_fillcolor(lc) + gr_polyline(x[rng], y[rng]; arrowside = arrowside, arrowstyle = arrowstyle) end end end From 8342da1ea2001db493a0aef77cd219743cab0df4 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Tue, 11 Jun 2019 23:15:59 +0200 Subject: [PATCH 2/3] allow row vector of arrows --- src/args.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/args.jl b/src/args.jl index 9ff20711..6f719bae 100644 --- a/src/args.jl +++ b/src/args.jl @@ -1030,7 +1030,7 @@ function preprocessArgs!(plotattributes::KW) arrow() elseif a in (false, nothing, :none) nothing - elseif !(typeof(a) <: Arrow) + elseif !(typeof(a) <: Arrow || typeof(a) <: AbstractArray{Arrow}) arrow(wraptuple(a)...) else a From fd2c01808a2df5e609eb9fe693ad5b29a93edfb6 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Wed, 12 Jun 2019 19:26:15 +0200 Subject: [PATCH 3/3] add :open and :closed arrow --- src/backends/gr.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/backends/gr.jl b/src/backends/gr.jl index ae105ee6..91bf25b4 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -90,6 +90,8 @@ const _gr_arrow_map = Dict( :filled => 4, :triangle => 5, :filledtriangle => 6, + :closed => 6, + :open => 5, ) gr_set_arrowstyle(s::Symbol) = GR.setarrowstyle(get(_gr_arrow_map, s, 1))