How to most efficiently add points to a dataset?
Al Hooton <[email protected]> Sun, 28 Nov 2004 21:18:21 -0800
| Newsgroups | gmane.comp.scigraphica.gtkextra |
|---|---|
| Message-ID | <[email protected]> |
All, I have a situation where I need to start out putting a dataset in a plot that has a single point, then add a subsequent point every several seconds. Each point is calculated so it is only one pixel to the left of the point before it. There are no connectors, just an ever-growing dataset of points. Currently, I do this as such: INIT: canvas = gtk_plot_canvas_new(....) plot = gtk_plot_new_with_size(.....) plotChild = gtk_plot_canvas_plot_new(plot) gtk_plot_canvas_put_child(canvas, plotChild, ......) dataset = gtk_plot_data_new(...) gtk_plot_add_data(plot, dataset) gtk_plot_data_set_points(dataset, X, Y, D, ......) (Above, there is only a single point in X, Y and D) EACH TIME I NEED TO ADD A POINT, EVERY FEW SECONDS: gtk_plot_remove_data(plot, dataset) dataset = gtk_plot_data_new(...) gtk_plot_add_data(plot, dataset) gtk_plot_data_set_points(dataset, X, Y, D, ......) Above, X, Y, and D grow by one point each time -------------- This works, for a while, but after I get 50 to 100 points in the datasets, it starts getting very slow. At a certain point, the UI process in my app (which is running this code) starts consuming all the processor just trying to deal with me constantly ripping datasets out of the plot and replacing them. I have been through the gtkextra-2 code, and I can't see a better way, but I *know* there has to be one! Can anybody provide a pointer to a better way of doing this? Thanks! -Al ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/