Re: XForms: Segmentation Fault using xyplot

From: Steve Lamont (
Date: Mon Jun 05 2000 - 12:53:13 EDT

  • Next message: Cihat Ozhasoglu: "XForms: Interix 2.2 (or OpenNT) for Windows 2000 and xforms"

    # To subscribers of the xforms list from Steve Lamont <> :

    > Thank you very much for your help, with it i corrected my code. My
    > intention doing the while was try to make xyplot works like a stripchart. I
    > know that i would have to insert others pieces of code but you think it's
    > possible? (I need something like a stripchart with a fixed scale in the
    > both axis) Could i use a fifo to pass data to the xyplot? Thanks in advance,

    It can be done, although it can be a bit tricky, since the XYPlot
    object is pretty thickheaded about how it wants to do scaling, etc.

    You'll have to keep an array of points to which you make your updates
    and then feed them to XYPlot, since there's no way to add a single
    point. For example, the following piece of code plots the most recent
    100 points:

            void add_point( float x, float y, FL_OBJECT *xyplot )


                    static int n = 0;
                    static float X[1000];
                    static float Y[1000];

                    if ( n == 1000 ) {

                            memcpy( &X[0], &X[901], sizeof( float ) * 99 );
                            memcpy( &Y[0], &Y[901], sizeof( float ) * 99 );
                            n = 99;

                    X[n] = x;
                    Y[n] = y;

                    fl_set_xyplot_data( xyplot,
                                        &X[n - 100],
                                        &Y[n - 100],
                                        ... );


    Note that there is a bug in this code (what happens when n < 100?) and
    it's not intended to be used "straight out of the box." I leave it to
    the user to deal with the startup case.

    As for the mechanism for passing data from your monitoring code to the
    plot code, a FIFO, I suppose, is as good as anything. You may wish to
    refer to the manual's discussion of asynchronous I/O or check the
    archives of this mailing list -- there has been considerable
    discussion of this subject and numerous different solutions to the
    problem, including use of threads.


    To unsubscribe, send the message "unsubscribe" to or see
    XForms Home Page:
    List Archive:

    This archive was generated by hypermail 2b29 : Mon Jun 05 2000 - 12:57:49 EDT