From 4233886a0563721fa5efb00ce541756fda529020 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 19 Oct 2020 23:14:46 +0100 Subject: [PATCH] Repair drill mark printing. 1) Make sure that layer dependencies don't prevent us from drawing drill marks. 2) Don't draw pad shapes when their particular layer isn't enabled (a side effect from the above) 3) Allow the printout painter to set a different hole colour (the special case for through-hole pads was handled twice anyway -- once in LoadColors() and once in draw( D_PAD ). 4) Replace the call to getDrillSize() which handles swapping in the small mark size if set. Fixes https://gitlab.com/kicad/code/kicad/issues/4847 --- include/render_settings.h | 5 ++- pcbnew/pcb_draw_panel_gal.cpp | 12 ++--- pcbnew/pcb_painter.cpp | 28 +++++++----- pcbnew/pcbnew_printout.cpp | 84 +++++++++++++++++++---------------- 4 files changed, 74 insertions(+), 55 deletions(-) diff --git a/include/render_settings.h b/include/render_settings.h index f42fd96252..429f961ccb 100644 --- a/include/render_settings.h +++ b/include/render_settings.h @@ -253,7 +253,7 @@ public: void SetSelectFactor( float aFactor ) { m_selectFactor = aFactor; } void SetHighContrastFactor( float aFactor ) { m_hiContrastFactor = aFactor; } - // TODO: these can go away once we have Cairo-based printing + // TODO: these can go away once the worksheet is moved to Cairo-based printing wxDC* GetPrintDC() { return m_printDC; } void SetPrintDC( wxDC* aDC ) { m_printDC = aDC; } @@ -294,7 +294,8 @@ protected: // lines. This sets an absolute minimum. bool m_showPageLimits; - wxDC* m_printDC; // This can go away once we have Cairo-based printing. + wxDC* m_printDC; // This can go away once the worksheet is moved to + // Cairo-based printing. }; } diff --git a/pcbnew/pcb_draw_panel_gal.cpp b/pcbnew/pcb_draw_panel_gal.cpp index 894c1a5aa9..cb99bdfa63 100644 --- a/pcbnew/pcb_draw_panel_gal.cpp +++ b/pcbnew/pcb_draw_panel_gal.cpp @@ -548,11 +548,13 @@ void PCB_DRAW_PANEL_GAL::setDefaultLayerDeps() m_view->SetLayerDisplayOnly( LAYER_ANCHOR ); // Some more required layers settings - m_view->SetRequired( LAYER_VIAS_HOLES, LAYER_VIA_THROUGH ); - m_view->SetRequired( LAYER_VIAS_NETNAMES, LAYER_VIA_THROUGH ); - m_view->SetRequired( LAYER_PADS_PLATEDHOLES, LAYER_PADS_TH ); - m_view->SetRequired( LAYER_NON_PLATEDHOLES, LAYER_PADS_TH ); - m_view->SetRequired( LAYER_PADS_NETNAMES, LAYER_PADS_TH ); + m_view->SetRequired( LAYER_VIAS_NETNAMES, LAYER_VIAS ); + m_view->SetRequired( LAYER_PADS_NETNAMES, LAYER_PADS ); + + // Holes can be independent of their host objects (cf: printing drill marks) + m_view->SetRequired( LAYER_VIAS_HOLES, LAYER_VIAS ); + m_view->SetRequired( LAYER_PADS_PLATEDHOLES, LAYER_PADS ); + m_view->SetRequired( LAYER_NON_PLATEDHOLES, LAYER_PADS ); // Via visibility m_view->SetRequired( LAYER_VIA_MICROVIA, LAYER_VIAS ); diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 557688befa..e7bad9fd89 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -666,17 +666,25 @@ void PCB_PAINTER::draw( const VIA* aVia, int aLayer ) return; } - - // Choose drawing settings depending on if we are drawing via's pad or hole - if( aLayer == LAYER_VIAS_HOLES ) + else if( aLayer == LAYER_VIAS_HOLES ) + { radius = getDrillSize( aVia ) / 2.0; - else + } + else if( ( aLayer == LAYER_VIA_THROUGH && aVia->GetViaType() == VIATYPE::THROUGH ) + || ( aLayer == LAYER_VIA_BBLIND && aVia->GetViaType() == VIATYPE::BLIND_BURIED ) + || ( aLayer == LAYER_VIA_MICROVIA && aVia->GetViaType() == VIATYPE::MICROVIA ) ) + { radius = aVia->GetWidth() / 2.0; + } + else + { + return; + } /// Vias not connected to copper are optionally not drawn /// We draw instead the hole size to ensure we show the proper clearance if( IsCopperLayer( aLayer ) && !aVia->FlashLayer( aLayer ) ) - radius = getDrillSize(aVia) / 2.0 ; + radius = getDrillSize( aVia ) / 2.0 ; bool sketchMode = false; COLOR4D color = m_pcbSettings.GetColor( aVia, aLayer ); @@ -878,10 +886,10 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer ) COLOR4D color; // Pad hole color is pad-type-specific: the background color for plated holes and the - // pad color for NPTHs. Note the extra check for "should be" NPTHs to keep mis-marked - // holes with no annular ring from getting "lost" in the background. - if( ( aLayer == LAYER_PADS_PLATEDHOLES ) && !aPad->PadShouldBeNPTH() ) - color = m_pcbSettings.GetBackgroundColor(); + // pad color for NPTHs. However if a pad is mis-marked as plated but has no annular ring + // then it will get "lost" in the background. + if( aLayer == LAYER_PADS_PLATEDHOLES && aPad->PadShouldBeNPTH() ) + color = m_pcbSettings.GetColor( aPad, LAYER_NON_PLATEDHOLES ); else color = m_pcbSettings.GetColor( aPad, aLayer ); @@ -907,7 +915,7 @@ void PCB_PAINTER::draw( const D_PAD* aPad, int aLayer ) const SHAPE_SEGMENT* seg = aPad->GetEffectiveHoleShape(); if( seg->GetSeg().A == seg->GetSeg().B ) // Circular hole - m_gal->DrawCircle( seg->GetSeg().A, seg->GetWidth()/2 ); + m_gal->DrawCircle( seg->GetSeg().A, getDrillSize( aPad ).x / 2 ); else m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B, seg->GetWidth() ); } diff --git a/pcbnew/pcbnew_printout.cpp b/pcbnew/pcbnew_printout.cpp index a412e42511..4f635623b6 100644 --- a/pcbnew/pcbnew_printout.cpp +++ b/pcbnew/pcbnew_printout.cpp @@ -142,11 +142,12 @@ void PCBNEW_PRINTOUT::setupViewLayers( KIGFX::VIEW& aView, const LSET& aLayerSet if( m_pcbnewSettings.m_asItemCheckboxes ) { - auto setVisibility = [&]( GAL_LAYER_ID aLayer ) - { - if( m_board->IsElementVisible( aLayer ) ) - aView.SetLayerVisible( aLayer ); - }; + auto setVisibility = + [&]( GAL_LAYER_ID aLayer ) + { + if( m_board->IsElementVisible( aLayer ) ) + aView.SetLayerVisible( aLayer ); + }; setVisibility( LAYER_MOD_FR ); setVisibility( LAYER_MOD_BK ); @@ -172,9 +173,11 @@ void PCBNEW_PRINTOUT::setupViewLayers( KIGFX::VIEW& aView, const LSET& aLayerSet // Keep certain items always enabled and just rely on either the finer or coarser // visibility controls - const int alwaysEnabled[] = { - LAYER_ZONES, LAYER_PADS, LAYER_VIA_MICROVIA, LAYER_VIA_BBLIND, LAYER_VIA_THROUGH - }; + const int alwaysEnabled[] = + { + LAYER_ZONES, LAYER_PADS, LAYER_VIA_MICROVIA, LAYER_VIA_BBLIND, + LAYER_VIA_THROUGH + }; for( int item : alwaysEnabled ) aView.SetLayerVisible( item, true ); @@ -191,33 +194,34 @@ void PCBNEW_PRINTOUT::setupViewLayers( KIGFX::VIEW& aView, const LSET& aLayerSet 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 item : { LAYER_PADS_TH, LAYER_VIAS } ) + for( GAL_LAYER_ID item : { LAYER_PADS_TH, LAYER_VIA_THROUGH } ) { aView.SetLayerVisible( item, true ); } - - if( m_pcbnewSettings.m_drillMarks != PCBNEW_PRINTOUT_SETTINGS::NO_DRILL_SHAPE ) - { - // Enable hole layers to draw drill marks - for( GAL_LAYER_ID holeLayer : { LAYER_PADS_PLATEDHOLES, LAYER_NON_PLATEDHOLES, - LAYER_VIAS_HOLES } ) - { - aView.SetLayerVisible( holeLayer, true ); - aView.SetTopLayer( holeLayer, true ); - } - } } // Keep certain items always enabled/disabled and just rely on the layer visibility - const int alwaysEnabled[] = { - LAYER_MOD_TEXT_FR, LAYER_MOD_TEXT_BK, LAYER_MOD_FR, LAYER_MOD_BK, - LAYER_MOD_VALUES, LAYER_MOD_REFERENCES, LAYER_TRACKS, LAYER_ZONES, LAYER_PADS, - LAYER_VIA_MICROVIA, LAYER_VIA_BBLIND, LAYER_VIA_THROUGH - }; + const int alwaysEnabled[] = + { + LAYER_MOD_TEXT_FR, LAYER_MOD_TEXT_BK, LAYER_MOD_FR, LAYER_MOD_BK, + LAYER_MOD_VALUES, LAYER_MOD_REFERENCES, LAYER_TRACKS, LAYER_ZONES, LAYER_PADS, + LAYER_VIAS, LAYER_VIA_MICROVIA, LAYER_VIA_BBLIND + }; for( int item : alwaysEnabled ) aView.SetLayerVisible( item, true ); } + + if( m_pcbnewSettings.m_drillMarks != PCBNEW_PRINTOUT_SETTINGS::NO_DRILL_SHAPE ) + { + // Enable hole layers to draw drill marks + for( GAL_LAYER_ID holeLayer : { LAYER_PADS_PLATEDHOLES, LAYER_NON_PLATEDHOLES, + LAYER_VIAS_HOLES } ) + { + aView.SetLayerVisible( holeLayer, true ); + aView.SetTopLayer( holeLayer, true ); + } + } } @@ -229,25 +233,29 @@ void PCBNEW_PRINTOUT::setupPainter( KIGFX::PAINTER& aPainter ) switch( m_pcbnewSettings.m_drillMarks ) { - case PCBNEW_PRINTOUT_SETTINGS::NO_DRILL_SHAPE: - painter.SetDrillMarks( false, 0 ); - break; + case PCBNEW_PRINTOUT_SETTINGS::NO_DRILL_SHAPE: + painter.SetDrillMarks( false, 0 ); + break; - case PCBNEW_PRINTOUT_SETTINGS::SMALL_DRILL_SHAPE: - painter.SetDrillMarks( false, Millimeter2iu( 0.3 ) ); - break; + case PCBNEW_PRINTOUT_SETTINGS::SMALL_DRILL_SHAPE: + painter.SetDrillMarks( false, Millimeter2iu( 0.3 ) ); - case PCBNEW_PRINTOUT_SETTINGS::FULL_DRILL_SHAPE: - painter.SetDrillMarks( true ); - break; + painter.GetSettings()->SetLayerColor( LAYER_PADS_PLATEDHOLES, COLOR4D::BLACK ); + painter.GetSettings()->SetLayerColor( LAYER_NON_PLATEDHOLES, COLOR4D::BLACK ); + painter.GetSettings()->SetLayerColor( LAYER_VIAS_HOLES, COLOR4D::BLACK ); + break; + + case PCBNEW_PRINTOUT_SETTINGS::FULL_DRILL_SHAPE: + painter.SetDrillMarks( true ); + + painter.GetSettings()->SetLayerColor( LAYER_PADS_PLATEDHOLES, COLOR4D::BLACK ); + painter.GetSettings()->SetLayerColor( LAYER_NON_PLATEDHOLES, COLOR4D::BLACK ); + painter.GetSettings()->SetLayerColor( LAYER_VIAS_HOLES, COLOR4D::BLACK ); + break; } painter.GetSettings()->SetDrawIndividualViaLayers( m_pcbnewSettings.m_pagination == PCBNEW_PRINTOUT_SETTINGS::LAYER_PER_PAGE ); - - painter.GetSettings()->SetLayerColor( LAYER_PADS_PLATEDHOLES, COLOR4D::WHITE ); - painter.GetSettings()->SetLayerColor( LAYER_NON_PLATEDHOLES, COLOR4D::WHITE ); - painter.GetSettings()->SetLayerColor( LAYER_VIAS_HOLES, COLOR4D::WHITE ); }