View Raw SPL
/*****************************************************************************
*                                                                            *
*   UNOVERPLOTALL.SPL Copyright (C) 2010 DSP Development Corporation         *
*                               All Rights Reserved                          *
*                                                                            *
*   Author:      Randy Race                                                  *
*                                                                            *
*   Synopsis:    Removes overplots from a stripchart                         *
*                                                                            *
*   Revisions:   13 Aug 2010  RRR  Creation                                  *
*                                                                            *
*****************************************************************************/

#include 

#if @HELP_UNOVERPLOTALL

    UNOVERPLOTALL

    Purpose: Removes overplots from a stripchart.

    Syntax:  UNOVERPLOTALL(window, sernum)

             window  - A window to overplot

             sernum  - Optional. An integer, the overplot to remove. Defaults
                       to -1, all overplots.

    Returns: Nothing, the specified overplotted series are removed from the
             stripchart.

    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. To remove the overplots:

             unoverplotall(W3)

    Remarks:
             Use OVERPLOTALL to add overplots to a stripchart.

    See Also:
             OVERLAY
             OVERPLOT
             OVERPLOTALL
             UNOVERLAY
             UNOVERPLOT
#endif


/* removes one or more overplots from a stripchart */
unoverplotall(w, n)
{
        local j, pm, nf;

        /* parse input args */
        if (argc < 2)
        {
                if (argc < 1) w = refwindow(w0);
                
                n = -1;
        }
        if (isscalar(w))
        {
                n = w;
                w = refwindow(w0);
        }

        /* if window is a stripchart */
        if (iswindow(w) && getplottype(w) == 7)
        {
                if (n < 0)
                {
                        /* remove all */
                        pm = plotmode(w, 0);
                        
                        loop (j = 1..numitems(w))
                        {
                                unoverplotall_remove(w, 1);
                        }
                        
                        plotmode(w, pm);
                }
                else
                {
                        /* remove specified overplot */
                        unoverplotall_remove(w, n);
                }
        }
        else
        {
                unoverlay(w, n);
                unoverplot(w, n);
        }
}


unoverplotall_remove(w, n)
{
        local cf, nf, j;

        /* original focus and number of overlays */
        cf = getfocus(w);
        nf = getfocus(w, -1);

        loop (j = 1..nf)
        {
                /* remove overplot from each focus */
                focus(w, j);
                
                if (numitems(w, j) > n)
                {
                        unoverplot(w, n);
                }
        }
        
        focus(w, cf);
}