mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-04-20 00:21:31 +00:00
Fix pretty-printing of UUIDs and bools.
This commit is contained in:
parent
d68fc87308
commit
fa52d68268
common/io/kicad
eeschema/sch_io/kicad_sexpr
include/io/kicad
pcbnew
@ -29,17 +29,25 @@ namespace KICAD_FORMAT {
|
||||
void FormatBool( OUTPUTFORMATTER* aOut, int aNestLevel, const wxString& aKey, bool aValue,
|
||||
char aSuffix )
|
||||
{
|
||||
aOut->Print( aNestLevel, "(%ls %s)%c", aKey.wc_str(), aValue ? "yes" : "no", aSuffix );
|
||||
if( aNestLevel )
|
||||
aOut->Print( aNestLevel, "(%ls %s)", aKey.wc_str(), aValue ? "yes" : "no" );
|
||||
else
|
||||
aOut->Print( 0, " (%ls %s)", aKey.wc_str(), aValue ? "yes" : "no" );
|
||||
|
||||
if( aSuffix )
|
||||
aOut->Print( 0, "%c", aSuffix );
|
||||
}
|
||||
|
||||
|
||||
void FormatUuid( OUTPUTFORMATTER* aOut, const KIID& aUuid, char aSuffix )
|
||||
void FormatUuid( OUTPUTFORMATTER* aOut, int aNestLevel, const KIID& aUuid, char aSuffix )
|
||||
{
|
||||
if( aSuffix )
|
||||
aOut->Print( 0, "(uuid \"%s\")%c", TO_UTF8( aUuid.AsString() ), aSuffix );
|
||||
if( aNestLevel )
|
||||
aOut->Print( aNestLevel, "(uuid \"%s\")", TO_UTF8( aUuid.AsString() ) );
|
||||
else
|
||||
aOut->Print( 0, "(uuid \"%s\")", TO_UTF8( aUuid.AsString() ) );
|
||||
aOut->Print( 0, " (uuid \"%s\")", TO_UTF8( aUuid.AsString() ) );
|
||||
|
||||
if( aSuffix )
|
||||
aOut->Print( 0, "%c", aSuffix );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -384,7 +384,7 @@ void SCH_IO_KICAD_SEXPR::Format( SCH_SHEET* aSheet )
|
||||
m_out->Print( 0, "(kicad_sch (version %d) (generator \"eeschema\") (generator_version \"%s\")\n\n",
|
||||
SEXPR_SCHEMATIC_FILE_VERSION, GetMajorMinorVersion().c_str().AsChar() );
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, screen->m_uuid );
|
||||
KICAD_FORMAT::FormatUuid( m_out, 0, screen->m_uuid, '\n' );
|
||||
|
||||
screen->GetPageSettings().Format( m_out, 1, 0 );
|
||||
m_out->Print( 0, "\n" );
|
||||
@ -763,7 +763,7 @@ void SCH_IO_KICAD_SEXPR::saveSymbol( SCH_SYMBOL* aSymbol, const SCHEMATIC& aSche
|
||||
|
||||
m_out->Print( 0, "\n" );
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aSymbol->m_Uuid );
|
||||
KICAD_FORMAT::FormatUuid( m_out, aNestLevel + 1, aSymbol->m_Uuid, '\n' );
|
||||
|
||||
m_nextFreeFieldId = MANDATORY_FIELDS;
|
||||
|
||||
@ -819,16 +819,15 @@ void SCH_IO_KICAD_SEXPR::saveSymbol( SCH_SYMBOL* aSymbol, const SCHEMATIC& aSche
|
||||
{
|
||||
if( pin->GetAlt().IsEmpty() )
|
||||
{
|
||||
m_out->Print( aNestLevel + 1, "(pin %s ", m_out->Quotew( pin->GetNumber() ).c_str() );
|
||||
KICAD_FORMAT::FormatUuid( m_out, pin->m_Uuid );
|
||||
m_out->Print( aNestLevel + 1, ")\n" );
|
||||
m_out->Print( aNestLevel + 1, "(pin %s", m_out->Quotew( pin->GetNumber() ).c_str() );
|
||||
KICAD_FORMAT::FormatUuid( m_out, 0, pin->m_Uuid );
|
||||
m_out->Print( 0, ")\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_out->Print( aNestLevel + 1, "(pin %s ", m_out->Quotew( pin->GetNumber() ).c_str() );
|
||||
KICAD_FORMAT::FormatUuid( m_out, pin->m_Uuid );
|
||||
m_out->Print( aNestLevel + 1, " (alternate %s))\n",
|
||||
m_out->Quotew( pin->GetAlt() ).c_str() );
|
||||
m_out->Print( aNestLevel + 1, "(pin %s", m_out->Quotew( pin->GetNumber() ).c_str() );
|
||||
KICAD_FORMAT::FormatUuid( m_out, 0, pin->m_Uuid );
|
||||
m_out->Print( 0, " (alternate %s))\n", m_out->Quotew( pin->GetAlt() ).c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
@ -994,9 +993,7 @@ void SCH_IO_KICAD_SEXPR::saveBitmap( const SCH_BITMAP& aBitmap, int aNestLevel )
|
||||
if( scale != 1.0 )
|
||||
m_out->Print( 0, " (scale %g)", scale );
|
||||
|
||||
m_out->Print( 0, "\n" );
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aBitmap.m_Uuid );
|
||||
KICAD_FORMAT::FormatUuid( m_out, 0, aBitmap.m_Uuid, '\n' );
|
||||
|
||||
m_out->Print( aNestLevel + 1, "(data" );
|
||||
|
||||
@ -1059,7 +1056,7 @@ void SCH_IO_KICAD_SEXPR::saveSheet( SCH_SHEET* aSheet, const SCH_SHEET_LIST& aSh
|
||||
KiROUND( aSheet->GetBackgroundColor().b * 255.0 ),
|
||||
aSheet->GetBackgroundColor().a );
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aSheet->m_Uuid );
|
||||
KICAD_FORMAT::FormatUuid( m_out, aNestLevel + 1, aSheet->m_Uuid, '\n' );
|
||||
|
||||
m_nextFreeFieldId = SHEET_MANDATORY_FIELDS;
|
||||
|
||||
@ -1070,7 +1067,7 @@ void SCH_IO_KICAD_SEXPR::saveSheet( SCH_SHEET* aSheet, const SCH_SHEET_LIST& aSh
|
||||
|
||||
for( const SCH_SHEET_PIN* pin : aSheet->GetPins() )
|
||||
{
|
||||
m_out->Print( aNestLevel + 1, "(pin %s %s (at %s %s %s)\n",
|
||||
m_out->Print( aNestLevel + 1, "(pin %s %s (at %s %s %s)",
|
||||
EscapedUTF8( pin->GetText() ).c_str(),
|
||||
getSheetPinShapeToken( pin->GetShape() ),
|
||||
EDA_UNIT_UTILS::FormatInternalUnits( schIUScale,
|
||||
@ -1079,9 +1076,9 @@ void SCH_IO_KICAD_SEXPR::saveSheet( SCH_SHEET* aSheet, const SCH_SHEET_LIST& aSh
|
||||
pin->GetPosition().y ).c_str(),
|
||||
EDA_UNIT_UTILS::FormatAngle( getSheetPinAngle( pin->GetSide() ) ).c_str() );
|
||||
|
||||
pin->Format( m_out, aNestLevel + 1, 0 );
|
||||
KICAD_FORMAT::FormatUuid( m_out, 0, pin->m_Uuid, '\n' );
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, pin->m_Uuid );
|
||||
pin->Format( m_out, aNestLevel + 2, 0 );
|
||||
|
||||
m_out->Print( aNestLevel + 1, ")\n" ); // Closes pin token.
|
||||
}
|
||||
@ -1179,9 +1176,8 @@ void SCH_IO_KICAD_SEXPR::saveJunction( SCH_JUNCTION* aJunction, int aNestLevel )
|
||||
KiROUND( aJunction->GetColor().b * 255.0 ),
|
||||
FormatDouble2Str( aJunction->GetColor().a ).c_str() );
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aJunction->m_Uuid );
|
||||
|
||||
m_out->Print( aNestLevel, ")\n" );
|
||||
KICAD_FORMAT::FormatUuid( m_out, aNestLevel + 1, aJunction->m_Uuid );
|
||||
m_out->Print( 0, ")\n" );
|
||||
}
|
||||
|
||||
|
||||
@ -1194,8 +1190,8 @@ void SCH_IO_KICAD_SEXPR::saveNoConnect( SCH_NO_CONNECT* aNoConnect, int aNestLev
|
||||
aNoConnect->GetPosition().x ).c_str(),
|
||||
EDA_UNIT_UTILS::FormatInternalUnits( schIUScale,
|
||||
aNoConnect->GetPosition().y ).c_str() );
|
||||
KICAD_FORMAT::FormatUuid( m_out, aNoConnect->m_Uuid );
|
||||
m_out->Print( aNestLevel, ")\n" );
|
||||
KICAD_FORMAT::FormatUuid( m_out, 0, aNoConnect->m_Uuid );
|
||||
m_out->Print( 0, ")\n" );
|
||||
}
|
||||
|
||||
|
||||
@ -1227,9 +1223,8 @@ void SCH_IO_KICAD_SEXPR::saveBusEntry( SCH_BUS_ENTRY_BASE* aBusEntry, int aNestL
|
||||
|
||||
m_out->Print( 0, "\n" );
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aBusEntry->m_Uuid );
|
||||
|
||||
m_out->Print( aNestLevel, ")\n" );
|
||||
KICAD_FORMAT::FormatUuid( m_out, aNestLevel + 1, aBusEntry->m_Uuid );
|
||||
m_out->Print( 0, ")\n" );
|
||||
}
|
||||
}
|
||||
|
||||
@ -1312,9 +1307,8 @@ void SCH_IO_KICAD_SEXPR::saveLine( SCH_LINE* aLine, int aNestLevel )
|
||||
line_stroke.Format( m_out, schIUScale, aNestLevel + 1 );
|
||||
m_out->Print( 0, "\n" );
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aLine->m_Uuid );
|
||||
|
||||
m_out->Print( aNestLevel, ")\n" );
|
||||
KICAD_FORMAT::FormatUuid( m_out, aNestLevel + 1, aLine->m_Uuid );
|
||||
m_out->Print( 0, ")\n" );
|
||||
}
|
||||
|
||||
|
||||
@ -1389,9 +1383,9 @@ void SCH_IO_KICAD_SEXPR::saveText( SCH_TEXT* aText, int aNestLevel )
|
||||
m_out->Print( 0, " (fields_autoplaced yes)" );
|
||||
|
||||
m_out->Print( 0, "\n" );
|
||||
aText->EDA_TEXT::Format( m_out, aNestLevel, 0 );
|
||||
aText->EDA_TEXT::Format( m_out, aNestLevel + 1, 0 );
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aText->m_Uuid );
|
||||
KICAD_FORMAT::FormatUuid( m_out, aNestLevel + 1, aText->m_Uuid );
|
||||
|
||||
if( label )
|
||||
{
|
||||
@ -1399,7 +1393,7 @@ void SCH_IO_KICAD_SEXPR::saveText( SCH_TEXT* aText, int aNestLevel )
|
||||
saveField( &field, aNestLevel + 1 );
|
||||
}
|
||||
|
||||
m_out->Print( aNestLevel, ")\n" ); // Closes text token.
|
||||
m_out->Print( 0, ")\n" ); // Closes text token.
|
||||
}
|
||||
|
||||
|
||||
@ -1443,9 +1437,9 @@ void SCH_IO_KICAD_SEXPR::saveTextBox( SCH_TEXTBOX* aTextBox, int aNestLevel )
|
||||
aTextBox->EDA_TEXT::Format( m_out, aNestLevel, 0 );
|
||||
|
||||
if( aTextBox->m_Uuid != niluuid )
|
||||
KICAD_FORMAT::FormatUuid( m_out, aTextBox->m_Uuid );
|
||||
KICAD_FORMAT::FormatUuid( m_out, aNestLevel + 1, aTextBox->m_Uuid );
|
||||
|
||||
m_out->Print( aNestLevel, ")\n" );
|
||||
m_out->Print( 0, ")\n" );
|
||||
}
|
||||
|
||||
|
||||
|
@ -37,9 +37,10 @@ namespace KICAD_FORMAT {
|
||||
* @param aSuffix is the character to format after the end of the boolean (after the close paren)
|
||||
*/
|
||||
KICOMMON_API void FormatBool( OUTPUTFORMATTER* aOut, int aNestLevel, const wxString& aKey,
|
||||
bool aValue, char aSuffix = '\n' );
|
||||
bool aValue, char aSuffix = 0 );
|
||||
|
||||
KICOMMON_API void FormatUuid( OUTPUTFORMATTER* aOut, const KIID& aUuid, char aSuffix = '\n' );
|
||||
KICOMMON_API void FormatUuid( OUTPUTFORMATTER* aOut, int aNestLevel, const KIID& aUuid,
|
||||
char aSuffix = 0 );
|
||||
|
||||
KICOMMON_API void Prettify( std::string& aSource, char aQuoteChar = '"' );
|
||||
|
||||
|
@ -604,22 +604,22 @@ void PCB_IO_KICAD_SEXPR::formatSetup( const BOARD* aBoard, int aNestLevel ) cons
|
||||
}
|
||||
|
||||
KICAD_FORMAT::FormatBool( m_out, aNestLevel + 1, "allow_soldermask_bridges_in_footprints",
|
||||
dsnSettings.m_AllowSoldermaskBridgesInFPs );
|
||||
dsnSettings.m_AllowSoldermaskBridgesInFPs, '\n' );
|
||||
|
||||
m_out->Print( 0, " (tenting " );
|
||||
m_out->Print( aNestLevel + 1, "(tenting" );
|
||||
|
||||
if( dsnSettings.m_TentViasFront || dsnSettings.m_TentViasBack )
|
||||
{
|
||||
if( dsnSettings.m_TentViasFront )
|
||||
m_out->Print( 0, "front " );
|
||||
m_out->Print( 0, " front" );
|
||||
if( dsnSettings.m_TentViasBack )
|
||||
m_out->Print( 0, "back " );
|
||||
m_out->Print( 0, " back" );
|
||||
|
||||
m_out->Print( 0, ")" );
|
||||
m_out->Print( 0, ")\n" );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_out->Print( 0, " none)" );
|
||||
m_out->Print( 0, " none)\n" );
|
||||
}
|
||||
|
||||
VECTOR2I origin = dsnSettings.GetAuxOrigin();
|
||||
@ -657,7 +657,7 @@ void PCB_IO_KICAD_SEXPR::formatGeneral( const BOARD* aBoard, int aNestLevel ) co
|
||||
formatInternalUnits( dsnSettings.GetBoardThickness() ).c_str() );
|
||||
|
||||
KICAD_FORMAT::FormatBool( m_out, aNestLevel + 1, "legacy_teardrops",
|
||||
aBoard->LegacyTeardrops() );
|
||||
aBoard->LegacyTeardrops(), '\n' );
|
||||
|
||||
m_out->Print( aNestLevel, ")\n\n" );
|
||||
|
||||
@ -787,11 +787,9 @@ void PCB_IO_KICAD_SEXPR::formatTeardropParameters( const TEARDROP_PARAMETERS& td
|
||||
tdParams.m_CurveSegCount,
|
||||
FormatDouble2Str( tdParams.m_WidthtoSizeFilterRatio ).c_str() );
|
||||
|
||||
KICAD_FORMAT::FormatBool( m_out, aNestLevel, "enabled", tdParams.m_Enabled );
|
||||
KICAD_FORMAT::FormatBool( m_out, aNestLevel, "allow_two_segments",
|
||||
tdParams.m_AllowUseTwoTracks );
|
||||
KICAD_FORMAT::FormatBool( m_out, aNestLevel, "prefer_zone_connections",
|
||||
!tdParams.m_TdOnPadsInZones );
|
||||
KICAD_FORMAT::FormatBool( m_out, 0, "enabled", tdParams.m_Enabled );
|
||||
KICAD_FORMAT::FormatBool( m_out, 0, "allow_two_segments", tdParams.m_AllowUseTwoTracks );
|
||||
KICAD_FORMAT::FormatBool( m_out, 0, "prefer_zone_connections", !tdParams.m_TdOnPadsInZones );
|
||||
m_out->Print( aNestLevel, ")" );
|
||||
}
|
||||
|
||||
@ -899,11 +897,11 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_DIMENSION_BASE* aDimension, int aNest
|
||||
wxFAIL_MSG( wxT( "Cannot format unknown dimension type!" ) );
|
||||
|
||||
if( aDimension->IsLocked() )
|
||||
KICAD_FORMAT::FormatBool( m_out, aNestLevel + 1, "locked", aDimension->IsLocked() );
|
||||
KICAD_FORMAT::FormatBool( m_out, 0, "locked", aDimension->IsLocked() );
|
||||
|
||||
formatLayer( aDimension->GetLayer() );
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aDimension->m_Uuid );
|
||||
KICAD_FORMAT::FormatUuid( m_out, 0, aDimension->m_Uuid, '\n' );
|
||||
|
||||
m_out->Print( aNestLevel+1, "(pts (xy %s %s) (xy %s %s))\n",
|
||||
formatInternalUnits( aDimension->GetStart().x ).c_str(),
|
||||
@ -1065,9 +1063,6 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_SHAPE* aShape, int aNestLevel ) const
|
||||
return;
|
||||
};
|
||||
|
||||
if( aShape->IsLocked() )
|
||||
KICAD_FORMAT::FormatBool( m_out, aNestLevel + 1, "locked", aShape->IsLocked() );
|
||||
|
||||
aShape->GetStroke().Format( m_out, pcbIUScale, aNestLevel + 1 );
|
||||
|
||||
// The filled flag represents if a solid fill is present on circles, rectangles and polygons
|
||||
@ -1078,6 +1073,9 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_SHAPE* aShape, int aNestLevel ) const
|
||||
m_out->Print( 0, aShape->IsFilled() ? " (fill solid)" : " (fill none)" );
|
||||
}
|
||||
|
||||
if( aShape->IsLocked() )
|
||||
KICAD_FORMAT::FormatBool( m_out, 0, "locked", aShape->IsLocked() );
|
||||
|
||||
if( aShape->GetLayerSet().count() > 1 )
|
||||
formatLayers( aShape->GetLayerSet() );
|
||||
else
|
||||
@ -1094,7 +1092,7 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_SHAPE* aShape, int aNestLevel ) const
|
||||
if( aShape->GetNetCode() > 0 )
|
||||
m_out->Print( 0, " (net %d)", m_mapping->Translate( aShape->GetNetCode() ) );
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aShape->m_Uuid, 0 );
|
||||
KICAD_FORMAT::FormatUuid( m_out, 0, aShape->m_Uuid );
|
||||
|
||||
m_out->Print( 0, ")\n" );
|
||||
}
|
||||
@ -1122,6 +1120,7 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_REFERENCE_IMAGE* aBitmap, int aNestLe
|
||||
if( const bool locked = aBitmap->IsLocked() )
|
||||
KICAD_FORMAT::FormatBool( m_out, 0, "locked", locked );
|
||||
|
||||
m_out->Print( 0, "\n" );
|
||||
m_out->Print( aNestLevel + 1, "(data" );
|
||||
|
||||
wxString out = wxBase64Encode( refImage.GetImage().GetImageDataBuffer() );
|
||||
@ -1142,9 +1141,8 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_REFERENCE_IMAGE* aBitmap, int aNestLe
|
||||
m_out->Print( 0, "\n" );
|
||||
m_out->Print( aNestLevel + 1, ")\n" ); // Closes data token.
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aBitmap->m_Uuid, 0 );
|
||||
|
||||
m_out->Print( aNestLevel, ")\n" ); // Closes image token.
|
||||
KICAD_FORMAT::FormatUuid( m_out, aNestLevel + 1, aBitmap->m_Uuid );
|
||||
m_out->Print( 0, ")\n" ); // Closes image token.
|
||||
}
|
||||
|
||||
|
||||
@ -1160,8 +1158,7 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_TARGET* aTarget, int aNestLevel ) con
|
||||
|
||||
formatLayer( aTarget->GetLayer() );
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aTarget->m_Uuid, 0 );
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, 0, aTarget->m_Uuid );
|
||||
m_out->Print( 0, ")\n" );
|
||||
}
|
||||
|
||||
@ -1197,21 +1194,17 @@ void PCB_IO_KICAD_SEXPR::format( const FOOTPRINT* aFootprint, int aNestLevel ) c
|
||||
SEXPR_BOARD_FILE_VERSION, GetMajorMinorVersion().c_str().AsChar() );
|
||||
|
||||
if( const bool locked = aFootprint->IsLocked() )
|
||||
{
|
||||
KICAD_FORMAT::FormatBool( m_out, 0, "locked", locked );
|
||||
}
|
||||
KICAD_FORMAT::FormatBool( m_out, aNestLevel + 1, "locked", locked, '\n' );
|
||||
|
||||
if( const bool placed = aFootprint->IsPlaced() )
|
||||
{
|
||||
KICAD_FORMAT::FormatBool( m_out, 0, "placed", placed );
|
||||
}
|
||||
KICAD_FORMAT::FormatBool( m_out, aNestLevel + 1, "placed", placed, '\n' );
|
||||
|
||||
m_out->Print( aNestLevel + 1, "" );
|
||||
formatLayer( aFootprint->GetLayer() );
|
||||
|
||||
m_out->Print( 0, "\n" );
|
||||
|
||||
if( !( m_ctl & CTL_OMIT_UUIDS ) )
|
||||
KICAD_FORMAT::FormatUuid( m_out, aFootprint->m_Uuid );
|
||||
KICAD_FORMAT::FormatUuid( m_out, aNestLevel+1, aFootprint->m_Uuid, '\n' );
|
||||
|
||||
if( !( m_ctl & CTL_OMIT_AT ) )
|
||||
{
|
||||
@ -1421,7 +1414,7 @@ void PCB_IO_KICAD_SEXPR::format( const FOOTPRINT* aFootprint, int aNestLevel ) c
|
||||
m_out->Quotew( bs3D->m_Filename ).c_str() );
|
||||
|
||||
if( !bs3D->m_Show )
|
||||
KICAD_FORMAT::FormatBool( m_out, aNestLevel + 1, "hide", !bs3D->m_Show );
|
||||
KICAD_FORMAT::FormatBool( m_out, aNestLevel + 1, "hide", !bs3D->m_Show, '\n' );
|
||||
|
||||
if( bs3D->m_Opacity != 1.0 )
|
||||
m_out->Print( aNestLevel+2, "(opacity %0.4f)", bs3D->m_Opacity );
|
||||
@ -1952,7 +1945,7 @@ void PCB_IO_KICAD_SEXPR::format( const PAD* aPad, int aNestLevel ) const
|
||||
|
||||
formatTenting( aPad->Padstack() );
|
||||
|
||||
m_out->Print( 0, "\n" );
|
||||
KICAD_FORMAT::FormatUuid( m_out, 0, aPad->m_Uuid );
|
||||
|
||||
// TODO: Refactor so that we call formatPadLayer( ALL_LAYERS ) above instead of redundant code
|
||||
auto formatPadLayer =
|
||||
@ -2035,20 +2028,22 @@ void PCB_IO_KICAD_SEXPR::format( const PAD* aPad, int aNestLevel ) const
|
||||
|
||||
if( aPad->Padstack().Mode() != PADSTACK::MODE::NORMAL )
|
||||
{
|
||||
std::string mode =
|
||||
aPad->Padstack().Mode() == PADSTACK::MODE::CUSTOM ? "custom" : "front_inner_back";
|
||||
m_out->Print( 0, "(padstack (mode %s)", mode.c_str() );
|
||||
m_out->Print( 0, "\n" );
|
||||
|
||||
if( aPad->Padstack().Mode() == PADSTACK::MODE::FRONT_INNER_BACK )
|
||||
{
|
||||
m_out->Print( 0, "(layer \"Inner\"" );
|
||||
m_out->Print( aNestLevel+1, "(padstack (mode front_inner_back)" );
|
||||
|
||||
m_out->Print( 0, " (layer \"Inner\"" );
|
||||
formatPadLayer( PADSTACK::INNER_LAYERS );
|
||||
m_out->Print( 0, ")(layer \"B.Cu\"" );
|
||||
m_out->Print( 0, ") (layer \"B.Cu\"" );
|
||||
formatPadLayer( B_Cu );
|
||||
m_out->Print( 0, ")" );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_out->Print( aNestLevel+1, "(padstack (mode custom)" );
|
||||
|
||||
int layerCount = board ? board->GetCopperLayerCount() : MAX_CU_LAYERS;
|
||||
|
||||
for( PCB_LAYER_ID layer : LAYER_RANGE( F_Cu, B_Cu, layerCount ) )
|
||||
@ -2056,7 +2051,7 @@ void PCB_IO_KICAD_SEXPR::format( const PAD* aPad, int aNestLevel ) const
|
||||
if( layer == F_Cu )
|
||||
continue;
|
||||
|
||||
m_out->Print( 0, "(layer %s", m_out->Quotew( LSET::Name( layer ) ).c_str() );
|
||||
m_out->Print( 0, " (layer %s", m_out->Quotew( LSET::Name( layer ) ).c_str() );
|
||||
formatPadLayer( layer );
|
||||
m_out->Print( 0, ")" );
|
||||
}
|
||||
@ -2065,8 +2060,7 @@ void PCB_IO_KICAD_SEXPR::format( const PAD* aPad, int aNestLevel ) const
|
||||
m_out->Print( 0, ")" );
|
||||
}
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aPad->m_Uuid );
|
||||
m_out->Print( aNestLevel, ")\n" );
|
||||
m_out->Print( 0, ")\n" );
|
||||
}
|
||||
|
||||
|
||||
@ -2146,7 +2140,7 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_TEXT* aText, int aNestLevel ) const
|
||||
if( parentFP && !aText->IsVisible() )
|
||||
KICAD_FORMAT::FormatBool( m_out, 0, "hide", !aText->IsVisible() );
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aText->m_Uuid );
|
||||
KICAD_FORMAT::FormatUuid( m_out, 0, aText->m_Uuid );
|
||||
|
||||
int ctl_flags = m_ctl | CTL_OMIT_HIDE;
|
||||
|
||||
@ -2154,6 +2148,7 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_TEXT* aText, int aNestLevel ) const
|
||||
// so ensure they are never written in kicad_pcb file
|
||||
ctl_flags |= CTL_OMIT_COLOR | CTL_OMIT_HYPERLINK;
|
||||
|
||||
m_out->Print( 0, "\n" );
|
||||
aText->EDA_TEXT::Format( m_out, aNestLevel, ctl_flags );
|
||||
|
||||
if( aText->GetFont() && aText->GetFont()->IsOutline() )
|
||||
@ -2175,7 +2170,7 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_TEXTBOX* aTextBox, int aNestLevel ) c
|
||||
m_out->Quotew( aTextBox->GetText() ).c_str() );
|
||||
|
||||
if( aTextBox->IsLocked() )
|
||||
KICAD_FORMAT::FormatBool( m_out, aNestLevel, "locked", aTextBox->IsLocked() );
|
||||
KICAD_FORMAT::FormatBool( m_out, aNestLevel, "locked", aTextBox->IsLocked(), '\n' );
|
||||
|
||||
if( aTextBox->GetShape() == SHAPE_T::RECTANGLE )
|
||||
{
|
||||
@ -2216,16 +2211,16 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_TEXTBOX* aTextBox, int aNestLevel ) c
|
||||
m_out->Print( aNestLevel + 1, "(angle %s)", EDA_UNIT_UTILS::FormatAngle( angle ).c_str() );
|
||||
|
||||
formatLayer( aTextBox->GetLayer() );
|
||||
m_out->Print( 0, "\n" );
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aTextBox->m_Uuid );
|
||||
KICAD_FORMAT::FormatUuid( m_out, 0, aTextBox->m_Uuid );
|
||||
|
||||
// PCB_TEXTBOXes are never hidden, so always omit "hide" attribute
|
||||
m_out->Print( 0, "\n" );
|
||||
aTextBox->EDA_TEXT::Format( m_out, aNestLevel, m_ctl | CTL_OMIT_HIDE );
|
||||
|
||||
if( aTextBox->Type() != PCB_TABLECELL_T )
|
||||
{
|
||||
KICAD_FORMAT::FormatBool( m_out, aNestLevel + 1, "border", aTextBox->IsBorderEnabled() );
|
||||
KICAD_FORMAT::FormatBool( m_out, aNestLevel + 1, "border", aTextBox->IsBorderEnabled(), '\n' );
|
||||
|
||||
aTextBox->GetStroke().Format( m_out, pcbIUScale, aNestLevel + 1 );
|
||||
}
|
||||
@ -2318,11 +2313,12 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_GROUP* aGroup, int aNestLevel ) const
|
||||
|
||||
m_out->Print( aNestLevel, "(group %s\n", m_out->Quotew( aGroup->GetName() ).c_str() );
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aGroup->m_Uuid );
|
||||
KICAD_FORMAT::FormatUuid( m_out, 0, aGroup->m_Uuid );
|
||||
|
||||
if( aGroup->IsLocked() )
|
||||
KICAD_FORMAT::FormatBool( m_out, aNestLevel + 1, "locked", aGroup->IsLocked() );
|
||||
KICAD_FORMAT::FormatBool( m_out, 0, "locked", aGroup->IsLocked() );
|
||||
|
||||
m_out->Print( 0, "\n" );
|
||||
m_out->Print( aNestLevel + 1, "(members\n" );
|
||||
|
||||
wxArrayString memberIds;
|
||||
@ -2342,11 +2338,11 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_GROUP* aGroup, int aNestLevel ) const
|
||||
|
||||
void PCB_IO_KICAD_SEXPR::format( const PCB_GENERATOR* aGenerator, int aNestLevel ) const
|
||||
{
|
||||
m_out->Print( aNestLevel, "(generated\n" );
|
||||
m_out->Print( aNestLevel, "(generated" );
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aGenerator->m_Uuid );
|
||||
KICAD_FORMAT::FormatUuid( m_out, 0, aGenerator->m_Uuid );
|
||||
|
||||
m_out->Print( aNestLevel + 1, "(type %s) (name %s)\n",
|
||||
m_out->Print( 0, "(type %s) (name %s)\n",
|
||||
TO_UTF8( aGenerator->GetGeneratorType() ),
|
||||
m_out->Quotew( aGenerator->GetName() ).c_str() );
|
||||
|
||||
@ -2604,8 +2600,7 @@ void PCB_IO_KICAD_SEXPR::format( const PCB_TRACK* aTrack, int aNestLevel ) const
|
||||
|
||||
m_out->Print( 0, " (net %d)", m_mapping->Translate( aTrack->GetNetCode() ) );
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aTrack->m_Uuid );
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, 0, aTrack->m_Uuid );
|
||||
m_out->Print( 0, ")\n" );
|
||||
}
|
||||
|
||||
@ -2641,7 +2636,7 @@ void PCB_IO_KICAD_SEXPR::format( const ZONE* aZone, int aNestLevel ) const
|
||||
formatLayer( aZone->GetFirstLayer() );
|
||||
}
|
||||
|
||||
KICAD_FORMAT::FormatUuid( m_out, aZone->m_Uuid );
|
||||
KICAD_FORMAT::FormatUuid( m_out, 0, aZone->m_Uuid );
|
||||
|
||||
if( !aZone->GetZoneName().empty() )
|
||||
m_out->Print( 0, " (name %s)", m_out->Quotew( aZone->GetZoneName() ).c_str() );
|
||||
|
@ -185,19 +185,19 @@ void PCB_PLOT_PARAMS::Format( OUTPUTFORMATTER* aFormatter,
|
||||
m_plotOnAllLayersSelection.FmtHex().c_str() );
|
||||
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "disableapertmacros",
|
||||
m_gerberDisableApertMacros );
|
||||
m_gerberDisableApertMacros, '\n' );
|
||||
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "usegerberextensions",
|
||||
m_useGerberProtelExtensions );
|
||||
m_useGerberProtelExtensions, '\n' );
|
||||
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "usegerberattributes",
|
||||
GetUseGerberX2format() );
|
||||
GetUseGerberX2format(), '\n' );
|
||||
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "usegerberadvancedattributes",
|
||||
GetIncludeGerberNetlistInfo() );
|
||||
GetIncludeGerberNetlistInfo(), '\n' );
|
||||
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "creategerberjobfile",
|
||||
GetCreateGerberJobFile() );
|
||||
GetCreateGerberJobFile(), '\n' );
|
||||
|
||||
// save this option only if it is not the default value,
|
||||
// to avoid incompatibility with older Pcbnew version
|
||||
@ -210,9 +210,9 @@ void PCB_PLOT_PARAMS::Format( OUTPUTFORMATTER* aFormatter,
|
||||
// SVG options
|
||||
aFormatter->Print( aNestLevel+1, "(svgprecision %d)\n", m_svgPrecision );
|
||||
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "plotframeref", m_plotDrawingSheet );
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "plotframeref", m_plotDrawingSheet, '\n' );
|
||||
aFormatter->Print( aNestLevel+1, "(mode %d)\n", GetPlotMode() == SKETCH ? 2 : 1 );
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "useauxorigin", m_useAuxOrigin );
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "useauxorigin", m_useAuxOrigin, '\n' );
|
||||
|
||||
// HPGL options
|
||||
aFormatter->Print( aNestLevel+1, "(hpglpennumber %d)\n", m_HPGLPenNum );
|
||||
@ -222,36 +222,36 @@ void PCB_PLOT_PARAMS::Format( OUTPUTFORMATTER* aFormatter,
|
||||
// PDF options
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1,
|
||||
getTokenName( T_pdf_front_fp_property_popups ),
|
||||
m_PDFFrontFPPropertyPopups );
|
||||
m_PDFFrontFPPropertyPopups, '\n' );
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1,
|
||||
getTokenName( T_pdf_back_fp_property_popups ),
|
||||
m_PDFBackFPPropertyPopups );
|
||||
m_PDFBackFPPropertyPopups, '\n' );
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1,
|
||||
getTokenName( T_pdf_metadata ),
|
||||
m_PDFMetadata );
|
||||
m_PDFMetadata, '\n' );
|
||||
|
||||
// DXF options
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, getTokenName( T_dxfpolygonmode ),
|
||||
m_DXFPolygonMode );
|
||||
m_DXFPolygonMode, '\n' );
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, getTokenName( T_dxfimperialunits ),
|
||||
m_DXFUnits == DXF_UNITS::INCHES );
|
||||
m_DXFUnits == DXF_UNITS::INCHES, '\n' );
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, getTokenName( T_dxfusepcbnewfont ),
|
||||
m_textMode != PLOT_TEXT_MODE::NATIVE );
|
||||
m_textMode != PLOT_TEXT_MODE::NATIVE, '\n' );
|
||||
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, getTokenName( T_psnegative ),
|
||||
m_negative );
|
||||
m_negative, '\n' );
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, getTokenName( T_psa4output ),
|
||||
m_A4Output );
|
||||
m_A4Output, '\n' );
|
||||
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "plotinvisibletext", m_plotInvisibleText );
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "sketchpadsonfab", m_sketchPadsOnFabLayers );
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "plotpadnumbers", m_plotPadNumbers );
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "hidednponfab", m_hideDNPFPsOnFabLayers );
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "sketchdnponfab", m_sketchDNPFPsOnFabLayers );
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "crossoutdnponfab", m_crossoutDNPFPsOnFabLayers );
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "subtractmaskfromsilk", m_subtractMaskFromSilk );
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "plotinvisibletext", m_plotInvisibleText, '\n' );
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "sketchpadsonfab", m_sketchPadsOnFabLayers, '\n' );
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "plotpadnumbers", m_plotPadNumbers, '\n' );
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "hidednponfab", m_hideDNPFPsOnFabLayers, '\n' );
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "sketchdnponfab", m_sketchDNPFPsOnFabLayers, '\n' );
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "crossoutdnponfab", m_crossoutDNPFPsOnFabLayers, '\n' );
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "subtractmaskfromsilk", m_subtractMaskFromSilk, '\n' );
|
||||
aFormatter->Print( aNestLevel+1, "(outputformat %d)\n", static_cast<int>( m_format ) );
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "mirror", m_mirror );
|
||||
KICAD_FORMAT::FormatBool( aFormatter, aNestLevel + 1, "mirror", m_mirror, '\n' );
|
||||
aFormatter->Print( aNestLevel+1, "(drillshape %d)\n", (int)m_drillMarks );
|
||||
aFormatter->Print( aNestLevel+1, "(scaleselection %d)\n", m_scaleSelection );
|
||||
aFormatter->Print( aNestLevel+1, "(outputdirectory \"%s\")",
|
||||
|
Loading…
Reference in New Issue
Block a user