Logo Search packages:      
Sourcecode: inkscape version File versions

SPObject * Inkscape::create_layer ( SPObject *  root,
SPObject *  layer 

Creates a new layer. Advances to the next layer id indicated by the string "layerNN", then creates a new group object of that id with attribute inkscape:groupmode='layer', and finally appends the new group object to root after object layer.

root should be either layer or an ancestor of it

Definition at line 31 of file layer-fns.cpp.

    SPDocument *document=SP_OBJECT_DOCUMENT(root);

    static int layer_suffix=1;
    gchar *id=NULL;
    do {
        id = g_strdup_printf("layer%d", layer_suffix++);
    } while (document->getObjectById(id));

    SPRepr *repr=sp_repr_new("svg:g");
    sp_repr_set_attr(repr, "inkscape:groupmode", "layer");
    sp_repr_set_attr(repr, "id", id);

    if ( root == layer ) {
        sp_repr_append_child(SP_OBJECT_REPR(root), repr);
    } else {
        SPRepr *layer_repr=SP_OBJECT_REPR(layer);
        sp_repr_add_child(sp_repr_parent(layer_repr), repr, layer_repr);

    return document->getObjectByRepr(repr);

Generated by  Doxygen 1.6.0   Back to index