summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabiertxo Arraiza Cenoz <jtx@jtx-desktop.markerlab.es>2017-10-09 18:33:01 +0000
committerJabiertxo Arraiza Cenoz <jtx@jtx-desktop.markerlab.es>2017-10-09 18:33:01 +0000
commitf318dbfe434769ab62b4f9d2971de89f1ebffc71 (patch)
treeb8a71ce927ac97ff2cd320809e7f0978213316f9 /src
parentCircle3pts LPE: handle overlapping points (diff)
downloadinkscape-f318dbfe434769ab62b4f9d2971de89f1ebffc71.tar.gz
inkscape-f318dbfe434769ab62b4f9d2971de89f1ebffc71.zip
Fixes for transforms in LPE shapes
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/lpe-measure-segments.cpp21
-rw-r--r--src/live_effects/lpe-measure-segments.h3
-rw-r--r--src/sp-ellipse.cpp16
-rw-r--r--src/sp-spiral.cpp29
-rw-r--r--src/sp-star.cpp30
5 files changed, 75 insertions, 24 deletions
diff --git a/src/live_effects/lpe-measure-segments.cpp b/src/live_effects/lpe-measure-segments.cpp
index b929f5154..738990bc0 100644
--- a/src/live_effects/lpe-measure-segments.cpp
+++ b/src/live_effects/lpe-measure-segments.cpp
@@ -31,6 +31,8 @@
#include "sp-item.h"
#include "sp-shape.h"
#include "sp-path.h"
+#include "sp-star.h"
+#include "sp-spiral.h"
#include "document.h"
#include "document-undo.h"
#include <iomanip>
@@ -136,6 +138,7 @@ LPEMeasureSegments::LPEMeasureSegments(LivePathEffectObject *lpeobject) :
helpline_overlap.param_set_range(-999999.0, 999999.0);
helpline_overlap.param_set_increments(1, 1);
helpline_overlap.param_set_digits(2);
+ star_ellipse_fix = Geom::identity();
}
LPEMeasureSegments::~LPEMeasureSegments() {}
@@ -566,7 +569,7 @@ void
LPEMeasureSegments::doBeforeEffect (SPLPEItem const* lpeitem)
{
SPLPEItem * splpeitem = const_cast<SPLPEItem *>(lpeitem);
- sp_lpe_item->parent = dynamic_cast<SPObject *>(splpeitem->parent);
+
SPDocument * document = SP_ACTIVE_DOCUMENT;
if (!document) {
return;
@@ -589,12 +592,17 @@ LPEMeasureSegments::doBeforeEffect (SPLPEItem const* lpeitem)
}
Geom::Point start_stored;
Geom::Point end_stored;
- Geom::Affine affinetransform = i2anc_affine(SP_OBJECT(lpeitem), SP_OBJECT(document->getRoot()));
+ Geom::Affine affinetransform = i2anc_affine(SP_OBJECT(lpeitem->parent), SP_OBJECT(document->getRoot()));
Geom::PathVector pathvector = pathv_to_linear_and_cubic_beziers(c->get_pathvector());
c->unref();
Geom::Affine writed_transform = Geom::identity();
sp_svg_transform_read(splpeitem->getAttribute("transform"), &writed_transform );
- pathvector *= writed_transform;
+ if (star_ellipse_fix != Geom::identity()) {
+ pathvector *= star_ellipse_fix;
+ star_ellipse_fix = Geom::identity();
+ } else {
+ pathvector *= writed_transform;
+ }
if ((Glib::ustring(format.param_getSVGValue()).empty())) {
format.param_setValue(Glib::ustring("{measure}{unit}"));
}
@@ -819,7 +827,12 @@ LPEMeasureSegments::doOnRemove (SPLPEItem const* /*lpeitem*/)
void
LPEMeasureSegments::transform_multiply(Geom::Affine const& postmul, bool set)
{
- sp_lpe_item_update_patheffect(sp_lpe_item, false, false);
+ SPStar * star = dynamic_cast<SPStar *>(sp_lpe_item);
+ SPSpiral * spiral = dynamic_cast<SPSpiral *>(sp_lpe_item);
+ if((spiral || star) && !postmul.withoutTranslation().isUniformScale()) {
+ star_ellipse_fix = postmul;
+ sp_lpe_item_update_patheffect(sp_lpe_item, false, false);
+ }
}
Geom::PathVector
diff --git a/src/live_effects/lpe-measure-segments.h b/src/live_effects/lpe-measure-segments.h
index 0b4ed5ef7..3b14fb191 100644
--- a/src/live_effects/lpe-measure-segments.h
+++ b/src/live_effects/lpe-measure-segments.h
@@ -44,7 +44,7 @@ public:
virtual void doOnRemove (SPLPEItem const* /*lpeitem*/);
virtual void doEffect (SPCurve * curve){}; //stop the chain
virtual void doOnVisibilityToggled(SPLPEItem const* /*lpeitem*/);
- virtual void transform_multiply(Geom::Affine const& postmul, bool set);
+ virtual void transform_multiply(Geom::Affine const& postmul, bool set);
virtual Geom::PathVector doEffect_path(Geom::PathVector const &path_in);
void createLine(Geom::Point start,Geom::Point end, const char * id, bool main, bool remove, bool arrows = false);
void createTextLabel(Geom::Point pos, size_t counter, double length, Geom::Coord angle, bool remove, bool valid);
@@ -79,6 +79,7 @@ private:
double anotation_width;
double previous_size;
double arrow_gap;
+ Geom::Affine star_ellipse_fix;
LPEMeasureSegments(const LPEMeasureSegments &);
LPEMeasureSegments &operator=(const LPEMeasureSegments &);
diff --git a/src/sp-ellipse.cpp b/src/sp-ellipse.cpp
index c2dca1fc3..bf50128f6 100644
--- a/src/sp-ellipse.cpp
+++ b/src/sp-ellipse.cpp
@@ -17,6 +17,8 @@
#include <glibmm.h>
#include <glibmm/i18n.h>
+#include "live_effects/effect.h"
+
#include <2geom/angle.h>
#include <2geom/circle.h>
#include <2geom/ellipse.h>
@@ -501,13 +503,18 @@ void SPGenericEllipse::set_shape(bool force)
Geom::Affine SPGenericEllipse::set_transform(Geom::Affine const &xform)
{
- // Allow live effects
- if (hasPathEffect() && pathEffectsEnabled()) {
+ if (hasPathEffect() && pathEffectsEnabled() &&
+ (this->hasPathEffectOfType(Inkscape::LivePathEffect::CLONE_ORIGINAL) ||
+ this->hasPathEffectOfType(Inkscape::LivePathEffect::BEND_PATH) ||
+ this->hasPathEffectOfType(Inkscape::LivePathEffect::FILL_BETWEEN_MANY) ||
+ this->hasPathEffectOfType(Inkscape::LivePathEffect::FILL_BETWEEN_STROKES) ) )
+ {
+ // if path has this LPE applied, don't write the transform to the pathdata, but write it 'unoptimized'
+ // also if the effect is type BEND PATH to fix bug #179842
this->adjust_livepatheffect(xform);
this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
return xform;
}
-
/* Calculate ellipse start in parent coords. */
Geom::Point pos(Geom::Point(this->cx.computed, this->cy.computed) * xform);
@@ -557,6 +564,9 @@ Geom::Affine SPGenericEllipse::set_transform(Geom::Affine const &xform)
// Adjust gradient fill
this->adjust_gradient(xform * ret.inverse());
+ // Adjust livepatheffect
+ this->adjust_livepatheffect(xform);
+
this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
return ret;
diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp
index f59fc0720..f35d5e86b 100644
--- a/src/sp-spiral.cpp
+++ b/src/sp-spiral.cpp
@@ -14,7 +14,7 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-
+#include "live_effects/effect.h"
#include "svg/svg.h"
#include "attributes.h"
#include <2geom/bezier-utils.h>
@@ -429,17 +429,27 @@ void SPSpiral::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape
*/
Geom::Affine SPSpiral::set_transform(Geom::Affine const &xform)
{
- // Only set transform with proportional scaling
- if (!xform.withoutTranslation().isUniformScale()) {
- return xform;
- }
-
- // Allow live effects
- if (hasPathEffect() && pathEffectsEnabled()) {
+ if (hasPathEffect() && pathEffectsEnabled() &&
+ (this->hasPathEffectOfType(Inkscape::LivePathEffect::CLONE_ORIGINAL) ||
+ this->hasPathEffectOfType(Inkscape::LivePathEffect::BEND_PATH) ||
+ this->hasPathEffectOfType(Inkscape::LivePathEffect::FILL_BETWEEN_MANY) ||
+ this->hasPathEffectOfType(Inkscape::LivePathEffect::FILL_BETWEEN_STROKES) ) )
+ {
+ // if path has this LPE applied, don't write the transform to the pathdata, but write it 'unoptimized'
+ // also if the effect is type BEND PATH to fix bug #179842
this->adjust_livepatheffect(xform);
this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
return xform;
}
+ // Only set transform with proportional scaling
+ if (!xform.withoutTranslation().isUniformScale()) {
+ // Adjust livepatheffect
+ if (hasPathEffect() && pathEffectsEnabled()) {
+ this->adjust_livepatheffect(xform);
+ this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
+ }
+ return xform;
+ }
/* Calculate spiral start in parent coords. */
Geom::Point pos( Geom::Point(this->cx, this->cy) * xform );
@@ -478,6 +488,9 @@ Geom::Affine SPSpiral::set_transform(Geom::Affine const &xform)
// Adjust gradient fill
this->adjust_gradient(xform * ret.inverse());
+ // Adjust livepatheffect
+ this->adjust_livepatheffect(xform);
+
this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
return ret;
diff --git a/src/sp-star.cpp b/src/sp-star.cpp
index 5913dde20..ccc8323d4 100644
--- a/src/sp-star.cpp
+++ b/src/sp-star.cpp
@@ -20,7 +20,7 @@
#include <cstring>
#include <string>
#include <glib.h>
-#include <glibmm/i18n.h>
+#include "live_effects/effect.h"
#include "svg/svg.h"
#include "attributes.h"
@@ -29,6 +29,7 @@
#include "document.h"
#include "sp-star.h"
+#include <glibmm/i18n.h>
SPStar::SPStar() : SPPolygon() ,
sides(5),
@@ -511,17 +512,27 @@ void SPStar::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::
Geom::Affine SPStar::set_transform(Geom::Affine const &xform)
{
bool opt_trans = (randomized == 0);
- // Only set transform with proportional scaling
- if (!xform.withoutTranslation().isUniformScale()) {
- return xform;
- }
-
- // Allow live effects
- if (hasPathEffect() && pathEffectsEnabled()) {
+ if (hasPathEffect() && pathEffectsEnabled() &&
+ (this->hasPathEffectOfType(Inkscape::LivePathEffect::CLONE_ORIGINAL) ||
+ this->hasPathEffectOfType(Inkscape::LivePathEffect::BEND_PATH) ||
+ this->hasPathEffectOfType(Inkscape::LivePathEffect::FILL_BETWEEN_MANY) ||
+ this->hasPathEffectOfType(Inkscape::LivePathEffect::FILL_BETWEEN_STROKES) ) )
+ {
+ // if path has this LPE applied, don't write the transform to the pathdata, but write it 'unoptimized'
+ // also if the effect is type BEND PATH to fix bug #179842
this->adjust_livepatheffect(xform);
this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
return xform;
}
+ // Only set transform with proportional scaling
+ if (!xform.withoutTranslation().isUniformScale()) {
+ // Adjust livepatheffect
+ if (hasPathEffect() && pathEffectsEnabled()) {
+ this->adjust_livepatheffect(xform);
+ this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
+ }
+ return xform;
+ }
/* Calculate star start in parent coords. */
Geom::Point pos( this->center * xform );
@@ -560,6 +571,9 @@ Geom::Affine SPStar::set_transform(Geom::Affine const &xform)
// Adjust gradient fill
this->adjust_gradient(xform * ret.inverse());
+ // Adjust livepatheffect
+ this->adjust_livepatheffect(xform);
+
this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
return ret;