Fix reading legacy zone fills which were based on stroked polygons.

This commit is contained in:
Alex Shvartzkop 2023-07-20 19:50:13 +05:00
parent ef66fe88ac
commit 448de72823
1 changed files with 24 additions and 36 deletions

View File

@ -5112,23 +5112,12 @@ ZONE* PCB_PARSER::parseZONE( BOARD_ITEM_CONTAINER* aParent )
std::map<PCB_LAYER_ID, SHAPE_POLY_SET> pts; std::map<PCB_LAYER_ID, SHAPE_POLY_SET> pts;
PCB_LAYER_ID filledLayer; PCB_LAYER_ID filledLayer;
bool addedFilledPolygons = false; bool addedFilledPolygons = false;
bool dropFilledPolygons = false; bool isStrokedFill = true;
std::unique_ptr<ZONE> zone = std::make_unique<ZONE>( aParent ); std::unique_ptr<ZONE> zone = std::make_unique<ZONE>( aParent );
zone->SetAssignedPriority( 0 ); zone->SetAssignedPriority( 0 );
bool isLegacy = false;
if( m_requiredVersion < 20210606 )
{
// A new zone fill strategy was added in v6, so we need to know if we're parsing
// a file that was written before that date. Note that the change was implemented as
// a new parameter without changing the version number, so we need to check for the
// presence of the new parameter instead of just the version number.
isLegacy = true;
}
// This is the default for board files: // This is the default for board files:
zone->SetIslandRemovalMode( ISLAND_REMOVAL_MODE::ALWAYS ); zone->SetIslandRemovalMode( ISLAND_REMOVAL_MODE::ALWAYS );
@ -5245,9 +5234,13 @@ ZONE* PCB_PARSER::parseZONE( BOARD_ITEM_CONTAINER* aParent )
break; break;
case T_filled_areas_thickness: case T_filled_areas_thickness:
// A new zone fill strategy was added in v6, so we need to know if we're parsing
// a zone that was filled before that. Note that the change was implemented as
// a new parameter, so we need to check for the presence of filled_areas_thickness
// instead of just its value.
if( parseBool() ) if( !parseBool() )
isLegacy = true; isStrokedFill = false;
NeedRIGHT(); NeedRIGHT();
break; break;
@ -5675,36 +5668,31 @@ ZONE* PCB_PARSER::parseZONE( BOARD_ITEM_CONTAINER* aParent )
zone->SetBorderDisplayStyle( hatchStyle, hatchPitch, true ); zone->SetBorderDisplayStyle( hatchStyle, hatchPitch, true );
} }
if( isLegacy && !zone->GetIsRuleArea() ) if( addedFilledPolygons )
{ {
if( m_showLegacy5ZoneWarning ) if( isStrokedFill && !zone->GetIsRuleArea() )
{ {
if( Pgm().IsGUI() && m_queryUserCallback ) if( m_showLegacy5ZoneWarning && m_queryUserCallback )
{ {
if( !m_queryUserCallback( wxLogWarning(
_( "Legacy Zone Warning" ), wxICON_WARNING, _( "Legacy zone fill strategy is not supported anymore.\nZone fills will "
_( "The legacy zone fill strategy is no longer supported.\n" "be converted on best-effort basis." ) );
"Convert zones to smoothed polygon fills?" ),
_( "Convert" ) ) ) m_showLegacy5ZoneWarning = false;
}
if( zone->GetMinThickness() > 0 )
{
for( auto& pair : pts )
{ {
THROW_IO_ERROR( wxT( "CANCEL" ) ); pair.second.Inflate( zone->GetMinThickness() / 2,
SHAPE_POLY_SET::ROUND_ALL_CORNERS, ARC_HIGH_DEF / 2 );
pair.second.Simplify( SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
} }
} }
else
{
THROW_IO_ERROR( wxT( "Legacy zone fill strategy was found; "
"open the board in the PCB Editor to resolve." ) );
}
m_showLegacy5ZoneWarning = false;
} }
zone->SetFlags( CANDIDATE );
dropFilledPolygons = true;
}
if( addedFilledPolygons && !dropFilledPolygons )
{
for( auto& pair : pts ) for( auto& pair : pts )
zone->SetFilledPolysList( pair.first, pair.second ); zone->SetFilledPolysList( pair.first, pair.second );