These are chat archives for jheinen/GR.jl

4th
Nov 2016
Josef Heinen
@jheinen
Nov 04 2016 07:48 UTC
@ChrisRackauckas : We have to live with the (poor) X11 output until the (interactive!) Qt-backend is finished - still WIP :-( . Switching to the GR CairoX11 driver is only an intermediate solution ...
Christopher Rackauckas
@ChrisRackauckas
Nov 04 2016 07:51 UTC
Good to know. When do you think that's coming?
Josef Heinen
@jheinen
Nov 04 2016 07:58 UTC
The GR output in Atom's plot pane is based on SVG and restricted in terms of real-time graphics. The challenge with the Qt-backend is not the GR integration - that's already working - but the deployment for different platforms. I don't want Julia users to struggle with Qt5 run-time installations ...
Tom Breloff
@tbreloff
Nov 04 2016 15:52 UTC
@jheinen I know we've discussed this in the past, but the current implementation for drawing markers isn't cutting it:
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
specifically it's a total hack to try to scale msize to some arbitrary guess of the window size
can you fill me in on exactly what coordinates GR.fillarea is taking?
(i tried to trace through the gr code, but it's pretty hard for me)
Josef Heinen
@jheinen
Nov 04 2016 16:59 UTC
@tbreloff : This snippet temporary sets the transformation to 0 (NDC = normalized device coordinates), so if you multiply those coordinates with the current window width/height, you will get the device specific coordinates. I'd suggest not to change the transformation and let GR transform window coordinates to device coordinates. In this case, however, you need different factors for the x and y.
Tom Breloff
@tbreloff
Nov 04 2016 17:00 UTC
say msize is in pixels, how should I change this?
Josef Heinen
@jheinen
Nov 04 2016 17:30 UTC
@tbreloff : GR.fillarea(xi + sx * msize / width, yi + sy * msize / width)
Tom Breloff
@tbreloff
Nov 04 2016 17:32 UTC
where width/height is size in pixels?
Josef Heinen
@jheinen
Nov 04 2016 18:03 UTC
Yes. Window width/height in pixels.
Tom Breloff
@tbreloff
Nov 04 2016 18:04 UTC
ok i think this works:
function gr_draw_marker(xi, yi, msize, shape::Shape)
    sx, sy = shape_coords(shape)
    # convert to ndc coords (percentages of window)
    GR.selntran(0)
    xi, yi = GR.wctondc(xi, yi)
    ms_ndc_x, ms_ndc_y = gr_pixels_to_ndc(msize, msize)
    GR.fillarea(xi .+ sx .* ms_ndc_x,
                yi .+ sy .* ms_ndc_y)
    GR.selntran(1)
end
with:
function gr_pixels_to_ndc(x_pixels, y_pixels)
    w,h = gr_plot_size
    totx = w * gr_view_xdiff()
    toty = h * gr_view_ydiff()
    x_pixels / totx, y_pixels / toty
end
so now the non-Shape version doesn't seem to be right
function gr_draw_marker(xi, yi, msize::Number, shape::Symbol)
    GR.setmarkertype(gr_markertype[shape])
    GR.setmarkersize(0.3msize)
    GR.polymarker([xi], [yi])
end
which has another magic hack of 0.3*msize
what are the units in GR.setmarkersize?
Tom Breloff
@tbreloff
Nov 04 2016 18:23 UTC
and a follow-up to GR.fillarea... it seems that the color isn't picked up (it's always black fill). I'm currently setting it with: gr_set_fillcolor(c) = GR.setfillcolorind(gr_getcolorind(cycle(c,1)))
function gr_getcolorind(c)
    GR.settransparency(float(alpha(c)))
    convert(Int, GR.inqcolorfromrgb(red(c), green(c), blue(c)))
end
do you see any reason that wouldn't work with GR.fillarea?
Tom Breloff
@tbreloff
Nov 04 2016 18:48 UTC
nevermind on the fillcolor... i found the problem
Josef Heinen
@jheinen
Nov 04 2016 19:37 UTC
The nominal marker size in GKS is 1 percent of the window height, which is multiplied with the marker size scale factor.
GR uses a default maker size scale factor of 2 ( = 2 percent of the window height)
Tom Breloff
@tbreloff
Nov 04 2016 19:48 UTC
ok so if I understand. window height is 400px. msize is 6px. then this would compute: (0.01 * 2 * 400) * (0.3 * 6) = 14?
Josef Heinen
@jheinen
Nov 04 2016 21:38 UTC
Yes!