Commit 1809f692 authored by jean-pierre charras's avatar jean-pierre charras

Eeschema: SCH_SHEET::GetBoundingBox(): better bounding box calculation.

parent f2e6170f
...@@ -525,7 +525,7 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, ...@@ -525,7 +525,7 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
int name_orientation; int name_orientation;
wxPoint pos_sheetname,pos_filename; wxPoint pos_sheetname,pos_filename;
wxPoint pos = m_Pos + aOffset; wxPoint pos = m_Pos + aOffset;
int LineWidth = g_DrawDefaultLineThickness; int lineWidth = GetPenSize();
if( aColor >= 0 ) if( aColor >= 0 )
color = aColor; color = aColor;
...@@ -535,7 +535,7 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, ...@@ -535,7 +535,7 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
GRSetDrawMode( aDC, aDrawMode ); GRSetDrawMode( aDC, aDrawMode );
GRRect( &aPanel->m_ClipBox, aDC, pos.x, pos.y, GRRect( &aPanel->m_ClipBox, aDC, pos.x, pos.y,
pos.x + m_Size.x, pos.y + m_Size.y, LineWidth, color ); pos.x + m_Size.x, pos.y + m_Size.y, lineWidth, color );
pos_sheetname = GetSheetNamePosition() + aOffset; pos_sheetname = GetSheetNamePosition() + aOffset;
pos_filename = GetFileNamePosition() + aOffset; pos_filename = GetFileNamePosition() + aOffset;
...@@ -555,7 +555,7 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, ...@@ -555,7 +555,7 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
DrawGraphicText( aPanel, aDC, pos_sheetname, DrawGraphicText( aPanel, aDC, pos_sheetname,
(EDA_Colors) txtcolor, Text, name_orientation, (EDA_Colors) txtcolor, Text, name_orientation,
wxSize( m_SheetNameSize, m_SheetNameSize ), wxSize( m_SheetNameSize, m_SheetNameSize ),
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, LineWidth, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_BOTTOM, lineWidth,
false, false ); false, false );
/* Draw text : FileName */ /* Draw text : FileName */
...@@ -568,7 +568,7 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, ...@@ -568,7 +568,7 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
DrawGraphicText( aPanel, aDC, pos_filename, DrawGraphicText( aPanel, aDC, pos_filename,
(EDA_Colors) txtcolor, Text, name_orientation, (EDA_Colors) txtcolor, Text, name_orientation,
wxSize( m_FileNameSize, m_FileNameSize ), wxSize( m_FileNameSize, m_FileNameSize ),
GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, LineWidth, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_VJUSTIFY_TOP, lineWidth,
false, false ); false, false );
...@@ -583,19 +583,30 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC, ...@@ -583,19 +583,30 @@ void SCH_SHEET::Draw( EDA_DRAW_PANEL* aPanel, wxDC* aDC,
EDA_RECT SCH_SHEET::GetBoundingBox() const EDA_RECT SCH_SHEET::GetBoundingBox() const
{ {
int dx, dy; wxPoint end;
EDA_RECT box( m_Pos, m_Size );
int lineWidth = GetPenSize();
// Determine length of texts // Determine length of texts
wxString Text1 = wxT( "Sheet: " ) + m_SheetName; wxString text = wxT( "Sheet: " ) + m_SheetName;
wxString Text2 = wxT( "File: " ) + m_FileName; int textlen = ReturnGraphicTextWidth( text, m_SheetNameSize, false, lineWidth );
int textlen1 = 10 * Text1.Len() * m_SheetNameSize / 9; text = wxT( "File: " ) + m_FileName;
int textlen2 = 10 * Text2.Len() * m_FileNameSize / 9; int textlen2 = ReturnGraphicTextWidth( text, m_FileNameSize, false, lineWidth );
textlen1 = MAX( textlen1, textlen2 ); // Calculate bounding box X size:
dx = MAX( m_Size.x, textlen1 ); textlen = MAX( textlen, textlen2 );
dy = m_Size.y + m_SheetNameSize + m_FileNameSize + 16; end.x = MAX( m_Size.x, textlen );
EDA_RECT box( wxPoint( m_Pos.x, m_Pos.y - m_SheetNameSize - 8 ), wxSize( dx, dy ) ); // Calculate bounding box pos:
end.y = m_Size.y;
end += m_Pos;
// Move upper and lower limits to include texts:
box.m_Pos.y -= wxRound( m_SheetNameSize * 1.3 ) + 8;
end.y += wxRound( m_FileNameSize * 1.3 ) + 8;
box.SetEnd( end );
box.Inflate( lineWidth / 2 );
return box; return box;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment