Fix Shape markers for GR

This commit is contained in:
Daniel Schwabeneder 2020-02-29 20:34:39 +01:00
parent 8610a82a88
commit 4051d016b9
2 changed files with 25 additions and 11 deletions

View File

@ -305,15 +305,27 @@ end
# --------------------------------------------------------- # ---------------------------------------------------------
# draw ONE Shape # draw ONE Shape
function gr_draw_marker(xi, yi, msize, shape::Shape) function gr_draw_marker(series, xi, yi, clims, i, msize, shape::Shape)
sx, sy = coords(shape) sx, sy = coords(shape)
# convert to ndc coords (percentages of window) # convert to ndc coords (percentages of window)
GR.selntran(0) GR.selntran(0)
w, h = gr_plot_size w, h = gr_plot_size
f = msize / (w + h) f = msize / (w + h)
xi, yi = GR.wctondc(xi, yi) xi, yi = GR.wctondc(xi, yi)
GR.fillarea(xi .+ sx .* f, xs = xi .+ sx .* f
yi .+ sy .* f) ys = yi .+ sy .* f
# draw the interior
mc = get_markercolor(series, clims, i)
gr_set_fill(mc)
gr_set_transparency(mc, get_markeralpha(series, i))
GR.fillarea(xs, ys)
# draw the shapes
msc = get_markerstrokecolor(series, i)
gr_set_line(get_markerstrokewidth(series, i), :solid, msc)
gr_set_transparency(msc, get_markerstrokealpha(series, i))
GR.polyline(xs, ys)
GR.selntran(1) GR.selntran(1)
end end
@ -323,7 +335,11 @@ function nominal_size()
end end
# draw ONE symbol marker # draw ONE symbol marker
function gr_draw_marker(xi, yi, msize::Number, shape::Symbol) function gr_draw_marker(series, xi, yi, clims, i, msize::Number, shape::Symbol)
GR.setborderwidth(series[:markerstrokewidth]);
gr_set_bordercolor(get_markerstrokecolor(series, i));
gr_set_markercolor(get_markercolor(series, clims, i));
gr_set_transparency(get_markeralpha(series, i))
GR.setmarkertype(gr_markertype[shape]) GR.setmarkertype(gr_markertype[shape])
GR.setmarkersize(0.3msize / nominal_size()) GR.setmarkersize(0.3msize / nominal_size())
GR.polymarker([xi], [yi]) GR.polymarker([xi], [yi])
@ -341,13 +357,7 @@ function gr_draw_markers(series::Series, x, y, clims, msize = series[:markersize
for i=eachindex(x) for i=eachindex(x)
msi = _cycle(msize, i) msi = _cycle(msize, i)
shape = _cycle(shapes, i) shape = _cycle(shapes, i)
i gr_draw_marker(series, x[i], y[i], clims, i, msi, shape)
GR.setborderwidth(series[:markerstrokewidth]);
gr_set_bordercolor(get_markerstrokecolor(series, i));
gr_set_markercolor(get_markercolor(series, clims, i));
gr_set_transparency(get_markeralpha(series, i))
gr_draw_marker(x[i], y[i], msi, shape)
end end
end end
end end

View File

@ -693,6 +693,10 @@ function get_markerstrokealpha(series, i::Int = 1)
_cycle(series[:markerstrokealpha], i) _cycle(series[:markerstrokealpha], i)
end end
function get_markerstrokewidth(series, i::Int = 1)
_cycle(series[:markerstrokewidth], i)
end
function has_attribute_segments(series::Series) function has_attribute_segments(series::Series)
# we want to check if a series needs to be split into segments just because # we want to check if a series needs to be split into segments just because
# of its attributes # of its attributes