From 522cc95fa0ffa9483134df80e4b85e9c273c967e Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 25 Sep 2013 02:14:24 +0200 Subject: First attemp for (bzr r12588.1.1) --- src/draw-context.cpp | 105 ++++++++++++++++++++++++++++++++++++++-- src/live_effects/lpe-bendpath.h | 2 +- src/widgets/pencil-toolbar.cpp | 2 + 3 files changed, 105 insertions(+), 4 deletions(-) diff --git a/src/draw-context.cpp b/src/draw-context.cpp index 09366526a..8b0237c0f 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -20,6 +20,7 @@ # include "config.h" #endif +#include "live_effects/lpe-bendpath.h" #include "live_effects/lpe-patternalongpath.h" #include "display/canvas-bpath.h" #include "xml/repr.h" @@ -45,7 +46,7 @@ #include "style.h" #include "ui/control-manager.h" #include "draw-context.h" - +#include "ui/clipboard.h" #include using Inkscape::DocumentUndo; @@ -244,7 +245,10 @@ static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item Effect::createAndApply(SPIRO, dc->desktop->doc(), item); } + static Geom::PathVector pathv; + static SPItem *itemEnd; 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"); @@ -299,13 +303,108 @@ static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item Effect::createAndApply(PATTERN_ALONG_PATH, dc->desktop->doc(), item); Effect* lpe = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(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()); shape_applied = true; break; } + case 5: + { + // take shape from clipboard; TODO: catch the case where clipboard is empty + Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); + if(cm->paste(SP_ACTIVE_DESKTOP,false) == true){ + Inkscape::Selection *selection = sp_desktop_selection(dc->desktop); + sp_selection_group(selection, dc->desktop); + GSList *items = const_cast(selection->itemList()); + SPObject *obj = reinterpret_cast(g_slist_nth_data(items,0)); + itemEnd = SP_ITEM(obj); + Effect::createAndApply(BEND_PATH, dc->desktop->doc(), itemEnd); + Effect* lpe = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(itemEnd)); + gchar const *svgd = item->getRepr()->attribute("d"); + static_cast(lpe)->bend_path.paste_param_path(svgd); + static_cast(lpe)->bend_path.param_editOncanvas(itemEnd, SP_ACTIVE_DESKTOP); + item->deleteObject(false,false); + //SPItem* item = itemEnd; + } + break; + } + 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){ + Effect::createAndApply(BEND_PATH, dc->desktop->doc(), itemEnd); + Effect* lpe = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(itemEnd)); + gchar const *svgd = item->getRepr()->attribute("d"); + static_cast(lpe)->bend_path.paste_param_path(svgd); + static_cast(lpe)->bend_path.param_editOncanvas(itemEnd, SP_ACTIVE_DESKTOP); + item->deleteObject(false,false); + //SPItem* item = itemEnd; + } + break; + } + } + shape = previous_shape; + } default: break; } + previous_shape = shape; if (shape_applied) { // apply original stroke color as fill and unset stroke; then return SPCSSAttr *css = sp_repr_css_attr_new(); @@ -322,7 +421,7 @@ static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item } if (dc->waiting_LPE_type != INVALID_LPE) { - Effect::createAndApply(dc->waiting_LPE_type, dc->desktop->doc(), item); + if(shape != 5) Effect::createAndApply(dc->waiting_LPE_type, dc->desktop->doc(), item); dc->waiting_LPE_type = INVALID_LPE; if (SP_IS_LPETOOL_CONTEXT(dc)) { diff --git a/src/live_effects/lpe-bendpath.h b/src/live_effects/lpe-bendpath.h index 16b8c6137..d3564bac4 100644 --- a/src/live_effects/lpe-bendpath.h +++ b/src/live_effects/lpe-bendpath.h @@ -39,9 +39,9 @@ public: virtual void resetDefaults(SPItem const* item); + PathParam bend_path; private: - PathParam bend_path; ScalarParam prop_scale; BoolParam scale_y_rel; BoolParam vertical_pattern; diff --git a/src/widgets/pencil-toolbar.cpp b/src/widgets/pencil-toolbar.cpp index f112a35fa..b16d55680 100644 --- a/src/widgets/pencil-toolbar.cpp +++ b/src/widgets/pencil-toolbar.cpp @@ -186,6 +186,8 @@ static GList * freehand_shape_dropdown_items_list() { glist = g_list_append (glist, _("Triangle out")); glist = g_list_append (glist, _("Ellipse")); glist = g_list_append (glist, _("From clipboard")); + glist = g_list_append (glist, _("Skeletal Stroke from clipboard")); + glist = g_list_append (glist, _("Last applied")); return glist; } -- cgit v1.2.3 From 4e687553f3955ef0988184c421a36ca19912c257 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 25 Sep 2013 02:39:56 +0200 Subject: Fix error in apply (bzr r12588.1.2) --- src/draw-context.cpp | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/draw-context.cpp b/src/draw-context.cpp index 8b0237c0f..ceb72cc71 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -235,6 +235,20 @@ static void spdc_apply_powerstroke_shape(const std::vector & points lpe->getRepr()->setAttribute("interpolator_beta", "0.2"); } +static void spdc_apply_bend_shape(gchar const *svgd, SPDrawContext *dc, SPItem *item) +{ + using namespace Inkscape::LivePathEffect; + + Effect::createAndApply(BEND_PATH, dc->desktop->doc(), item); + Effect* lpe = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item)); + + // write bend parameters: + lpe->getRepr()->setAttribute("bend_path", svgd); + lpe->getRepr()->setAttribute("prop_scale", "1"); + lpe->getRepr()->setAttribute("scale_y_rel", "false"); + lpe->getRepr()->setAttribute("vertical_pattern", "false"); +} + static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item, SPCurve *curve) { using namespace Inkscape::LivePathEffect; @@ -319,13 +333,9 @@ static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item GSList *items = const_cast(selection->itemList()); SPObject *obj = reinterpret_cast(g_slist_nth_data(items,0)); itemEnd = SP_ITEM(obj); - Effect::createAndApply(BEND_PATH, dc->desktop->doc(), itemEnd); - Effect* lpe = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(itemEnd)); gchar const *svgd = item->getRepr()->attribute("d"); - static_cast(lpe)->bend_path.paste_param_path(svgd); - static_cast(lpe)->bend_path.param_editOncanvas(itemEnd, SP_ACTIVE_DESKTOP); - item->deleteObject(false,false); - //SPItem* item = itemEnd; + spdc_apply_bend_shape(svgd, dc, itemEnd); + item->deleteObject(); } break; } @@ -388,13 +398,9 @@ static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item { // take shape from clipboard; TODO: catch the case where clipboard is empty if(itemEnd != NULL){ - Effect::createAndApply(BEND_PATH, dc->desktop->doc(), itemEnd); - Effect* lpe = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(itemEnd)); gchar const *svgd = item->getRepr()->attribute("d"); - static_cast(lpe)->bend_path.paste_param_path(svgd); - static_cast(lpe)->bend_path.param_editOncanvas(itemEnd, SP_ACTIVE_DESKTOP); - item->deleteObject(false,false); - //SPItem* item = itemEnd; + spdc_apply_bend_shape(svgd, dc, itemEnd); + item->deleteObject(); } break; } @@ -421,7 +427,7 @@ static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item } if (dc->waiting_LPE_type != INVALID_LPE) { - if(shape != 5) Effect::createAndApply(dc->waiting_LPE_type, dc->desktop->doc(), item); + Effect::createAndApply(dc->waiting_LPE_type, dc->desktop->doc(), item); dc->waiting_LPE_type = INVALID_LPE; if (SP_IS_LPETOOL_CONTEXT(dc)) { -- cgit v1.2.3 From af156edfd8f77cdffdd572ce9f2d76642e830a43 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 25 Sep 2013 02:46:32 +0200 Subject: Name of attributes in effect changed (bzr r12588.1.3) --- src/draw-context.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/draw-context.cpp b/src/draw-context.cpp index ceb72cc71..66064949a 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -243,10 +243,10 @@ static void spdc_apply_bend_shape(gchar const *svgd, SPDrawContext *dc, SPItem * Effect* lpe = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item)); // write bend parameters: - lpe->getRepr()->setAttribute("bend_path", svgd); + lpe->getRepr()->setAttribute("bendpath", svgd); lpe->getRepr()->setAttribute("prop_scale", "1"); lpe->getRepr()->setAttribute("scale_y_rel", "false"); - lpe->getRepr()->setAttribute("vertical_pattern", "false"); + lpe->getRepr()->setAttribute("vertical", "false"); } static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item, SPCurve *curve) -- cgit v1.2.3 From b59da03d20018c9e5aad70b6a356db3e6015cfae Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 25 Sep 2013 03:20:01 +0200 Subject: Some Fix (bzr r12588.1.4) --- src/widgets/pencil-toolbar.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/widgets/pencil-toolbar.cpp b/src/widgets/pencil-toolbar.cpp index b16d55680..783d8dd4d 100644 --- a/src/widgets/pencil-toolbar.cpp +++ b/src/widgets/pencil-toolbar.cpp @@ -186,7 +186,7 @@ static GList * freehand_shape_dropdown_items_list() { glist = g_list_append (glist, _("Triangle out")); glist = g_list_append (glist, _("Ellipse")); glist = g_list_append (glist, _("From clipboard")); - glist = g_list_append (glist, _("Skeletal Stroke from clipboard")); + glist = g_list_append (glist, _("Bend from clipboard")); glist = g_list_append (glist, _("Last applied")); return glist; -- cgit v1.2.3 From e1c46795a24f7f7edb18424193b21314b31a138d Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 26 Sep 2013 22:02:39 +0200 Subject: Fixing ending selection (bzr r12588.1.6) --- src/draw-context.cpp | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/draw-context.cpp b/src/draw-context.cpp index 051b54711..618a9c240 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -328,14 +328,22 @@ static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item // take shape from clipboard; TODO: catch the case where clipboard is empty Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); if(cm->paste(SP_ACTIVE_DESKTOP,false) == true){ + gchar const *svgd = item->getRepr()->attribute("d"); + item->deleteObject(); + if(itemEnd != NULL && itemEnd->getRepr() != NULL) + itemEnd->deleteObject(); Inkscape::Selection *selection = sp_desktop_selection(dc->desktop); sp_selection_group(selection, dc->desktop); GSList *items = const_cast(selection->itemList()); SPObject *obj = reinterpret_cast(g_slist_nth_data(items,0)); itemEnd = SP_ITEM(obj); - gchar const *svgd = item->getRepr()->attribute("d"); - spdc_apply_bend_shape(svgd, dc, itemEnd); - item->deleteObject(); + sp_selection_duplicate(dc->desktop); + itemEnd->setExplicitlyHidden(true); + items = const_cast(selection->itemList()); + obj = reinterpret_cast(g_slist_nth_data(items,0)); + spdc_apply_bend_shape(svgd, dc, SP_ITEM(obj)); + SP_ITEM(obj)->setExplicitlyHidden(false); + selection->set(obj,true); } break; } @@ -397,25 +405,24 @@ static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item case 5: { // take shape from clipboard; TODO: catch the case where clipboard is empty - if(itemEnd != NULL){ + if(itemEnd != NULL && itemEnd->getRepr() != NULL){ + gchar const *svgd = item->getRepr()->attribute("d"); + item->deleteObject(); Inkscape::Selection *selection = sp_desktop_selection(dc->desktop); - selection->clear(); - selection->add(itemEnd); + 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)); - itemEnd = SP_ITEM(obj); - itemEnd->getRepr()->setAttribute("inkscape:path-effect", NULL); - gchar const *svgd = item->getRepr()->attribute("d"); - spdc_apply_bend_shape(svgd, dc, itemEnd); - selection->clear(); - selection->add(itemEnd); - item->deleteObject(); + 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(obj,true); } break; } - } - shape = previous_shape; + } + shape = previous_shape; } default: break; -- cgit v1.2.3 From 2f4916861e76618e5a1767c3209d78a11e7eb24d Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 15 Oct 2013 02:59:47 +0200 Subject: Fix errors on compile and in console detected by su_v, added selection of stroke used (bzr r12588.1.13) --- src/draw-context.cpp | 52 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/src/draw-context.cpp b/src/draw-context.cpp index 62e96a21c..c3cc65021 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -240,7 +240,7 @@ static void spdc_apply_bend_shape(gchar const *svgd, SPDrawContext *dc, SPItem * using namespace Inkscape::LivePathEffect; Effect::createAndApply(BEND_PATH, dc->desktop->doc(), item); - Effect* lpe = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item)); + Effect* lpe = SP_LPE_ITEM(item)->getCurrentLPE(); // write bend parameters: lpe->getRepr()->setAttribute("bendpath", svgd); @@ -258,7 +258,12 @@ static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1) { Effect::createAndApply(SPIRO, dc->desktop->doc(), item); } - + //BSpline + //AƱadimos el modo BSpline a los efectos en espera + if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2) { + Effect::createAndApply(BSPLINE, dc->desktop->doc(), item); + } + //BSPline End static Geom::PathVector pathv; static SPItem *itemEnd; int shape = prefs->getInt(tool_name(dc) + "/shape", 0); @@ -266,6 +271,7 @@ static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *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"); + Inkscape::XML::Document *xml_doc = SP_ACTIVE_DESKTOP->doc()->getReprDoc(); #define SHAPE_LENGTH 10 #define SHAPE_HEIGHT 10 @@ -329,21 +335,26 @@ static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); if(cm->paste(SP_ACTIVE_DESKTOP,false) == true){ gchar const *svgd = item->getRepr()->attribute("d"); - item->deleteObject(); - if(itemEnd != NULL && itemEnd->getRepr() != NULL) + //item->deleteObject(); + if(itemEnd != NULL && !itemEnd->getRepr()) itemEnd->deleteObject(); Inkscape::Selection *selection = sp_desktop_selection(dc->desktop); sp_selection_group(selection, dc->desktop); GSList *items = const_cast(selection->itemList()); SPObject *obj = reinterpret_cast(g_slist_nth_data(items,0)); - itemEnd = SP_ITEM(obj); - sp_selection_duplicate(dc->desktop); - itemEnd->setExplicitlyHidden(true); - items = const_cast(selection->itemList()); - obj = reinterpret_cast(g_slist_nth_data(items,0)); - spdc_apply_bend_shape(svgd, dc, SP_ITEM(obj)); - SP_ITEM(obj)->setExplicitlyHidden(false); - selection->set(obj,true); + if(SP_IS_OBJECT(obj)){ + itemEnd = SP_ITEM(obj); + sp_selection_duplicate(dc->desktop); + itemEnd->setExplicitlyHidden(true); + items = const_cast(selection->itemList()); + obj = reinterpret_cast(g_slist_nth_data(items,0)); + if(SP_IS_OBJECT(obj)){ + spdc_apply_bend_shape(svgd, dc, SP_ITEM(obj)); + SP_ITEM(obj)->setExplicitlyHidden(false); + item->updateRepr(xml_doc,SP_ITEM(obj)->getRepr(),SP_OBJECT_WRITE_BUILD); + SP_ITEM(obj)->deleteObject(); + } + } } break; } @@ -405,19 +416,23 @@ static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item case 5: { // take shape from clipboard; TODO: catch the case where clipboard is empty - if(itemEnd != NULL && itemEnd->getRepr() != NULL){ + if(itemEnd != NULL && !itemEnd->getRepr()){ gchar const *svgd = item->getRepr()->attribute("d"); - item->deleteObject(); + //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)); - 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(obj,true); + 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); + item = SP_ITEM(obj); + item->updateRepr(xml_doc,SP_ITEM(obj)->getRepr(),SP_OBJECT_WRITE_BUILD); + SP_ITEM(obj)->deleteObject(); + } } break; } @@ -442,6 +457,7 @@ static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item sp_repr_css_attr_unref(css); return; } + if(shape == 5 || (shape == 6 && previous_shape == 5))return; if (dc->waiting_LPE_type != INVALID_LPE) { Effect::createAndApply(dc->waiting_LPE_type, dc->desktop->doc(), item); -- cgit v1.2.3 From fa0850f0af674ce9f21378a9554fbe6c03b03603 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 15 Oct 2013 03:10:55 +0200 Subject: Fixing errors (bzr r12588.1.15) --- src/draw-context.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/draw-context.cpp b/src/draw-context.cpp index c3cc65021..37c3c42c0 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -351,7 +351,7 @@ static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item if(SP_IS_OBJECT(obj)){ spdc_apply_bend_shape(svgd, dc, SP_ITEM(obj)); SP_ITEM(obj)->setExplicitlyHidden(false); - item->updateRepr(xml_doc,SP_ITEM(obj)->getRepr(),SP_OBJECT_WRITE_BUILD); + item->updateRepr(xml_doc,SP_ITEM(obj)->getRepr(),SP_OBJECT_WRITE_ALL); SP_ITEM(obj)->deleteObject(); } } @@ -430,7 +430,7 @@ static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item spdc_apply_bend_shape(svgd, dc, SP_ITEM(obj)); SP_ITEM(obj)->setExplicitlyHidden(false); item = SP_ITEM(obj); - item->updateRepr(xml_doc,SP_ITEM(obj)->getRepr(),SP_OBJECT_WRITE_BUILD); + item->updateRepr(xml_doc,SP_ITEM(obj)->getRepr(),SP_OBJECT_WRITE_ALL); SP_ITEM(obj)->deleteObject(); } } -- cgit v1.2.3 From 227ceae5c30b8ec0c0eb81eff06a387ad18b6e99 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 16 Oct 2013 12:04:41 +0200 Subject: fixing bend warnings (bzr r12588.1.16) --- src/draw-context.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/draw-context.cpp b/src/draw-context.cpp index 37c3c42c0..df0e6be3b 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -249,6 +249,7 @@ static void spdc_apply_bend_shape(gchar const *svgd, SPDrawContext *dc, SPItem * lpe->getRepr()->setAttribute("vertical", "false"); } +static bool bend; static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item, SPCurve *curve) { using namespace Inkscape::LivePathEffect; @@ -264,6 +265,7 @@ static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item Effect::createAndApply(BSPLINE, dc->desktop->doc(), item); } //BSPline End + bend = false; static Geom::PathVector pathv; static SPItem *itemEnd; int shape = prefs->getInt(tool_name(dc) + "/shape", 0); @@ -271,7 +273,6 @@ static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *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"); - Inkscape::XML::Document *xml_doc = SP_ACTIVE_DESKTOP->doc()->getReprDoc(); #define SHAPE_LENGTH 10 #define SHAPE_HEIGHT 10 @@ -335,7 +336,7 @@ static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get(); if(cm->paste(SP_ACTIVE_DESKTOP,false) == true){ gchar const *svgd = item->getRepr()->attribute("d"); - //item->deleteObject(); + item->deleteObject(); if(itemEnd != NULL && !itemEnd->getRepr()) itemEnd->deleteObject(); Inkscape::Selection *selection = sp_desktop_selection(dc->desktop); @@ -351,8 +352,8 @@ static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item if(SP_IS_OBJECT(obj)){ spdc_apply_bend_shape(svgd, dc, SP_ITEM(obj)); SP_ITEM(obj)->setExplicitlyHidden(false); - item->updateRepr(xml_doc,SP_ITEM(obj)->getRepr(),SP_OBJECT_WRITE_ALL); - SP_ITEM(obj)->deleteObject(); + bend = true; + selection->set(SP_ITEM(obj),true); } } } @@ -418,7 +419,7 @@ static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item // take shape from clipboard; TODO: catch the case where clipboard is empty if(itemEnd != NULL && !itemEnd->getRepr()){ gchar const *svgd = item->getRepr()->attribute("d"); - //item->deleteObject(); + item->deleteObject(); Inkscape::Selection *selection = sp_desktop_selection(dc->desktop); selection->add(SP_OBJECT(itemEnd)); sp_selection_duplicate(dc->desktop); @@ -430,8 +431,9 @@ static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item spdc_apply_bend_shape(svgd, dc, SP_ITEM(obj)); SP_ITEM(obj)->setExplicitlyHidden(false); item = SP_ITEM(obj); - item->updateRepr(xml_doc,SP_ITEM(obj)->getRepr(),SP_OBJECT_WRITE_ALL); - SP_ITEM(obj)->deleteObject(); + SP_OBJECT(item)->setSuccessor(obj); + bend = true; + selection->set(SP_ITEM(obj),true); } } break; @@ -681,6 +683,8 @@ static void spdc_flush_white(SPDrawContext *dc, SPCurve *gc) { SPCurve *c; + if(bend) return; + if (dc->white_curves) { g_assert(dc->white_item); c = SPCurve::concat(dc->white_curves); -- cgit v1.2.3 From b4e5058110f8e4f5ed22eb9e9ba67129c6895413 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 16 Oct 2013 12:33:57 +0200 Subject: fixing bend warnings (bzr r12588.1.18) --- src/draw-context.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/draw-context.cpp b/src/draw-context.cpp index df0e6be3b..7eafcabab 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -683,8 +683,6 @@ static void spdc_flush_white(SPDrawContext *dc, SPCurve *gc) { SPCurve *c; - if(bend) return; - if (dc->white_curves) { g_assert(dc->white_item); c = SPCurve::concat(dc->white_curves); @@ -738,11 +736,11 @@ static void spdc_flush_white(SPDrawContext *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); - dc->selection->set(repr); + if(!bend) dc->selection->set(repr); Inkscape::GC::release(repr); - item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse(); - item->doWriteTransform(item->getRepr(), item->transform, NULL, true); - item->updateRepr(); + 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(); } DocumentUndo::done(doc, SP_IS_PEN_CONTEXT(dc)? SP_VERB_CONTEXT_PEN : SP_VERB_CONTEXT_PENCIL, -- cgit v1.2.3 From 420a873bbc7ab29821174b31ab44f8dc78b50b9b Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 16 Oct 2013 12:40:49 +0200 Subject: fixing bend warnings (bzr r12588.1.19) --- src/draw-context.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/draw-context.cpp b/src/draw-context.cpp index 7eafcabab..b2afb5095 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -430,8 +430,6 @@ static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item SP_ITEM(obj)->getRepr()->setAttribute("inkscape:path-effect", NULL); spdc_apply_bend_shape(svgd, dc, SP_ITEM(obj)); SP_ITEM(obj)->setExplicitlyHidden(false); - item = SP_ITEM(obj); - SP_OBJECT(item)->setSuccessor(obj); bend = true; selection->set(SP_ITEM(obj),true); } -- cgit v1.2.3 From 2cb4bc14f2c2252ea5af6e0e5b857d8d5813ffcd Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 16 Oct 2013 12:51:38 +0200 Subject: fixing last applied bend (bzr r12588.1.20) --- src/draw-context.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/draw-context.cpp b/src/draw-context.cpp index b2afb5095..3b89652b9 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -337,7 +337,7 @@ static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item if(cm->paste(SP_ACTIVE_DESKTOP,false) == true){ gchar const *svgd = item->getRepr()->attribute("d"); item->deleteObject(); - if(itemEnd != NULL && !itemEnd->getRepr()) + if(itemEnd != NULL && itemEnd->getRepr() != NULL) itemEnd->deleteObject(); Inkscape::Selection *selection = sp_desktop_selection(dc->desktop); sp_selection_group(selection, dc->desktop); @@ -417,7 +417,7 @@ static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item case 5: { // take shape from clipboard; TODO: catch the case where clipboard is empty - if(itemEnd != NULL && !itemEnd->getRepr()){ + if(itemEnd != NULL && itemEnd->getRepr() != NULL){ gchar const *svgd = item->getRepr()->attribute("d"); item->deleteObject(); Inkscape::Selection *selection = sp_desktop_selection(dc->desktop); -- cgit v1.2.3 From 6c7e1a4c27e6ce0d7b59c1512ea612e584b16fc0 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 16 Oct 2013 14:19:49 +0200 Subject: Make private bend parameter like original (bzr r12588.1.21) --- src/live_effects/lpe-bendpath.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/live_effects/lpe-bendpath.h b/src/live_effects/lpe-bendpath.h index d3564bac4..38b1a1446 100644 --- a/src/live_effects/lpe-bendpath.h +++ b/src/live_effects/lpe-bendpath.h @@ -39,9 +39,8 @@ public: virtual void resetDefaults(SPItem const* item); - PathParam bend_path; - private: + PathParam bend_path; ScalarParam prop_scale; BoolParam scale_y_rel; BoolParam vertical_pattern; -- cgit v1.2.3 From bd1f2f185d4b1f4a849d07c4e57e9475f54821fd Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 16 Oct 2013 14:23:21 +0200 Subject: add empty line in bend parameter like original (bzr r12588.1.22) --- src/live_effects/lpe-bendpath.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/live_effects/lpe-bendpath.h b/src/live_effects/lpe-bendpath.h index 38b1a1446..16b8c6137 100644 --- a/src/live_effects/lpe-bendpath.h +++ b/src/live_effects/lpe-bendpath.h @@ -39,6 +39,7 @@ public: virtual void resetDefaults(SPItem const* item); + private: PathParam bend_path; ScalarParam prop_scale; -- cgit v1.2.3 From 474cbb61fee066dcfd84455820881dc50e97b1b7 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 16 Oct 2013 14:32:21 +0200 Subject: Removed BSpline from tell by su_v (bzr r12588.1.23) --- src/draw-context.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/draw-context.cpp b/src/draw-context.cpp index 3b89652b9..dcddd683e 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -259,12 +259,6 @@ static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1) { Effect::createAndApply(SPIRO, dc->desktop->doc(), item); } - //BSpline - //AƱadimos el modo BSpline a los efectos en espera - if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2) { - Effect::createAndApply(BSPLINE, dc->desktop->doc(), item); - } - //BSPline End bend = false; static Geom::PathVector pathv; static SPItem *itemEnd; -- cgit v1.2.3 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(-) 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(-) 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(-) 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(-) 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(-) 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 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(-) 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(-) 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