cleanup and comments
This commit is contained in:
parent
4dfadeaf15
commit
e3c06cad57
@ -269,14 +269,6 @@ end
|
||||
# ---------------------------------------------------------
|
||||
|
||||
# draw ONE Shape
|
||||
# function gr_draw_marker(xi, yi, msize, shape::Shape)
|
||||
# sx, sy = shape_coords(shape)
|
||||
# GR.selntran(0)
|
||||
# xi, yi = GR.wctondc(xi, yi)
|
||||
# GR.fillarea(xi + sx * 0.0015msize,
|
||||
# yi + sy * 0.0015msize)
|
||||
# GR.selntran(1)
|
||||
# end
|
||||
function gr_draw_marker(xi, yi, msize, shape::Shape)
|
||||
sx, sy = shape_coords(shape)
|
||||
# convert to ndc coords (percentages of window)
|
||||
@ -963,52 +955,12 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
||||
GR.drawimage(xmin, xmax, ymax, ymin, w, h, rgba)
|
||||
end
|
||||
|
||||
# if anns != nothing
|
||||
# TODO handle series annotations
|
||||
# TODO: this should be moved with SeriesAnnotations... iterate like:
|
||||
# for (xi,yi,str,shape) in eachann(anns, sp) ... end
|
||||
# or maybe
|
||||
# anns.sp = sp
|
||||
# for (xi,yi,str,shape) in anns ... end
|
||||
# TODO: maybe scrap all of this and do some preprocessing to overwrite the marker shape with
|
||||
# a vector of the computed shapes?? then marker_z, etc will still work
|
||||
# @assert !is3d(sp)
|
||||
# shapefillcolor = plot_color(ann.shapefill.color, ann.shapefill.alpha)
|
||||
# shapestrokecolor = plot_color(ann.shapestroke.color, ann.shapestroke.alpha)
|
||||
# for i=1:length(y)
|
||||
# xi = cycle(x,i)
|
||||
# yi = cycle(y,i)
|
||||
# # @show anns.strs typeof(anns.strs)
|
||||
# str = cycle(anns.strs,i)
|
||||
|
||||
# if !isnull(anns.baseshape)
|
||||
# # get the width and height of the string (in mm)
|
||||
# sw, sh = text_size(str, anns.font.pointsize)
|
||||
#
|
||||
# # how much to scale the base shape?
|
||||
# xscale = 0.5 * resolve_mixed(MixedMeasures(0, 0, sw), sp, :x)
|
||||
# yscale = 0.5 * resolve_mixed(MixedMeasures(0, 0, sh), sp, :y)
|
||||
#
|
||||
# # get the shape for this x/y/str
|
||||
# shape = scale(get(anns.baseshape), xscale, yscale)
|
||||
# translate!(shape, xi, yi)
|
||||
#
|
||||
# # draw the interior
|
||||
# gr_set_fill(shapefillcolor)
|
||||
# GR.fillarea(shape_coords(shape)...)
|
||||
#
|
||||
# # draw the shapes
|
||||
# gr_set_line(anns.shapestroke.width, anns.shapestroke.style, shapestrokecolor)
|
||||
# GR.polyline(shape_coords(shape)...)
|
||||
# end
|
||||
|
||||
# this is all we need to add the series_annotations text
|
||||
anns = series[:series_annotations]
|
||||
for (xi,yi,str) in EachAnn(anns, x, y)
|
||||
gr_set_font(anns.font)
|
||||
gr_text(GR.wctondc(xi, yi)..., str)
|
||||
end
|
||||
# end
|
||||
# this is all we need to add the series_annotations text
|
||||
anns = series[:series_annotations]
|
||||
for (xi,yi,str) in EachAnn(anns, x, y)
|
||||
gr_set_font(anns.font)
|
||||
gr_text(GR.wctondc(xi, yi)..., str)
|
||||
end
|
||||
|
||||
GR.restorestate()
|
||||
end
|
||||
|
||||
@ -803,16 +803,6 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
||||
push!(handle, ax[:add_patch](patches))
|
||||
end
|
||||
end
|
||||
# path = py_path(x, y)
|
||||
# patches = pypatches.pymember("PathPatch")(path;
|
||||
# label = series[:label],
|
||||
# zorder = series[:series_plotindex],
|
||||
# edgecolor = py_linecolor(series),
|
||||
# facecolor = py_fillcolor(series),
|
||||
# linewidth = py_dpi_scale(plt, series[:linewidth]),
|
||||
# fill = true
|
||||
# )
|
||||
# handle = ax[:add_patch](patches)
|
||||
push!(handles, handle)
|
||||
end
|
||||
|
||||
|
||||
@ -390,31 +390,18 @@ type SeriesAnnotations
|
||||
strs::AbstractVector # the labels/names
|
||||
font::Font
|
||||
baseshape::Nullable
|
||||
# shapefill::Brush
|
||||
# shapestroke::Stroke
|
||||
# x
|
||||
# y
|
||||
end
|
||||
function series_annotations(strs::AbstractVector, args...)
|
||||
fnt = font()
|
||||
shp = Nullable{Any}()
|
||||
scalefactor = 1
|
||||
# br = brush(:steelblue)
|
||||
# stk = stroke()
|
||||
# α = nothing
|
||||
for arg in args
|
||||
if isa(arg, Shape) || (isa(arg, AbstractVector) && eltype(arg) == Shape)
|
||||
shp = Nullable(arg)
|
||||
# elseif isa(arg, Brush)
|
||||
# brush = arg
|
||||
# elseif isa(arg, Stroke)
|
||||
# stk = arg
|
||||
elseif isa(arg, Font)
|
||||
fnt = arg
|
||||
elseif isa(arg, Symbol) && haskey(_shapes, arg)
|
||||
shp = _shapes[arg]
|
||||
# elseif allAlphas(arg)
|
||||
# α = arg
|
||||
elseif isa(arg, Number)
|
||||
scalefactor = arg
|
||||
else
|
||||
@ -426,11 +413,6 @@ function series_annotations(strs::AbstractVector, args...)
|
||||
scale!(s, scalefactor, scalefactor, (0,0))
|
||||
end
|
||||
end
|
||||
# if α != nothing
|
||||
# br.alpha = α
|
||||
# stk.alpha = α
|
||||
# end
|
||||
# note: x/y coords are added later
|
||||
SeriesAnnotations(strs, fnt, shp)
|
||||
end
|
||||
series_annotations(anns::SeriesAnnotations) = anns
|
||||
@ -439,14 +421,10 @@ series_annotations(::Void) = nothing
|
||||
function series_annotations_shapes!(series::Series, scaletype::Symbol = :pixels)
|
||||
anns = series[:series_annotations]
|
||||
if anns != nothing && !isnull(anns.baseshape)
|
||||
# x = series[:x]
|
||||
# y = series[:y]
|
||||
# we should use baseshape to overwrite the markershape attribute
|
||||
# we use baseshape to overwrite the markershape attribute
|
||||
# with a list of custom shapes for each
|
||||
msize = Float64[]
|
||||
shapes = Shape[begin
|
||||
# xi = cycle(x,i)
|
||||
# yi = cycle(y,i)
|
||||
str = cycle(anns.strs,i)
|
||||
|
||||
# get the width and height of the string (in mm)
|
||||
@ -455,26 +433,19 @@ function series_annotations_shapes!(series::Series, scaletype::Symbol = :pixels)
|
||||
# how much to scale the base shape?
|
||||
# note: it's a rough assumption that the shape fills the unit box [-1,-1,1,1],
|
||||
# so we scale the length-2 shape by 1/2 the total length
|
||||
# if scaletype == :pixels
|
||||
scalar = (backend() == PyPlotBackend() ? 1.7 : 1.0)
|
||||
xscale = 0.5to_pixels(sw) * scalar
|
||||
yscale = 0.55to_pixels(sh) * scalar
|
||||
# else
|
||||
# sp = series[:subplot]
|
||||
# xscale = 0.5 * resolve_mixed(MixedMeasures(0, 0, sw), sp, :x)
|
||||
# yscale = 0.5 * resolve_mixed(MixedMeasures(0, 0, sh), sp, :y)
|
||||
# end
|
||||
xscale = 0.5to_pixels(sw) * scalar
|
||||
yscale = 0.55to_pixels(sh) * scalar
|
||||
|
||||
# we save the size of the larger direction to the markersize list,
|
||||
# and then re-scale a copy of baseshape to match the w/h ratio
|
||||
maxscale = max(xscale, yscale)
|
||||
push!(msize, maxscale)
|
||||
|
||||
# get the shape for this x/y/str
|
||||
# @show get(anns.baseshape) xscale,yscale
|
||||
baseshape = cycle(get(anns.baseshape),i)
|
||||
shape = scale(baseshape, xscale/maxscale, yscale/maxscale, (0,0))
|
||||
# @show shape
|
||||
end for i=1:length(anns.strs)]
|
||||
series[:markershape] = shapes
|
||||
series[:markersize] = msize #1 # the scaling is handled in the shapes
|
||||
series[:markersize] = msize
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user