From 1ec47a053baf50c3d7b57a0efbbd2d4dfc03fb6e Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 22 Apr 2025 18:19:24 +0100 Subject: [PATCH] Don't save UUIDs for teardrop zones. They're really just a geometry cache. Also removes writing of filled_areas_thickness, which hasn't been supported in yonks. Also cleans up writing of island removal strategy (the limit is only needed in limit mode). Fixes https://gitlab.com/kicad/code/kicad/-/issues/20717 --- common/io/kicad/kicad_io_utils.cpp | 2 +- .../pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp | 32 ++++++++++--------- .../kicad_sexpr/pcb_io_kicad_sexpr_parser.cpp | 10 +++--- pcbnew/teardrop/teardrop.cpp | 2 -- pcbnew/teardrop/teardrop.h | 2 -- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/common/io/kicad/kicad_io_utils.cpp b/common/io/kicad/kicad_io_utils.cpp index a2561ff59a..922cbce486 100644 --- a/common/io/kicad/kicad_io_utils.cpp +++ b/common/io/kicad/kicad_io_utils.cpp @@ -172,7 +172,7 @@ void Prettify( std::string& aSource, bool aCompactSave ) while( ++seek != aSource.end() && isalpha( *seek ) ) token += *seek; - return token == "font" || token == "stroke" || token == "fill" + return token == "font" || token == "stroke" || token == "fill" || token == "teardrop" || token == "offset" || token == "rotate" || token == "scale"; }; diff --git a/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp b/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp index db57f3686b..a72e1b7461 100644 --- a/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp +++ b/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp @@ -2541,9 +2541,10 @@ void PCB_IO_KICAD_SEXPR::format( const ZONE* aZone ) const else formatLayer( aZone->GetFirstLayer() ); - KICAD_FORMAT::FormatUuid( m_out, aZone->m_Uuid ); + if( !aZone->IsTeardropArea() ) + KICAD_FORMAT::FormatUuid( m_out, aZone->m_Uuid ); - if( !aZone->GetZoneName().empty() ) + if( !aZone->GetZoneName().empty() && !aZone->IsTeardropArea() ) m_out->Print( "(name %s)", m_out->Quotew( aZone->GetZoneName() ).c_str() ); // Save the outline aux info @@ -2565,13 +2566,12 @@ void PCB_IO_KICAD_SEXPR::format( const ZONE* aZone ) const if( aZone->GetAssignedPriority() > 0 ) m_out->Print( "(priority %d)", aZone->GetAssignedPriority() ); - // Add teardrop keywords in file: (attr (teardrop (type xxx)))where xxx is the teardrop type + // Add teardrop keywords in file: (attr (teardrop (type xxx))) where xxx is the teardrop type if( aZone->IsTeardropArea() ) { m_out->Print( "(attr (teardrop (type %s)))", - aZone->GetTeardropAreaType() == TEARDROP_TYPE::TD_VIAPAD - ? "padvia" - : "track_end" ); + aZone->GetTeardropAreaType() == TEARDROP_TYPE::TD_VIAPAD ? "padvia" + : "track_end" ); } m_out->Print( "(connect_pads" ); @@ -2603,9 +2603,6 @@ void PCB_IO_KICAD_SEXPR::format( const ZONE* aZone ) const m_out->Print( "(min_thickness %s)", formatInternalUnits( aZone->GetMinThickness() ).c_str() ); - // We continue to write this for 3rd-party parsers, but we no longer read it (as of V7). - m_out->Print( "(filled_areas_thickness no)" ); - if( aZone->GetIsRuleArea() ) { // Keepout settings @@ -2645,9 +2642,12 @@ void PCB_IO_KICAD_SEXPR::format( const ZONE* aZone ) const if( aZone->GetFillMode() == ZONE_FILL_MODE::HATCH_PATTERN ) m_out->Print( "(mode hatch)" ); - m_out->Print( "(thermal_gap %s) (thermal_bridge_width %s)", - formatInternalUnits( aZone->GetThermalReliefGap() ).c_str(), - formatInternalUnits( aZone->GetThermalReliefSpokeWidth() ).c_str() ); + if( !aZone->IsTeardropArea() ) + { + m_out->Print( "(thermal_gap %s) (thermal_bridge_width %s)", + formatInternalUnits( aZone->GetThermalReliefGap() ).c_str(), + formatInternalUnits( aZone->GetThermalReliefSpokeWidth() ).c_str() ); + } if( aZone->GetCornerSmoothingType() != ZONE_SETTINGS::SMOOTHING_NONE ) { @@ -2670,10 +2670,12 @@ void PCB_IO_KICAD_SEXPR::format( const ZONE* aZone ) const m_out->Print( "(radius %s)", formatInternalUnits( aZone->GetCornerRadius() ).c_str() ); } - if( aZone->GetIslandRemovalMode() != ISLAND_REMOVAL_MODE::ALWAYS ) + m_out->Print( "(island_removal_mode %d)", + static_cast( aZone->GetIslandRemovalMode() ) ); + + if( aZone->GetIslandRemovalMode() == ISLAND_REMOVAL_MODE::AREA ) { - m_out->Print( "(island_removal_mode %d) (island_area_min %s)", - static_cast( aZone->GetIslandRemovalMode() ), + m_out->Print( "(island_area_min %s)", formatInternalUnits( aZone->GetMinIslandArea() / pcbIUScale.IU_PER_MM ).c_str() ); } diff --git a/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr_parser.cpp b/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr_parser.cpp index bb2c785079..a2c29ae684 100644 --- a/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr_parser.cpp +++ b/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr_parser.cpp @@ -6872,7 +6872,10 @@ ZONE* PCB_IO_KICAD_SEXPR_PARSER::parseZONE( BOARD_ITEM_CONTAINER* aParent ) std::map> legacySegs; PCB_LAYER_ID filledLayer; bool addedFilledPolygons = false; - bool isStrokedFill = true; + + // This hasn't been supported since V6 or so, but we only stopped writing out the token + // in V10. + bool isStrokedFill = m_requiredVersion < 20250210; std::unique_ptr zone = std::make_unique( aParent ); @@ -7473,9 +7476,8 @@ ZONE* PCB_IO_KICAD_SEXPR_PARSER::parseZONE( BOARD_ITEM_CONTAINER* aParent ) { if( m_showLegacy5ZoneWarning ) { - wxLogWarning( - _( "Legacy zone fill strategy is not supported anymore.\nZone fills will " - "be converted on best-effort basis." ) ); + wxLogWarning( _( "Legacy zone fill strategy is not supported anymore.\n" + "Zone fills will be converted on best-effort basis." ) ); m_showLegacy5ZoneWarning = false; } diff --git a/pcbnew/teardrop/teardrop.cpp b/pcbnew/teardrop/teardrop.cpp index 594f5b725a..66a9b1943e 100644 --- a/pcbnew/teardrop/teardrop.cpp +++ b/pcbnew/teardrop/teardrop.cpp @@ -72,8 +72,6 @@ ZONE* TEARDROP_MANAGER::createTeardrop( TEARDROP_VARIANT aTeardropVariant, teardrop->SetMinThickness( pcbIUScale.mmToIU( 0.0254 ) ); // The minimum zone thickness teardrop->SetPadConnection( ZONE_CONNECTION::FULL ); teardrop->SetIsFilled( false ); - teardrop->SetZoneName( aTeardropVariant == TD_TYPE_PADVIA ? MAGIC_TEARDROP_PADVIA_NAME - : MAGIC_TEARDROP_TRACK_NAME ); teardrop->SetIslandRemovalMode( ISLAND_REMOVAL_MODE::NEVER ); teardrop->SetBorderDisplayStyle( ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_FULL, pcbIUScale.mmToIU( 0.1 ), true ); diff --git a/pcbnew/teardrop/teardrop.h b/pcbnew/teardrop/teardrop.h index c909f76113..cebd9c6cab 100644 --- a/pcbnew/teardrop/teardrop.h +++ b/pcbnew/teardrop/teardrop.h @@ -34,8 +34,6 @@ #include #include "teardrop_parameters.h" -#define MAGIC_TEARDROP_PADVIA_NAME "$teardrop_padvia$" -#define MAGIC_TEARDROP_TRACK_NAME "$teardrop_track$" // A class to store tracks grouped by layer and netcode class TRACK_BUFFER