diff options
| author | Jabier Arraiza <jabier.arraiza@marker.es> | 2018-03-03 00:12:41 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2018-03-26 17:48:34 +0000 |
| commit | 95b1c7b549605d7c6ce6623cc4cd121ed7c51a64 (patch) | |
| tree | 1c38b4fe6baabbf45c55e0929516dd825f7d6847 /src/object/sp-ellipse.cpp | |
| parent | Allow building with USE_PANGO_WIN32. (diff) | |
| download | inkscape-95b1c7b549605d7c6ce6623cc4cd121ed7c51a64.tar.gz inkscape-95b1c7b549605d7c6ce6623cc4cd121ed7c51a64.zip | |
Base LPE refactor
Diffstat (limited to 'src/object/sp-ellipse.cpp')
| -rw-r--r-- | src/object/sp-ellipse.cpp | 66 |
1 files changed, 21 insertions, 45 deletions
diff --git a/src/object/sp-ellipse.cpp b/src/object/sp-ellipse.cpp index c32e3012c..95bfd6160 100644 --- a/src/object/sp-ellipse.cpp +++ b/src/object/sp-ellipse.cpp @@ -18,6 +18,8 @@ #include <glibmm/i18n.h> #include "live_effects/effect.h" +#include "live_effects/lpeobject.h" +#include "live_effects/lpeobject-reference.h" #include <2geom/angle.h> #include <2geom/circle.h> @@ -410,7 +412,7 @@ const char *SPGenericEllipse::displayName() const } // Create path for rendering shape on screen -void SPGenericEllipse::set_shape(bool force) +void SPGenericEllipse::set_shape() { // std::cout << "SPGenericEllipse::set_shape: Entrance" << std::endl; if (hasBrokenPathEffect()) { @@ -420,7 +422,7 @@ void SPGenericEllipse::set_shape(bool force) // unconditionally read the curve from d, if any, to preserve appearance Geom::PathVector pv = sp_svg_read_pathv(this->getRepr()->attribute("d")); SPCurve *cold = new SPCurve(pv); - this->setCurveInsync(cold, TRUE); + this->setCurveInsync(cold); cold->unref(); } @@ -432,7 +434,7 @@ void SPGenericEllipse::set_shape(bool force) this->normalize(); - SPCurve *curve = NULL; + SPCurve *c = NULL; // For simplicity, we use a circle with center (0, 0) and radius 1 for our calculations. Geom::Circle circle(0, 0, 1); @@ -465,7 +467,7 @@ void SPGenericEllipse::set_shape(bool force) } else { pb.flush(); } - curve = new SPCurve(pb.peek()); + c = new SPCurve(pb.peek()); // gchar *str = sp_svg_write_path(curve->get_pathvector()); // std::cout << " path: " << str << std::endl; @@ -473,32 +475,25 @@ void SPGenericEllipse::set_shape(bool force) // Stretching / moving the calculated shape to fit the actual dimensions. Geom::Affine aff = Geom::Scale(rx.computed, ry.computed) * Geom::Translate(cx.computed, cy.computed); - curve->transform(aff); - + c->transform(aff); + /* Reset the shape's curve to the "original_curve" * This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/ - if(this->getCurveBeforeLPE()) { - if(!force && this->getCurveBeforeLPE()->get_pathvector() == curve->get_pathvector()) { - curve->unref(); - return; + SPCurve * before = this->getCurveBeforeLPE(); + if (before || this->hasPathEffectRecursive()) { + if (!before || before->get_pathvector() != c->get_pathvector()){ + this->setCurveBeforeLPE(c); + this->update_patheffect(false); + } else { + this->setCurveBeforeLPE(c); } + } else { + this->setCurveInsync(c); } - this->setCurveInsync(curve, TRUE); - this->setCurveBeforeLPE(curve); - - if (hasPathEffect() && pathEffectsEnabled()) { - SPCurve *c_lpe = curve->copy(); - bool success = this->performPathEffect(c_lpe); - - if (success) { - this->setCurveInsync(c_lpe, TRUE); - } - - c_lpe->unref(); + if (before) { + before->unref(); } - - curve->unref(); - // std::cout << "SPGenericEllipse::set_shape: Exit" << std::endl; + c->unref(); } Geom::Affine SPGenericEllipse::set_transform(Geom::Affine const &xform) @@ -633,25 +628,6 @@ void SPGenericEllipse::modified(guint flags) SPShape::modified(flags); } -void SPGenericEllipse::update_patheffect(bool write) -{ - this->set_shape(true); - - if (write) { - Inkscape::XML::Node *repr = this->getRepr(); - - if (this->_curve != NULL && type == SP_GENERIC_ELLIPSE_ARC) { - gchar *str = sp_svg_write_path(this->_curve->get_pathvector()); - repr->setAttribute("d", str); - g_free(str); - } else { - repr->setAttribute("d", NULL); - } - } - - this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); -} - void SPGenericEllipse::normalize() { Geom::AngleInterval a(this->start, this->end, true); @@ -698,7 +674,7 @@ void SPGenericEllipse::position_set(gdouble x, gdouble y, gdouble rx, gdouble ry this->rx = rx; this->ry = ry; - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + Inkscape::Preferences * prefs = Inkscape::Preferences::get(); // those pref values are in degrees, while we want radians if (prefs->getDouble("/tools/shapes/arc/start", 0.0) != 0) { |
