From 45b94a4b3e346400825c6097c5e13ed68f39d82c Mon Sep 17 00:00:00 2001 From: Martin Thierer Date: Tue, 14 Mar 2023 23:26:20 +0100 Subject: [PATCH] Pcbnew: Fix rotating bitmaps Fixes rotating bitmaps with "rotate counterclockwise", "rotate clockwise" and "move exactly" commands. Only rotation by 0, 90, 180 and 270 degrees is supported for bitmaps. Other values are rounded to the nearest 90 degree multiple. There is a different bug that this commit doesn't address, which is that BITMAP_BASE::Rotate() got its CW/CCW logic reversed ("m_image->Rotate( false )" should rotate CW, but does not). Fixes https://gitlab.com/kicad/code/kicad/issues/14197 --- pcbnew/pcb_bitmap.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pcbnew/pcb_bitmap.cpp b/pcbnew/pcb_bitmap.cpp index 37d8001ade..8e026cc1ee 100644 --- a/pcbnew/pcb_bitmap.cpp +++ b/pcbnew/pcb_bitmap.cpp @@ -179,8 +179,15 @@ void PCB_BITMAP::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) void PCB_BITMAP::Rotate( const VECTOR2I& aCenter, const EDA_ANGLE& aAngle ) { + EDA_ANGLE norm( aAngle.AsDegrees(), DEGREES_T ); + RotatePoint( m_pos, aCenter, aAngle ); - m_image->Rotate( false ); + + norm.Normalize(); + + // each call to m_image->Rotate() rotates 90 degrees CCW + for( double ang = 45.0; ang < norm.AsDegrees(); ang += 90.0 ) + m_image->Rotate( false ); }