From e4ca2408d41547c6c3e6439111e0e316e36b8e07 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 1 Aug 2022 20:22:13 -0700 Subject: [PATCH] Net Inspector: Handle via layers Rather than measuring the total via height, measure from the entry to exit track height to get a more accurate distance (cherry picked from commit 57de5a6b65ee334061109cdaf66a88111c5c112e) --- pcbnew/dialogs/dialog_net_inspector.cpp | 31 +++++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/pcbnew/dialogs/dialog_net_inspector.cpp b/pcbnew/dialogs/dialog_net_inspector.cpp index 6ec27c61fd..c1ce4ce738 100644 --- a/pcbnew/dialogs/dialog_net_inspector.cpp +++ b/pcbnew/dialogs/dialog_net_inspector.cpp @@ -1376,14 +1376,35 @@ void DIALOG_NET_INSPECTOR::updateNet( NETINFO_ITEM* aNet ) unsigned int DIALOG_NET_INSPECTOR::calculateViaLength( const PCB_TRACK* aTrack ) const { - const PCB_VIA& via = dynamic_cast( *aTrack ); + const PCB_VIA* via = dynamic_cast( aTrack ); BOARD_DESIGN_SETTINGS& bds = m_brd->GetDesignSettings(); // calculate the via length individually from the board stackup and via's start and end layer. if( bds.m_HasStackup ) { + static std::vector connectedTypes = { PCB_TRACE_T, PCB_ARC_T, PCB_PAD_T }; + + PCB_LAYER_ID top_layer = UNDEFINED_LAYER; + PCB_LAYER_ID bottom_layer = UNDEFINED_LAYER; + + for( int layer = via->TopLayer(); layer <= via->BottomLayer(); ++layer ) + { + if( m_brd->GetConnectivity()->IsConnectedOnLayer( via, layer, connectedTypes, true ) ) + { + if( top_layer == UNDEFINED_LAYER ) + top_layer = PCB_LAYER_ID( layer ); + else + bottom_layer = PCB_LAYER_ID( layer ); + } + } + + if( top_layer == UNDEFINED_LAYER ) + top_layer = via->TopLayer(); + if( bottom_layer == UNDEFINED_LAYER ) + bottom_layer = via->BottomLayer(); + const BOARD_STACKUP& stackup = bds.GetStackupDescriptor(); - return stackup.GetLayerDistance( via.TopLayer(), via.BottomLayer() ); + return stackup.GetLayerDistance( top_layer, bottom_layer ); } else { @@ -1392,12 +1413,12 @@ unsigned int DIALOG_NET_INSPECTOR::calculateViaLength( const PCB_TRACK* aTrack ) int layerThickness = bds.GetBoardThickness() / dielectricLayers; int effectiveBottomLayer; - if( via.BottomLayer() == B_Cu ) + if( via->BottomLayer() == B_Cu ) effectiveBottomLayer = F_Cu + dielectricLayers; else - effectiveBottomLayer = via.BottomLayer(); + effectiveBottomLayer = via->BottomLayer(); - int layerCount = effectiveBottomLayer - via.TopLayer(); + int layerCount = effectiveBottomLayer - via->TopLayer(); return layerCount * layerThickness; }