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

This commit is contained in:
Roberto Fernandez Bautista 2023-08-02 19:28:26 +02:00
parent 44ff2f4858
commit 30a63b7b32
3 changed files with 28 additions and 49 deletions

View File

@ -982,31 +982,6 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
GetBoard()->Show( 0, std::cout ); GetBoard()->Show( 0, std::cout );
#endif #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: // from EDA_APPL which was first loaded BOARD only:
{ {
/* For an obscure reason the focus is lost after loading a board file /* For an obscure reason the focus is lost after loading a board file

View File

@ -2319,6 +2319,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER()
ZONE_BORDER_DISPLAY_STYLE outline_hatch = ZONE_BORDER_DISPLAY_STYLE::NO_HATCH; ZONE_BORDER_DISPLAY_STYLE outline_hatch = ZONE_BORDER_DISPLAY_STYLE::NO_HATCH;
bool endContour = false; bool endContour = false;
bool segmentFill = false;
int holeIndex = -1; // -1 is the main outline; holeIndex >= 0 = hole index int holeIndex = -1; // -1 is the main outline; holeIndex >= 0 = hole index
char buf[1024]; char buf[1024];
char* line; char* line;
@ -2454,33 +2455,22 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER()
if( fillmode) if( fillmode)
{ {
// SEGMENT fill mode no longer supported. Make sure user is OK with converting segmentFill = true;
// them.
if( m_showLegacySegmentZoneWarning ) if( m_showLegacySegmentZoneWarning )
{ {
KIDIALOG dlg( nullptr, wxLogWarning( _( "The legacy segment zone fill mode is no longer supported.\n"
_( "The legacy segment fill mode is no longer supported.\n" "Zone fills will be converted on a best-effort basis." ) );
"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" ) );
m_showLegacySegmentZoneWarning = false; m_showLegacySegmentZoneWarning = false;
} }
// User OK'd; switch to polygon mode
zc->SetFillMode( ZONE_FILL_MODE::POLYGONS );
m_board->SetModified();
} }
else else
{ {
zc->SetFillMode( ZONE_FILL_MODE::POLYGONS ); segmentFill = false;
} }
zc->SetFillMode( ZONE_FILL_MODE::POLYGONS );
zc->SetIsFilled( fillstate == 'S' ); zc->SetIsFilled( fillstate == 'S' );
zc->SetThermalReliefGap( thermalReliefGap ); zc->SetThermalReliefGap( thermalReliefGap );
zc->SetThermalReliefSpokeWidth( thermalReliefCopperBridge ); zc->SetThermalReliefSpokeWidth( thermalReliefCopperBridge );
@ -2545,7 +2535,7 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER()
makeNewOutline = end_contour; makeNewOutline = end_contour;
} }
zc->SetFilledPolysList( zc->GetLayer(), polysList ); zc->SetFilledPolysList( zc->GetFirstLayer(), polysList );
} }
else if( TESTLINE( "$FILLSEGMENTS" ) ) else if( TESTLINE( "$FILLSEGMENTS" ) )
{ {
@ -2568,6 +2558,20 @@ void LEGACY_PLUGIN::loadZONE_CONTAINER()
if( zc->GetIsRuleArea() ) if( zc->GetIsRuleArea() )
zc->SetNetCode( NETINFO_LIST::UNCONNECTED ); 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 ) );
inflatedFill.InflateWithLinkedHoles( zc->GetMinThickness() / 2,
SHAPE_POLY_SET::ROUND_ALL_CORNERS,
ARC_HIGH_DEF / 2,
SHAPE_POLY_SET::PM_STRICTLY_SIMPLE );
zc->SetFilledPolysList( layer, inflatedFill );
}
// should always occur, but who knows, a zone without two corners // should always occur, but who knows, a zone without two corners
// is no zone at all, it's a spot? // is no zone at all, it's a spot?