From e5da7a46061dc77834e3e2ec7251e17eb9ccc087 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 20 Apr 2020 17:00:00 +0100 Subject: [PATCH] Fix via printing. LAYER_VIAS needs to get set for them to print at all, and GetLOD needs too look at the view layer visibiilties, not the board layer visibilities. Also implements a more pad-like strategy for printing blind/buried vias when printing one layer per page (where the top/bottom arcs don't make sense). Fixes https://gitlab.com/kicad/code/kicad/issues/1938 (cherry picked from commit dce42612d399458b1bf6e6c274065dc5530eef39) --- pcbnew/class_track.cpp | 10 +++++++--- pcbnew/pcb_painter.cpp | 2 +- pcbnew/pcb_painter.h | 5 +++++ pcbnew/pcbnew_printout.cpp | 28 +++++++++++++++------------- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/pcbnew/class_track.cpp b/pcbnew/class_track.cpp index 41b47ed416..cc2a2f13a0 100644 --- a/pcbnew/class_track.cpp +++ b/pcbnew/class_track.cpp @@ -1034,12 +1034,16 @@ unsigned int VIA::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const if( IsNetnameLayer( aLayer ) ) return m_Width == 0 ? HIDE : ( Millimeter2iu( 10 ) / m_Width ); + LSET visibleLayers; - BOARD* board = GetBoard(); + for( int i = 0; i < PCB_LAYER_ID_COUNT; ++i ) + { + if( aView->IsLayerVisible( i ) ) + visibleLayers.set( i ); + } // Only draw the via if at least one of the layers it crosses is being displayed - if( board && ( board->GetVisibleLayers() & GetLayerSet() ).any() - && aView->IsLayerVisible( LAYER_VIAS ) ) + if( ( visibleLayers & GetLayerSet() ).any() && aView->IsLayerVisible( LAYER_VIAS ) ) { switch( m_ViaType ) { diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index b408173baf..5ca65f6bbe 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -539,7 +539,7 @@ void PCB_PAINTER::draw( const VIA* aVia, int aLayer ) break; } - if( aVia->GetViaType() == VIA_BLIND_BURIED ) + if( aVia->GetViaType() == VIA_BLIND_BURIED && !m_pcbSettings.GetDrawIndividualViaLayers() ) { // Buried vias are drawn in a special way to indicate the top and bottom layers PCB_LAYER_ID layerTop, layerBottom; diff --git a/pcbnew/pcb_painter.h b/pcbnew/pcb_painter.h index 879ae6c962..a326223c46 100644 --- a/pcbnew/pcb_painter.h +++ b/pcbnew/pcb_painter.h @@ -162,6 +162,9 @@ public: const COLOR4D& GetCursorColor() override { return m_layerColors[ LAYER_CURSOR ]; } + bool GetDrawIndividualViaLayers() const { return m_drawIndividualViaLayers; } + void SetDrawIndividualViaLayers( bool aFlag ) { m_drawIndividualViaLayers = aFlag; } + protected: ///> Flag determining if items on a given layer should be drawn as an outline or a filled item bool m_sketchMode[GAL_LAYER_ID_END]; @@ -190,6 +193,8 @@ protected: ///> Flag determining if zones should have outlines drawn bool m_zoneOutlines; + bool m_drawIndividualViaLayers = false; + ///> Maximum font size for netnames (and other dynamically shown strings) static const double MAX_FONT_SIZE; diff --git a/pcbnew/pcbnew_printout.cpp b/pcbnew/pcbnew_printout.cpp index a21121e1f0..c9c29a4988 100644 --- a/pcbnew/pcbnew_printout.cpp +++ b/pcbnew/pcbnew_printout.cpp @@ -67,18 +67,18 @@ PCBNEW_PRINTOUT::PCBNEW_PRINTOUT( BOARD* aBoard, const PCBNEW_PRINTOUT_SETTINGS& bool PCBNEW_PRINTOUT::OnPrintPage( int aPage ) { - // Store the layerset, as it is going to be modified below and the original settings are needed + // Store the layerset, as it is going to be modified below and the original settings are + // needed. LSET lset = m_settings.m_layerSet; int pageCount = lset.count(); wxString layer; PCB_LAYER_ID extractLayer; // compute layer mask from page number if we want one page per layer - if( m_pcbnewSettings.m_pagination == 0 ) // One page per layer + if( m_pcbnewSettings.m_pagination == PCBNEW_PRINTOUT_SETTINGS::LAYER_PER_PAGE ) { - // This sequence is TBD, call a different - // sequencer if needed, such as Seq(). Could not find documentation on - // page order. + // This sequence is TBD, call a different sequencer if needed, such as Seq(). + // Could not find documentation on page order. LSEQ seq = lset.UIOrder(); // aPage starts at 1, not 0 @@ -116,7 +116,7 @@ int PCBNEW_PRINTOUT::milsToIU( double aMils ) const void PCBNEW_PRINTOUT::setupViewLayers( const std::unique_ptr& aView, - const LSET& aLayerSet ) + const LSET& aLayerSet ) { BOARD_PRINTOUT::setupViewLayers( aView, aLayerSet ); @@ -133,8 +133,7 @@ void PCBNEW_PRINTOUT::setupViewLayers( const std::unique_ptr& aView if( ( aLayerSet & LSET::AllCuMask() ).any() ) // Items visible on any copper layer { // Enable items on copper layers, but do not draw holes - for( auto item : { LAYER_PADS_TH, LAYER_VIA_MICROVIA, - LAYER_VIA_BBLIND, LAYER_VIA_THROUGH } ) + for( GAL_LAYER_ID item : { LAYER_PADS_TH, LAYER_VIAS } ) { aView->SetLayerVisible( item, true ); } @@ -142,21 +141,21 @@ void PCBNEW_PRINTOUT::setupViewLayers( const std::unique_ptr& aView if( m_pcbnewSettings.m_drillMarks != PCBNEW_PRINTOUT_SETTINGS::NO_DRILL_SHAPE ) { // Enable hole layers to draw drill marks - for( auto holeLayer : { LAYER_PADS_PLATEDHOLES, - LAYER_NON_PLATEDHOLES, LAYER_VIAS_HOLES }) + 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_MOD_VALUES, LAYER_MOD_REFERENCES, LAYER_TRACKS, + LAYER_VIA_MICROVIA, LAYER_VIA_BBLIND, LAYER_VIA_THROUGH }; for( int item : alwaysEnabled ) @@ -168,7 +167,7 @@ void PCBNEW_PRINTOUT::setupPainter( const std::unique_ptr& aPain { BOARD_PRINTOUT::setupPainter( aPainter ); - auto painter = static_cast( aPainter.get() ); + KIGFX::PCB_PRINT_PAINTER* painter = static_cast( aPainter.get() ); switch( m_pcbnewSettings.m_drillMarks ) { @@ -185,6 +184,9 @@ void PCBNEW_PRINTOUT::setupPainter( const std::unique_ptr& aPain 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 );