Ejemplo n.º 1
0
void coords_changed(MtxCurve *curve, gpointer data)
{
	gint index = mtx_curve_get_active_coord_index(curve);
	MtxCurveCoord point;
	mtx_curve_get_coords_at_index(curve,index,&point);
	/*printf("changed coord %i, to %.1f,%.1f\n",index,point.x,point.y);*/
	
}
Ejemplo n.º 2
0
/*! 
  \brief signal handler to deal with the user clicking on the curve and moving
  the vertex, which thus updates the corresponding entry
  \param curve is the pointer to the curve object
  \param data is unused
  */
G_MODULE_EXPORT void coords_changed(GtkWidget *curve, gpointer data)
{
	MtxCurveCoord point;
	gint index = 0;
	GArray *array;
	gint precision = 0;
	GtkWidget *entry = NULL;
	gchar * tmpbuf = NULL;

	index = mtx_curve_get_active_coord_index(MTX_CURVE(curve));
	mtx_curve_get_coords_at_index(MTX_CURVE(curve),index,&point);

	if(!mtx_curve_get_x_axis_lock_state(MTX_CURVE(curve)))
	{
		/* X Coord */
		array = OBJ_GET(curve,"x_entries");
		entry = g_array_index(array,GtkWidget *,index);
		precision = (GINT)OBJ_GET(entry, "precision");
		tmpbuf = g_strdup_printf("%1$.*2$f",point.x,precision);
		gtk_entry_set_text(GTK_ENTRY(entry),tmpbuf);
		g_signal_emit_by_name(entry, "activate");
		g_free(tmpbuf);
	}
Ejemplo n.º 3
0
/*!
  \brief updates the curve with new data from the corresponding text entry
  This extracts the curve axis and index from the widget in order to know 
  which vertex of the curve to change
  \param widget is hte entry that was changed via the user
  \param data is a pointer to the curve to update
  \returns FALSE
  */
G_MODULE_EXPORT gboolean update_2d_curve(GtkWidget *widget, gpointer data)
{
	GtkWidget *curve = (GtkWidget *)data;
	MtxCurveCoord point;
	Axis axis;
	gint index = 0;
	gchar * text = NULL;
	gfloat tmpf = 0.0;

	index = (GINT) OBJ_GET(widget,"curve_index");
	axis = (Axis) OBJ_GET(widget,"curve_axis");
	mtx_curve_get_coords_at_index(MTX_CURVE(curve),index,&point);
	text = gtk_editable_get_chars(GTK_EDITABLE(widget),0,-1);
	tmpf = (gfloat)strtod(g_strdelimit(text,",.",'.'),NULL);
	if (axis == _X_)
		point.x = tmpf;
	else if (axis == _Y_)
		point.y = tmpf;
	else
		printf(_("ERROR in update_2d_curve()!!!\n"));
	mtx_curve_set_coords_at_index(MTX_CURVE(curve),index,point);
	return FALSE;
}