| Top |
| GwyValueFormat * | gwy_value_format_new () |
| GwyValueFormat * | gwy_value_format_copy () |
| void | gwy_value_format_free () |
| void | gwy_value_format_assign () |
| void | gwy_value_format_set_units () |
| void | gwy_value_format_clear () |
GwyValueFormat object represents instructions how to format numbers representing physical quantities, including
precision and units. They are usually created based on a GwyUnit and some data ranges with functions such as
gwy_unit_get_format_with_resolution() or gwy_unit_get_format_with_digits(). Various data objects also offer
method for obtaining value formats representing reasonably their coordinates or values, for instance
gwy_field_get_value_format_xy().
GwyValueFormat * gwy_value_format_new (gdouble magnitude,gint precision,const gchar *units);
Constructs a new value format directly.
Usually you construct value formats from a GwyUnit using functions such as gwy_unit_get_format_with_digits()
or obtain it from data object functions.
GwyValueFormat *
gwy_value_format_copy (GwyValueFormat *format);
Copies a value format structure.
void
gwy_value_format_free (GwyValueFormat *format);
Frees a value format structure.
void gwy_value_format_assign (GwyValueFormat *format,GwyValueFormat *source);
Assigns a value format from another.
void gwy_value_format_set_units (GwyValueFormat *format,const gchar *units);
Sets the units field of a value format structure.
This function keeps the units
and units_gstring
fields consistent.
void
gwy_value_format_clear (GwyValueFormat *format);
Clears a value format structure.
The magnitude becomes 1, the unit string becomes empty and the precision is set to a reasonable neutral value.
Often, the cleared format is not meant to be used for formatting numbers, although the empty unit part may be
still used to display empty units generically. Simply freeing the format and handling NULL formats can work
equally well. This function is most useful when you want to keep a single format around for a long time.
typedef struct {
gdouble magnitude;
gint precision;
gchar *units;
} GwyValueFormat;
A physical quantity formatting information.
The magnitude
and precision
fields can be directly modified if necessary. Units must be always set with
gwy_value_format_set_units() to update the internal representation correctly.