Logo Search packages:      
Sourcecode: inkscape version File versions  Download package

static Inkscape::XML::Node * sp_filter_write ( SPObject object,
Inkscape::XML::Document doc,
Inkscape::XML::Node repr,
guint  flags 
) [static]

Writes its settings to an incoming repr object, if any.

Definition at line 284 of file sp-filter.cpp.

References Inkscape::XML::Node::addChild(), Inkscape::XML::Document::createElement(), Inkscape::GC::release(), Inkscape::XML::Node::setAttribute(), sp_repr_set_svg_double(), and SPObject::updateRepr().

{
    SPFilter *filter = SP_FILTER(object);
    SPObject *child;
    Inkscape::XML::Node *crepr;

    /* Original from sp-item-group.cpp */
    if (flags & SP_OBJECT_WRITE_BUILD) {
        GSList *l;
        if (!repr) {
            repr = doc->createElement("svg:filter");
        }
        l = NULL;
        for (child = sp_object_first_child(object); child != NULL; child = SP_OBJECT_NEXT(child) ) {
            crepr = child->updateRepr(doc, NULL, flags);
            if (crepr) l = g_slist_prepend (l, crepr);
        }
        while (l) {
            repr->addChild((Inkscape::XML::Node *) l->data, NULL);
            Inkscape::GC::release((Inkscape::XML::Node *) l->data);
            l = g_slist_remove (l, l->data);
        }
    } else {
        for (child = sp_object_first_child(object) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
            child->updateRepr(flags);
        }
    }

    if ((flags & SP_OBJECT_WRITE_ALL) || filter->filterUnits_set) {
        switch (filter->filterUnits) {
            case SP_FILTER_UNITS_USERSPACEONUSE:
                repr->setAttribute("filterUnits", "userSpaceOnUse");
                break;
            default:
                repr->setAttribute("filterUnits", "objectBoundingBox");
                break;
        }
    }

    if ((flags & SP_OBJECT_WRITE_ALL) || filter->primitiveUnits_set) {
        switch (filter->primitiveUnits) {
            case SP_FILTER_UNITS_OBJECTBOUNDINGBOX:
                repr->setAttribute("primitiveUnits", "objectBoundingBox");
                break;
            default:
                repr->setAttribute("primitiveUnits", "userSpaceOnUse");
                break;
        }
    }

    if (filter->x._set) {
        sp_repr_set_svg_double(repr, "x", filter->x.computed);
    } else {
        repr->setAttribute("x", NULL);
    }

    if (filter->y._set) {
        sp_repr_set_svg_double(repr, "y", filter->y.computed);
    } else {
        repr->setAttribute("y", NULL);
    }

    if (filter->width._set) {
        sp_repr_set_svg_double(repr, "width", filter->width.computed);
    } else {
        repr->setAttribute("width", NULL);
    }

    if (filter->height._set) {
        sp_repr_set_svg_double(repr, "height", filter->height.computed);
    } else {
        repr->setAttribute("height", NULL);
    }

    if (filter->filterRes.getNumber()>=0) {
        gchar *tmp = filter->filterRes.getValueString();
        repr->setAttribute("filterRes", tmp);
        g_free(tmp);
    } else {
        repr->setAttribute("filterRes", NULL);
    }

    if (filter->href->getURI()) {
        gchar *uri_string = filter->href->getURI()->toString();
        repr->setAttribute("xlink:href", uri_string);
        g_free(uri_string);
    }

    // TODO: This is evil, correctly implement support for color-interpolation-filters!!!
    // The color-interpolation-filters attribute is initially set to linearRGB according to the SVG standard.
    // However, Inkscape completely ignores it and implicitly assumes that it is sRGB (like color-interpolation-filters).
    // This results in a discrepancy between Inkscape and other renderers in how they render filters.
    // To mitigate this problem I've (Jasper van de Gronde,th.v.d.gronde@hccnet.nl) added this to ensure that at least
    // any filters written by Inkscape will henceforth be rendered the same in other renderers.
    // In the future Inkscape should have proper support for the color-interpolation properties and this should be changed.
    repr->setAttribute("color-interpolation-filters", "sRGB");

    if (((SPObjectClass *) filter_parent_class)->write) {
        ((SPObjectClass *) filter_parent_class)->write(object, doc, repr, flags);
    }

    return repr;
}


Generated by  Doxygen 1.6.0   Back to index