summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2013-09-25 00:14:24 +0000
committerJabiertxof <jtx@jtx.marker.es>2013-09-25 00:14:24 +0000
commit522cc95fa0ffa9483134df80e4b85e9c273c967e (patch)
treeabee9d0978d15898b98afcb2e6e65fb9549c1489 /src
parentFix my email address through codebase (diff)
downloadinkscape-522cc95fa0ffa9483134df80e4b85e9c273c967e.tar.gz
inkscape-522cc95fa0ffa9483134df80e4b85e9c273c967e.zip
First attemp for
(bzr r12588.1.1)
Diffstat (limited to 'src')
-rw-r--r--src/draw-context.cpp105
-rw-r--r--src/live_effects/lpe-bendpath.h2
-rw-r--r--src/widgets/pencil-toolbar.cpp2
3 files changed, 105 insertions, 4 deletions
diff --git a/src/draw-context.cpp b/src/draw-context.cpp
index 09366526a..8b0237c0f 100644
--- a/src/draw-context.cpp
+++ b/src/draw-context.cpp
@@ -20,6 +20,7 @@
# include "config.h"
#endif
+#include "live_effects/lpe-bendpath.h"
#include "live_effects/lpe-patternalongpath.h"
#include "display/canvas-bpath.h"
#include "xml/repr.h"
@@ -45,7 +46,7 @@
#include "style.h"
#include "ui/control-manager.h"
#include "draw-context.h"
-
+#include "ui/clipboard.h"
#include <gdk/gdkkeysyms.h>
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<LPEPatternAlongPath*>(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<GSList *>(selection->itemList());
+ SPObject *obj = reinterpret_cast<SPObject *>(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<LPEBendPath*>(lpe)->bend_path.paste_param_path(svgd);
+ static_cast<LPEBendPath*>(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<Geom::Point> 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<Geom::Point> 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<LPEBendPath*>(lpe)->bend_path.paste_param_path(svgd);
+ static_cast<LPEBendPath*>(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;
}