Set default netclass for newly-added no-net PNS items

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16144
This commit is contained in:
Jon Evans 2023-12-10 22:59:36 -05:00
parent d8d71a8a6e
commit 47ab6f8d03
3 changed files with 14 additions and 4 deletions

View File

@ -164,6 +164,7 @@ public:
*/
void Clear();
void SetParent( BOARD* aParent ) { m_parent = aParent; }
BOARD* GetParent() const // Replace EDA_ITEM::GetParent() with a more useful return-type
{
return m_parent;

View File

@ -64,6 +64,7 @@ NETINFO_ITEM::~NETINFO_ITEM()
void NETINFO_ITEM::Clear()
{
wxCHECK( m_parent, /* void */ );
m_netClass = m_parent->GetDesignSettings().m_NetSettings->m_DefaultNetClass;
}

View File

@ -1878,6 +1878,7 @@ void PNS_KICAD_IFACE_BASE::AddItem( PNS::ITEM* aItem )
BOARD_CONNECTED_ITEM* PNS_KICAD_IFACE::createBoardItem( PNS::ITEM* aItem )
{
BOARD_CONNECTED_ITEM* newBI = nullptr;
auto net = static_cast<NETINFO_ITEM*>( aItem->Net() );
switch( aItem->Kind() )
{
@ -1887,7 +1888,7 @@ BOARD_CONNECTED_ITEM* PNS_KICAD_IFACE::createBoardItem( PNS::ITEM* aItem )
PCB_ARC* new_arc = new PCB_ARC( m_board, static_cast<const SHAPE_ARC*>( arc->Shape() ) );
new_arc->SetWidth( arc->Width() );
new_arc->SetLayer( ToLAYER_ID( arc->Layers().Start() ) );
new_arc->SetNet( static_cast<NETINFO_ITEM*>( arc->Net() ) );
new_arc->SetNet( net );
newBI = new_arc;
break;
}
@ -1901,7 +1902,7 @@ BOARD_CONNECTED_ITEM* PNS_KICAD_IFACE::createBoardItem( PNS::ITEM* aItem )
track->SetEnd( VECTOR2I( s.B.x, s.B.y ) );
track->SetWidth( seg->Width() );
track->SetLayer( ToLAYER_ID( seg->Layers().Start() ) );
track->SetNet( static_cast<NETINFO_ITEM*>( seg->Net() ) );
track->SetNet( net );
newBI = track;
break;
}
@ -1913,7 +1914,7 @@ BOARD_CONNECTED_ITEM* PNS_KICAD_IFACE::createBoardItem( PNS::ITEM* aItem )
via_board->SetPosition( VECTOR2I( via->Pos().x, via->Pos().y ) );
via_board->SetWidth( via->Diameter() );
via_board->SetDrill( via->Drill() );
via_board->SetNet( static_cast<NETINFO_ITEM*>( via->Net() ) );
via_board->SetNet( net );
via_board->SetViaType( via->ViaType() ); // MUST be before SetLayerPair()
via_board->SetIsFree( via->IsFree() );
via_board->SetLayerPair( ToLAYER_ID( via->Layers().Start() ),
@ -1934,6 +1935,13 @@ BOARD_CONNECTED_ITEM* PNS_KICAD_IFACE::createBoardItem( PNS::ITEM* aItem )
default: break;
}
if( net->GetNetCode() <= 0 )
{
NETINFO_ITEM* newNetInfo = newBI->GetNet();
newNetInfo->SetParent( m_board );
newNetInfo->SetNetClass( m_board->GetDesignSettings().m_NetSettings->m_DefaultNetClass );
}
return newBI;
}