summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbulia byak <buliabyak@gmail.com>2008-02-25 10:11:26 +0000
committerbuliabyak <buliabyak@users.sourceforge.net>2008-02-25 10:11:26 +0000
commit339b65b1a02890ff07daedf9091a81e8f9737d10 (patch)
treeac153c7d9f5a3c8b10bc8436acecfe64c5b50dad /src
parentfix-render-of-zero-dimension-rects (diff)
downloadinkscape-339b65b1a02890ff07daedf9091a81e8f9737d10.tar.gz
inkscape-339b65b1a02890ff07daedf9091a81e8f9737d10.zip
fix converting 3d boxes to path and ungrouping - do not lose selection, preserve style, id and clip/mask
(bzr r4849)
Diffstat (limited to 'src')
-rw-r--r--src/box3d.cpp21
-rw-r--r--src/box3d.h2
-rw-r--r--src/path-chemistry.cpp13
-rw-r--r--src/sp-item-group.cpp12
4 files changed, 32 insertions, 16 deletions
diff --git a/src/box3d.cpp b/src/box3d.cpp
index 7f52abd8c..5beee4acc 100644
--- a/src/box3d.cpp
+++ b/src/box3d.cpp
@@ -1336,8 +1336,7 @@ box3d_switch_perspectives(SPBox3D *box, Persp3D *old_persp, Persp3D *new_persp,
/* 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 *
+Inkscape::XML::Node *
box3d_convert_to_group(SPBox3D *box) {
SPDocument *doc = SP_OBJECT_DOCUMENT(box);
Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
@@ -1345,6 +1344,13 @@ box3d_convert_to_group(SPBox3D *box) {
// remember position of the box
int pos = SP_OBJECT_REPR(box)->position();
+ // remember important attributes
+ Inkscape::XML::Node *repr_source = SP_OBJECT_REPR(box);
+ gchar const *id = repr_source->attribute("id");
+ gchar const *style = repr_source->attribute("style");
+ gchar const *mask = repr_source->attribute("mask");
+ gchar const *clip_path = repr_source->attribute("clip-path");
+
// create a new group and add the sides (converted to ordinary paths) as its children
Inkscape::XML::Node *grepr = xml_doc->createElement("svg:g");
@@ -1354,7 +1360,7 @@ box3d_convert_to_group(SPBox3D *box) {
repr = box3d_side_convert_to_path(SP_BOX3D_SIDE(child));
grepr->appendChild(repr);
} else {
- g_warning("Non-side item encountered as child of a 3D box.\n");
+ g_warning("Non-side item encountered as child of a 3D box.");
}
}
@@ -1362,10 +1368,17 @@ box3d_convert_to_group(SPBox3D *box) {
SPObject *parent = SP_OBJECT_PARENT(box);
SP_OBJECT_REPR(parent)->appendChild(grepr);
grepr->setPosition(pos);
+ grepr->setAttribute("style", style);
+ if (mask)
+ grepr->setAttribute("mask", mask);
+ if (clip_path)
+ grepr->setAttribute("clip-path", clip_path);
SP_OBJECT(box)->deleteObject(true);
- return SP_GROUP(doc->getObjectByRepr(grepr));
+ grepr->setAttribute("id", id);
+
+ return grepr;
}
static inline void
diff --git a/src/box3d.h b/src/box3d.h
index 2fbf224a5..d9fd540b6 100644
--- a/src/box3d.h
+++ b/src/box3d.h
@@ -77,7 +77,7 @@ void box3d_mark_transformed(SPBox3D *box);
Persp3D *box3d_get_perspective(SPBox3D const *box);
void box3d_switch_perspectives(SPBox3D *box, Persp3D *old_persp, Persp3D *new_persp, bool recompute_corners = false);
-SPGroup *box3d_convert_to_group(SPBox3D *box);
+Inkscape::XML::Node *box3d_convert_to_group(SPBox3D *box);
#endif /* __SP_BOX3D_H__ */
diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp
index 254a00e27..7466a7066 100644
--- a/src/path-chemistry.cpp
+++ b/src/path-chemistry.cpp
@@ -297,12 +297,13 @@ sp_selected_path_to_curves0(gboolean interactive, guint32 /*text_grouping_policy
if (SP_IS_BOX3D(item)) {
// convert 3D box to ordinary group of paths; replace the old element in 'selected' with the new group
- GSList *sel_it = g_slist_find(selected, item);
- sel_it->data = box3d_convert_to_group(SP_BOX3D(item));
- item = SP_ITEM(sel_it->data);
-
- did = true;
- selected = g_slist_remove (selected, item);
+ Inkscape::XML::Node *repr = box3d_convert_to_group(SP_BOX3D(item));
+
+ if (repr) {
+ to_select = g_slist_prepend (to_select, repr);
+ did = true;
+ selected = g_slist_remove (selected, item);
+ }
continue;
}
diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp
index ac7aee1d4..5ae5713ca 100644
--- a/src/sp-item-group.cpp
+++ b/src/sp-item-group.cpp
@@ -329,11 +329,13 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done)
SPItem *pitem = SP_ITEM (SP_OBJECT_PARENT (gitem));
Inkscape::XML::Node *prepr = SP_OBJECT_REPR (pitem);
- if (SP_IS_BOX3D(gitem)) {
- group = box3d_convert_to_group(SP_BOX3D(gitem));
- gitem = SP_ITEM(group);
- grepr = SP_OBJECT_REPR(gitem);
- }
+ if (SP_IS_BOX3D(gitem)) {
+ grepr = box3d_convert_to_group(SP_BOX3D(gitem));
+ if (grepr) {
+ gitem = SP_ITEM(doc->getObjectByRepr(grepr));
+ group = SP_GROUP(gitem);
+ }
+ }
/* Step 1 - generate lists of children objects */
GSList *items = NULL;