Code brevity.

(cherry picked from commit f951497a4f)
This commit is contained in:
Jeff Young
2025-03-01 22:23:30 +00:00
parent 0ec82b65be
commit 203ddb7b47
135 changed files with 678 additions and 788 deletions
+26 -24
View File
@@ -288,7 +288,7 @@ bool GERBER_PLOTTER::StartPlot( const wxString& aPageNumber )
fprintf( m_outputFile, "G04 Created by KiCad (%s) date %s*\n",
TO_UTF8( Title ), TO_UTF8( date.FormatISOCombined( ' ') ) );
/* Mass parameter: unit = INCHES/MM */
/* Mass parameter: unit = IN/MM */
if( m_gerberUnitInch )
fputs( "%MOIN*%\n", m_outputFile );
else
@@ -615,7 +615,8 @@ void GERBER_PLOTTER::writeApertureList()
break;
case APERTURE::AT_RECT:
fprintf( m_outputFile, "R,%#fX%#f*%%\n", tool.m_Size.x * fscale,
fprintf( m_outputFile, "R,%#fX%#f*%%\n",
tool.m_Size.x * fscale,
tool.m_Size.y * fscale );
break;
@@ -624,7 +625,8 @@ void GERBER_PLOTTER::writeApertureList()
break;
case APERTURE::AT_OVAL:
fprintf( m_outputFile, "O,%#fX%#f*%%\n", tool.m_Size.x * fscale,
fprintf( m_outputFile, "O,%#fX%#f*%%\n",
tool.m_Size.x * fscale,
tool.m_Size.y * fscale );
break;
@@ -639,8 +641,10 @@ void GERBER_PLOTTER::writeApertureList()
case APERTURE::AT_REGULAR_POLY10:
case APERTURE::AT_REGULAR_POLY11:
case APERTURE::AT_REGULAR_POLY12:
fprintf( m_outputFile, "P,%#fX%dX%#f*%%\n", tool.GetDiameter() * fscale,
tool.GetRegPolyVerticeCount(), tool.GetRotation().AsDegrees() );
fprintf( m_outputFile, "P,%#fX%dX%#f*%%\n",
tool.GetDiameter() * fscale,
tool.GetRegPolyVerticeCount(),
tool.GetRotation().AsDegrees() );
break;
case APERTURE::AM_ROUND_RECT: // Aperture macro for round rect pads
@@ -668,12 +672,16 @@ void GERBER_PLOTTER::writeApertureList()
for( int ii = 0; ii < 4; ii++ )
RotatePoint( corners[ii], -tool.m_Rotation );
fprintf( m_outputFile, "%s,%#fX", APER_MACRO_ROUNDRECT_NAME, tool.m_Radius * fscale );
fprintf( m_outputFile, "%s,%#fX",
APER_MACRO_ROUNDRECT_NAME,
tool.m_Radius * fscale );
// Add each corner
for( int ii = 0; ii < 4; ii++ )
{
fprintf( m_outputFile, "%#fX%#fX", corners[ii].x * fscale, corners[ii].y * fscale );
fprintf( m_outputFile, "%#fX%#fX",
corners[ii].x * fscale,
corners[ii].y * fscale );
}
fprintf( m_outputFile, "0*%%\n" );
@@ -682,7 +690,9 @@ void GERBER_PLOTTER::writeApertureList()
case APERTURE::AM_ROT_RECT: // Aperture macro for rotated rect pads
fprintf( m_outputFile, "%s,%#fX%#fX%#f*%%\n", APER_MACRO_ROT_RECT_NAME,
tool.m_Size.x * fscale, tool.m_Size.y * fscale, tool.m_Rotation.AsDegrees() );
tool.m_Size.x * fscale,
tool.m_Size.y * fscale,
tool.m_Rotation.AsDegrees() );
break;
case APERTURE::APER_MACRO_OUTLINE4P: // Aperture macro for trapezoid pads
@@ -714,11 +724,8 @@ void GERBER_PLOTTER::writeApertureList()
// Output all corners (should be 4 to 8 corners)
// Remember: the Y coordinate must be negated, due to the fact in Pcbnew
// the Y axis is from top to bottom
for( size_t ii = 0; ii < tool.m_Corners.size(); ii++ )
{
fprintf( m_outputFile, "%#fX%#fX", tool.m_Corners[ii].x * fscale,
-tool.m_Corners[ii].y * fscale );
}
for( const VECTOR2I& corner : tool.m_Corners)
fprintf( m_outputFile, "%#fX%#fX", corner.x * fscale, -corner.y * fscale );
// close outline and output rotation
fprintf( m_outputFile, "%#f*%%\n", tool.m_Rotation.AsDegrees() );
@@ -741,10 +748,11 @@ void GERBER_PLOTTER::writeApertureList()
RotatePoint( start, tool.m_Rotation );
RotatePoint( end, tool.m_Rotation );
fprintf( m_outputFile, "%s,%#fX%#fX%#fX%#fX%#fX0*%%\n", APER_MACRO_SHAPE_OVAL_NAME,
fprintf( m_outputFile, "%s,%#fX%#fX%#fX%#fX%#fX0*%%\n",
APER_MACRO_SHAPE_OVAL_NAME,
tool.m_Size.y * fscale, // width
start.x * fscale, -start.y * fscale, // X,Y corner start pos
end.x * fscale, -end.y * fscale ); // X,Y cornerend pos
end.x * fscale, -end.y * fscale ); // X,Y corner end pos
}
break;
@@ -756,7 +764,9 @@ void GERBER_PLOTTER::writeApertureList()
// Write DCODE id ( "%ADDxx" is already in buffer) and rotation
// the full line is something like :%ADD12FreePoly1,45.000000*%
fprintf( m_outputFile, "%s%d,%#f*%%\n", AM_FREEPOLY_BASENAME, idx,
fprintf( m_outputFile, "%s%d,%#f*%%\n",
AM_FREEPOLY_BASENAME,
idx,
tool.m_Rotation.AsDegrees() );
break;
}
@@ -950,13 +960,9 @@ void GERBER_PLOTTER::PlotGerberRegion( const SHAPE_LINE_CHAIN& aPoly, GBR_METADA
if( clearTA_AperFunction )
{
if( m_useX2format )
{
fputs( "%TD.AperFunction*%\n", m_outputFile );
}
else
{
fputs( "G04 #@! TD.AperFunction*\n", m_outputFile );
}
}
}
@@ -986,13 +992,9 @@ void GERBER_PLOTTER::PlotGerberRegion( const std::vector<VECTOR2I>& aCornerList,
if( clearTA_AperFunction )
{
if( m_useX2format )
{
fputs( "%TD.AperFunction*%\n", m_outputFile );
}
else
{
fputs( "G04 #@! TD.AperFunction*\n", m_outputFile );
}
}
}