Pcbnew, Flip rectangle shape: Keep its anchor position after flipping.

Previously, it was flipped using the shape anchor position. But for this
shape, the anchor (top left corner)) is reinitialized after flipping, so
flipping twice moves the shape.
Now the rectangle center is used as reference position to flip the shape
From master branch

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18797
This commit is contained in:
jean-pierre charras
2024-09-28 18:17:00 +02:00
parent f2e012119a
commit 3aaae7405d
+9 -1
View File
@@ -2062,8 +2062,16 @@ int EDIT_TOOL::Flip( const TOOL_EVENT& aEvent )
// If only one item selected, flip around the selection or item anchor point (instead
// of the bounding box center) to avoid moving the item anchor
// but only if the item is not a PCB_SHAPE with SHAPE_T::RECTANGLE shape, because
// for this shape the flip transform swap start and end coordinates and move the shape.
// So using the center of the shape is better (the shape does not move)
if( selection.GetSize() == 1 )
refPt = selection.GetReferencePoint();
{
PCB_SHAPE* item = dynamic_cast<PCB_SHAPE*>( selection.GetItem( 0 ) );
if( !item || item->GetShape() != SHAPE_T::RECTANGLE )
refPt = selection.GetReferencePoint();
}
bool leftRight = frame()->GetPcbNewSettings()->m_FlipLeftRight;