summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2017-08-13 15:15:47 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2017-08-13 15:15:47 +0000
commitd0930c9bda63f8500b83df8dec3766379a0d60d4 (patch)
tree9a05dbcac6b98850bdcbef9082d7293de6906bb7 /src
parentMerge branch 'jabiertxof/inkscape-inkscape.dev_power_clip_and_mask' (diff)
downloadinkscape-d0930c9bda63f8500b83df8dec3766379a0d60d4.tar.gz
inkscape-d0930c9bda63f8500b83df8dec3766379a0d60d4.zip
Attemp to fix bug 1707899, retain shapes color. Also now retain shape previous width
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/lpe-bendpath.cpp6
-rw-r--r--src/live_effects/lpe-bendpath.h2
-rw-r--r--src/live_effects/lpe-patternalongpath.cpp3
-rw-r--r--src/live_effects/parameter/powerstrokepointarray.cpp4
-rw-r--r--src/ui/tools/freehand-base.cpp36
5 files changed, 36 insertions, 15 deletions
diff --git a/src/live_effects/lpe-bendpath.cpp b/src/live_effects/lpe-bendpath.cpp
index 363356cac..5c1953fda 100644
--- a/src/live_effects/lpe-bendpath.cpp
+++ b/src/live_effects/lpe-bendpath.cpp
@@ -157,10 +157,10 @@ LPEBendPath::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom:
}
void
-LPEBendPath::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item)
+LPEBendPath::addKnotHolderEntities(KnotHolder *knotholder, SPItem *item)
{
KnotHolderEntity *e = new BeP::KnotHolderEntityWidthBendPath(this);
- e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _("Change the width"), SP_KNOT_SHAPE_CIRCLE);
+ e->create(NULL, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _("Change the width"), SP_KNOT_SHAPE_CIRCLE);
knotholder->add(e);
}
@@ -189,6 +189,8 @@ KnotHolderEntityWidthBendPath::knot_set(Geom::Point const &p, Geom::Point const&
} else {
lpe->prop_scale.param_set_value(Geom::distance(s , ptA)/(lpe->original_height/2.0));
}
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble("/live_effect/bend/width", lpe->prop_scale);
sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true);
}
diff --git a/src/live_effects/lpe-bendpath.h b/src/live_effects/lpe-bendpath.h
index eeda86a5e..54c5d70fe 100644
--- a/src/live_effects/lpe-bendpath.h
+++ b/src/live_effects/lpe-bendpath.h
@@ -45,7 +45,7 @@ public:
void addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec);
- virtual void addKnotHolderEntities(KnotHolder * knotholder, SPDesktop * desktop, SPItem * item);
+ virtual void addKnotHolderEntities(KnotHolder * knotholder, SPItem * item);
PathParam bend_path;
diff --git a/src/live_effects/lpe-patternalongpath.cpp b/src/live_effects/lpe-patternalongpath.cpp
index b026bbc22..22b18e077 100644
--- a/src/live_effects/lpe-patternalongpath.cpp
+++ b/src/live_effects/lpe-patternalongpath.cpp
@@ -311,7 +311,8 @@ KnotHolderEntityWidthPatternAlongPath::knot_set(Geom::Point const &p, Geom::Poin
} else {
lpe->prop_scale.param_set_value(Geom::distance(s , ptA)/(lpe->original_height/2.0));
}
-
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble("/live_effect/pap/width", lpe->prop_scale);
}
sp_lpe_item_update_patheffect (SP_LPE_ITEM(item), false, true);
}
diff --git a/src/live_effects/parameter/powerstrokepointarray.cpp b/src/live_effects/parameter/powerstrokepointarray.cpp
index 7753d819d..25639b406 100644
--- a/src/live_effects/parameter/powerstrokepointarray.cpp
+++ b/src/live_effects/parameter/powerstrokepointarray.cpp
@@ -164,6 +164,10 @@ PowerStrokePointArrayParamKnotHolderEntity::knot_set(Geom::Point const &p, Geom:
double t = nearest_time(s, pwd2);
double offset = dot(s - pwd2.valueAt(t), n.valueAt(t));
_pparam->_vector.at(_index) = Geom::Point(t, offset);
+ if (_pparam->_vector.size() == 1 ) {
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble("/live_effect/power_stroke/width", offset);
+ }
sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false);
}
diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp
index 8a5ef0aad..76d2df8c5 100644
--- a/src/ui/tools/freehand-base.cpp
+++ b/src/ui/tools/freehand-base.cpp
@@ -212,9 +212,13 @@ 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);
- double scale_doc = 1 / dc->desktop->doc()->getDocumentScale()[0];
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ double scale = prefs->getDouble("/live_effect/pap/width", 1);
+ if (!scale) {
+ scale = 1 / dc->desktop->doc()->getDocumentScale()[0];
+ }
Inkscape::SVGOStringStream os;
- os << scale_doc;
+ os << scale;
lpe->getRepr()->setAttribute("prop_scale", os.str().c_str());
}
@@ -249,7 +253,14 @@ static void spdc_apply_bend_shape(gchar const *svgd, FreehandBase *dc, SPItem *i
Effect* lpe = SP_LPE_ITEM(item)->getCurrentLPE();
// write bend parameters:
- lpe->getRepr()->setAttribute("prop_scale", "1");
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ double scale = prefs->getDouble("/live_effect/bend/width", 1);
+ if (!scale) {
+ scale = 1;
+ }
+ Inkscape::SVGOStringStream os;
+ os << scale;
+ lpe->getRepr()->setAttribute("prop_scale", os.str().c_str());
lpe->getRepr()->setAttribute("scale_y_rel", "false");
lpe->getRepr()->setAttribute("vertical", "false");
static_cast<LPEBendPath*>(lpe)->bend_path.paste_param_path(svgd);
@@ -287,7 +298,6 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item,
previous_shape_type = shape;
}
if(shape == LAST_APPLIED){
-
shape = previous_shape_type;
if(shape == CLIPBOARD || shape == BEND_CLIPBOARD){
shape = LAST_APPLIED;
@@ -333,10 +343,14 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item,
bool shape_applied = false;
SPCSSAttr *css_item = sp_css_attr_from_object(item, SP_STYLE_FLAG_ALWAYS);
const char *cstroke = sp_repr_css_property(css_item, "stroke", "none");
+ const char *cfill = sp_repr_css_property(css_item, "fill", "none");
const char *stroke_width = sp_repr_css_property(css_item, "stroke-width", "0");
double swidth;
sp_svg_number_read_d(stroke_width, &swidth);
-
+ swidth = prefs->getDouble("/live_effect/power_stroke/width", swidth/2);
+ if (!swidth) {
+ swidth = swidth/2;
+ }
#define SHAPE_LENGTH 10
#define SHAPE_HEIGHT 10
@@ -348,7 +362,8 @@ 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] = Geom::Point(0., swidth);
//points[0] *= i2anc_affine(static_cast<SPItem *>(item->parent), NULL).inverse();
spdc_apply_powerstroke_shape(points, dc, item);
@@ -360,7 +375,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item,
// "triangle out"
guint curve_length = curve->get_segment_count();
std::vector<Geom::Point> points(1);
- points[0] = Geom::Point(0, swidth/2);
+ points[0] = Geom::Point(0, swidth);
//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);
@@ -476,11 +491,10 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item,
if (shape_applied) {
// apply original stroke color as fill and unset stroke; then return
SPCSSAttr *css = sp_repr_css_attr_new();
-
- if (!strcmp(cstroke, "none")){
- sp_repr_css_set_property (css, "fill", "black");
- } else {
+ if (!strcmp(cfill, "none")) {
sp_repr_css_set_property (css, "fill", cstroke);
+ } else {
+ sp_repr_css_set_property (css, "fill", cfill);
}
sp_repr_css_set_property (css, "stroke", "none");
sp_desktop_apply_css_recursive(item, css, true);