diff --git a/pcbnew/pad.cpp b/pcbnew/pad.cpp index f49dba5978..4cdbf95aca 100644 --- a/pcbnew/pad.cpp +++ b/pcbnew/pad.cpp @@ -1081,13 +1081,6 @@ EDA_ITEM* PAD::Clone() const } -bool PAD::PadShouldBeNPTH() const -{ - return( m_attribute == PAD_ATTRIB_PTH - && m_drill.x >= m_size.x && m_drill.y >= m_size.y ); -} - - void PAD::ViewGetLayers( int aLayers[], int& aCount ) const { aCount = 0; diff --git a/pcbnew/pad.h b/pcbnew/pad.h index 20f93b4d56..bd8eb64d85 100644 --- a/pcbnew/pad.h +++ b/pcbnew/pad.h @@ -613,13 +613,6 @@ public: return (PAD*) Clone(); } - /** - * A pad whose hole is the same size as the pad is a NPTH. However, if the user - * fails to mark this correctly then the pad will become invisible on the board. - * This check allows us to special-case this error-condition. - */ - bool PadShouldBeNPTH() const; - /** * Rebuilds the effective shape cache (and bounding box and radius) for the pad and clears * the dirty bit. diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 7a4b5cdecb..6de373f0cd 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -229,41 +229,47 @@ COLOR4D PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) cons const EDA_ITEM* item = dynamic_cast( aItem ); const BOARD_CONNECTED_ITEM* conItem = dynamic_cast ( aItem ); + // Marker shadows + if( aLayer == LAYER_MARKER_SHADOWS ) + return m_backgroundColor.WithAlpha( 0.6 ); + + if( !item ) + return m_layerColors[aLayer]; + + // Pad hole color is pad-type-specific: the background color for PTHs (which are assumed + // to have an annular ring) and the pad color for NPTHs (which are assumed *not* to have + // an annular ring). + // However, this means a PTH pad with *no* annular ring won't get drawn, so we need to + // special-case that. + // We have the opposite issue when printing in B&W: both a PTH hole and its annular ring + // will normally get assigned black, so we need to special-case that too. + if( aLayer == LAYER_PADS_PLATEDHOLES || aLayer == LAYER_NON_PLATEDHOLES ) + { + const PAD* pad = static_cast( item ); + bool hasAnnularRing = pad->GetSizeX() > pad->GetDrillSizeX() + && pad->GetSizeY() > pad->GetDrillSizeY(); + + if( !hasAnnularRing && m_layerColors[aLayer] == m_layerColors[LAYER_PCB_BACKGROUND] ) + aLayer = LAYER_MOD_TEXT_INVISIBLE; + + if( hasAnnularRing && m_layerColors[aLayer] == m_layerColors[LAYER_PADS_TH] ) + aLayer = LAYER_PCB_BACKGROUND; + } + // Zones should pull from the copper layer if( item && item->Type() == PCB_ZONE_T && IsZoneLayer( aLayer ) ) aLayer = aLayer - LAYER_ZONE_START; - // Marker shadows - if( aLayer == LAYER_MARKER_SHADOWS ) - { - COLOR4D shadowColor = m_backgroundColor.WithAlpha( 0.6 ); - - if( item && item->IsSelected() ) - shadowColor.Brighten( m_selectFactor ); - - return shadowColor; - } - // Normal path: get the layer base color COLOR4D color = m_layerColors[aLayer]; - if( item ) - { - // Selection disambiguation - if( item->IsBrightened() ) - return color.Brightened( m_selectFactor ).WithAlpha( 0.8 ); + // Selection disambiguation + if( item->IsBrightened() ) + return color.Brightened( m_selectFactor ).WithAlpha( 0.8 ); - // Don't let pads that *should* be NPTHs get lost - if( item->Type() == PCB_PAD_T && dyn_cast( item )->PadShouldBeNPTH() ) - aLayer = LAYER_MOD_TEXT_INVISIBLE; - - if( item->IsSelected() ) - color = m_layerColorsSel[aLayer]; - } - else - { - return m_layerColors[aLayer]; - } + // Normal selection + if( item->IsSelected() ) + color = m_layerColorsSel[aLayer]; // Try to obtain the netcode for the item if( conItem ) @@ -875,15 +881,7 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer ) // Pad drawing BOARD_DESIGN_SETTINGS& bds = aPad->GetBoard()->GetDesignSettings(); - COLOR4D color; - - // Pad hole color is pad-type-specific: the background color for plated holes and the - // 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 ); + COLOR4D color = m_pcbSettings.GetColor( aPad, aLayer ); if( m_pcbSettings.m_sketchMode[LAYER_PADS_TH] ) { @@ -911,6 +909,12 @@ void PCB_PAINTER::draw( const PAD* aPad, int aLayer ) else m_gal->DrawSegment( seg->GetSeg().A, seg->GetSeg().B, seg->GetWidth() ); } + else if( aLayer == LAYER_PADS_TH + && aPad->GetSizeX() <= aPad->GetDrillSizeX() + && aPad->GetSizeY() <= aPad->GetDrillSizeY() ) + { + // no annular ring to draw + } else { wxSize pad_size = aPad->GetSize();