diff options
| author | Maximilian Albert <maximilian.albert@gmail.com> | 2008-01-09 02:40:03 +0000 |
|---|---|---|
| committer | cilix42 <cilix42@users.sourceforge.net> | 2008-01-09 02:40:03 +0000 |
| commit | e02a2538ec72f8d8aaaab5f62b5fb57da9ca1cdc (patch) | |
| tree | 2b7f78d4304636620999003baa1efd7601f942d7 /src/box3d.cpp | |
| parent | Khmer translations updated (diff) | |
| download | inkscape-e02a2538ec72f8d8aaaab5f62b5fb57da9ca1cdc.tar.gz inkscape-e02a2538ec72f8d8aaaab5f62b5fb57da9ca1cdc.zip | |
Convert 3D boxes to ordinary groups before tweaking, ungrouping or applying 'convert to path' (closes LP #179693 and #176646).
(bzr r4439)
Diffstat (limited to 'src/box3d.cpp')
| -rw-r--r-- | src/box3d.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/box3d.cpp b/src/box3d.cpp index 3fe9787e3..545c58105 100644 --- a/src/box3d.cpp +++ b/src/box3d.cpp @@ -1452,6 +1452,39 @@ box3d_switch_perspectives(SPBox3D *box, Persp3D *old_persp, Persp3D *new_persp, g_free(href); } +/* Converts the 3D box to an ordinary SPGroup, adds it to the XML tree at the same position as + the original box and deletes the latter */ +// TODO: Copy over all important attributes (see sp_selected_item_to_curved_repr() for an example) +SPGroup * +box3d_convert_to_group(SPBox3D *box) { + SPDocument *doc = SP_OBJECT_DOCUMENT(box); + Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); + + // remember position of the box + int pos = SP_OBJECT_REPR(box)->position(); + + // create a new group and add the sides (converted to ordinary paths) as its children + Inkscape::XML::Node *grepr = xml_doc->createElement("svg:g"); + + Inkscape::XML::Node *repr; + for (SPObject *child = sp_object_first_child(SP_OBJECT(box)); child != NULL; child = SP_OBJECT_NEXT(child) ) { + if (SP_IS_BOX3D_SIDE(child)) { + repr = box3d_side_convert_to_path(SP_BOX3D_SIDE(child)); + grepr->appendChild(repr); + } else { + g_warning("Non-side object encountered as child of a 3D box.\n"); + } + } + + // add the new group to the box's parent and set remembered position + SPObject *parent = SP_OBJECT_PARENT(box); + SP_OBJECT_REPR(parent)->appendChild(grepr); + grepr->setPosition(pos); + + SP_OBJECT(box)->deleteObject(true); + + return SP_GROUP(doc->getObjectByRepr(grepr)); +} /* Local Variables: |
