summaryrefslogtreecommitdiffstats
path: root/src/ui/tools/freehand-base.cpp
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-08-02 11:29:25 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-08-02 11:29:25 +0000
commitd141eb2df3805c3049b863c1bf8429bed9d0763d (patch)
treea757cf20a6015e721f59c238a7095e6c4e06baa0 /src/ui/tools/freehand-base.cpp
parentUpdate simplify interactive to handle trinagle out powerstrokes, also fix it ... (diff)
downloadinkscape-d141eb2df3805c3049b863c1bf8429bed9d0763d.tar.gz
inkscape-d141eb2df3805c3049b863c1bf8429bed9d0763d.zip
Fixed some typos in bsector and bspline
In freehand base fix a crash un bend path if no clipboard. Also rewrite retrive clipboard to get it at correct document size (bzr r14272)
Diffstat (limited to 'src/ui/tools/freehand-base.cpp')
-rw-r--r--src/ui/tools/freehand-base.cpp46
1 files changed, 31 insertions, 15 deletions
diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp
index f4ad284c7..bdce1cd46 100644
--- a/src/ui/tools/freehand-base.cpp
+++ b/src/ui/tools/freehand-base.cpp
@@ -46,6 +46,7 @@
#include "live_effects/lpe-powerstroke.h"
#include "style.h"
#include "ui/control-manager.h"
+#include "util/units.h"
// clipboard support
#include "ui/clipboard.h"
#include "ui/tools/freehand-base.h"
@@ -393,15 +394,24 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item,
}
case CLIPBOARD:
{
- // take shape from clipboard; TODO: catch the case where clipboard is empty
- Effect::createAndApply(PATTERN_ALONG_PATH, dc->desktop->doc(), item);
- Effect* lpe = SP_LPE_ITEM(item)->getCurrentLPE();
- static_cast<LPEPatternAlongPath*>(lpe)->pattern.on_paste_button_click();
+ // take shape from clipboard;
Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
Glib::ustring svgd = cm->getPathParameter(SP_ACTIVE_DESKTOP);
- previous_shape_pathv = sp_svg_read_pathv(svgd.data());
-
- shape_applied = true;
+ if(svgd != ""){
+ previous_shape_pathv = sp_svg_read_pathv(svgd.data());
+ Inkscape::XML::Node *nv_repr = SP_ACTIVE_DESKTOP->getNamedView()->getRepr();
+ if (nv_repr->attribute("inkscape:document-units")){
+ double scale_units = Inkscape::Util::Quantity::convert(1, "px", nv_repr->attribute("inkscape:document-units"));
+ if (!Geom::are_near(scale_units, 1.0, Geom::EPSILON)) {
+ previous_shape_pathv *= Geom::Scale(scale_units);
+ }
+ }
+ SPCurve const *c = new SPCurve(previous_shape_pathv);
+ spdc_paste_curve_as_freehand_shape(c, dc, item);
+ shape_applied = true;
+ } else {
+ shape = NONE;
+ }
break;
}
case BEND_CLIPBOARD:
@@ -413,10 +423,14 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item,
path *= item->i2doc_affine().inverse();
svgd = sp_svg_write_path( path );
bend_item = dc->selection->singleItem();
- bend_item->moveTo(item,false);
- spdc_apply_bend_shape(svgd, dc, bend_item);
- bend_item->transform = Geom::Affine(1,0,0,1,0,0);
- dc->selection->add(SP_OBJECT(bend_item));
+ if(bend_item){
+ bend_item->moveTo(item,false);
+ spdc_apply_bend_shape(svgd, dc, bend_item);
+ bend_item->transform = Geom::Affine(1,0,0,1,0,0);
+ dc->selection->add(SP_OBJECT(bend_item));
+ } else {
+ shape = NONE;
+ }
} else {
shape = NONE;
}
@@ -444,10 +458,12 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item,
sp_selection_duplicate(dc->desktop);
dc->selection->remove(SP_OBJECT(bend_item));
bend_item = dc->selection->singleItem();
- bend_item->moveTo(item,false);
- spdc_apply_bend_shape(svgd, dc, bend_item);
- bend_item->transform = Geom::Affine(1,0,0,1,0,0);
- dc->selection->add(SP_OBJECT(bend_item));
+ if(bend_item){
+ bend_item->moveTo(item,false);
+ spdc_apply_bend_shape(svgd, dc, bend_item);
+ bend_item->transform = Geom::Affine(1,0,0,1,0,0);
+ dc->selection->add(SP_OBJECT(bend_item));
+ }
}
shape = BEND_CLIPBOARD;
}