Overhaul show no-net indicators logic.

It doesn't appear that it was ever finished the first time around.

Fixes https://gitlab.com/kicad/code/kicad/issues/11020
This commit is contained in:
Jeff Young 2022-03-02 18:04:06 +00:00
parent 6b806bbe9c
commit 513486b0ec
1 changed files with 113 additions and 112 deletions

View File

@ -894,15 +894,33 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
if( IsNetnameLayer( aLayer ) )
{
// Is anything that we can display enabled?
bool displayNetname = ( (pcbconfig() && pcbconfig()->m_Display.m_NetNames == 1)
|| (pcbconfig() && pcbconfig()->m_Display.m_NetNames == 3 ) )
&& !aPad->GetNetname().empty();
if( !pcbconfig() )
return;
bool displayPadNumber = !pcbconfig() || pcbconfig()->m_Display.m_PadNumbers;
PCBNEW_SETTINGS::DISPLAY_OPTIONS& displayOpts = pcbconfig()->m_Display;
wxString netname;
wxString padNumber;
if( displayNetname || displayPadNumber )
if( displayOpts.m_PadNumbers )
padNumber = UnescapeString( aPad->GetNumber() );
if( displayOpts.m_NetNames == 1 || displayOpts.m_NetNames == 3 )
netname = UnescapeString( aPad->GetShortNetname() );
if( displayOpts.m_PadNoConnects
&& aPad->GetShortNetname().StartsWith( wxT( "unconnected-(" ) ) )
{
wxString pinType = aPad->GetPinType();
if( pinType == wxT( "no_connect" ) || pinType.EndsWith( wxT( "+no_connect" ) ) )
netname = wxT( "x" );
else if( pinType == wxT( "free" ) )
netname = wxT( "*" );
}
if( netname.IsEmpty() && padNumber.IsEmpty() )
return;
EDA_RECT padBBox = aPad->GetBoundingBox();
VECTOR2D position = padBBox.Centre();
VECTOR2D padsize = VECTOR2D( padBBox.GetSize() );
@ -954,29 +972,14 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
// Divide the space, to display both pad numbers and netnames and set the Y text
// position to display 2 lines
if( displayNetname && displayPadNumber )
if( !netname.IsEmpty() && !padNumber.IsEmpty() )
{
size = size / 2.5;
textpos.y = size / 1.7;
}
if( displayNetname )
if( !netname.IsEmpty() )
{
wxString netname = UnescapeString( aPad->GetShortNetname() );
wxString pinType = aPad->GetPinType();
// If the pad is actually not connected (unique pad in the net),
// shorten the displayed netname (actual name not useful)
// Can happen if the pad netname is edited inside the board editor, therefore
// having a netname not coming from schematic
if( netname.StartsWith( wxT( "unconnected-(" ) ) )
{
if( pinType == wxT( "no_connect" ) || pinType.EndsWith( wxT( "+no_connect" ) ) )
netname = wxT( "x" );
else if( pinType == wxT( "free" ) )
netname = wxT( "*" );
}
// approximate the size of net name text:
double tsize = 1.5 * padsize.x / std::max( PrintableCharCount( netname ), 1 );
tsize = std::min( tsize, size );
@ -990,9 +993,8 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
m_gal->BitmapText( netname, textpos, ANGLE_HORIZONTAL );
}
if( displayPadNumber )
if( !padNumber.IsEmpty() )
{
const wxString& padNumber = aPad->GetNumber();
textpos.y = -textpos.y;
// approximate the size of the pad number text:
@ -1010,7 +1012,6 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
}
m_gal->Restore();
}
return;
}