From 84d42a266953b7ecf39bdabe97684d8f989e6b36 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 28 Oct 2023 20:55:25 +0100 Subject: [PATCH] Normalize rectangles after rotation/flipping. Fixes https://gitlab.com/kicad/code/kicad/-/issues/14341 --- common/eda_shape.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/common/eda_shape.cpp b/common/eda_shape.cpp index 5c2149f2b2..e2d4f52f53 100644 --- a/common/eda_shape.cpp +++ b/common/eda_shape.cpp @@ -351,6 +351,14 @@ void EDA_SHAPE::rotate( const VECTOR2I& aRotCentre, const EDA_ANGLE& aAngle ) { RotatePoint( m_start, aRotCentre, aAngle ); RotatePoint( m_end, aRotCentre, aAngle ); + + // Normalize + BOX2I bbox; + bbox.Merge( m_start ); + bbox.Merge( m_end ); + m_start = bbox.GetOrigin(); + m_end = bbox.GetEnd(); + break; } @@ -405,6 +413,17 @@ void EDA_SHAPE::flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) } std::swap( m_start, m_end ); + + if( m_shape == SHAPE_T::RECTANGLE ) + { + // Normalize + BOX2I bbox; + bbox.Merge( m_start ); + bbox.Merge( m_end ); + m_start = bbox.GetOrigin(); + m_end = bbox.GetEnd(); + } + break; case SHAPE_T::CIRCLE: