Esempio n. 1
0
static gsize
gwy_3d_setup_get_size(GObject *object)
{
    Gwy3DSetup *setup;

    gwy_debug("");
    g_return_val_if_fail(GWY_IS_3D_SETUP(object), 0);

    setup = GWY_3D_SETUP(object);
    {
        GwySerializeSpec spec[] = {
            { 'i', "projection", &setup->projection, NULL, },
            { 'i', "visualization", &setup->visualization, NULL, },
            { 'b', "axes-visible", &setup->axes_visible, NULL, },
            { 'b', "labels-visible", &setup->labels_visible, NULL, },
            { 'd', "rotation-x", &setup->rotation_x, NULL, },
            { 'd', "rotation-y", &setup->rotation_y, NULL, },
            { 'd', "scale", &setup->scale, NULL, },
            { 'd', "z-scale", &setup->z_scale, NULL, },
            { 'd', "light-phi", &setup->light_phi, NULL, },
            { 'd', "light-theta", &setup->light_theta, NULL, },
        };

        return gwy_serialize_get_struct_size(GWY_3D_SETUP_TYPE_NAME,
                                             G_N_ELEMENTS(spec), spec);
    }
}
Esempio n. 2
0
static gsize
gwy_si_unit_get_size(GObject *obj)
{
    GwySIUnit *si_unit;
    gsize size;

    g_return_val_if_fail(GWY_IS_SI_UNIT(obj), 0);

    si_unit = GWY_SI_UNIT(obj);
    size = gwy_serialize_get_struct_size(GWY_SI_UNIT_TYPE_NAME, 0, NULL);
    /* Just estimate */
    size += 20*si_unit->units->len;

    return size;
}
Esempio n. 3
0
static gsize
gwy_spectra_get_size(GObject *obj)
{
    GwySpectra *spectra;
    GwyDataLine **curves;
    gdouble *coords;
    guint32 *selected;
    guint32 ncurves, ncoords, nselected;
    gsize retval;

    gwy_debug("");
    g_return_val_if_fail(GWY_IS_SPECTRA(obj), 0);

    spectra = GWY_SPECTRA(obj);
    if (!spectra->si_unit_xy)
        spectra->si_unit_xy = gwy_si_unit_new(NULL);

    separate_arrays(spectra->spectra,
                    &ncurves, &curves,
                    &ncoords, &coords,
                    &nselected, &selected);

    {
        GwySerializeSpec spec[] = {
            { 's', "title",       &spectra->title,       NULL,       },
            { 'o', "si_unit_xy",  &spectra->si_unit_xy,  NULL,       },
            { 'D', "coords",      &coords,               &ncoords,   },
            { 'I', "selected",    &selected,             &nselected, },
            { 'O', "data",        &curves,               &ncurves,   },
            { 's', "spec_xlabel", &spectra->spec_xlabel, NULL,       },
            { 's', "spec_ylabel", &spectra->spec_ylabel, NULL,       },
        };
        guint nspec = fix_serialisation_spec(spec);

        retval = gwy_serialize_get_struct_size(GWY_SPECTRA_TYPE_NAME,
                                               nspec, spec);
    }
    g_free(curves);
    g_free(coords);
    g_free(selected);

    return retval;
}
Esempio n. 4
0
static gsize
gwy_surface_get_size(GObject *obj)
{
    GwySurface *surface;
    guint32 datasize;

    g_return_val_if_fail(GWY_IS_SURFACE(obj), 0);

    surface = GWY_SURFACE(obj);
    ensure_units(surface);
    datasize = 3*surface->n;
    {
        GwySerializeSpec spec[] = {
            { 'o', "si_unit_xy", &surface->priv->si_unit_xy, NULL, },
            { 'o', "si_unit_z", &surface->priv->si_unit_z, NULL, },
            { 'D', "data", &surface->data, &datasize, },
        };
        return gwy_serialize_get_struct_size(GWY_SURFACE_TYPE_NAME,
                                             G_N_ELEMENTS(spec), spec);
    }
}
Esempio n. 5
0
static gsize
gwy_string_list_get_size(GObject *obj)
{
    GwyStringList *strlist;
    GPtrArray *strings;
    gsize size;

    g_return_val_if_fail(GWY_IS_STRING_LIST(obj), 0);

    strlist = GWY_STRING_LIST(obj);
    strings = (GPtrArray*)strlist->strings;
    {
        guint32 len = strings->len;
        GwySerializeSpec spec[] = {
            { 'S', "strings", &strings->pdata, &len, },
        };
        size = gwy_serialize_get_struct_size(GWY_STRING_LIST_TYPE_NAME,
                                             G_N_ELEMENTS(spec), spec);
    }

    return size;
}