summaryrefslogtreecommitdiffstats
path: root/src/object
diff options
context:
space:
mode:
authorAlexander Valavanis <valavanisalex@gmail.com>2019-06-05 19:33:55 +0000
committerAlexander Valavanis <valavanisalex@gmail.com>2019-06-05 19:33:55 +0000
commit2e40143d6e75d50bf659abddc5c7c25fb1bc2436 (patch)
treee2fa747c95569dc3f77fcdfa770b3d404ff065cc /src/object
parentHackfest2019: Rm tautological tests (diff)
parentUse a flowbox when there are more than two options for font feature settings. (diff)
downloadinkscape-2e40143d6e75d50bf659abddc5c7c25fb1bc2436.tar.gz
inkscape-2e40143d6e75d50bf659abddc5c7c25fb1bc2436.zip
Merge changes
Diffstat (limited to 'src/object')
-rw-r--r--src/object/sp-rect.cpp48
-rw-r--r--src/object/sp-rect.h2
-rw-r--r--src/object/sp-shape.cpp15
-rw-r--r--src/object/sp-shape.h5
4 files changed, 61 insertions, 9 deletions
diff --git a/src/object/sp-rect.cpp b/src/object/sp-rect.cpp
index 207d2fc5a..1ecfab558 100644
--- a/src/object/sp-rect.cpp
+++ b/src/object/sp-rect.cpp
@@ -19,9 +19,10 @@
#include "attributes.h"
#include "style.h"
#include "sp-rect.h"
-#include <glibmm/i18n.h>
#include "sp-guide.h"
#include "preferences.h"
+#include "svg/svg.h"
+#include <glibmm/i18n.h>
#define noRECT_VERBOSE
@@ -193,6 +194,20 @@ const char* SPRect::displayName() const {
#define C1 0.554
void SPRect::set_shape() {
+ if (hasBrokenPathEffect()) {
+ g_warning ("The spiral shape has unknown LPE on it! Convert to path to make it editable preserving the appearance; editing it as spiral will remove the bad LPE");
+
+ if (this->getRepr()->attribute("d")) {
+ // 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);
+ this->setCurveBeforeLPE( cold );
+ cold->unref();
+ }
+
+ return;
+ }
if ((this->height.computed < 1e-18) || (this->width.computed < 1e-18)) {
this->setCurveInsync(nullptr);
this->setCurveBeforeLPE(nullptr);
@@ -259,13 +274,26 @@ void SPRect::set_shape() {
c->lineto(x + w, y + h);
c->lineto(x + 0.0, y + h);
}
-
- c->closepath();
- this->setCurveInsync(c);
- this->setCurveBeforeLPE(c);
-
- // LPE is not applied because result can generally not be represented as SPRect
-
+ /* 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)*/
+ SPCurve * before = this->getCurveBeforeLPE();
+ bool haslpe = this->hasPathEffectOnClipOrMaskRecursive(this);
+ if (before || haslpe) {
+ if (c && before && before->get_pathvector() != c->get_pathvector()){
+ this->setCurveBeforeLPE(c);
+ sp_lpe_item_update_patheffect(this, true, false);
+ } else if(haslpe) {
+ this->setCurveBeforeLPE(c);
+ } else {
+ //This happends on undo, fix bug:#1791784
+ this->setCurveInsync(c);
+ }
+ } else {
+ this->setCurveInsync(c);
+ }
+ if (before) {
+ before->unref();
+ }
c->unref();
}
@@ -300,6 +328,10 @@ void SPRect::setRy(bool set, gdouble value) {
this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
+void SPRect::update_patheffect(bool write) {
+ SPShape::update_patheffect(write);
+}
+
Geom::Affine SPRect::set_transform(Geom::Affine const& xform) {
/* Calculate rect start in parent coords. */
Geom::Point pos(Geom::Point(this->x.computed, this->y.computed) * xform);
diff --git a/src/object/sp-rect.h b/src/object/sp-rect.h
index 39fac16f9..bbc9d3c69 100644
--- a/src/object/sp-rect.h
+++ b/src/object/sp-rect.h
@@ -57,7 +57,7 @@ public:
Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags) override;
const char* displayName() const override;
-
+ void update_patheffect(bool write) override;
void set_shape() override;
Geom::Affine set_transform(Geom::Affine const& xform) override;
diff --git a/src/object/sp-shape.cpp b/src/object/sp-shape.cpp
index d615980c0..eb4c01e54 100644
--- a/src/object/sp-shape.cpp
+++ b/src/object/sp-shape.cpp
@@ -121,6 +121,10 @@ void SPShape::update(SPCtx* ctx, guint flags) {
// std::cout << "SPShape::update(): " << (getId()?getId():"null") << std::endl;
SPLPEItem::update(ctx, flags);
+ // Any update can change the bounding box,
+ // so the cached version can no longer be used.
+ bbox_cache_is_valid = false;
+
/* This stanza checks that an object's marker style agrees with
* the marker objects it has allocated. sp_shape_set_marker ensures
* that the appropriate marker objects are present (or absent) to
@@ -456,6 +460,13 @@ void SPShape::modified(unsigned int flags) {
}
Geom::OptRect SPShape::bbox(Geom::Affine const &transform, SPItem::BBoxType bboxtype) const {
+ // If the object is clipped, the update funcation that invalidates
+ // the cache doesn't get called if the object is moved, so we need
+ // to compare the transformations as well.
+ if (bbox_cache_is_valid && transform == bbox_transform_cache) {
+ return bbox_cache;
+ }
+
Geom::OptRect bbox;
if (!this->_curve || this->_curve->get_pathvector().empty()) {
@@ -641,6 +652,10 @@ Geom::OptRect SPShape::bbox(Geom::Affine const &transform, SPItem::BBoxType bbox
}
}
+ bbox_transform_cache = transform;
+ bbox_cache = bbox;
+ bbox_cache_is_valid = true;
+
return bbox;
}
diff --git a/src/object/sp-shape.h b/src/object/sp-shape.h
index 6289be079..10d719648 100644
--- a/src/object/sp-shape.h
+++ b/src/object/sp-shape.h
@@ -49,6 +49,11 @@ public:
int hasMarkers () const;
int numberOfMarkers (int type) const;
+ // bbox cache
+ mutable bool bbox_cache_is_valid = false;
+ mutable Geom::Affine bbox_transform_cache;
+ mutable Geom::OptRect bbox_cache;
+
public: // temporarily public, until SPPath is properly classed, etc.
SPCurve *_curve_before_lpe;