Re: XForms: XYplot point replacement

From: T.C. Zhao (tc_zhao@yahoo.com)
Date: Thu Jun 06 2002 - 14:56:37 EDT

  • Next message: spl@ncmir.ucsd.edu: "Re: XForms: XForms 1.0 Release Candidate 3"

    # To subscribers of the xforms list from "T.C. Zhao" <tc_zhao@yahoo.com> :

    Acutally if someone can take the initiative and ownership to change
    the API so all data manipulation routines can take
    an ID (default parameter like in C++ would come in
    handy here), many of the subtle features
    (or redundant APIs) are addressed in a general way.

    --- Reed Riddle <drriddle@qwest.net> wrote:
    > # To subscribers of the xforms list from "Reed Riddle" <drriddle@qwest.net>
    > :
    >
    >
    > Howdy folks,
    >
    > I'm working on an interactive XYplot function, where I need to
    > change the point color (to indicate if the point is valid data or
    > garbage). Since you can't change the color of a point, I'm using
    > overlays. I was going to use the routine that inserts a point in
    > the data, but that adds to the size of the array (and memory is
    > important here). So, I started looking at the point replacement
    > routine in xyplot.c:
    >
    > > void
    > > fl_replace_xyplot_point(FL_OBJECT * ob, int i, double x, double y)
    > > {
    > > SPEC *sp = ob->spec;
    > >
    > > if (i < 0 || i >= sp->n[0])
    > > return;
    > >
    > > if ((sp->x[0][i] != x) || (sp->y[0][i] != y))
    > > {
    > > sp->x[0][i] = x;
    > > sp->y[0][i] = y;
    > > fl_redraw_object(ob);
    > > }
    > > }
    >
    > This replaces data values in the main data array. Notice the 0
    > index? I decided to replace it with the ID number for the overlay:
    >
    > > void
    > > fl_replace_xyplot_overlay_point(FL_OBJECT * ob, int i, int ID,
    > > double x, double y)
    > > {
    > > SPEC *sp = ob->spec;
    > >
    > > if (i < 1 || i >= sp->n[ID])
    > > return;
    > >
    > > if ((sp->x[ID][i] != x) || (sp->y[ID][i] != y))
    > > {
    > > sp->x[ID][i] = x;
    > > sp->y[ID][i] = y;
    > > fl_redraw_object(ob);
    > > }
    > > }
    >
    > And, magically, it works! I set the ID test to cut out if it's 0,
    > since I didn't want to replace the data itself, just add or remove a
    > point from the overlay; I like the idea of keeping the overlay
    > points separate from the data plot points.
    >
    > Anyways, I just thought I would submit this, just in case someone
    > thinks it's useful. This is all part of creating an interactive
    > XYplot (scaling, mouse & keyboard interaction, etc), which I'll
    > gladly share when I finish it in two years. :) If anyone has done
    > something similar, I'd love to hear about it.
    >
    > Reed
    >
    > ----------------------------------------------------------------------
    > Dr. Reed L. Riddle
    > Assistant Director of Whole Earth Telescope Operations
    > Iowa State University Department of Physics & Astronomy
    > Email: drriddle@qwest.net
    > Homepage: http://www.iitap.iastate.edu/~riddle/
    >
    > "This life has been a test. If it had been an actual life, you would
    > have received actual instructions on where to go and what to do."
    > -- Angela Chase, "My so-called life"
    >
    > _________________________________________________
    > To unsubscribe, send the message "unsubscribe" to
    > xforms-request@bob.usuhs.mil or see
    > http://bob.usuhs.mil/mailserv/xforms.html
    > XForms Home Page: http://world.std.com/~xforms
    > List Archive: http://bob.usuhs.mil/mailserv/list-archives/
    >

    __________________________________________________
    Do You Yahoo!?
    Yahoo! - Official partner of 2002 FIFA World Cup
    http://fifaworldcup.yahoo.com
    _________________________________________________
    To unsubscribe, send the message "unsubscribe" to
    xforms-request@bob.usuhs.mil or see
    http://bob.usuhs.mil/mailserv/xforms.html
    XForms Home Page: http://world.std.com/~xforms
    List Archive: http://bob.usuhs.mil/mailserv/list-archives/



    This archive was generated by hypermail 2b29 : Thu Jun 06 2002 - 14:59:52 EDT