lineclip(s, mode, rloc)
{
local i, h, y, inplace = 0;
local xl, xr, yt, yb, ytic, yticset;
if (argc < 3)
{
if (argc < 2)
{
if (argc < 1)
{
s = refwindow(w0);
}
mode = 0;
}
rloc = 0;
}
if (getwnum(s) == getwnum(w0)) inplace = 1;
if (length(s) > 0)
{
/* get line handles placed for cliping */
h = findhandle(s, "tag", "clipline");
if (length(h) > 0)
{
echo("Clipping Points ...");
if (inplace)
{
/* original coords */
xl = getxl(s);
xr = getxr(s);
yt = getyt(s);
yb = getyb(s);
ytic = getytic(s);
yticset = getyticset(s);
}
/* series to clip */
y = refseries(s);
/* clip data for each line */
loop (i = 1..length(h))
{
y = clipline(h[i], y, mode, rloc);
}
deletehandle(h);
echo("");
if (inplace)
{
plotmode(w0, 0);
/* see if we have overlays */
if (getfocus(-1) > 1)
{
w0[.., getfocus()] = y;
}
else
{
w0 = y;
sety(w0, yb, yt);
if (yticset)
{
setytic(w0, ytic);
}
else
{
setytic(w0, -1);
}
}
setx(w0, xl, xr);
plotmode(w0, 1);
}
else
{
return(y);
}
}
}
}