Menu

#628 Object clipping

None
closed-accepted
nobody
None
5
2015-02-06
2013-06-28
No

Hi,

I propose a clip/noclip property for objects.

I had the problem, that I wanted to mark something with a circle on the plot boundary. Especially for automatically calulated borders it was best to specify the circle center in graph/plot coordinates. But with this coordinate types, the circle is clipped to the plot boundaries.

The attached patch is a first proposal, which introduces two new keywords for objects:

  • clip: Do the clipping based on coordinate type choice
  • noclip: Clip only at the canvas boundary, independent of the coordinate type.

You can test with the following example (needs the patch from https://sourceforge.net/p/gnuplot/bugs/1255/):

reset
set xrange[-1:1]
set yrange[-1:1]
set macros
fs="fillstyle solid 1.0 border lc rgb 'black' lw 2"

set lmargin at screen 0.2
set rmargin at screen 0.8
set tmargin at screen 0.8
set bmargin at screen 0.2


set object 1 rectangle from first -1.1,first -1.1 \
  to first -0.5, first -0.5
set object 1 fc rgb 'red' @fs
set object 2 circle at graph 0, graph 0.5 radius graph 0.1
set object 2 fc rgb 'green' @fs
set object 3 polygon from first -0.5, first 0.5 \
  to first 0, first 1.2 \
  to first 0.5,first 0.5
set object 3 fc rgb 'yellow' @fs
set object 4 ellipse at graph 1,graph 0 size first 0.3, first 0.4
set object 4 fc rgb '#8888ff' @fs

plot 0
pause -1

The plot styles 'with circles' and 'with ellipses' are not affected.

Instead of having only these two options I would prefer having an additional possibility to clip to the plot boundary regardless of the coordinate type. (options 'clip', 'noclip', 'autoclip'?).

Looking forward to your comments,
Christoph

1 Attachments

Discussion

  • Christoph Bersch

    I reworked the object clipping:

    • Options clipdefault, clip and noclip for set object circle, rectangle, polygon, and ellipse.
      • clipdefault clips the objects based on the coordinate types (this is the default and corresponds to the current implementation).
      • clip clips the objects at the plot boundaries.
      • noclip disables clipping.
    • Options clip and noclip for plotting styles with circles and with ellipses which can be set using set style circle and set style ellipse.
     
  • Ethan Merritt

    Ethan Merritt - 2013-10-19
    • status: open --> pending-accepted
    • Group: -->
     
  • Ethan Merritt

    Ethan Merritt - 2013-10-19

    Added to cvs for 4.7, but with only a placeholder for the "always clip" option.
    I am failing to see when this would ever be needed. Can you give an example?

     
  • Christoph Bersch

    I don't have a special use case, but I always found it kind of unintuitive to have the clipping depend on the coordinate type.

    I guess it makes sense to have it, but often I prefer to set clip without worrying about the coordinate type.

     
  • Ethan Merritt

    Ethan Merritt - 2013-11-12
    • status: pending-accepted --> closed-accepted
     

Log in to post a comment.