Commit a39c53ba authored by twanvl's avatar twanvl

(minor) use getAngle() instead of trAngle(0)

parent 4578cae7
......@@ -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;
......
......@@ -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,
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment