Set unprinted layer colors to background.

This allows our Black&White special cases to still work when the
hole annular rings aren't being printed.

Fixes https://gitlab.com/kicad/code/kicad/issues/7692
This commit is contained in:
Jeff Young 2021-02-25 13:02:33 +00:00
parent 1ac81c04e5
commit 2c009906e5
2 changed files with 28 additions and 20 deletions

View File

@ -128,8 +128,8 @@ void BOARD_PRINTOUT::DrawPage( const wxString& aLayerName, int aPageNum, int aPa
dstSettings->SetIsPrinting( true ); dstSettings->SetIsPrinting( true );
setupViewLayers( *view, m_settings.m_LayerSet );
setupPainter( *painter ); setupPainter( *painter );
setupViewLayers( *view, m_settings.m_LayerSet );
auto sheetSizeMils = m_settings.m_pageInfo.GetSizeMils(); auto sheetSizeMils = m_settings.m_pageInfo.GetSizeMils();
VECTOR2I sheetSizeIU( milsToIU( sheetSizeMils.GetWidth() ), milsToIU( sheetSizeMils.GetHeight() ) ); VECTOR2I sheetSizeIU( milsToIU( sheetSizeMils.GetWidth() ), milsToIU( sheetSizeMils.GetHeight() ) );

View File

@ -132,22 +132,27 @@ void PCBNEW_PRINTOUT::setupViewLayers( KIGFX::VIEW& aView, const LSET& aLayerSet
{ {
BOARD_PRINTOUT::setupViewLayers( aView, aLayerSet ); BOARD_PRINTOUT::setupViewLayers( aView, aLayerSet );
for( LSEQ layerSeq = m_settings.m_LayerSet.Seq(); layerSeq; ++layerSeq ) for( PCB_LAYER_ID layer : m_settings.m_LayerSet.Seq() )
{ {
aView.SetLayerVisible( PCBNEW_LAYER_ID_START + *layerSeq, true ); aView.SetLayerVisible( PCBNEW_LAYER_ID_START + layer, true );
// Enable the corresponding zone layer // Enable the corresponding zone layer
if( IsCopperLayer( *layerSeq ) ) if( IsCopperLayer( layer ) )
aView.SetLayerVisible( LAYER_ZONE_START + *layerSeq, true ); aView.SetLayerVisible( LAYER_ZONE_START + layer, true );
} }
RENDER_SETTINGS* renderSettings = aView.GetPainter()->GetSettings();
COLOR4D backgroundColor = renderSettings->GetLayerColor( LAYER_PCB_BACKGROUND );
if( m_pcbnewSettings.m_asItemCheckboxes ) if( m_pcbnewSettings.m_asItemCheckboxes )
{ {
auto setVisibility = auto setVisibility =
[&]( GAL_LAYER_ID aLayer ) [&]( GAL_LAYER_ID aLayer )
{ {
if( m_board->IsElementVisible( aLayer ) ) if( m_board->IsElementVisible( aLayer ) )
aView.SetLayerVisible( aLayer ); aView.SetLayerVisible( aLayer, true );
else
renderSettings->SetLayerColor( aLayer, backgroundColor );
}; };
setVisibility( LAYER_MOD_FR ); setVisibility( LAYER_MOD_FR );
@ -180,25 +185,29 @@ void PCBNEW_PRINTOUT::setupViewLayers( KIGFX::VIEW& aView, const LSET& aLayerSet
LAYER_VIA_THROUGH LAYER_VIA_THROUGH
}; };
for( int item : alwaysEnabled ) for( int layer : alwaysEnabled )
aView.SetLayerVisible( item, true ); aView.SetLayerVisible( layer, true );
} }
else else
{ {
// Enable pad layers corresponding to the selected copper layers // Enable pad layers corresponding to the selected copper layers
if( aLayerSet.test( F_Cu ) ) if( aLayerSet.test( F_Cu ) )
aView.SetLayerVisible( LAYER_PAD_FR, true ); aView.SetLayerVisible( LAYER_PAD_FR, true );
else
renderSettings->SetLayerColor( LAYER_PAD_FR, backgroundColor );
if( aLayerSet.test( B_Cu ) ) if( aLayerSet.test( B_Cu ) )
aView.SetLayerVisible( LAYER_PAD_BK, true ); aView.SetLayerVisible( LAYER_PAD_BK, true );
else
renderSettings->SetLayerColor( LAYER_PAD_BK, backgroundColor );
if( ( aLayerSet & LSET::AllCuMask() ).any() ) // Items visible on any copper layer // Enable items on copper layers, but do not draw holes
for( GAL_LAYER_ID layer : { LAYER_PADS_TH, LAYER_VIA_THROUGH } )
{ {
// Enable items on copper layers, but do not draw holes if( ( aLayerSet & LSET::AllCuMask() ).any() ) // Items visible on any copper layer
for( GAL_LAYER_ID item : { LAYER_PADS_TH, LAYER_VIA_THROUGH } ) aView.SetLayerVisible( layer, true );
{ else
aView.SetLayerVisible( item, true ); renderSettings->SetLayerColor( layer, backgroundColor );
}
} }
// Keep certain items always enabled/disabled and just rely on the layer visibility // Keep certain items always enabled/disabled and just rely on the layer visibility
@ -209,18 +218,17 @@ void PCBNEW_PRINTOUT::setupViewLayers( KIGFX::VIEW& aView, const LSET& aLayerSet
LAYER_VIAS, LAYER_VIA_MICROVIA, LAYER_VIA_BBLIND LAYER_VIAS, LAYER_VIA_MICROVIA, LAYER_VIA_BBLIND
}; };
for( int item : alwaysEnabled ) for( int layer : alwaysEnabled )
aView.SetLayerVisible( item, true ); aView.SetLayerVisible( layer, true );
} }
if( m_pcbnewSettings.m_drillMarks != PCBNEW_PRINTOUT_SETTINGS::NO_DRILL_SHAPE ) if( m_pcbnewSettings.m_drillMarks != PCBNEW_PRINTOUT_SETTINGS::NO_DRILL_SHAPE )
{ {
// Enable hole layers to draw drill marks // Enable hole layers to draw drill marks
for( GAL_LAYER_ID holeLayer : { LAYER_PAD_PLATEDHOLES, LAYER_NON_PLATEDHOLES, for( int layer : { LAYER_PAD_PLATEDHOLES, LAYER_NON_PLATEDHOLES, LAYER_VIA_HOLES } )
LAYER_VIA_HOLES } )
{ {
aView.SetLayerVisible( holeLayer, true ); aView.SetLayerVisible( layer, true );
aView.SetTopLayer( holeLayer, true ); aView.SetTopLayer( layer, true );
} }
} }
} }