Made overbar position independant of pen size for text, to fix graphics glitches with halo text.

Slightly retuned for compensating the new position.
This commit is contained in:
Lorenzo Marcantonio 2013-04-10 21:09:59 +02:00
parent cca97586a9
commit b1c710a214
5 changed files with 22 additions and 19 deletions

View File

@ -54,11 +54,9 @@
double s_HersheyScaleFactor = HERSHEY_SCALE_FACTOR;
/* Helper function for texts with over bar
*/
int OverbarPositionY( int size_v, int thickness )
int OverbarPositionY( int size_v )
{
return KiROUND( ( (double) size_v * 1.1 ) + ( (double) thickness * 1.5 ) );
return KiROUND( size_v * 1.22 );
}
@ -155,7 +153,7 @@ static const char* GetHersheyShapeDescription( int AsciiCode )
AsciiCode = '?';
if( AsciiCode < 32 )
AsciiCode = 32; /* Clamp control chars */
AsciiCode = 32; // Clamp control chars
AsciiCode -= 32;
@ -391,9 +389,9 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
/* if a text size is too small, the text cannot be drawn, and it is drawn as a single
* graphic line */
if( std::abs( aSize.x ) < 3 )
if( aDC && ( aDC->LogicalToDeviceYRel( std::abs( aSize.y ) ) < MIN_TEXT_SIZE ))
{
/* draw the text as a line always vertically centered */
// draw the text as a line always vertically centered
wxPoint end( current_char_pos.x + dx, current_char_pos.y );
RotatePoint( &current_char_pos, aPos, aOrient );
@ -417,7 +415,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
if( aItalic )
{
overbar_italic_comp = OverbarPositionY( size_v, aWidth ) / 8;
overbar_italic_comp = OverbarPositionY( size_v ) / 8;
if( italic_reverse )
{
@ -450,7 +448,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
// Starting the overbar
overbar_pos = current_char_pos;
overbar_pos.x += overbar_italic_comp;
overbar_pos.y -= OverbarPositionY( size_v, aWidth );
overbar_pos.y -= OverbarPositionY( size_v );
RotatePoint( &overbar_pos, aPos, aOrient );
}
else
@ -459,7 +457,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
coord[0] = overbar_pos;
overbar_pos = current_char_pos;
overbar_pos.x += overbar_italic_comp;
overbar_pos.y -= OverbarPositionY( size_v, aWidth );
overbar_pos.y -= OverbarPositionY( size_v );
RotatePoint( &overbar_pos, aPos, aOrient );
coord[1] = overbar_pos;
// Plot the overbar segment
@ -520,7 +518,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
else
{
wxPoint currpoint;
hc1 -= xsta; hc2 -= 11; // Align the midpoint
hc1 -= xsta; hc2 -= 10; // Align the midpoint
hc1 = KiROUND( hc1 * size_h * s_HersheyScaleFactor );
hc2 = KiROUND( hc2 * size_v * s_HersheyScaleFactor );
@ -551,7 +549,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
// Close the last overbar
coord[0] = overbar_pos;
overbar_pos = current_char_pos;
overbar_pos.y -= OverbarPositionY( size_v, aWidth );
overbar_pos.y -= OverbarPositionY( size_v );
RotatePoint( &overbar_pos, aPos, aOrient );
coord[1] = overbar_pos;

View File

@ -46,7 +46,6 @@
extern void IncrementLabelMember( wxString& name );
extern int OverbarPositionY( int size_v, int thickness );
/* Names of sheet label types. */
@ -1320,11 +1319,11 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const
int x = symb_len + linewidth + 3;
// Use negation bar Y position to calculate full vertical size
#define Y_CORRECTION 1.22
#define Y_CORRECTION 1.3
// Note: this factor is due to the fact the negation bar Y position
// does not give exactly the full Y size of text
// and is experimentally set to this value
int y = KiROUND( OverbarPositionY( HalfSize, linewidth ) * Y_CORRECTION );
int y = KiROUND( OverbarPositionY( HalfSize ) * Y_CORRECTION );
// add room for line thickness and space between top of text and graphic shape
y += linewidth;

View File

@ -50,6 +50,12 @@ int ReturnGraphicTextWidth( const wxString& aText, int size_h, bool italic, bool
* Return the text length of a negable string, excluding the ~ markers */
int NegableTextLength( const wxString& aText );
/**
* Helper function for texts with over bar, can be used as strut value
* for multiline text (add interline spacing)
*/
int OverbarPositionY( int size_v );
/**
* Function DrawGraphicText
* Draw a graphic text (like module texts)

View File

@ -551,7 +551,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
if( aDC->LogicalToDeviceXRel( tsize ) >= MIN_TEXT_SIZE ) // Not drawable when size too small.
{
// tsize reserve room for marges and segments thickness
tsize = ( tsize * 8 ) / 10;
tsize = ( tsize * 7 ) / 10;
DrawGraphicHaloText( aDrawInfo.m_DrawPanel, aDC, tpos,
aDrawInfo.m_Color, BLACK, WHITE,
buffer, t_angle,
@ -578,7 +578,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
RotatePoint( &tpos, shape_pos, angle );
// tsize reserve room for marges and segments thickness
tsize = ( tsize * 8 ) / 10;
tsize = ( tsize * 7 ) / 10;
DrawGraphicHaloText( aDrawInfo.m_DrawPanel, aDC, tpos,
aDrawInfo.m_Color, BLACK, WHITE,
m_ShortNetname, t_angle,

View File

@ -750,7 +750,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode,
if( (aDrawMode & GR_XOR) == 0 )
GRSetDrawMode( aDC, GR_COPY );
tsize = (tsize * 8) / 10; // small reduction to give a better look
tsize = (tsize * 7) / 10; // small reduction to give a better look
DrawGraphicHaloText( panel, aDC, tpos,
color, BLACK, WHITE, net->GetShortNetname(), angle,
wxSize( tsize, tsize ),
@ -961,7 +961,7 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode,
if( aDC->LogicalToDeviceXRel( tsize ) >= MIN_TEXT_SIZE )
{
tsize = (tsize * 8) / 10; // small reduction to give a better look, inside via
tsize = (tsize * 7) / 10; // small reduction to give a better look, inside via
if( (aDrawMode & GR_XOR) == 0 )
GRSetDrawMode( aDC, GR_COPY );