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(-) (limited to 'src') 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(-) (limited to 'src') 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(-) (limited to 'src') 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(-) (limited to 'src') 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(-) (limited to 'src') 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(-) (limited to 'src') 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(-) (limited to 'src') 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(-) (limited to 'src') 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(-) (limited to 'src') 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(-) (limited to 'src') 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(-) (limited to 'src') 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(-) (limited to 'src') 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(+) (limited to 'src') 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(-) (limited to 'src') 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(-) (limited to 'src') 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') 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') 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') 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') 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 ++++++++++++++++++++++++++ src/ui/tools/pencil-tool.cpp | 14 ++++++++++---- src/widgets/pencil-toolbar.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ src/widgets/toolbox.cpp | 2 ++ 4 files changed, 80 insertions(+), 4 deletions(-) (limited to 'src') 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"); diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp index db24c7432..e30bb3a7a 100644 --- a/src/ui/tools/pencil-tool.cpp +++ b/src/ui/tools/pencil-tool.cpp @@ -637,8 +637,11 @@ void PencilTool::_interpolate() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); double const tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0) * 0.4; - double const tolerance_sq = 0.02 * square(this->desktop->w2d().descrim() * tol) * exp(0.2 * tol - 2); - + double tolerance_sq = 0.02 * square(this->desktop->w2d().descrim() * tol) * exp(0.2 * tol - 2); + bool simplify = prefs->getInt("/tools/freehand/pencil/simplify", 0); + if(simplify){ + tolerance_sq = 0; + } g_assert(is_zero(this->req_tangent) || is_unit_vector(this->req_tangent)); this->green_curve->reset(); @@ -705,8 +708,11 @@ void PencilTool::_sketchInterpolate() { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); double const tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0) * 0.4; - double const tolerance_sq = 0.02 * square(this->desktop->w2d().descrim() * tol) * exp(0.2 * tol - 2); - + double tolerance_sq = 0.02 * square(this->desktop->w2d().descrim() * tol) * exp(0.2 * tol - 2); + bool simplify = prefs->getInt("/tools/freehand/pencil/simplify", 0); + if(simplify){ + tolerance_sq = 0; + } bool average_all_sketches = prefs->getBool("/tools/freehand/pencil/average_all_sketches", true); g_assert(is_zero(this->req_tangent) || is_unit_vector(this->req_tangent)); diff --git a/src/widgets/pencil-toolbar.cpp b/src/widgets/pencil-toolbar.cpp index 1214a378a..43d73dbc6 100644 --- a/src/widgets/pencil-toolbar.cpp +++ b/src/widgets/pencil-toolbar.cpp @@ -28,6 +28,7 @@ # include "config.h" #endif +#include #include #include "pencil-toolbar.h" @@ -43,6 +44,11 @@ #include "ui/tools/pen-tool.h" #include "ui/uxmanager.h" #include "widgets/spinbutton-events.h" +#include +#include "live_effects/lpe-simplify.h" +#include "live_effects/effect-enum.h" +#include "live_effects/lpeobject.h" +#include "sp-lpe-item.h" using Inkscape::UI::UXManager; using Inkscape::DocumentUndo; @@ -151,6 +157,12 @@ static void freehand_change_shape(EgeSelectOneAction* act, GObject *dataKludge) prefs->setInt(freehand_tool_name(dataKludge) + "/shape", shape); } +static void freehand_simplify_lpe(InkToggleAction* itact, GObject *dataKludge) { + gint simplify = gtk_toggle_action_get_active( GTK_TOGGLE_ACTION(itact) ); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setInt(freehand_tool_name(dataKludge) + "/simplify", simplify); +} + /** * Generate the list of freehand advanced shape option entries. */ @@ -232,6 +244,24 @@ static void sp_pencil_tb_tolerance_value_changed(GtkAdjustment *adj, GObject *tb prefs->setDouble("/tools/freehand/pencil/tolerance", gtk_adjustment_get_value(adj)); g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); + SPDesktop *desktop = static_cast(g_object_get_data(tbl, "desktop")); + SPItem * item = desktop->getSelection()->singleItem(); + if(item){ + SPLPEItem* lpeitem = dynamic_cast(item); + if (lpeitem && lpeitem->hasPathEffect()){ + Inkscape::LivePathEffect::Effect* thisEffect = lpeitem->getPathEffectOfType(Inkscape::LivePathEffect::SIMPLIFY); + if(thisEffect){ + Inkscape::LivePathEffect::LPESimplify *lpe = dynamic_cast(thisEffect->getLPEObj()->get_lpe()); + if (lpe) { + 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; + lpe->getRepr()->setAttribute("threshold", ss.str()); + } + } + } + } } /* @@ -303,6 +333,18 @@ void sp_pencil_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_pencil_tb_defaults), holder ); gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); } + /* LPE simplify based tolerance */ + { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + InkToggleAction* itact = ink_toggle_action_new( "PencilLpeSimplify", + _("LPE based interactive simplify"), + _("LPE based interactive simplify"), + INKSCAPE_ICON("interactive_simplify"), + Inkscape::ICON_SIZE_DECORATION ); + gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(itact), prefs->getInt("/tools/freehand/pencil/simplify", 0) ); + g_signal_connect_after( G_OBJECT(itact), "toggled", G_CALLBACK(freehand_simplify_lpe), holder) ; + gtk_action_group_add_action( mainActions, GTK_ACTION(itact) ); + } g_signal_connect( holder, "destroy", G_CALLBACK(purge_repr_listener), holder ); diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 5d52db6f2..83180e43d 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -403,6 +403,8 @@ static gchar const * ui_descr = " " " " " " + " " + " " " " " " " " -- 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 +- src/widgets/pencil-toolbar.cpp | 32 ++++++++++++++++++-------------- src/widgets/toolbox.cpp | 1 - 3 files changed, 19 insertions(+), 16 deletions(-) (limited to 'src') 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"); diff --git a/src/widgets/pencil-toolbar.cpp b/src/widgets/pencil-toolbar.cpp index 43d73dbc6..a06d76d01 100644 --- a/src/widgets/pencil-toolbar.cpp +++ b/src/widgets/pencil-toolbar.cpp @@ -49,6 +49,7 @@ #include "live_effects/effect-enum.h" #include "live_effects/lpeobject.h" #include "sp-lpe-item.h" +#include "util/glib-list-iterators.h" using Inkscape::UI::UXManager; using Inkscape::DocumentUndo; @@ -245,19 +246,22 @@ static void sp_pencil_tb_tolerance_value_changed(GtkAdjustment *adj, GObject *tb gtk_adjustment_get_value(adj)); g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); SPDesktop *desktop = static_cast(g_object_get_data(tbl, "desktop")); - SPItem * item = desktop->getSelection()->singleItem(); - if(item){ - SPLPEItem* lpeitem = dynamic_cast(item); - if (lpeitem && lpeitem->hasPathEffect()){ - Inkscape::LivePathEffect::Effect* thisEffect = lpeitem->getPathEffectOfType(Inkscape::LivePathEffect::SIMPLIFY); - if(thisEffect){ - Inkscape::LivePathEffect::LPESimplify *lpe = dynamic_cast(thisEffect->getLPEObj()->get_lpe()); - if (lpe) { - 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; - lpe->getRepr()->setAttribute("threshold", ss.str()); + std::list selected; + selected.insert >(selected.end(), desktop->getSelection()->itemList(), NULL); + if(!selected.empty()){ + for (std::list::iterator it(selected.begin()); it != selected.end(); ++it){ + SPLPEItem* lpeitem = dynamic_cast(*it); + if (lpeitem && lpeitem->hasPathEffect()){ + Inkscape::LivePathEffect::Effect* thisEffect = lpeitem->getPathEffectOfType(Inkscape::LivePathEffect::SIMPLIFY); + if(thisEffect){ + Inkscape::LivePathEffect::LPESimplify *lpe = dynamic_cast(thisEffect->getLPEObj()->get_lpe()); + if (lpe) { + 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; + lpe->getRepr()->setAttribute("threshold", ss.str()); + } } } } @@ -340,7 +344,7 @@ void sp_pencil_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb _("LPE based interactive simplify"), _("LPE based interactive simplify"), INKSCAPE_ICON("interactive_simplify"), - Inkscape::ICON_SIZE_DECORATION ); + Inkscape::ICON_SIZE_SMALL_TOOLBAR ); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(itact), prefs->getInt("/tools/freehand/pencil/simplify", 0) ); g_signal_connect_after( G_OBJECT(itact), "toggled", G_CALLBACK(freehand_simplify_lpe), holder) ; gtk_action_group_add_action( mainActions, GTK_ACTION(itact) ); diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 83180e43d..79b94cd24 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -402,7 +402,6 @@ static gchar const * ui_descr = " " " " " " - " " " " " " " " -- 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') 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') 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') 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') 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 fbf782922e70079430192417f1a9ec84fe59c8dc Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 9 Apr 2015 21:20:32 +0200 Subject: astyle simplify LPE (bzr r13973.1.12) --- src/live_effects/lpe-simplify.cpp | 134 +++++++++++++++++++------------------- src/live_effects/lpe-simplify.h | 48 +++++++------- 2 files changed, 91 insertions(+), 91 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-simplify.cpp b/src/live_effects/lpe-simplify.cpp index 1fe18dd5e..bbedd355a 100644 --- a/src/live_effects/lpe-simplify.cpp +++ b/src/live_effects/lpe-simplify.cpp @@ -27,39 +27,39 @@ namespace LivePathEffect { LPESimplify::LPESimplify(LivePathEffectObject *lpeobject) : Effect(lpeobject), - steps(_("Steps:"),_("Change number of simplify steps "), "steps", &wr, this,1), - threshold(_("Roughly threshold:"), _("Roughly threshold:"), "threshold", &wr, this, 0.003), - smooth_angles(_("Smooth angles:"), _("Max degree difference on handles to preform a smooth"), "smooth_angles", &wr, this, 20.), - helper_size(_("Helper size:"), _("Helper size"), "helper_size", &wr, this, 5), - simplifyindividualpaths(_("Paths separately"), _("Simplifying paths (separately)"), "simplifyindividualpaths", &wr, this, false, - "", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")), - simplifyJustCoalesce(_("Just coalesce"), _("Simplify just coalesce"), "simplifyJustCoalesce", &wr, this, false, - "", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")) - { - registerParameter(&steps); - registerParameter(&threshold); - registerParameter(&smooth_angles); - registerParameter(&helper_size); - registerParameter(&simplifyindividualpaths); - registerParameter(&simplifyJustCoalesce); + steps(_("Steps:"),_("Change number of simplify steps "), "steps", &wr, this,1), + threshold(_("Roughly threshold:"), _("Roughly threshold:"), "threshold", &wr, this, 0.003), + smooth_angles(_("Smooth angles:"), _("Max degree difference on handles to preform a smooth"), "smooth_angles", &wr, this, 20.), + helper_size(_("Helper size:"), _("Helper size"), "helper_size", &wr, this, 5), + simplifyindividualpaths(_("Paths separately"), _("Simplifying paths (separately)"), "simplifyindividualpaths", &wr, this, false, + "", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")), + simplifyJustCoalesce(_("Just coalesce"), _("Simplify just coalesce"), "simplifyJustCoalesce", &wr, this, false, + "", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")) +{ + registerParameter(&steps); + registerParameter(&threshold); + registerParameter(&smooth_angles); + registerParameter(&helper_size); + registerParameter(&simplifyindividualpaths); + registerParameter(&simplifyJustCoalesce); - threshold.param_set_range(0.0001, Geom::infinity()); - threshold.param_set_increments(0.0001, 0.0001); - threshold.param_set_digits(6); + threshold.param_set_range(0.0001, Geom::infinity()); + threshold.param_set_increments(0.0001, 0.0001); + threshold.param_set_digits(6); - steps.param_set_range(0, 100); - steps.param_set_increments(1, 1); - steps.param_set_digits(0); + steps.param_set_range(0, 100); + steps.param_set_increments(1, 1); + steps.param_set_digits(0); - smooth_angles.param_set_range(0.0, 365.0); - smooth_angles.param_set_increments(10, 10); - smooth_angles.param_set_digits(2); + smooth_angles.param_set_range(0.0, 365.0); + smooth_angles.param_set_increments(10, 10); + smooth_angles.param_set_digits(2); - helper_size.param_set_range(0.0, 999.0); - helper_size.param_set_increments(5, 5); - helper_size.param_set_digits(2); + helper_size.param_set_range(0.0, 999.0); + helper_size.param_set_increments(5, 5); + helper_size.param_set_digits(2); - radiusHelperNodes = 6.0; + radiusHelperNodes = 6.0; } LPESimplify::~LPESimplify() {} @@ -67,7 +67,7 @@ LPESimplify::~LPESimplify() {} void LPESimplify::doBeforeEffect (SPLPEItem const* lpeitem) { - if(!hp.empty()){ + if(!hp.empty()) { hp.clear(); } bbox = SP_ITEM(lpeitem)->visualBounds(); @@ -91,9 +91,8 @@ LPESimplify::newWidget() if ((*it)->widget_is_visible) { Parameter * param = *it; Gtk::Widget * widg = dynamic_cast(param->param_newWidget()); - if (param->param_key == "simplifyindividualpaths" || - param->param_key == "simplifyJustCoalesce") - { + if (param->param_key == "simplifyindividualpaths" || + param->param_key == "simplifyJustCoalesce") { Glib::ustring * tip = param->param_getTooltip(); if (widg) { buttons->pack_start(*widg, true, true, 2); @@ -104,7 +103,7 @@ LPESimplify::newWidget() widg->set_has_tooltip(false); } } - } else{ + } else { Glib::ustring * tip = param->param_getTooltip(); if (widg) { Gtk::HBox * scalarParameter = dynamic_cast(widg); @@ -128,28 +127,29 @@ LPESimplify::newWidget() return dynamic_cast(vbox); } -void -LPESimplify::doEffect(SPCurve *curve) { +void +LPESimplify::doEffect(SPCurve *curve) +{ Geom::PathVector const original_pathv = pathv_to_linear_and_cubic_beziers(curve->get_pathvector()); gdouble size = Geom::L2(bbox->dimensions()); //size /= Geom::Affine(0,0,0,0,0,0).descrim(); Path* pathliv = Path_for_pathvector(original_pathv); - if(simplifyindividualpaths){ + if(simplifyindividualpaths) { size = Geom::L2(Geom::bounds_fast(original_pathv)->dimensions()); } - for (int unsigned i = 0; i < steps; i++){ + for (int unsigned i = 0; i < steps; i++) { if ( simplifyJustCoalesce ) { - pathliv->Coalesce(threshold * size); - }else{ - pathliv->ConvertEvenLines(threshold * size); - pathliv->Simplify(threshold * size); + pathliv->Coalesce(threshold * size); + } else { + pathliv->ConvertEvenLines(threshold * size); + pathliv->Simplify(threshold * size); } } Geom::PathVector result = Geom::parse_svg_path(pathliv->svg_dump_path()); generateHelperPathAndSmooth(result); curve->set_pathvector(result); SPDesktop* desktop = SP_ACTIVE_DESKTOP; - if(desktop && INK_IS_NODE_TOOL(desktop->event_context)){ + if(desktop && INK_IS_NODE_TOOL(desktop->event_context)) { Inkscape::UI::Tools::NodeTool *nt = static_cast(desktop->event_context); nt->update_helperpath(); } @@ -158,15 +158,15 @@ LPESimplify::doEffect(SPCurve *curve) { void LPESimplify::generateHelperPathAndSmooth(Geom::PathVector &result) { - if(steps < 1){ + if(steps < 1) { return; } Geom::PathVector tmpPath; Geom::CubicBezier const *cubic = NULL; for (Geom::PathVector::iterator path_it = result.begin(); path_it != result.end(); ++path_it) { //Si está vacío... - if (path_it->empty()){ - continue; + if (path_it->empty()) { + continue; } //Itreadores Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve @@ -174,20 +174,20 @@ LPESimplify::generateHelperPathAndSmooth(Geom::PathVector &result) Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop SPCurve *nCurve = new SPCurve(); if (path_it->closed()) { - // if the path is closed, maybe we have to stop a bit earlier because the - // closing line segment has zerolength. - const Geom::Curve &closingline = - path_it->back_closed(); // the closing line segment is always of type - // Geom::LineSegment. - if (are_near(closingline.initialPoint(), closingline.finalPoint())) { - // closingline.isDegenerate() did not work, because it only checks for - // *exact* zero length, which goes wrong for relative coordinates and - // rounding errors... - // the closing line segment has zero-length. So stop before that one! - curve_endit = path_it->end_open(); - } + // if the path is closed, maybe we have to stop a bit earlier because the + // closing line segment has zerolength. + const Geom::Curve &closingline = + path_it->back_closed(); // the closing line segment is always of type + // Geom::LineSegment. + if (are_near(closingline.initialPoint(), closingline.finalPoint())) { + // closingline.isDegenerate() did not work, because it only checks for + // *exact* zero length, which goes wrong for relative coordinates and + // rounding errors... + // the closing line segment has zero-length. So stop before that one! + curve_endit = path_it->end_open(); + } } - if(helper_size > 0){ + if(helper_size > 0) { drawNode(curve_it1->initialPoint()); } nCurve->moveto(curve_it1->initialPoint()); @@ -202,14 +202,14 @@ LPESimplify::generateHelperPathAndSmooth(Geom::PathVector &result) pointAt1 = (*cubic)[1]; pointAt2 = (*cubic)[2]; } - if(start == Geom::Point(0,0)){ + if(start == Geom::Point(0,0)) { start = pointAt1; } - - if(path_it->closed() && curve_it2 == curve_endit){ + + if(path_it->closed() && curve_it2 == curve_endit) { pointAt4 = start; } - if(curve_it2 != curve_endit){ + if(curve_it2 != curve_endit) { cubic = dynamic_cast(&*curve_it2); if (cubic) { pointAt4 = (*cubic)[1]; @@ -219,7 +219,7 @@ LPESimplify::generateHelperPathAndSmooth(Geom::PathVector &result) Geom::Ray ray2(pointAt3, pointAt4); double angle1 = Geom::rad_to_deg(ray1.angle()); double angle2 = Geom::rad_to_deg(ray2.angle()); - if((smooth_angles >= angle2 - angle1) && !are_near(pointAt4,pointAt3) && !are_near(pointAt2,pointAt3)){ + if((smooth_angles >= angle2 - angle1) && !are_near(pointAt4,pointAt3) && !are_near(pointAt2,pointAt3)) { double dist = Geom::distance(pointAt2,pointAt3); Geom::Angle angleFixed = ray2.angle(); angleFixed -= Geom::Angle::from_degrees(180.0); @@ -231,11 +231,11 @@ LPESimplify::generateHelperPathAndSmooth(Geom::PathVector &result) pointAt1 = (*cubic)[1]; pointAt2 = (*cubic)[2]; if(helper_size > 0) { - if(!are_near((*cubic)[0],(*cubic)[1])){ + if(!are_near((*cubic)[0],(*cubic)[1])) { drawHandle((*cubic)[1]); drawHandleLine((*cubic)[0],(*cubic)[1]); } - if(!are_near((*cubic)[3],(*cubic)[2])){ + if(!are_near((*cubic)[3],(*cubic)[2])) { drawHandle((*cubic)[2]); drawHandleLine((*cubic)[3],(*cubic)[2]); } @@ -257,7 +257,7 @@ LPESimplify::generateHelperPathAndSmooth(Geom::PathVector &result) result = tmpPath; } -void +void LPESimplify::drawNode(Geom::Point p) { double r = radiusHelperNodes; @@ -289,7 +289,7 @@ LPESimplify::drawHandleLine(Geom::Point p,Geom::Point p2) Geom::Path path; path.start( p ); double diameter = radiusHelperNodes; - if(helper_size > 0 && Geom::distance(p,p2) > (diameter * 0.35)){ + if(helper_size > 0 && Geom::distance(p,p2) > (diameter * 0.35)) { Geom::Ray ray2(p, p2); p2 = p2 - Geom::Point::polar(ray2.angle(),(diameter * 0.35)); } diff --git a/src/live_effects/lpe-simplify.h b/src/live_effects/lpe-simplify.h index c18c3ecdf..bc70e9f54 100644 --- a/src/live_effects/lpe-simplify.h +++ b/src/live_effects/lpe-simplify.h @@ -14,43 +14,43 @@ namespace Inkscape { namespace LivePathEffect { -class LPESimplify : public Effect , GroupBBoxEffect{ +class LPESimplify : public Effect , GroupBBoxEffect { public: - LPESimplify(LivePathEffectObject *lpeobject); - virtual ~LPESimplify(); + LPESimplify(LivePathEffectObject *lpeobject); + virtual ~LPESimplify(); - virtual void doEffect(SPCurve *curve); + virtual void doEffect(SPCurve *curve); - virtual void doBeforeEffect (SPLPEItem const* lpeitem); + virtual void doBeforeEffect (SPLPEItem const* lpeitem); - virtual void generateHelperPathAndSmooth(Geom::PathVector &result); + virtual void generateHelperPathAndSmooth(Geom::PathVector &result); - virtual Gtk::Widget * newWidget(); + virtual Gtk::Widget * newWidget(); - virtual void drawNode(Geom::Point p); - - virtual void drawHandle(Geom::Point p); + virtual void drawNode(Geom::Point p); - virtual void drawHandleLine(Geom::Point p,Geom::Point p2); + virtual void drawHandle(Geom::Point p); + + virtual void drawHandleLine(Geom::Point p,Geom::Point p2); protected: void addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector &hp_vec); private: - ScalarParam steps; - ScalarParam threshold; - ScalarParam smooth_angles; - ScalarParam helper_size; - ToggleButtonParam simplifyindividualpaths; - ToggleButtonParam simplifyJustCoalesce; - - double radiusHelperNodes; - Geom::PathVector hp; - Geom::OptRect bbox; - - LPESimplify(const LPESimplify &); - LPESimplify &operator=(const LPESimplify &); + ScalarParam steps; + ScalarParam threshold; + ScalarParam smooth_angles; + ScalarParam helper_size; + ToggleButtonParam simplifyindividualpaths; + ToggleButtonParam simplifyJustCoalesce; + + double radiusHelperNodes; + Geom::PathVector hp; + Geom::OptRect bbox; + + LPESimplify(const LPESimplify &); + LPESimplify &operator=(const LPESimplify &); }; -- cgit v1.2.3 From cec061f7cf7b30d2a92ddf729c36aa032a1b6ddf Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 9 Apr 2015 21:30:28 +0200 Subject: Coding style fixes (bzr r13973.1.13) --- src/live_effects/lpe-simplify.cpp | 80 +++++++++++++++++++-------------------- src/live_effects/lpe-simplify.h | 6 +-- 2 files changed, 43 insertions(+), 43 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-simplify.cpp b/src/live_effects/lpe-simplify.cpp index bbedd355a..d2ced47ae 100644 --- a/src/live_effects/lpe-simplify.cpp +++ b/src/live_effects/lpe-simplify.cpp @@ -31,17 +31,17 @@ LPESimplify::LPESimplify(LivePathEffectObject *lpeobject) threshold(_("Roughly threshold:"), _("Roughly threshold:"), "threshold", &wr, this, 0.003), smooth_angles(_("Smooth angles:"), _("Max degree difference on handles to preform a smooth"), "smooth_angles", &wr, this, 20.), helper_size(_("Helper size:"), _("Helper size"), "helper_size", &wr, this, 5), - simplifyindividualpaths(_("Paths separately"), _("Simplifying paths (separately)"), "simplifyindividualpaths", &wr, this, false, + simplify_individual_paths(_("Paths separately"), _("Simplifying paths (separately)"), "simplify_individual_paths", &wr, this, false, "", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")), - simplifyJustCoalesce(_("Just coalesce"), _("Simplify just coalesce"), "simplifyJustCoalesce", &wr, this, false, + simplify_just_coalesce(_("Just coalesce"), _("Simplify just coalesce"), "simplify_just_coalesce", &wr, this, false, "", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")) { registerParameter(&steps); registerParameter(&threshold); registerParameter(&smooth_angles); registerParameter(&helper_size); - registerParameter(&simplifyindividualpaths); - registerParameter(&simplifyJustCoalesce); + registerParameter(&simplify_individual_paths); + registerParameter(&simplify_just_coalesce); threshold.param_set_range(0.0001, Geom::infinity()); threshold.param_set_increments(0.0001, 0.0001); @@ -59,7 +59,7 @@ LPESimplify::LPESimplify(LivePathEffectObject *lpeobject) helper_size.param_set_increments(5, 5); helper_size.param_set_digits(2); - radiusHelperNodes = 6.0; + radius_helper_nodes = 6.0; } LPESimplify::~LPESimplify() {} @@ -72,7 +72,7 @@ LPESimplify::doBeforeEffect (SPLPEItem const* lpeitem) } bbox = SP_ITEM(lpeitem)->visualBounds(); SPLPEItem * item = const_cast(lpeitem); - radiusHelperNodes = helper_size; + radius_helper_nodes = helper_size; item->apply_to_clippath(item); item->apply_to_mask(item); } @@ -91,8 +91,8 @@ LPESimplify::newWidget() if ((*it)->widget_is_visible) { Parameter * param = *it; Gtk::Widget * widg = dynamic_cast(param->param_newWidget()); - if (param->param_key == "simplifyindividualpaths" || - param->param_key == "simplifyJustCoalesce") { + if (param->param_key == "simplify_individual_paths" || + param->param_key == "simplify_just_coalesce") { Glib::ustring * tip = param->param_getTooltip(); if (widg) { buttons->pack_start(*widg, true, true, 2); @@ -106,10 +106,10 @@ LPESimplify::newWidget() } else { Glib::ustring * tip = param->param_getTooltip(); if (widg) { - Gtk::HBox * scalarParameter = dynamic_cast(widg); - std::vector< Gtk::Widget* > childList = scalarParameter->get_children(); - Gtk::Entry* entryWidg = dynamic_cast(childList[1]); - entryWidg->set_width_chars(8); + Gtk::HBox * horizontal_box = dynamic_cast(widg); + std::vector< Gtk::Widget* > child_list = horizontal_box->get_children(); + Gtk::Entry* entry_widg = dynamic_cast(child_list[1]); + entry_widg->set_width_chars(8); vbox->pack_start(*widg, true, true, 2); if (tip) { widg->set_tooltip_text(*tip); @@ -134,11 +134,11 @@ LPESimplify::doEffect(SPCurve *curve) gdouble size = Geom::L2(bbox->dimensions()); //size /= Geom::Affine(0,0,0,0,0,0).descrim(); Path* pathliv = Path_for_pathvector(original_pathv); - if(simplifyindividualpaths) { + if(simplify_individual_paths) { size = Geom::L2(Geom::bounds_fast(original_pathv)->dimensions()); } for (int unsigned i = 0; i < steps; i++) { - if ( simplifyJustCoalesce ) { + if ( simplify_just_coalesce ) { pathliv->Coalesce(threshold * size); } else { pathliv->ConvertEvenLines(threshold * size); @@ -161,7 +161,7 @@ LPESimplify::generateHelperPathAndSmooth(Geom::PathVector &result) if(steps < 1) { return; } - Geom::PathVector tmpPath; + Geom::PathVector tmp_path; Geom::CubicBezier const *cubic = NULL; for (Geom::PathVector::iterator path_it = result.begin(); path_it != result.end(); ++path_it) { //Si está vacío... @@ -188,48 +188,48 @@ LPESimplify::generateHelperPathAndSmooth(Geom::PathVector &result) } } if(helper_size > 0) { - drawNode(curve_it1->initialPoint()); + draw_node(curve_it1->initialPoint()); } nCurve->moveto(curve_it1->initialPoint()); Geom::Point start = Geom::Point(0,0); while (curve_it1 != curve_endit) { cubic = dynamic_cast(&*curve_it1); - Geom::Point pointAt1 = curve_it1->initialPoint(); - Geom::Point pointAt2 = curve_it1->finalPoint(); - Geom::Point pointAt3 = curve_it1->finalPoint(); - Geom::Point pointAt4 = curve_it1->finalPoint(); + Geom::Point point_at1 = curve_it1->initialPoint(); + Geom::Point point_at2 = curve_it1->finalPoint(); + Geom::Point point_at3 = curve_it1->finalPoint(); + Geom::Point point_at4 = curve_it1->finalPoint(); if (cubic) { - pointAt1 = (*cubic)[1]; - pointAt2 = (*cubic)[2]; + point_at1 = (*cubic)[1]; + point_at2 = (*cubic)[2]; } if(start == Geom::Point(0,0)) { - start = pointAt1; + start = point_at1; } if(path_it->closed() && curve_it2 == curve_endit) { - pointAt4 = start; + point_at4 = start; } if(curve_it2 != curve_endit) { cubic = dynamic_cast(&*curve_it2); if (cubic) { - pointAt4 = (*cubic)[1]; + point_at4 = (*cubic)[1]; } } - Geom::Ray ray1(pointAt2, pointAt3); - Geom::Ray ray2(pointAt3, pointAt4); + Geom::Ray ray1(point_at2, point_at3); + Geom::Ray ray2(point_at3, point_at4); double angle1 = Geom::rad_to_deg(ray1.angle()); double angle2 = Geom::rad_to_deg(ray2.angle()); - if((smooth_angles >= angle2 - angle1) && !are_near(pointAt4,pointAt3) && !are_near(pointAt2,pointAt3)) { - double dist = Geom::distance(pointAt2,pointAt3); + if((smooth_angles >= angle2 - angle1) && !are_near(point_at4,point_at3) && !are_near(point_at2,point_at3)) { + double dist = Geom::distance(point_at2,point_at3); Geom::Angle angleFixed = ray2.angle(); angleFixed -= Geom::Angle::from_degrees(180.0); - pointAt2 = Geom::Point::polar(angleFixed,dist) + pointAt3; + point_at2 = Geom::Point::polar(angleFixed,dist) + point_at3; } - nCurve->curveto(pointAt1, pointAt2, curve_it1->finalPoint()); + nCurve->curveto(point_at1, point_at2, curve_it1->finalPoint()); cubic = dynamic_cast(nCurve->last_segment()); if (cubic) { - pointAt1 = (*cubic)[1]; - pointAt2 = (*cubic)[2]; + point_at1 = (*cubic)[1]; + point_at2 = (*cubic)[2]; if(helper_size > 0) { if(!are_near((*cubic)[0],(*cubic)[1])) { drawHandle((*cubic)[1]); @@ -242,7 +242,7 @@ LPESimplify::generateHelperPathAndSmooth(Geom::PathVector &result) } } if(helper_size > 0) { - drawNode(curve_it1->finalPoint()); + draw_node(curve_it1->finalPoint()); } ++curve_it1; ++curve_it2; @@ -250,17 +250,17 @@ LPESimplify::generateHelperPathAndSmooth(Geom::PathVector &result) if (path_it->closed()) { nCurve->closepath_current(); } - tmpPath.push_back(nCurve->get_pathvector()[0]); + tmp_path.push_back(nCurve->get_pathvector()[0]); nCurve->reset(); delete nCurve; } - result = tmpPath; + result = tmp_path; } void -LPESimplify::drawNode(Geom::Point p) +LPESimplify::draw_node(Geom::Point p) { - double r = radiusHelperNodes; + double r = radius_helper_nodes; char const * svgd; svgd = "M 0.55,0.5 A 0.05,0.05 0 0 1 0.5,0.55 0.05,0.05 0 0 1 0.45,0.5 0.05,0.05 0 0 1 0.5,0.45 0.05,0.05 0 0 1 0.55,0.5 Z M 0,0 1,0 1,1 0,1 Z"; Geom::PathVector pathv = sp_svg_read_pathv(svgd); @@ -273,7 +273,7 @@ LPESimplify::drawNode(Geom::Point p) void LPESimplify::drawHandle(Geom::Point p) { - double r = radiusHelperNodes; + double r = radius_helper_nodes; char const * svgd; svgd = "M 0.7,0.35 A 0.35,0.35 0 0 1 0.35,0.7 0.35,0.35 0 0 1 0,0.35 0.35,0.35 0 0 1 0.35,0 0.35,0.35 0 0 1 0.7,0.35 Z"; Geom::PathVector pathv = sp_svg_read_pathv(svgd); @@ -288,7 +288,7 @@ LPESimplify::drawHandleLine(Geom::Point p,Geom::Point p2) { Geom::Path path; path.start( p ); - double diameter = radiusHelperNodes; + double diameter = radius_helper_nodes; if(helper_size > 0 && Geom::distance(p,p2) > (diameter * 0.35)) { Geom::Ray ray2(p, p2); p2 = p2 - Geom::Point::polar(ray2.angle(),(diameter * 0.35)); diff --git a/src/live_effects/lpe-simplify.h b/src/live_effects/lpe-simplify.h index bc70e9f54..294d77b35 100644 --- a/src/live_effects/lpe-simplify.h +++ b/src/live_effects/lpe-simplify.h @@ -42,10 +42,10 @@ private: ScalarParam threshold; ScalarParam smooth_angles; ScalarParam helper_size; - ToggleButtonParam simplifyindividualpaths; - ToggleButtonParam simplifyJustCoalesce; + ToggleButtonParam simplify_individual_paths; + ToggleButtonParam simplify_just_coalesce; - double radiusHelperNodes; + double radius_helper_nodes; Geom::PathVector hp; Geom::OptRect bbox; -- cgit v1.2.3 From dbff287750e69fde0a98e67c297531113ed74d13 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 9 Apr 2015 21:34:51 +0200 Subject: fix a bug in refactor (bzr r13973.1.14) --- src/live_effects/lpe-simplify.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/live_effects/lpe-simplify.cpp b/src/live_effects/lpe-simplify.cpp index d2ced47ae..7fc20ede1 100644 --- a/src/live_effects/lpe-simplify.cpp +++ b/src/live_effects/lpe-simplify.cpp @@ -188,7 +188,7 @@ LPESimplify::generateHelperPathAndSmooth(Geom::PathVector &result) } } if(helper_size > 0) { - draw_node(curve_it1->initialPoint()); + drawNode(curve_it1->initialPoint()); } nCurve->moveto(curve_it1->initialPoint()); Geom::Point start = Geom::Point(0,0); @@ -242,7 +242,7 @@ LPESimplify::generateHelperPathAndSmooth(Geom::PathVector &result) } } if(helper_size > 0) { - draw_node(curve_it1->finalPoint()); + drawNode(curve_it1->finalPoint()); } ++curve_it1; ++curve_it2; @@ -258,7 +258,7 @@ LPESimplify::generateHelperPathAndSmooth(Geom::PathVector &result) } void -LPESimplify::draw_node(Geom::Point p) +LPESimplify::drawNode(Geom::Point p) { double r = radius_helper_nodes; char const * svgd; -- 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') 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 6a65a35182b059890732c0ddc9be9d0a3a37b941 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 25 Jul 2015 01:18:08 +0200 Subject: change from list to vector (bzr r13973.1.16) --- src/widgets/pencil-toolbar.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/widgets/pencil-toolbar.cpp b/src/widgets/pencil-toolbar.cpp index a06d76d01..f2214bf49 100644 --- a/src/widgets/pencil-toolbar.cpp +++ b/src/widgets/pencil-toolbar.cpp @@ -246,10 +246,9 @@ static void sp_pencil_tb_tolerance_value_changed(GtkAdjustment *adj, GObject *tb gtk_adjustment_get_value(adj)); g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); SPDesktop *desktop = static_cast(g_object_get_data(tbl, "desktop")); - std::list selected; - selected.insert >(selected.end(), desktop->getSelection()->itemList(), NULL); + std::vector selected = desktop->getSelection()->itemList(); if(!selected.empty()){ - for (std::list::iterator it(selected.begin()); it != selected.end(); ++it){ + for (std::vector::iterator it(selected.begin()); it != selected.end(); ++it){ SPLPEItem* lpeitem = dynamic_cast(*it); if (lpeitem && lpeitem->hasPathEffect()){ Inkscape::LivePathEffect::Effect* thisEffect = lpeitem->getPathEffectOfType(Inkscape::LivePathEffect::SIMPLIFY); -- cgit v1.2.3 From dc77ca9ec48c72a20fbd3f9ae038f41e01d98216 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 25 Jul 2015 16:14:12 +0200 Subject: SPKnot no longer consumes all GDK_KEY_PRESS events Fixed bugs: - https://launchpad.net/bugs/1164964 (bzr r14255) --- src/knot.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/knot.cpp b/src/knot.cpp index b3813ab53..92d14afb9 100644 --- a/src/knot.cpp +++ b/src/knot.cpp @@ -206,6 +206,8 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot return true; } + bool key_press_event_unconsumed = FALSE; + knot_ref(knot); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -355,6 +357,7 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot break; default: consumed = FALSE; + key_press_event_unconsumed = TRUE; break; } break; @@ -364,7 +367,11 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot knot_unref(knot); - return consumed || grabbed; + if (key_press_event_unconsumed) { + return false; // e.g. in case "%" was pressed to toggle snapping, or Q for quick zoom (while dragging a handle) + } else { + return consumed || grabbed; + } } void sp_knot_handler_request_position(GdkEvent *event, SPKnot *knot) { -- cgit v1.2.3 From e54ebcdc4a05ada120a82c7d721044fdd4c205d0 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 25 Jul 2015 16:23:16 +0200 Subject: Cleanup spurious indentation (bzr r14256) --- src/knot.cpp | 242 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 121 insertions(+), 121 deletions(-) (limited to 'src') diff --git a/src/knot.cpp b/src/knot.cpp index 92d14afb9..bfc0c4f0b 100644 --- a/src/knot.cpp +++ b/src/knot.cpp @@ -215,154 +215,154 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot switch (event->type) { case GDK_2BUTTON_PRESS: - if (event->button.button == 1) { - knot->doubleclicked_signal.emit(knot, event->button.state); + if (event->button.button == 1) { + knot->doubleclicked_signal.emit(knot, event->button.state); - grabbed = FALSE; - moved = FALSE; - consumed = TRUE; - } - break; + grabbed = FALSE; + moved = FALSE; + consumed = TRUE; + } + break; case GDK_BUTTON_PRESS: - if ((event->button.button == 1) && knot->desktop && knot->desktop->event_context && !knot->desktop->event_context->space_panning) { - Geom::Point const p = knot->desktop->w2d(Geom::Point(event->button.x, event->button.y)); - knot->startDragging(p, (gint) event->button.x, (gint) event->button.y, event->button.time); + if ((event->button.button == 1) && knot->desktop && knot->desktop->event_context && !knot->desktop->event_context->space_panning) { + Geom::Point const p = knot->desktop->w2d(Geom::Point(event->button.x, event->button.y)); + knot->startDragging(p, (gint) event->button.x, (gint) event->button.y, event->button.time); - consumed = TRUE; - } - break; + consumed = TRUE; + } + break; case GDK_BUTTON_RELEASE: - if (event->button.button == 1 && knot->desktop && knot->desktop->event_context && !knot->desktop->event_context->space_panning) { - // If we have any pending snap event, then invoke it now - if (knot->desktop->event_context->_delayed_snap_event) { - sp_event_context_snap_watchdog_callback(knot->desktop->event_context->_delayed_snap_event); - } - - sp_event_context_discard_delayed_snap_event(knot->desktop->event_context); - - knot->pressure = 0; - - if (transform_escaped) { - transform_escaped = false; - consumed = TRUE; - } else { - knot->setFlag(SP_KNOT_GRABBED, FALSE); - - if (!nograb) { - sp_canvas_item_ungrab(knot->item, event->button.time); - } + if (event->button.button == 1 && knot->desktop && knot->desktop->event_context && !knot->desktop->event_context->space_panning) { + // If we have any pending snap event, then invoke it now + if (knot->desktop->event_context->_delayed_snap_event) { + sp_event_context_snap_watchdog_callback(knot->desktop->event_context->_delayed_snap_event); + } - if (moved) { - knot->setFlag(SP_KNOT_DRAGGING, FALSE); + sp_event_context_discard_delayed_snap_event(knot->desktop->event_context); - knot->ungrabbed_signal.emit(knot, event->button.state); - } else { - knot->click_signal.emit(knot, event->button.state); - } + knot->pressure = 0; - grabbed = FALSE; - moved = FALSE; - consumed = TRUE; - } - } - if (tools_isactive(knot->desktop, TOOLS_NODES)) { - Inkscape::UI::Tools::NodeTool *nt = static_cast(knot->desktop->event_context); - nt->update_helperpath(); - } - break; - case GDK_MOTION_NOTIFY: - if (grabbed && knot->desktop && knot->desktop->event_context && !knot->desktop->event_context->space_panning) { + if (transform_escaped) { + transform_escaped = false; consumed = TRUE; + } else { + knot->setFlag(SP_KNOT_GRABBED, FALSE); - if ( within_tolerance - && ( abs( (gint) event->motion.x - xp ) < tolerance ) - && ( abs( (gint) event->motion.y - yp ) < tolerance ) ) { - break; // do not drag if we're within tolerance from origin + if (!nograb) { + sp_canvas_item_ungrab(knot->item, event->button.time); } - // Once the user has moved farther than tolerance from the original location - // (indicating they intend to move the object, not click), then always process the - // motion notify coordinates as given (no snapping back to origin) - within_tolerance = false; + if (moved) { + knot->setFlag(SP_KNOT_DRAGGING, FALSE); - if (gdk_event_get_axis (event, GDK_AXIS_PRESSURE, &knot->pressure)) { - knot->pressure = CLAMP (knot->pressure, 0, 1); + knot->ungrabbed_signal.emit(knot, event->button.state); } else { - knot->pressure = 0.5; + knot->click_signal.emit(knot, event->button.state); } - if (!moved) { - knot->grabbed_signal.emit(knot, event->motion.state); + grabbed = FALSE; + moved = FALSE; + consumed = TRUE; + } + } + if (tools_isactive(knot->desktop, TOOLS_NODES)) { + Inkscape::UI::Tools::NodeTool *nt = static_cast(knot->desktop->event_context); + nt->update_helperpath(); + } + break; + case GDK_MOTION_NOTIFY: + if (grabbed && knot->desktop && knot->desktop->event_context && !knot->desktop->event_context->space_panning) { + consumed = TRUE; + + if ( within_tolerance + && ( abs( (gint) event->motion.x - xp ) < tolerance ) + && ( abs( (gint) event->motion.y - yp ) < tolerance ) ) { + break; // do not drag if we're within tolerance from origin + } - knot->setFlag(SP_KNOT_DRAGGING, TRUE); - } + // Once the user has moved farther than tolerance from the original location + // (indicating they intend to move the object, not click), then always process the + // motion notify coordinates as given (no snapping back to origin) + within_tolerance = false; - sp_event_context_snap_delay_handler(knot->desktop->event_context, NULL, knot, (GdkEventMotion *)event, Inkscape::UI::Tools::DelayedSnapEvent::KNOT_HANDLER); - sp_knot_handler_request_position(event, knot); - moved = TRUE; + if (gdk_event_get_axis (event, GDK_AXIS_PRESSURE, &knot->pressure)) { + knot->pressure = CLAMP (knot->pressure, 0, 1); + } else { + knot->pressure = 0.5; } - if (tools_isactive(knot->desktop, TOOLS_NODES)) { - Inkscape::UI::Tools::NodeTool *nt = static_cast(knot->desktop->event_context); - nt->update_helperpath(); + + if (!moved) { + knot->grabbed_signal.emit(knot, event->motion.state); + + knot->setFlag(SP_KNOT_DRAGGING, TRUE); } - break; + + sp_event_context_snap_delay_handler(knot->desktop->event_context, NULL, knot, (GdkEventMotion *)event, Inkscape::UI::Tools::DelayedSnapEvent::KNOT_HANDLER); + sp_knot_handler_request_position(event, knot); + moved = TRUE; + } + if (tools_isactive(knot->desktop, TOOLS_NODES)) { + Inkscape::UI::Tools::NodeTool *nt = static_cast(knot->desktop->event_context); + nt->update_helperpath(); + } + break; case GDK_ENTER_NOTIFY: - knot->setFlag(SP_KNOT_MOUSEOVER, TRUE); - knot->setFlag(SP_KNOT_GRABBED, FALSE); + knot->setFlag(SP_KNOT_MOUSEOVER, TRUE); + knot->setFlag(SP_KNOT_GRABBED, FALSE); - if (knot->tip && knot->desktop && knot->desktop->event_context) { - knot->desktop->event_context->defaultMessageContext()->set(Inkscape::NORMAL_MESSAGE, knot->tip); - } + if (knot->tip && knot->desktop && knot->desktop->event_context) { + knot->desktop->event_context->defaultMessageContext()->set(Inkscape::NORMAL_MESSAGE, knot->tip); + } - grabbed = FALSE; - moved = FALSE; - consumed = TRUE; - break; + grabbed = FALSE; + moved = FALSE; + consumed = TRUE; + break; case GDK_LEAVE_NOTIFY: - knot->setFlag(SP_KNOT_MOUSEOVER, FALSE); - knot->setFlag(SP_KNOT_GRABBED, FALSE); + knot->setFlag(SP_KNOT_MOUSEOVER, FALSE); + knot->setFlag(SP_KNOT_GRABBED, FALSE); - if (knot->tip && knot->desktop && knot->desktop->event_context) { - knot->desktop->event_context->defaultMessageContext()->clear(); - } + if (knot->tip && knot->desktop && knot->desktop->event_context) { + knot->desktop->event_context->defaultMessageContext()->clear(); + } - grabbed = FALSE; - moved = FALSE; - consumed = TRUE; - break; + grabbed = FALSE; + moved = FALSE; + consumed = TRUE; + break; case GDK_KEY_PRESS: // keybindings for knot - switch (Inkscape::UI::Tools::get_group0_keyval(&event->key)) { - case GDK_KEY_Escape: - knot->setFlag(SP_KNOT_GRABBED, FALSE); - - if (!nograb) { - sp_canvas_item_ungrab(knot->item, event->button.time); - } - - if (moved) { - knot->setFlag(SP_KNOT_DRAGGING, FALSE); - - knot->ungrabbed_signal.emit(knot, event->button.state); - - DocumentUndo::undo(knot->desktop->getDocument()); - knot->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Node or handle drag canceled.")); - transform_escaped = true; - consumed = TRUE; - } - - grabbed = FALSE; - moved = FALSE; - - sp_event_context_discard_delayed_snap_event(knot->desktop->event_context); - break; - default: - consumed = FALSE; - key_press_event_unconsumed = TRUE; - break; - } - break; + switch (Inkscape::UI::Tools::get_group0_keyval(&event->key)) { + case GDK_KEY_Escape: + knot->setFlag(SP_KNOT_GRABBED, FALSE); + + if (!nograb) { + sp_canvas_item_ungrab(knot->item, event->button.time); + } + + if (moved) { + knot->setFlag(SP_KNOT_DRAGGING, FALSE); + + knot->ungrabbed_signal.emit(knot, event->button.state); + + DocumentUndo::undo(knot->desktop->getDocument()); + knot->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Node or handle drag canceled.")); + transform_escaped = true; + consumed = TRUE; + } + + grabbed = FALSE; + moved = FALSE; + + sp_event_context_discard_delayed_snap_event(knot->desktop->event_context); + break; + default: + consumed = FALSE; + key_press_event_unconsumed = TRUE; + break; + } + break; default: - break; + break; } knot_unref(knot); -- cgit v1.2.3 From 2416766e3b71f22adb6943495458697b1b958a08 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 25 Jul 2015 21:12:04 +0200 Subject: Removes extra unnecesary code pointed by Nathan Hurst (bzr r13973.1.19) --- src/widgets/pencil-toolbar.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/widgets/pencil-toolbar.cpp b/src/widgets/pencil-toolbar.cpp index f2214bf49..4b177d3ad 100644 --- a/src/widgets/pencil-toolbar.cpp +++ b/src/widgets/pencil-toolbar.cpp @@ -247,20 +247,18 @@ static void sp_pencil_tb_tolerance_value_changed(GtkAdjustment *adj, GObject *tb g_object_set_data( tbl, "freeze", GINT_TO_POINTER(FALSE) ); SPDesktop *desktop = static_cast(g_object_get_data(tbl, "desktop")); std::vector selected = desktop->getSelection()->itemList(); - if(!selected.empty()){ - for (std::vector::iterator it(selected.begin()); it != selected.end(); ++it){ - SPLPEItem* lpeitem = dynamic_cast(*it); - if (lpeitem && lpeitem->hasPathEffect()){ - Inkscape::LivePathEffect::Effect* thisEffect = lpeitem->getPathEffectOfType(Inkscape::LivePathEffect::SIMPLIFY); - if(thisEffect){ - Inkscape::LivePathEffect::LPESimplify *lpe = dynamic_cast(thisEffect->getLPEObj()->get_lpe()); - if (lpe) { - 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; - lpe->getRepr()->setAttribute("threshold", ss.str()); - } + for (std::vector::iterator it(selected.begin()); it != selected.end(); ++it){ + SPLPEItem* lpeitem = dynamic_cast(*it); + if (lpeitem && lpeitem->hasPathEffect()){ + Inkscape::LivePathEffect::Effect* thisEffect = lpeitem->getPathEffectOfType(Inkscape::LivePathEffect::SIMPLIFY); + if(thisEffect){ + Inkscape::LivePathEffect::LPESimplify *lpe = dynamic_cast(thisEffect->getLPEObj()->get_lpe()); + if (lpe) { + 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; + lpe->getRepr()->setAttribute("threshold", ss.str()); } } } -- cgit v1.2.3 From c7a58fa3190e53b2aaf2886ef3eb4dd0c7524bcd Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 25 Jul 2015 21:52:00 +0200 Subject: =?UTF-8?q?Fix=20snapping=20of=20start=20point=20of=20path=20when?= =?UTF-8?q?=20holding=20the=20CTRL=20key=20in=20the=20B=C3=A9zier=20tool?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed bugs: - https://launchpad.net/bugs/1432354 (bzr r14257) --- src/ui/tools/pen-tool.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp index 827dbf5c3..d924d8773 100644 --- a/src/ui/tools/pen-tool.cpp +++ b/src/ui/tools/pen-tool.cpp @@ -268,6 +268,9 @@ void PenTool::_endpointSnap(Geom::Point &p, guint const state) const { if ((state & GDK_CONTROL_MASK) && !this->polylines_paraxial) { //CTRL enables angular snapping if (this->npoints > 0) { spdc_endpoint_snap_rotation(this, p, this->p[0], state); + } else { + boost::optional origin = boost::optional(); + spdc_endpoint_snap_free(this, p, origin, state); } } else { // We cannot use shift here to disable snapping because the shift-key is already used -- cgit v1.2.3 From 839c74d60e8c1dd4e2be802130905bafff934647 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Sun, 26 Jul 2015 12:53:15 +0200 Subject: Commented out tidy_operator_styled_whitespace (fixes bug 1477723). Fixed bugs: - https://launchpad.net/bugs/1477723 (bzr r14258) --- src/text-editing.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/text-editing.cpp b/src/text-editing.cpp index 050e223eb..d9cebc625 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -1805,6 +1805,14 @@ static bool tidy_operator_redundant_semi_nesting(SPObject **item, bool /*has_tex return false; } + +/* tidy_operator_styled_whitespace commented out: not only did it have bugs, + * but it did *not* preserve the rendering: spaces in different font sizes, + * for instance, have different width, so moving them out of tspans changes + * the document. cf https://bugs.launchpad.net/inkscape/+bug/1477723 +*/ + +#if 0 /** helper for tidy_operator_styled_whitespace(), finds the last string object in a paragraph which is not \a not_obj. */ static SPString* find_last_string_child_not_equal_to(SPObject *root, SPObject *not_obj) @@ -1883,6 +1891,7 @@ static bool tidy_operator_styled_whitespace(SPObject **item, bool has_text_decor delete_obj->deleteObject(); return true; } +#endif /* possible tidy operators that are not yet implemented, either because they are difficult, occur infrequently, or because I'm not sure that the @@ -1917,8 +1926,7 @@ static bool tidy_xml_tree_recursively(SPObject *root, bool has_text_decoration) tidy_operator_repeated_spans, tidy_operator_excessive_nesting, tidy_operator_redundant_double_nesting, - tidy_operator_redundant_semi_nesting, - tidy_operator_styled_whitespace + tidy_operator_redundant_semi_nesting }; bool changes = false; -- cgit v1.2.3 From 6fd1a081d166d88200a22a89928bdca9192b1491 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 27 Jul 2015 02:04:29 +0200 Subject: add flattern button to interactive simplify (bzr r14261) --- src/live_effects/lpe-simplify.cpp | 1 + src/widgets/pencil-toolbar.cpp | 50 ++++++++++++++++++++++++++++++++++++++- src/widgets/toolbox.cpp | 1 + 3 files changed, 51 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/live_effects/lpe-simplify.cpp b/src/live_effects/lpe-simplify.cpp index 265192a17..f6842a030 100644 --- a/src/live_effects/lpe-simplify.cpp +++ b/src/live_effects/lpe-simplify.cpp @@ -82,6 +82,7 @@ LPESimplify::newWidget() { // use manage here, because after deletion of Effect object, others might still be pointing to this widget. Gtk::VBox * vbox = Gtk::manage( new Gtk::VBox(Effect::newWidget()) ); + vbox->set_border_width(5); vbox->set_homogeneous(false); vbox->set_spacing(2); diff --git a/src/widgets/pencil-toolbar.cpp b/src/widgets/pencil-toolbar.cpp index 4b177d3ad..c889436b9 100644 --- a/src/widgets/pencil-toolbar.cpp +++ b/src/widgets/pencil-toolbar.cpp @@ -30,6 +30,7 @@ #include #include +#include #include "pencil-toolbar.h" #include "desktop.h" @@ -45,9 +46,11 @@ #include "ui/uxmanager.h" #include "widgets/spinbutton-events.h" #include +#include "live_effects/effect.h" #include "live_effects/lpe-simplify.h" #include "live_effects/effect-enum.h" #include "live_effects/lpeobject.h" +#include "live_effects/lpeobject-reference.h" #include "sp-lpe-item.h" #include "util/glib-list-iterators.h" @@ -233,6 +236,41 @@ static void sp_pencil_tb_defaults(GtkWidget * /*widget*/, GObject *obj) spinbutton_defocus(tbl); } +static void sp_simplify_flatten(GtkWidget * /*widget*/, GObject *obj) +{ + SPDesktop *desktop = static_cast(g_object_get_data(obj, "desktop")); + std::vector selected = desktop->getSelection()->itemList(); + for (std::vector::iterator it(selected.begin()); it != selected.end(); ++it){ + SPLPEItem* lpeitem = dynamic_cast(*it); + if (lpeitem && lpeitem->hasPathEffect()){ + PathEffectList lpelist = lpeitem->getEffectList(); + std::list::iterator i; + for (i = lpelist.begin(); i != lpelist.end(); ++i) { + LivePathEffectObject *lpeobj = (*i)->lpeobject; + if (lpeobj) { + Inkscape::LivePathEffect::Effect *lpe = lpeobj->get_lpe(); + if (dynamic_cast(lpe)) { + SPShape * shape = dynamic_cast(lpeitem); + if(shape){ + SPCurve * c = shape->getCurveBeforeLPE(); + lpe->doEffect(c); + lpeitem->setCurrentPathEffect(*i); + if (lpelist.size() > 1){ + lpeitem->removeCurrentPathEffect(true); + shape->setCurveBeforeLPE(c); + } else { + lpeitem->removeCurrentPathEffect(false); + shape->setCurve(c,0); + } + break; + } + } + } + } + } + } +} + static void sp_pencil_tb_tolerance_value_changed(GtkAdjustment *adj, GObject *tbl) { // quit if run by the attr_changed listener @@ -255,7 +293,7 @@ static void sp_pencil_tb_tolerance_value_changed(GtkAdjustment *adj, GObject *tb Inkscape::LivePathEffect::LPESimplify *lpe = dynamic_cast(thisEffect->getLPEObj()->get_lpe()); if (lpe) { double tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0); - tol = tol/(100.0*(101.0-tol)); + tol = tol/(100.0*(102.0-tol)); std::ostringstream ss; ss << tol; lpe->getRepr()->setAttribute("threshold", ss.str()); @@ -346,6 +384,16 @@ void sp_pencil_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GOb g_signal_connect_after( G_OBJECT(itact), "toggled", G_CALLBACK(freehand_simplify_lpe), holder) ; gtk_action_group_add_action( mainActions, GTK_ACTION(itact) ); } + /* LPE simplify flatten */ + { + InkAction* inky = ink_action_new( "PencilLpeSimplifyFlatten", + _("LPE simplify flatten"), + _("LPE simplify flatten"), + INKSCAPE_ICON("flatten_simplify"), + Inkscape::ICON_SIZE_SMALL_TOOLBAR ); + g_signal_connect_after( G_OBJECT(inky), "activate", G_CALLBACK(sp_simplify_flatten), holder ); + gtk_action_group_add_action( mainActions, GTK_ACTION(inky) ); + } g_signal_connect( holder, "destroy", G_CALLBACK(purge_repr_listener), holder ); diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index 62e4bcb8b..cdf39e9ef 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -399,6 +399,7 @@ static gchar const * ui_descr = " " " " " " + " " " " " " " " -- 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') 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 e252d27fc3e3f80c7f9745286992dfa06925d42e Mon Sep 17 00:00:00 2001 From: Kris De Gussem Date: Mon, 27 Jul 2015 21:31:56 +0200 Subject: + NULL check (fixes bug #1474011 : Segmentation fault in sp_filter_primitive_read_in) (bzr r14263) --- src/sp-filter-primitive.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/sp-filter-primitive.cpp b/src/sp-filter-primitive.cpp index 1f85c8193..2e57cbfd7 100644 --- a/src/sp-filter-primitive.cpp +++ b/src/sp-filter-primitive.cpp @@ -194,7 +194,9 @@ Inkscape::XML::Node* SPFilterPrimitive::write(Inkscape::XML::Document *doc, Inks int sp_filter_primitive_read_in(SPFilterPrimitive *prim, gchar const *name) { - if (!name) return Inkscape::Filters::NR_FILTER_SLOT_NOT_SET; + if (!name | !prim){ + return Inkscape::Filters::NR_FILTER_SLOT_NOT_SET; + } // TODO: are these case sensitive or not? (assumed yes) switch (name[0]) { case 'S': -- cgit v1.2.3 From a0de7d964dc4d7ae0d3c280d5f9463e63c964ae9 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Mon, 27 Jul 2015 16:32:00 -0400 Subject: \n (bzr r14266) --- src/sp-factory.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/sp-factory.cpp b/src/sp-factory.cpp index 55e673c4a..84329eaaf 100644 --- a/src/sp-factory.cpp +++ b/src/sp-factory.cpp @@ -297,7 +297,7 @@ SPObject *SPFactory::createObject(std::string const& id) else if (id.empty()) // comments {} else { - fprintf(stderr, "WARNING: unknown type: %s", id.c_str()); + fprintf(stderr, "WARNING: unknown type: %s\n", id.c_str()); } return ret; -- cgit v1.2.3 From 190eee4ce82f084b4903a0c585053c02bfde02da Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Mon, 27 Jul 2015 16:33:14 -0400 Subject: || (bzr r14267) --- src/sp-filter-primitive.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/sp-filter-primitive.cpp b/src/sp-filter-primitive.cpp index 2e57cbfd7..b18850914 100644 --- a/src/sp-filter-primitive.cpp +++ b/src/sp-filter-primitive.cpp @@ -194,7 +194,7 @@ Inkscape::XML::Node* SPFilterPrimitive::write(Inkscape::XML::Document *doc, Inks int sp_filter_primitive_read_in(SPFilterPrimitive *prim, gchar const *name) { - if (!name | !prim){ + if (!name || !prim){ return Inkscape::Filters::NR_FILTER_SLOT_NOT_SET; } // TODO: are these case sensitive or not? (assumed yes) -- cgit v1.2.3 From ac1d540f5e5dae805c051829fe10e76035238c6c Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Wed, 29 Jul 2015 22:51:14 +0200 Subject: fix for a small warning introduced in r14142 (cf ) (bzr r14268) --- src/sp-item.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 410fd9b37..4937e6c76 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -351,8 +351,8 @@ void SPItem::lowerToBottom() { SPObject * bottom=parent->firstChild(); while(dynamic_cast(bottom) && dynamic_cast(bottom->next) && bottom!=this && !is_item(*(bottom->next))) bottom=bottom->next; - if (bottom) { - Inkscape::XML::Node *ref = ( bottom ? bottom->getRepr() : NULL ); + if (bottom && bottom != this) { + Inkscape::XML::Node *ref = bottom->getRepr() ; parent->getRepr()->changeOrder(getRepr(), ref); } } -- cgit v1.2.3