diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp
index 6ec5256eecba218495c671843454d2622ef122b1..186b766635f1115ee63e0817401f4fd83af249c5 100644 (file)
--- a/src/sp-item-group.cpp
+++ b/src/sp-item-group.cpp
#include <string>
#include "display/nr-arena-group.h"
+#include "display/curve.h"
#include "libnr/nr-matrix-ops.h"
#include "libnr/nr-matrix-fns.h"
#include "xml/repr.h"
#include "inkscape.h"
#include "desktop-handles.h"
#include "selection.h"
+#include "live_effects/lpeobject.h"
+#include "live_effects/lpeobject-reference.h"
static void sp_group_class_init (SPGroupClass *klass);
static void sp_group_init (SPGroup *group);
static void sp_group_order_changed (SPObject * object, Inkscape::XML::Node * child, Inkscape::XML::Node * old_ref, Inkscape::XML::Node * new_ref);
static void sp_group_update (SPObject *object, SPCtx *ctx, guint flags);
static void sp_group_modified (SPObject *object, guint flags);
-static Inkscape::XML::Node *sp_group_write (SPObject *object, Inkscape::XML::Node *repr, guint flags);
+static Inkscape::XML::Node *sp_group_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
static void sp_group_set(SPObject *object, unsigned key, char const *value);
static void sp_group_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags);
static void sp_group_snappoints (SPItem const *item, SnapPointsIter p);
static void sp_group_update_patheffect(SPLPEItem *lpeitem, bool write);
+static void sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup);
static SPLPEItemClass * parent_class;
item_class->show = sp_group_show;
item_class->hide = sp_group_hide;
item_class->snappoints = sp_group_snappoints;
-
+
lpe_item_class->update_patheffect = sp_group_update_patheffect;
}
static void
sp_group_modified (SPObject *object, guint flags)
{
+ if (((SPObjectClass *) (parent_class))->modified)
+ ((SPObjectClass *) (parent_class))->modified (object, flags);
+
SP_GROUP(object)->group->onModified(flags);
}
static Inkscape::XML::Node *
-sp_group_write (SPObject *object, Inkscape::XML::Node *repr, guint flags)
+sp_group_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
{
SPGroup *group;
SPObject *child;
if (flags & SP_OBJECT_WRITE_BUILD) {
GSList *l;
if (!repr) {
- Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object));
repr = xml_doc->createElement("svg:g");
}
l = NULL;
for (child = sp_object_first_child(object); child != NULL; child = SP_OBJECT_NEXT(child) ) {
- crepr = child->updateRepr(NULL, flags);
+ crepr = child->updateRepr(xml_doc, NULL, flags);
if (crepr) l = g_slist_prepend (l, crepr);
}
while (l) {
}
if (((SPObjectClass *) (parent_class))->write)
- ((SPObjectClass *) (parent_class))->write (object, repr, flags);
+ ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags);
return repr;
}
gitem = SP_ITEM(group);
}
- sp_lpe_item_remove_path_effect(SP_LPE_ITEM(group), false);
+ sp_lpe_item_remove_all_path_effects(SP_LPE_ITEM(group), false);
/* Step 1 - generate lists of children objects */
GSList *items = NULL;
if (objects) {
Inkscape::XML::Node *last_def = SP_OBJECT_REPR(defs)->lastChild();
while (objects) {
- SP_OBJECT_REPR(defs)->addChild((Inkscape::XML::Node *) objects->data, last_def);
- Inkscape::GC::release((Inkscape::XML::Node *) objects->data);
+ Inkscape::XML::Node *repr = (Inkscape::XML::Node *) objects->data;
+ if (!sp_repr_is_meta_element(repr))
+ SP_OBJECT_REPR(defs)->addChild(repr, last_def);
+ Inkscape::GC::release(repr);
objects = g_slist_remove (objects, objects->data);
}
}
SPItem *item = (SPItem *) doc->getObjectByRepr(repr);
sp_item_write_transform(item, repr, item->transform, NULL, false);
-
+
Inkscape::GC::release(repr);
if (children && SP_IS_ITEM (item))
*children = g_slist_prepend (*children, item);
items = g_slist_remove (items, items->data);
}
- if (do_done)
+ if (do_done)
sp_document_done (doc, SP_VERB_NONE, _("Ungroup"));
}
_group->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
-void CGroup::onUpdate(SPCtx *ctx, unsigned int flags) {
+void CGroup::onUpdate(SPCtx *ctx, unsigned int flags) {
SPItemCtx *ictx, cctx;
ictx = (SPItemCtx *) ctx;
}
void CGroup::calculateBBox(NRRect *bbox, NR::Matrix const &transform, unsigned const flags) {
-
- NR::Maybe<NR::Rect> dummy_bbox = NR::Nothing();
-
+
+ boost::optional<NR::Rect> dummy_bbox;
+
GSList *l = _group->childList(false, SPObject::ActionBBox);
while (l) {
SPObject *o = SP_OBJECT (l->data);
- if (SP_IS_ITEM(o)) {
+ if (SP_IS_ITEM(o) && !SP_ITEM(o)->isHidden()) {
SPItem *child = SP_ITEM(o);
NR::Matrix const ct(child->transform * transform);
sp_item_invoke_bbox_full(child, &dummy_bbox, ct, flags, FALSE);
- }
+ }
l = g_slist_remove (l, o);
}
-
+
*bbox = NRRect(dummy_bbox);
}
SPObject *o = SP_OBJECT (l->data);
if (SP_IS_ITEM(o)) {
sp_item_invoke_print (SP_ITEM (o), ctx);
- }
+ }
l = g_slist_remove (l, o);
}
}
len++;
}
}
-
+
return len;
}
for ( GSList const *iter = item_list; iter; iter = iter->next ) {
SPObject *subitem = static_cast<SPObject *>(iter->data);
if (SP_IS_LPE_ITEM(subitem)) {
- sp_lpe_item_update_patheffect(SP_LPE_ITEM(subitem), true);
+ if (SP_LPE_ITEM_CLASS (G_OBJECT_GET_CLASS (subitem))->update_patheffect) {
+ SP_LPE_ITEM_CLASS (G_OBJECT_GET_CLASS (subitem))->update_patheffect (SP_LPE_ITEM(subitem), write);
+ }
+ }
+ }
+
+ if (sp_lpe_item_has_path_effect(lpeitem) && sp_lpe_item_path_effects_enabled(lpeitem)) {
+ for (PathEffectList::iterator it = lpeitem->path_effect_list->begin(); it != lpeitem->path_effect_list->end(); it++)
+ {
+ LivePathEffectObject *lpeobj = (*it)->lpeobject;
+ lpeobj->lpe->doBeforeEffect(lpeitem);
}
+
+ sp_group_perform_patheffect(SP_GROUP(lpeitem), SP_GROUP(lpeitem));
}
}
+static void
+sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup)
+{
+ GSList const *item_list = sp_item_group_item_list(SP_GROUP(group));
+ for ( GSList const *iter = item_list; iter; iter = iter->next ) {
+ SPObject *subitem = static_cast<SPObject *>(iter->data);
+ if (SP_IS_GROUP(subitem)) {
+ sp_group_perform_patheffect(SP_GROUP(subitem), topgroup);
+ } else if (SP_IS_SHAPE(subitem)) {
+ SPCurve * c = sp_shape_get_curve(SP_SHAPE(subitem));
+ sp_lpe_item_perform_path_effect(SP_LPE_ITEM(topgroup), c);
+ sp_shape_set_curve(SP_SHAPE(subitem), c, TRUE);
+
+ Inkscape::XML::Node *repr = SP_OBJECT_REPR(subitem);
+
+ gchar *str = sp_svg_write_path(c->get_pathvector());
+ repr->setAttribute("d", str);
+ g_free(str);
+
+ c->unref();
+ }
+ }
+}
/*
Local Variables: