From 02c5ac41e41fb335cd2946bfbb9e418a9116ba48 Mon Sep 17 00:00:00 2001 From: Tavmjong Bah Date: Tue, 14 Mar 2017 11:17:48 +0100 Subject: Add functions to rotate drawing inside desktop. (bzr r15595) --- src/desktop.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ src/desktop.h | 5 +++++ 2 files changed, 47 insertions(+) (limited to 'src') diff --git a/src/desktop.cpp b/src/desktop.cpp index ddd5dfe83..f33c2bc29 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -1085,6 +1085,48 @@ SPDesktop::zoom_grab_focus() } +/** + * Rotate keeping the point 'c' fixed in the desktop window. + */ +void +SPDesktop::rotate_absolute_keep_point (Geom::Point const &c, double rotate) +{ + Geom::Point w = d2w( c ); // Must be before rotate changed. + _current_affine.setRotate( rotate ); + set_display_area( c, w ); +} + + +void +SPDesktop::rotate_relative_keep_point (Geom::Point const &c, double rotate) +{ + Geom::Point w = d2w( c ); // Must be before rotate changed. + _current_affine.addRotate( rotate ); + set_display_area( c, w ); +} + + +/** + * Rotate aligning the point 'c' to the center of desktop window. + */ +void +SPDesktop::rotate_absolute_center_point (Geom::Point const &c, double rotate) +{ + _current_affine.setRotate( rotate ); + Geom::Rect viewbox = canvas->getViewbox(); + set_display_area( c, viewbox.midpoint() ); +} + + +void +SPDesktop::rotate_relative_center_point (Geom::Point const &c, double rotate) +{ + _current_affine.addRotate( rotate ); + Geom::Rect viewbox = canvas->getViewbox(); + set_display_area( c, viewbox.midpoint() ); +} + + /** * Scroll canvas by to a particular point (window coordinates). */ diff --git a/src/desktop.h b/src/desktop.h index 2d2297c6b..3dc11b557 100644 --- a/src/desktop.h +++ b/src/desktop.h @@ -346,6 +346,11 @@ public: void zoom_grab_focus(); + void rotate_absolute_keep_point (Geom::Point const &c, double const rotate); + void rotate_relative_keep_point (Geom::Point const &c, double const rotate); + void rotate_absolute_center_point (Geom::Point const &c, double const rotate); + void rotate_relative_center_point (Geom::Point const &c, double const rotate); + void scroll_absolute (Geom::Point const &point, bool is_scrolling = false); void scroll_relative (Geom::Point const &delta, bool is_scrolling = false); void scroll_relative_in_svg_coords (double dx, double dy, bool is_scrolling = false); -- cgit v1.2.3