|
|
@ -894,124 +894,125 @@ 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; |
|
|
|
|
|
|
|
PCBNEW_SETTINGS::DISPLAY_OPTIONS& displayOpts = pcbconfig()->m_Display; |
|
|
|
wxString netname; |
|
|
|
wxString padNumber; |
|
|
|
|
|
|
|
bool displayPadNumber = !pcbconfig() || pcbconfig()->m_Display.m_PadNumbers; |
|
|
|
if( displayOpts.m_PadNumbers ) |
|
|
|
padNumber = UnescapeString( aPad->GetNumber() ); |
|
|
|
|
|
|
|
if( displayNetname || displayPadNumber ) |
|
|
|
if( displayOpts.m_NetNames == 1 || displayOpts.m_NetNames == 3 ) |
|
|
|
netname = UnescapeString( aPad->GetShortNetname() ); |
|
|
|
|
|
|
|
if( displayOpts.m_PadNoConnects |
|
|
|
&& aPad->GetShortNetname().StartsWith( wxT( "unconnected-(" ) ) ) |
|
|
|
{ |
|
|
|
EDA_RECT padBBox = aPad->GetBoundingBox(); |
|
|
|
VECTOR2D position = padBBox.Centre(); |
|
|
|
VECTOR2D padsize = VECTOR2D( padBBox.GetSize() ); |
|
|
|
wxString pinType = aPad->GetPinType(); |
|
|
|
|
|
|
|
if( aPad->GetShape() != PAD_SHAPE::CUSTOM ) |
|
|
|
{ |
|
|
|
// Don't allow a 45° rotation to bloat a pad's bounding box unnecessarily
|
|
|
|
double limit = std::min( aPad->GetSize().x, aPad->GetSize().y ) * 1.1; |
|
|
|
if( pinType == wxT( "no_connect" ) || pinType.EndsWith( wxT( "+no_connect" ) ) ) |
|
|
|
netname = wxT( "x" ); |
|
|
|
else if( pinType == wxT( "free" ) ) |
|
|
|
netname = wxT( "*" ); |
|
|
|
} |
|
|
|
|
|
|
|
if( padsize.x > limit && padsize.y > limit ) |
|
|
|
{ |
|
|
|
padsize.x = limit; |
|
|
|
padsize.y = limit; |
|
|
|
} |
|
|
|
} |
|
|
|
if( netname.IsEmpty() && padNumber.IsEmpty() ) |
|
|
|
return; |
|
|
|
|
|
|
|
double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE; |
|
|
|
double size = padsize.y; |
|
|
|
EDA_RECT padBBox = aPad->GetBoundingBox(); |
|
|
|
VECTOR2D position = padBBox.Centre(); |
|
|
|
VECTOR2D padsize = VECTOR2D( padBBox.GetSize() ); |
|
|
|
|
|
|
|
m_gal->Save(); |
|
|
|
m_gal->Translate( position ); |
|
|
|
if( aPad->GetShape() != PAD_SHAPE::CUSTOM ) |
|
|
|
{ |
|
|
|
// Don't allow a 45° rotation to bloat a pad's bounding box unnecessarily
|
|
|
|
double limit = std::min( aPad->GetSize().x, aPad->GetSize().y ) * 1.1; |
|
|
|
|
|
|
|
// Keep the size ratio for the font, but make it smaller
|
|
|
|
if( padsize.x < padsize.y ) |
|
|
|
if( padsize.x > limit && padsize.y > limit ) |
|
|
|
{ |
|
|
|
m_gal->Rotate( -ANGLE_90.AsRadians() ); |
|
|
|
size = padsize.x; |
|
|
|
std::swap( padsize.x, padsize.y ); |
|
|
|
padsize.x = limit; |
|
|
|
padsize.y = limit; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Font size limits
|
|
|
|
if( size > maxSize ) |
|
|
|
size = maxSize; |
|
|
|
|
|
|
|
// Default font settings
|
|
|
|
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER ); |
|
|
|
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER ); |
|
|
|
m_gal->SetFontBold( false ); |
|
|
|
m_gal->SetFontItalic( false ); |
|
|
|
m_gal->SetFontUnderlined( false ); |
|
|
|
m_gal->SetTextMirrored( false ); |
|
|
|
m_gal->SetStrokeColor( m_pcbSettings.GetColor( aPad, aLayer ) ); |
|
|
|
m_gal->SetIsStroke( true ); |
|
|
|
m_gal->SetIsFill( false ); |
|
|
|
double maxSize = PCB_RENDER_SETTINGS::MAX_FONT_SIZE; |
|
|
|
double size = padsize.y; |
|
|
|
|
|
|
|
// We have already translated the GAL to be centered at the center of the pad's
|
|
|
|
// bounding box
|
|
|
|
VECTOR2I textpos( 0, 0 ); |
|
|
|
m_gal->Save(); |
|
|
|
m_gal->Translate( position ); |
|
|
|
|
|
|
|
// Divide the space, to display both pad numbers and netnames and set the Y text
|
|
|
|
// position to display 2 lines
|
|
|
|
if( displayNetname && displayPadNumber ) |
|
|
|
{ |
|
|
|
size = size / 2.5; |
|
|
|
textpos.y = size / 1.7; |
|
|
|
} |
|
|
|
// Keep the size ratio for the font, but make it smaller
|
|
|
|
if( padsize.x < padsize.y ) |
|
|
|
{ |
|
|
|
m_gal->Rotate( -ANGLE_90.AsRadians() ); |
|
|
|
size = padsize.x; |
|
|
|
std::swap( padsize.x, padsize.y ); |
|
|
|
} |
|
|
|
|
|
|
|
if( displayNetname ) |
|
|
|
{ |
|
|
|
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( "*" ); |
|
|
|
} |
|
|
|
// Font size limits
|
|
|
|
if( size > maxSize ) |
|
|
|
size = maxSize; |
|
|
|
|
|
|
|
// Default font settings
|
|
|
|
m_gal->SetHorizontalJustify( GR_TEXT_H_ALIGN_CENTER ); |
|
|
|
m_gal->SetVerticalJustify( GR_TEXT_V_ALIGN_CENTER ); |
|
|
|
m_gal->SetFontBold( false ); |
|
|
|
m_gal->SetFontItalic( false ); |
|
|
|
m_gal->SetFontUnderlined( false ); |
|
|
|
m_gal->SetTextMirrored( false ); |
|
|
|
m_gal->SetStrokeColor( m_pcbSettings.GetColor( aPad, aLayer ) ); |
|
|
|
m_gal->SetIsStroke( true ); |
|
|
|
m_gal->SetIsFill( false ); |
|
|
|
|
|
|
|
// approximate the size of net name text:
|
|
|
|
double tsize = 1.5 * padsize.x / std::max( PrintableCharCount( netname ), 1 ); |
|
|
|
tsize = std::min( tsize, size ); |
|
|
|
// We have already translated the GAL to be centered at the center of the pad's
|
|
|
|
// bounding box
|
|
|
|
VECTOR2I textpos( 0, 0 ); |
|
|
|
|
|
|
|
// Use a smaller text size to handle interline, pen size...
|
|
|
|
tsize *= 0.7; |
|
|
|
VECTOR2D namesize( tsize, tsize ); |
|
|
|
// Divide the space, to display both pad numbers and netnames and set the Y text
|
|
|
|
// position to display 2 lines
|
|
|
|
if( !netname.IsEmpty() && !padNumber.IsEmpty() ) |
|
|
|
{ |
|
|
|
size = size / 2.5; |
|
|
|
textpos.y = size / 1.7; |
|
|
|
} |
|
|
|
|
|
|
|
m_gal->SetGlyphSize( namesize ); |
|
|
|
m_gal->SetLineWidth( namesize.x / 12.0 ); |
|
|
|
m_gal->BitmapText( netname, textpos, ANGLE_HORIZONTAL ); |
|
|
|
} |
|
|
|
if( !netname.IsEmpty() ) |
|
|
|
{ |
|
|
|
// approximate the size of net name text:
|
|
|
|
double tsize = 1.5 * padsize.x / std::max( PrintableCharCount( netname ), 1 ); |
|
|
|
tsize = std::min( tsize, size ); |
|
|
|
|
|
|
|
if( displayPadNumber ) |
|
|
|
{ |
|
|
|
const wxString& padNumber = aPad->GetNumber(); |
|
|
|
textpos.y = -textpos.y; |
|
|
|
// Use a smaller text size to handle interline, pen size...
|
|
|
|
tsize *= 0.7; |
|
|
|
VECTOR2D namesize( tsize, tsize ); |
|
|
|
|
|
|
|
// approximate the size of the pad number text:
|
|
|
|
double tsize = 1.5 * padsize.x / std::max( PrintableCharCount( padNumber ), 1 ); |
|
|
|
tsize = std::min( tsize, size ); |
|
|
|
m_gal->SetGlyphSize( namesize ); |
|
|
|
m_gal->SetLineWidth( namesize.x / 12.0 ); |
|
|
|
m_gal->BitmapText( netname, textpos, ANGLE_HORIZONTAL ); |
|
|
|
} |
|
|
|
|
|
|
|
// Use a smaller text size to handle interline, pen size...
|
|
|
|
tsize *= 0.7; |
|
|
|
tsize = std::min( tsize, size ); |
|
|
|
VECTOR2D numsize( tsize, tsize ); |
|
|
|
if( !padNumber.IsEmpty() ) |
|
|
|
{ |
|
|
|
textpos.y = -textpos.y; |
|
|
|
|
|
|
|
m_gal->SetGlyphSize( numsize ); |
|
|
|
m_gal->SetLineWidth( numsize.x / 12.0 ); |
|
|
|
m_gal->BitmapText( padNumber, textpos, ANGLE_HORIZONTAL ); |
|
|
|
} |
|
|
|
// approximate the size of the pad number text:
|
|
|
|
double tsize = 1.5 * padsize.x / std::max( PrintableCharCount( padNumber ), 1 ); |
|
|
|
tsize = std::min( tsize, size ); |
|
|
|
|
|
|
|
m_gal->Restore(); |
|
|
|
// Use a smaller text size to handle interline, pen size...
|
|
|
|
tsize *= 0.7; |
|
|
|
tsize = std::min( tsize, size ); |
|
|
|
VECTOR2D numsize( tsize, tsize ); |
|
|
|
|
|
|
|
m_gal->SetGlyphSize( numsize ); |
|
|
|
m_gal->SetLineWidth( numsize.x / 12.0 ); |
|
|
|
m_gal->BitmapText( padNumber, textpos, ANGLE_HORIZONTAL ); |
|
|
|
} |
|
|
|
|
|
|
|
m_gal->Restore(); |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
else if( aLayer == LAYER_PAD_HOLEWALLS ) |
|
|
|