Esempio n. 1
0
static void sp_simplify_flatten(GtkWidget * /*widget*/, GObject *obj)
{
    SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data(obj, "desktop"));
    std::vector<SPItem *> selected = desktop->getSelection()->itemList();
    for (std::vector<SPItem *>::iterator it(selected.begin()); it != selected.end(); ++it){
        SPLPEItem* lpeitem = dynamic_cast<SPLPEItem*>(*it);
        if (lpeitem && lpeitem->hasPathEffect()){
            PathEffectList lpelist = lpeitem->getEffectList();
            std::list<Inkscape::LivePathEffect::LPEObjectReference *>::iterator i;
            for (i = lpelist.begin(); i != lpelist.end(); ++i) {
                LivePathEffectObject *lpeobj = (*i)->lpeobject;
                if (lpeobj) {
                    Inkscape::LivePathEffect::Effect *lpe = lpeobj->get_lpe();
                    if (dynamic_cast<Inkscape::LivePathEffect::LPESimplify *>(lpe)) {
                        SPShape * shape = dynamic_cast<SPShape *>(lpeitem);
                        if(shape){
                            SPCurve * c = shape->getCurveBeforeLPE();
                            lpe->doEffect(c);
                            lpeitem->setCurrentPathEffect(*i);
                            if (lpelist.size() > 1){
                                lpeitem->removeCurrentPathEffect(true);
                                shape->setCurveBeforeLPE(c);
                            } else {
                                lpeitem->removeCurrentPathEffect(false);
                                shape->setCurve(c,0);
                            }
                            break;
                        }
                    }
                }
            }
        }
    }
}
/*
 * First clears the effectlist_store, then appends all effects from the effectlist.
 */
void
LivePathEffectEditor::effect_list_reload(SPLPEItem *lpeitem)
{
    effectlist_store->clear();

    PathEffectList effectlist = sp_lpe_item_get_effect_list(lpeitem);
    PathEffectList::iterator it;
    for( it = effectlist.begin() ; it!=effectlist.end(); it++ )
    {
        if ( !(*it)->lpeobject ) {
            continue;
        }

        if ((*it)->lpeobject->get_lpe()) {
            Gtk::TreeModel::Row row = *(effectlist_store->append());
            row[columns.col_name] = (*it)->lpeobject->get_lpe()->getName();
            row[columns.lperef] = *it;
            row[columns.col_visible] = (*it)->lpeobject->get_lpe()->isVisible();
        } else {
            Gtk::TreeModel::Row row = *(effectlist_store->append());
            row[columns.col_name] = _("Unknown effect");
            row[columns.lperef] = *it;
            row[columns.col_visible] = false;
        }
    }
}
Esempio n. 3
0
static std::string patheffectlist_write_svg(PathEffectList const & list)
{
    HRefList hreflist;

    for (PathEffectList::const_iterator it = list.begin(); it != list.end(); ++it)
    {
        hreflist.push_back( std::string((*it)->lpeobject_href) );
    }

    return hreflist_write_svg(hreflist);
}
Esempio n. 4
0
/**
 * Calls any registered handlers for the update_patheffect action
 */
void
sp_lpe_item_update_patheffect (SPLPEItem *lpeitem, bool wholetree, bool write)
{
#ifdef SHAPE_VERBOSE
    g_message("sp_lpe_item_update_patheffect: %p\n", lpeitem);
#endif
    g_return_if_fail (lpeitem != NULL);
    g_return_if_fail (SP_IS_LPE_ITEM (lpeitem));

    if (!lpeitem->pathEffectsEnabled())
        return;

    // TODO: hack! this will be removed when path length measuring is reimplemented in a better way
    PathEffectList lpelist = lpeitem->getEffectList();
    std::list<Inkscape::LivePathEffect::LPEObjectReference *>::iterator i;
    for (i = lpelist.begin(); i != lpelist.end(); ++i) {
        if ((*i)->lpeobject) {
            Inkscape::LivePathEffect::Effect *lpe = (*i)->lpeobject->get_lpe();
            if (dynamic_cast<Inkscape::LivePathEffect::LPEPathLength *>(lpe)) {
                if (!lpe->isVisible()) {
                    // we manually disable text for LPEPathLength
                    // use static_cast, because we already checked for the right type above
                    static_cast<Inkscape::LivePathEffect::LPEPathLength *>(lpe)->hideCanvasText();
                }
            }
        }
    }

    SPLPEItem *top = NULL;

    if (wholetree) {
        SPLPEItem *prev_parent = lpeitem;
        SPLPEItem *parent = dynamic_cast<SPLPEItem*>(prev_parent->parent);
        while (parent && parent->hasPathEffectRecursive()) {
            prev_parent = parent;
            parent = dynamic_cast<SPLPEItem*>(prev_parent->parent);
        }
        top = prev_parent;
    }
    else {
        top = lpeitem;
    }

    top->update_patheffect(write);
}