Commit b1c710a2 authored by Lorenzo Marcantonio's avatar Lorenzo Marcantonio

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

Slightly retuned for compensating the new position.
parent cca97586
...@@ -54,11 +54,9 @@ ...@@ -54,11 +54,9 @@
double s_HersheyScaleFactor = HERSHEY_SCALE_FACTOR; double s_HersheyScaleFactor = HERSHEY_SCALE_FACTOR;
/* Helper function for texts with over bar int OverbarPositionY( int size_v )
*/
int OverbarPositionY( int size_v, int thickness )
{ {
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 ) ...@@ -155,7 +153,7 @@ static const char* GetHersheyShapeDescription( int AsciiCode )
AsciiCode = '?'; AsciiCode = '?';
if( AsciiCode < 32 ) if( AsciiCode < 32 )
AsciiCode = 32; /* Clamp control chars */ AsciiCode = 32; // Clamp control chars
AsciiCode -= 32; AsciiCode -= 32;
...@@ -391,9 +389,9 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, ...@@ -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 /* if a text size is too small, the text cannot be drawn, and it is drawn as a single
* graphic line */ * 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 ); wxPoint end( current_char_pos.x + dx, current_char_pos.y );
RotatePoint( &current_char_pos, aPos, aOrient ); RotatePoint( &current_char_pos, aPos, aOrient );
...@@ -417,7 +415,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, ...@@ -417,7 +415,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
if( aItalic ) if( aItalic )
{ {
overbar_italic_comp = OverbarPositionY( size_v, aWidth ) / 8; overbar_italic_comp = OverbarPositionY( size_v ) / 8;
if( italic_reverse ) if( italic_reverse )
{ {
...@@ -450,7 +448,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, ...@@ -450,7 +448,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
// Starting the overbar // Starting the overbar
overbar_pos = current_char_pos; overbar_pos = current_char_pos;
overbar_pos.x += overbar_italic_comp; overbar_pos.x += overbar_italic_comp;
overbar_pos.y -= OverbarPositionY( size_v, aWidth ); overbar_pos.y -= OverbarPositionY( size_v );
RotatePoint( &overbar_pos, aPos, aOrient ); RotatePoint( &overbar_pos, aPos, aOrient );
} }
else else
...@@ -459,7 +457,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, ...@@ -459,7 +457,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
coord[0] = overbar_pos; coord[0] = overbar_pos;
overbar_pos = current_char_pos; overbar_pos = current_char_pos;
overbar_pos.x += overbar_italic_comp; overbar_pos.x += overbar_italic_comp;
overbar_pos.y -= OverbarPositionY( size_v, aWidth ); overbar_pos.y -= OverbarPositionY( size_v );
RotatePoint( &overbar_pos, aPos, aOrient ); RotatePoint( &overbar_pos, aPos, aOrient );
coord[1] = overbar_pos; coord[1] = overbar_pos;
// Plot the overbar segment // Plot the overbar segment
...@@ -520,7 +518,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, ...@@ -520,7 +518,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
else else
{ {
wxPoint currpoint; wxPoint currpoint;
hc1 -= xsta; hc2 -= 11; // Align the midpoint hc1 -= xsta; hc2 -= 10; // Align the midpoint
hc1 = KiROUND( hc1 * size_h * s_HersheyScaleFactor ); hc1 = KiROUND( hc1 * size_h * s_HersheyScaleFactor );
hc2 = KiROUND( hc2 * size_v * s_HersheyScaleFactor ); hc2 = KiROUND( hc2 * size_v * s_HersheyScaleFactor );
...@@ -551,7 +549,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel, ...@@ -551,7 +549,7 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
// Close the last overbar // Close the last overbar
coord[0] = overbar_pos; coord[0] = overbar_pos;
overbar_pos = current_char_pos; overbar_pos = current_char_pos;
overbar_pos.y -= OverbarPositionY( size_v, aWidth ); overbar_pos.y -= OverbarPositionY( size_v );
RotatePoint( &overbar_pos, aPos, aOrient ); RotatePoint( &overbar_pos, aPos, aOrient );
coord[1] = overbar_pos; coord[1] = overbar_pos;
......
...@@ -46,7 +46,6 @@ ...@@ -46,7 +46,6 @@
extern void IncrementLabelMember( wxString& name ); extern void IncrementLabelMember( wxString& name );
extern int OverbarPositionY( int size_v, int thickness );
/* Names of sheet label types. */ /* Names of sheet label types. */
...@@ -1320,11 +1319,11 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const ...@@ -1320,11 +1319,11 @@ void SCH_GLOBALLABEL::CreateGraphicShape( std::vector <wxPoint>& aPoints, const
int x = symb_len + linewidth + 3; int x = symb_len + linewidth + 3;
// Use negation bar Y position to calculate full vertical size // 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 // Note: this factor is due to the fact the negation bar Y position
// does not give exactly the full Y size of text // does not give exactly the full Y size of text
// and is experimentally set to this value // 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 // add room for line thickness and space between top of text and graphic shape
y += linewidth; y += linewidth;
......
...@@ -50,6 +50,12 @@ int ReturnGraphicTextWidth( const wxString& aText, int size_h, bool italic, bool ...@@ -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 */ * Return the text length of a negable string, excluding the ~ markers */
int NegableTextLength( const wxString& aText ); 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 * Function DrawGraphicText
* Draw a graphic text (like module texts) * Draw a graphic text (like module texts)
......
...@@ -551,7 +551,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) ...@@ -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. if( aDC->LogicalToDeviceXRel( tsize ) >= MIN_TEXT_SIZE ) // Not drawable when size too small.
{ {
// tsize reserve room for marges and segments thickness // tsize reserve room for marges and segments thickness
tsize = ( tsize * 8 ) / 10; tsize = ( tsize * 7 ) / 10;
DrawGraphicHaloText( aDrawInfo.m_DrawPanel, aDC, tpos, DrawGraphicHaloText( aDrawInfo.m_DrawPanel, aDC, tpos,
aDrawInfo.m_Color, BLACK, WHITE, aDrawInfo.m_Color, BLACK, WHITE,
buffer, t_angle, buffer, t_angle,
...@@ -578,7 +578,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo ) ...@@ -578,7 +578,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
RotatePoint( &tpos, shape_pos, angle ); RotatePoint( &tpos, shape_pos, angle );
// tsize reserve room for marges and segments thickness // tsize reserve room for marges and segments thickness
tsize = ( tsize * 8 ) / 10; tsize = ( tsize * 7 ) / 10;
DrawGraphicHaloText( aDrawInfo.m_DrawPanel, aDC, tpos, DrawGraphicHaloText( aDrawInfo.m_DrawPanel, aDC, tpos,
aDrawInfo.m_Color, BLACK, WHITE, aDrawInfo.m_Color, BLACK, WHITE,
m_ShortNetname, t_angle, m_ShortNetname, t_angle,
......
...@@ -750,7 +750,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, ...@@ -750,7 +750,7 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode,
if( (aDrawMode & GR_XOR) == 0 ) if( (aDrawMode & GR_XOR) == 0 )
GRSetDrawMode( aDC, GR_COPY ); 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, DrawGraphicHaloText( panel, aDC, tpos,
color, BLACK, WHITE, net->GetShortNetname(), angle, color, BLACK, WHITE, net->GetShortNetname(), angle,
wxSize( tsize, tsize ), wxSize( tsize, tsize ),
...@@ -961,7 +961,7 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode, ...@@ -961,7 +961,7 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode,
if( aDC->LogicalToDeviceXRel( tsize ) >= MIN_TEXT_SIZE ) 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 ) if( (aDrawMode & GR_XOR) == 0 )
GRSetDrawMode( aDC, GR_COPY ); GRSetDrawMode( aDC, GR_COPY );
......
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