Re: hi

"Eric M. Monsler" <[email protected]>
Newsgroups gmane.comp.scigraphica.gtkextra
Message-ID <[email protected]>
john wrote:
(snip)
> make a gtk_window
> make new canvas and plot widgets, plot the data i have, and add it 
> to the window
> if the user requests new data to be graphed, i destroy the canvas and plot
> widget, make new canvas and plot widgets, plot the data i have, and add it 
> to the old window
> 
> this seems to work for the first few times, however, after a while, the 
> canvas and plot would no longer show up. when i click on the region, the 
> widgets seem to be there but hidden from view (all i can see is the window 
> widget and gray inside).
> 
> i was wondering if anyone has run into this problem before ...
> 

No, but I can tell you that you're working way harder than you need to 
to change the data.

I do:

       /* Now, update plot data (whew!) */
       gtk_plot_data_set_numpoints(pXYPState->apGtkPlotData[0], 
iPointsToPlot);
       gtk_plot_data_set_x(pXYPState->apGtkPlotData[0],
			  pXYPState->paAVPlotData[0].x_data);
       gtk_plot_data_set_y(pXYPState->apGtkPlotData[0],
			  pXYPState->paAVPlotData[0].y_data);

and the new data is applied.  The apGtkPlotData is the return from 
initialization time call:

pXYPState->apGtkPlotData[0] = GTK_PLOT_DATA(gtk_plot_data_new());

which I had previously added to the plot with:

   /* Add data to plot (dataset should be empty). Show plot layer */
   gtk_plot_add_data(GTK_PLOT(pPlotLayer),pXYPState->apGtkPlotData[0]);
   gtk_plot_autoscale(GTK_PLOT(pPlotLayer));
   gtk_widget_show(pPlotLayer);


So, when new data arrives I update my arrays of x_data and y_data, and 
then just tell gtk_plot_ routines how many points, and the x and y sets.

Then I cause repaint, refresh, etc.  The gdk_flush() call below should 
not be required, but I was getting errors with crappy Win32 X-servers 
until I added it.


       gtk_plot_canvas_paint(GTK_PLOT_CANVAS(pXYPState->pPlotCanvas));

       /* This flush has caught X errors */
       gdk_flush();

       gtk_plot_canvas_refresh(GTK_PLOT_CANVAS(pXYPState->pPlotCanvas));

       /* This flush commented out, as the prev. flush caught an error */
       /* gdk_flush(); */
	
#if 0
       g_message("XYPlot refreshed with %d points",iPointsToPlot);
#endif

       gtk_widget_show(pXYPState->pXYPWin);


I think that all of the above came out of the so-called 'realtime' demo 
in the gtkextra distribution.

HTH,

Eric



-------------------------------------------------------
This SF.net email is sponsored by: ObjectStore.
If flattening out C++ or Java code to make your application fit in a
relational database is painful, don't do it! Check out ObjectStore.
Now part of Progress Software. http://www.objectstore.net/sourceforge
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.