diff --git a/src/render/value/choice.cpp b/src/render/value/choice.cpp index 9cbadb46..4affd86a 100644 --- a/src/render/value/choice.cpp +++ b/src/render/value/choice.cpp @@ -110,7 +110,7 @@ void draw_choice_viewer(RotatedDC& dc, ValueViewer& viewer, ChoiceStyle& style, void get_options(Rotation& rot, ValueViewer& viewer, const ChoiceStyle& style, GeneratedImage::Options& opts) { opts.package = &viewer.getStylePackage(); opts.local_package = &viewer.getLocalPackage(); - opts.angle = rot.trAngle(0); + opts.angle = rot.getAngle(); if (viewer.nativeLook()) { opts.width = opts.height = 16; opts.preserve_aspect = ASPECT_BORDER; diff --git a/src/util/rotation.cpp b/src/util/rotation.cpp index b1ce3997..e609c420 100644 --- a/src/util/rotation.cpp +++ b/src/util/rotation.cpp @@ -72,6 +72,7 @@ RealSize Rotation::trSize(const RealSize& size) const { return RealSize(c * x + s * y, s * x + c * y); } */ + RealSize Rotation::trSizeToBB(const RealSize& size) const { if (straight()) { if (sideways()) { @@ -85,6 +86,7 @@ RealSize Rotation::trSizeToBB(const RealSize& size) const { return RealSize(fabs(c * x) + fabs(s * y), fabs(s * x) + fabs(c * y)); } } + RealRect Rotation::trRectToBB(const RealRect& r) const { if (straight()) { RealSize s = trSizeToBB(r.size()); @@ -117,6 +119,8 @@ RealRect Rotation::trRectToBB(const RealRect& r) const { return result; } } + + RealRect Rotation::trRectStraight(const RealRect& r) const { assert(angle == 0); return RealRect(r.position() + origin, r.size()); @@ -139,6 +143,11 @@ RealPoint Rotation::trInv(const RealPoint& p) const { return RealPoint((c * x - s * y) / zoomX, (s * x + c * y) / zoomY); } +RealSize Rotation::trInv(const RealSize& x) const { + double a = deg_to_rad(angle), s = sin(a), c = cos(a); + return RealSize((c * x.width - s * x.height) / zoomX, + (s * x.width + c * x.height) / zoomY); +} RealPoint Rotation::boundingBoxCorner(const RealSize& size) const { // This function is a bit tricky, diff --git a/src/util/rotation.hpp b/src/util/rotation.hpp index 4e749ffa..e70b1778 100644 --- a/src/util/rotation.hpp +++ b/src/util/rotation.hpp @@ -98,6 +98,8 @@ class Rotation { /// Translate a point back to internal coordinates RealPoint trInv(const RealPoint& p) const; + /// Translate a size back to internal coordinates + RealSize trInv(const RealSize& p) const; protected: int angle; ///< The angle of rotation in degrees (counterclockwise)