diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2015-08-02 14:13:52 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2015-08-02 14:13:52 +0000 |
| commit | ccc1eda3878a76a3266ab29fc5f0d9b3b259d305 (patch) | |
| tree | 940839115a6066841e1b381e343e3244bb90519a /src | |
| parent | Fixed bugs in branch review and updated to new api (diff) | |
| parent | Fixed some typos in bsector and bspline (diff) | |
| download | inkscape-ccc1eda3878a76a3266ab29fc5f0d9b3b259d305.tar.gz inkscape-ccc1eda3878a76a3266ab29fc5f0d9b3b259d305.zip | |
update to trunk
(bzr r13879.1.21)
Diffstat (limited to 'src')
| -rw-r--r-- | src/document.cpp | 7 | ||||
| -rw-r--r-- | src/live_effects/lpe-angle_bisector.cpp | 2 | ||||
| -rw-r--r-- | src/live_effects/lpe-bspline.cpp | 1 | ||||
| -rw-r--r-- | src/ui/tools/freehand-base.cpp | 58 | ||||
| -rw-r--r-- | src/widgets/pencil-toolbar.cpp | 39 |
5 files changed, 78 insertions, 29 deletions
diff --git a/src/document.cpp b/src/document.cpp index ebf5d312f..2ea969910 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -1640,7 +1640,7 @@ void SPDocument::importDefs(SPDocument *source) prevent_id_clashes(source, this); for (std::vector<Inkscape::XML::Node const *>::iterator defs = defsNodes.begin(); defs != defsNodes.end(); ++defs) { - importDefsNode(source, const_cast<Inkscape::XML::Node *>(*defs), target_defs); + importDefsNode(source, const_cast<Inkscape::XML::Node *>(*defs), target_defs); } } @@ -1688,11 +1688,10 @@ void SPDocument::importDefsNode(SPDocument *source, Inkscape::XML::Node *defs, I /* First pass: remove duplicates in clipboard of definitions in document */ for (Inkscape::XML::Node *def = defs->firstChild() ; def ; def = def->next()) { - + if(def->type() != Inkscape::XML::ELEMENT_NODE)continue; /* If this clipboard has been pasted into one document, and is now being pasted into another, or pasted again into the same, it will already have been processed. If we detect that then skip the rest of this pass. */ - Glib::ustring defid = def->attribute("id"); if( defid.find( DuplicateDefString ) != Glib::ustring::npos )break; @@ -1722,6 +1721,7 @@ void SPDocument::importDefsNode(SPDocument *source, Inkscape::XML::Node *defs, I /* Second pass: remove duplicates in clipboard of earlier definitions in clipboard */ for (Inkscape::XML::Node *def = defs->firstChild() ; def ; def = def->next()) { + if(def->type() != Inkscape::XML::ELEMENT_NODE)continue; Glib::ustring defid = def->attribute("id"); if( defid.find( DuplicateDefString ) != Glib::ustring::npos )continue; // this one already handled SPObject *src = source->getObjectByRepr(def); @@ -1749,6 +1749,7 @@ void SPDocument::importDefsNode(SPDocument *source, Inkscape::XML::Node *defs, I /* Final pass: copy over those parts which are not duplicates */ for (Inkscape::XML::Node *def = defs->firstChild() ; def ; def = def->next()) { + if(def->type() != Inkscape::XML::ELEMENT_NODE)continue; /* Ignore duplicate defs marked in the first pass */ Glib::ustring defid = def->attribute("id"); diff --git a/src/live_effects/lpe-angle_bisector.cpp b/src/live_effects/lpe-angle_bisector.cpp index 95a81c763..900d29e3a 100644 --- a/src/live_effects/lpe-angle_bisector.cpp +++ b/src/live_effects/lpe-angle_bisector.cpp @@ -38,7 +38,7 @@ public: virtual Geom::Point knot_get() const; }; -} // namespace TtC +} // namespace AB LPEAngleBisector::LPEAngleBisector(LivePathEffectObject *lpeobject) : Effect(lpeobject), diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index c2a2d080e..6575700c7 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -245,6 +245,7 @@ LPEBSpline::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom:: { hp_vec.push_back(hp); } + Gtk::Widget *LPEBSpline::newWidget() { // use manage here, because after deletion of Effect object, others might diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index fa45d8dbb..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" @@ -289,7 +290,7 @@ static void spdc_apply_simplify(std::string threshold, FreehandBase *dc, SPItem Effect::createAndApply(SIMPLIFY, dc->desktop->doc(), item); Effect* lpe = SP_LPE_ITEM(item)->getCurrentLPE(); - // write powerstroke parameters: + // write simplify parameters: lpe->getRepr()->setAttribute("steps", "1"); lpe->getRepr()->setAttribute("threshold", threshold); lpe->getRepr()->setAttribute("smooth_angles", "360"); @@ -314,20 +315,22 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, std::ostringstream ss; ss << tol; spdc_apply_simplify(ss.str(), dc, item); + sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); } if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1) { Effect::createAndApply(SPIRO, dc->desktop->doc(), item); } - //add the bspline node in the waiting effects + if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2) { Effect::createAndApply(BSPLINE, dc->desktop->doc(), item); } + SPShape *sp_shape = dynamic_cast<SPShape *>(item); + if (sp_shape) { + curve = sp_shape->getCurve(); + } //Store the clipboard path to apply in the future without the use of clipboard - static Geom::PathVector previous_shape_pathv; - - shapeType shape = (shapeType)prefs->getInt(tool_name(dc) + "/shape", 0); bool shape_applied = false; @@ -391,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: @@ -411,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; } @@ -442,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; } diff --git a/src/widgets/pencil-toolbar.cpp b/src/widgets/pencil-toolbar.cpp index aef9b4560..17c1d341d 100644 --- a/src/widgets/pencil-toolbar.cpp +++ b/src/widgets/pencil-toolbar.cpp @@ -46,8 +46,10 @@ #include "ui/uxmanager.h" #include "widgets/spinbutton-events.h" #include <selection.h> +#include "display/curve.h" #include "live_effects/effect.h" #include "live_effects/lpe-simplify.h" +#include "live_effects/lpe-powerstroke.h" #include "live_effects/effect-enum.h" #include "live_effects/lpeobject.h" #include "live_effects/lpeobject-reference.h" @@ -289,15 +291,42 @@ static void sp_pencil_tb_tolerance_value_changed(GtkAdjustment *adj, GObject *tb for (std::vector<SPItem *>::iterator it(selected.begin()); it != selected.end(); ++it){ SPLPEItem* lpeitem = dynamic_cast<SPLPEItem*>(*it); if (lpeitem && lpeitem->hasPathEffect()){ - Inkscape::LivePathEffect::Effect* thisEffect = lpeitem->getPathEffectOfType(Inkscape::LivePathEffect::SIMPLIFY); - if(thisEffect){ - Inkscape::LivePathEffect::LPESimplify *lpe = dynamic_cast<Inkscape::LivePathEffect::LPESimplify*>(thisEffect->getLPEObj()->get_lpe()); - if (lpe) { + Inkscape::LivePathEffect::Effect* simplify = lpeitem->getPathEffectOfType(Inkscape::LivePathEffect::SIMPLIFY); + if(simplify){ + Inkscape::LivePathEffect::LPESimplify *lpe_simplify = dynamic_cast<Inkscape::LivePathEffect::LPESimplify*>(simplify->getLPEObj()->get_lpe()); + if (lpe_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; - lpe->getRepr()->setAttribute("threshold", ss.str()); + Inkscape::LivePathEffect::Effect* powerstroke = lpeitem->getPathEffectOfType(Inkscape::LivePathEffect::POWERSTROKE); + bool simplified = false; + if(powerstroke){ + Inkscape::LivePathEffect::LPEPowerStroke *lpe_powerstroke = dynamic_cast<Inkscape::LivePathEffect::LPEPowerStroke*>(powerstroke->getLPEObj()->get_lpe()); + if(lpe_powerstroke){ + lpe_powerstroke->getRepr()->setAttribute("is_visible", "false"); + sp_lpe_item_update_patheffect(lpeitem, false, false); + SPShape *sp_shape = dynamic_cast<SPShape *>(lpeitem); + if (sp_shape) { + guint previous_curve_length = sp_shape->getCurve()->get_segment_count(); + lpe_simplify->getRepr()->setAttribute("threshold", ss.str()); + sp_lpe_item_update_patheffect(lpeitem, false, false); + simplified = true; + guint curve_length = sp_shape->getCurve()->get_segment_count(); + std::vector<Geom::Point> ts = lpe_powerstroke->offset_points.data(); + double factor = (double)curve_length/ (double)previous_curve_length; + for (size_t i = 0; i < ts.size(); i++) { + ts[i][Geom::X] = ts[i][Geom::X] * factor; + } + lpe_powerstroke->offset_points.param_setValue(ts); + } + lpe_powerstroke->getRepr()->setAttribute("is_visible", "true"); + sp_lpe_item_update_patheffect(lpeitem, false, false); + } + } + if(!simplified){ + lpe_simplify->getRepr()->setAttribute("threshold", ss.str()); + } } } } |
