From 619f8b5d9173f2bcc9d9aefccee832d686724e79 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Mon, 17 Oct 2016 15:04:09 +0200 Subject: Add option to scale mesh to fit in bounding box. (bzr r15173) --- src/ui/tools/mesh-tool.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++++++ src/ui/tools/mesh-tool.h | 1 + 2 files changed, 67 insertions(+) (limited to 'src/ui') diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 33cdc3bda..cea508782 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -52,6 +52,7 @@ #include "ui/tools/mesh-tool.h" #include "sp-mesh-gradient.h" #include "display/sp-ctrlcurve.h" +#include "display/curve.h" using Inkscape::DocumentUndo; @@ -430,6 +431,71 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation ) } +/** + * Scale mesh to just fit into bbox of selected items. + */ +void +sp_mesh_context_fit_mesh_in_bbox (MeshTool *rc) +{ + +#ifdef DEBUG_MESH + std::cout << "sp_mesh_context_fit_mesh_in_bbox: entrance: Entrance"<< std::endl; +#endif + + SPDesktop *desktop = SP_EVENT_CONTEXT (rc)->desktop; + + Inkscape::Selection *selection = desktop->getSelection(); + if (selection == NULL) { + return; + } + + bool changed = false; + auto itemlist = selection->items(); + for (auto i=itemlist.begin(); i!=itemlist.end(); ++i) { + + SPItem *item = *i; + SPStyle *style = item->style; + + if (style && (style->fill.isPaintserver())) { + SPPaintServer *server = item->style->getFillPaintServer(); + if ( SP_IS_MESHGRADIENT(server) ) { + + SPMeshGradient *gradient = SP_MESHGRADIENT(server); + SPCurve * outline = gradient->array.outline_path(); + Geom::OptRect mesh_bbox = outline->get_pathvector().boundsExact(); + outline->unref(); + Geom::OptRect item_bbox = item->geometricBounds(); + + if ((*mesh_bbox).width() == 0) { + continue; + } + if ((*mesh_bbox).height() == 0) { + continue; + } + double scale_x = (*item_bbox).width() /(*mesh_bbox).width() ; + double scale_y = (*item_bbox).height()/(*mesh_bbox).height(); + + Geom::Translate t1(-(*mesh_bbox).min()); + Geom::Scale scale(scale_x,scale_y); + Geom::Translate t2((*item_bbox).min()); + Geom::Affine transform = t1 * scale * t2; + if (!transform.isIdentity() ) { + gradient->array.transform(transform); + gradient->array.write( gradient ); + gradient->requestModified(SP_OBJECT_MODIFIED_FLAG); + changed = true; + } + } + } + + } + if (changed) { + DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_MESH, + _("Fit mesh inside bounding box.")); + } +} + + /** Handles all keyboard and mouse input for meshs. Note: node/handle events are take care of elsewhere. diff --git a/src/ui/tools/mesh-tool.h b/src/ui/tools/mesh-tool.h index 91b35b3af..f142bfd9c 100644 --- a/src/ui/tools/mesh-tool.h +++ b/src/ui/tools/mesh-tool.h @@ -59,6 +59,7 @@ private: void sp_mesh_context_select_next(ToolBase *event_context); void sp_mesh_context_select_prev(ToolBase *event_context); void sp_mesh_context_corner_operation(MeshTool *event_context, MeshCornerOperation operation ); +void sp_mesh_context_fit_mesh_in_bbox(MeshTool *event_context); } } -- cgit v1.2.3 From 5a528acc28fee968aee4d79373625ed7d0fa553d Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 18 Oct 2016 19:07:20 +0200 Subject: Use geometric bounding box for fill, visual for stroke in creating mesh. (bzr r15175) --- src/ui/tools/mesh-tool.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index cea508782..c6983b94a 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -1036,7 +1036,8 @@ static void sp_mesh_new_default(MeshTool &rc) { // Get corresponding object SPMeshGradient *mg = static_cast(document->getObjectByRepr(repr)); - mg->array.create(mg, *i, (*i)->visualBounds()); + mg->array.create(mg, *i, (fill_or_stroke == Inkscape::FOR_FILL) ? + (*i)->geometricBounds() : (*i)->visualBounds()); bool isText = SP_IS_TEXT(*i); sp_style_set_property_url (*i, ((fill_or_stroke == Inkscape::FOR_FILL) ? "fill":"stroke"), @@ -1045,6 +1046,11 @@ static void sp_mesh_new_default(MeshTool &rc) { (*i)->requestModified(SP_OBJECT_MODIFIED_FLAG|SP_OBJECT_STYLE_MODIFIED_FLAG); } + if (css) { + sp_repr_css_attr_unref(css); + css = 0; + } + DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_MESH, _("Create mesh")); // status text; we do not track coords because this branch is run once, not all the time -- cgit v1.2.3 From 1277a92d4c1cd93e9a172718f557a8cd1a855625 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Wed, 19 Oct 2016 00:24:26 +0200 Subject: update author list in about dialog from AUTHORS file (bzr r15176) --- src/ui/dialog/aboutbox.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/ui') diff --git a/src/ui/dialog/aboutbox.cpp b/src/ui/dialog/aboutbox.cpp index 04cf9d02a..846f00d8a 100644 --- a/src/ui/dialog/aboutbox.cpp +++ b/src/ui/dialog/aboutbox.cpp @@ -256,6 +256,7 @@ void AboutBox::initStrings() { "Joshua L. Blocher\n" "Hanno Böck\n" "Tomasz Boczkowski\n" +"Adrian Boguszewski\n" "Henrik Bohre\n" "Boldewyn\n" "Daniel Borgmann\n" @@ -265,6 +266,7 @@ void AboutBox::initStrings() { "Christopher Brown\n" "Marcus Brubaker\n" "Luca Bruno\n" +"Brynn (brynn@inkscapecommunity.com)\n" "Nicu Buculei\n" "Bulia Byak\n" "Pierre Caclin\n" @@ -289,10 +291,12 @@ void AboutBox::initStrings() { "Nicolas Dufour\n" "Tim Dwyer\n" "Maxim V. Dziumanenko\n" +"Moritz Eberl\n" "Johan Engelen\n" "Miklos Erdelyi\n" "Ulf Erikson\n" "Noé Falzon\n" +"Sebastian Faubel\n" "Frank Felfe\n" "Andrew Fitzsimon\n" "Edward Flick\n" @@ -324,6 +328,7 @@ void AboutBox::initStrings() { "Jean-Olivier Irisson\n" "Bob Jamison\n" "Ted Janeczko\n" +"Marc Jeanmougin\n" "jEsuSdA\n" "Fernando Lucchesi Bastos Jurema\n" "Lauris Kaplinski\n" @@ -389,6 +394,7 @@ void AboutBox::initStrings() { "Shivaken\n" "Michael Sloan\n" "John Smith\n" +"Sandra Snan\n" "Boštjan Špetič\n" "Aaron Spike\n" "Kaushik Sridharan\n" @@ -413,7 +419,8 @@ void AboutBox::initStrings() { "Gellule Xg\n" "Daniel Yacob\n" "Masatake Yamato\n" -"David Yip"; +"David Yip" +; //############################## //# T R A N S L A T O R S -- cgit v1.2.3