View Raw SPL
/*****************************************************************************
*                                                                            *
*   CUT.SPL      Copyright (C) 1998-2017 DSP Development Corporation         *
*                               All Rights Reserved                          *
*                                                                            *
*   Author:      Randy Race                                                  *
*                                                                            *
*   Synopsis:    Cuts displayed contents of a Window into the current Window *
*                                                                            *
*   Revisions:    8 Jun 1998  RRR  Creation                                  *
*                16 Nov 2006  RRR  Optional cutxy parameter for y range      *
*                22 May 2012  RRR  Optional zeropad to pad end points        *
*                17 Sep 2017  RRR  refactor for big data speedup             *
*                                                                            *
*****************************************************************************/

#if @HELP_CUT

    CUT

    Purpose: Cuts the displayed contents of a Window

    Syntax:  CUT(win, cutxy, zeropad)

              win    - A window

              cutxy  - Optional. An integer, 1: cut using both the x and y
                       displayed range, 0: cut using the x range only (default).

             zeropad - Optional. An integer, 1: pad beginning and/or end
                       points with zeros if cut range beyond the series
                       size, 0: limit cut range to series extent (default).

    Returns: A series or array

    Example:
             W1: gnorm(1000, 1/1000);setx(.2, .5)
             W2: cut(W1)

             W2 contains the data actually displayed in W1.

    Example:
             W1: gnorm(1000, 1/1000);sety(-0.5, 1.5)
             W2: cut(W1)
             W3: cut(W1, 1)

             W2 contains the same data as W1, but W3 contains the Y extracted
             portion of the data displayed in W1. The Y values of W3 range
             from -0.5 to 1.5.

    Example:
             W1: gnorm(1000, 1/1000);setx(-0.5, 1.5)
             W2: cut(W1, 0, 0)
             W3: cut(W1, 0, 1)

             W2 contains the same data as W1 because the dislayed data
             is longer than the extent of W1. However, W3 pads the starting
             and ending values with zeros to produce a series that extends
             from -0.5 to 1.5.

    Remarks:
             Cut works properly on arrays and images.

             The ZEROPAD option only applies to series.

    See Also:
             Extract
             Setvport
#endif


/* extract the displayed portion of a series */
cut(win = refwindow(w0), cutxy = 0, zeropad = 0)
{
        local s;

        s = wincut(win, win, cutxy, zeropad);
        
        return(s);
}