7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-20 23:11:41 +00:00

Formatting.

This commit is contained in:
Jeff Young 2025-01-17 22:00:15 +00:00
parent 8d20cf454b
commit a1fbff35e8
7 changed files with 86 additions and 91 deletions

View File

@ -57,8 +57,8 @@ CLI::PCB_EXPORT_POS_COMMAND::PCB_EXPORT_POS_COMMAND() : PCB_EXPORT_BASE_COMMAND(
m_argParser.add_argument( ARG_UNITS )
.default_value( std::string( "in" ) )
.help( UTF8STDSTR(
_( "Output units; ascii or csv format only; valid options: in,mm" ) ) )
.help( UTF8STDSTR( _( "Output units; ascii or csv format only; valid options: "
"in,mm" ) ) )
.metavar( "UNITS" );
m_argParser.add_argument( ARG_NEGATE_BOTTOM_X )
@ -80,8 +80,7 @@ CLI::PCB_EXPORT_POS_COMMAND::PCB_EXPORT_POS_COMMAND() : PCB_EXPORT_BASE_COMMAND(
.flag();
m_argParser.add_argument( ARG_EXCLUDE_DNP )
.help( UTF8STDSTR(
_( "Exclude all footprints with the Do Not Populate flag set" ) ) )
.help( UTF8STDSTR( _( "Exclude all footprints with the Do Not Populate flag set" ) ) )
.flag();
m_argParser.add_argument( ARG_GERBER_BOARD_EDGE )
@ -93,6 +92,7 @@ CLI::PCB_EXPORT_POS_COMMAND::PCB_EXPORT_POS_COMMAND() : PCB_EXPORT_BASE_COMMAND(
int CLI::PCB_EXPORT_POS_COMMAND::doPerform( KIWAY& aKiway )
{
int baseExit = PCB_EXPORT_BASE_COMMAND::doPerform( aKiway );
if( baseExit != EXIT_CODES::OK )
return baseExit;
@ -117,6 +117,7 @@ int CLI::PCB_EXPORT_POS_COMMAND::doPerform( KIWAY& aKiway )
aPosJob->m_gerberBoardEdge = m_argParser.get<bool>( ARG_GERBER_BOARD_EDGE );
wxString format = From_UTF8( m_argParser.get<std::string>( ARG_FORMAT ).c_str() );
if( format == wxS( "ascii" ) )
{
aPosJob->m_format = JOB_EXPORT_PCB_POS::FORMAT::ASCII;

View File

@ -510,9 +510,9 @@ bool DIALOG_GEN_FOOTPRINT_POSITION::CreateAsciiFiles()
}
fpcount = m_editFrame->DoGenFootprintsPositionFile( fn.GetFullPath(), UnitsMM(), OnlySMD(),
ExcludeAllTH(), ExcludeDNP(), topSide,
bottomSide, useCSVfmt,
useAuxOrigin, negateBottomX );
ExcludeAllTH(), ExcludeDNP(), topSide,
bottomSide, useCSVfmt,
useAuxOrigin, negateBottomX );
if( fpcount < 0 )
{

View File

@ -219,11 +219,15 @@ int GERBER_WRITER::createDrillFile( wxString& aFullFilename, bool aIsNpth,
// Good practice of oblong pad holes (slots) is to use a specific aperture for
// routing, not used in drill commands.
if( hole_descr.m_Hole_Shape )
{
gbr_metadata.SetApertureAttrib(
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CMP_OBLONG_DRILL );
}
else
{
gbr_metadata.SetApertureAttrib(
GBR_APERTURE_METADATA::GBR_APERTURE_ATTRIB_CMP_DRILL );
}
}
// Add object attribute: component reference to pads (mainly useful for users)

View File

@ -71,12 +71,12 @@ enum ONSIDE GERBER_JOBFILE_WRITER::hasSilkLayers()
{
int flag = SIDE_NONE;
for( unsigned ii = 0; ii < m_params.m_LayerId.size(); ii++ )
for( PCB_LAYER_ID layer : m_params.m_LayerId )
{
if( m_params.m_LayerId[ii] == B_SilkS )
if( layer == B_SilkS )
flag |= SIDE_BOTTOM;
if( m_params.m_LayerId[ii] == F_SilkS )
if( layer == F_SilkS )
flag |= SIDE_TOP;
}
@ -88,12 +88,12 @@ enum ONSIDE GERBER_JOBFILE_WRITER::hasSolderMasks()
{
int flag = SIDE_NONE;
for( unsigned ii = 0; ii < m_params.m_LayerId.size(); ii++ )
for( PCB_LAYER_ID layer : m_params.m_LayerId )
{
if( m_params.m_LayerId[ii] == B_Mask )
if( layer == B_Mask )
flag |= SIDE_BOTTOM;
if( m_params.m_LayerId[ii] == F_Mask )
if( layer == F_Mask )
flag |= SIDE_TOP;
}
@ -108,21 +108,10 @@ const char* GERBER_JOBFILE_WRITER::sideKeyValue( enum ONSIDE aValue )
switch( aValue )
{
case SIDE_NONE:
value = "No";
break;
case SIDE_TOP:
value = "TopOnly";
break;
case SIDE_BOTTOM:
value = "BotOnly";
break;
case SIDE_BOTH:
value = "Both";
break;
case SIDE_NONE: value = "No"; break;
case SIDE_TOP: value = "TopOnly"; break;
case SIDE_BOTTOM: value = "BotOnly"; break;
case SIDE_BOTH: value = "Both"; break;
}
return value;
@ -731,9 +720,9 @@ void GERBER_JOBFILE_WRITER::addJSONMaterialStackup()
subLayerName.Printf( wxT( " (%d/%d)" ), sub_idx + 1, sub_layer_count );
wxString name = wxString::Format( wxT( "%s/%s%s" ),
formatStringFromUTF32( m_pcb->GetLayerName( last_copper_layer ) ),
formatStringFromUTF32( m_pcb->GetLayerName( next_copper_layer ) ),
subLayerName );
formatStringFromUTF32( m_pcb->GetLayerName( last_copper_layer ) ),
formatStringFromUTF32( m_pcb->GetLayerName( next_copper_layer ) ),
subLayerName );
layer_json["Name"] = name;
@ -743,8 +732,8 @@ void GERBER_JOBFILE_WRITER::addJSONMaterialStackup()
note << wxString::Format( wxT( "Type: %s" ), layer_name.c_str() );
note << wxString::Format( wxT( " (from %s to %s)" ),
formatStringFromUTF32( m_pcb->GetLayerName( last_copper_layer ) ),
formatStringFromUTF32( m_pcb->GetLayerName( next_copper_layer ) ) );
formatStringFromUTF32( m_pcb->GetLayerName( last_copper_layer ) ),
formatStringFromUTF32( m_pcb->GetLayerName( next_copper_layer ) ) );
layer_json["Notes"] = note;
}

View File

@ -216,7 +216,8 @@ std::string PLACE_FILE_EXPORTER::GenPositionData()
else
{
// Write file header
snprintf( line, sizeof(line), "### Footprint positions - created on %s ###\n", TO_UTF8( GetISO8601CurrentDateTime() ) );
snprintf( line, sizeof(line), "### Footprint positions - created on %s ###\n",
TO_UTF8( GetISO8601CurrentDateTime() ) );
buffer += line;
@ -298,11 +299,13 @@ std::string PLACE_FILE_EXPORTER::GenReportData()
// Generate header file comments.)
char line[1024];
snprintf( line, sizeof(line), "## Footprint report - date %s\n", TO_UTF8( GetISO8601CurrentDateTime() ) );
snprintf( line, sizeof(line), "## Footprint report - date %s\n",
TO_UTF8( GetISO8601CurrentDateTime() ) );
buffer += line;
wxString Title = GetBuildVersion();
snprintf( line, sizeof(line), "## Created by KiCad version %s\n", TO_UTF8( Title ) );
snprintf( line, sizeof(line), "## Created by KiCad version %s\n",
TO_UTF8( Title ) );
buffer += line;
buffer += unit_text;
@ -314,11 +317,13 @@ std::string PLACE_FILE_EXPORTER::GenReportData()
buffer += "\n$BOARD\n";
snprintf( line, sizeof(line), "upper_left_corner %9.6f %9.6f\n",
bbbox.GetX() * conv_unit, bbbox.GetY() * conv_unit );
bbbox.GetX() * conv_unit,
bbbox.GetY() * conv_unit );
buffer += line;
snprintf( line, sizeof(line), "lower_right_corner %9.6f %9.6f\n",
bbbox.GetRight() * conv_unit, bbbox.GetBottom() * conv_unit );
bbbox.GetRight() * conv_unit,
bbbox.GetBottom() * conv_unit );
buffer += line;
buffer += "$EndBOARD\n\n";

View File

@ -39,7 +39,9 @@
PCB_PLOTTER::PCB_PLOTTER( BOARD* aBoard, REPORTER* aReporter, PCB_PLOT_PARAMS& aParams ) :
m_board( aBoard ), m_plotOpts( aParams ), m_reporter( aReporter )
m_board( aBoard ),
m_plotOpts( aParams ),
m_reporter( aReporter )
{
}
@ -88,10 +90,8 @@ bool PCB_PLOTTER::Plot( const wxString& aOutputPath,
size_t finalPageCount = 0;
for( size_t i = 0; i < layersToPlot.size(); i++ )
for( PCB_LAYER_ID layer : layersToPlot )
{
PCB_LAYER_ID layer = layersToPlot[i];
if( copperLayerShouldBeSkipped( layer ) )
continue;
@ -257,8 +257,7 @@ bool PCB_PLOTTER::Plot( const wxString& aOutputPath,
wxFileName fn( m_board->GetFileName() );
// Build gerber job file from basename
BuildPlotFileName( &fn, aOutputPath, wxT( "job" ),
FILEEXT::GerberJobFileExtension );
BuildPlotFileName( &fn, aOutputPath, wxT( "job" ), FILEEXT::GerberJobFileExtension );
jobfile_writer->CreateJobFile( fn.GetFullPath() );
}
@ -313,10 +312,8 @@ LSEQ PCB_PLOTTER::getPlotSequence( PCB_LAYER_ID aLayerToPlot, LSEQ aPlotWithAllL
// Base layer always gets plotted first.
plotSequence.push_back( aLayerToPlot );
for( size_t i = 0; i < aPlotWithAllLayersSeq.size(); i++ )
for( PCB_LAYER_ID layer : aPlotWithAllLayersSeq )
{
PCB_LAYER_ID layer = aPlotWithAllLayersSeq[i];
// Don't plot the same layer more than once;
if( find( plotSequence.begin(), plotSequence.end(), layer ) != plotSequence.end() )
continue;
@ -328,99 +325,98 @@ LSEQ PCB_PLOTTER::getPlotSequence( PCB_LAYER_ID aLayerToPlot, LSEQ aPlotWithAllL
}
void PCB_PLOTTER::PlotJobToPlotOpts( PCB_PLOT_PARAMS& aPlotOpts, JOB_EXPORT_PCB_PLOT* aJob )
void PCB_PLOTTER::PlotJobToPlotOpts( PCB_PLOT_PARAMS& aOpts, JOB_EXPORT_PCB_PLOT* aJob )
{
if( aJob->m_plotFormat == JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::GERBER )
{
JOB_EXPORT_PCB_GERBERS* gJob = static_cast<JOB_EXPORT_PCB_GERBERS*>( aJob );
aPlotOpts.SetDisableGerberMacros( gJob->m_disableApertureMacros );
aPlotOpts.SetUseGerberProtelExtensions( gJob->m_useProtelFileExtension );
aPlotOpts.SetUseGerberX2format( gJob->m_useX2Format );
aPlotOpts.SetIncludeGerberNetlistInfo( gJob->m_includeNetlistAttributes );
aPlotOpts.SetCreateGerberJobFile( gJob->m_createJobsFile );
aPlotOpts.SetGerberPrecision( gJob->m_precision );
aPlotOpts.SetSubtractMaskFromSilk( gJob->m_subtractSolderMaskFromSilk );
aOpts.SetDisableGerberMacros( gJob->m_disableApertureMacros );
aOpts.SetUseGerberProtelExtensions( gJob->m_useProtelFileExtension );
aOpts.SetUseGerberX2format( gJob->m_useX2Format );
aOpts.SetIncludeGerberNetlistInfo( gJob->m_includeNetlistAttributes );
aOpts.SetCreateGerberJobFile( gJob->m_createJobsFile );
aOpts.SetGerberPrecision( gJob->m_precision );
aOpts.SetSubtractMaskFromSilk( gJob->m_subtractSolderMaskFromSilk );
}
if( aJob->m_plotFormat == JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::SVG )
{
JOB_EXPORT_PCB_SVG* svgJob = static_cast<JOB_EXPORT_PCB_SVG*>( aJob );
aPlotOpts.SetSvgPrecision( svgJob->m_precision );
aOpts.SetSvgPrecision( svgJob->m_precision );
}
if( aJob->m_plotFormat == JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::DXF )
{
JOB_EXPORT_PCB_DXF* dxfJob = static_cast<JOB_EXPORT_PCB_DXF*>( aJob );
aPlotOpts.SetDXFPlotUnits( dxfJob->m_dxfUnits == JOB_EXPORT_PCB_DXF::DXF_UNITS::INCHES
aOpts.SetDXFPlotUnits( dxfJob->m_dxfUnits == JOB_EXPORT_PCB_DXF::DXF_UNITS::INCHES
? DXF_UNITS::INCHES
: DXF_UNITS::MILLIMETERS );
aPlotOpts.SetPlotMode( dxfJob->m_plotGraphicItemsUsingContours ? OUTLINE_MODE::SKETCH
: OUTLINE_MODE::FILLED );
aOpts.SetPlotMode( dxfJob->m_plotGraphicItemsUsingContours ? OUTLINE_MODE::SKETCH
: OUTLINE_MODE::FILLED );
aPlotOpts.SetDXFPlotPolygonMode( dxfJob->m_polygonMode );
aOpts.SetDXFPlotPolygonMode( dxfJob->m_polygonMode );
}
if( aJob->m_plotFormat == JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::PDF )
{
JOB_EXPORT_PCB_PDF* pdfJob = static_cast<JOB_EXPORT_PCB_PDF*>( aJob );
aPlotOpts.m_PDFFrontFPPropertyPopups = pdfJob->m_pdfFrontFPPropertyPopups;
aPlotOpts.m_PDFBackFPPropertyPopups = pdfJob->m_pdfBackFPPropertyPopups;
aPlotOpts.m_PDFMetadata = pdfJob->m_pdfMetadata;
aPlotOpts.m_PDFSingle = pdfJob->m_pdfSingle;
aOpts.m_PDFFrontFPPropertyPopups = pdfJob->m_pdfFrontFPPropertyPopups;
aOpts.m_PDFBackFPPropertyPopups = pdfJob->m_pdfBackFPPropertyPopups;
aOpts.m_PDFMetadata = pdfJob->m_pdfMetadata;
aOpts.m_PDFSingle = pdfJob->m_pdfSingle;
}
aPlotOpts.SetUseAuxOrigin( aJob->m_useDrillOrigin );
aPlotOpts.SetPlotFrameRef( aJob->m_plotDrawingSheet );
aPlotOpts.SetPlotInvisibleText( aJob->m_plotInvisibleText );
aPlotOpts.SetSketchPadsOnFabLayers( aJob->m_sketchPadsOnFabLayers );
aPlotOpts.SetHideDNPFPsOnFabLayers( aJob->m_hideDNPFPsOnFabLayers );
aPlotOpts.SetSketchDNPFPsOnFabLayers( aJob->m_sketchDNPFPsOnFabLayers );
aPlotOpts.SetCrossoutDNPFPsOnFabLayers( aJob->m_crossoutDNPFPsOnFabLayers );
aPlotOpts.SetPlotPadNumbers( aJob->m_plotPadNumbers );
aOpts.SetUseAuxOrigin( aJob->m_useDrillOrigin );
aOpts.SetPlotFrameRef( aJob->m_plotDrawingSheet );
aOpts.SetPlotInvisibleText( aJob->m_plotInvisibleText );
aOpts.SetSketchPadsOnFabLayers( aJob->m_sketchPadsOnFabLayers );
aOpts.SetHideDNPFPsOnFabLayers( aJob->m_hideDNPFPsOnFabLayers );
aOpts.SetSketchDNPFPsOnFabLayers( aJob->m_sketchDNPFPsOnFabLayers );
aOpts.SetCrossoutDNPFPsOnFabLayers( aJob->m_crossoutDNPFPsOnFabLayers );
aOpts.SetPlotPadNumbers( aJob->m_plotPadNumbers );
aPlotOpts.SetBlackAndWhite( aJob->m_blackAndWhite );
aPlotOpts.SetMirror( aJob->m_mirror );
aPlotOpts.SetNegative( aJob->m_negative );
aOpts.SetBlackAndWhite( aJob->m_blackAndWhite );
aOpts.SetMirror( aJob->m_mirror );
aOpts.SetNegative( aJob->m_negative );
aPlotOpts.SetLayerSelection( aJob->m_printMaskLayer );
aPlotOpts.SetPlotOnAllLayersSelection( aJob->m_printMaskLayersToIncludeOnAllLayers );
aOpts.SetLayerSelection( aJob->m_printMaskLayer );
aOpts.SetPlotOnAllLayersSelection( aJob->m_printMaskLayersToIncludeOnAllLayers );
switch( aJob->m_plotFormat )
{
default:
case JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::GERBER:
aPlotOpts.SetFormat( PLOT_FORMAT::GERBER );
break;
case JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::POST: aPlotOpts.SetFormat( PLOT_FORMAT::POST ); break;
case JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::SVG: aPlotOpts.SetFormat( PLOT_FORMAT::SVG ); break;
case JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::DXF: aPlotOpts.SetFormat( PLOT_FORMAT::DXF ); break;
case JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::HPGL: aPlotOpts.SetFormat( PLOT_FORMAT::HPGL ); break;
case JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::PDF: aPlotOpts.SetFormat( PLOT_FORMAT::PDF ); break;
case JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::GERBER: aOpts.SetFormat( PLOT_FORMAT::GERBER ); break;
case JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::POST: aOpts.SetFormat( PLOT_FORMAT::POST ); break;
case JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::SVG: aOpts.SetFormat( PLOT_FORMAT::SVG ); break;
case JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::DXF: aOpts.SetFormat( PLOT_FORMAT::DXF ); break;
case JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::HPGL: aOpts.SetFormat( PLOT_FORMAT::HPGL ); break;
case JOB_EXPORT_PCB_PLOT::PLOT_FORMAT::PDF: aOpts.SetFormat( PLOT_FORMAT::PDF ); break;
}
switch( aJob->m_drillShapeOption )
{
case JOB_EXPORT_PCB_PLOT::DRILL_MARKS::NO_DRILL_SHAPE:
aPlotOpts.SetDrillMarksType( DRILL_MARKS::NO_DRILL_SHAPE );
aOpts.SetDrillMarksType( DRILL_MARKS::NO_DRILL_SHAPE );
break;
case JOB_EXPORT_PCB_PLOT::DRILL_MARKS::SMALL_DRILL_SHAPE:
aPlotOpts.SetDrillMarksType( DRILL_MARKS::SMALL_DRILL_SHAPE );
aOpts.SetDrillMarksType( DRILL_MARKS::SMALL_DRILL_SHAPE );
break;
default:
case JOB_EXPORT_PCB_PLOT::DRILL_MARKS::FULL_DRILL_SHAPE:
aPlotOpts.SetDrillMarksType( DRILL_MARKS::FULL_DRILL_SHAPE );
aOpts.SetDrillMarksType( DRILL_MARKS::FULL_DRILL_SHAPE );
break;
}
SETTINGS_MANAGER& mgr = Pgm().GetSettingsManager();
wxString theme = aJob->m_colorTheme;
if( theme.IsEmpty() )
theme = wxT( "pcbnew" );
PCBNEW_SETTINGS* cfg = mgr.GetAppSettings<PCBNEW_SETTINGS>( theme );
aPlotOpts.SetColorSettings( mgr.GetColorSettings( cfg->m_ColorTheme ) );
aOpts.SetColorSettings( mgr.GetColorSettings( cfg->m_ColorTheme ) );
aPlotOpts.SetOutputDirectory( aJob->GetConfiguredOutputPath() );
aOpts.SetOutputDirectory( aJob->GetConfiguredOutputPath() );
}

View File

@ -70,7 +70,7 @@ public:
/**
* Translate a JOB to PCB_PLOT_PARAMS
*/
static void PlotJobToPlotOpts( PCB_PLOT_PARAMS& aPlotOpts, JOB_EXPORT_PCB_PLOT* aJob );
static void PlotJobToPlotOpts( PCB_PLOT_PARAMS& aOpts, JOB_EXPORT_PCB_PLOT* aJob );
protected:
BOARD* m_board;