diff --git a/pcbnew/router/pns_hole.h b/pcbnew/router/pns_hole.h index fbc85b3d5d..fc4be0942f 100644 --- a/pcbnew/router/pns_hole.h +++ b/pcbnew/router/pns_hole.h @@ -49,6 +49,14 @@ public: */ virtual HOLE* Clone() const override; + virtual int Net() const override + { + if( m_parentPadVia ) + return m_parentPadVia->Net(); + + return m_net; + } + virtual const SHAPE_LINE_CHAIN Hull( int aClearance = 0, int aWalkaroundThickness = 0, int aLayer = -1 ) const override; @@ -59,6 +67,7 @@ public: const SHAPE* Shape() const override { return m_holeShape; } + void SetParentPadVia( ITEM* aParent ) { m_parentPadVia = aParent; } ITEM* ParentPadVia() const { return m_parentPadVia; } BOARD_ITEM* BoardItem() const override diff --git a/pcbnew/router/pns_item.h b/pcbnew/router/pns_item.h index 71ff3a28d9..c048968823 100644 --- a/pcbnew/router/pns_item.h +++ b/pcbnew/router/pns_item.h @@ -186,7 +186,7 @@ public: virtual BOARD_ITEM* BoardItem() const { return m_parent; } void SetNet( int aNet ) { m_net = aNet; } - int Net() const { return m_net; } + virtual int Net() const { return m_net; } const LAYER_RANGE& Layers() const { return m_layers; } void SetLayers( const LAYER_RANGE& aLayers ) { m_layers = aLayers; } diff --git a/pcbnew/router/pns_via.h b/pcbnew/router/pns_via.h index ede01b4137..8097080004 100644 --- a/pcbnew/router/pns_via.h +++ b/pcbnew/router/pns_via.h @@ -51,19 +51,21 @@ class VIA : public LINKED_ITEM { public: VIA() : - LINKED_ITEM( VIA_T ) + LINKED_ITEM( VIA_T ), + m_hole( nullptr ) { - m_diameter = 2; // Dummy value - m_drill = 0; - m_viaType = VIATYPE::THROUGH; - m_isFree = false; + m_diameter = 2; // Dummy value + m_drill = 0; + m_viaType = VIATYPE::THROUGH; + m_isFree = false; m_isVirtual = false; - m_hole = HOLE::MakeCircularHole( m_pos, m_diameter / 2 ); + SetHole( HOLE::MakeCircularHole( m_pos, m_diameter / 2 ) ); } VIA( const VECTOR2I& aPos, const LAYER_RANGE& aLayers, int aDiameter, int aDrill, int aNet = -1, VIATYPE aViaType = VIATYPE::THROUGH ) : - LINKED_ITEM( VIA_T ) + LINKED_ITEM( VIA_T ), + m_hole( nullptr ) { SetNet( aNet ); SetLayers( aLayers ); @@ -71,24 +73,22 @@ public: m_diameter = aDiameter; m_drill = aDrill; m_shape = SHAPE_CIRCLE( aPos, aDiameter / 2 ); - m_hole = HOLE::MakeCircularHole( m_pos, aDrill / 2 ); - m_hole->SetNet( aNet ); - m_hole->SetOwner( this ); + SetHole( HOLE::MakeCircularHole( m_pos, aDrill / 2 ) ); m_viaType = aViaType; m_isFree = false; m_isVirtual = false; } VIA( const VIA& aB ) : - LINKED_ITEM( aB ) + LINKED_ITEM( aB ), + m_hole( nullptr ) { SetNet( aB.Net() ); SetLayers( aB.Layers() ); m_pos = aB.m_pos; m_diameter = aB.m_diameter; m_shape = SHAPE_CIRCLE( m_pos, m_diameter / 2 ); - m_hole = aB.m_hole->Clone(); - m_hole->SetOwner( this ); + SetHole( aB.m_hole->Clone() ); m_marker = aB.m_marker; m_rank = aB.m_rank; m_drill = aB.m_drill; @@ -177,7 +177,7 @@ public: } m_hole = aHole; - m_hole->SetNet( Net() ); + m_hole->SetParentPadVia( this ); m_hole->SetOwner( this ); if( m_hole )