void SPLPEItem::apply_to_clippath(SPItem *item) { SPClipPath *clipPath = item->clip_ref->getObject(); if(clipPath) { SPObject * clip_data = clipPath->firstChild(); SPCurve * clip_curve = NULL; if (SP_IS_PATH(clip_data)) { clip_curve = SP_PATH(clip_data)->get_original_curve(); } else if(SP_IS_SHAPE(clip_data)) { clip_curve = SP_SHAPE(clip_data)->getCurve(); } else if(SP_IS_GROUP(clip_data)) { apply_to_clip_or_mask_group(SP_ITEM(clip_data), item); return; } if(clip_curve) { bool success = false; if(SP_IS_GROUP(this)){ clip_curve->transform(i2anc_affine(SP_GROUP(item), SP_GROUP(this))); success = this->performPathEffect(clip_curve); clip_curve->transform(i2anc_affine(SP_GROUP(item), SP_GROUP(this)).inverse()); } else { success = this->performPathEffect(clip_curve); } Inkscape::XML::Node *reprClip = clip_data->getRepr(); if (success) { gchar *str = sp_svg_write_path(clip_curve->get_pathvector()); reprClip->setAttribute("d", str); g_free(str); } else { // LPE was unsuccesfull. Read the old 'd'-attribute. if (gchar const * value = reprClip->attribute("d")) { Geom::PathVector pv = sp_svg_read_pathv(value); SPCurve *oldcurve = new SPCurve(pv); if (oldcurve) { SP_SHAPE(clip_data)->setCurve(oldcurve, TRUE); oldcurve->unref(); } } } clip_curve->unref(); } } if(SP_IS_GROUP(item)){ GSList const *item_list = sp_item_group_item_list(SP_GROUP(item)); for ( GSList const *iter = item_list; iter; iter = iter->next ) { SPObject *subitem = static_cast<SPObject *>(iter->data); apply_to_clippath(SP_ITEM(subitem)); } } }
static void sp_conn_get_route_and_redraw(SPPath *const path, const bool updatePathRepr = true) { // Get the new route around obstacles. bool rerouted = path->connEndPair.reroutePathFromLibavoid(); if (!rerouted) { return; } SPItem *h2attItem[2] = {0}; path->connEndPair.getAttachedItems(h2attItem); SPObject const *const ancestor = get_nearest_common_ancestor(path, h2attItem); Geom::Affine const path2anc(i2anc_affine(path, ancestor)); // Set sensible values incase there the connector ends are not // attached to any shapes. Geom::PathVector conn_pv = path->_curve->get_pathvector(); double endPos[2] = { 0.0, static_cast<double>(conn_pv[0].size()) }; for (unsigned h = 0; h < 2; ++h) { // Assume center point for all if (h2attItem[h]) { Geom::Affine h2i2anc = i2anc_affine(h2attItem[h], ancestor); try_get_intersect_point_with_item(path, h2attItem[h], h2i2anc, path2anc, (h == 0), endPos[h]); } } change_endpts(path->_curve, endPos); if (updatePathRepr) { path->updateRepr(); path->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } }