eagle: determine and use the minimum copper layer stackup count

Fixes: https://gitlab.com/kicad/code/kicad/issues/13484
This commit is contained in:
vinsfortunato 2023-01-29 20:09:12 +01:00 committed by Jeff Young
parent 586f22c2f7
commit 5bdaf20af6
2 changed files with 28 additions and 11 deletions

View File

@ -398,17 +398,7 @@ BOARD* EAGLE_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe,
// IO_ERROR exceptions are left uncaught, they pass upwards from here.
// Ensure the copper layers count is a multiple of 2
// Pcbnew does not like boards with odd layers count
// (these boards cannot exist. they actually have a even layers count)
int lyrcnt = m_board->GetCopperLayerCount();
if( (lyrcnt % 2) != 0 )
{
lyrcnt++;
m_board->SetCopperLayerCount( lyrcnt );
}
m_board->SetCopperLayerCount( getMinimumCopperLayerCount() );
centerBoard();
deleter.release();
@ -3213,3 +3203,27 @@ void EAGLE_PLUGIN::FootprintLibOptions( STRING_UTF8_MAP* aListToAppendTo ) const
{
PLUGIN::FootprintLibOptions( aListToAppendTo );
}
int EAGLE_PLUGIN::getMinimumCopperLayerCount() const
{
int minLayerCount = 2;
std::map<wxString, PCB_LAYER_ID>::const_iterator it;
for( it = m_layer_map.begin(); it != m_layer_map.end(); ++it )
{
PCB_LAYER_ID layerId = it->second;
if( IsCopperLayer( layerId ) && layerId != F_Cu && layerId != B_Cu
&& ( layerId + 2 ) > minLayerCount )
minLayerCount = layerId + 2;
}
// Ensure the copper layers count is a multiple of 2
// Pcbnew does not like boards with odd layers count
// (these boards cannot exist. they actually have a even layers count)
if( ( minLayerCount % 2 ) != 0 )
minLayerCount++;
return minLayerCount;
}

View File

@ -241,6 +241,9 @@ private:
/// get a file's or dir's modification time.
static wxDateTime getModificationTime( const wxString& aPath );
/// Determines the minimum copper layer stackup count that includes all mapped layers.
int getMinimumCopperLayerCount() const;
// all these loadXXX() throw IO_ERROR or ptree_error exceptions:
void loadAllSections( wxXmlNode* aDocument );