From 4e5dd6952e5f2351bb03ad63fab4e74ea6b19da9 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 1 Nov 2020 15:25:42 +0000 Subject: [PATCH] Fix arc flipping behaviour. Also fixes flipping of a dragged selection to be around the anchor point. Fixes https://gitlab.com/kicad/code/kicad/issues/6217 --- pcbnew/pcb_shape.cpp | 11 ++++++++++- pcbnew/tools/edit_tool.cpp | 11 ++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/pcbnew/pcb_shape.cpp b/pcbnew/pcb_shape.cpp index c6b758860d..34b57a2f39 100644 --- a/pcbnew/pcb_shape.cpp +++ b/pcbnew/pcb_shape.cpp @@ -4,7 +4,7 @@ * Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck * Copyright (C) 2011 Wayne Stambaugh - * Copyright (C) 1992-2019 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -165,6 +165,10 @@ void PCB_SHAPE::Scale( double aScale ) scalePt( m_BezierC2 ); break; + case S_ARC: + scalePt( m_ThirdPoint ); + break; + case S_CIRCLE: // ring or circle m_End.x = m_Start.x + KiROUND( radius * aScale ); m_End.y = m_Start.y; @@ -261,6 +265,11 @@ void PCB_SHAPE::Flip( const wxPoint& aCentre, bool aFlipLeftRight ) switch ( m_Shape ) { case S_ARC: + if( aFlipLeftRight ) + m_ThirdPoint.x = aCentre.x - ( m_ThirdPoint.x - aCentre.x ); + else + m_ThirdPoint.y = aCentre.y - ( m_ThirdPoint.y - aCentre.y ); + m_Angle = -m_Angle; break; diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 0f9ded1dc9..86feb53f6b 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -1158,10 +1158,15 @@ int EDIT_TOOL::Flip( const TOOL_EVENT& aEvent ) // Flip around the anchor for footprints, and the bounding box center for board items VECTOR2I modPoint = EditingModules() ? VECTOR2I( 0, 0 ) : selection.GetCenter(); - // If only one item selected, flip around the item anchor point, instead - // of the bounding box center, to avoid moving the item anchor + // 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 if( selection.GetSize() == 1 ) - modPoint = static_cast( selection.GetItem( 0 ) )->GetPosition(); + { + if( selection.HasReferencePoint() ) + modPoint = selection.GetReferencePoint(); + else + modPoint = static_cast( selection.GetItem( 0 ) )->GetPosition(); + } bool leftRight = frame()->Settings().m_FlipLeftRight;