Fix plotting offset issue for non-symbol fields.

This commit is contained in:
Jeff Young 2022-08-29 11:52:40 +01:00
parent 5ebc51bf63
commit c65228e15f
1 changed files with 19 additions and 15 deletions

View File

@ -929,7 +929,10 @@ void SCH_FIELD::Plot( PLOTTER* aPlotter, bool aBackground ) const
return; return;
// Calculate the text orientation, according to the symbol orientation/mirror // Calculate the text orientation, according to the symbol orientation/mirror
EDA_ANGLE orient = GetTextAngle(); EDA_ANGLE orient = GetTextAngle();
VECTOR2I textpos = GetTextPos();
GR_TEXT_H_ALIGN_T hjustify = GetHorizJustify();
GR_TEXT_V_ALIGN_T vjustify = GetVertJustify();
if( m_parent && m_parent->Type() == SCH_SYMBOL_T ) if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
{ {
@ -942,21 +945,22 @@ void SCH_FIELD::Plot( PLOTTER* aPlotter, bool aBackground ) const
else else
orient = ANGLE_HORIZONTAL; orient = ANGLE_HORIZONTAL;
} }
}
/* /*
* Calculate the text justification, according to the symbol orientation/mirror. * Calculate the text justification, according to the symbol orientation/mirror. This is
* This is a bit complicated due to cumulative calculations: * a bit complicated due to cumulative calculations:
* - numerous cases (mirrored or not, rotation) * - numerous cases (mirrored or not, rotation)
* - the plotter's Text function will also recalculate H and V justifications according to * - the plotter's Text() function will also recalculate H and V justifications according
* the text orientation. * to the text orientation
* - When a symbol is mirrored, the text is not mirrored and justifications are complicated * - when a symbol is mirrored the text is not, and justifications become a nightmare
* to calculate so the easier way is to use no justifications (centered text) and use *
* GetBoundingBox to know the text coordinate considered as centered * So the easier way is to use no justifications (centered text) and use GetBoundingBox to
*/ * know the text coordinate considered as centered.
GR_TEXT_H_ALIGN_T hjustify = GR_TEXT_H_ALIGN_CENTER; */
GR_TEXT_V_ALIGN_T vjustify = GR_TEXT_V_ALIGN_CENTER; hjustify = GR_TEXT_H_ALIGN_CENTER;
VECTOR2I textpos = GetBoundingBox().Centre(); vjustify = GR_TEXT_V_ALIGN_CENTER;
textpos = GetBoundingBox().Centre();
}
aPlotter->Text( textpos, color, GetShownText(), orient, GetTextSize(), hjustify, vjustify, aPlotter->Text( textpos, color, GetShownText(), orient, GetTextSize(), hjustify, vjustify,
penWidth, IsItalic(), IsBold(), false, GetDrawFont() ); penWidth, IsItalic(), IsBold(), false, GetDrawFont() );