diff options
| author | Jabier Arraiza <jabier.arraiza@marker.es> | 2017-12-07 20:47:44 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2017-12-07 20:47:44 +0000 |
| commit | 075a88fc7edbec8682bcd672de325ec1bedf129f (patch) | |
| tree | 33d64f8ddc366a96e2c480b672224d44fc0e6355 /src/ui/tools/freehand-base.cpp | |
| parent | Update to trunk (diff) | |
| parent | Fix bug 1733422 - Bezier and pencil tool don't work form: from clipboard (diff) | |
| download | inkscape-075a88fc7edbec8682bcd672de325ec1bedf129f.tar.gz inkscape-075a88fc7edbec8682bcd672de325ec1bedf129f.zip | |
Mege trunk into powerpencilII
Diffstat (limited to 'src/ui/tools/freehand-base.cpp')
| -rw-r--r-- | src/ui/tools/freehand-base.cpp | 76 |
1 files changed, 45 insertions, 31 deletions
diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp index 89d9074ba..b72eb84db 100644 --- a/src/ui/tools/freehand-base.cpp +++ b/src/ui/tools/freehand-base.cpp @@ -36,6 +36,7 @@ #include "ui/tools/lpe-tool.h" #include "selection-chemistry.h" #include "sp-item-group.h" +#include "sp-rect.h" #include "live_effects/lpe-powerstroke.h" #include "style.h" #include "ui/control-manager.h" @@ -85,7 +86,7 @@ FreehandBase::FreehandBase(gchar const *const *cursor_shape) , green_anchor(NULL) , green_closed(false) , white_item(NULL) - , overwrite_curve(NULL) + , sa_overwrited(NULL) , sa(NULL) , ea(NULL) , waiting_LPE_type(Inkscape::LivePathEffect::INVALID_LPE) @@ -144,7 +145,7 @@ void FreehandBase::setup() { this->green_closed = FALSE; // Create start anchor alternative curve - this->overwrite_curve = new SPCurve(); + this->sa_overwrited = new SPCurve(); this->attach = TRUE; spdc_attach_selection(this, this->selection); @@ -464,6 +465,8 @@ 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)){ SPItem * pasted_clipboard = dc->selection->singleItem(); + dc->selection->toCurves(); + pasted_clipboard = dc->selection->singleItem(); if(pasted_clipboard){ Inkscape::XML::Node *pasted_clipboard_root = pasted_clipboard->getRepr(); Inkscape::XML::Node *path = sp_repr_lookup_name(pasted_clipboard_root, "svg:path", -1); // unlimited search depth @@ -492,6 +495,19 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, { gchar const *svgd = item->getRepr()->attribute("d"); if(bend_item && (SP_IS_SHAPE(bend_item) || SP_IS_GROUP(bend_item))){ + // If item is a SPRect, convert it to path first: + if ( dynamic_cast<SPRect *>(bend_item) ) { + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + if (desktop) { + Inkscape::Selection *sel = desktop->getSelection(); + if ( sel && !sel->isEmpty() ) { + sel->clear(); + sel->add(bend_item); + sel->toCurves(); + bend_item = sel->singleItem(); + } + } + } bend_item->moveTo(item,false); bend_item->transform.setTranslation(Geom::Point()); spdc_apply_bend_shape(svgd, dc, bend_item); @@ -597,6 +613,9 @@ static void spdc_selection_modified(Inkscape::Selection *sel, guint /*flags*/, F static void spdc_attach_selection(FreehandBase *dc, Inkscape::Selection */*sel*/) { + if (SP_IS_PENCIL_CONTEXT(dc) && dc->sa && dc->input_has_pressure) { + return; + } // We reset white and forget white/start/end anchors spdc_reset_white(dc); dc->sa = NULL; @@ -742,38 +761,21 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) { // We hit bot start and end of single curve, closing paths dc->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Closing path.")); - if (dc->sa->start && !(dc->sa->curve->is_closed()) ) { - c = reverse_then_unref(c); - } - if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || - prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ - dc->overwrite_curve->append_continuous(c, 0.0625); - c->unref(); - dc->overwrite_curve->closepath_current(); - if(dc->sa){ - dc->white_curves.erase(std::find(dc->white_curves.begin(),dc->white_curves.end(), dc->sa->curve)); - dc->white_curves.push_back(dc->overwrite_curve); - } - }else{ - dc->sa->curve->append_continuous(c, 0.0625); - c->unref(); - dc->sa->curve->closepath_current(); + dc->sa_overwrited->append_continuous(c, 0.0625); + c->unref(); + dc->sa_overwrited->closepath_current(); + if(dc->sa){ + dc->white_curves.erase(std::find(dc->white_curves.begin(),dc->white_curves.end(), dc->sa->curve)); + dc->white_curves.push_back(dc->sa_overwrited); } + spdc_flush_white(dc, NULL); return; } - // Step C - test start if (dc->sa) { - SPCurve *s = dc->sa->curve; - dc->white_curves.erase(std::find(dc->white_curves.begin(),dc->white_curves.end(), s)); - if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 || - prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){ - s = dc->overwrite_curve; - } - if (dc->sa->start) { - s = reverse_then_unref(s); - } + dc->white_curves.erase(std::find(dc->white_curves.begin(),dc->white_curves.end(), dc->sa->curve)); + SPCurve *s = dc->sa_overwrited; s->append_continuous(c, 0.0625); c->unref(); c = s; @@ -805,7 +807,6 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed) c->append_continuous(e, 0.0625); e->unref(); } - if (forceclosed) { dc->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Path is closed.")); @@ -880,8 +881,17 @@ static void spdc_flush_white(FreehandBase *dc, SPCurve *gc) if(previous_shape_type == BEND_CLIPBOARD){ repr->parent()->removeChild(repr); } + } else if (SP_IS_PENCIL_CONTEXT(dc)) { + if (dc->input_has_pressure) { + spdc_check_for_and_apply_waiting_LPE(dc, dc->white_item, c, false); +// Inkscape::Preferences *prefs = Inkscape::Preferences::get(); +// shapeType shape = (shapeType)prefs->getInt(tool_name(dc) + "/shape", 0); +// if (shape == NONE) { +// std::vector<Geom::Point> points; +// spdc_apply_powerstroke_shape(points, dc, dc->white_item); +// } + } } - DocumentUndo::done(doc, SP_IS_PEN_CONTEXT(dc)? SP_VERB_CONTEXT_PEN : SP_VERB_CONTEXT_PENCIL, _("Draw path")); @@ -950,7 +960,11 @@ static void spdc_free_colors(FreehandBase *dc) if (dc->blue_curve) { dc->blue_curve = dc->blue_curve->unref(); } - + + // Overwrite start anchor curve + if (dc->sa_overwrited) { + dc->sa_overwrited = dc->sa_overwrited->unref(); + } // Green for (auto i : dc->green_bpaths) sp_canvas_item_destroy(i); |
