From 865fa10fb279fc5a857c0da9b0a5ee96e681fefd Mon Sep 17 00:00:00 2001 From: Alex Shvartzkop Date: Sat, 19 Aug 2023 22:48:57 +0300 Subject: [PATCH] Fix pad arcs in Gerber plot when aperture macros are disabled. Fixes https://gitlab.com/kicad/code/kicad/-/issues/15452 --- common/plotters/GERBER_plotter.cpp | 15 ++++++++++++--- include/plotters/plotter.h | 6 +++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/common/plotters/GERBER_plotter.cpp b/common/plotters/GERBER_plotter.cpp index a784e2eefb..dc7d7d1ae2 100644 --- a/common/plotters/GERBER_plotter.cpp +++ b/common/plotters/GERBER_plotter.cpp @@ -339,7 +339,7 @@ bool GERBER_PLOTTER::EndPlot() if( substr && strcmp( substr, "G04 APERTURE LIST*" ) == 0 ) { // Add aperture list macro: - if( m_hasApertureRoundRect | m_hasApertureRotOval || + if( m_hasApertureRoundRect || m_hasApertureRotOval || m_hasApertureOutline4P || m_hasApertureRotRect || m_hasApertureChamferedRect || m_am_freepoly_list.AmCount() ) { @@ -822,8 +822,13 @@ void GERBER_PLOTTER::Arc( const VECTOR2D& aCenter, const EDA_ANGLE& aStartAngle, { SetCurrentLineWidth( aWidth ); + EDA_ANGLE endAngle( aEndAngle ); + + while( endAngle < aStartAngle ) + endAngle += ANGLE_360; + // aFill is not used here. - plotArc( aCenter, aStartAngle, aEndAngle, aRadius, false ); + plotArc( aCenter, aStartAngle, endAngle, aRadius, false ); } @@ -884,7 +889,11 @@ void GERBER_PLOTTER::plotArc( const VECTOR2I& aCenter, const EDA_ANGLE& aStartAn VECTOR2D devRelCenter = userToDeviceCoordinates( aCenter ) - userToDeviceCoordinates( start ); fprintf( m_outputFile, "G75*\n" ); // Multiquadrant (360 degrees) mode - fprintf( m_outputFile, "G03*\n" ); // Active circular interpolation, CCW + + if( aStartAngle < aEndAngle ) + fprintf( m_outputFile, "G03*\n" ); // Active circular interpolation, CCW + else + fprintf( m_outputFile, "G02*\n" ); // Active circular interpolation, CW fprintf( m_outputFile, "X%dY%dI%dJ%dD01*\n", KiROUND( devEnd.x ), KiROUND( devEnd.y ), diff --git a/include/plotters/plotter.h b/include/plotters/plotter.h index f4559505c6..81206fb87e 100644 --- a/include/plotters/plotter.h +++ b/include/plotters/plotter.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2016-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2016-2023 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 @@ -214,7 +214,7 @@ public: /** * Generic fallback: arc rendered as a polyline. - * Winding direction: clockwise in increasing X -> right, increasing Y -> down system. + * Winding direction: clockwise in right-down coordinate system. */ virtual void Arc( const VECTOR2I& aCenter, const VECTOR2I& aStart, const VECTOR2I& aEnd, FILL_T aFill, int aWidth, int aMaxError ); @@ -227,7 +227,7 @@ public: * In some plotters (i.e. dxf) whe need a good precision when calculating an arc * without error introduced by rounding, to avoid moving the end points, * usually important in outlines when plotting an arc given by center, radius and angles. - * Winding direction: counter-clockwise in increasing X -> right, increasing Y -> down system. + * Winding direction: counter-clockwise in right-down coordinate system. */ virtual void Arc( const VECTOR2D& aCentre, const EDA_ANGLE& aStartAngle, const EDA_ANGLE& aEndAngle, double aRadius, FILL_T aFill,