Centralize no-connect- and free-pad processing.

Also makes the track-net-names less squirrelly around the viewport
edges.
This commit is contained in:
Jeff Young 2022-09-05 17:23:19 +01:00
parent 9e8e241924
commit 16b4f96405
3 changed files with 32 additions and 9 deletions

View File

@ -157,6 +157,20 @@ bool PAD::IsLocked() const
};
bool PAD::IsNoConnectPad() const
{
return GetShortNetname().StartsWith( wxT( "unconnected-(" ) )
&& ( m_pinType == wxT( "no_connect" ) || m_pinType.EndsWith( wxT( "+no_connect" ) ) );
}
bool PAD::IsFreePad() const
{
return GetShortNetname().StartsWith( wxT( "unconnected-(" ) )
&& m_pinType == wxT( "free" );
}
LSET PAD::PTHMask()
{
static LSET saved = LSET::AllCuMask() | LSET( 2, F_Mask, B_Mask );

View File

@ -162,6 +162,18 @@ public:
&& !m_number.IsEmpty() && m_number == other->m_number;
}
/**
* @return true if the pad is associated with an "unconnected" pin (or a no-connect symbol)
* and has no net.
*/
bool IsNoConnectPad() const;
/**
* @return true if the pad is associated with a "free" pin (not-internally-connected) and has
* not yet been assigned another net (ie: by being routed to).
*/
bool IsFreePad() const;
/**
* Set the new shape of this pad.
*/

View File

@ -637,9 +637,9 @@ void PCB_PAINTER::draw( const PCB_TRACK* aTrack, int aLayer )
ClipLine( &clipBox, visibleSeg.A.x, visibleSeg.A.y, visibleSeg.B.x, visibleSeg.B.y );
// Check if the track is long enough to have a netname displayed
int seg_minlenght = track_width * 6; // min lenght of the visible segment to draw the net name
int seg_minlength = track_width * 6;
if( visibleSeg.Length() < seg_minlenght )
if( visibleSeg.Length() < seg_minlength )
return;
const wxString& netName = UnescapeString( aTrack->GetShortNetname() );
@ -651,7 +651,7 @@ void PCB_PAINTER::draw( const PCB_TRACK* aTrack, int aLayer )
// If the last position is still on the track, and it's some reasonable distance inside
// the viewport then don't move the netname; just use the last position.
if( visibleSeg.Distance( aTrack->m_LastNetnamePosition ) < penWidth
&& clipBox.Inflate( -seg_minlenght ).Contains( aTrack->m_LastNetnamePosition ) )
&& clipBox.Inflate( -seg_minlength / 2 ).Contains( aTrack->m_LastNetnamePosition ) )
{
textPosition = aTrack->m_LastNetnamePosition;
}
@ -1004,14 +1004,11 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer )
if( displayOpts->m_NetNames == 1 || displayOpts->m_NetNames == 3 )
netname = UnescapeString( aPad->GetShortNetname() );
if( displayOpts->m_PadNoConnects
&& aPad->GetShortNetname().StartsWith( wxT( "unconnected-(" ) ) )
if( displayOpts->m_PadNoConnects )
{
wxString pinType = aPad->GetPinType();
if( pinType == wxT( "no_connect" ) || pinType.EndsWith( wxT( "+no_connect" ) ) )
if( aPad->IsNoConnectPad() )
netname = wxT( "x" );
else if( pinType == wxT( "free" ) )
else if( aPad->IsFreePad() )
netname = wxT( "*" );
}
}