From 604d6fee79a94bd2a54078e1e4d3e70a1bfe56d4 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 16 Nov 2013 22:22:08 +0100 Subject: fix error su_v tell to me (bzr r12588.1.27) --- src/ui/tools/freehand-base.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/ui/tools/freehand-base.cpp') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 6e3a04b59..510dfcf4d 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -240,7 +240,7 @@ static void spdc_apply_powerstroke_shape(const std::vector & points lpe->getRepr()->setAttribute("interpolator_beta", "0.2"); } -<<<<<<< TREE + static void spdc_apply_bend_shape(gchar const *svgd, SPDrawContext *dc, SPItem *item) { using namespace Inkscape::LivePathEffect; @@ -256,10 +256,8 @@ static void spdc_apply_bend_shape(gchar const *svgd, SPDrawContext *dc, SPItem * } static bool bend; -static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item, SPCurve *curve) -======= static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, SPCurve *curve) ->>>>>>> MERGE-SOURCE + { using namespace Inkscape::LivePathEffect; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); -- cgit v1.2.3 From c764ff004f76c5d7ac484c9392935bcc0b3ab731 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 16 Nov 2013 22:53:28 +0100 Subject: Fix repointed by su_v (bzr r12588.1.29) --- src/ui/tools/freehand-base.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/tools/freehand-base.cpp') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 510dfcf4d..b80a3a503 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -241,7 +241,7 @@ static void spdc_apply_powerstroke_shape(const std::vector & points } -static void spdc_apply_bend_shape(gchar const *svgd, SPDrawContext *dc, SPItem *item) +static void spdc_apply_bend_shape(gchar const *svgd, FreehandBase *dc, SPItem *item) { using namespace Inkscape::LivePathEffect; -- cgit v1.2.3 From 67818f7833a38c77fcbe2f7960816ce68505408a Mon Sep 17 00:00:00 2001 From: root Date: Wed, 2 Apr 2014 01:40:57 +0200 Subject: refactor from lastApplied (bzr r12588.1.33) --- src/ui/tools/freehand-base.cpp | 148 ++++++++++++++++------------------------- 1 file changed, 59 insertions(+), 89 deletions(-) (limited to 'src/ui/tools/freehand-base.cpp') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index df2e6f517..4f2ec6c48 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -250,8 +250,7 @@ static void spdc_apply_bend_shape(gchar const *svgd, FreehandBase *dc, SPItem *i lpe->getRepr()->setAttribute("scale_y_rel", "false"); lpe->getRepr()->setAttribute("vertical", "false"); } - -static bool bend; +static int previous_shape_type = -1; static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, SPCurve *curve) { @@ -262,18 +261,32 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1) { Effect::createAndApply(SPIRO, dc->desktop->doc(), item); } - bend = false; - static Geom::PathVector pathv; - static SPItem *itemEnd; + + //Store the clipboard path to apply in the future without the use of clipboard + static Geom::PathVector previous_shape_pathv; + //Last shape applied type "-1" means "no previous shape" int shape = prefs->getInt(tool_name(dc) + "/shape", 0); - static int previous_shape; 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"); + static SPItem *itemEnd; #define SHAPE_LENGTH 10 #define SHAPE_HEIGHT 10 + if(shape == 6){ + shape = previous_shape_type; + if(shape == 4){ + shape = 6; + } + if(shape == 5){ + shape = 7; + } + if(previous_shape_type == -1){ + shape = 0; + } + } + switch (shape) { case 0: // don't apply any shape @@ -312,6 +325,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, c->closepath(); spdc_paste_curve_as_freehand_shape(c, dc, item); c->unref(); + shape_applied = true; break; } @@ -323,7 +337,8 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, static_cast(lpe)->pattern.on_paste_button_click(); Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); Glib::ustring svgd = cm->getPathParameter(SP_ACTIVE_DESKTOP); - pathv = sp_svg_read_pathv(svgd.data()); + previous_shape_pathv = sp_svg_read_pathv(svgd.data()); + shape_applied = true; break; } @@ -349,7 +364,6 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, if(SP_IS_OBJECT(obj)){ spdc_apply_bend_shape(svgd, dc, SP_ITEM(obj)); SP_ITEM(obj)->setExplicitlyHidden(false); - bend = true; selection->set(SP_ITEM(obj),true); } } @@ -358,88 +372,44 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, } case 6: { - // "Last applied" - switch(previous_shape){ - case 0: - // don't apply any shape - break; - case 1: - { - // "triangle in" - std::vector points(1); - points[0] = Geom::Point(0., SHAPE_HEIGHT/2); - spdc_apply_powerstroke_shape(points, dc, item); - - shape_applied = true; - break; - } - case 2: - { - // "triangle out" - guint curve_length = curve->get_segment_count(); - std::vector points(1); - points[0] = Geom::Point((double)curve_length, SHAPE_HEIGHT/2); - spdc_apply_powerstroke_shape(points, dc, item); - - shape_applied = true; - break; - } - case 3: - { - // "ellipse" - SPCurve *c = new SPCurve(); - const double C1 = 0.552; - c->moveto(0, SHAPE_HEIGHT/2); - c->curveto(0, (1 - C1) * SHAPE_HEIGHT/2, (1 - C1) * SHAPE_LENGTH/2, 0, SHAPE_LENGTH/2, 0); - c->curveto((1 + C1) * SHAPE_LENGTH/2, 0, SHAPE_LENGTH, (1 - C1) * SHAPE_HEIGHT/2, SHAPE_LENGTH, SHAPE_HEIGHT/2); - c->curveto(SHAPE_LENGTH, (1 + C1) * SHAPE_HEIGHT/2, (1 + C1) * SHAPE_LENGTH/2, SHAPE_HEIGHT, SHAPE_LENGTH/2, SHAPE_HEIGHT); - c->curveto((1 - C1) * SHAPE_LENGTH/2, SHAPE_HEIGHT, 0, (1 + C1) * SHAPE_HEIGHT/2, 0, SHAPE_HEIGHT/2); - c->closepath(); - spdc_paste_curve_as_freehand_shape(c, dc, item); - c->unref(); - shape_applied = true; - break; - } - case 4: - { - if(pathv.size() != 0){ - SPCurve * c = new SPCurve(); - c->set_pathvector(pathv); - spdc_paste_curve_as_freehand_shape(c, dc, item); - c->unref(); - shape_applied = true; - } - break; - } - case 5: - { - // take shape from clipboard; TODO: catch the case where clipboard is empty - if(itemEnd != NULL && itemEnd->getRepr() != NULL){ - gchar const *svgd = item->getRepr()->attribute("d"); - item->deleteObject(); - Inkscape::Selection *selection = sp_desktop_selection(dc->desktop); - selection->add(SP_OBJECT(itemEnd)); - sp_selection_duplicate(dc->desktop); - selection->remove(SP_OBJECT(itemEnd)); - GSList *items = const_cast(selection->itemList()); - SPObject *obj = reinterpret_cast(g_slist_nth_data(items,0)); - if(SP_IS_OBJECT(obj)){ - SP_ITEM(obj)->getRepr()->setAttribute("inkscape:path-effect", NULL); - spdc_apply_bend_shape(svgd, dc, SP_ITEM(obj)); - SP_ITEM(obj)->setExplicitlyHidden(false); - bend = true; - selection->set(SP_ITEM(obj),true); - } - } - break; + if(previous_shape_pathv.size() != 0){ + SPCurve * c = new SPCurve(); + c->set_pathvector(previous_shape_pathv); + spdc_paste_curve_as_freehand_shape(c, dc, item); + c->unref(); + + shape_applied = true; + } + + shape = previous_shape_type; + break; + } + case 7: + { + // take shape from clipboard; TODO: catch the case where clipboard is empty + if(itemEnd != NULL && itemEnd->getRepr() != NULL){ + gchar const *svgd = item->getRepr()->attribute("d"); + item->deleteObject(); + Inkscape::Selection *selection = sp_desktop_selection(dc->desktop); + selection->add(SP_OBJECT(itemEnd)); + sp_selection_duplicate(dc->desktop); + selection->remove(SP_OBJECT(itemEnd)); + GSList *items = const_cast(selection->itemList()); + SPObject *obj = reinterpret_cast(g_slist_nth_data(items,0)); + if(SP_IS_OBJECT(obj)){ + SP_ITEM(obj)->getRepr()->setAttribute("inkscape:path-effect", NULL); + spdc_apply_bend_shape(svgd, dc, SP_ITEM(obj)); + SP_ITEM(obj)->setExplicitlyHidden(false); + selection->set(SP_ITEM(obj),true); } } - shape = previous_shape; + shape = previous_shape_type; + break; } default: break; } - previous_shape = shape; + previous_shape_type = shape; if (shape_applied) { // apply original stroke color as fill and unset stroke; then return SPCSSAttr *css = sp_repr_css_attr_new(); @@ -454,7 +424,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, sp_repr_css_attr_unref(css); return; } - if(shape == 5 || (shape == 6 && previous_shape == 5))return; + if(previous_shape_type == 5)return; if (dc->waiting_LPE_type != INVALID_LPE) { Effect::createAndApply(dc->waiting_LPE_type, dc->desktop->doc(), item); @@ -731,11 +701,11 @@ static void spdc_flush_white(FreehandBase *dc, SPCurve *gc) // we finished the path; now apply any waiting LPEs or freehand shapes spdc_check_for_and_apply_waiting_LPE(dc, item, c); - if(!bend) dc->selection->set(repr); + if(previous_shape_type != 5) dc->selection->set(repr); Inkscape::GC::release(repr); - if(!bend) item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); - if(!bend) item->doWriteTransform(item->getRepr(), item->transform, NULL, true); - if(!bend) item->updateRepr(); + if(previous_shape_type != 5) item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); + if(previous_shape_type != 5) item->doWriteTransform(item->getRepr(), item->transform, NULL, true); + if(previous_shape_type != 5) item->updateRepr(); } DocumentUndo::done(doc, SP_IS_PEN_CONTEXT(dc)? SP_VERB_CONTEXT_PEN : SP_VERB_CONTEXT_PENCIL, -- cgit v1.2.3 From 63a8ebd9d68033c5ac23014ca325a8043f38733b Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 24 Nov 2014 22:38:30 +0100 Subject: Fixing bend from clipboard to trunk 0.92 (bzr r12588.1.36) --- src/ui/tools/freehand-base.cpp | 48 ++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 27 deletions(-) (limited to 'src/ui/tools/freehand-base.cpp') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 68b57dc90..a452ae7c8 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -257,7 +257,7 @@ static void spdc_apply_powerstroke_shape(const std::vector & points std::ostringstream s; s.imbue(std::locale::classic()); - s << "0," << stroke_width / 2.; + s << points[0][Geom::X] << "," << stroke_width / 2.; // write powerstroke parameters: lpe->getRepr()->setAttribute("start_linecap_type", "zerowidth"); @@ -285,9 +285,11 @@ static void spdc_apply_bend_shape(gchar const *svgd, FreehandBase *dc, SPItem *i lpe->getRepr()->setAttribute("scale_y_rel", "false"); lpe->getRepr()->setAttribute("vertical", "false"); } -static int previous_shape_type = -1; -static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, SPCurve *curve) +enum shapeType { NONE, TRIANGLE_IN, TRIANGLE_OUT, ELLIPSE, CLIPBOARD, BEND_CLIPBOARD, LAST_APPLIED }; +static shapeType previous_shape_type = NONE; + +static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, SPCurve *curve) { using namespace Inkscape::LivePathEffect; Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -304,8 +306,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, //Store the clipboard path to apply in the future without the use of clipboard static Geom::PathVector previous_shape_pathv; - enum shapeType { NONE, TRIANGLE_IN, TRIANGLE_OUT, ELLIPSE, CLIPBOARD, BEND_CLIPBOARD, LAST_APPLIED }; - static shapeType previous_shape_type = NONE; + shapeType shape = (shapeType)prefs->getInt(tool_name(dc) + "/shape", 0); @@ -385,14 +386,11 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, { Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); if(cm->paste(SP_ACTIVE_DESKTOP,false) == true){ + item->transform = SP_ITEM(SP_ACTIVE_DESKTOP->currentLayer())->i2doc_affine().inverse(); gchar const *svgd = item->getRepr()->attribute("d"); - item->getRepr()->setAttribute("d", ""); bendItem = dc->selection->singleItem(); - item->setSuccessor(bendItem); - item = bendItem; - g_assert(item != NULL); - spdc_apply_bend_shape(svgd, dc, item); - dc->selection->set(item,true); + spdc_apply_bend_shape(svgd, dc, bendItem); + dc->selection->set(bendItem,true); } break; } @@ -407,30 +405,28 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, shape_applied = true; } + shape = CLIPBOARD; } else { if(bendItem != NULL && bendItem->getRepr() != NULL){ + item->transform = SP_ITEM(SP_ACTIVE_DESKTOP->currentLayer())->i2doc_affine().inverse(); gchar const *svgd = item->getRepr()->attribute("d"); - item->getRepr()->setAttribute("d", ""); Inkscape::Selection *selection = sp_desktop_selection(dc->desktop); selection->add(SP_OBJECT(bendItem)); sp_selection_duplicate(dc->desktop); selection->remove(SP_OBJECT(bendItem)); bendItem = dc->selection->singleItem(); - item->setSuccessor(bendItem); - item = bendItem; - g_assert(item != NULL); - spdc_apply_bend_shape(svgd, dc, item); - dc->selection->set(item,true); + spdc_apply_bend_shape(svgd, dc, bendItem); + dc->selection->set(bendItem,true); } + shape = BEND_CLIPBOARD; } break; } default: break; } - if(shape != LAST_APPLIED){ - previous_shape_type = shape; - } + previous_shape_type = shape; + if (shape_applied) { // apply original stroke color as fill and unset stroke; then return SPCSSAttr *css = sp_repr_css_attr_new(); @@ -445,7 +441,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, sp_repr_css_attr_unref(css); return; } - if(previous_shape_type == 5 || previous_shape_type == 6 || previous_shape_type == 7){ + if(previous_shape_type == LAST_APPLIED){ return; } if (dc->waiting_LPE_type != INVALID_LPE) { @@ -754,19 +750,17 @@ static void spdc_flush_white(FreehandBase *dc, SPCurve *gc) // Attach repr SPItem *item = SP_ITEM(desktop->currentLayer()->appendChildRepr(repr)); - // we finished the path; now apply any waiting LPEs or freehand shapes spdc_check_for_and_apply_waiting_LPE(dc, item, c); - if(previous_shape_type == -1 || previous_shape_type == 5 || previous_shape_type == 6){ - return; - } - if(previous_shape_type != 7){ + if(previous_shape_type != BEND_CLIPBOARD){ dc->selection->set(repr); } - 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){ + repr->parent()->removeChild(repr); + } } DocumentUndo::done(doc, SP_IS_PEN_CONTEXT(dc)? SP_VERB_CONTEXT_PEN : SP_VERB_CONTEXT_PENCIL, -- cgit v1.2.3 From dde5cc0fe6c8f4c00711813baeca5ae1d0d671c6 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 25 Nov 2014 00:16:06 +0100 Subject: updated code to work on 0.92 code (bzr r12588.1.38) --- src/ui/tools/freehand-base.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/ui/tools/freehand-base.cpp') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index a452ae7c8..2ef06df61 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -385,12 +385,16 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, case BEND_CLIPBOARD: { Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); - if(cm->paste(SP_ACTIVE_DESKTOP,false) == true){ + if(cm->paste(SP_ACTIVE_DESKTOP,true) == true){ item->transform = SP_ITEM(SP_ACTIVE_DESKTOP->currentLayer())->i2doc_affine().inverse(); gchar const *svgd = item->getRepr()->attribute("d"); bendItem = dc->selection->singleItem(); + bendItem->moveTo(item,false); spdc_apply_bend_shape(svgd, dc, bendItem); - dc->selection->set(bendItem,true); + bendItem->transform = Geom::Affine(1,0,0,1,0,0); + dc->selection->add(SP_OBJECT(bendItem)); + } else { + shape = NONE; } break; } @@ -410,13 +414,14 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, if(bendItem != NULL && bendItem->getRepr() != NULL){ item->transform = SP_ITEM(SP_ACTIVE_DESKTOP->currentLayer())->i2doc_affine().inverse(); gchar const *svgd = item->getRepr()->attribute("d"); - Inkscape::Selection *selection = sp_desktop_selection(dc->desktop); - selection->add(SP_OBJECT(bendItem)); + dc->selection->add(SP_OBJECT(bendItem)); sp_selection_duplicate(dc->desktop); - selection->remove(SP_OBJECT(bendItem)); + dc->selection->remove(SP_OBJECT(bendItem)); bendItem = dc->selection->singleItem(); + bendItem->moveTo(item,false); spdc_apply_bend_shape(svgd, dc, bendItem); - dc->selection->set(bendItem,true); + bendItem->transform = Geom::Affine(1,0,0,1,0,0); + dc->selection->add(SP_OBJECT(bendItem)); } shape = BEND_CLIPBOARD; } @@ -441,9 +446,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, sp_repr_css_attr_unref(css); return; } - if(previous_shape_type == LAST_APPLIED){ - return; - } + if (dc->waiting_LPE_type != INVALID_LPE) { Effect::createAndApply(dc->waiting_LPE_type, dc->desktop->doc(), item); dc->waiting_LPE_type = INVALID_LPE; -- cgit v1.2.3 From 2a0d24e61c826a9bf33cad4c8f6769d52d433b43 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 8 Mar 2015 00:13:15 +0100 Subject: add interactive smooth to pen tool (bzr r13973.1.1) --- src/ui/tools/freehand-base.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/ui/tools/freehand-base.cpp') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 0f14d7534..5858bfcfd 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -21,6 +21,7 @@ #endif #include "live_effects/lpe-patternalongpath.h" +#include "live_effects/lpe-simplify.h" #include "display/canvas-bpath.h" #include "xml/repr.h" #include "svg/svg.h" @@ -266,6 +267,23 @@ static void spdc_apply_powerstroke_shape(const std::vector & points lpe->getRepr()->setAttribute("offset_points", s.str().c_str()); } +static void spdc_apply_simplify(std::string threshold, FreehandBase *dc, SPItem *item) +{ + using namespace Inkscape::LivePathEffect; + + Effect::createAndApply(SIMPLIFY, dc->desktop->doc(), item); + Effect* lpe = SP_LPE_ITEM(item)->getCurrentLPE(); + // write powerstroke parameters: + lpe->getRepr()->setAttribute("steps", "1"); + lpe->getRepr()->setAttribute("threshold", threshold); + lpe->getRepr()->setAttribute("Helper size", "0"); + lpe->getRepr()->setAttribute("smooth_angles", "360"); + lpe->getRepr()->setAttribute("nodes", "false"); + lpe->getRepr()->setAttribute("handles", "false"); + lpe->getRepr()->setAttribute("simplifyindividualpaths", "false"); + lpe->getRepr()->setAttribute("simplifyJustCoalesce", "false"); +} + static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, SPCurve *curve) { using namespace Inkscape::LivePathEffect; @@ -287,6 +305,14 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, shapeType shape = (shapeType)prefs->getInt(tool_name(dc) + "/shape", 0); + bool simplify = prefs->getInt(tool_name(dc) + "/simplify", 0); + if(simplify){ + double tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0); + tol = tol/(100.0*(101.0-tol)); + std::ostringstream ss; + ss << tol; + spdc_apply_simplify(ss.str(), dc, 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"); -- cgit v1.2.3 From c4383f04d9a3cbe231a31662cb0b5358d512e2f1 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 8 Mar 2015 16:36:57 +0100 Subject: allow use multiple lines, added new icon (bzr r13973.1.3) --- src/ui/tools/freehand-base.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/tools/freehand-base.cpp') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 5858bfcfd..0844091c3 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -276,7 +276,7 @@ static void spdc_apply_simplify(std::string threshold, FreehandBase *dc, SPItem // write powerstroke parameters: lpe->getRepr()->setAttribute("steps", "1"); lpe->getRepr()->setAttribute("threshold", threshold); - lpe->getRepr()->setAttribute("Helper size", "0"); + lpe->getRepr()->setAttribute("helper", "false"); lpe->getRepr()->setAttribute("smooth_angles", "360"); lpe->getRepr()->setAttribute("nodes", "false"); lpe->getRepr()->setAttribute("handles", "false"); -- cgit v1.2.3 From 8fcb510cfc24026d6747b778664b952e6d788d67 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 8 Mar 2015 17:57:28 +0100 Subject: fix to fit the new parameters of simplify lpe (bzr r13973.1.5) --- src/ui/tools/freehand-base.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/ui/tools/freehand-base.cpp') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 0844091c3..35f85f928 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -276,7 +276,6 @@ static void spdc_apply_simplify(std::string threshold, FreehandBase *dc, SPItem // write powerstroke parameters: lpe->getRepr()->setAttribute("steps", "1"); lpe->getRepr()->setAttribute("threshold", threshold); - lpe->getRepr()->setAttribute("helper", "false"); lpe->getRepr()->setAttribute("smooth_angles", "360"); lpe->getRepr()->setAttribute("nodes", "false"); lpe->getRepr()->setAttribute("handles", "false"); -- cgit v1.2.3 From 8e5f2c798334914daa121c8a1a593a16b63b6d5f Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 9 Mar 2015 20:38:13 +0100 Subject: Fix new added simplify parameter (bzr r13973.1.7) --- src/ui/tools/freehand-base.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/ui/tools/freehand-base.cpp') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 35f85f928..bc4f98413 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -277,6 +277,7 @@ static void spdc_apply_simplify(std::string threshold, FreehandBase *dc, SPItem lpe->getRepr()->setAttribute("steps", "1"); lpe->getRepr()->setAttribute("threshold", threshold); lpe->getRepr()->setAttribute("smooth_angles", "360"); + lpe->getRepr()->setAttribute("helper_size", "0"); lpe->getRepr()->setAttribute("nodes", "false"); lpe->getRepr()->setAttribute("handles", "false"); lpe->getRepr()->setAttribute("simplifyindividualpaths", "false"); -- cgit v1.2.3 From b64a562f4a8f6cca5d07fc6063d80739f1bb1dee Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 10 Mar 2015 19:30:57 +0100 Subject: Update to new simplify (bzr r13973.1.9) --- src/ui/tools/freehand-base.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/ui/tools/freehand-base.cpp') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index bc4f98413..c75e0a354 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -278,8 +278,6 @@ static void spdc_apply_simplify(std::string threshold, FreehandBase *dc, SPItem lpe->getRepr()->setAttribute("threshold", threshold); lpe->getRepr()->setAttribute("smooth_angles", "360"); lpe->getRepr()->setAttribute("helper_size", "0"); - lpe->getRepr()->setAttribute("nodes", "false"); - lpe->getRepr()->setAttribute("handles", "false"); lpe->getRepr()->setAttribute("simplifyindividualpaths", "false"); lpe->getRepr()->setAttribute("simplifyJustCoalesce", "false"); } -- cgit v1.2.3 From 4b881e97ff24ba534edab7592ed74bb1a07f6939 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 9 Apr 2015 20:57:44 +0200 Subject: Rename a variable to current coding style (bzr r12588.1.41) --- src/ui/tools/freehand-base.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src/ui/tools/freehand-base.cpp') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 22948c7bc..096957be0 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -311,7 +311,7 @@ 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"); - static SPItem *bendItem; + static SPItem *bend_item; #define SHAPE_LENGTH 10 #define SHAPE_HEIGHT 10 @@ -386,11 +386,11 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, if(cm->paste(SP_ACTIVE_DESKTOP,true) == true){ item->transform = SP_ITEM(SP_ACTIVE_DESKTOP->currentLayer())->i2doc_affine().inverse(); gchar const *svgd = item->getRepr()->attribute("d"); - bendItem = dc->selection->singleItem(); - bendItem->moveTo(item,false); - spdc_apply_bend_shape(svgd, dc, bendItem); - bendItem->transform = Geom::Affine(1,0,0,1,0,0); - dc->selection->add(SP_OBJECT(bendItem)); + bend_item = dc->selection->singleItem(); + bend_item->moveTo(item,false); + spdc_apply_bend_shape(svgd, dc, bend_item); + bend_item->transform = Geom::Affine(1,0,0,1,0,0); + dc->selection->add(SP_OBJECT(bend_item)); } else { shape = NONE; } @@ -409,17 +409,17 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, } shape = CLIPBOARD; } else { - if(bendItem != NULL && bendItem->getRepr() != NULL){ + if(bend_item != NULL && bend_item->getRepr() != NULL){ item->transform = SP_ITEM(SP_ACTIVE_DESKTOP->currentLayer())->i2doc_affine().inverse(); gchar const *svgd = item->getRepr()->attribute("d"); - dc->selection->add(SP_OBJECT(bendItem)); + dc->selection->add(SP_OBJECT(bend_item)); sp_selection_duplicate(dc->desktop); - dc->selection->remove(SP_OBJECT(bendItem)); - bendItem = dc->selection->singleItem(); - bendItem->moveTo(item,false); - spdc_apply_bend_shape(svgd, dc, bendItem); - bendItem->transform = Geom::Affine(1,0,0,1,0,0); - dc->selection->add(SP_OBJECT(bendItem)); + dc->selection->remove(SP_OBJECT(bend_item)); + bend_item = dc->selection->singleItem(); + bend_item->moveTo(item,false); + spdc_apply_bend_shape(svgd, dc, bend_item); + bend_item->transform = Geom::Affine(1,0,0,1,0,0); + dc->selection->add(SP_OBJECT(bend_item)); } shape = BEND_CLIPBOARD; } -- cgit v1.2.3 From 9b709f551c3d889cf4235913c317f1b10ee9e72e Mon Sep 17 00:00:00 2001 From: jabiertxof Date: Wed, 29 Apr 2015 10:31:50 -0400 Subject: Fis fix a bug finded in my presentation in the HackFest (bzr r12588.1.43) --- src/ui/tools/freehand-base.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/ui/tools/freehand-base.cpp') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 9aa6c9589..a13fc0d8b 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -384,8 +384,10 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, { Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); if(cm->paste(SP_ACTIVE_DESKTOP,true) == true){ - item->transform = SP_ITEM(SP_ACTIVE_DESKTOP->currentLayer())->i2doc_affine().inverse(); gchar const *svgd = item->getRepr()->attribute("d"); + Geom::PathVector path = sp_svg_read_pathv(svgd); + path *= item->i2doc_affine().inverse(); + svgd = sp_svg_write_path( path ); bend_item = dc->selection->singleItem(); bend_item->moveTo(item,false); spdc_apply_bend_shape(svgd, dc, bend_item); @@ -410,8 +412,10 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, shape = CLIPBOARD; } else { if(bend_item != NULL && bend_item->getRepr() != NULL){ - item->transform = SP_ITEM(SP_ACTIVE_DESKTOP->currentLayer())->i2doc_affine().inverse(); gchar const *svgd = item->getRepr()->attribute("d"); + Geom::PathVector path = sp_svg_read_pathv(svgd); + path *= item->i2doc_affine().inverse(); + svgd = sp_svg_write_path( path ); dc->selection->add(SP_OBJECT(bend_item)); sp_selection_duplicate(dc->desktop); dc->selection->remove(SP_OBJECT(bend_item)); -- cgit v1.2.3 From 3f83712a0ae1400d8ffa8dc0d40247b78f6d1a7a Mon Sep 17 00:00:00 2001 From: jtx Date: Mon, 27 Jul 2015 12:21:31 +0200 Subject: Fix LPE stack in interactive simplify (bzr r14262) --- src/ui/tools/freehand-base.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/ui/tools/freehand-base.cpp') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 865ee760e..2d742b6bf 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -288,6 +288,14 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (item && SP_IS_LPE_ITEM(item)) { + bool simplify = prefs->getInt(tool_name(dc) + "/simplify", 0); + if(simplify){ + double tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0); + tol = tol/(100.0*(102.0-tol)); + std::ostringstream ss; + ss << tol; + spdc_apply_simplify(ss.str(), dc, item); + } if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1) { Effect::createAndApply(SPIRO, dc->desktop->doc(), item); } @@ -303,14 +311,6 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, shapeType shape = (shapeType)prefs->getInt(tool_name(dc) + "/shape", 0); - bool simplify = prefs->getInt(tool_name(dc) + "/simplify", 0); - if(simplify){ - double tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0); - tol = tol/(100.0*(101.0-tol)); - std::ostringstream ss; - ss << tol; - spdc_apply_simplify(ss.str(), dc, 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"); -- cgit v1.2.3 From aeedb1dda68d5529363a144c13d26f8804da4c64 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 1 Aug 2015 16:27:30 +0200 Subject: Update simplify interactive to handle trinagle out powerstrokes, also fix it for Spiro paths. Updated toolbar slider to also update powerstroke points (bzr r14271) --- src/ui/tools/freehand-base.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/ui/tools/freehand-base.cpp') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index fa45d8dbb..f4ad284c7 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -289,7 +289,7 @@ static void spdc_apply_simplify(std::string threshold, FreehandBase *dc, SPItem Effect::createAndApply(SIMPLIFY, dc->desktop->doc(), item); Effect* lpe = SP_LPE_ITEM(item)->getCurrentLPE(); - // write powerstroke parameters: + // write simplify parameters: lpe->getRepr()->setAttribute("steps", "1"); lpe->getRepr()->setAttribute("threshold", threshold); lpe->getRepr()->setAttribute("smooth_angles", "360"); @@ -314,20 +314,22 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, std::ostringstream ss; ss << tol; spdc_apply_simplify(ss.str(), dc, item); + sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); } if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1) { Effect::createAndApply(SPIRO, dc->desktop->doc(), item); } - //add the bspline node in the waiting effects + if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2) { Effect::createAndApply(BSPLINE, dc->desktop->doc(), item); } + SPShape *sp_shape = dynamic_cast(item); + if (sp_shape) { + curve = sp_shape->getCurve(); + } //Store the clipboard path to apply in the future without the use of clipboard - static Geom::PathVector previous_shape_pathv; - - shapeType shape = (shapeType)prefs->getInt(tool_name(dc) + "/shape", 0); bool shape_applied = false; -- cgit v1.2.3 From d141eb2df3805c3049b863c1bf8429bed9d0763d Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 2 Aug 2015 13:29:25 +0200 Subject: Fixed some typos in bsector and bspline In freehand base fix a crash un bend path if no clipboard. Also rewrite retrive clipboard to get it at correct document size (bzr r14272) --- src/ui/tools/freehand-base.cpp | 46 ++++++++++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 15 deletions(-) (limited to 'src/ui/tools/freehand-base.cpp') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index f4ad284c7..bdce1cd46 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -46,6 +46,7 @@ #include "live_effects/lpe-powerstroke.h" #include "style.h" #include "ui/control-manager.h" +#include "util/units.h" // clipboard support #include "ui/clipboard.h" #include "ui/tools/freehand-base.h" @@ -393,15 +394,24 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, } case CLIPBOARD: { - // take shape from clipboard; TODO: catch the case where clipboard is empty - Effect::createAndApply(PATTERN_ALONG_PATH, dc->desktop->doc(), item); - Effect* lpe = SP_LPE_ITEM(item)->getCurrentLPE(); - static_cast(lpe)->pattern.on_paste_button_click(); + // take shape from clipboard; Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); Glib::ustring svgd = cm->getPathParameter(SP_ACTIVE_DESKTOP); - previous_shape_pathv = sp_svg_read_pathv(svgd.data()); - - shape_applied = true; + if(svgd != ""){ + previous_shape_pathv = sp_svg_read_pathv(svgd.data()); + Inkscape::XML::Node *nv_repr = SP_ACTIVE_DESKTOP->getNamedView()->getRepr(); + if (nv_repr->attribute("inkscape:document-units")){ + double scale_units = Inkscape::Util::Quantity::convert(1, "px", nv_repr->attribute("inkscape:document-units")); + if (!Geom::are_near(scale_units, 1.0, Geom::EPSILON)) { + previous_shape_pathv *= Geom::Scale(scale_units); + } + } + SPCurve const *c = new SPCurve(previous_shape_pathv); + spdc_paste_curve_as_freehand_shape(c, dc, item); + shape_applied = true; + } else { + shape = NONE; + } break; } case BEND_CLIPBOARD: @@ -413,10 +423,14 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, path *= item->i2doc_affine().inverse(); svgd = sp_svg_write_path( path ); bend_item = dc->selection->singleItem(); - bend_item->moveTo(item,false); - spdc_apply_bend_shape(svgd, dc, bend_item); - bend_item->transform = Geom::Affine(1,0,0,1,0,0); - dc->selection->add(SP_OBJECT(bend_item)); + if(bend_item){ + bend_item->moveTo(item,false); + spdc_apply_bend_shape(svgd, dc, bend_item); + bend_item->transform = Geom::Affine(1,0,0,1,0,0); + dc->selection->add(SP_OBJECT(bend_item)); + } else { + shape = NONE; + } } else { shape = NONE; } @@ -444,10 +458,12 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, sp_selection_duplicate(dc->desktop); dc->selection->remove(SP_OBJECT(bend_item)); bend_item = dc->selection->singleItem(); - bend_item->moveTo(item,false); - spdc_apply_bend_shape(svgd, dc, bend_item); - bend_item->transform = Geom::Affine(1,0,0,1,0,0); - dc->selection->add(SP_OBJECT(bend_item)); + if(bend_item){ + bend_item->moveTo(item,false); + spdc_apply_bend_shape(svgd, dc, bend_item); + bend_item->transform = Geom::Affine(1,0,0,1,0,0); + dc->selection->add(SP_OBJECT(bend_item)); + } } shape = BEND_CLIPBOARD; } -- cgit v1.2.3 From ea883fa7a8b207aea8a86fb41084da03ee2ef827 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 5 Aug 2015 21:25:52 +0200 Subject: Fix some transform problems in Bend path. Also refactor a bit the file to simplify it (bzr r14276) --- src/ui/tools/freehand-base.cpp | 44 ++++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 27 deletions(-) (limited to 'src/ui/tools/freehand-base.cpp') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index bdce1cd46..6adece54f 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -215,7 +215,7 @@ static Glib::ustring const tool_name(FreehandBase *dc) : "/tools/freehand/pencil" ); } -static void spdc_paste_curve_as_freehand_shape(const SPCurve *c, FreehandBase *dc, SPItem *item) +static void spdc_paste_curve_as_freehand_shape(gchar const *svgd, FreehandBase *dc, SPItem *item) { using namespace Inkscape::LivePathEffect; @@ -223,7 +223,6 @@ static void spdc_paste_curve_as_freehand_shape(const SPCurve *c, FreehandBase *d Effect::createAndApply(PATTERN_ALONG_PATH, dc->desktop->doc(), item); Effect* lpe = SP_LPE_ITEM(item)->getCurrentLPE(); - gchar *svgd = sp_svg_write_path(c->get_pathvector()); static_cast(lpe)->pattern.paste_param_path(svgd); } @@ -278,10 +277,10 @@ 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("bendpath", svgd); lpe->getRepr()->setAttribute("prop_scale", "1"); lpe->getRepr()->setAttribute("scale_y_rel", "false"); lpe->getRepr()->setAttribute("vertical", "false"); + static_cast(lpe)->bend_path.paste_param_path(svgd); } static void spdc_apply_simplify(std::string threshold, FreehandBase *dc, SPItem *item) @@ -386,7 +385,8 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, c->curveto(SHAPE_LENGTH, (1 + C1) * SHAPE_HEIGHT/2, (1 + C1) * SHAPE_LENGTH/2, SHAPE_HEIGHT, SHAPE_LENGTH/2, SHAPE_HEIGHT); c->curveto((1 - C1) * SHAPE_LENGTH/2, SHAPE_HEIGHT, 0, (1 + C1) * SHAPE_HEIGHT/2, 0, SHAPE_HEIGHT/2); c->closepath(); - spdc_paste_curve_as_freehand_shape(c, dc, item); + gchar const *svgd = sp_svg_write_path(c->get_pathvector()); + spdc_paste_curve_as_freehand_shape(svgd, dc, item); c->unref(); shape_applied = true; @@ -399,15 +399,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, Glib::ustring svgd = cm->getPathParameter(SP_ACTIVE_DESKTOP); if(svgd != ""){ previous_shape_pathv = sp_svg_read_pathv(svgd.data()); - Inkscape::XML::Node *nv_repr = SP_ACTIVE_DESKTOP->getNamedView()->getRepr(); - if (nv_repr->attribute("inkscape:document-units")){ - double scale_units = Inkscape::Util::Quantity::convert(1, "px", nv_repr->attribute("inkscape:document-units")); - if (!Geom::are_near(scale_units, 1.0, Geom::EPSILON)) { - previous_shape_pathv *= Geom::Scale(scale_units); - } - } - SPCurve const *c = new SPCurve(previous_shape_pathv); - spdc_paste_curve_as_freehand_shape(c, dc, item); + spdc_paste_curve_as_freehand_shape(svgd.data(), dc, item); shape_applied = true; } else { shape = NONE; @@ -419,14 +411,11 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); if(cm->paste(SP_ACTIVE_DESKTOP,true) == true){ gchar const *svgd = item->getRepr()->attribute("d"); - Geom::PathVector path = sp_svg_read_pathv(svgd); - path *= item->i2doc_affine().inverse(); - svgd = sp_svg_write_path( path ); bend_item = dc->selection->singleItem(); if(bend_item){ bend_item->moveTo(item,false); + bend_item->transform = Geom::Affine(1,0,0,1,0,0); spdc_apply_bend_shape(svgd, dc, bend_item); - bend_item->transform = Geom::Affine(1,0,0,1,0,0); dc->selection->add(SP_OBJECT(bend_item)); } else { shape = NONE; @@ -440,32 +429,33 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, { if(previous_shape_type == CLIPBOARD){ if(previous_shape_pathv.size() != 0){ - SPCurve * c = new SPCurve(); - c->set_pathvector(previous_shape_pathv); - spdc_paste_curve_as_freehand_shape(c, dc, item); - c->unref(); + gchar const *svgd = sp_svg_write_path(previous_shape_pathv); + spdc_paste_curve_as_freehand_shape(svgd, dc, item); shape_applied = true; + shape = CLIPBOARD; + } else{ + shape = NONE; } - shape = CLIPBOARD; } else { if(bend_item != NULL && bend_item->getRepr() != NULL){ gchar const *svgd = item->getRepr()->attribute("d"); - Geom::PathVector path = sp_svg_read_pathv(svgd); - path *= item->i2doc_affine().inverse(); - svgd = sp_svg_write_path( path ); dc->selection->add(SP_OBJECT(bend_item)); sp_selection_duplicate(dc->desktop); dc->selection->remove(SP_OBJECT(bend_item)); bend_item = dc->selection->singleItem(); if(bend_item){ bend_item->moveTo(item,false); - spdc_apply_bend_shape(svgd, dc, bend_item); bend_item->transform = Geom::Affine(1,0,0,1,0,0); + spdc_apply_bend_shape(svgd, dc, bend_item); dc->selection->add(SP_OBJECT(bend_item)); + shape = BEND_CLIPBOARD; + } else { + shape = NONE; } + } else { + shape = NONE; } - shape = BEND_CLIPBOARD; } break; } -- cgit v1.2.3 From 4edf64a6334e4d67866e0b77acca5df037840eb7 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 5 Aug 2015 23:03:18 +0200 Subject: Allow scale on bend items (bzr r14277) --- src/ui/tools/freehand-base.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/ui/tools/freehand-base.cpp') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 6adece54f..31fb2f376 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -414,7 +414,11 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, bend_item = dc->selection->singleItem(); if(bend_item){ bend_item->moveTo(item,false); - bend_item->transform = Geom::Affine(1,0,0,1,0,0); + Geom::Coord expansion_X = bend_item->transform.expansionX(); + Geom::Coord expansion_Y = bend_item->transform.expansionY(); + bend_item->transform = Geom::Affine(1,0,0,1,0,0); + bend_item->transform.setExpansionX(expansion_X); + bend_item->transform.setExpansionY(expansion_Y); spdc_apply_bend_shape(svgd, dc, bend_item); dc->selection->add(SP_OBJECT(bend_item)); } else { @@ -446,7 +450,11 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, bend_item = dc->selection->singleItem(); if(bend_item){ bend_item->moveTo(item,false); + Geom::Coord expansion_X = bend_item->transform.expansionX(); + Geom::Coord expansion_Y = bend_item->transform.expansionY(); bend_item->transform = Geom::Affine(1,0,0,1,0,0); + bend_item->transform.setExpansionX(expansion_X); + bend_item->transform.setExpansionY(expansion_Y); spdc_apply_bend_shape(svgd, dc, bend_item); dc->selection->add(SP_OBJECT(bend_item)); shape = BEND_CLIPBOARD; -- cgit v1.2.3 From 8887b2a26bf5f558db43f6cda7bdd504b474bea3 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 8 Aug 2015 01:58:22 +0200 Subject: Fix a bug scaling path parameters (bzr r14282) --- src/ui/tools/freehand-base.cpp | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) (limited to 'src/ui/tools/freehand-base.cpp') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 31fb2f376..4e5fcfbee 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -215,7 +215,7 @@ static Glib::ustring const tool_name(FreehandBase *dc) : "/tools/freehand/pencil" ); } -static void spdc_paste_curve_as_freehand_shape(gchar const *svgd, FreehandBase *dc, SPItem *item) +static void spdc_paste_curve_as_freehand_shape(Geom::PathVector const &newpath, FreehandBase *dc, SPItem *item) { using namespace Inkscape::LivePathEffect; @@ -223,7 +223,7 @@ static void spdc_paste_curve_as_freehand_shape(gchar const *svgd, FreehandBase * Effect::createAndApply(PATTERN_ALONG_PATH, dc->desktop->doc(), item); Effect* lpe = SP_LPE_ITEM(item)->getCurrentLPE(); - static_cast(lpe)->pattern.paste_param_path(svgd); + static_cast(lpe)->pattern.set_new_value(newpath,true); } static void spdc_apply_powerstroke_shape(const std::vector & points, FreehandBase *dc, SPItem *item) @@ -385,8 +385,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, c->curveto(SHAPE_LENGTH, (1 + C1) * SHAPE_HEIGHT/2, (1 + C1) * SHAPE_LENGTH/2, SHAPE_HEIGHT, SHAPE_LENGTH/2, SHAPE_HEIGHT); c->curveto((1 - C1) * SHAPE_LENGTH/2, SHAPE_HEIGHT, 0, (1 + C1) * SHAPE_HEIGHT/2, 0, SHAPE_HEIGHT/2); c->closepath(); - gchar const *svgd = sp_svg_write_path(c->get_pathvector()); - spdc_paste_curve_as_freehand_shape(svgd, dc, item); + spdc_paste_curve_as_freehand_shape(c->get_pathvector(), dc, item); c->unref(); shape_applied = true; @@ -396,11 +395,27 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, { // take shape from clipboard; Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); - Glib::ustring svgd = cm->getPathParameter(SP_ACTIVE_DESKTOP); - if(svgd != ""){ - previous_shape_pathv = sp_svg_read_pathv(svgd.data()); - spdc_paste_curve_as_freehand_shape(svgd.data(), dc, item); - shape_applied = true; + if(cm->paste(SP_ACTIVE_DESKTOP,true) == true){ + SPItem * pasted_clipboard = dc->selection->singleItem(); + if(pasted_clipboard){ + Inkscape::XML::Node *pasted_clipboard_root = pasted_clipboard->getRepr(); + Inkscape::XML::Node *path = sp_repr_lookup_name(pasted_clipboard_root, "svg:path", -1); // unlimited search depth + if ( path != NULL ) { + gchar const *svgd = path->attribute("d"); + dc->selection->remove(SP_OBJECT(pasted_clipboard)); + previous_shape_pathv = sp_svg_read_pathv(svgd); + previous_shape_pathv *= pasted_clipboard->transform; + spdc_paste_curve_as_freehand_shape(previous_shape_pathv, dc, item); + + shape = CLIPBOARD; + shape_applied = true; + pasted_clipboard->deleteObject(); + } else { + shape = NONE; + } + } else { + shape = NONE; + } } else { shape = NONE; } @@ -421,6 +436,8 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, bend_item->transform.setExpansionY(expansion_Y); spdc_apply_bend_shape(svgd, dc, bend_item); dc->selection->add(SP_OBJECT(bend_item)); + + shape = BEND_CLIPBOARD; } else { shape = NONE; } @@ -433,8 +450,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, { if(previous_shape_type == CLIPBOARD){ if(previous_shape_pathv.size() != 0){ - gchar const *svgd = sp_svg_write_path(previous_shape_pathv); - spdc_paste_curve_as_freehand_shape(svgd, dc, item); + spdc_paste_curve_as_freehand_shape(previous_shape_pathv, dc, item); shape_applied = true; shape = CLIPBOARD; @@ -457,6 +473,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, bend_item->transform.setExpansionY(expansion_Y); spdc_apply_bend_shape(svgd, dc, bend_item); dc->selection->add(SP_OBJECT(bend_item)); + shape = BEND_CLIPBOARD; } else { shape = NONE; -- cgit v1.2.3 From e37df71275e0b1b195924670766d5408a80cca31 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 8 Aug 2015 02:23:52 +0200 Subject: allow more translations than only scale (bzr r14283) --- src/ui/tools/freehand-base.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/ui/tools/freehand-base.cpp') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 4e5fcfbee..a889a12e6 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -429,11 +429,7 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, bend_item = dc->selection->singleItem(); if(bend_item){ bend_item->moveTo(item,false); - Geom::Coord expansion_X = bend_item->transform.expansionX(); - Geom::Coord expansion_Y = bend_item->transform.expansionY(); - bend_item->transform = Geom::Affine(1,0,0,1,0,0); - bend_item->transform.setExpansionX(expansion_X); - bend_item->transform.setExpansionY(expansion_Y); + bend_item->transform.setTranslation(Geom::Point()); spdc_apply_bend_shape(svgd, dc, bend_item); dc->selection->add(SP_OBJECT(bend_item)); -- cgit v1.2.3 From 253da39319875724ef7345f8cc14ac75a31a4f2d Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 6 Jan 2016 13:40:41 +0100 Subject: Fix crash when apply Bend From Clipboard to a clone by the pen/pencil toolbar (bzr r14563) --- src/ui/tools/freehand-base.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/ui/tools/freehand-base.cpp') diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index a889a12e6..613857626 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -42,6 +42,7 @@ #include "selection-chemistry.h" #include "snap.h" #include "sp-path.h" +#include "sp-use.h" #include "sp-namedview.h" #include "live_effects/lpe-powerstroke.h" #include "style.h" @@ -271,7 +272,11 @@ static void spdc_apply_powerstroke_shape(const std::vector & points static void spdc_apply_bend_shape(gchar const *svgd, FreehandBase *dc, SPItem *item) { using namespace Inkscape::LivePathEffect; - if(!SP_LPE_ITEM(item)->hasPathEffectOfType(BEND_PATH)){ + SPUse *use = dynamic_cast(item); + if ( use ) { + return; + } + if(!SP_IS_LPE_ITEM(item) || !SP_LPE_ITEM(item)->hasPathEffectOfType(BEND_PATH)){ Effect::createAndApply(BEND_PATH, dc->desktop->doc(), item); } Effect* lpe = SP_LPE_ITEM(item)->getCurrentLPE(); -- cgit v1.2.3