diff options
| author | root <root@jtx.marker.es> | 2013-10-05 00:49:20 +0000 |
|---|---|---|
| committer | root <root@jtx.marker.es> | 2013-10-05 00:49:20 +0000 |
| commit | 0de4a7013187366efbeeb5887191b6ea57445899 (patch) | |
| tree | 4403a23f086824c3f43a0d60853e625f5ce5c635 /src | |
| parent | update to trunk (diff) | |
| parent | C++ (diff) | |
| download | inkscape-0de4a7013187366efbeeb5887191b6ea57445899.tar.gz inkscape-0de4a7013187366efbeeb5887191b6ea57445899.zip | |
update to trunk
(bzr r11950.1.159)
Diffstat (limited to 'src')
37 files changed, 249 insertions, 223 deletions
diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp index 4d8b1e2d7..040b031c6 100644 --- a/src/box3d-side.cpp +++ b/src/box3d-side.cpp @@ -207,9 +207,9 @@ void Box3DSide::set_shape() { * This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/ this->setCurveInsync( c, TRUE); - if (hasPathEffect() && sp_lpe_item_path_effects_enabled(this)) { + if (hasPathEffect() && pathEffectsEnabled()) { SPCurve *c_lpe = c->copy(); - bool success = sp_lpe_item_perform_path_effect(this, c_lpe); + bool success = this->performPathEffect(c_lpe); if (success) { this->setCurveInsync(c_lpe, TRUE); diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp index 71a7f8906..69adcb441 100644 --- a/src/display/drawing-item.cpp +++ b/src/display/drawing-item.cpp @@ -746,7 +746,6 @@ DrawingItem::pick(Geom::Point const &p, double delta, unsigned flags) Geom::OptIntRect box = (outline || (flags & PICK_AS_CLIP)) ? _bbox : _drawbox; if (!box) { - g_warning("bbox unset when picking"); return NULL; } diff --git a/src/draw-context.cpp b/src/draw-context.cpp index 37d2b0e56..dafb773f6 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -212,7 +212,7 @@ static void spdc_paste_curve_as_freehand_shape(const SPCurve *c, SPDrawContext * // TODO: Don't paste path if nothing is on the clipboard Effect::createAndApply(PATTERN_ALONG_PATH, dc->desktop->doc(), item); - Effect* lpe = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item)); + Effect* lpe = SP_LPE_ITEM(item)->getCurrentLPE(); gchar *svgd = sp_svg_write_path(c->get_pathvector()); static_cast<LPEPatternAlongPath*>(lpe)->pattern.paste_param_path(svgd); } @@ -222,7 +222,7 @@ static void spdc_apply_powerstroke_shape(const std::vector<Geom::Point> & points using namespace Inkscape::LivePathEffect; Effect::createAndApply(POWERSTROKE, dc->desktop->doc(), item); - Effect* lpe = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item)); + Effect* lpe = SP_LPE_ITEM(item)->getCurrentLPE(); static_cast<LPEPowerStroke*>(lpe)->offset_points.param_set_and_write_new_value(points); // write powerstroke parameters: @@ -303,7 +303,7 @@ static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item { // take shape from clipboard; TODO: catch the case where clipboard is empty Effect::createAndApply(PATTERN_ALONG_PATH, dc->desktop->doc(), item); - Effect* lpe = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item)); + Effect* lpe = SP_LPE_ITEM(item)->getCurrentLPE(); static_cast<LPEPatternAlongPath*>(lpe)->pattern.on_paste_button_click(); shape_applied = true; diff --git a/src/file.cpp b/src/file.cpp index e0675e8cf..8a7b177c0 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -135,14 +135,17 @@ SPDesktop *sp_file_new(const std::string &templ) Inkscape::XML::Node *myRoot = doc->getReprRoot(); Inkscape::XML::Node *nodeToRemove = sp_repr_lookup_name(myRoot, "inkscape:_templateinfo"); if (nodeToRemove != NULL){ + DocumentUndo::setUndoSensitive(doc, false); sp_repr_unparent(nodeToRemove); delete nodeToRemove; - DocumentUndo::clearUndo(doc); + DocumentUndo::setUndoSensitive(doc, true); } // Set viewBox if it doesn't exist if (!doc->getRoot()->viewBox_set) { + DocumentUndo::setUndoSensitive(doc, false); doc->setViewBox(Geom::Rect::from_xywh(0, 0, doc->getWidth().quantity, doc->getHeight().quantity)); + DocumentUndo::setUndoSensitive(doc, true); } SPDesktop *desktop = SP_ACTIVE_DESKTOP; diff --git a/src/knotholder.cpp b/src/knotholder.cpp index 32ba9075b..9abba83d7 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -209,7 +209,7 @@ KnotHolder::knot_ungrabbed_handler(SPKnot */*knot*/) // This writes all parameters to SVG. Is this sufficiently efficient or should we only // write the ones that were changed? - Inkscape::LivePathEffect::Effect *lpe = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(object)); + Inkscape::LivePathEffect::Effect *lpe = SP_LPE_ITEM(object)->getCurrentLPE(); if (lpe) { LivePathEffectObject *lpeobj = lpe->getLPEObj(); lpeobj->updateRepr(); diff --git a/src/libnrtype/font-lister.cpp b/src/libnrtype/font-lister.cpp index 0a83f55e9..aa50f4be0 100644 --- a/src/libnrtype/font-lister.cpp +++ b/src/libnrtype/font-lister.cpp @@ -203,6 +203,7 @@ namespace Inkscape font_list_store->thaw_notify(); } + // FIXME: why do we parse the style attribute instead of the object's SPStyle? void FontLister::update_font_list_recursive( SPObject *r, std::list<Glib::ustring> *l ) { diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index b84403495..1f1c8d2dd 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -281,7 +281,7 @@ void Effect::createAndApply(const char* name, SPDocument *doc, SPItem *item) Inkscape::GC::release(repr); gchar *href = g_strdup_printf("#%s", repr_id); - sp_lpe_item_add_path_effect(SP_LPE_ITEM(item), href, true); + SP_LPE_ITEM(item)->addPathEffect(href, true); g_free(href); } diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index f7a7155b0..b9d86628f 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -66,7 +66,7 @@ public: /* * isReady() indicates whether all preparations which are necessary to apply the LPE are done, * e.g., waiting for a parameter path either before the effect is created or when it needs a - * path as argument. This is set in sp_lpe_item_add_path_effect(). + * path as argument. This is set in SPLPEItem::addPathEffect(). */ inline bool isReady() const { return is_ready; } inline void setReady(bool ready = true) { is_ready = ready; } diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index c2749e393..84f3fbb33 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -88,7 +88,7 @@ LPEBSpline::createAndApply(const char* name, SPDocument *doc, SPItem *item) Inkscape::GC::release(repr); gchar *href = g_strdup_printf("#%s", repr_id); - sp_lpe_item_add_path_effect(SP_LPE_ITEM(item), href, true); + SP_LPE_ITEM(item)->addPathEffect( href, true); g_free(href); } } diff --git a/src/live_effects/lpe-copy_rotate.cpp b/src/live_effects/lpe-copy_rotate.cpp index c1b72c3c7..65bbcdad1 100644 --- a/src/live_effects/lpe-copy_rotate.cpp +++ b/src/live_effects/lpe-copy_rotate.cpp @@ -115,7 +115,7 @@ LPECopyRotate::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & p } void -LPECopyRotate::addCanvasIndicators(SPLPEItem */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec) +LPECopyRotate::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec) { using namespace Geom; diff --git a/src/live_effects/lpe-copy_rotate.h b/src/live_effects/lpe-copy_rotate.h index 1354b980a..ca7aa269c 100644 --- a/src/live_effects/lpe-copy_rotate.h +++ b/src/live_effects/lpe-copy_rotate.h @@ -41,7 +41,7 @@ public: void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); protected: - virtual void addCanvasIndicators(SPLPEItem *lpeitem, std::vector<Geom::PathVector> &hp_vec); + virtual void addCanvasIndicators(SPLPEItem const *lpeitem, std::vector<Geom::PathVector> &hp_vec); private: ScalarParam starting_angle; diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index 27652bf0c..8fec69958 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -588,7 +588,7 @@ LPEKnot::doBeforeEffect (SPLPEItem const* lpeitem) } void -LPEKnot::addCanvasIndicators(SPLPEItem */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec) +LPEKnot::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec) { using namespace Geom; double r = switcher_size*.1; diff --git a/src/live_effects/lpe-knot.h b/src/live_effects/lpe-knot.h index a25607981..b937f9021 100644 --- a/src/live_effects/lpe-knot.h +++ b/src/live_effects/lpe-knot.h @@ -64,7 +64,7 @@ public: void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item); protected: - virtual void addCanvasIndicators(SPLPEItem *lpeitem, std::vector<Geom::PathVector> &hp_vec); + virtual void addCanvasIndicators(SPLPEItem const *lpeitem, std::vector<Geom::PathVector> &hp_vec); private: void updateSwitcher(); diff --git a/src/live_effects/lpe-vonkoch.cpp b/src/live_effects/lpe-vonkoch.cpp index f7b2beeba..c0050fa60 100644 --- a/src/live_effects/lpe-vonkoch.cpp +++ b/src/live_effects/lpe-vonkoch.cpp @@ -176,7 +176,7 @@ LPEVonKoch::doEffect_path (std::vector<Geom::Path> const & path_in) //Usefull?? //void -//LPEVonKoch::addCanvasIndicators(SPLPEItem */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec) +//LPEVonKoch::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec) /*{ using namespace Geom; if (draw_boxes.get_value()){ diff --git a/src/live_effects/lpe-vonkoch.h b/src/live_effects/lpe-vonkoch.h index 2ea7c8169..7dff2be52 100644 --- a/src/live_effects/lpe-vonkoch.h +++ b/src/live_effects/lpe-vonkoch.h @@ -57,7 +57,7 @@ public: //Usefull?? // protected: - //virtual void addCanvasIndicators(SPLPEItem *lpeitem, std::vector<Geom::PathVector> &hp_vec); + //virtual void addCanvasIndicators(SPLPEItem const *lpeitem, std::vector<Geom::PathVector> &hp_vec); private: ScalarParam nbgenerations; diff --git a/src/live_effects/lpeobject.cpp b/src/live_effects/lpeobject.cpp index d61f2b2fa..d92c94d01 100644 --- a/src/live_effects/lpeobject.cpp +++ b/src/live_effects/lpeobject.cpp @@ -181,7 +181,7 @@ livepatheffect_on_repr_attr_changed ( Inkscape::XML::Node * /*repr*/, /** * If this has other users, create a new private duplicate and return it * returns 'this' when no forking was necessary (and therefore no duplicate was made) - * Check out sp_lpe_item_fork_path_effects_if_necessary ! + * Check out SPLPEItem::forkPathEffectsIfNecessary ! */ LivePathEffectObject *LivePathEffectObject::fork_private_if_necessary(unsigned int nr_of_allowed_users) { diff --git a/src/live_effects/lpeobject.h b/src/live_effects/lpeobject.h index 534a12897..9700024fe 100644 --- a/src/live_effects/lpeobject.h +++ b/src/live_effects/lpeobject.h @@ -39,6 +39,7 @@ public: /* Note that the returned pointer can be NULL in a valid LivePathEffectObject contained in a valid list of lpeobjects in an lpeitem! * So one should always check whether the returned value is NULL or not */ Inkscape::LivePathEffect::Effect * get_lpe() { return lpe; }; + Inkscape::LivePathEffect::Effect const * get_lpe() const { return lpe; }; Inkscape::LivePathEffect::Effect *lpe; // this can be NULL in a valid LivePathEffectObject diff --git a/src/lpe-tool-context.cpp b/src/lpe-tool-context.cpp index bcf58aaf3..edc9a6930 100644 --- a/src/lpe-tool-context.cpp +++ b/src/lpe-tool-context.cpp @@ -290,7 +290,7 @@ int lpetool_item_has_construction(SPLPEToolContext */*lc*/, SPItem *item) return -1; } - Inkscape::LivePathEffect::Effect* lpe = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item)); + Inkscape::LivePathEffect::Effect* lpe = SP_LPE_ITEM(item)->getCurrentLPE(); if (!lpe) { return -1; } diff --git a/src/object-edit.cpp b/src/object-edit.cpp index 28786bf66..2021b91f5 100644 --- a/src/object-edit.cpp +++ b/src/object-edit.cpp @@ -46,7 +46,7 @@ static KnotHolder *sp_lpe_knot_holder(SPItem *item, SPDesktop *desktop) { KnotHolder *knot_holder = new KnotHolder(desktop, item, NULL); - Inkscape::LivePathEffect::Effect *effect = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item)); + Inkscape::LivePathEffect::Effect *effect = SP_LPE_ITEM(item)->getCurrentLPE(); effect->addHandles(knot_holder, desktop, item); return knot_holder; @@ -61,9 +61,9 @@ KnotHolder *createKnotHolder(SPItem *item, SPDesktop *desktop) KnotHolder *knotholder = NULL; if (SP_IS_LPE_ITEM(item) && - sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item)) && - sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item))->isVisible() && - sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item))->providesKnotholder()) { + SP_LPE_ITEM(item)->getCurrentLPE() && + SP_LPE_ITEM(item)->getCurrentLPE()->isVisible() && + SP_LPE_ITEM(item)->getCurrentLPE()->providesKnotholder()) { knotholder = sp_lpe_knot_holder(item, desktop); } else if (SP_IS_RECT(item)) { knotholder = new RectKnotHolder(desktop, item, NULL); diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index 52569dd21..5f478435d 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -405,7 +405,7 @@ sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_selec } if (SP_IS_GROUP(item)) { - sp_lpe_item_remove_all_path_effects(SP_LPE_ITEM(item), true); + SP_LPE_ITEM(item)->removeAllPathEffects(true); GSList *item_list = sp_item_group_item_list(SP_GROUP(item)); GSList *item_to_select = NULL; diff --git a/src/pen-context.cpp b/src/pen-context.cpp index 97bc03676..a9bd09c51 100644 --- a/src/pen-context.cpp +++ b/src/pen-context.cpp @@ -191,7 +191,7 @@ SPPenContext::~SPPenContext() { if (this->expecting_clicks_for_LPE > 0) { // we received too few clicks to sanely set the parameter path so we remove the LPE from the item - sp_lpe_item_remove_current_path_effect(this->waiting_item, false); + this->waiting_item->removeCurrentPathEffect(false); } } diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 2105ca99a..49a731b15 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -482,7 +482,7 @@ void sp_selection_duplicate(SPDesktop *desktop, bool suppressDone) if (fork_livepatheffects) { SPObject *new_obj = doc->getObjectByRepr(copy); if (new_obj && SP_IS_LPE_ITEM(new_obj)) { - sp_lpe_item_fork_path_effects_if_necessary(SP_LPE_ITEM(new_obj), 1); + SP_LPE_ITEM(new_obj)->forkPathEffectsIfNecessary(1); } } @@ -1184,7 +1184,7 @@ static void sp_selection_remove_livepatheffect_impl(SPItem *item) { if ( SPLPEItem *lpeitem = dynamic_cast<SPLPEItem*>(item) ) { if ( lpeitem->hasPathEffect() ) { - sp_lpe_item_remove_all_path_effects(SP_LPE_ITEM(item), false); + lpeitem->removeAllPathEffects(false); } } } @@ -2321,7 +2321,7 @@ void sp_selection_next_patheffect_param(SPDesktop * dt) SPItem *item = selection->singleItem(); if ( SPLPEItem *lpeitem = dynamic_cast<SPLPEItem*>(item) ) { if (lpeitem->hasPathEffect()) { - sp_lpe_item_edit_next_param_oncanvas(lpeitem, dt); + lpeitem->editNextParamOncanvas(dt); } else { dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("The selection has no applied path effect.")); } @@ -2779,7 +2779,7 @@ void sp_selection_clone_original_path_lpe(SPDesktop *desktop) SPObject *clone_obj = desktop->doc()->getObjectById(clone->attribute("id")); if (SP_IS_LPE_ITEM(clone_obj)) { gchar *href = g_strdup_printf("#%s", lpe_id); - sp_lpe_item_add_path_effect( SP_LPE_ITEM(clone_obj), href, false ); + SP_LPE_ITEM(clone_obj)->addPathEffect( href, false ); g_free(href); } } diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp index 80e57afc3..06201859f 100644 --- a/src/sp-ellipse.cpp +++ b/src/sp-ellipse.cpp @@ -205,9 +205,9 @@ void SPGenericEllipse::set_shape() this->setCurveInsync(curve, TRUE); this->setCurveBeforeLPE(curve); - if (hasPathEffect() && sp_lpe_item_path_effects_enabled(this)) { + if (hasPathEffect() && pathEffectsEnabled()) { SPCurve *c_lpe = curve->copy(); - bool success = sp_lpe_item_perform_path_effect(this, c_lpe); + bool success = this->performPathEffect(c_lpe); if (success) { this->setCurveInsync(c_lpe, TRUE); diff --git a/src/sp-image.cpp b/src/sp-image.cpp index f2fc6a37a..86668d9ed 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -433,73 +433,75 @@ void SPImage::update(SPCtx *ctx, unsigned int flags) { this->ox = this->x.computed; this->oy = this->y.computed; - int pixwidth = this->pixbuf->width(); - int pixheight = this->pixbuf->height(); - - this->sx = this->width.computed / pixwidth; - this->sy = this->height.computed / pixheight; - - // preserveAspectRatio calculate bounds / clipping rectangle -- EAF - if (this->pixbuf && (this->aspect_align != SP_ASPECT_NONE)) { - double x, y; - - switch (this->aspect_align) { - case SP_ASPECT_XMIN_YMIN: - x = 0.0; - y = 0.0; - break; - case SP_ASPECT_XMID_YMIN: - x = 0.5; - y = 0.0; - break; - case SP_ASPECT_XMAX_YMIN: - x = 1.0; - y = 0.0; - break; - case SP_ASPECT_XMIN_YMID: - x = 0.0; - y = 0.5; - break; - case SP_ASPECT_XMID_YMID: - x = 0.5; - y = 0.5; - break; - case SP_ASPECT_XMAX_YMID: - x = 1.0; - y = 0.5; - break; - case SP_ASPECT_XMIN_YMAX: - x = 0.0; - y = 1.0; - break; - case SP_ASPECT_XMID_YMAX: - x = 0.5; - y = 1.0; - break; - case SP_ASPECT_XMAX_YMAX: - x = 1.0; - y = 1.0; - break; - default: - x = 0.0; - y = 0.0; - break; - } + if (this->pixbuf) { + int pixwidth = this->pixbuf->width(); + int pixheight = this->pixbuf->height(); - if (this->aspect_clip == SP_ASPECT_SLICE) { - double scale = std::max(this->sx, this->sy); - this->sx = scale; - this->sy = scale; - } else { - double scale = std::min(this->sx, this->sy); - this->sx = scale; - this->sy = scale; - } + this->sx = this->width.computed / pixwidth; + this->sy = this->height.computed / pixheight; + + // preserveAspectRatio calculate bounds / clipping rectangle -- EAF + if (this->aspect_align != SP_ASPECT_NONE) { + double x, y; - double vw = pixwidth * this->sx; - double vh = pixheight * this->sy; - this->ox += x * (this->width.computed - vw); - this->oy += y * (this->height.computed - vh); + switch (this->aspect_align) { + case SP_ASPECT_XMIN_YMIN: + x = 0.0; + y = 0.0; + break; + case SP_ASPECT_XMID_YMIN: + x = 0.5; + y = 0.0; + break; + case SP_ASPECT_XMAX_YMIN: + x = 1.0; + y = 0.0; + break; + case SP_ASPECT_XMIN_YMID: + x = 0.0; + y = 0.5; + break; + case SP_ASPECT_XMID_YMID: + x = 0.5; + y = 0.5; + break; + case SP_ASPECT_XMAX_YMID: + x = 1.0; + y = 0.5; + break; + case SP_ASPECT_XMIN_YMAX: + x = 0.0; + y = 1.0; + break; + case SP_ASPECT_XMID_YMAX: + x = 0.5; + y = 1.0; + break; + case SP_ASPECT_XMAX_YMAX: + x = 1.0; + y = 1.0; + break; + default: + x = 0.0; + y = 0.0; + break; + } + + if (this->aspect_clip == SP_ASPECT_SLICE) { + double scale = std::max(this->sx, this->sy); + this->sx = scale; + this->sy = scale; + } else { + double scale = std::min(this->sx, this->sy); + this->sx = scale; + this->sy = scale; + } + + double vw = pixwidth * this->sx; + double vh = pixheight * this->sy; + this->ox += x * (this->width.computed - vw); + this->oy += y * (this->height.computed - vh); + } } sp_image_update_canvas_image ((SPImage *) this); } diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 41e049b86..ae974200f 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -424,7 +424,7 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) gitem = group; } - sp_lpe_item_remove_all_path_effects(SP_LPE_ITEM(group), false); + SP_LPE_ITEM(group)->removeAllPathEffects(false); /* Step 1 - generate lists of children objects */ GSList *items = NULL; @@ -763,7 +763,7 @@ void SPGroup::update_patheffect(bool write) { } } - if (hasPathEffect() && sp_lpe_item_path_effects_enabled(this)) { + if (hasPathEffect() && pathEffectsEnabled()) { for (PathEffectList::iterator it = this->path_effect_list->begin(); it != this->path_effect_list->end(); it++) { LivePathEffectObject *lpeobj = (*it)->lpeobject; @@ -799,7 +799,7 @@ sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write) // only run LPEs when the shape has a curve defined if (c) { c->transform(i2anc_affine(subitem, topgroup)); - sp_lpe_item_perform_path_effect(SP_LPE_ITEM(topgroup), c); + SP_LPE_ITEM(topgroup)->performPathEffect(c); c->transform(i2anc_affine(subitem, topgroup).inverse()); SP_SHAPE(subitem)->setCurve(c, TRUE); diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 5bf0afdeb..e8338046b 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -1288,10 +1288,10 @@ void SPItem::adjust_livepatheffect (Geom::Affine const &postmul, bool set) if ( SP_IS_LPE_ITEM(this) ) { SPLPEItem *lpeitem = SP_LPE_ITEM (this); if ( lpeitem->hasPathEffect() ) { - sp_lpe_item_fork_path_effects_if_necessary(lpeitem); + lpeitem->forkPathEffectsIfNecessary(); // now that all LPEs are forked_if_necessary, we can apply the transform - PathEffectList effect_list = sp_lpe_item_get_effect_list(lpeitem); + PathEffectList effect_list = lpeitem->getEffectList(); for (PathEffectList::iterator it = effect_list.begin(); it != effect_list.end(); ++it) { LivePathEffectObject *lpeobj = (*it)->lpeobject; diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index b3e6182a4..b7e4ee4a9 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -197,8 +197,8 @@ Inkscape::XML::Node* SPLPEItem::write(Inkscape::XML::Document *xml_doc, Inkscape /** * returns true when LPE was successful. */ -bool sp_lpe_item_perform_path_effect(SPLPEItem *lpeitem, SPCurve *curve) { - if (!lpeitem) { +bool SPLPEItem::performPathEffect(SPCurve *curve) { + if (!this) { return false; } @@ -206,15 +206,15 @@ bool sp_lpe_item_perform_path_effect(SPLPEItem *lpeitem, SPCurve *curve) { return false; } - if (lpeitem->hasPathEffect() && sp_lpe_item_path_effects_enabled(lpeitem)) { - for (PathEffectList::iterator it = lpeitem->path_effect_list->begin(); it != lpeitem->path_effect_list->end(); ++it) + if (this->hasPathEffect() && this->pathEffectsEnabled()) { + for (PathEffectList::iterator it = this->path_effect_list->begin(); it != this->path_effect_list->end(); ++it) { LivePathEffectObject *lpeobj = (*it)->lpeobject; if (!lpeobj) { /** \todo Investigate the cause of this. * For example, this happens when copy pasting an object with LPE applied. Probably because the object is pasted while the effect is not yet pasted to defs, and cannot be found. */ - g_warning("sp_lpe_item_perform_path_effect - NULL lpeobj in list!"); + g_warning("SPLPEItem::performPathEffect - NULL lpeobj in list!"); return false; } Inkscape::LivePathEffect::Effect *lpe = lpeobj->get_lpe(); @@ -222,7 +222,7 @@ bool sp_lpe_item_perform_path_effect(SPLPEItem *lpeitem, SPCurve *curve) { /** \todo Investigate the cause of this. * Not sure, but I think this can happen when an unknown effect type is specified... */ - g_warning("sp_lpe_item_perform_path_effect - lpeobj with invalid lpe in the stack!"); + g_warning("SPLPEItem::performPathEffect - lpeobj with invalid lpe in the stack!"); return false; } @@ -234,8 +234,8 @@ bool sp_lpe_item_perform_path_effect(SPLPEItem *lpeitem, SPCurve *curve) { } // Groups have their doBeforeEffect called elsewhere - if (!SP_IS_GROUP(lpeitem)) { - lpe->doBeforeEffect(lpeitem); + if (!SP_IS_GROUP(this)) { + lpe->doBeforeEffect(this); } try { @@ -273,11 +273,11 @@ sp_lpe_item_update_patheffect (SPLPEItem *lpeitem, bool wholetree, bool write) g_return_if_fail (lpeitem != NULL); g_return_if_fail (SP_IS_LPE_ITEM (lpeitem)); - if (!sp_lpe_item_path_effects_enabled(lpeitem)) + if (!lpeitem->pathEffectsEnabled()) return; // TODO: hack! this will be removed when path length measuring is reimplemented in a better way - PathEffectList lpelist = sp_lpe_item_get_effect_list(lpeitem); + PathEffectList lpelist = lpeitem->getEffectList(); std::list<Inkscape::LivePathEffect::LPEObjectReference *>::iterator i; for (i = lpelist.begin(); i != lpelist.end(); ++i) { if ((*i)->lpeobject) { @@ -366,99 +366,99 @@ sp_lpe_item_cleanup_original_path_recursive(SPLPEItem *lpeitem) } } -void sp_lpe_item_add_path_effect(SPLPEItem *lpeitem, gchar *value, bool reset) +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(lpeitem, false, true); + sp_lpe_item_update_patheffect(this, false, true); // Disable the path effects while preparing the new lpe - sp_lpe_item_enable_path_effects(lpeitem, false); + 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 = lpeitem->path_effect_list->begin(); it != lpeitem->path_effect_list->end(); ++it) + 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); - lpeitem->getRepr()->setAttribute("inkscape:path-effect", hrefs.c_str()); + this->getRepr()->setAttribute("inkscape:path-effect", hrefs.c_str()); // make sure there is an original-d for paths!!! - sp_lpe_item_create_original_path_recursive(lpeitem); + sp_lpe_item_create_original_path_recursive(this); - LivePathEffectObject *lpeobj = lpeitem->path_effect_list->back()->lpeobject; + 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(lpeitem); + lpe->resetDefaults(this); } // perform this once when the effect is applied - lpe->doOnApply(SP_LPE_ITEM(lpeitem)); + 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(lpeitem, true); + sp_lpe_item_enable_path_effects(this, true); // Apply the path effect - sp_lpe_item_update_patheffect(lpeitem, true, true); + sp_lpe_item_update_patheffect(this, true, true); } } -void sp_lpe_item_add_path_effect(SPLPEItem *lpeitem, LivePathEffectObject * new_lpeobj) +void SPLPEItem::addPathEffect(LivePathEffectObject * new_lpeobj) { const gchar * repr_id = new_lpeobj->getRepr()->attribute("id"); gchar *hrefstr = g_strdup_printf("#%s", repr_id); - sp_lpe_item_add_path_effect(lpeitem, hrefstr, false); + this->addPathEffect(hrefstr, false); g_free(hrefstr); } -void sp_lpe_item_remove_current_path_effect(SPLPEItem *lpeitem, bool keep_paths) +void SPLPEItem::removeCurrentPathEffect(bool keep_paths) { - Inkscape::LivePathEffect::LPEObjectReference* lperef = sp_lpe_item_get_current_lpereference(lpeitem); + Inkscape::LivePathEffect::LPEObjectReference* lperef = this->getCurrentLPEReference(); if (!lperef) return; - PathEffectList new_list = *lpeitem->path_effect_list; + PathEffectList new_list = *this->path_effect_list; new_list.remove(lperef); //current lpe ref is always our 'own' pointer from the path_effect_list std::string r = patheffectlist_write_svg(new_list); if (!r.empty()) { - lpeitem->getRepr()->setAttribute("inkscape:path-effect", r.c_str()); + this->getRepr()->setAttribute("inkscape:path-effect", r.c_str()); } else { - lpeitem->getRepr()->setAttribute("inkscape:path-effect", NULL); + this->getRepr()->setAttribute("inkscape:path-effect", NULL); } if (!keep_paths) { - sp_lpe_item_cleanup_original_path_recursive(lpeitem); + sp_lpe_item_cleanup_original_path_recursive(this); } } -void sp_lpe_item_remove_all_path_effects(SPLPEItem *lpeitem, bool keep_paths) +void SPLPEItem::removeAllPathEffects(bool keep_paths) { - lpeitem->getRepr()->setAttribute("inkscape:path-effect", NULL); + this->getRepr()->setAttribute("inkscape:path-effect", NULL); if (!keep_paths) { - sp_lpe_item_cleanup_original_path_recursive(lpeitem); + sp_lpe_item_cleanup_original_path_recursive(this); } } -void sp_lpe_item_down_current_path_effect(SPLPEItem *lpeitem) +void SPLPEItem::downCurrentPathEffect() { - Inkscape::LivePathEffect::LPEObjectReference* lperef = sp_lpe_item_get_current_lpereference(lpeitem); + Inkscape::LivePathEffect::LPEObjectReference* lperef = getCurrentLPEReference(); if (!lperef) return; - PathEffectList new_list = *lpeitem->path_effect_list; + PathEffectList new_list = *this->path_effect_list; PathEffectList::iterator cur_it = find( new_list.begin(), new_list.end(), lperef ); if (cur_it != new_list.end()) { PathEffectList::iterator down_it = cur_it; @@ -468,18 +468,18 @@ void sp_lpe_item_down_current_path_effect(SPLPEItem *lpeitem) } } std::string r = patheffectlist_write_svg(new_list); - lpeitem->getRepr()->setAttribute("inkscape:path-effect", r.c_str()); + this->getRepr()->setAttribute("inkscape:path-effect", r.c_str()); - sp_lpe_item_cleanup_original_path_recursive(lpeitem); + sp_lpe_item_cleanup_original_path_recursive(this); } -void sp_lpe_item_up_current_path_effect(SPLPEItem *lpeitem) +void SPLPEItem::upCurrentPathEffect() { - Inkscape::LivePathEffect::LPEObjectReference* lperef = sp_lpe_item_get_current_lpereference(lpeitem); + Inkscape::LivePathEffect::LPEObjectReference* lperef = getCurrentLPEReference(); if (!lperef) return; - PathEffectList new_list = *lpeitem->path_effect_list; + PathEffectList new_list = *this->path_effect_list; PathEffectList::iterator cur_it = find( new_list.begin(), new_list.end(), lperef ); if (cur_it != new_list.end() && cur_it != new_list.begin()) { PathEffectList::iterator up_it = cur_it; @@ -488,9 +488,9 @@ void sp_lpe_item_up_current_path_effect(SPLPEItem *lpeitem) } std::string r = patheffectlist_write_svg(new_list); - lpeitem->getRepr()->setAttribute("inkscape:path-effect", r.c_str()); + this->getRepr()->setAttribute("inkscape:path-effect", r.c_str()); - sp_lpe_item_cleanup_original_path_recursive(lpeitem); + sp_lpe_item_cleanup_original_path_recursive(this); } /** used for shapes so they can see if they should also disable shape calculation and read from d= */ @@ -531,6 +531,26 @@ bool SPLPEItem::hasPathEffect() const return true; } +bool SPLPEItem::hasPathEffectOfType(int const type) const +{ + if (path_effect_list->empty()) { + return false; + } + + for (PathEffectList::const_iterator it = path_effect_list->begin(); it != path_effect_list->end(); ++it) + { + LivePathEffectObject const *lpeobj = (*it)->lpeobject; + if (lpeobj) { + Inkscape::LivePathEffect::Effect const* lpe = lpeobj->get_lpe(); + if (lpe && (lpe->effectType() == type)) { + return true; + } + } + } + + return false; +} + bool SPLPEItem::hasPathEffectRecursive() const { if (parent && SP_IS_LPE_ITEM(parent)) { @@ -546,32 +566,22 @@ SPLPEItem::getPathEffectOfType(int type) { std::list<Inkscape::LivePathEffect::LPEObjectReference *>::iterator i; for (i = path_effect_list->begin(); i != path_effect_list->end(); ++i) { - Inkscape::LivePathEffect::Effect* lpe = (*i)->lpeobject->get_lpe(); - if (lpe && (lpe->effectType() == type)) { - return lpe; + LivePathEffectObject *lpeobj = (*i)->lpeobject; + if (lpeobj) { + Inkscape::LivePathEffect::Effect* lpe = lpeobj->get_lpe(); + if (lpe && (lpe->effectType() == type)) { + return lpe; + } } } return NULL; } -/* Return false if the item is not a path or already has a shape applied */ -bool sp_lpe_item_can_accept_freehand_shape(SPLPEItem *lpeitem) -{ - if (!SP_IS_PATH(lpeitem)) - return false; - - if (lpeitem->getPathEffectOfType(Inkscape::LivePathEffect::FREEHAND_SHAPE)) { - return false; - } - - return true; -} - -void sp_lpe_item_edit_next_param_oncanvas(SPLPEItem *lpeitem, SPDesktop *dt) +void SPLPEItem::editNextParamOncanvas(SPDesktop *dt) { - Inkscape::LivePathEffect::LPEObjectReference *lperef = sp_lpe_item_get_current_lpereference(lpeitem); + Inkscape::LivePathEffect::LPEObjectReference *lperef = this->getCurrentLPEReference(); if (lperef && lperef->lpeobject && lperef->lpeobject->get_lpe()) { - lperef->lpeobject->get_lpe()->editNextParamOncanvas(lpeitem, dt); + lperef->lpeobject->get_lpe()->editNextParamOncanvas(this, dt); } } @@ -637,29 +647,29 @@ static std::string hreflist_write_svg(HRefList const & list) } // Return a copy of the effect list -PathEffectList sp_lpe_item_get_effect_list(SPLPEItem *lpeitem) +PathEffectList SPLPEItem::getEffectList() { - return *(lpeitem->path_effect_list); + return *path_effect_list; } // Return a copy of the effect list -PathEffectList const sp_lpe_item_get_effect_list(SPLPEItem const *lpeitem) +PathEffectList const SPLPEItem::getEffectList() const { - return *(lpeitem->path_effect_list); + return *path_effect_list; } -Inkscape::LivePathEffect::LPEObjectReference* sp_lpe_item_get_current_lpereference(SPLPEItem *lpeitem) +Inkscape::LivePathEffect::LPEObjectReference* SPLPEItem::getCurrentLPEReference() { - if (!lpeitem->current_path_effect && !lpeitem->path_effect_list->empty()) { - sp_lpe_item_set_current_path_effect(lpeitem, lpeitem->path_effect_list->back()); + if (!this->current_path_effect && !this->path_effect_list->empty()) { + setCurrentPathEffect(this->path_effect_list->back()); } - return lpeitem->current_path_effect; + return this->current_path_effect; } -Inkscape::LivePathEffect::Effect* sp_lpe_item_get_current_lpe(SPLPEItem *lpeitem) +Inkscape::LivePathEffect::Effect* SPLPEItem::getCurrentLPE() { - Inkscape::LivePathEffect::LPEObjectReference* lperef = sp_lpe_item_get_current_lpereference(lpeitem); + Inkscape::LivePathEffect::LPEObjectReference* lperef = getCurrentLPEReference(); if (lperef && lperef->lpeobject) return lperef->lpeobject->get_lpe(); @@ -667,11 +677,11 @@ Inkscape::LivePathEffect::Effect* sp_lpe_item_get_current_lpe(SPLPEItem *lpeitem return NULL; } -bool sp_lpe_item_set_current_path_effect(SPLPEItem *lpeitem, Inkscape::LivePathEffect::LPEObjectReference* lperef) +bool SPLPEItem::setCurrentPathEffect(Inkscape::LivePathEffect::LPEObjectReference* lperef) { - for (PathEffectList::iterator it = lpeitem->path_effect_list->begin(); it != lpeitem->path_effect_list->end(); ++it) { + for (PathEffectList::iterator it = path_effect_list->begin(); it != path_effect_list->end(); ++it) { if ((*it)->lpeobject_repr == lperef->lpeobject_repr) { - lpeitem->current_path_effect = (*it); // current_path_effect should always be a pointer from the path_effect_list ! + this->current_path_effect = (*it); // current_path_effect should always be a pointer from the path_effect_list ! return true; } } @@ -714,21 +724,21 @@ void SPLPEItem::replacePathEffects( std::vector<LivePathEffectObject const *> co * use this method instead. * Returns true if one or more effects were forked; returns false if nothing was done. */ -bool sp_lpe_item_fork_path_effects_if_necessary(SPLPEItem *lpeitem, unsigned int nr_of_allowed_users) +bool SPLPEItem::forkPathEffectsIfNecessary(unsigned int nr_of_allowed_users) { bool forked = false; - if ( lpeitem->hasPathEffect() ) { + if ( this->hasPathEffect() ) { // If one of the path effects is used by 2 or more items, fork it // so that each object has its own independent copy of the effect. // Note: replacing path effects messes up the path effect list // Clones of the LPEItem will increase the refcount of the lpeobjects. // Therefore, nr_of_allowed_users should be increased with the number of clones (i.e. refs to the lpeitem) - nr_of_allowed_users += lpeitem->hrefcount; + nr_of_allowed_users += this->hrefcount; std::vector<LivePathEffectObject const *> old_lpeobjs, new_lpeobjs; - PathEffectList effect_list = sp_lpe_item_get_effect_list(lpeitem); + PathEffectList effect_list = this->getEffectList(); for (PathEffectList::iterator it = effect_list.begin(); it != effect_list.end(); ++it) { LivePathEffectObject *lpeobj = (*it)->lpeobject; @@ -743,7 +753,7 @@ bool sp_lpe_item_fork_path_effects_if_necessary(SPLPEItem *lpeitem, unsigned int } if (forked) { - lpeitem->replacePathEffects(old_lpeobjs, new_lpeobjs); + this->replacePathEffects(old_lpeobjs, new_lpeobjs); } } @@ -763,9 +773,9 @@ static void sp_lpe_item_enable_path_effects(SPLPEItem *lpeitem, bool enable) } // Are the path effects enabled on this item ? -bool sp_lpe_item_path_effects_enabled(SPLPEItem *lpeitem) +bool SPLPEItem::pathEffectsEnabled() const { - return lpeitem->path_effects_enabled > 0; + return path_effects_enabled > 0; } /* diff --git a/src/sp-lpe-item.h b/src/sp-lpe-item.h index 81adb938a..cd72ac55b 100644 --- a/src/sp-lpe-item.h +++ b/src/sp-lpe-item.h @@ -70,29 +70,34 @@ public: virtual void update_patheffect(bool write); + bool performPathEffect(SPCurve *curve); + + bool pathEffectsEnabled() const; bool hasPathEffect() const; + bool hasPathEffectOfType(int const type) const; bool hasPathEffectRecursive() const; Inkscape::LivePathEffect::Effect* getPathEffectOfType(int type); bool hasBrokenPathEffect() const; + + PathEffectList getEffectList(); + PathEffectList const getEffectList() const; + + void downCurrentPathEffect(); + void upCurrentPathEffect(); + Inkscape::LivePathEffect::LPEObjectReference* getCurrentLPEReference(); + Inkscape::LivePathEffect::Effect* getCurrentLPE(); + bool setCurrentPathEffect(Inkscape::LivePathEffect::LPEObjectReference* lperef); + void removeCurrentPathEffect(bool keep_paths); + void removeAllPathEffects(bool keep_paths); + void addPathEffect(gchar *value, bool reset); + void addPathEffect(LivePathEffectObject * new_lpeobj); + + bool forkPathEffectsIfNecessary(unsigned int nr_of_allowed_users = 1); + + void editNextParamOncanvas(SPDesktop *dt); }; -void sp_lpe_item_update_patheffect (SPLPEItem *lpeitem, bool wholetree, bool write); -bool sp_lpe_item_perform_path_effect(SPLPEItem *lpeitem, SPCurve *curve); -void sp_lpe_item_add_path_effect(SPLPEItem *lpeitem, gchar *value, bool reset); -void sp_lpe_item_add_path_effect(SPLPEItem *lpeitem, LivePathEffectObject * new_lpeobj); -bool sp_lpe_item_fork_path_effects_if_necessary(SPLPEItem *lpeitem, unsigned int nr_of_allowed_users = 1); -void sp_lpe_item_remove_all_path_effects(SPLPEItem *lpeitem, bool keep_paths); -void sp_lpe_item_remove_current_path_effect(SPLPEItem *lpeitem, bool keep_paths); -void sp_lpe_item_down_current_path_effect(SPLPEItem *lpeitem); -void sp_lpe_item_up_current_path_effect(SPLPEItem *lpeitem); -bool sp_lpe_item_can_accept_freehand_shape(SPLPEItem *lpeitem); -void sp_lpe_item_edit_next_param_oncanvas(SPLPEItem *lpeitem, SPDesktop *dt); -PathEffectList sp_lpe_item_get_effect_list(SPLPEItem *lpeitem); -PathEffectList const sp_lpe_item_get_effect_list(SPLPEItem const *lpeitem); -Inkscape::LivePathEffect::LPEObjectReference* sp_lpe_item_get_current_lpereference(SPLPEItem *lpeitem); -Inkscape::LivePathEffect::Effect* sp_lpe_item_get_current_lpe(SPLPEItem *lpeitem); -bool sp_lpe_item_set_current_path_effect(SPLPEItem *lpeitem, Inkscape::LivePathEffect::LPEObjectReference* lperef); -bool sp_lpe_item_path_effects_enabled(SPLPEItem *lpeitem); +void sp_lpe_item_update_patheffect (SPLPEItem *lpeitem, bool wholetree, bool write); // careful, class already has method with *very* similar name! #endif /* !SP_LPE_ITEM_H_SEEN */ diff --git a/src/sp-path.cpp b/src/sp-path.cpp index af2f02328..b225f0735 100644 --- a/src/sp-path.cpp +++ b/src/sp-path.cpp @@ -76,7 +76,7 @@ gchar* SPPath::description() { if (hasPathEffect()) { Glib::ustring s; - PathEffectList effect_list = sp_lpe_item_get_effect_list(this); + PathEffectList effect_list = this->getEffectList(); for (PathEffectList::iterator it = effect_list.begin(); it != effect_list.end(); ++it) { @@ -265,7 +265,7 @@ Geom::Affine SPPath::set_transform(Geom::Affine const &transform) { // Transform the original-d path if this is a valid LPE this, other else the (ordinary) path if (_curve_before_lpe && hasPathEffectRecursive()) { - if (getPathEffectOfType(Inkscape::LivePathEffect::CLONE_ORIGINAL)) { + if (this->hasPathEffectOfType(Inkscape::LivePathEffect::CLONE_ORIGINAL)) { // if path has the CLONE_ORIGINAL LPE applied, don't write the transform to the pathdata, but write it 'unoptimized' return transform; } else { @@ -307,7 +307,7 @@ g_message("sp_path_update_patheffect"); * This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/ this->setCurveInsync(curve, TRUE); - bool success = sp_lpe_item_perform_path_effect(this, curve); + bool success = this->performPathEffect(curve); if (success && write) { // could also do this->getRepr()->updateRepr(); but only the d attribute needs updating. diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp index 5d80e43fe..56aca507f 100644 --- a/src/sp-spiral.cpp +++ b/src/sp-spiral.cpp @@ -380,9 +380,9 @@ void SPSpiral::set_shape() { setCurveInsync( c, TRUE); setCurveBeforeLPE( c ); - if (hasPathEffect() && sp_lpe_item_path_effects_enabled(this)) { + if (hasPathEffect() && pathEffectsEnabled()) { SPCurve *c_lpe = c->copy(); - bool success = sp_lpe_item_perform_path_effect(this, c_lpe); + bool success = this->performPathEffect(c_lpe); if (success) { this->setCurveInsync( c_lpe, TRUE); diff --git a/src/sp-star.cpp b/src/sp-star.cpp index c2c0883e5..e634eccac 100644 --- a/src/sp-star.cpp +++ b/src/sp-star.cpp @@ -460,9 +460,9 @@ void SPStar::set_shape() { this->setCurveInsync( c, TRUE); this->setCurveBeforeLPE( c ); - if (hasPathEffect() && sp_lpe_item_path_effects_enabled(this)) { + if (hasPathEffect() && pathEffectsEnabled()) { SPCurve *c_lpe = c->copy(); - bool success = sp_lpe_item_perform_path_effect(this, c_lpe); + bool success = this->performPathEffect(c_lpe); if (success) { this->setCurveInsync( c_lpe, TRUE); diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 319928d99..ad40178fb 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -419,7 +419,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool { // apply live path effects prior to performing boolean operation if (SP_IS_LPE_ITEM(l->data)) { - sp_lpe_item_remove_all_path_effects(SP_LPE_ITEM(l->data), true); + SP_LPE_ITEM(l->data)->removeAllPathEffects(true); } SPCSSAttr *css = sp_repr_css_attr(reinterpret_cast<SPObject *>(il->data)->getRepr(), "style"); diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index ed28cabbd..da6fed86b 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -938,7 +938,7 @@ void ClipboardManagerImpl::_applyPathEffect(SPItem *item, gchar const *effectsta { SPLPEItem *lpeitem = SP_LPE_ITEM(item); // for each effect in the stack, check if we need to fork it before adding it to the item - sp_lpe_item_fork_path_effects_if_necessary(lpeitem, 1); + lpeitem->forkPathEffectsIfNecessary(1); std::istringstream iss(effectstack); std::string href; @@ -949,7 +949,7 @@ void ClipboardManagerImpl::_applyPathEffect(SPItem *item, gchar const *effectsta return; } LivePathEffectObject *lpeobj = LIVEPATHEFFECT(obj); - sp_lpe_item_add_path_effect(lpeitem, lpeobj); + lpeitem->addPathEffect(lpeobj); } } } diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index e96b57170..30b16cee0 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -280,7 +280,7 @@ LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel) set_sensitize_all(true); if ( lpeitem->hasPathEffect() ) { - Inkscape::LivePathEffect::Effect *lpe = sp_lpe_item_get_current_lpe(lpeitem); + Inkscape::LivePathEffect::Effect *lpe = lpeitem->getCurrentLPE(); if (lpe) { showParams(*lpe); lpe_list_locked = true; @@ -332,7 +332,7 @@ LivePathEffectEditor::effect_list_reload(SPLPEItem *lpeitem) { effectlist_store->clear(); - PathEffectList effectlist = sp_lpe_item_get_effect_list(lpeitem); + PathEffectList effectlist = lpeitem->getEffectList(); PathEffectList::iterator it; for( it = effectlist.begin() ; it!=effectlist.end(); ++it) { @@ -475,7 +475,7 @@ LivePathEffectEditor::onRemove() if ( sel && !sel->isEmpty() ) { SPItem *item = sel->singleItem(); if ( item && SP_IS_LPE_ITEM(item) ) { - sp_lpe_item_remove_current_path_effect(SP_LPE_ITEM(item), false); + SP_LPE_ITEM(item)->removeCurrentPathEffect(false); DocumentUndo::done( sp_desktop_document(current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Remove path effect") ); @@ -491,13 +491,13 @@ void LivePathEffectEditor::onUp() Inkscape::Selection *sel = _getSelection(); if ( sel && !sel->isEmpty() ) { SPItem *item = sel->singleItem(); - if ( item && SP_IS_LPE_ITEM(item) ) { - sp_lpe_item_up_current_path_effect(SP_LPE_ITEM(item)); + if ( SPLPEItem *lpeitem = SP_LPE_ITEM(item) ) { + lpeitem->upCurrentPathEffect(); DocumentUndo::done( sp_desktop_document(current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Move path effect up") ); - effect_list_reload(SP_LPE_ITEM(item)); + effect_list_reload(lpeitem); } } } @@ -507,13 +507,13 @@ void LivePathEffectEditor::onDown() Inkscape::Selection *sel = _getSelection(); if ( sel && !sel->isEmpty() ) { SPItem *item = sel->singleItem(); - if ( item && SP_IS_LPE_ITEM(item) ) { - sp_lpe_item_down_current_path_effect(SP_LPE_ITEM(item)); + if ( SPLPEItem *lpeitem = SP_LPE_ITEM(item) ) { + lpeitem->downCurrentPathEffect(); DocumentUndo::done( sp_desktop_document(current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Move path effect down") ); - effect_list_reload(SP_LPE_ITEM(item)); + effect_list_reload(lpeitem); } } } @@ -530,7 +530,7 @@ void LivePathEffectEditor::on_effect_selection_changed() if (lperef && current_lpeitem) { if (lperef->lpeobject->get_lpe()) { lpe_list_locked = true; // prevent reload of the list which would lose selection - sp_lpe_item_set_current_path_effect(current_lpeitem, lperef); + current_lpeitem->setCurrentPathEffect(lperef); showParams(*lperef->lpeobject->get_lpe()); } } diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 10e50a970..f72313315 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -222,7 +222,7 @@ void PathManipulator::writeXML() sp_object_ref(_path); _path->deleteObject(true, true); sp_object_unref(_path); - _path = 0; + _path = NULL; } _observer->unblock(); } @@ -1317,8 +1317,9 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE) Geom::PathVector pathv = builder.peek() * (_edit_transform * _i2d_transform).inverse(); _spcurve->set_pathvector(pathv); if (alert_LPE) { + /// \todo note that _path can be an Inkscape::LivePathEffect::Effect* too, kind of confusing, rework member naming? if (SP_IS_LPE_ITEM(_path) && _path->hasPathEffect()) { - PathEffectList effect_list = sp_lpe_item_get_effect_list(_path); + PathEffectList effect_list = _path->getEffectList(); LivePathEffect::LPEPowerStroke *lpe_pwr = dynamic_cast<LivePathEffect::LPEPowerStroke*>( effect_list.front()->lpeobject->get_lpe() ); if (lpe_pwr) { lpe_pwr->adjustForNewPath(pathv); @@ -1419,6 +1420,10 @@ void PathManipulator::_getGeometry() } else { _spcurve->unref(); _spcurve = _path->get_curve_for_edit(); + // never allow NULL to sneak in here! + if (_spcurve == NULL) { + _spcurve = new SPCurve(); + } } } diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h index 2fc0b90da..8bf228a54 100644 --- a/src/ui/tool/path-manipulator.h +++ b/src/ui/tool/path-manipulator.h @@ -144,7 +144,7 @@ private: SubpathList _subpaths; MultiPathManipulator &_multi_path_manipulator; - SPPath *_path; + SPPath *_path; ///< can be an SPPath or an Inkscape::LivePathEffect::Effect !!! SPCurve *_spcurve; // in item coordinates SPCanvasItem *_outline; CurveDragPoint *_dragpoint; // an invisible control point hoverng over curve diff --git a/src/widgets/lpe-toolbar.cpp b/src/widgets/lpe-toolbar.cpp index 55cce90cd..922526a9f 100644 --- a/src/widgets/lpe-toolbar.cpp +++ b/src/widgets/lpe-toolbar.cpp @@ -145,7 +145,7 @@ static void sp_lpetool_toolbox_sel_changed(Inkscape::Selection *selection, GObje SPItem *item = selection->singleItem(); if (item && SP_IS_LPE_ITEM(item) && lpetool_item_has_construction(lc, item)) { SPLPEItem *lpeitem = SP_LPE_ITEM(item); - Effect* lpe = sp_lpe_item_get_current_lpe(lpeitem); + Effect* lpe = lpeitem->getCurrentLPE(); if (lpe && lpe->effectType() == LINE_SEGMENT) { LPELineSegment *lpels = static_cast<LPELineSegment*>(lpe); g_object_set_data(tbl, "currentlpe", lpe); |
