From da857f2774cf3fa0ce8f493c3d7511e8349bfe4c Mon Sep 17 00:00:00 2001 From: charras Date: Tue, 26 Jan 2010 18:02:03 +0000 Subject: [PATCH] Added pads show/hide from layer manager (option was existing in dialog, but not in code) --- TODO.txt | 5 ---- pcbnew/class_pad_draw_functions.cpp | 45 ++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/TODO.txt b/TODO.txt index 5e106098a4..4f978d5b63 100644 --- a/TODO.txt +++ b/TODO.txt @@ -89,11 +89,6 @@ P2) Write accessors for all items in PCB_VISIBLE such as grid control, so that * Need to add polygon aperture type. Then example 2 in RS274xrevd_e.pdf will draw properly. -* Figure out why BOARD::IsElementVisible( PAD_{FR,BK}_VISIBLE ) is never tested, - and why the pads cannot be turned off. Did something get broke? - -* Via visibility does not respond to the LAYER_WIDGET. - Dick: D1) Get the nested quote support for DSNLEXER fixed up and committed. diff --git a/pcbnew/class_pad_draw_functions.cpp b/pcbnew/class_pad_draw_functions.cpp index 258e547253..d070a04b53 100644 --- a/pcbnew/class_pad_draw_functions.cpp +++ b/pcbnew/class_pad_draw_functions.cpp @@ -38,6 +38,45 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, if( m_Flags & DO_NOT_DRAW ) return; + /* 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) + + bool frontVisible = g_DesignSettings.IsElementVisible( PCB_VISIBLE(PAD_FR_VISIBLE) ); + bool backVisible = g_DesignSettings.IsElementVisible( PCB_VISIBLE(PAD_BK_VISIBLE) ); + + 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; + + WinEDA_BasePcbFrame* frame = (WinEDA_BasePcbFrame*) panel->GetParent(); PCB_SCREEN* screen = frame->GetScreen(); if( frame->m_DisplayPadFill == FILLED ) @@ -49,10 +88,14 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, #endif if( m_Masque_Layer & LAYER_FRONT ) - color = g_PadCMPColor; + { + color = g_PadCMPColor; + } if( m_Masque_Layer & LAYER_BACK ) + { color |= g_PadCUColor; + } if( color == 0 ) /* Not on copper layer */ {