diff --git a/src/draw-context.cpp b/src/draw-context.cpp
index ce6ccc0e48effd5798b81b2a0662208b31a75bce..d54ccc7788dc1fb092cb41cccaf69c628cb71d2f 100644 (file)
--- a/src/draw-context.cpp
+++ b/src/draw-context.cpp
#include "snap.h"
#include "sp-path.h"
#include "sp-namedview.h"
+#include "live_effects/lpe-patternalongpath.h"
static void sp_draw_context_class_init(SPDrawContextClass *klass);
static void sp_draw_context_init(SPDrawContext *dc);
return ret;
}
+static void
+spdc_paste_curve_as_param_path(const SPCurve *c, SPDrawContext *dc, SPItem *item)
+{
+ using namespace Inkscape::LivePathEffect;
+
+ // TODO: Don't paste path if nothing is on the clipboard
+
+ Effect::createAndApply(Inkscape::LivePathEffect::PATTERN_ALONG_PATH, dc->desktop->doc(), item);
+ Effect* lpe = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item));
+ gchar *svgd = sp_svg_write_path(c->get_pathvector());
+ static_cast<LPEPatternAlongPath*>(lpe)->pattern.paste_param_path(svgd);
+}
+
/*
* If we have an item and a waiting LPE, apply the effect to the item
* (spiro spline mode is treated separately)
using namespace Inkscape::LivePathEffect;
if (item) {
+ int shape = prefs_get_int_attribute("tools.freehand", "shape", 0);
+
+ switch (shape) {
+ case 0:
+ break;
+ case 1:
+ {
+ Effect::createAndApply(PATTERN_ALONG_PATH, dc->desktop->doc(), item);
+ Effect* lpe = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item));
+ static_cast<LPEPatternAlongPath*>(lpe)->pattern.on_paste_button_click();
+ return;
+ }
+ case 2:
+ {
+ // TODO: this is only for illustration (we create a "decrescendo"-shaped path
+ // manually; eventually we should read the path from a separate file)
+ SPCurve *c = new SPCurve();
+ c->moveto(0,0);
+ c->lineto(0,10);
+ c->lineto(200,5);
+ c->closepath();
+ spdc_paste_curve_as_param_path(c, dc, item);
+ c->unref();
+ return;
+ }
+ default:
+ break;
+ }
+
if (prefs_get_int_attribute("tools.freehand", "spiro-spline-mode", 0)) {
Effect::createAndApply(SPIRO, dc->desktop->doc(), item);
return;
static void
spdc_selection_changed(Inkscape::Selection *sel, SPDrawContext *dc)
{
- // note: in draw context, selection_changed() is only called when a new item was created;
- // otherwise the following function call would yield wrong results
+ // note: in draw context, selection_changed() is only called with a valid item as argument when
+ // a new item was created; otherwise the following function call would yield wrong results
spdc_check_for_and_apply_waiting_LPE(dc, sel->singleItem());
if (dc->attach) {