gr implementation

This commit is contained in:
Daniel Schwabeneder 2018-08-24 17:20:19 +02:00
parent e991e2bf37
commit 84601bacdb
2 changed files with 23 additions and 26 deletions

View File

@ -338,7 +338,11 @@ end
# draw the markers, one at a time # draw the markers, one at a time
function gr_draw_markers(series::Series, x, y, msize, mz) function gr_draw_markers(series::Series, x, y, clims, msize = series[:markersize])
isempty(x) && return
GR.setfillintstyle(GR.INTSTYLE_SOLID)
shapes = series[:markershape] shapes = series[:markershape]
if shapes != :none if shapes != :none
for i=1:length(x) for i=1:length(x)
@ -355,7 +359,7 @@ function gr_draw_markers(series::Series, x, y, msize, mz)
# draw the shape - don't draw filled area if marker shape is 1D # draw the shape - don't draw filled area if marker shape is 1D
if !(shape in (:hline, :vline, :+, :x)) if !(shape in (:hline, :vline, :+, :x))
cfunc(get_markercolor(series, i)) cfunc(get_markercolor(series, clims, i))
gr_set_transparency(get_markeralpha(series, i)) gr_set_transparency(get_markeralpha(series, i))
gr_draw_marker(x[i], y[i], msi, shape) gr_draw_marker(x[i], y[i], msi, shape)
end end
@ -363,13 +367,6 @@ function gr_draw_markers(series::Series, x, y, msize, mz)
end end
end end
function gr_draw_markers(series::Series, x, y, clims)
isempty(x) && return
mz = normalize_zvals(series[:marker_z], clims)
GR.setfillintstyle(GR.INTSTYLE_SOLID)
gr_draw_markers(series, x, y, series[:markersize], mz)
end
# --------------------------------------------------------- # ---------------------------------------------------------
function gr_set_line(lw, style, c) #, a) function gr_set_line(lw, style, c) #, a)
@ -1038,7 +1035,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
GR.setfillintstyle(GR.INTSTYLE_SOLID) GR.setfillintstyle(GR.INTSTYLE_SOLID)
fr_from, fr_to = (is_2tuple(frng) ? frng : (y, frng)) fr_from, fr_to = (is_2tuple(frng) ? frng : (y, frng))
for (i, rng) in enumerate(segments) for (i, rng) in enumerate(segments)
gr_set_fillcolor(get_fillcolor(series, i)) gr_set_fillcolor(get_fillcolor(series, clims, i))
fx = _cycle(x, vcat(rng, reverse(rng))) fx = _cycle(x, vcat(rng, reverse(rng)))
fy = vcat(_cycle(fr_from,rng), _cycle(fr_to,reverse(rng))) fy = vcat(_cycle(fr_from,rng), _cycle(fr_to,reverse(rng)))
gr_set_transparency(get_fillalpha(series, i)) gr_set_transparency(get_fillalpha(series, i))
@ -1049,7 +1046,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
# draw the line(s) # draw the line(s)
if st in (:path, :straightline) if st in (:path, :straightline)
for (i, rng) in enumerate(segments) for (i, rng) in enumerate(segments)
gr_set_line(get_linewidth(series, i), get_linestyle(series, i), get_linecolor(series, i)) #, series[:linealpha]) gr_set_line(get_linewidth(series, i), get_linestyle(series, i), get_linecolor(series, clims, i)) #, series[:linealpha])
gr_set_transparency(get_linealpha(series, i)) gr_set_transparency(get_linealpha(series, i))
arrowside = isa(series[:arrow], Arrow) ? series[:arrow].side : :none arrowside = isa(series[:arrow], Arrow) ? series[:arrow].side : :none
gr_polyline(x[rng], y[rng]; arrowside = arrowside) gr_polyline(x[rng], y[rng]; arrowside = arrowside)
@ -1129,7 +1126,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
lz = series[:line_z] lz = series[:line_z]
segments = iter_segments(series) segments = iter_segments(series)
for (i, rng) in enumerate(segments) for (i, rng) in enumerate(segments)
gr_set_line(get_linewidth(series, i), get_linestyle(series, i), get_linecolor(series, i)) #, series[:linealpha]) gr_set_line(get_linewidth(series, i), get_linestyle(series, i), get_linecolor(series, clims, i)) #, series[:linealpha])
gr_set_transparency(get_linealpha(series, i)) gr_set_transparency(get_linealpha(series, i))
GR.polyline3d(x[rng], y[rng], z[rng]) GR.polyline3d(x[rng], y[rng], z[rng])
end end
@ -1201,12 +1198,12 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
xseg, yseg = x[rng], y[rng] xseg, yseg = x[rng], y[rng]
# draw the interior # draw the interior
gr_set_fill(get_fillcolor(series, i)) gr_set_fill(get_fillcolor(series, clims, i))
gr_set_transparency(get_fillalpha(series, i)) gr_set_transparency(get_fillalpha(series, i))
GR.fillarea(xseg, yseg) GR.fillarea(xseg, yseg)
# draw the shapes # draw the shapes
gr_set_line(get_linewidth(series, i), get_linestyle(series, i), get_linecolor(series, i)) gr_set_line(get_linewidth(series, i), get_linestyle(series, i), get_linecolor(series, clims, i))
gr_set_transparency(get_linealpha(series, i)) gr_set_transparency(get_linealpha(series, i))
GR.polyline(xseg, yseg) GR.polyline(xseg, yseg)
end end
@ -1298,10 +1295,10 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
for series in series_list(sp) for series in series_list(sp)
should_add_to_legend(series) || continue should_add_to_legend(series) || continue
st = series[:seriestype] st = series[:seriestype]
gr_set_line(get_linewidth(series), get_linestyle(series), get_linecolor(series)) #, series[:linealpha]) gr_set_line(get_linewidth(series), get_linestyle(series), get_linecolor(series, clims)) #, series[:linealpha])
if (st == :shape || series[:fillrange] != nothing) && series[:ribbon] == nothing if (st == :shape || series[:fillrange] != nothing) && series[:ribbon] == nothing
gr_set_fill(get_fillcolor(series)) #, series[:fillalpha]) gr_set_fill(get_fillcolor(series, clims)) #, series[:fillalpha])
l, r = xpos-0.07, xpos-0.01 l, r = xpos-0.07, xpos-0.01
b, t = ypos-0.4dy, ypos+0.4dy b, t = ypos-0.4dy, ypos+0.4dy
x = [l, r, r, l, l] x = [l, r, r, l, l]
@ -1309,7 +1306,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
gr_set_transparency(get_fillalpha(series)) gr_set_transparency(get_fillalpha(series))
gr_polyline(x, y, GR.fillarea) gr_polyline(x, y, GR.fillarea)
gr_set_transparency(get_linealpha(series)) gr_set_transparency(get_linealpha(series))
gr_set_line(get_linewidth(series), get_linestyle(series), get_linecolor(series)) gr_set_line(get_linewidth(series), get_linestyle(series), get_linecolor(series, clims))
st == :shape && gr_polyline(x, y) st == :shape && gr_polyline(x, y)
end end
@ -1323,7 +1320,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
end end
if series[:markershape] != :none if series[:markershape] != :none
gr_draw_markers(series, xpos - .035, ypos, 6, nothing) gr_draw_markers(series, xpos - .035, ypos, clims, 6)
end end
if typeof(series[:label]) <: Array if typeof(series[:label]) <: Array

View File

@ -619,18 +619,18 @@ end
for comp in (:line, :fill, :marker) for comp in (:line, :fill, :marker)
compcolor = Symbol(comp, :color) compcolor = string(comp, :color)
get_compcolor = Symbol(:get_, compcolor) get_compcolor = Symbol(:get_, compcolor)
comp_z = Symbol(comp, :_z) comp_z = string(comp, :_z)
compalpha = Symbol(comp, :alpha) compalpha = string(comp, :alpha)
get_compalpha = Symbol(:get_, compalpha) get_compalpha = Symbol(:get_, compalpha)
@eval begin @eval begin
function $get_compcolor(series, cmin::Real, cmax::Real, i::Int = 1) function $get_compcolor(series, cmin::Real, cmax::Real, i::Int = 1)
c = series[$Symbol(compcolor)] c = series[$Symbol($compcolor)]
z = series[$Symbol(comp_z)] z = series[$Symbol($comp_z)]
if z == nothing if z == nothing
isa(c, ColorGradient) ? c : plot_color(_cycle(c, i)) isa(c, ColorGradient) ? c : plot_color(_cycle(c, i))
else else
@ -639,17 +639,17 @@ for comp in (:line, :fill, :marker)
end end
end end
$get_compcolor(series, clims, i::Int = i) = $get_compcolor(series, clims[1], clims[2], i) $get_compcolor(series, clims, i::Int = 1) = $get_compcolor(series, clims[1], clims[2], i)
function $get_compcolor(series, i::Int = 1) function $get_compcolor(series, i::Int = 1)
if series[$Symbol(comp_z)] == nothing if series[$Symbol($comp_z)] == nothing
$get_compcolor(series, 0, 1, i) $get_compcolor(series, 0, 1, i)
else else
$get_compcolor(series, get_clims(series[:subplot]), i) $get_compcolor(series, get_clims(series[:subplot]), i)
end end
end end
$get_compalpha(series, i::Int = 1) = _cycle(series[$compalpha], i) $get_compalpha(series, i::Int = 1) = _cycle(series[$Symbol($compalpha)], i)
end end
end end