minor changes.

This commit is contained in:
charras 2008-12-15 10:24:19 +00:00
parent 829f54831c
commit 23003001f1
2 changed files with 23 additions and 22 deletions

View File

@ -399,7 +399,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
wxPoint tpos0 = wxPoint( ux0, uy0 ); // Position of the centre of text wxPoint tpos0 = wxPoint( ux0, uy0 ); // Position of the centre of text
wxPoint tpos = tpos0; wxPoint tpos = tpos0;
wxSize AreaSize; // size of text area, normalized to AreaSize.y < AreaSize.x wxSize AreaSize; // size of text area, normalized to AreaSize.y < AreaSize.x
int len; int shortname_len = m_ShortNetname.Len();
if( GetShape() == PAD_CIRCLE ) if( GetShape() == PAD_CIRCLE )
angle = 0; angle = 0;
AreaSize = m_Size; AreaSize = m_Size;
@ -410,7 +410,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
AreaSize.y = m_Size.x; AreaSize.y = m_Size.x;
} }
if( !m_Netname.IsEmpty() ) // if there is a netname, provides room to display this netname if( shortname_len > 0 ) // if there is a netname, provides room to display this netname
{ {
AreaSize.y /= 2; // Text used only the upper area of the pad. The lower area displays the net name AreaSize.y /= 2; // Text used only the upper area of the pad. The lower area displays the net name
tpos.y -= AreaSize.y / 2; tpos.y -= AreaSize.y / 2;
@ -424,32 +424,31 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
NORMALIZE_ANGLE_90( t_angle ); NORMALIZE_ANGLE_90( t_angle );
/* Note: in next calculations, texte size is calculated for 3 or more chars. /* Note: in next calculations, texte size is calculated for 3 or more chars.
Of course, pads nimbers and nets names can have less than 3 chars. Of course, pads numbers and nets names can have less than 3 chars.
but after some tries, i found this is gives the best look but after some tries, i found this is gives the best look
*/ */
#define MIN_CHAR_COUNT 3 #define MIN_CHAR_COUNT 3
wxString buffer; wxString buffer;
ReturnStringPadName( buffer ); ReturnStringPadName( buffer );
len = buffer.Len(); int numpad_len = buffer.Len();
len = MAX( len, MIN_CHAR_COUNT); numpad_len = MAX( numpad_len, MIN_CHAR_COUNT);
int tsize = min( AreaSize.y, AreaSize.x / len ); int tsize = min( AreaSize.y, AreaSize.x / numpad_len );
#define CHAR_SIZE_MIN 5 #define CHAR_SIZE_MIN 5
if( (tsize / zoom) >= CHAR_SIZE_MIN ) // Not drawable in size too small. if( (tsize / zoom) >= CHAR_SIZE_MIN ) // Not drawable when size too small.
{ {
tsize = (int) (tsize * 0.8); // reserve room for marges and segments thickness tsize = (int) (tsize * 0.8); // reserve room for marges and segments thickness
DrawGraphicText( panel, DC, tpos, DrawGraphicText( panel, DC, tpos,
WHITE, buffer, t_angle, wxSize( tsize, tsize ), WHITE, buffer, t_angle, wxSize( tsize, tsize ),
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, tsize / 8 ); GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, tsize / 7 );
} }
// display the short netname // display the short netnam, if exists
len = m_ShortNetname.Len(); if (shortname_len == 0 )
if (len == 0 )
return; return;
len = MAX( len, MIN_CHAR_COUNT); shortname_len = MAX( shortname_len, MIN_CHAR_COUNT);
tsize = min( AreaSize.y, AreaSize.x / len ); tsize = min( AreaSize.y, AreaSize.x / shortname_len );
if( (tsize / zoom) >= CHAR_SIZE_MIN ) // Not drawable in size too small. if( (tsize / zoom) >= CHAR_SIZE_MIN ) // Not drawable in size too small.
{ {
@ -460,7 +459,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
tsize = (int) (tsize * 0.8); // reserve room for marges and segments thickness tsize = (int) (tsize * 0.8); // reserve room for marges and segments thickness
DrawGraphicText( panel, DC, tpos, DrawGraphicText( panel, DC, tpos,
WHITE, m_ShortNetname, t_angle, wxSize( tsize, tsize ), WHITE, m_ShortNetname, t_angle, wxSize( tsize, tsize ),
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, tsize / 8 ); GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, tsize / 7 );
} }
} }

View File

@ -773,15 +773,17 @@ void SEGVIA::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoi
return; return;
int len = net->GetShortNetname().Len(); int len = net->GetShortNetname().Len();
if ( len > 0 )
// calculate a good size for the text (fixed to 9 pixels, if possible) {
// calculate a good size for the text
int tsize = m_Width / len; int tsize = m_Width / len;
if( ( tsize / zoom) >= 6 ) if( ( tsize / zoom) >= 6 )
{ {
tsize = (tsize * 8) / 10; // small reduction to give a better look, inside via tsize = (tsize * 8) / 10; // small reduction to give a better look, inside via
DrawGraphicText( panel, DC, m_Start, DrawGraphicText( panel, DC, m_Start,
WHITE, net->GetShortNetname(), 0, wxSize( tsize, tsize ), WHITE, net->GetShortNetname(), 0, wxSize( tsize, tsize ),
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, tsize / 8 ); GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, tsize / 7 );
}
} }
} }