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

Fixes https://gitlab.com/kicad/code/kicad/-/issues/18797
This commit is contained in:
jean-pierre charras 2024-09-28 10:14:25 +02:00
parent 164ff0b870
commit 50d5c6a437

View File

@ -2270,8 +2270,21 @@ 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();
{
EDA_ITEM* item = static_cast<EDA_ITEM*>( selection.GetItem( 0 ) );
if( item->IsBOARD_ITEM() )
{
EDA_SHAPE* boardItem = dynamic_cast<EDA_SHAPE*>( item );
if( !boardItem || boardItem->GetShape() != SHAPE_T::RECTANGLE )
refPt = selection.GetReferencePoint();
}
}
const FLIP_DIRECTION flipDirection = frame()->GetPcbNewSettings()->m_FlipDirection;