From 845d677a3bd7a39320e32b6c53fa70963a92ba87 Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Wed, 12 Jun 2019 20:36:26 +0300 Subject: Refactoring: replace funcs with methods. I hereby disclaim any implicit or explicit ownership of my changes in this changeset, and put them under a multiple licence consisting of your choice of one of more of: - The CC0 / Public Domain - https://creativecommons.org/choose/zero/ . - The MIT / Expat license - https://en.wikipedia.org/wiki/MIT_License - The default licence of your project - The https://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License - version 2.1 or higher - The https://en.wikipedia.org/wiki/GNU_General_Public_License - version 2 or higher - Any licence in the 2018-Aug-27 popular licenses list of https://opensource.org/licenses - The https://en.wikipedia.org/wiki/Apache_License version 2.0 or later - The https://en.wikipedia.org/wiki/Artistic_License version 2.0 or later - The https://en.wikipedia.org/wiki/ISC_license - The https://opensource.org/licenses/BSD-2-Clause Crediting me will be nice, but not mandatory, and you can change the licence of the project without needing my permission. --- src/object/sp-item.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'src/object/sp-item.cpp') diff --git a/src/object/sp-item.cpp b/src/object/sp-item.cpp index ee54c8ada..7d8ab4b50 100644 --- a/src/object/sp-item.cpp +++ b/src/object/sp-item.cpp @@ -1733,6 +1733,42 @@ void SPItem::rotate_rel(Geom::Rotate const &rotation) updateRepr(); } } + +void SPItem::scale_rel(Geom::Scale const &scale) +{ + Geom::OptRect bbox = desktopVisualBounds(); + if (bbox) { + Geom::Translate const s(bbox->midpoint()); // use getCenter? + set_i2d_affine(i2dt_affine() * s.inverse() * scale * s); + doWriteTransform(transform); + } +} + +void SPItem::skew_rel(double skewX, double skewY) +{ + Geom::Point center = getCenter(); + Geom::Translate const s(getCenter()); + + Geom::Affine const skew(1, skewY, skewX, 1, 0, 0); + Geom::Affine affine = Geom::Affine(s).inverse() * skew * Geom::Affine(s); + + set_i2d_affine(i2dt_affine() * affine); + doWriteTransform(transform); + + // Restore the center position (it's changed because the bbox center changed) + if (isCenterSet()) { + setCenter(center * affine); + updateRepr(); + } +} + +void SPItem::move_rel( Geom::Translate const &tr) +{ + set_i2d_affine(i2dt_affine() * tr); + + doWriteTransform(transform); +} + /* Local Variables: mode:c++ -- cgit v1.2.3