summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorShlomi Fish <shlomif@shlomifish.org>2019-06-12 16:01:28 +0000
committerShlomi Fish <shlomif@shlomifish.org>2019-06-12 16:01:28 +0000
commitf724d2d99d2195dea3049bfe580b6b6f5386c7b6 (patch)
tree7b7ae06ef2f6f16436790e5da14402ec34e1c552 /src
parentUpdate comments to match reality. (diff)
downloadinkscape-f724d2d99d2195dea3049bfe580b6b6f5386c7b6.tar.gz
inkscape-f724d2d99d2195dea3049bfe580b6b6f5386c7b6.zip
Refactor: convert rotate_rel() to a method.
Diffstat (limited to 'src')
-rw-r--r--src/object/sp-item-transform.cpp18
-rw-r--r--src/object/sp-item-transform.h1
-rw-r--r--src/object/sp-item.cpp17
-rw-r--r--src/object/sp-item.h1
-rwxr-xr-xsrc/selection-chemistry.cpp2
-rw-r--r--src/ui/dialog/transformation.cpp2
-rw-r--r--src/ui/tools/tweak-tool.cpp2
7 files changed, 21 insertions, 22 deletions
diff --git a/src/object/sp-item-transform.cpp b/src/object/sp-item-transform.cpp
index 2806931c0..4fbe0bcc5 100644
--- a/src/object/sp-item-transform.cpp
+++ b/src/object/sp-item-transform.cpp
@@ -21,24 +21,6 @@
#include <glib.h>
-void sp_item_rotate_rel(SPItem *item, Geom::Rotate const &rotation)
-{
- Geom::Point center = item->getCenter();
- Geom::Translate const s(item->getCenter());
- Geom::Affine affine = Geom::Affine(s).inverse() * Geom::Affine(rotation) * Geom::Affine(s);
-
- // Rotate item.
- item->set_i2d_affine(item->i2dt_affine() * (Geom::Affine)affine);
- // Use each item's own transform writer, consistent with sp_selection_apply_affine()
- item->doWriteTransform(item->transform);
-
- // Restore the center position (it's changed because the bbox center changed)
- if (item->isCenterSet()) {
- item->setCenter(center * affine);
- item->updateRepr();
- }
-}
-
void sp_item_scale_rel(SPItem *item, Geom::Scale const &scale)
{
Geom::OptRect bbox = item->desktopVisualBounds();
diff --git a/src/object/sp-item-transform.h b/src/object/sp-item-transform.h
index f5a40c3ab..02c8362dd 100644
--- a/src/object/sp-item-transform.h
+++ b/src/object/sp-item-transform.h
@@ -14,7 +14,6 @@
class SPItem;
-void sp_item_rotate_rel(SPItem *item, Geom::Rotate const &rotation);
void sp_item_scale_rel (SPItem *item, Geom::Scale const &scale);
void sp_item_skew_rel (SPItem *item, double skewX, double skewY);
void sp_item_move_rel(SPItem *item, Geom::Translate const &tr);
diff --git a/src/object/sp-item.cpp b/src/object/sp-item.cpp
index 5a8e23e84..ee54c8ada 100644
--- a/src/object/sp-item.cpp
+++ b/src/object/sp-item.cpp
@@ -1716,6 +1716,23 @@ void SPItem::convert_to_guides() const {
sp_guide_pt_pairs_to_guides(document, pts);
}
+void SPItem::rotate_rel(Geom::Rotate const &rotation)
+{
+ Geom::Point center = getCenter();
+ Geom::Translate const s(getCenter());
+ Geom::Affine affine = Geom::Affine(s).inverse() * Geom::Affine(rotation) * Geom::Affine(s);
+
+ // Rotate item.
+ set_i2d_affine(i2dt_affine() * (Geom::Affine)affine);
+ // Use each item's own transform writer, consistent with sp_selection_apply_affine()
+ doWriteTransform(transform);
+
+ // Restore the center position (it's changed because the bbox center changed)
+ if (isCenterSet()) {
+ setCenter(center * affine);
+ updateRepr();
+ }
+}
/*
Local Variables:
mode:c++
diff --git a/src/object/sp-item.h b/src/object/sp-item.h
index 20d423692..4ff3ca460 100644
--- a/src/object/sp-item.h
+++ b/src/object/sp-item.h
@@ -395,6 +395,7 @@ private:
static void stroke_ps_ref_changed(SPObject *old_clip, SPObject *clip, SPItem *item);
public:
+ void rotate_rel(Geom::Rotate const &rotation);
void build(SPDocument *document, Inkscape::XML::Node *repr) override;
void release() override;
void set(SPAttributeEnum key, char const* value) override;
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index ea9d1eace..f458155d8 100755
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -1867,7 +1867,7 @@ void ObjectSet::rotate90(bool ccw)
for (auto l=items_copy.begin();l!=items_copy.end() ;++l) {
SPItem *item = *l;
if (item) {
- sp_item_rotate_rel(item, rot_90);
+ item->rotate_rel(rot_90);
} else {
g_assert_not_reached();
}
diff --git a/src/ui/dialog/transformation.cpp b/src/ui/dialog/transformation.cpp
index d4649ddd1..2c0ffc869 100644
--- a/src/ui/dialog/transformation.cpp
+++ b/src/ui/dialog/transformation.cpp
@@ -797,7 +797,7 @@ void Transformation::applyPageRotate(Inkscape::Selection *selection)
auto tmp= selection->items();
for(auto i=tmp.begin();i!=tmp.end();++i){
SPItem *item = *i;
- sp_item_rotate_rel(item, Geom::Rotate (angle*M_PI/180.0));
+ item->rotate_rel(Geom::Rotate (angle*M_PI/180.0));
}
} else {
boost::optional<Geom::Point> center = selection->center();
diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp
index 1cb757bfd..205de0e5d 100644
--- a/src/ui/tools/tweak-tool.cpp
+++ b/src/ui/tools/tweak-tool.cpp
@@ -456,7 +456,7 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
if (x < 1) {
double angle = (reverse? force : -force) * 0.05 * (cos(M_PI * x) + 1) * M_PI;
angle *= -selection->desktop()->yaxisdir();
- sp_item_rotate_rel(item, Geom::Rotate(angle));
+ item->rotate_rel(Geom::Rotate(angle));
did = true;
}
}