Commit 20eaf66d authored by Lorenzo Marcantonio's avatar Lorenzo Marcantonio
Browse files

Hunted down hardcoded pixel size thresholds for drawing

Dynamic contrast for netname and pin numbers ('halo' text)
Handle netname drawing even on diagonal tracks
parent b525e3be
Loading
Loading
Loading
Loading
+32 −0
Original line number Diff line number Diff line
@@ -561,6 +561,38 @@ void DrawGraphicText( EDA_DRAW_PANEL* aPanel,
    }
}

void DrawGraphicHaloText( EDA_DRAW_PANEL * aPanel,
                          wxDC * aDC,
                          const wxPoint &aPos,
                          enum EDA_COLOR_T aBgColor,
                          enum EDA_COLOR_T aColor1,
                          enum EDA_COLOR_T aColor2,
                          const wxString &aText,
                          int aOrient,
                          const wxSize &aSize,
                          enum EDA_TEXT_HJUSTIFY_T aH_justify,
                          enum EDA_TEXT_VJUSTIFY_T aV_justify,
                          int aWidth,
                          bool aItalic,
                          bool aBold,
                          void (*aCallback)( int x0, int y0, int xf, int yf ),
                          PLOTTER * aPlotter )
{
    // Swap color if contrast would be better
    if( ColorIsLight( aBgColor ) ) {
        EDA_COLOR_T c = aColor1;
        aColor1 = aColor2;
        aColor2 = c;
    }

    DrawGraphicText( aPanel, aDC, aPos, aColor1, aText, aOrient, aSize, 
                     aH_justify, aV_justify, aWidth, aItalic, aBold, 
                     aCallback, aPlotter );
    
    DrawGraphicText( aPanel, aDC, aPos, aColor2, aText, aOrient, aSize, 
                     aH_justify, aV_justify, aWidth / 4, aItalic, aBold, 
                     aCallback, aPlotter );
}

/**
 * Function PlotGraphicText
+8 −0
Original line number Diff line number Diff line
@@ -1512,6 +1512,14 @@ EDA_COLOR_T ColorByName( const wxChar *aName )
    return UNSPECIFIED_COLOR;
}

bool ColorIsLight( EDA_COLOR_T aColor )
{
    const StructColors &c = g_ColorRefs[ColorGetBase( aColor )];
    int r = c.m_Red;
    int g = c.m_Green;
    int b = c.m_Blue;
    return ((r * r) + (g * g) + (b * b)) > (128 * 128 * 3);
}

EDA_COLOR_T ColorFindNearest( const wxColour &aColor )
{
+6 −0
Original line number Diff line number Diff line
@@ -139,6 +139,12 @@ EDA_COLOR_T ColorByName( const wxChar *aName );
/// Find the nearest color match
EDA_COLOR_T ColorFindNearest( const wxColour &aColor );

/**
 * Check if a color is light i.e. if black would be more readable than
 * white on it
 */
bool ColorIsLight( EDA_COLOR_T aColor );

inline const wxChar *ColorGetName( EDA_COLOR_T aColor )
{
    EDA_COLOR_T base = ColorGetBase( aColor );
+23 −0
Original line number Diff line number Diff line
@@ -88,4 +88,27 @@ void DrawGraphicText( EDA_DRAW_PANEL * aPanel,
                      PLOTTER * aPlotter = NULL );


/**
 * Draw graphic text with a border, so that it can be read on different
 * backgrounds. See DrawGraphicText for most of the parameters.
 * If aBgColor is a dark color text is drawn in aColor2 with aColor1
 * border; otherwise colors are swapped.
 */
void DrawGraphicHaloText( EDA_DRAW_PANEL * aPanel,
                          wxDC * aDC,
                          const wxPoint &aPos,
                          enum EDA_COLOR_T aBgColor,
                          enum EDA_COLOR_T aColor1,
                          enum EDA_COLOR_T aColor2,
                          const wxString &aText,
                          int aOrient,
                          const wxSize &aSize,
                          enum EDA_TEXT_HJUSTIFY_T aH_justify,
                          enum EDA_TEXT_VJUSTIFY_T aV_justify,
                          int aWidth,
                          bool aItalic,
                          bool aBold,
                          void (*aCallback)( int x0, int y0, int xf, int yf ) = NULL,
                          PLOTTER * aPlotter = NULL );

#endif /* __INCLUDE__DRAWTXT_H__ */
+1 −1
Original line number Diff line number Diff line
@@ -350,7 +350,7 @@ void DIMENSION::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color,
    typeaff = DisplayOpt.DisplayDrawItems;
    width   = m_Width;

    if( DC->LogicalToDeviceXRel( width ) < 2 )
    if( DC->LogicalToDeviceXRel( width ) <= MIN_DRAW_WIDTH )
        typeaff = LINE;

    switch( typeaff )
Loading