Minor cleanup.

This commit is contained in:
Jeff Young 2023-08-30 11:09:11 +01:00
parent 1eaadf7c7f
commit ace394aab9
1 changed files with 16 additions and 20 deletions

View File

@ -817,38 +817,34 @@ void LIB_PIN::PlotPinTexts( PLOTTER *aPlotter, const VECTOR2I &aPinPos, PIN_ORIE
case PIN_ORIENTATION::PIN_RIGHT: x1 += m_length; break; case PIN_ORIENTATION::PIN_RIGHT: x1 += m_length; break;
} }
auto plotText = auto plotName =
[&]( int px, int py, const COLOR4D& color, const wxString& text, const EDA_ANGLE& angle, [&]( int x, int y, const EDA_ANGLE& angle, GR_TEXT_H_ALIGN_T hJustify,
int size, GR_TEXT_H_ALIGN_T hJustify, GR_TEXT_V_ALIGN_T vJustify, int penWidth ) GR_TEXT_V_ALIGN_T vJustify )
{ {
TEXT_ATTRIBUTES attrs; TEXT_ATTRIBUTES attrs;
attrs.m_StrokeWidth = std::min( penWidth, size / 5 ); // Keep text readable attrs.m_StrokeWidth = namePenWidth;
attrs.m_Angle = angle; attrs.m_Angle = angle;
attrs.m_Size = VECTOR2I( size, size ); attrs.m_Size = VECTOR2I( m_nameTextSize, m_nameTextSize );
attrs.m_Halign = hJustify; attrs.m_Halign = hJustify;
attrs.m_Valign = vJustify; attrs.m_Valign = vJustify;
attrs.m_Multiline = false; attrs.m_Multiline = false;
aPlotter->PlotText( VECTOR2I( px, py ), color, text, attrs, font, GetFontMetrics() ); aPlotter->PlotText( VECTOR2I( x, y ), nameColor, name, attrs, font, GetFontMetrics() );
};
auto plotName =
[&]( int px, int py, const EDA_ANGLE& angle, GR_TEXT_H_ALIGN_T hJustify,
GR_TEXT_V_ALIGN_T vJustify )
{
plotText( px, py, nameColor, name, angle, m_nameTextSize, hJustify, vJustify,
namePenWidth );
}; };
auto plotNum = auto plotNum =
[&]( int px, int py, const EDA_ANGLE& angle, GR_TEXT_H_ALIGN_T hJustify, [&]( int x, int y, const EDA_ANGLE& angle, GR_TEXT_H_ALIGN_T hJustify,
GR_TEXT_V_ALIGN_T vJustify ) GR_TEXT_V_ALIGN_T vJustify )
{ {
plotText( px, py, numColor, number, angle, m_numTextSize, hJustify, vJustify, TEXT_ATTRIBUTES attrs;
numPenWidth ); attrs.m_StrokeWidth = numPenWidth;
attrs.m_Angle = angle;
attrs.m_Size = VECTOR2I( m_numTextSize, m_numTextSize );
attrs.m_Halign = hJustify;
attrs.m_Valign = vJustify;
attrs.m_Multiline = false;
aPlotter->PlotText( VECTOR2I( x, y ), numColor, number, attrs, font, GetFontMetrics() );
}; };
/* Draw the text inside, but the pin numbers outside. */ /* Draw the text inside, but the pin numbers outside. */