From f8f48f922e0d7018e74f8beca055226e85dbfe2c Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Fri, 19 Apr 2024 16:30:00 -0700 Subject: [PATCH] Show disambiguated netname when needed When using subsheets with nets that end in the same netname, it can be confusing in pcbnew to know which net you are dealing with. In these cases, we show the full netname including path to assist when routing Fixes https://gitlab.com/kicad/code/kicad/-/issues/16187 (cherry picked from commit b346cde30b34940db57ea539818824443cedb045) --- pcbnew/pcb_painter.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 4495db6663..1a96d5f11c 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -705,7 +705,15 @@ void PCB_PAINTER::draw( const PCB_TRACK* aTrack, int aLayer ) return; SHAPE_SEGMENT trackShape( { aTrack->GetStart(), aTrack->GetEnd() }, aTrack->GetWidth() ); - renderNetNameForSegment( trackShape, color, aTrack->GetUnescapedShortNetname() ); + wxString netname = aTrack->GetUnescapedShortNetname(); + + for( const auto& netinfo : aTrack->GetBoard()->GetNetInfo() ) + { + if( netinfo->GetUnescapedShortNetname() == netname ) + netname = UnescapeString( aTrack->GetNetname() ); + } + + renderNetNameForSegment( trackShape, color, netname ); return; } else if( IsCopperLayer( aLayer ) || aLayer == LAYER_LOCKED_ITEM_SHADOW ) @@ -1159,6 +1167,12 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer ) if( netname.IsEmpty() && padNumber.IsEmpty() ) return; + for( const auto& netinfo : board->GetNetInfo() ) + { + if( netinfo->GetUnescapedShortNetname() == netname ) + netname = UnescapeString( aPad->GetNetname() ); + } + BOX2I padBBox = aPad->GetBoundingBox(); VECTOR2D position = padBBox.Centre(); VECTOR2D padsize = VECTOR2D( padBBox.GetSize() );