Exemple #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;
}
Exemple #2
0
/*!
  \brief Creates a stripchart widget (i.e. accel wizard)
  \param parent is the container for stripchart widget
  */
G_MODULE_EXPORT void create_stripchart(GtkWidget *parent)
{
	GtkWidget *chart = NULL;
	gchar ** sources = NULL;
	gchar * tmpbuf = NULL;
	guint i = 0;
	gconstpointer *object = NULL;
	gint min = 0;
	gint max = 0;
	gint precision = 0;
	gchar * name = NULL;
	DataSize size = MTX_U08;
	Rtv_Map *rtv_map;

	ENTER();
	rtv_map = (Rtv_Map *)DATA_GET(global_data,"rtv_map");
	tmpbuf = (gchar *)OBJ_GET(parent,"sources");
	if (tmpbuf);
		sources = g_strsplit(tmpbuf,",",-1);
	chart = mtx_stripchart_new();
	gtk_container_add(GTK_CONTAINER(parent), chart);
	//gtk_widget_realize(chart);
	for (i=0;i<g_strv_length(sources);i++)
	{
		if (!rtv_map)
			continue;
		object = (gconstpointer *)g_hash_table_lookup(rtv_map->rtv_hash,sources[i]);
		if (!object)
			continue;
		if ((gchar *)DATA_GET(object,"dlog_gui_name"))
			name = (gchar *)DATA_GET(object,"dlog_gui_name");
		else
			name = g_strdup("undefined!\n");
		if (DATA_GET(object,"real_lower"))
			min = (GINT)strtol((gchar *)DATA_GET(object,"real_lower"),NULL,10);
		else
			min = get_extreme_from_size(size,LOWER);
		if (DATA_GET(object,"real_upper"))
			max = (GINT)strtol((gchar *)DATA_GET(object,"real_upper"),NULL,10);
		else
			max = get_extreme_from_size(size,UPPER);
		if (DATA_GET(object,"precision"))
			precision = (GINT)DATA_GET(object,"precision");
		else
			precision = 0;
		mtx_stripchart_add_trace(MTX_STRIPCHART(chart),(gfloat)min,(gfloat)max,precision,name,NULL);
	}
	create_rtv_multi_value_historical_watch(sources,FALSE,"update_stripchart_data",chart);
	g_strfreev(sources);
	gtk_widget_show_all(parent);
	EXIT();
	return;
}