From 632414c7cdd5f8992c6d6439d25128b82e93d499 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Mon, 2 Sep 2013 15:51:04 -0400 Subject: Fix bug that added transforms to new objects. (bzr r12475.1.11) --- src/sp-spiral.cpp | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'src/sp-spiral.cpp') diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp index 43e552d68..6f3a63f6a 100644 --- a/src/sp-spiral.cpp +++ b/src/sp-spiral.cpp @@ -35,6 +35,7 @@ static void sp_spiral_update (SPObject *object, SPCtx *ctx, guint flags); static gchar * sp_spiral_description (SPItem * item); static void sp_spiral_snappoints(SPItem const *item, std::vector &p, Inkscape::SnapPreferences const *snapprefs); +static Geom::Affine sp_spiral_set_transform(SPItem *item, Geom::Affine const &xform); static void sp_spiral_set_shape (SPShape *shape); static void sp_spiral_update_patheffect (SPLPEItem *lpeitem, bool write); @@ -60,6 +61,7 @@ static void sp_spiral_class_init(SPSpiralClass *klass) item_class->description = sp_spiral_description; item_class->snappoints = sp_spiral_snappoints; + item_class->set_transform = sp_spiral_set_transform; lpe_item_class->update_patheffect = sp_spiral_update_patheffect; @@ -492,6 +494,63 @@ static void sp_spiral_snappoints(SPItem const *item, std::vectorcx, spiral->cy) * xform ); + + /* This function takes care of translation and scaling, we return whatever parts we can't + handle. */ + Geom::Affine ret(Geom::Affine(xform).withoutTranslation()); + gdouble const s = hypot(ret[0], ret[1]); + if (s > 1e-9) { + ret[0] /= s; + ret[1] /= s; + ret[2] /= s; + ret[3] /= s; + } else { + ret[0] = 1.0; + ret[1] = 0.0; + ret[2] = 0.0; + ret[3] = 1.0; + } + + spiral->rad *= s; + + /* Find start in item coords */ + pos = pos * ret.inverse(); + spiral->cx = pos[Geom::X]; + spiral->cy = pos[Geom::Y]; + + sp_spiral_set_shape(spiral); + + // Adjust stroke width + item->adjust_stroke(s); + + // Adjust pattern fill + item->adjust_pattern(xform * ret.inverse()); + + // Adjust gradient fill + item->adjust_gradient(xform * ret.inverse()); + + item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); + + return ret; +} + /** * Return one of the points on the spiral. * -- cgit v1.2.3 From eb3598e7e27619c759ef33bb9ec4ffb8898523de Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Fri, 20 Sep 2013 00:45:16 -0400 Subject: Refactor status-bar text for multiple items, was very broken Fixed bugs: - https://launchpad.net/bugs/1199192 (bzr r12550) --- src/sp-spiral.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/sp-spiral.cpp') diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp index 8d2954c6e..ab7cc5c9d 100644 --- a/src/sp-spiral.cpp +++ b/src/sp-spiral.cpp @@ -227,12 +227,14 @@ void SPSpiral::update_patheffect(bool write) { shape->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } -gchar* SPSpiral::description() { - SPSpiral* item = this; +const char* SPSpiral::display_name() { + return _("Spiral"); +} - // TRANSLATORS: since turn count isn't an integer, please adjust the +gchar* SPSpiral::description() { + // TRANSLATORS: since turn count isn't an integer, please adjust the // string as needed to deal with an localized plural forms. - return g_strdup_printf (_("Spiral with %3f turns"), SP_SPIRAL(item)->revo); + return g_strdup_printf (_("with %3f turns"), SP_SPIRAL(this)->revo); } /** -- cgit v1.2.3