[Rd] followup to graphics bug #414

Paul Murrell paul@stat.auckland.ac.nz
Mon, 14 Feb 2000 15:53:03 +1300


hi


> I have done a little bit of poking around at the bug that I reported
> earlier (steep slopes and lines from far outside the plot range doing
> funny things), and have tracked it down to the fact that, as noted in the
> Unix man page, XDrawLine[s] doesn't like coordinates that are outside of
> the range of (-32767,32767).
>
> Now the question is, what to do about this?  A quick "fix" (not a fix but
> at least an acknowledgement of the problem) would check coordinates in
> GLine() and issue a warning instead of trying to draw anything if any of
> the coordinates was outside the allowed range (would one have to add a
> per-driver piece of information giving the min and max vals?).
>
> I wrote a prototype of some clipping code in R that I could translate to C
> and stick into src/unix/devX11.c right before every call to XDrawLine or
> XDrawLines.  Before I go to that trouble, though: is there a better way to
> do this?  Is there already clipping code lying around somewhere else in R?
> Is there a way to do this generically (perhaps by adding an outer clipping
> region to every device at its device-coordinate limits) that would
> centralize the code and not require it to be repeated for every
> driver/line-drawing call?
>
>  Any thoughts?  I'd really like to get this fixed ...


there is clipping code in R (see, e.g,. CScliplines in graphics.c)

whether it gets called or not depends on the canClip flag in the DevDesc
structure.  If this is
false (0) then the R clipping code gets called, otherwise R gets the device
to do the clipping.
currently, the X11 device has canClip = 1 so none of the R clipping code
gets called.

NOTE that getting R to do the clipping serves two purposes:  (i) it clips
(wow !)  (ii) it prevents silly values getting sent to the device

a quick fix then is to simply set canClip = 0 in devX11.c

this is a bit of overkill though because we really only want to do (ii)
above

one solution would be to get R to check for silly values (e.g., clip to devi
ce extent) regardless of the canClip flag, which wouldn't be too much work
because the clipping code is all in place.

i think that would be preferable to making each device responsible for
checking for silly values.

paul


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._