Fix pad arcs in Gerber plot when aperture macros are disabled.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15452
This commit is contained in:
Alex Shvartzkop 2023-08-19 22:48:57 +03:00
parent c20cc24400
commit 865fa10fb2
2 changed files with 15 additions and 6 deletions

View File

@ -339,7 +339,7 @@ bool GERBER_PLOTTER::EndPlot()
if( substr && strcmp( substr, "G04 APERTURE LIST*" ) == 0 ) if( substr && strcmp( substr, "G04 APERTURE LIST*" ) == 0 )
{ {
// Add aperture list macro: // Add aperture list macro:
if( m_hasApertureRoundRect | m_hasApertureRotOval || if( m_hasApertureRoundRect || m_hasApertureRotOval ||
m_hasApertureOutline4P || m_hasApertureRotRect || m_hasApertureOutline4P || m_hasApertureRotRect ||
m_hasApertureChamferedRect || m_am_freepoly_list.AmCount() ) m_hasApertureChamferedRect || m_am_freepoly_list.AmCount() )
{ {
@ -822,8 +822,13 @@ void GERBER_PLOTTER::Arc( const VECTOR2D& aCenter, const EDA_ANGLE& aStartAngle,
{ {
SetCurrentLineWidth( aWidth ); SetCurrentLineWidth( aWidth );
EDA_ANGLE endAngle( aEndAngle );
while( endAngle < aStartAngle )
endAngle += ANGLE_360;
// aFill is not used here. // 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 ); VECTOR2D devRelCenter = userToDeviceCoordinates( aCenter ) - userToDeviceCoordinates( start );
fprintf( m_outputFile, "G75*\n" ); // Multiquadrant (360 degrees) mode 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", fprintf( m_outputFile, "X%dY%dI%dJ%dD01*\n",
KiROUND( devEnd.x ), KiROUND( devEnd.y ), KiROUND( devEnd.x ), KiROUND( devEnd.y ),

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * 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 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 * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -214,7 +214,7 @@ public:
/** /**
* Generic fallback: arc rendered as a polyline. * 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, virtual void Arc( const VECTOR2I& aCenter, const VECTOR2I& aStart, const VECTOR2I& aEnd,
FILL_T aFill, int aWidth, int aMaxError ); 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 * 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, * 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. * 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, virtual void Arc( const VECTOR2D& aCentre, const EDA_ANGLE& aStartAngle,
const EDA_ANGLE& aEndAngle, double aRadius, FILL_T aFill, const EDA_ANGLE& aEndAngle, double aRadius, FILL_T aFill,