Ejemplo n.º 1
0
int main (int argc, char **argv)
{
	GtkWidget *window = NULL;
	GdkColor col = { 0,100,200,300};
	gint i = 0;
	gfloat j = 0.0;
	gint trace1 = 0;
	gint trace2 = 0;
	gint trace3 = 0;
	gfloat data[3] = {0.1,1.1,2.2};
	gint timeout = 0;

	gtk_init (&argc, &argv);

	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

	gtk_widget_set_size_request(GTK_WIDGET(window),320,320);
	chart = mtx_stripchart_new ();
	gtk_container_add (GTK_CONTAINER (window), chart);
	gtk_widget_realize(chart);
	trace1 = mtx_stripchart_add_trace(MTX_STRIPCHART(chart),-512.0,1536.0,0,"Trace 1", NULL);
	printf("trace 1's ID %i\n",trace1);
	trace2 = mtx_stripchart_add_trace(MTX_STRIPCHART(chart),-100.0,512.0,0,"Trace 2", NULL);
	printf("trace 2's ID %i\n",trace2);
	trace3 = mtx_stripchart_add_trace(MTX_STRIPCHART(chart),512.0,1024.0,1,"Trace 3", NULL);
	printf("trace 3's ID %i\n",trace3);
	for (j=0;j<1024;j+=2.5)
	{
		for (i=0;i<3;i++)
			data[i] = j;
		/*printf("setting values to %f, %f, %f\n",data[0],data[1],data[2]); */

		mtx_stripchart_set_values(MTX_STRIPCHART(chart),data);
	}
	mtx_stripchart_get_latest_values(MTX_STRIPCHART(chart),data);
/*	printf("latest values are %f, %f, %f\n",data[0],data[1],data[2]);*/


	/*mtx_stripchart_delete_trace(MTX_STRIPCHART(chart),trace2);*/

	

	timeout = g_timeout_add(40,(GSourceFunc)update_stripchart,(gpointer)chart);
/*	g_timeout_add(4000,(GSourceFunc)remove_trace,GINT_TO_POINTER(trace2));*/


	gtk_widget_show_all (window);


	g_signal_connect (window, "delete_event",
			G_CALLBACK (close_demo), GINT_TO_POINTER(timeout));
	g_signal_connect (window, "destroy_event",
			G_CALLBACK (close_demo), GINT_TO_POINTER(timeout));

	gtk_main ();
	return 0;
}
Ejemplo n.º 2
0
G_MODULE_EXPORT void update_stripchart_data(DataWatch* watch)
{
	mtx_stripchart_set_values(MTX_STRIPCHART(watch->user_data),watch->vals);
}