Exemple #1
0
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);
            }
        }
    }
}
Exemple #2
0
void SPLPEItem::modified(unsigned int flags) {
    if (SP_IS_GROUP(this) && (flags & SP_OBJECT_MODIFIED_FLAG) && (flags & SP_OBJECT_USER_MODIFIED_FLAG_B)) {
        sp_lpe_item_update_patheffect(this, true, true);
    }

//    SPItem::onModified(flags);
}
Exemple #3
0
/**
 * Gets called when any of the lpestack's lpeobject repr contents change: i.e. parameter change in any of the stacked LPEs
 */
static void
lpeobject_ref_modified(SPObject */*href*/, guint /*flags*/, SPLPEItem *lpeitem)
{
#ifdef SHAPE_VERBOSE
    g_message("lpeobject_ref_modified");
#endif
    sp_lpe_item_update_patheffect (lpeitem, true, true);
}
Exemple #4
0
void
PointParamKnotHolderEntity::knot_click(guint state)
{
    if (state & GDK_CONTROL_MASK) {
            if (state & GDK_MOD1_MASK) {
                this->pparam->param_set_default();
                SPLPEItem * splpeitem = dynamic_cast<SPLPEItem *>(item);
                if(splpeitem){
                    sp_lpe_item_update_patheffect(splpeitem, false, false);
                }
            }
    }
}
Exemple #5
0
/**
 * Adds a original_curve to the path.  If owner is specified, a reference
 * will be made, otherwise the curve will be copied into the path.
 * Any existing curve in the path will be unreferenced first.
 * This routine triggers reapplication of an effect if present
 * and also triggers a request to update the display. Does not write
 * result to XML when write=false.
 */
void SPPath::set_original_curve (SPCurve *new_curve, unsigned int owner, bool write)
{
    if (_curve_before_lpe) {
        _curve_before_lpe = _curve_before_lpe->unref();
    }
    if (new_curve) {
        if (owner) {
            _curve_before_lpe = new_curve->ref();
        } else {
            _curve_before_lpe = new_curve->copy();
        }
    }
    sp_lpe_item_update_patheffect(this, true, write);
    requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
Exemple #6
0
static void
sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem)
{
    g_return_if_fail(lpeitem != NULL);

    if (SP_IS_GROUP(lpeitem)) {
        if (!lpeitem->hasPathEffectRecursive()) {
            SPMask * mask = lpeitem->mask_ref->getObject();
            if(mask)
            {
                sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(mask->firstChild()));
            }
            SPClipPath * clipPath = lpeitem->clip_ref->getObject();
            if(clipPath)
            {
                sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clipPath->firstChild()));
            }
        }
        GSList const *item_list = sp_item_group_item_list(SP_GROUP(lpeitem));
        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_cleanup_original_path_recursive(SP_LPE_ITEM(subitem));
            }
        }
    }
    else if (SP_IS_PATH(lpeitem)) {
        Inkscape::XML::Node *repr = lpeitem->getRepr();
        if (!lpeitem->hasPathEffectRecursive() && repr->attribute("inkscape:original-d")) {
            SPMask * mask = lpeitem->mask_ref->getObject();
            if(mask)
            {
                sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(mask->firstChild()));
            }
            SPClipPath * clipPath = lpeitem->clip_ref->getObject();
            if(clipPath)
            {
                sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clipPath->firstChild()));
            }
            repr->setAttribute("d", repr->attribute("inkscape:original-d"));
            repr->setAttribute("inkscape:original-d", NULL);
        }
        else {
            sp_lpe_item_update_patheffect(lpeitem, true, true);
        }
    }
}
void
KnotHolderEntityEnd::bisector_end_set(Geom::Point const &p, guint state, bool left) {
    LPEPerpBisector *lpe = dynamic_cast<LPEPerpBisector *>(_effect);
    if (!lpe) return;

    Geom::Point const s = snap_knot_position(p, state);

    double lambda = Geom::nearest_point(s, lpe->M, lpe->perp_dir);
    if (left) {
        lpe->C = lpe->M + lpe->perp_dir * lambda;
        lpe->length_left.param_set_value(lambda);
    } else {
        lpe->D = lpe->M + lpe->perp_dir * lambda;
        lpe->length_right.param_set_value(-lambda);
    }

    // FIXME: this should not directly ask for updating the item. It should write to SVG, which triggers updating.
    sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), true, true);
}
Exemple #8
0
void
PointParamKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &origin, guint state)
{
    Geom::Point s = snap_knot_position(p, state);
    if (state & GDK_CONTROL_MASK) {
        Geom::Point A(origin[Geom::X],p[Geom::Y]);
        Geom::Point B(p[Geom::X],origin[Geom::Y]);
        double distanceA = Geom::distance(A,p);
        double distanceB = Geom::distance(B,p);
        if(distanceA > distanceB){
            s = B;
        } else {
            s = A;
        }
    }
    pparam->param_setValue(s, true);
    SPLPEItem * splpeitem = dynamic_cast<SPLPEItem *>(item);
    if(splpeitem){
        sp_lpe_item_update_patheffect(splpeitem, false, false);
    }
}
Exemple #9
0
 virtual void knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) {
     Geom::Point const s = p - param->origin;
     /// @todo implement angle snapping when holding CTRL
     param->setVector(s);
     sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false);
 };
Exemple #10
0
 virtual void knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint /*state*/) {
     Geom::Point const s = snap_knot_position(p);
     param->setOrigin(s);
     sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false);
 };