eeschema: improve hierarchical sheet text placement

Take field name sizes and user preference line thickness into account
when calculating placement of the text fields of a hierarchical sheet on
the canvas.

The previous calculations contained some magic numbers which seem to
have been well suited to cases where line width is 8 and text size is
0.050. However, the text collided with the sheet outline as soon as text
size or line width was increased.

This commit has been evaluated with line widths ranging from 5 to 100
and text sizes ranging from 0.02 to 0.200. Also in combination with
characters such as qyg and ÅÄÖÜ in the file/sheet names.

(cherry picked from commit b1a60b2)
This commit is contained in:
Martin Aberg 2018-06-22 07:20:31 +01:00 committed by Jeff Young
parent 5b55a0d8e6
commit 41829162d2
1 changed files with 4 additions and 3 deletions

View File

@ -389,15 +389,16 @@ int SCH_SHEET::GetPenSize() const
wxPoint SCH_SHEET::GetSheetNamePosition()
{
wxPoint pos = m_pos;
int margin = KiROUND( GetPenSize() / 2.0 + 4 + m_sheetNameSize * 0.3 );
if( IsVerticalOrientation() )
{
pos.x -= 8;
pos.x -= margin;
pos.y += m_size.y;
}
else
{
pos.y -= 8;
pos.y -= margin;
}
return pos;
@ -407,7 +408,7 @@ wxPoint SCH_SHEET::GetSheetNamePosition()
wxPoint SCH_SHEET::GetFileNamePosition()
{
wxPoint pos = m_pos;
int margin = GetPenSize() + 4;
int margin = KiROUND( GetPenSize() / 2.0 + 4 + m_fileNameSize * 0.4 );
if( IsVerticalOrientation() )
{