View Raw SPL
/*****************************************************************************
*                                                                            *
*   OVERPLOTALL.SPL Copyright (C) 2010 DSP Development Corporation           *
*                               All Rights Reserved                          *
*                                                                            *
*   Author:      Randy Race                                                  *
*                                                                            *
*   Synopsis:    Overplots stripcharts and series                            *
*                                                                            *
*   Revisions:   13 Aug 2010  RRR  Creation                                  *
*                                                                            *
*****************************************************************************/

#include 

#if @HELP_OVERPLOTALL

    OVERPLOTALL

    Purpose: Overplots a series onto a stripchart.

    Syntax:  OVERPLOTALL(series, color)

              series - A window or series to overplot

              color  - Optional. An integer, the overplot color. Defaults
                       to the next color in the overplot list.

    Returns: Nothing, the input window or series is overplotted onto the
             current window.

    Example:
             W1: stripchart(gnorm(1000, 1), gnorm(1000, 1))
             W2: integ(w1)
             W3: movavg(w2, 20);overplotall(w2, lred)

             The stripchart data in W2 is synthesized by integrating
             two 1000 point series of normally distributed random noise.
             The series is smoothed via a 20 point moving average in
             W3. The unsmoothed source in W2 is overplotted in red on to
             W3 for visual comparison.

    Remarks:
             Use UNOVERPLOTALL to remove overplots from a stripchart.

    See Also:
             OVERLAY
             OVERPLOT
             UNOVERLAY
             UNOVERPLOT
             UNOVERPLOTALL
#endif


/* overlay stripcharts and overlays */
overlayall(s, color)
{
        local nf, cf, j;

        if (argc < 1) error("overplotall - input required");

        if (argc < 2) color = -1;

        /* check if stripchart */        
        if (getplottype(s) == 7)
        {
                /* min overlays */
                nf = min(getfocus(-1), numitems(s));

                /* current focus */
                cf = getfocus();

                loop (j = 1..nf)
                {
                        /* set focus to each channel and overlay */
                        focus(j);
                        overlay(getitem(s, j), color, 0);
                }

                /* restore original focus */
                focus(cf);
        }
        else
        {
                /* standard overlay */
                overlay(s, color);
        }
}