Fix loading of legacy zone fills in .brd files + Don't refill after board import

(cherry picked from commit 30a63b7b32)
This commit is contained in:
Roberto Fernandez Bautista 2023-08-02 19:28:26 +02:00 committed by Alex Shvartzkop
parent af5b6b0eba
commit 88f65f4e47
3 changed files with 29 additions and 49 deletions

View File

@ -980,31 +980,6 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
GetBoard()->Show( 0, std::cout );
#endif
// Re-fill any zones which had their legacy fills deleted on open
for( ZONE* zone : GetBoard()->Zones() )
{
if( zone->GetFlags() & CANDIDATE )
{
toFill.push_back( zone );
zone->ClearTempFlags();
}
}
if( toFill.size() )
{
BOARD_COMMIT commit( this );
ZONE_FILLER filler( GetBoard(), &commit );
progressReporter.Report( _( "Converting zone fills" ) );
filler.SetProgressReporter( &progressReporter );
if( filler.Fill( toFill ) )
commit.Push( _( "Convert Zone(s)" ), SKIP_CONNECTIVITY );
rebuildConnectivity();
}
// from EDA_APPL which was first loaded BOARD only:
{
/* For an obscure reason the focus is lost after loading a board file

View File

@ -5672,7 +5672,7 @@ ZONE* PCB_PARSER::parseZONE( BOARD_ITEM_CONTAINER* aParent )
case T_segment: // deprecated, convert to polygons
case T_polygon:
default:
default:
zone->SetFillMode( ZONE_FILL_MODE::POLYGONS ); break;
}
@ -5958,11 +5958,11 @@ ZONE* PCB_PARSER::parseZONE( BOARD_ITEM_CONTAINER* aParent )
// Legacy zones only had one layer
filledLayer = zone->GetFirstLayer();
SEG fillSegment;
fillSegment.A = parseXY();
fillSegment.B = parseXY();
fillSegment.B = parseXY();
legacySegs[filledLayer].push_back( fillSegment );
@ -6079,7 +6079,7 @@ ZONE* PCB_PARSER::parseZONE( BOARD_ITEM_CONTAINER* aParent )
}
}
}
for( auto& [layer, polyset] : pts )
zone->SetFilledPolysList( layer, polyset );
@ -6117,12 +6117,12 @@ ZONE* PCB_PARSER::parseZONE( BOARD_ITEM_CONTAINER* aParent )
layerFill.BooleanAdd( segPolygon, SHAPE_POLY_SET::PM_FAST );
}
zone->SetFilledPolysList( layer, layerFill );
zone->CalculateFilledArea();
}
}
// Ensure keepout and non copper zones do not have a net
// (which have no sense for these zones)

View File

@ -2340,6 +2340,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER()
ZONE_BORDER_DISPLAY_STYLE outline_hatch = ZONE_BORDER_DISPLAY_STYLE::NO_HATCH;
bool endContour = false;
bool segmentFill = false;
int holeIndex = -1; // -1 is the main outline; holeIndex >= 0 = hole index
char buf[1024];
char* line;
@ -2475,33 +2476,22 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER()
if( fillmode)
{
// SEGMENT fill mode no longer supported. Make sure user is OK with converting
// them.
segmentFill = true;
if( m_showLegacySegmentZoneWarning )
{
KIDIALOG dlg( nullptr,
_( "The legacy segment fill mode is no longer supported.\n"
"Convert zones to smoothed polygon fills?" ),
_( "Legacy Zone Warning" ),
wxYES_NO | wxICON_WARNING );
dlg.DoNotShowCheckbox( __FILE__, __LINE__ );
if( dlg.ShowModal() == wxID_NO )
THROW_IO_ERROR( wxT( "CANCEL" ) );
wxLogWarning( _( "The legacy segment zone fill mode is no longer supported.\n"
"Zone fills will be converted on a best-effort basis." ) );
m_showLegacySegmentZoneWarning = false;
}
// User OK'd; switch to polygon mode
zc->SetFillMode( ZONE_FILL_MODE::POLYGONS );
m_board->SetModified();
}
else
{
zc->SetFillMode( ZONE_FILL_MODE::POLYGONS );
segmentFill = false;
}
zc->SetFillMode( ZONE_FILL_MODE::POLYGONS );
zc->SetIsFilled( fillstate == 'S' );
zc->SetThermalReliefGap( thermalReliefGap );
zc->SetThermalReliefSpokeWidth( thermalReliefCopperBridge );
@ -2566,7 +2556,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER()
makeNewOutline = end_contour;
}
zc->SetFilledPolysList( zc->GetLayer(), polysList );
zc->SetFilledPolysList( zc->GetFirstLayer(), polysList );
}
else if( TESTLINE( "$FILLSEGMENTS" ) )
{
@ -2589,6 +2579,21 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER()
if( zc->GetIsRuleArea() )
zc->SetNetCode( NETINFO_LIST::UNCONNECTED );
if( zc->GetMinThickness() > 0 )
{
// Inflate the fill polygon
PCB_LAYER_ID layer = zc->GetFirstLayer();
SHAPE_POLY_SET inflatedFill = SHAPE_POLY_SET( *zc->GetFilledPolysList( layer ) );
int numSegs =
GetArcToSegmentCount( zc->GetMinThickness(), ARC_HIGH_DEF, FULL_CIRCLE );
inflatedFill.InflateWithLinkedHoles( zc->GetMinThickness() / 2, numSegs,
SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
zc->SetFilledPolysList( layer, inflatedFill );
}
// should always occur, but who knows, a zone without two corners
// is no zone at all, it's a spot?