2009-11-12 15:43:38 +00:00
|
|
|
/*******************************/
|
|
|
|
/* class_pad_draw_function.cpp */
|
|
|
|
/*******************************/
|
2008-12-14 19:45:05 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "common.h"
|
|
|
|
#include "trigo.h"
|
2009-09-22 12:27:57 +00:00
|
|
|
#include "pcbnew_id.h" // ID_TRACK_BUTT
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "drawtxt.h"
|
|
|
|
|
|
|
|
#include "pcbnew.h"
|
2009-10-28 11:48:47 +00:00
|
|
|
#include "class_board_design_settings.h"
|
2010-01-29 20:36:12 +00:00
|
|
|
#include "colors_selection.h"
|
2008-12-14 19:45:05 +00:00
|
|
|
|
2010-03-29 16:42:03 +00:00
|
|
|
/* uncomment this line to show this pad with its specfic size and color
|
|
|
|
* when it is not on copper layers, and only one solder mask layer or solder paste layer
|
|
|
|
* is displayed for this pad
|
|
|
|
* After testing this feature,I am not sure this is a good idea
|
|
|
|
* but the code is left here.
|
|
|
|
*/
|
|
|
|
//#define SHOW_PADMASK_REAL_SIZE_AND_COLOR
|
2008-12-14 19:45:05 +00:00
|
|
|
|
|
|
|
/** Draw a pad:
|
|
|
|
* @param DC = device context
|
|
|
|
* @param offset = draw offset
|
|
|
|
* @param draw_mode = mode: GR_OR, GR_XOR, GR_AND...
|
|
|
|
*/
|
2009-11-12 15:43:38 +00:00
|
|
|
void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode,
|
|
|
|
const wxPoint& offset )
|
2008-12-14 19:45:05 +00:00
|
|
|
{
|
|
|
|
int ii;
|
|
|
|
int color = 0;
|
|
|
|
int ux0, uy0,
|
|
|
|
dx, dx0, dy, dy0,
|
|
|
|
rotdx,
|
|
|
|
delta_cx, delta_cy,
|
|
|
|
xc, yc;
|
|
|
|
int angle;
|
|
|
|
wxPoint coord[4];
|
|
|
|
int fillpad = 0;
|
|
|
|
wxPoint shape_pos;
|
2009-11-12 15:43:38 +00:00
|
|
|
wxSize mask_margin; // margin (clearance) used for some non copper layers
|
2010-03-29 16:42:03 +00:00
|
|
|
int showActualMaskSize = 0; /* == layer number if the actual pad size on mask layer can be displayed
|
|
|
|
* i.e. if only one layer is shown for this pad
|
|
|
|
* and this layer is a mask (solder mask or sloder paste
|
|
|
|
*/
|
2008-12-14 19:45:05 +00:00
|
|
|
|
|
|
|
if( m_Flags & DO_NOT_DRAW )
|
|
|
|
return;
|
|
|
|
|
2010-01-26 18:02:03 +00:00
|
|
|
/* We can show/hide pads from the layer manager.
|
|
|
|
* options are show/hide pads on front and/or back side of the board
|
|
|
|
* For through pads, we hide them only if both sides are hidden.
|
|
|
|
* smd pads on back are hidden for all layers (copper and technical layers)
|
|
|
|
* on back side of the board
|
|
|
|
* smd pads on front are hidden for all layers (copper and technical layers)
|
|
|
|
* on front side of the board
|
|
|
|
* ECO, edge and Draw layers and not considered
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Mask layers for Back side of board
|
|
|
|
#define BACK_SIDE_LAYERS \
|
|
|
|
(LAYER_BACK | ADHESIVE_LAYER_BACK | SOLDERPASTE_LAYER_BACK\
|
|
|
|
| SILKSCREEN_LAYER_BACK | SOLDERMASK_LAYER_BACK)
|
|
|
|
|
|
|
|
// Mask layers for Front side of board
|
|
|
|
#define FRONT_SIDE_LAYERS \
|
|
|
|
(LAYER_FRONT | ADHESIVE_LAYER_FRONT | SOLDERPASTE_LAYER_FRONT\
|
|
|
|
| SILKSCREEN_LAYER_FRONT | SOLDERMASK_LAYER_FRONT)
|
|
|
|
|
2010-01-31 20:01:46 +00:00
|
|
|
BOARD * brd = GetBoard( );
|
|
|
|
bool frontVisible = brd->IsElementVisible( PCB_VISIBLE(PAD_FR_VISIBLE) );
|
|
|
|
bool backVisible = brd->IsElementVisible( PCB_VISIBLE(PAD_BK_VISIBLE) );
|
2010-01-26 18:02:03 +00:00
|
|
|
|
|
|
|
if( !frontVisible && !backVisible )
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* If pad are only on front side (no layer on back side)
|
|
|
|
* and if hide front side pads is enabled, do not draw
|
|
|
|
*/
|
|
|
|
if( !frontVisible && ( (m_Masque_Layer & BACK_SIDE_LAYERS) == 0 ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* If pad are only on back side (no layer on front side)
|
|
|
|
* and if hide back side pads is enabled, do not draw
|
|
|
|
*/
|
|
|
|
if( !backVisible && ( (m_Masque_Layer & FRONT_SIDE_LAYERS) == 0 ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
2009-12-21 12:05:36 +00:00
|
|
|
WinEDA_BasePcbFrame* frame = (WinEDA_BasePcbFrame*) panel->GetParent();
|
2008-12-14 19:45:05 +00:00
|
|
|
PCB_SCREEN* screen = frame->GetScreen();
|
|
|
|
if( frame->m_DisplayPadFill == FILLED )
|
|
|
|
fillpad = 1;
|
|
|
|
|
2009-06-25 20:45:27 +00:00
|
|
|
#if defined(PCBNEW) || defined(__WXMAC__)
|
|
|
|
if( m_Flags & IS_MOVED || !DisplayOpt.DisplayPadFill )
|
2008-12-14 19:45:05 +00:00
|
|
|
fillpad = 0;
|
|
|
|
#endif
|
|
|
|
|
2009-12-21 13:05:11 +00:00
|
|
|
if( m_Masque_Layer & LAYER_FRONT )
|
2010-01-26 18:02:03 +00:00
|
|
|
{
|
2010-01-31 20:01:46 +00:00
|
|
|
color = brd->GetVisibleElementColor(PAD_FR_VISIBLE);
|
2010-01-26 18:02:03 +00:00
|
|
|
}
|
2008-12-14 19:45:05 +00:00
|
|
|
|
2009-12-21 13:05:11 +00:00
|
|
|
if( m_Masque_Layer & LAYER_BACK )
|
2010-01-26 18:02:03 +00:00
|
|
|
{
|
2010-01-31 20:01:46 +00:00
|
|
|
color |= brd->GetVisibleElementColor(PAD_BK_VISIBLE);
|
2010-01-26 18:02:03 +00:00
|
|
|
}
|
2008-12-14 19:45:05 +00:00
|
|
|
|
|
|
|
if( color == 0 ) /* Not on copper layer */
|
|
|
|
{
|
2009-10-21 19:16:25 +00:00
|
|
|
// If the pad in on only one tech layer, use the layer color
|
|
|
|
// else use DARKGRAY
|
2010-03-29 16:42:03 +00:00
|
|
|
int mask_non_copper_layers = m_Masque_Layer & ~ALL_CU_LAYERS;
|
|
|
|
#ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR
|
|
|
|
mask_non_copper_layers &= brd->GetVisibleLayers();
|
|
|
|
#endif
|
|
|
|
switch( mask_non_copper_layers )
|
2008-12-14 19:45:05 +00:00
|
|
|
{
|
2010-03-29 16:42:03 +00:00
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
|
2009-12-21 18:51:37 +00:00
|
|
|
case ADHESIVE_LAYER_BACK:
|
2010-01-31 20:01:46 +00:00
|
|
|
color = brd->GetLayerColor(ADHESIVE_N_BACK);
|
2008-12-14 19:45:05 +00:00
|
|
|
break;
|
|
|
|
|
2009-12-21 18:51:37 +00:00
|
|
|
case ADHESIVE_LAYER_FRONT:
|
2010-01-31 20:01:46 +00:00
|
|
|
color = brd->GetLayerColor(ADHESIVE_N_FRONT);
|
2008-12-14 19:45:05 +00:00
|
|
|
break;
|
|
|
|
|
2009-12-21 18:51:37 +00:00
|
|
|
case SOLDERPASTE_LAYER_BACK:
|
2010-01-31 20:01:46 +00:00
|
|
|
color = brd->GetLayerColor(SOLDERPASTE_N_BACK);
|
2010-03-29 16:42:03 +00:00
|
|
|
showActualMaskSize = SOLDERPASTE_N_BACK;
|
2008-12-14 19:45:05 +00:00
|
|
|
break;
|
|
|
|
|
2009-12-21 18:51:37 +00:00
|
|
|
case SOLDERPASTE_LAYER_FRONT:
|
2010-01-31 20:01:46 +00:00
|
|
|
color = brd->GetLayerColor(SOLDERPASTE_N_FRONT);
|
2010-03-29 16:42:03 +00:00
|
|
|
showActualMaskSize = SOLDERPASTE_N_FRONT;
|
2008-12-14 19:45:05 +00:00
|
|
|
break;
|
|
|
|
|
2009-12-21 18:51:37 +00:00
|
|
|
case SILKSCREEN_LAYER_BACK:
|
2010-01-31 20:01:46 +00:00
|
|
|
color = brd->GetLayerColor(SILKSCREEN_N_BACK);
|
2008-12-14 19:45:05 +00:00
|
|
|
break;
|
|
|
|
|
2009-12-21 18:51:37 +00:00
|
|
|
case SILKSCREEN_LAYER_FRONT:
|
2010-01-31 20:01:46 +00:00
|
|
|
color = brd->GetLayerColor(SILKSCREEN_N_FRONT);
|
2008-12-14 19:45:05 +00:00
|
|
|
break;
|
|
|
|
|
2009-12-21 18:51:37 +00:00
|
|
|
case SOLDERMASK_LAYER_BACK:
|
2010-01-31 20:01:46 +00:00
|
|
|
color = brd->GetLayerColor(SOLDERMASK_N_BACK);
|
2010-03-29 16:42:03 +00:00
|
|
|
showActualMaskSize = SOLDERMASK_N_BACK;
|
2008-12-14 19:45:05 +00:00
|
|
|
break;
|
|
|
|
|
2009-12-21 18:51:37 +00:00
|
|
|
case SOLDERMASK_LAYER_FRONT:
|
2010-01-31 20:01:46 +00:00
|
|
|
color = brd->GetLayerColor(SOLDERMASK_N_FRONT);
|
2010-03-29 16:42:03 +00:00
|
|
|
showActualMaskSize = SOLDERMASK_N_FRONT;
|
2008-12-14 19:45:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case DRAW_LAYER:
|
2010-01-31 20:01:46 +00:00
|
|
|
color = brd->GetLayerColor(DRAW_N);
|
2008-12-14 19:45:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case COMMENT_LAYER:
|
2010-01-31 20:01:46 +00:00
|
|
|
color = brd->GetLayerColor(COMMENT_N);
|
2008-12-14 19:45:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ECO1_LAYER:
|
2010-01-31 20:01:46 +00:00
|
|
|
color = brd->GetLayerColor(ECO1_N);
|
2008-12-14 19:45:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ECO2_LAYER:
|
2010-01-31 20:01:46 +00:00
|
|
|
color = brd->GetLayerColor(ECO2_N);
|
2008-12-14 19:45:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EDGE_LAYER:
|
2010-01-31 20:01:46 +00:00
|
|
|
color = brd->GetLayerColor(EDGE_N);
|
2008-12-14 19:45:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
color = DARKGRAY;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// if PAD_SMD pad and high contrast mode
|
2009-11-12 15:43:38 +00:00
|
|
|
if( ( m_Attribut == PAD_SMD || m_Attribut == PAD_CONN )
|
|
|
|
&& DisplayOpt.ContrastModeDisplay )
|
2008-12-14 19:45:05 +00:00
|
|
|
{
|
|
|
|
// when routing tracks
|
|
|
|
if( frame && frame->m_ID_current_state == ID_TRACK_BUTT )
|
|
|
|
{
|
|
|
|
int routeTop = screen->m_Route_Layer_TOP;
|
|
|
|
int routeBot = screen->m_Route_Layer_BOTTOM;
|
|
|
|
|
|
|
|
// if routing between copper and component layers,
|
|
|
|
// or the current layer is one of said 2 external copper layers,
|
|
|
|
// then highlight only the current layer.
|
2009-11-12 15:43:38 +00:00
|
|
|
if( ( ( 1 << routeTop ) | ( 1 << routeBot ) )
|
2009-12-21 13:05:11 +00:00
|
|
|
== ( LAYER_BACK | LAYER_FRONT )
|
2009-11-12 15:43:38 +00:00
|
|
|
|| ( ( 1 << screen->m_Active_Layer )
|
2009-12-21 13:05:11 +00:00
|
|
|
& ( LAYER_BACK | LAYER_FRONT ) ) )
|
2008-12-14 19:45:05 +00:00
|
|
|
{
|
|
|
|
if( !IsOnLayer( screen->m_Active_Layer ) )
|
|
|
|
{
|
|
|
|
color &= ~MASKCOLOR;
|
|
|
|
color |= DARKDARKGRAY;
|
|
|
|
}
|
|
|
|
}
|
2009-11-12 15:43:38 +00:00
|
|
|
// else routing between an internal signal layer and some other
|
|
|
|
// layer. Grey out all PAD_SMD pads not on current or the single
|
|
|
|
// selected external layer.
|
2008-12-14 19:45:05 +00:00
|
|
|
else if( !IsOnLayer( screen->m_Active_Layer )
|
|
|
|
&& !IsOnLayer( routeTop )
|
|
|
|
&& !IsOnLayer( routeBot ) )
|
|
|
|
{
|
|
|
|
color &= ~MASKCOLOR;
|
|
|
|
color |= DARKDARKGRAY;
|
|
|
|
}
|
|
|
|
}
|
2009-11-12 15:43:38 +00:00
|
|
|
// when not edting tracks, show PAD_SMD components not on active layer
|
|
|
|
// as greyed out
|
2008-12-14 19:45:05 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if( !IsOnLayer( screen->m_Active_Layer ) )
|
|
|
|
{
|
|
|
|
color &= ~MASKCOLOR;
|
|
|
|
color |= DARKDARKGRAY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-29 16:42:03 +00:00
|
|
|
#ifdef SHOW_PADMASK_REAL_SIZE_AND_COLOR
|
|
|
|
if( showActualMaskSize )
|
|
|
|
{
|
|
|
|
switch( showActualMaskSize )
|
|
|
|
{
|
|
|
|
case SOLDERMASK_N_BACK:
|
|
|
|
case SOLDERMASK_N_FRONT:
|
|
|
|
mask_margin.x = mask_margin.y = GetSolderMaskMargin();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SOLDERPASTE_N_BACK:
|
|
|
|
case SOLDERPASTE_N_FRONT:
|
|
|
|
mask_margin = GetSolderPasteMargin();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
// if Contrast mode is ON and a technical layer active, show pads on this
|
|
|
|
// layer so we can see pads on paste or solder layer and the size of the
|
|
|
|
// mask
|
2010-03-29 16:42:03 +00:00
|
|
|
if( DisplayOpt.ContrastModeDisplay && screen->m_Active_Layer > LAST_COPPER_LAYER )
|
2009-03-26 19:27:50 +00:00
|
|
|
{
|
|
|
|
if( IsOnLayer( screen->m_Active_Layer ) )
|
2009-10-21 19:16:25 +00:00
|
|
|
{
|
2010-01-31 20:01:46 +00:00
|
|
|
color = brd->GetLayerColor(screen->m_Active_Layer);
|
2009-11-04 19:08:08 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
// In hight contrast mode, and if the active layer is the mask
|
|
|
|
// layer shows the pad size with the mask clearance
|
2009-10-21 19:16:25 +00:00
|
|
|
switch( screen->m_Active_Layer )
|
|
|
|
{
|
2009-12-21 17:56:25 +00:00
|
|
|
case SOLDERMASK_N_BACK:
|
|
|
|
case SOLDERMASK_N_FRONT:
|
2009-11-04 19:08:08 +00:00
|
|
|
mask_margin.x = mask_margin.y = GetSolderMaskMargin();
|
|
|
|
break;
|
|
|
|
|
2009-12-21 17:56:25 +00:00
|
|
|
case SOLDERPASTE_N_BACK:
|
|
|
|
case SOLDERPASTE_N_FRONT:
|
2009-11-04 19:08:08 +00:00
|
|
|
mask_margin = GetSolderPasteMargin();
|
2009-10-21 19:16:25 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-03-26 19:27:50 +00:00
|
|
|
else
|
|
|
|
color = DARKDARKGRAY;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-12-14 19:45:05 +00:00
|
|
|
if( draw_mode & GR_SURBRILL )
|
|
|
|
{
|
|
|
|
if( draw_mode & GR_AND )
|
|
|
|
color &= ~HIGHT_LIGHT_FLAG;
|
|
|
|
else
|
|
|
|
color |= HIGHT_LIGHT_FLAG;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( color & HIGHT_LIGHT_FLAG )
|
|
|
|
color = ColorRefs[color & MASKCOLOR].m_LightColor;
|
|
|
|
|
|
|
|
GRSetDrawMode( DC, draw_mode ); /* mode de trace */
|
|
|
|
|
|
|
|
/* calcul du centre des pads en coordonnees Ecran : */
|
|
|
|
shape_pos = ReturnShapePos();
|
|
|
|
ux0 = shape_pos.x - offset.x;
|
|
|
|
uy0 = shape_pos.y - offset.y;
|
|
|
|
xc = ux0;
|
|
|
|
yc = uy0;
|
|
|
|
|
|
|
|
dx = dx0 = m_Size.x >> 1;
|
|
|
|
dy = dy0 = m_Size.y >> 1; /* demi dim dx et dy */
|
|
|
|
|
|
|
|
angle = m_Orient;
|
|
|
|
|
|
|
|
bool DisplayIsol = DisplayOpt.DisplayPadIsol;
|
|
|
|
if( ( m_Masque_Layer & ALL_CU_LAYERS ) == 0 )
|
|
|
|
DisplayIsol = FALSE;
|
|
|
|
|
2009-09-19 16:15:40 +00:00
|
|
|
SetAlpha( &color, 170 );
|
2009-05-30 16:06:01 +00:00
|
|
|
|
2009-09-19 16:15:40 +00:00
|
|
|
/* Get the pad clearance. This has a meaning only for Pcbnew.
|
2009-11-12 15:43:38 +00:00
|
|
|
* for Cvpcb (and Gerbview) GetClearance() creates debug errors because
|
|
|
|
* there is no net classes so a call to GetClearance() is made only when
|
|
|
|
* needed (never needed in Cvpcb nor in Gerbview)
|
2009-09-19 16:15:40 +00:00
|
|
|
*/
|
2009-10-21 19:16:25 +00:00
|
|
|
int padClearance = DisplayIsol ? GetClearance() : 0;
|
2009-09-10 15:22:26 +00:00
|
|
|
|
2008-12-14 19:45:05 +00:00
|
|
|
switch( GetShape() )
|
|
|
|
{
|
|
|
|
case PAD_CIRCLE:
|
|
|
|
if( fillpad )
|
2009-11-12 15:43:38 +00:00
|
|
|
GRFilledCircle( &panel->m_ClipBox, DC, xc, yc,
|
|
|
|
dx + mask_margin.x, 0, color, color );
|
2008-12-14 19:45:05 +00:00
|
|
|
else
|
2009-11-12 15:43:38 +00:00
|
|
|
GRCircle( &panel->m_ClipBox, DC, xc, yc, dx + mask_margin.x,
|
2010-02-22 19:56:32 +00:00
|
|
|
m_PadSketchModePenSize, color );
|
2008-12-14 19:45:05 +00:00
|
|
|
|
|
|
|
if( DisplayIsol )
|
|
|
|
{
|
|
|
|
GRCircle( &panel->m_ClipBox,
|
2009-03-26 19:27:50 +00:00
|
|
|
DC,
|
|
|
|
xc,
|
|
|
|
yc,
|
2009-09-10 15:22:26 +00:00
|
|
|
dx + padClearance,
|
2009-03-26 19:27:50 +00:00
|
|
|
0,
|
|
|
|
color );
|
2008-12-14 19:45:05 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PAD_OVAL:
|
2009-11-12 15:43:38 +00:00
|
|
|
if( dx > dy ) /* horizontal */
|
2008-12-14 19:45:05 +00:00
|
|
|
{
|
|
|
|
delta_cx = dx - dy;
|
|
|
|
delta_cy = 0;
|
2009-11-12 15:43:38 +00:00
|
|
|
rotdx = m_Size.y + ( mask_margin.y * 2 );
|
2008-12-14 19:45:05 +00:00
|
|
|
}
|
2009-11-12 15:43:38 +00:00
|
|
|
else /* vertical */
|
2008-12-14 19:45:05 +00:00
|
|
|
{
|
|
|
|
delta_cx = 0;
|
|
|
|
delta_cy = dy - dx;
|
2009-11-12 15:43:38 +00:00
|
|
|
rotdx = m_Size.x + ( mask_margin.x * 2 );
|
2008-12-14 19:45:05 +00:00
|
|
|
}
|
|
|
|
RotatePoint( &delta_cx, &delta_cy, angle );
|
|
|
|
|
|
|
|
if( fillpad )
|
|
|
|
{
|
2009-10-21 19:16:25 +00:00
|
|
|
GRFillCSegm( &panel->m_ClipBox, DC,
|
2009-10-25 15:54:00 +00:00
|
|
|
ux0 + delta_cx, uy0 + delta_cy,
|
|
|
|
ux0 - delta_cx, uy0 - delta_cy,
|
2009-11-04 19:08:08 +00:00
|
|
|
rotdx, color );
|
2008-12-14 19:45:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-10-21 19:16:25 +00:00
|
|
|
GRCSegm( &panel->m_ClipBox, DC,
|
2009-10-25 15:54:00 +00:00
|
|
|
ux0 + delta_cx, uy0 + delta_cy,
|
|
|
|
ux0 - delta_cx, uy0 - delta_cy,
|
2010-02-22 19:56:32 +00:00
|
|
|
rotdx, m_PadSketchModePenSize, color );
|
2008-12-14 19:45:05 +00:00
|
|
|
}
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
/* Draw the isolation line. */
|
2008-12-14 19:45:05 +00:00
|
|
|
if( DisplayIsol )
|
|
|
|
{
|
2009-09-10 15:22:26 +00:00
|
|
|
rotdx = rotdx + 2 * padClearance;
|
2008-12-14 19:45:05 +00:00
|
|
|
|
|
|
|
GRCSegm( &panel->m_ClipBox, DC, ux0 + delta_cx, uy0 + delta_cy,
|
2009-03-26 19:27:50 +00:00
|
|
|
ux0 - delta_cx, uy0 - delta_cy,
|
|
|
|
rotdx, color );
|
2008-12-14 19:45:05 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PAD_RECT:
|
|
|
|
case PAD_TRAPEZOID:
|
|
|
|
{
|
|
|
|
int ddx, ddy;
|
2009-11-12 15:43:38 +00:00
|
|
|
ddx = ( m_DeltaSize.x >> 1 );
|
|
|
|
ddy = ( m_DeltaSize.y >> 1 );
|
2008-12-14 19:45:05 +00:00
|
|
|
|
2009-11-04 19:08:08 +00:00
|
|
|
coord[0].x = -dx - ddy - mask_margin.x;
|
|
|
|
coord[0].y = +dy + ddx + mask_margin.y;
|
2008-12-14 19:45:05 +00:00
|
|
|
|
2009-11-04 19:08:08 +00:00
|
|
|
coord[1].x = -dx + ddy - mask_margin.x;
|
|
|
|
coord[1].y = -dy - ddx - mask_margin.y;
|
2008-12-14 19:45:05 +00:00
|
|
|
|
2009-11-04 19:08:08 +00:00
|
|
|
coord[2].x = +dx - ddy + mask_margin.x;
|
|
|
|
coord[2].y = -dy + ddx - mask_margin.y;
|
2008-12-14 19:45:05 +00:00
|
|
|
|
2009-11-04 19:08:08 +00:00
|
|
|
coord[3].x = +dx + ddy + mask_margin.x;
|
|
|
|
coord[3].y = +dy - ddx + mask_margin.y;
|
2008-12-14 19:45:05 +00:00
|
|
|
|
|
|
|
for( ii = 0; ii < 4; ii++ )
|
|
|
|
{
|
|
|
|
RotatePoint( &coord[ii].x, &coord[ii].y, angle );
|
|
|
|
coord[ii].x = coord[ii].x + ux0;
|
|
|
|
coord[ii].y = coord[ii].y + uy0;
|
|
|
|
}
|
|
|
|
|
2010-02-22 19:56:32 +00:00
|
|
|
GRClosedPoly( &panel->m_ClipBox, DC, 4, coord, fillpad,
|
|
|
|
fillpad ? 0 : m_PadSketchModePenSize, color, color );
|
2008-12-14 19:45:05 +00:00
|
|
|
|
|
|
|
if( DisplayIsol )
|
|
|
|
{
|
2009-11-04 19:08:08 +00:00
|
|
|
dx += padClearance;
|
|
|
|
dy += padClearance;
|
2008-12-14 19:45:05 +00:00
|
|
|
|
|
|
|
coord[0].x = -dx - ddy;
|
|
|
|
coord[0].y = dy + ddx;
|
|
|
|
|
|
|
|
coord[1].x = -dx + ddy;
|
|
|
|
coord[1].y = -dy - ddx;
|
|
|
|
|
|
|
|
coord[2].x = dx - ddy;
|
|
|
|
coord[2].y = -dy + ddx;
|
|
|
|
|
|
|
|
coord[3].x = dx + ddy;
|
|
|
|
coord[3].y = dy - ddx;
|
|
|
|
|
|
|
|
for( ii = 0; ii < 4; ii++ )
|
|
|
|
{
|
|
|
|
RotatePoint( &coord[ii].x, &coord[ii].y, angle );
|
|
|
|
coord[ii].x = coord[ii].x + ux0;
|
|
|
|
coord[ii].y = coord[ii].y + uy0;
|
|
|
|
}
|
|
|
|
|
2008-12-29 18:02:54 +00:00
|
|
|
GRClosedPoly( &panel->m_ClipBox, DC, 4, coord, 0, color, color );
|
2008-12-14 19:45:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Draw the pad hole */
|
|
|
|
int cx0 = m_Pos.x - offset.x;
|
|
|
|
int cy0 = m_Pos.y - offset.y;
|
|
|
|
int hole = m_Drill.x >> 1;
|
|
|
|
|
|
|
|
if( fillpad && hole )
|
|
|
|
{
|
|
|
|
bool blackpenstate = false;
|
2009-04-05 20:49:15 +00:00
|
|
|
if( screen->m_IsPrinting )
|
2008-12-14 19:45:05 +00:00
|
|
|
{
|
|
|
|
blackpenstate = GetGRForceBlackPenState();
|
|
|
|
GRForceBlackPen( false );
|
2009-01-15 14:32:29 +00:00
|
|
|
color = g_DrawBgColor;
|
2008-12-14 19:45:05 +00:00
|
|
|
}
|
|
|
|
else
|
2009-11-12 15:43:38 +00:00
|
|
|
color = BLACK; // or DARKGRAY;
|
2008-12-14 19:45:05 +00:00
|
|
|
|
|
|
|
if( draw_mode != GR_XOR )
|
|
|
|
GRSetDrawMode( DC, GR_COPY );
|
|
|
|
else
|
|
|
|
GRSetDrawMode( DC, GR_XOR );
|
|
|
|
|
|
|
|
switch( m_DrillShape )
|
|
|
|
{
|
|
|
|
case PAD_CIRCLE:
|
2010-02-08 18:15:42 +00:00
|
|
|
|
|
|
|
#ifdef USE_WX_ZOOM
|
|
|
|
if( DC->LogicalToDeviceXRel( hole ) > 1 )
|
|
|
|
#else
|
|
|
|
if( screen->Scale( hole ) > 1 ) /* draw hole if its size is enough */
|
|
|
|
#endif
|
2009-11-12 15:43:38 +00:00
|
|
|
GRFilledCircle( &panel->m_ClipBox, DC, cx0, cy0, hole, 0,
|
|
|
|
color, color );
|
2008-12-14 19:45:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PAD_OVAL:
|
|
|
|
dx = m_Drill.x >> 1;
|
2009-11-12 15:43:38 +00:00
|
|
|
dy = m_Drill.y >> 1;
|
2008-12-14 19:45:05 +00:00
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
if( m_Drill.x > m_Drill.y ) /* horizontal */
|
2008-12-14 19:45:05 +00:00
|
|
|
{
|
2009-11-12 15:43:38 +00:00
|
|
|
delta_cx = dx - dy;
|
|
|
|
delta_cy = 0;
|
2008-12-14 19:45:05 +00:00
|
|
|
rotdx = m_Drill.y;
|
|
|
|
}
|
2009-11-12 15:43:38 +00:00
|
|
|
else /* vertical */
|
2008-12-14 19:45:05 +00:00
|
|
|
{
|
2009-11-12 15:43:38 +00:00
|
|
|
delta_cx = 0;
|
|
|
|
delta_cy = dy - dx;
|
2008-12-14 19:45:05 +00:00
|
|
|
rotdx = m_Drill.x;
|
|
|
|
}
|
|
|
|
RotatePoint( &delta_cx, &delta_cy, angle );
|
|
|
|
|
2009-03-23 19:54:15 +00:00
|
|
|
GRFillCSegm( &panel->m_ClipBox, DC, cx0 + delta_cx, cy0 + delta_cy,
|
2009-11-12 15:43:38 +00:00
|
|
|
cx0 - delta_cx, cy0 - delta_cy, rotdx, color );
|
2008-12-14 19:45:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
if( screen->m_IsPrinting )
|
2008-12-14 19:45:05 +00:00
|
|
|
GRForceBlackPen( blackpenstate );
|
|
|
|
}
|
|
|
|
|
|
|
|
GRSetDrawMode( DC, draw_mode );
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
/* Draw "No connect" ( / or \ or cross X ) if necessary. : */
|
2010-01-31 20:01:46 +00:00
|
|
|
if( m_Netname.IsEmpty() && brd->IsElementVisible( PCB_VISIBLE(NO_CONNECTS_VISIBLE) ) )
|
2008-12-14 19:45:05 +00:00
|
|
|
{
|
|
|
|
dx0 = MIN( dx0, dy0 );
|
|
|
|
int nc_color = BLUE;
|
|
|
|
|
2009-12-21 13:05:11 +00:00
|
|
|
if( m_Masque_Layer & LAYER_FRONT ) /* Draw \ */
|
2008-12-14 19:45:05 +00:00
|
|
|
GRLine( &panel->m_ClipBox, DC, cx0 - dx0, cy0 - dx0,
|
2009-03-26 19:27:50 +00:00
|
|
|
cx0 + dx0, cy0 + dx0, 0, nc_color );
|
2008-12-14 19:45:05 +00:00
|
|
|
|
2009-12-21 13:05:11 +00:00
|
|
|
if( m_Masque_Layer & LAYER_BACK ) /* Draw / */
|
2008-12-14 19:45:05 +00:00
|
|
|
GRLine( &panel->m_ClipBox, DC, cx0 + dx0, cy0 - dx0,
|
2009-03-26 19:27:50 +00:00
|
|
|
cx0 - dx0, cy0 + dx0, 0, nc_color );
|
2008-12-14 19:45:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Draw the pad number */
|
2009-03-26 19:27:50 +00:00
|
|
|
bool display_padnum = true;
|
2008-12-14 19:45:05 +00:00
|
|
|
if( frame && !frame->m_DisplayPadNum )
|
2009-03-26 19:27:50 +00:00
|
|
|
display_padnum = false;
|
|
|
|
|
|
|
|
bool display_netname = true;
|
2009-11-12 15:43:38 +00:00
|
|
|
if( ( DisplayOpt.DisplayNetNamesMode == 0 )
|
|
|
|
|| ( DisplayOpt.DisplayNetNamesMode == 2 ) )
|
2009-03-26 19:27:50 +00:00
|
|
|
display_netname = false;
|
|
|
|
|
|
|
|
if( !display_padnum && !display_netname )
|
2008-12-14 19:45:05 +00:00
|
|
|
return;
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
wxPoint tpos0 = wxPoint( ux0, uy0 ); // Position of the centre of text
|
2008-12-14 19:45:05 +00:00
|
|
|
wxPoint tpos = tpos0;
|
2009-11-12 15:43:38 +00:00
|
|
|
wxSize AreaSize; // size of text area, normalized to
|
|
|
|
// AreaSize.y < AreaSize.x
|
2009-03-26 19:27:50 +00:00
|
|
|
int shortname_len = m_ShortNetname.Len();
|
2009-09-19 16:15:40 +00:00
|
|
|
if( !display_netname )
|
2009-03-26 19:27:50 +00:00
|
|
|
shortname_len = 0;
|
2008-12-14 19:45:05 +00:00
|
|
|
if( GetShape() == PAD_CIRCLE )
|
|
|
|
angle = 0;
|
|
|
|
AreaSize = m_Size;
|
|
|
|
if( m_Size.y > m_Size.x )
|
|
|
|
{
|
|
|
|
angle += 900;
|
|
|
|
AreaSize.x = m_Size.y;
|
|
|
|
AreaSize.y = m_Size.x;
|
|
|
|
}
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
if( shortname_len > 0 ) // if there is a netname, provides room
|
|
|
|
// to display this netname
|
2008-12-14 19:45:05 +00:00
|
|
|
{
|
2009-11-12 15:43:38 +00:00
|
|
|
AreaSize.y /= 2; // Text used only the upper area of the
|
|
|
|
// pad. The lower area displays the net
|
|
|
|
// name
|
2008-12-14 19:45:05 +00:00
|
|
|
tpos.y -= AreaSize.y / 2;
|
|
|
|
}
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
// Calculate the position of text, that is the middle point of the upper
|
|
|
|
// area of the pad
|
2008-12-14 19:45:05 +00:00
|
|
|
RotatePoint( &tpos, wxPoint( ux0, uy0 ), angle );
|
|
|
|
|
|
|
|
/* Draw text with an angle between -90 deg and + 90 deg */
|
|
|
|
int t_angle = angle;
|
|
|
|
NORMALIZE_ANGLE_90( t_angle );
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
/* Note: in next calculations, texte size is calculated for 3 or more
|
|
|
|
* 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
|
2009-03-26 19:27:50 +00:00
|
|
|
*/
|
2008-12-14 19:45:05 +00:00
|
|
|
#define MIN_CHAR_COUNT 3
|
|
|
|
wxString buffer;
|
|
|
|
|
2009-09-19 16:15:40 +00:00
|
|
|
int tsize;
|
2009-03-26 19:27:50 +00:00
|
|
|
if( display_padnum )
|
2008-12-14 19:45:05 +00:00
|
|
|
{
|
2009-03-26 19:27:50 +00:00
|
|
|
ReturnStringPadName( buffer );
|
|
|
|
int numpad_len = buffer.Len();
|
|
|
|
numpad_len = MAX( numpad_len, MIN_CHAR_COUNT );
|
2008-12-14 19:45:05 +00:00
|
|
|
|
2009-03-26 19:27:50 +00:00
|
|
|
tsize = min( AreaSize.y, AreaSize.x / numpad_len );
|
|
|
|
#define CHAR_SIZE_MIN 5
|
2010-02-08 18:15:42 +00:00
|
|
|
|
|
|
|
#ifdef USE_WX_ZOOM
|
|
|
|
if( DC->LogicalToDeviceXRel( tsize ) >= CHAR_SIZE_MIN ) // Not drawable when size too small.
|
|
|
|
#else
|
|
|
|
if( screen->Scale( tsize ) >= CHAR_SIZE_MIN ) // Not drawable when size too small.
|
|
|
|
#endif
|
2009-03-26 19:27:50 +00:00
|
|
|
{
|
2009-11-12 15:43:38 +00:00
|
|
|
tsize = (int) ( tsize * 0.8 ); // reserve room for
|
|
|
|
// marges and segments
|
|
|
|
// thickness
|
|
|
|
|
|
|
|
DrawGraphicText( panel, DC, tpos, WHITE, buffer, t_angle,
|
|
|
|
wxSize( tsize, tsize ), GR_TEXT_HJUSTIFY_CENTER,
|
|
|
|
GR_TEXT_VJUSTIFY_CENTER, tsize / 7, false, false,
|
|
|
|
false );
|
2009-03-26 19:27:50 +00:00
|
|
|
}
|
2008-12-14 19:45:05 +00:00
|
|
|
}
|
|
|
|
|
2009-03-26 19:27:50 +00:00
|
|
|
// display the short netname, if exists
|
|
|
|
if( shortname_len == 0 )
|
2008-12-14 19:45:05 +00:00
|
|
|
return;
|
2009-03-26 19:27:50 +00:00
|
|
|
|
|
|
|
shortname_len = MAX( shortname_len, MIN_CHAR_COUNT );
|
2008-12-15 10:24:19 +00:00
|
|
|
tsize = min( AreaSize.y, AreaSize.x / shortname_len );
|
2008-12-14 19:45:05 +00:00
|
|
|
|
2010-02-08 18:15:42 +00:00
|
|
|
#ifdef USE_WX_ZOOM
|
|
|
|
if( DC->LogicalToDeviceXRel( tsize ) >= CHAR_SIZE_MIN ) // Not drawable in size too small.
|
|
|
|
#else
|
|
|
|
if( screen->Scale( tsize ) >= CHAR_SIZE_MIN ) // Not drawable in size too small.
|
|
|
|
#endif
|
2008-12-14 19:45:05 +00:00
|
|
|
{
|
2009-11-12 15:43:38 +00:00
|
|
|
if( !( !IsOnLayer( screen->m_Active_Layer )
|
|
|
|
&& DisplayOpt.ContrastModeDisplay ) )
|
2009-09-19 16:15:40 +00:00
|
|
|
{
|
|
|
|
tpos = tpos0;
|
|
|
|
if( display_padnum )
|
|
|
|
tpos.y += AreaSize.y / 2;
|
|
|
|
RotatePoint( &tpos, wxPoint( ux0, uy0 ), angle );
|
|
|
|
|
2009-11-12 15:43:38 +00:00
|
|
|
tsize = (int) ( tsize * 0.8 ); // reserve room for marges and
|
|
|
|
// segments thickness
|
|
|
|
DrawGraphicText( panel, DC, tpos, WHITE, m_ShortNetname, t_angle,
|
|
|
|
wxSize( tsize, tsize ), GR_TEXT_HJUSTIFY_CENTER,
|
|
|
|
GR_TEXT_VJUSTIFY_CENTER, tsize / 7, false, false );
|
2009-09-19 16:15:40 +00:00
|
|
|
}
|
2008-12-14 19:45:05 +00:00
|
|
|
}
|
|
|
|
}
|