diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index ed4115323..46465726e 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -545,6 +545,32 @@ bool PCB_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in return false; } + // SEGMENT fill mode no longer supported. Make sure user is OK with converting them. + bool showWarning = true; + + for( auto zone : loadedBoard->Zones() ) + { + if( zone->GetFillMode() == ZFM_SEGMENTS ) + { + if( showWarning ) + { + KIDIALOG dlg( this, + _( "The legacy segment fill mode is no longer supported.\n" + "Convert zones to polygon fills?"), + _( "Legacy Zone Warning" ), + wxYES_NO | wxICON_WARNING ); + + dlg.DoNotShowCheckbox( __FILE__, __LINE__ ); + + if( dlg.ShowModal() == wxID_NO ) + return false; + } + + showWarning = false; + zone->SetFillMode( ZFM_POLYGONS ); + } + } + // 6.0 TODO: some settings didn't make it into the board file in 5.1 so as not to // change the file format. For 5.1 we must copy them across from the config-initialized // board. diff --git a/pcbnew/zone_filler.cpp b/pcbnew/zone_filler.cpp index 000b1d0c4..1f7e1b82c 100644 --- a/pcbnew/zone_filler.cpp +++ b/pcbnew/zone_filler.cpp @@ -52,6 +52,28 @@ #include "zone_filler.h" +class PROGRESS_REPORTER_HIDER +{ +public: + PROGRESS_REPORTER_HIDER( WX_PROGRESS_REPORTER* aReporter ) + { + m_reporter = aReporter; + + if( aReporter ) + aReporter->Hide(); + } + + ~PROGRESS_REPORTER_HIDER() + { + if( m_reporter ) + m_reporter->Show(); + } + +private: + WX_PROGRESS_REPORTER* m_reporter; +}; + + extern void CreateThermalReliefPadPolygon( SHAPE_POLY_SET& aCornerBuffer, const D_PAD& aPad, int aThermalGap, int aCopperThickness, int aMinThicknessValue, int aCircleToSegmentsCount, @@ -60,6 +82,7 @@ extern void CreateThermalReliefPadPolygon( SHAPE_POLY_SET& aCornerBuffer, static double s_thermalRot = 450; // angle of stubs in thermal reliefs for round pads static const bool s_DumpZonesWhenFilling = false; + ZONE_FILLER::ZONE_FILLER( BOARD* aBoard, COMMIT* aCommit ) : m_board( aBoard ), m_commit( aCommit ), m_progressReporter( nullptr ) { @@ -86,6 +109,51 @@ bool ZONE_FILLER::Fill( std::vector aZones, bool aCheck ) if( !lock ) return false; + if( m_progressReporter ) + { + m_progressReporter->Report( _( "Checking zone fills..." ) ); + m_progressReporter->SetMaxProgress( toFill.size() ); + } + + // Preflight deprecated segment zones + for( auto zone : aZones ) + { + if( zone->GetFillMode() == ZFM_SEGMENTS ) + { + if( aCheck ) + { + // Segment zones, being deprecated, are out-of-date by definition + PROGRESS_REPORTER_HIDER raii( m_progressReporter ); + KIDIALOG dlg( m_progressReporter->GetParent(), + _( "Zone fills are out-of-date. Refill?" ), + _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING ); + dlg.SetOKCancelLabels( _( "Refill" ), _( "Continue without Refill" ) ); + dlg.DoNotShowCheckbox( __FILE__, __LINE__ ); + + if( dlg.ShowModal() == wxID_CANCEL ) + { + m_progressReporter->Show(); + return false; + } + + aCheck = false; + } + + PROGRESS_REPORTER_HIDER raii( m_progressReporter ); + KIDIALOG dlg( m_progressReporter->GetParent(), + _( "The legacy segment fill mode is no longer supported.\n" + "Convert zones to polygon fills?"), + _( "Legacy Zone Warning" ), wxOK | wxCANCEL | wxICON_WARNING ); + dlg.SetOKCancelLabels( _( "Convert" ), _( "Continue without Refill" ) ); + dlg.DoNotShowCheckbox( __FILE__, __LINE__ ); + + if( dlg.ShowModal() != wxID_OK ) + return false; + + break; + } + } + for( auto zone : aZones ) { // Keepout zones are not filled @@ -107,12 +175,6 @@ bool ZONE_FILLER::Fill( std::vector aZones, bool aCheck ) zone->UnFill(); } - if( m_progressReporter ) - { - m_progressReporter->Report( _( "Checking zone fills..." ) ); - m_progressReporter->SetMaxProgress( toFill.size() ); - } - // Remove deprecaded segment zones (only found in very old boards) m_board->m_SegZoneDeprecated.DeleteAll(); @@ -129,20 +191,13 @@ bool ZONE_FILLER::Fill( std::vector aZones, bool aCheck ) ZONE_CONTAINER* zone = toFill[i].m_zone; if( zone->GetFillMode() == ZFM_SEGMENTS ) - { - ZONE_SEGMENT_FILL segFill; - fillZoneWithSegments( zone, zone->GetFilledPolysList(), segFill ); - zone->SetFillSegments( segFill ); - } - else - { - SHAPE_POLY_SET rawPolys, finalPolys; - fillSingleZone( zone, rawPolys, finalPolys ); + zone->SetFillMode( ZFM_POLYGONS ); - zone->SetRawPolysList( rawPolys ); - zone->SetFilledPolysList( finalPolys ); - } + SHAPE_POLY_SET rawPolys, finalPolys; + fillSingleZone( zone, rawPolys, finalPolys ); + zone->SetRawPolysList( rawPolys ); + zone->SetFilledPolysList( finalPolys ); zone->SetIsFilled( true ); if( m_progressReporter ) @@ -223,27 +278,16 @@ bool ZONE_FILLER::Fill( std::vector aZones, bool aCheck ) outOfDate = true; } - if( aCheck ) + if( aCheck && outOfDate ) { - bool refill = false; - wxCHECK( m_progressReporter, false ); - - if( outOfDate ) - { - m_progressReporter->Hide(); - - KIDIALOG dlg( m_progressReporter->GetParent(), - _( "Zone fills are out-of-date. Refill?" ), - _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING ); - dlg.SetOKCancelLabels( _( "Refill" ), _( "Continue without Refill" ) ); - dlg.DoNotShowCheckbox( __FILE__, __LINE__ ); - - refill = ( dlg.ShowModal() == wxID_OK ); - - m_progressReporter->Show(); - } - - if( !refill ) + PROGRESS_REPORTER_HIDER raii( m_progressReporter ); + KIDIALOG dlg( m_progressReporter->GetParent(), + _( "Zone fills are out-of-date. Refill?" ), + _( "Confirmation" ), wxOK | wxCANCEL | wxICON_WARNING ); + dlg.SetOKCancelLabels( _( "Refill" ), _( "Continue without Refill" ) ); + dlg.DoNotShowCheckbox( __FILE__, __LINE__ ); + + if( dlg.ShowModal() == wxID_CANCEL ) { if( m_commit ) m_commit->Revert();