summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2016-09-11 10:10:44 +0000
committerjabiertxof <info@marker.es>2016-09-11 10:10:44 +0000
commitd16ce258120800e84bfca5c3c687c25177a3137c (patch)
tree6bea797a1d28f66544796fb646246bb0b3212172 /src
parentFix bug: #1621213 in Pattern Along Path LPE (diff)
downloadinkscape-d16ce258120800e84bfca5c3c687c25177a3137c.tar.gz
inkscape-d16ce258120800e84bfca5c3c687c25177a3137c.zip
Fix bugs: #1621234 and #172137
Fixed bugs: - https://launchpad.net/bugs/172137 - https://launchpad.net/bugs/1621234 (bzr r15111)
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/lpe-bendpath.cpp14
-rw-r--r--src/live_effects/lpe-bendpath.h2
-rw-r--r--src/live_effects/lpe-patternalongpath.cpp21
-rw-r--r--src/live_effects/lpe-patternalongpath.h1
-rw-r--r--src/ui/tools/freehand-base.cpp39
5 files changed, 36 insertions, 41 deletions
diff --git a/src/live_effects/lpe-bendpath.cpp b/src/live_effects/lpe-bendpath.cpp
index 2ba1e32b4..c24d38d7b 100644
--- a/src/live_effects/lpe-bendpath.cpp
+++ b/src/live_effects/lpe-bendpath.cpp
@@ -67,7 +67,6 @@ LPEBendPath::LPEBendPath(LivePathEffectObject *lpeobject) :
_provides_knotholder_entities = true;
apply_to_clippath_and_mask = true;
concatenate_before_pwd2 = true;
- _prop_scale_store = prop_scale;
}
LPEBendPath::~LPEBendPath()
@@ -81,9 +80,6 @@ LPEBendPath::doBeforeEffect (SPLPEItem const* lpeitem)
// get the item bounding box
original_bbox(lpeitem);
original_height = boundingbox_Y.max() - boundingbox_Y.min();
- if(_prop_scale_store != prop_scale) {
- prop_scale.param_set_value(_prop_scale_store);
- }
}
Geom::Piecewise<Geom::D2<Geom::SBasis> >
@@ -124,9 +120,9 @@ LPEBendPath::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd
}
if ( scale_y_rel.get_value() ) {
- y*=(scaling*_prop_scale_store);
+ y*=(scaling*prop_scale);
} else {
- if (_prop_scale_store != 1.0) y *= _prop_scale_store;
+ if (prop_scale != 1.0) y *= prop_scale;
}
Piecewise<D2<SBasis> > output = compose(uskeleton,x) + y*compose(n,x);
@@ -188,9 +184,9 @@ KnotHolderEntityWidthBendPath::knot_set(Geom::Point const &p, Geom::Point const&
Geom::Point knot_pos = this->knot->pos * item->i2dt_affine().inverse();
Geom::Coord nearest_to_ray = ray.nearestTime(knot_pos);
if(nearest_to_ray == 0){
- lpe->_prop_scale_store = -Geom::distance(s , ptA)/(lpe->original_height/2.0);
+ lpe->prop_scale.param_set_value(-Geom::distance(s , ptA)/(lpe->original_height/2.0));
} else {
- lpe->_prop_scale_store = Geom::distance(s , ptA)/(lpe->original_height/2.0);
+ lpe->prop_scale.param_set_value(Geom::distance(s , ptA)/(lpe->original_height/2.0));
}
sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true);
@@ -211,7 +207,7 @@ KnotHolderEntityWidthBendPath::knot_get() const
ray.setPoints(ptA,(*cubic)[1]);
}
ray.setAngle(ray.angle() + Geom::rad_from_deg(90));
- Geom::Point result_point = Geom::Point::polar(ray.angle(), (lpe->original_height/2.0) * lpe->_prop_scale_store) + ptA;
+ Geom::Point result_point = Geom::Point::polar(ray.angle(), (lpe->original_height/2.0) * lpe->prop_scale) + ptA;
bp_helper_path.clear();
Geom::Path hp(result_point);
diff --git a/src/live_effects/lpe-bendpath.h b/src/live_effects/lpe-bendpath.h
index 36789bb15..eeda86a5e 100644
--- a/src/live_effects/lpe-bendpath.h
+++ b/src/live_effects/lpe-bendpath.h
@@ -58,7 +58,7 @@ private:
BoolParam vertical_pattern;
Geom::Piecewise<Geom::D2<Geom::SBasis> > uskeleton;
Geom::Piecewise<Geom::D2<Geom::SBasis> > n;
- double _prop_scale_store;
+
void on_pattern_pasted();
LPEBendPath(const LPEBendPath&);
diff --git a/src/live_effects/lpe-patternalongpath.cpp b/src/live_effects/lpe-patternalongpath.cpp
index f90ac2b70..0785da235 100644
--- a/src/live_effects/lpe-patternalongpath.cpp
+++ b/src/live_effects/lpe-patternalongpath.cpp
@@ -96,7 +96,7 @@ LPEPatternAlongPath::LPEPatternAlongPath(LivePathEffectObject *lpeobject) :
prop_scale.param_set_increments(0.01, 0.10);
_provides_knotholder_entities = true;
- _prop_scale_store = prop_scale;
+
}
LPEPatternAlongPath::~LPEPatternAlongPath()
@@ -112,9 +112,6 @@ LPEPatternAlongPath::doBeforeEffect (SPLPEItem const* lpeitem)
if (bbox) {
original_height = (*bbox)[Geom::Y].max() - (*bbox)[Geom::Y].min();
}
- if(_prop_scale_store != prop_scale) {
- prop_scale.param_set_value(_prop_scale_store);
- }
}
Geom::Piecewise<Geom::D2<Geom::SBasis> >
@@ -217,9 +214,9 @@ LPEPatternAlongPath::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > con
x*=scaling;
}
if ( scale_y_rel.get_value() ) {
- y*=(scaling*_prop_scale_store);
+ y*=(scaling*prop_scale);
} else {
- if (_prop_scale_store != 1.0) y *= _prop_scale_store;
+ if (prop_scale != 1.0) y *= prop_scale;
}
x += toffset;
@@ -257,10 +254,12 @@ LPEPatternAlongPath::transform_multiply(Geom::Affine const& postmul, bool set)
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
bool transform_stroke = prefs ? prefs->getBool("/options/transform/stroke", true) : true;
if (transform_stroke && !scale_y_rel) {
- prop_scale.param_set_value(_prop_scale_store * ((postmul.expansionX() + postmul.expansionY()) / 2));
- }
+ prop_scale.param_set_value(prop_scale * ((postmul.expansionX() + postmul.expansionY()) / 2));
+ prop_scale.write_to_SVG();
+ }
if (postmul.isTranslation()) {
pattern.param_transform_multiply(postmul, set);
+ pattern.write_to_SVG();
}
sp_lpe_item_update_patheffect (sp_lpe_item, false, true);
}
@@ -303,9 +302,9 @@ KnotHolderEntityWidthPatternAlongPath::knot_set(Geom::Point const &p, Geom::Poin
Geom::Point knot_pos = this->knot->pos * item->i2dt_affine().inverse();
Geom::Coord nearest_to_ray = ray.nearestTime(knot_pos);
if(nearest_to_ray == 0){
- lpe->_prop_scale_store = -Geom::distance(s , ptA)/(lpe->original_height/2.0);
+ lpe->prop_scale.param_set_value(-Geom::distance(s , ptA)/(lpe->original_height/2.0));
} else {
- lpe->_prop_scale_store = Geom::distance(s , ptA)/(lpe->original_height/2.0);
+ lpe->prop_scale.param_set_value(Geom::distance(s , ptA)/(lpe->original_height/2.0));
}
}
@@ -329,7 +328,7 @@ KnotHolderEntityWidthPatternAlongPath::knot_get() const
ray.setPoints(ptA, (*cubic)[1]);
}
ray.setAngle(ray.angle() + Geom::rad_from_deg(90));
- Geom::Point result_point = Geom::Point::polar(ray.angle(), (lpe->original_height/2.0) * lpe->_prop_scale_store) + ptA;
+ Geom::Point result_point = Geom::Point::polar(ray.angle(), (lpe->original_height/2.0) * lpe->prop_scale) + ptA;
pap_helper_path.clear();
Geom::Path hp(result_point);
diff --git a/src/live_effects/lpe-patternalongpath.h b/src/live_effects/lpe-patternalongpath.h
index eedf4c172..3d7fc02bc 100644
--- a/src/live_effects/lpe-patternalongpath.h
+++ b/src/live_effects/lpe-patternalongpath.h
@@ -61,7 +61,6 @@ private:
BoolParam prop_units;
BoolParam vertical_pattern;
ScalarParam fuse_tolerance;
- double _prop_scale_store;
void on_pattern_pasted();
LPEPatternAlongPath(const LPEPatternAlongPath&);
diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp
index 7382c37ea..e42336113 100644
--- a/src/ui/tools/freehand-base.cpp
+++ b/src/ui/tools/freehand-base.cpp
@@ -212,19 +212,10 @@ static void spdc_paste_curve_as_freehand_shape(Geom::PathVector const &newpath,
Effect::createAndApply(PATTERN_ALONG_PATH, dc->desktop->doc(), item);
Effect* lpe = SP_LPE_ITEM(item)->getCurrentLPE();
static_cast<LPEPatternAlongPath*>(lpe)->pattern.set_new_value(newpath,true);
-
- // write pattern along path parameters:
- lpe->getRepr()->setAttribute("copytype", "single_stretched");
- lpe->getRepr()->setAttribute("fuse_tolerance", "0");
- lpe->getRepr()->setAttribute("is_visible", "true");
- lpe->getRepr()->setAttribute("normal_offset", "0");
- lpe->getRepr()->setAttribute("prop_scale", "1");
- lpe->getRepr()->setAttribute("prop_units", "false");
- lpe->getRepr()->setAttribute("scale_y_rel", "false");
- lpe->getRepr()->setAttribute("spacing", "0");
- lpe->getRepr()->setAttribute("tang_offset", "0");
- lpe->getRepr()->setAttribute("vertical_pattern", "false");
-
+ double scale_doc = 1 / dc->desktop->doc()->getDocumentScale()[0];
+ Inkscape::SVGOStringStream os;
+ os << scale_doc;
+ lpe->getRepr()->setAttribute("prop_scale", os.str().c_str());
}
static void spdc_apply_powerstroke_shape(const std::vector<Geom::Point> & points, FreehandBase *dc, SPItem *item)
@@ -341,7 +332,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item,
// "triangle in"
std::vector<Geom::Point> points(1);
points[0] = Geom::Point(0., swidth/2);
- points[0] *= i2anc_affine(static_cast<SPItem *>(item->parent), NULL).inverse();
+ //points[0] *= i2anc_affine(static_cast<SPItem *>(item->parent), NULL).inverse();
spdc_apply_powerstroke_shape(points, dc, item);
shape_applied = true;
@@ -353,7 +344,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item,
guint curve_length = curve->get_segment_count();
std::vector<Geom::Point> points(1);
points[0] = Geom::Point(0, swidth/2);
- points[0] *= i2anc_affine(static_cast<SPItem *>(item->parent), NULL).inverse();
+ //points[0] *= i2anc_affine(static_cast<SPItem *>(item->parent), NULL).inverse();
points[0][Geom::X] = (double)curve_length;
spdc_apply_powerstroke_shape(points, dc, item);
@@ -791,16 +782,26 @@ static void spdc_flush_white(FreehandBase *dc, SPCurve *gc)
if (!dc->white_item) {
// Attach repr
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ shapeType shape_selected = (shapeType)prefs->getInt(tool_name(dc) + "/shape", 0);
SPItem *item = SP_ITEM(desktop->currentLayer()->appendChildRepr(repr));
-
- spdc_check_for_and_apply_waiting_LPE(dc, item, c);
- if(previous_shape_type != BEND_CLIPBOARD){
- dc->selection->set(repr);
+ //Bend needs the transforms applied after, Other effects best before
+ if((previous_shape_type == BEND_CLIPBOARD && shape_selected == LAST_APPLIED) ||
+ shape_selected == BEND_CLIPBOARD)
+ {
+ spdc_check_for_and_apply_waiting_LPE(dc, item, c);
+ previous_shape_type == BEND_CLIPBOARD;
}
Inkscape::GC::release(repr);
item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse();
item->updateRepr();
item->doWriteTransform(item->getRepr(), item->transform, NULL, true);
+ if((previous_shape_type != BEND_CLIPBOARD || shape_selected != LAST_APPLIED) &&
+ shape_selected != BEND_CLIPBOARD)
+ {
+ spdc_check_for_and_apply_waiting_LPE(dc, item, c);
+ dc->selection->set(repr);
+ }
if(previous_shape_type == BEND_CLIPBOARD){
repr->parent()->removeChild(repr);
}