Don't render hole walls when no physical layers are visible.

Fixes https://gitlab.com/kicad/code/kicad/issues/7369
This commit is contained in:
Jeff Young 2021-02-01 16:03:05 +00:00
parent dc4b73fcef
commit 1f27b7e7df
6 changed files with 89 additions and 46 deletions

View File

@ -846,6 +846,13 @@ LSET LSET::UserMask()
}
LSET LSET::PhysicalLayersMask()
{
static const LSET saved = AllBoardTechMask() | AllCuMask();
return saved;
}
LSET LSET::UserDefinedLayers()
{
static const LSET saved( 9,

View File

@ -649,6 +649,12 @@ public:
static LSET UserMask();
/**
* Return a mask holding all layers which are physically realized. Equivalent to the copper
* layers + the board tech mask.
*/
static LSET PhysicalLayersMask();
/**
* Return a mask with all of the allowable user defined layers.
*/
@ -802,6 +808,22 @@ inline bool IsCopperLayer( LAYER_NUM aLayerId, bool aIncludeSyntheticCopperLayer
return IsCopperLayer( aLayerId );
}
inline bool IsViaPadLayer( LAYER_NUM aLayer )
{
return aLayer == LAYER_VIA_THROUGH
|| aLayer == LAYER_VIA_MICROVIA
|| aLayer == LAYER_VIA_BBLIND;
}
inline bool IsHoleLayer( LAYER_NUM aLayer )
{
return aLayer == LAYER_VIA_HOLES
|| aLayer == LAYER_VIA_HOLEWALLS
|| aLayer == LAYER_PAD_PLATEDHOLES
|| aLayer == LAYER_PAD_HOLEWALLS
|| aLayer == LAYER_NON_PLATEDHOLES;
}
/**
* Test whether a layer is a non copper and a non tech layer.
*
@ -909,7 +931,7 @@ inline int GetNetnameLayer( int aLayer )
return LAYER_PAD_FR_NETNAMES;
else if( aLayer == LAYER_PAD_BK )
return LAYER_PAD_BK_NETNAMES;
else if( aLayer >= LAYER_VIA_MICROVIA && aLayer <= LAYER_VIA_THROUGH )
else if( IsViaPadLayer( aLayer ) )
return LAYER_VIA_NETNAMES;
// Fallback

View File

@ -404,6 +404,10 @@ public:
inline bool IsLayerVisible( int aLayer ) const
{
wxCHECK( aLayer < (int) m_layers.size(), false );
if( GetPrintMode() > 0 )
return true;
return m_layers.at( aLayer ).visible;
}
@ -683,7 +687,7 @@ public:
* @return the printing mode.
*/
int GetPrintMode() { return m_printMode; }
int GetPrintMode() const { return m_printMode; }
/**
* Set the printing mode.

View File

@ -1223,22 +1223,16 @@ double PAD::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
PCB_PAINTER* painter = static_cast<PCB_PAINTER*>( aView->GetPainter() );
PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings();
BOARD* board = GetBoard();
if( board && aLayer == LAYER_PADS_TH )
{
LSET visible = board->GetVisibleLayers() & board->GetEnabledLayers();
if( !FlashLayer( visible ) )
return HIDE;
}
if( aView->GetPrintMode() > 0 ) // In printing mode the pad is always drawable
return 0.0;
LSET visible = LSET::AllLayersMask();
// Meta control for hiding all pads
if( !aView->IsLayerVisible( LAYER_PADS ) )
return HIDE;
// Handle board visibility (unless printing)
if( board && !aView->GetPrintMode() )
visible = board->GetVisibleLayers() & board->GetEnabledLayers();
// Handle Render tab switches
if( ( GetAttribute() == PAD_ATTRIB_PTH || GetAttribute() == PAD_ATTRIB_NPTH )
&& !aView->IsLayerVisible( LAYER_PADS_TH ) )
@ -1258,14 +1252,30 @@ double PAD::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
if( IsBackLayer( (PCB_LAYER_ID) aLayer ) && !aView->IsLayerVisible( LAYER_PAD_BK ) )
return HIDE;
if( IsNetnameLayer( aLayer ) )
if( aLayer == LAYER_PADS_TH )
{
if( !FlashLayer( visible ) )
return HIDE;
}
else if( IsHoleLayer( aLayer ) )
{
if( !( visible & LSET::PhysicalLayersMask() ).any() )
return HIDE;
}
else if( IsNetnameLayer( aLayer ) )
{
// Hide netnames unless pad is flashed to a high-contrast layer
if( renderSettings->GetHighContrast() )
{
// Hide netnames unless pad is flashed to a high-contrast layer
if( !FlashLayer( renderSettings->GetPrimaryHighContrastLayer() ) )
return HIDE;
}
else
{
// Hide netnames unless pad is flashed to a visible layer
if( !FlashLayer( visible ) )
return HIDE;
}
// Netnames will be shown only if zoom is appropriate
int divisor = std::min( GetBoundingBox().GetWidth(), GetBoundingBox().GetHeight() );

View File

@ -233,9 +233,7 @@ COLOR4D PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) cons
if( aLayer == LAYER_MARKER_SHADOWS )
return m_backgroundColor.WithAlpha( 0.6 );
if( aLayer == LAYER_PAD_PLATEDHOLES
|| aLayer == LAYER_NON_PLATEDHOLES
|| aLayer == LAYER_VIA_HOLES )
if( IsHoleLayer( aLayer ) )
{
// Careful that we don't end up with the same colour for the annular ring and the hole
// when printing in B&W.

View File

@ -596,46 +596,48 @@ double VIA::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
PCB_PAINTER* painter = static_cast<PCB_PAINTER*>( aView->GetPainter() );
PCB_RENDER_SETTINGS* renderSettings = painter->GetSettings();
BOARD* board = GetBoard();
LSET visible = LSET::AllLayersMask();
if( IsNetnameLayer( aLayer ) )
// Meta control for hiding all vias
if( !aView->IsLayerVisible( LAYER_VIAS ) )
return HIDE;
// Handle board visibility (unless printing)
if( board && !aView->GetPrintMode() )
visible = board->GetVisibleLayers() & board->GetEnabledLayers();
if( IsViaPadLayer( aLayer ) )
{
if( !FlashLayer( visible ) )
return HIDE;
}
else if( IsHoleLayer( aLayer ) )
{
if( !( visible & LSET::PhysicalLayersMask() ).any() )
return HIDE;
}
else if( IsNetnameLayer( aLayer ) )
{
// Show netnames only if via is flashed to a high-contrast layer
if( renderSettings->GetHighContrast() )
{
// Hide netnames unless via is flashed to a high-contrast layer
if( !FlashLayer( renderSettings->GetPrimaryHighContrastLayer() ) )
return HIDE;
}
else
{
// Hide netnames unless pad is flashed to a visible layer
if( !FlashLayer( visible ) )
return HIDE;
}
// Netnames will be shown only if zoom is appropriate
return m_Width == 0 ? HIDE : ( (double)Millimeter2iu( 10 ) / m_Width );
}
bool onVisibleLayer = false;
PCB_LAYER_ID top;
PCB_LAYER_ID bottom;
LayerPair( &top, &bottom );
for( int layer = top; layer <= bottom; ++layer )
{
if( aView->IsLayerVisible( layer ) )
{
onVisibleLayer = true;
break;
}
}
// Draw through vias unconditionally if the vias control is turned on.
// Draw blind/buried/microvias only if at least one of the layers crossed is enabeld.
if( aView->IsLayerVisible( LAYER_VIAS ) )
{
if( !onVisibleLayer && m_viaType != VIATYPE::THROUGH )
return HIDE;
return aView->IsLayerVisible( LAYER_VIAS ) ? 0.0 : HIDE;
}
return HIDE;
// Passed all tests; show.
return 0.0;
}