void SPLPEItem::addPathEffect(gchar *value, bool reset) { if (value) { // Apply the path effects here because in the casse of a group, lpe->resetDefaults // needs that all the subitems have their effects applied sp_lpe_item_update_patheffect(this, false, true); // Disable the path effects while preparing the new lpe sp_lpe_item_enable_path_effects(this, false); // Add the new reference to the list of LPE references HRefList hreflist; for (PathEffectList::const_iterator it = this->path_effect_list->begin(); it != this->path_effect_list->end(); ++it) { hreflist.push_back( std::string((*it)->lpeobject_href) ); } hreflist.push_back( std::string(value) ); std::string hrefs = hreflist_write_svg(hreflist); this->getRepr()->setAttribute("inkscape:path-effect", hrefs.c_str()); // Make sure that ellipse is stored as <svg:path> if( SP_IS_GENERICELLIPSE(this)) { SP_GENERICELLIPSE(this)->write( this->getRepr()->document(), this->getRepr(), SP_OBJECT_WRITE_EXT ); } // make sure there is an original-d for paths!!! sp_lpe_item_create_original_path_recursive(this); LivePathEffectObject *lpeobj = this->path_effect_list->back()->lpeobject; if (lpeobj && lpeobj->get_lpe()) { Inkscape::LivePathEffect::Effect *lpe = lpeobj->get_lpe(); // Ask the path effect to reset itself if it doesn't have parameters yet if (reset) { // has to be called when all the subitems have their lpes applied lpe->resetDefaults(this); } // perform this once when the effect is applied lpe->doOnApply(this); // indicate that all necessary preparations are done and the effect can be performed lpe->setReady(); } //Enable the path effects now that everything is ready to apply the new path effect sp_lpe_item_enable_path_effects(this, true); // Apply the path effect sp_lpe_item_update_patheffect(this, true, true); //fix bug 1219324 if (SP_ACTIVE_DESKTOP ) { Inkscape::UI::Tools::ToolBase *ec = SP_ACTIVE_DESKTOP->event_context; if (INK_IS_NODE_TOOL(ec)) { tools_switch(SP_ACTIVE_DESKTOP, TOOLS_LPETOOL); //mhh tools_switch(SP_ACTIVE_DESKTOP, TOOLS_NODES); } } } }
void LPESimplify::doEffect(SPCurve *curve) { Geom::PathVector const original_pathv = pathv_to_linear_and_cubic_beziers(curve->get_pathvector()); gdouble size = Geom::L2(bbox->dimensions()); //size /= Geom::Affine(0,0,0,0,0,0).descrim(); Path* pathliv = Path_for_pathvector(original_pathv); if(simplify_individual_paths) { size = Geom::L2(Geom::bounds_fast(original_pathv)->dimensions()); } size /= sp_lpe_item->i2doc_affine().descrim(); for (int unsigned i = 0; i < steps; i++) { if ( simplify_just_coalesce ) { pathliv->Coalesce(threshold * size); } else { pathliv->ConvertEvenLines(threshold * size); pathliv->Simplify(threshold * size); } } Geom::PathVector result = Geom::parse_svg_path(pathliv->svg_dump_path()); generateHelperPathAndSmooth(result); curve->set_pathvector(result); SPDesktop* desktop = SP_ACTIVE_DESKTOP; if(desktop && INK_IS_NODE_TOOL(desktop->event_context)) { Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>(desktop->event_context); nt->update_helperpath(); } }