summaryrefslogtreecommitdiffstats
path: root/src/object/sp-path.cpp
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2018-03-03 00:12:41 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2018-03-26 17:48:34 +0000
commit95b1c7b549605d7c6ce6623cc4cd121ed7c51a64 (patch)
tree1c38b4fe6baabbf45c55e0929516dd825f7d6847 /src/object/sp-path.cpp
parentAllow building with USE_PANGO_WIN32. (diff)
downloadinkscape-95b1c7b549605d7c6ce6623cc4cd121ed7c51a64.tar.gz
inkscape-95b1c7b549605d7c6ce6623cc4cd121ed7c51a64.zip
Base LPE refactor
Diffstat (limited to 'src/object/sp-path.cpp')
-rw-r--r--src/object/sp-path.cpp135
1 files changed, 6 insertions, 129 deletions
diff --git a/src/object/sp-path.cpp b/src/object/sp-path.cpp
index bad843a05..3c64c09b0 100644
--- a/src/object/sp-path.cpp
+++ b/src/object/sp-path.cpp
@@ -191,13 +191,14 @@ void SPPath::set(unsigned int key, const gchar* value) {
SPCurve *curve = new SPCurve(pv);
if (curve) {
- this->set_original_curve(curve, TRUE, true);
+ this->setCurveBeforeLPE(curve);
curve->unref();
}
} else {
- this->set_original_curve(NULL, TRUE, true);
+ this->setCurveBeforeLPE(NULL);
+
}
-
+ sp_lpe_item_update_patheffect(this, true, true);
this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
break;
@@ -207,11 +208,11 @@ void SPPath::set(unsigned int key, const gchar* value) {
SPCurve *curve = new SPCurve(pv);
if (curve) {
- this->setCurve(curve, TRUE);
+ this->setCurve(curve);
curve->unref();
}
} else {
- this->setCurve(NULL, TRUE);
+ this->setCurve(NULL);
}
this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
@@ -361,130 +362,6 @@ Geom::Affine SPPath::set_transform(Geom::Affine const &transform) {
return Geom::identity();
}
-
-void SPPath::update_patheffect(bool write) {
- Inkscape::XML::Node *repr = this->getRepr();
-
-#ifdef PATH_VERBOSE
-g_message("sp_path_update_patheffect");
-#endif
-
- if (_curve_before_lpe && hasPathEffectRecursive()) {
- SPCurve *curve = _curve_before_lpe->copy();
- /* if a path has an lpeitem applied, then reset the curve to the _curve_before_lpe.
- * 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 = this->performPathEffect(curve);
-
- if (success && write) {
- // could also do this->getRepr()->updateRepr(); but only the d attribute needs updating.
-#ifdef PATH_VERBOSE
-g_message("sp_path_update_patheffect writes 'd' attribute");
-#endif
- if (_curve) {
- gchar *str = sp_svg_write_path(this->_curve->get_pathvector());
- repr->setAttribute("d", str);
- g_free(str);
- } else {
- repr->setAttribute("d", NULL);
- }
- } else if (!success) {
- // LPE was unsuccessful. Read the old 'd'-attribute.
- if (gchar const * value = repr->attribute("d")) {
- Geom::PathVector pv = sp_svg_read_pathv(value);
- SPCurve *oldcurve = new SPCurve(pv);
-
- if (oldcurve) {
- this->setCurve(oldcurve, TRUE);
- oldcurve->unref();
- }
- }
- }
-
- this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
- curve->unref();
- }
-}
-
-
-/**
- * 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);
-}
-
-/**
- * Return duplicate of _curve_before_lpe (if any exists) or NULL if there is no curve
- */
-SPCurve * SPPath::get_original_curve () const
-{
- if (_curve_before_lpe) {
- return _curve_before_lpe->copy();
- }
-
- return NULL;
-}
-
-/**
- * Return duplicate of edittable curve which is _curve_before_lpe if it exists or
- * shape->curve if not.
- */
-SPCurve* SPPath::get_curve_for_edit () const
-{
- if (_curve_before_lpe && hasPathEffectRecursive()) {
- return get_original_curve();
- } else {
- return getCurve();
- }
-}
-
-/**
- * Returns \c _curve_before_lpe if it is not NULL and a valid LPE is applied or
- * \c curve if not.
- */
-const SPCurve* SPPath::get_curve_reference () const
-{
- if (_curve_before_lpe && hasPathEffectRecursive()) {
- return _curve_before_lpe;
- } else {
- return _curve;
- }
-}
-
-/**
- * Returns \c _curve_before_lpe if it is not NULL and a valid LPE is applied or \c curve if not.
- * \todo should only be available to class friends!
- */
-SPCurve* SPPath::get_curve ()
-{
- if (_curve_before_lpe && hasPathEffectRecursive()) {
- return _curve_before_lpe;
- } else {
- return _curve;
- }
-}
-
/*
Local Variables:
mode:c++