Scale down netnames on tracks so overbars fit.

Also fixes a bug where the overbar ignored the color opacity.

Fixes https://gitlab.com/kicad/code/kicad/issues/7524
This commit is contained in:
Jeff Young 2021-02-13 19:21:42 +00:00
parent 379c28340f
commit 60d4d5b846
2 changed files with 16 additions and 6 deletions

View File

@ -1986,7 +1986,7 @@ void OPENGL_GAL::drawBitmapOverbar( double aLength, double aHeight )
Translate( VECTOR2D( -aLength, -aHeight-1.5*H ) );
currentManager->Reserve( 6 );
currentManager->Color( strokeColor.r, strokeColor.g, strokeColor.b, 1 );
currentManager->Color( strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a );
currentManager->Shader( 0 );

View File

@ -503,28 +503,38 @@ void PCB_PAINTER::draw( const TRACK* aTrack, int aLayer )
return;
const wxString& netName = UnescapeString( aTrack->GetShortNetname() );
double textSize = width;
double penWidth = width / 12.0;
VECTOR2D textPosition = start + line / 2.0; // center of the track
double textOrientation;
double textOrientation;
if( end.y == start.y ) // horizontal
{
textOrientation = 0;
textPosition.y += penWidth;
}
else if( end.x == start.x ) // vertical
{
textOrientation = M_PI / 2;
textPosition.x += penWidth;
}
else
{
textOrientation = -atan( line.y / line.x );
textPosition.x += penWidth / 1.4;
textPosition.y += penWidth / 1.4;
}
double textSize = width;
m_gal->SetIsStroke( true );
m_gal->SetIsFill( false );
m_gal->SetStrokeColor( color );
m_gal->SetLineWidth( width / 10.0 );
m_gal->SetLineWidth( penWidth );
m_gal->SetFontBold( false );
m_gal->SetFontItalic( false );
m_gal->SetFontUnderlined( false );
m_gal->SetTextMirrored( false );
m_gal->SetGlyphSize( VECTOR2D( textSize * 0.7, textSize * 0.7 ) );
m_gal->SetGlyphSize( VECTOR2D( textSize * 0.55, textSize * 0.55 ) );
m_gal->SetHorizontalJustify( GR_TEXT_HJUSTIFY_CENTER );
m_gal->SetVerticalJustify( GR_TEXT_VJUSTIFY_CENTER );
m_gal->BitmapText( netName, textPosition, textOrientation );