From 3aaae7405dcaa5cbca2e7e87793420c970277003 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 28 Sep 2024 18:17:00 +0200 Subject: [PATCH] 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 --- pcbnew/tools/edit_tool.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index ddc220738b..dcc366d5e7 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -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( selection.GetItem( 0 ) ); + + if( !item || item->GetShape() != SHAPE_T::RECTANGLE ) + refPt = selection.GetReferencePoint(); + } bool leftRight = frame()->GetPcbNewSettings()->m_FlipLeftRight;