Hunted down hardcoded pixel size thresholds for drawing
Dynamic contrast for netname and pin numbers ('halo' text) Handle netname drawing even on diagonal tracks
This commit is contained in:
parent
b525e3be55
commit
20eaf66d5b
|
@ -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
|
* Function PlotGraphicText
|
||||||
|
|
|
@ -1512,6 +1512,14 @@ EDA_COLOR_T ColorByName( const wxChar *aName )
|
||||||
return UNSPECIFIED_COLOR;
|
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 )
|
EDA_COLOR_T ColorFindNearest( const wxColour &aColor )
|
||||||
{
|
{
|
||||||
|
|
|
@ -139,6 +139,12 @@ EDA_COLOR_T ColorByName( const wxChar *aName );
|
||||||
/// Find the nearest color match
|
/// Find the nearest color match
|
||||||
EDA_COLOR_T ColorFindNearest( const wxColour &aColor );
|
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 )
|
inline const wxChar *ColorGetName( EDA_COLOR_T aColor )
|
||||||
{
|
{
|
||||||
EDA_COLOR_T base = ColorGetBase( aColor );
|
EDA_COLOR_T base = ColorGetBase( aColor );
|
||||||
|
|
|
@ -88,4 +88,27 @@ void DrawGraphicText( EDA_DRAW_PANEL * aPanel,
|
||||||
PLOTTER * aPlotter = NULL );
|
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__ */
|
#endif /* __INCLUDE__DRAWTXT_H__ */
|
||||||
|
|
|
@ -350,7 +350,7 @@ void DIMENSION::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color,
|
||||||
typeaff = DisplayOpt.DisplayDrawItems;
|
typeaff = DisplayOpt.DisplayDrawItems;
|
||||||
width = m_Width;
|
width = m_Width;
|
||||||
|
|
||||||
if( DC->LogicalToDeviceXRel( width ) < 2 )
|
if( DC->LogicalToDeviceXRel( width ) <= MIN_DRAW_WIDTH )
|
||||||
typeaff = LINE;
|
typeaff = LINE;
|
||||||
|
|
||||||
switch( typeaff )
|
switch( typeaff )
|
||||||
|
|
|
@ -209,7 +209,7 @@ void DRAWSEGMENT::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
|
||||||
if( m_Flags & FORCE_SKETCH )
|
if( m_Flags & FORCE_SKETCH )
|
||||||
mode = SKETCH;
|
mode = SKETCH;
|
||||||
|
|
||||||
if( l_trace < DC->DeviceToLogicalXRel( MIN_DRAW_WIDTH ) )
|
if( DC->LogicalToDeviceXRel( l_trace ) <= MIN_DRAW_WIDTH )
|
||||||
mode = LINE;
|
mode = LINE;
|
||||||
|
|
||||||
switch( m_Shape )
|
switch( m_Shape )
|
||||||
|
|
|
@ -146,7 +146,7 @@ void EDGE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
|
||||||
typeaff = SKETCH;
|
typeaff = SKETCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( DC->LogicalToDeviceXRel( m_Width ) < MIN_DRAW_WIDTH )
|
if( DC->LogicalToDeviceXRel( m_Width ) <= MIN_DRAW_WIDTH )
|
||||||
typeaff = LINE;
|
typeaff = LINE;
|
||||||
|
|
||||||
switch( type_trace )
|
switch( type_trace )
|
||||||
|
|
|
@ -115,7 +115,7 @@ void PCB_TARGET::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE mode_color,
|
||||||
typeaff = DisplayOpt.DisplayDrawItems;
|
typeaff = DisplayOpt.DisplayDrawItems;
|
||||||
width = m_Width;
|
width = m_Width;
|
||||||
|
|
||||||
if( DC->LogicalToDeviceXRel( width ) < 2 )
|
if( DC->LogicalToDeviceXRel( width ) <= MIN_DRAW_WIDTH )
|
||||||
typeaff = LINE;
|
typeaff = LINE;
|
||||||
|
|
||||||
radius = m_Size / 3;
|
radius = m_Size / 3;
|
||||||
|
|
|
@ -433,7 +433,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
|
||||||
switch( m_DrillShape )
|
switch( m_DrillShape )
|
||||||
{
|
{
|
||||||
case PAD_CIRCLE:
|
case PAD_CIRCLE:
|
||||||
if( aDC->LogicalToDeviceXRel( hole ) > 1 )
|
if( aDC->LogicalToDeviceXRel( hole ) > MIN_DRAW_WIDTH )
|
||||||
GRFilledCircle( aClipBox, aDC, holepos.x, holepos.y, hole, 0,
|
GRFilledCircle( aClipBox, aDC, holepos.x, holepos.y, hole, 0,
|
||||||
aDrawInfo.m_Color, hole_color );
|
aDrawInfo.m_Color, hole_color );
|
||||||
break;
|
break;
|
||||||
|
@ -487,6 +487,11 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
|
||||||
holepos.x - dx0, holepos.y + dx0, 0, nc_color );
|
holepos.x - dx0, holepos.y + dx0, 0, nc_color );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( aDrawInfo.m_DrawMode != GR_XOR )
|
||||||
|
GRSetDrawMode( aDC, GR_COPY );
|
||||||
|
else
|
||||||
|
GRSetDrawMode( aDC, GR_XOR );
|
||||||
|
|
||||||
// Draw the pad number
|
// Draw the pad number
|
||||||
if( !aDrawInfo.m_Display_padnum && !aDrawInfo.m_Display_netname )
|
if( !aDrawInfo.m_Display_padnum && !aDrawInfo.m_Display_netname )
|
||||||
return;
|
return;
|
||||||
|
@ -542,15 +547,17 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
|
||||||
numpad_len = std::max( numpad_len, MIN_CHAR_COUNT );
|
numpad_len = std::max( numpad_len, MIN_CHAR_COUNT );
|
||||||
|
|
||||||
tsize = std::min( AreaSize.y, AreaSize.x / numpad_len );
|
tsize = std::min( AreaSize.y, AreaSize.x / numpad_len );
|
||||||
#define CHAR_SIZE_MIN 5
|
|
||||||
|
|
||||||
if( aDC->LogicalToDeviceXRel( tsize ) >= CHAR_SIZE_MIN ) // 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 = (int) ( tsize * 0.8 );
|
tsize = ( tsize * 8 ) / 10;
|
||||||
DrawGraphicText( aDrawInfo.m_DrawPanel, aDC, tpos, WHITE, buffer, t_angle,
|
DrawGraphicHaloText( aDrawInfo.m_DrawPanel, aDC, tpos,
|
||||||
wxSize( tsize, tsize ), GR_TEXT_HJUSTIFY_CENTER,
|
aDrawInfo.m_Color, BLACK, WHITE,
|
||||||
GR_TEXT_VJUSTIFY_CENTER, tsize / 7, false, false );
|
buffer, t_angle,
|
||||||
|
wxSize( tsize , tsize ), GR_TEXT_HJUSTIFY_CENTER,
|
||||||
|
GR_TEXT_VJUSTIFY_CENTER, tsize / 7, false, false );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -561,7 +568,7 @@ void D_PAD::DrawShape( EDA_RECT* aClipBox, wxDC* aDC, PAD_DRAWINFO& aDrawInfo )
|
||||||
shortname_len = std::max( shortname_len, MIN_CHAR_COUNT );
|
shortname_len = std::max( shortname_len, MIN_CHAR_COUNT );
|
||||||
tsize = std::min( AreaSize.y, AreaSize.x / shortname_len );
|
tsize = std::min( AreaSize.y, AreaSize.x / shortname_len );
|
||||||
|
|
||||||
if( aDC->LogicalToDeviceXRel( tsize ) >= CHAR_SIZE_MIN ) // Not drawable in size too small.
|
if( aDC->LogicalToDeviceXRel( tsize ) >= MIN_TEXT_SIZE ) // Not drawable in size too small.
|
||||||
{
|
{
|
||||||
tpos = tpos0;
|
tpos = tpos0;
|
||||||
|
|
||||||
|
@ -571,10 +578,12 @@ 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 = (int) ( tsize * 0.8 );
|
tsize = ( tsize * 8 ) / 10;
|
||||||
DrawGraphicText( aDrawInfo.m_DrawPanel, aDC, tpos, WHITE, m_ShortNetname, t_angle,
|
DrawGraphicHaloText( aDrawInfo.m_DrawPanel, aDC, tpos,
|
||||||
wxSize( tsize, tsize ), GR_TEXT_HJUSTIFY_CENTER,
|
aDrawInfo.m_Color, BLACK, WHITE,
|
||||||
GR_TEXT_VJUSTIFY_CENTER, tsize / 7, false, false );
|
m_ShortNetname, t_angle,
|
||||||
|
wxSize( tsize, tsize ), GR_TEXT_HJUSTIFY_CENTER,
|
||||||
|
GR_TEXT_VJUSTIFY_CENTER, tsize / 7, false, false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -275,7 +275,7 @@ void TEXTE_MODULE::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
|
||||||
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) panel->GetParent();
|
PCB_BASE_FRAME* frame = (PCB_BASE_FRAME*) panel->GetParent();
|
||||||
int width = m_Thickness;
|
int width = m_Thickness;
|
||||||
if( ( frame->m_DisplayModText == LINE )
|
if( ( frame->m_DisplayModText == LINE )
|
||||||
|| ( DC->LogicalToDeviceXRel( width ) < MIN_DRAW_WIDTH ) )
|
|| ( DC->LogicalToDeviceXRel( width ) <= MIN_DRAW_WIDTH ) )
|
||||||
width = 0;
|
width = 0;
|
||||||
else if( frame->m_DisplayModText == SKETCH )
|
else if( frame->m_DisplayModText == SKETCH )
|
||||||
width = -width;
|
width = -width;
|
||||||
|
|
|
@ -579,7 +579,7 @@ TRACK* TRACK::GetEndNetCode( int NetCode )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
|
void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode,
|
||||||
const wxPoint& aOffset )
|
const wxPoint& aOffset )
|
||||||
{
|
{
|
||||||
int l_trace;
|
int l_trace;
|
||||||
|
@ -592,29 +592,29 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
|
||||||
BOARD * brd = GetBoard( );
|
BOARD * brd = GetBoard( );
|
||||||
EDA_COLOR_T color = brd->GetLayerColor(m_Layer);
|
EDA_COLOR_T color = brd->GetLayerColor(m_Layer);
|
||||||
|
|
||||||
if( brd->IsLayerVisible( m_Layer ) == false && !( draw_mode & GR_HIGHLIGHT ) )
|
if( brd->IsLayerVisible( m_Layer ) == false && !( aDrawMode & GR_HIGHLIGHT ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef USE_WX_OVERLAY
|
#ifdef USE_WX_OVERLAY
|
||||||
// If dragged not draw in OnPaint otherwise remains impressed in wxOverlay
|
// If dragged not draw in OnPaint otherwise remains impressed in wxOverlay
|
||||||
if( (m_Flags && IS_DRAGGED) && DC->IsKindOf(wxCLASSINFO(wxPaintDC)))
|
if( (m_Flags && IS_DRAGGED) && aDC->IsKindOf(wxCLASSINFO(wxPaintDC)))
|
||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if( ( draw_mode & GR_ALLOW_HIGHCONTRAST ) && DisplayOpt.ContrastModeDisplay )
|
if( ( aDrawMode & GR_ALLOW_HIGHCONTRAST ) && DisplayOpt.ContrastModeDisplay )
|
||||||
{
|
{
|
||||||
if( !IsOnLayer( curr_layer ) )
|
if( !IsOnLayer( curr_layer ) )
|
||||||
ColorTurnToDarkDarkGray( &color );
|
ColorTurnToDarkDarkGray( &color );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( draw_mode & GR_HIGHLIGHT )
|
if( aDrawMode & GR_HIGHLIGHT )
|
||||||
ColorChangeHighlightFlag( &color, !(draw_mode & GR_AND) );
|
ColorChangeHighlightFlag( &color, !(aDrawMode & GR_AND) );
|
||||||
|
|
||||||
ColorApplyHighlightFlag( &color );
|
ColorApplyHighlightFlag( &color );
|
||||||
|
|
||||||
SetAlpha( &color, 150 );
|
SetAlpha( &color, 150 );
|
||||||
|
|
||||||
GRSetDrawMode( DC, draw_mode );
|
GRSetDrawMode( aDC, aDrawMode );
|
||||||
|
|
||||||
|
|
||||||
l_trace = m_Width >> 1;
|
l_trace = m_Width >> 1;
|
||||||
|
@ -624,29 +624,29 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
|
||||||
radius = (int) hypot( (double) ( m_End.x - m_Start.x ),
|
radius = (int) hypot( (double) ( m_End.x - m_Start.x ),
|
||||||
(double) ( m_End.y - m_Start.y ) );
|
(double) ( m_End.y - m_Start.y ) );
|
||||||
|
|
||||||
if( DC->LogicalToDeviceXRel( l_trace ) < MIN_DRAW_WIDTH )
|
if( aDC->LogicalToDeviceXRel( l_trace ) <= MIN_DRAW_WIDTH )
|
||||||
{
|
{
|
||||||
GRCircle( panel->GetClipBox(), DC, m_Start.x + aOffset.x,
|
GRCircle( panel->GetClipBox(), aDC, m_Start.x + aOffset.x,
|
||||||
m_Start.y + aOffset.y, radius, color );
|
m_Start.y + aOffset.y, radius, color );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
if( DC->LogicalToDeviceXRel( l_trace ) <= 1 ) /* Sketch mode if l_trace/zoom <= 1 */
|
if( aDC->LogicalToDeviceXRel( l_trace ) <= MIN_DRAW_WIDTH ) // Line mode if too small
|
||||||
{
|
{
|
||||||
GRCircle( panel->GetClipBox(), DC, m_Start.x + aOffset.x,
|
GRCircle( panel->GetClipBox(), aDC, m_Start.x + aOffset.x,
|
||||||
m_Start.y + aOffset.y, radius, color );
|
m_Start.y + aOffset.y, radius, color );
|
||||||
}
|
}
|
||||||
else if( ( !DisplayOpt.DisplayPcbTrackFill) || GetState( FORCE_SKETCH ) )
|
else if( ( !DisplayOpt.DisplayPcbTrackFill) || GetState( FORCE_SKETCH ) )
|
||||||
{
|
{
|
||||||
GRCircle( panel->GetClipBox(), DC, m_Start.x + aOffset.x,
|
GRCircle( panel->GetClipBox(), aDC, m_Start.x + aOffset.x,
|
||||||
m_Start.y + aOffset.y, radius - l_trace, color );
|
m_Start.y + aOffset.y, radius - l_trace, color );
|
||||||
GRCircle( panel->GetClipBox(), DC, m_Start.x + aOffset.x,
|
GRCircle( panel->GetClipBox(), aDC, m_Start.x + aOffset.x,
|
||||||
m_Start.y + aOffset.y, radius + l_trace, color );
|
m_Start.y + aOffset.y, radius + l_trace, color );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GRCircle( panel->GetClipBox(), DC, m_Start.x + aOffset.x,
|
GRCircle( panel->GetClipBox(), aDC, m_Start.x + aOffset.x,
|
||||||
m_Start.y + aOffset.y, radius, m_Width, color );
|
m_Start.y + aOffset.y, radius, m_Width, color );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -654,19 +654,19 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( DC->LogicalToDeviceXRel( l_trace ) < MIN_DRAW_WIDTH )
|
if( aDC->LogicalToDeviceXRel( l_trace ) <= MIN_DRAW_WIDTH )
|
||||||
{
|
{
|
||||||
GRLine( panel->GetClipBox(), DC, m_Start + aOffset, m_End + aOffset, 0, color );
|
GRLine( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, 0, color );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !DisplayOpt.DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
|
if( !DisplayOpt.DisplayPcbTrackFill || GetState( FORCE_SKETCH ) )
|
||||||
{
|
{
|
||||||
GRCSegm( panel->GetClipBox(), DC, m_Start + aOffset, m_End + aOffset, m_Width, color );
|
GRCSegm( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset, m_Width, color );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GRFillCSegm( panel->GetClipBox(), DC, m_Start.x + aOffset.x,
|
GRFillCSegm( panel->GetClipBox(), aDC, m_Start.x + aOffset.x,
|
||||||
m_Start.y + aOffset.y,
|
m_Start.y + aOffset.y,
|
||||||
m_End.x + aOffset.x, m_End.y + aOffset.y, m_Width, color );
|
m_End.x + aOffset.x, m_End.y + aOffset.y, m_Width, color );
|
||||||
}
|
}
|
||||||
|
@ -677,14 +677,13 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
|
||||||
// Show clearance for tracks, not for zone segments
|
// Show clearance for tracks, not for zone segments
|
||||||
if( ShowClearance( this ) )
|
if( ShowClearance( this ) )
|
||||||
{
|
{
|
||||||
GRCSegm( panel->GetClipBox(), DC, m_Start + aOffset, m_End + aOffset,
|
GRCSegm( panel->GetClipBox(), aDC, m_Start + aOffset, m_End + aOffset,
|
||||||
m_Width + (GetClearance() * 2), color );
|
m_Width + (GetClearance() * 2), color );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Display the short netname for tracks, not for zone segments.
|
/* Display the short netname for tracks, not for zone segments.
|
||||||
* we must filter tracks, to avoid a lot of texts.
|
* we must filter tracks, to avoid a lot of texts.
|
||||||
* - only horizontal or vertical tracks are eligible
|
* - only tracks with a length > 10 * thickness are eligible
|
||||||
* - only tracks with a length > 10 * thickness are eligible
|
|
||||||
* and, of course, if we are not printing the board
|
* and, of course, if we are not printing the board
|
||||||
*/
|
*/
|
||||||
if( Type() == PCB_ZONE_T )
|
if( Type() == PCB_ZONE_T )
|
||||||
|
@ -694,15 +693,14 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#define THRESHOLD 10
|
#define THRESHOLD 10
|
||||||
if( (m_End.x - m_Start.x) != 0 && (m_End.y - m_Start.y) != 0 )
|
|
||||||
return;
|
|
||||||
|
|
||||||
int len = std::abs( (m_End.x - m_Start.x) + (m_End.y - m_Start.y) );
|
int len = int( hypot( (m_End.x - m_Start.x), (m_End.y - m_Start.y) ) );
|
||||||
|
|
||||||
if( len < THRESHOLD * m_Width )
|
if( len < THRESHOLD * m_Width )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( DC->LogicalToDeviceXRel( m_Width ) < 6 ) // no room to display a text inside track
|
// no room to display a text inside track
|
||||||
|
if( aDC->LogicalToDeviceXRel( m_Width ) < MIN_TEXT_SIZE )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( GetNet() == 0 )
|
if( GetNet() == 0 )
|
||||||
|
@ -719,32 +717,53 @@ void TRACK::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
|
||||||
{
|
{
|
||||||
// calculate a good size for the text
|
// calculate a good size for the text
|
||||||
int tsize = std::min( m_Width, len / textlen );
|
int tsize = std::min( m_Width, len / textlen );
|
||||||
|
int dx = m_End.x - m_Start.x ;
|
||||||
|
int dy = m_End.y - m_Start.y ;
|
||||||
wxPoint tpos = m_Start + m_End;
|
wxPoint tpos = m_Start + m_End;
|
||||||
tpos.x /= 2;
|
tpos.x /= 2;
|
||||||
tpos.y /= 2;
|
tpos.y /= 2;
|
||||||
|
|
||||||
// Calculate angle: if the track segment is vertical, angle = 90 degrees
|
// Calculate angle: if the track segment is vertical, angle = 90 degrees
|
||||||
int angle = 0;
|
// If horizontal 0 degrees, otherwise compute it
|
||||||
|
int angle; // angle is in 0.1 degree
|
||||||
|
|
||||||
if( (m_End.x - m_Start.x) == 0 ) // Vertical segment
|
if( dy == 0 ) // Horizontal segment
|
||||||
angle = 900; // angle is in 0.1 degree
|
|
||||||
|
|
||||||
if( DC->LogicalToDeviceXRel( tsize ) >= 6 )
|
|
||||||
{
|
{
|
||||||
if( !(!IsOnLayer( curr_layer )&& DisplayOpt.ContrastModeDisplay) )
|
angle = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( dx == 0 ) // Vertical segment
|
||||||
{
|
{
|
||||||
tsize = (tsize * 8) / 10; // small reduction to give a better look
|
angle = 900;
|
||||||
DrawGraphicText( panel, DC, tpos,
|
|
||||||
WHITE, net->GetShortNetname(), angle, wxSize( tsize, tsize ),
|
|
||||||
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, tsize / 7,
|
|
||||||
false, false );
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* atan2 is *not* the solution here, since can give upside
|
||||||
|
down text. We want to work only in the first and fourth quadrant */
|
||||||
|
angle = 10 * RAD2DEG( -atan( double( dy )/ double( dx ) ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ( aDC->LogicalToDeviceXRel( tsize ) >= MIN_TEXT_SIZE )
|
||||||
|
&& ( !(!IsOnLayer( curr_layer )&& DisplayOpt.ContrastModeDisplay) ) )
|
||||||
|
{
|
||||||
|
if( (aDrawMode & GR_XOR) == 0 )
|
||||||
|
GRSetDrawMode( aDC, GR_COPY );
|
||||||
|
|
||||||
|
tsize = (tsize * 8) / 10; // small reduction to give a better look
|
||||||
|
DrawGraphicHaloText( panel, aDC, tpos,
|
||||||
|
color, BLACK, WHITE, net->GetShortNetname(), angle,
|
||||||
|
wxSize( tsize, tsize ),
|
||||||
|
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
|
||||||
|
tsize / 7,
|
||||||
|
false, false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
|
void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* aDC, GR_DRAWMODE aDrawMode,
|
||||||
const wxPoint& aOffset )
|
const wxPoint& aOffset )
|
||||||
{
|
{
|
||||||
int radius;
|
int radius;
|
||||||
|
@ -757,7 +776,7 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
|
||||||
if( frame->m_DisplayViaFill == FILLED )
|
if( frame->m_DisplayViaFill == FILLED )
|
||||||
fillvia = 1;
|
fillvia = 1;
|
||||||
|
|
||||||
GRSetDrawMode( DC, draw_mode );
|
GRSetDrawMode( aDC, aDrawMode );
|
||||||
|
|
||||||
BOARD * brd = GetBoard( );
|
BOARD * brd = GetBoard( );
|
||||||
EDA_COLOR_T color = brd->GetVisibleElementColor(VIAS_VISIBLE + m_Shape);
|
EDA_COLOR_T color = brd->GetVisibleElementColor(VIAS_VISIBLE + m_Shape);
|
||||||
|
@ -772,8 +791,8 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
|
||||||
ColorTurnToDarkDarkGray( &color );
|
ColorTurnToDarkDarkGray( &color );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( draw_mode & GR_HIGHLIGHT )
|
if( aDrawMode & GR_HIGHLIGHT )
|
||||||
ColorChangeHighlightFlag( &color, !(draw_mode & GR_AND) );
|
ColorChangeHighlightFlag( &color, !(aDrawMode & GR_AND) );
|
||||||
|
|
||||||
ColorApplyHighlightFlag( &color );
|
ColorApplyHighlightFlag( &color );
|
||||||
|
|
||||||
|
@ -783,16 +802,16 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
|
||||||
radius = m_Width >> 1;
|
radius = m_Width >> 1;
|
||||||
// for small via size on screen (radius < 4 pixels) draw a simplified shape
|
// for small via size on screen (radius < 4 pixels) draw a simplified shape
|
||||||
|
|
||||||
int radius_in_pixels = DC->LogicalToDeviceXRel( radius );
|
int radius_in_pixels = aDC->LogicalToDeviceXRel( radius );
|
||||||
|
|
||||||
bool fast_draw = false;
|
bool fast_draw = false;
|
||||||
|
|
||||||
// Vias are drawn as a filled circle or a double circle. The hole will be drawn later
|
// Vias are drawn as a filled circle or a double circle. The hole will be drawn later
|
||||||
int drill_radius = GetDrillValue() / 2;
|
int drill_radius = GetDrillValue() / 2;
|
||||||
|
|
||||||
int inner_radius = radius - DC->DeviceToLogicalXRel( 2 );
|
int inner_radius = radius - aDC->DeviceToLogicalXRel( 2 );
|
||||||
|
|
||||||
if( radius_in_pixels < 3 )
|
if( radius_in_pixels < MIN_VIA_DRAW_SIZE )
|
||||||
{
|
{
|
||||||
fast_draw = true;
|
fast_draw = true;
|
||||||
fillvia = false;
|
fillvia = false;
|
||||||
|
@ -800,16 +819,16 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
|
||||||
|
|
||||||
if( fillvia )
|
if( fillvia )
|
||||||
{
|
{
|
||||||
GRFilledCircle( panel->GetClipBox(), DC, m_Start + aOffset, radius, color );
|
GRFilledCircle( panel->GetClipBox(), aDC, m_Start + aOffset, radius, color );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GRCircle( panel->GetClipBox(), DC, m_Start + aOffset,radius, 0, color );
|
GRCircle( panel->GetClipBox(), aDC, m_Start + aOffset, radius, 0, color );
|
||||||
|
|
||||||
if ( fast_draw )
|
if ( fast_draw )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
GRCircle( panel->GetClipBox(), DC, m_Start + aOffset, inner_radius, 0, color );
|
GRCircle( panel->GetClipBox(), aDC, m_Start + aOffset, inner_radius, 0, color );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw the via hole if the display option allows it
|
// Draw the via hole if the display option allows it
|
||||||
|
@ -834,13 +853,11 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
|
||||||
color = BLACK; // or DARKGRAY;
|
color = BLACK; // or DARKGRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( draw_mode != GR_XOR )
|
if( (aDrawMode & GR_XOR) == 0)
|
||||||
GRSetDrawMode( DC, GR_COPY );
|
GRSetDrawMode( aDC, GR_COPY );
|
||||||
else
|
|
||||||
GRSetDrawMode( DC, GR_XOR );
|
|
||||||
|
|
||||||
if( DC->LogicalToDeviceXRel( drill_radius ) > 1 ) // Draw hole if large enough.
|
if( aDC->LogicalToDeviceXRel( drill_radius ) > MIN_DRAW_WIDTH ) // Draw hole if large enough.
|
||||||
GRFilledCircle( panel->GetClipBox(), DC, m_Start.x + aOffset.x,
|
GRFilledCircle( panel->GetClipBox(), aDC, m_Start.x + aOffset.x,
|
||||||
m_Start.y + aOffset.y, drill_radius, 0, color, color );
|
m_Start.y + aOffset.y, drill_radius, 0, color, color );
|
||||||
|
|
||||||
if( screen->m_IsPrinting )
|
if( screen->m_IsPrinting )
|
||||||
|
@ -849,14 +866,14 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( drill_radius < inner_radius ) // We can show the via hole
|
if( drill_radius < inner_radius ) // We can show the via hole
|
||||||
GRCircle( panel->GetClipBox(), DC, m_Start + aOffset, drill_radius, 0, color );
|
GRCircle( panel->GetClipBox(), aDC, m_Start + aOffset, drill_radius, 0, color );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ShowClearance( this ) )
|
if( ShowClearance( this ) )
|
||||||
{
|
{
|
||||||
GRCircle( panel->GetClipBox(), DC, m_Start + aOffset, radius + GetClearance(), 0, color );
|
GRCircle( panel->GetClipBox(), aDC, m_Start + aOffset, radius + GetClearance(), 0, color );
|
||||||
}
|
}
|
||||||
|
|
||||||
// for Micro Vias, draw a partial cross : X on component layer, or + on copper layer
|
// for Micro Vias, draw a partial cross : X on component layer, or + on copper layer
|
||||||
|
@ -877,21 +894,21 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* lines | or \ */
|
/* lines | or \ */
|
||||||
GRLine( panel->GetClipBox(), DC, m_Start.x + aOffset.x - ax,
|
GRLine( panel->GetClipBox(), aDC, m_Start.x + aOffset.x - ax,
|
||||||
m_Start.y + aOffset.y - ay,
|
m_Start.y + aOffset.y - ay,
|
||||||
m_Start.x + aOffset.x - bx,
|
m_Start.x + aOffset.x - bx,
|
||||||
m_Start.y + aOffset.y - by, 0, color );
|
m_Start.y + aOffset.y - by, 0, color );
|
||||||
GRLine( panel->GetClipBox(), DC, m_Start.x + aOffset.x + bx,
|
GRLine( panel->GetClipBox(), aDC, m_Start.x + aOffset.x + bx,
|
||||||
m_Start.y + aOffset.y + by,
|
m_Start.y + aOffset.y + by,
|
||||||
m_Start.x + aOffset.x + ax,
|
m_Start.x + aOffset.x + ax,
|
||||||
m_Start.y + aOffset.y + ay, 0, color );
|
m_Start.y + aOffset.y + ay, 0, color );
|
||||||
|
|
||||||
/* lines - or / */
|
// lines - or /
|
||||||
GRLine( panel->GetClipBox(), DC, m_Start.x + aOffset.x + ay,
|
GRLine( panel->GetClipBox(), aDC, m_Start.x + aOffset.x + ay,
|
||||||
m_Start.y + aOffset.y - ax,
|
m_Start.y + aOffset.y - ax,
|
||||||
m_Start.x + aOffset.x + by,
|
m_Start.x + aOffset.x + by,
|
||||||
m_Start.y + aOffset.y - bx, 0, color );
|
m_Start.y + aOffset.y - bx, 0, color );
|
||||||
GRLine( panel->GetClipBox(), DC, m_Start.x + aOffset.x - by,
|
GRLine( panel->GetClipBox(), aDC, m_Start.x + aOffset.x - by,
|
||||||
m_Start.y + aOffset.y + bx,
|
m_Start.y + aOffset.y + bx,
|
||||||
m_Start.x + aOffset.x - ay,
|
m_Start.x + aOffset.x - ay,
|
||||||
m_Start.y + aOffset.y + ax, 0, color );
|
m_Start.y + aOffset.y + ax, 0, color );
|
||||||
|
@ -906,19 +923,19 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
|
||||||
|
|
||||||
( (SEGVIA*) this )->ReturnLayerPair( &layer_top, &layer_bottom );
|
( (SEGVIA*) this )->ReturnLayerPair( &layer_top, &layer_bottom );
|
||||||
|
|
||||||
/* lines for the top layer */
|
// lines for the top layer
|
||||||
RotatePoint( &ax, &ay, layer_top * 3600 / brd->GetCopperLayerCount( ) );
|
RotatePoint( &ax, &ay, layer_top * 3600 / brd->GetCopperLayerCount( ) );
|
||||||
RotatePoint( &bx, &by, layer_top * 3600 / brd->GetCopperLayerCount( ) );
|
RotatePoint( &bx, &by, layer_top * 3600 / brd->GetCopperLayerCount( ) );
|
||||||
GRLine( panel->GetClipBox(), DC, m_Start.x + aOffset.x - ax,
|
GRLine( panel->GetClipBox(), aDC, m_Start.x + aOffset.x - ax,
|
||||||
m_Start.y + aOffset.y - ay,
|
m_Start.y + aOffset.y - ay,
|
||||||
m_Start.x + aOffset.x - bx,
|
m_Start.x + aOffset.x - bx,
|
||||||
m_Start.y + aOffset.y - by, 0, color );
|
m_Start.y + aOffset.y - by, 0, color );
|
||||||
|
|
||||||
/* lines for the bottom layer */
|
// lines for the bottom layer
|
||||||
ax = 0; ay = radius; bx = 0; by = drill_radius;
|
ax = 0; ay = radius; bx = 0; by = drill_radius;
|
||||||
RotatePoint( &ax, &ay, layer_bottom * 3600 / brd->GetCopperLayerCount( ) );
|
RotatePoint( &ax, &ay, layer_bottom * 3600 / brd->GetCopperLayerCount( ) );
|
||||||
RotatePoint( &bx, &by, layer_bottom * 3600 / brd->GetCopperLayerCount( ) );
|
RotatePoint( &bx, &by, layer_bottom * 3600 / brd->GetCopperLayerCount( ) );
|
||||||
GRLine( panel->GetClipBox(), DC, m_Start.x + aOffset.x - ax,
|
GRLine( panel->GetClipBox(), aDC, m_Start.x + aOffset.x - ax,
|
||||||
m_Start.y + aOffset.y - ay,
|
m_Start.y + aOffset.y - ay,
|
||||||
m_Start.x + aOffset.x - bx,
|
m_Start.x + aOffset.x - bx,
|
||||||
m_Start.y + aOffset.y - by, 0, color );
|
m_Start.y + aOffset.y - by, 0, color );
|
||||||
|
@ -943,13 +960,17 @@ void SEGVIA::Draw( EDA_DRAW_PANEL* panel, wxDC* DC, GR_DRAWMODE draw_mode,
|
||||||
// calculate a good size for the text
|
// calculate a good size for the text
|
||||||
int tsize = m_Width / len;
|
int tsize = m_Width / len;
|
||||||
|
|
||||||
if( DC->LogicalToDeviceXRel( tsize ) >= 6 )
|
if( aDC->LogicalToDeviceXRel( tsize ) >= MIN_TEXT_SIZE )
|
||||||
{
|
{
|
||||||
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,
|
if( (aDrawMode & GR_XOR) == 0 )
|
||||||
WHITE, net->GetShortNetname(), 0, wxSize( tsize, tsize ),
|
GRSetDrawMode( aDC, GR_COPY );
|
||||||
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, tsize / 7,
|
|
||||||
false, false );
|
DrawGraphicHaloText( panel, aDC, m_Start,
|
||||||
|
color, WHITE, BLACK, net->GetShortNetname(), 0,
|
||||||
|
wxSize( tsize, tsize ),
|
||||||
|
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER,
|
||||||
|
tsize / 7, false, false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,7 @@ class MSG_PANEL_ITEM;
|
||||||
|
|
||||||
#define UNDEFINED_DRILL_DIAMETER -1 //< Undefined via drill diameter.
|
#define UNDEFINED_DRILL_DIAMETER -1 //< Undefined via drill diameter.
|
||||||
|
|
||||||
|
#define MIN_VIA_DRAW_SIZE 4 /// Minimum size in pixel for full drawing
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function GetTrace
|
* Function GetTrace
|
||||||
|
|
Loading…
Reference in New Issue