Allow GetLayer() to be used with single-layer zones.

Also fixes a bug in GetFirstLayer() where we were checking
m_layerSet.size() (which is always 60) rather than
m_layerSet.count() (which is the number of set layers).

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15233
This commit is contained in:
Jeff Young 2023-08-08 12:34:57 +01:00
parent 54759389de
commit 8bb895373a
2 changed files with 8 additions and 2 deletions

View File

@ -32,6 +32,9 @@ wxString LayerName( int aLayer )
switch( aLayer )
{
// PCB_LAYER_ID
case UNDEFINED_LAYER: return _( "undefined" );
// Copper
case F_Cu: return wxT( "F.Cu" );
case In1_Cu: return wxT( "In1.Cu" );
case In2_Cu: return wxT( "In2.Cu" );

View File

@ -247,13 +247,16 @@ VECTOR2I ZONE::GetPosition() const
PCB_LAYER_ID ZONE::GetLayer() const
{
return BOARD_ITEM::GetLayer();
if( m_layerSet.count() == 1 )
return m_layerSet.UIOrder()[0];
else
return UNDEFINED_LAYER;
}
PCB_LAYER_ID ZONE::GetFirstLayer() const
{
if( m_layerSet.size() )
if( m_layerSet.count() )
return m_layerSet.UIOrder()[0];
else
return UNDEFINED_LAYER;