From 2f47857abc3b74886ecbff5ccbaa229f276dc9b4 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 5 Nov 2022 12:00:56 +0000 Subject: [PATCH] Move zone borders back to their "host" layer. Zone borders shouldn't be affected by zone-opacity control; we always draw them in full layer opacity. Fixes https://gitlab.com/kicad/code/kicad/issues/12438 (cherry picked from commit 25f06eed8cac786a245d8b816c06911b264a170d) --- common/view/view_group.cpp | 2 +- include/layer_ids.h | 2 +- pcbnew/pcb_painter.cpp | 64 +++++++++++++++++++++----------------- pcbnew/zone.cpp | 10 +++--- 4 files changed, 44 insertions(+), 34 deletions(-) diff --git a/common/view/view_group.cpp b/common/view/view_group.cpp index 7bf64f99fa..c4662e61fa 100644 --- a/common/view/view_group.cpp +++ b/common/view/view_group.cpp @@ -148,7 +148,7 @@ void VIEW_GROUP::ViewDraw( int aLayer, VIEW* aView ) const { int layer = layers[i]; - if( IsZoneLayer( layer ) ) + if( IsZoneFillLayer( layer ) ) layer = layer - LAYER_ZONE_START; bool draw = aView->IsLayerVisible( layer ); diff --git a/include/layer_ids.h b/include/layer_ids.h index 5ed327bb46..fa998c0306 100644 --- a/include/layer_ids.h +++ b/include/layer_ids.h @@ -980,7 +980,7 @@ inline bool IsNetnameLayer( LAYER_NUM aLayer ) } -inline bool IsZoneLayer( LAYER_NUM aLayer ) +inline bool IsZoneFillLayer( int aLayer ) { return aLayer >= LAYER_ZONE_START && aLayer <= LAYER_ZONE_END; } diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 71317c95d6..4ab3564560 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -262,7 +262,7 @@ COLOR4D PCB_RENDER_SETTINGS::GetColor( const VIEW_ITEM* aItem, int aLayer ) cons // Zones should pull from the copper layer if( item && ( item->Type() == PCB_ZONE_T || item->Type() == PCB_FP_ZONE_T ) ) { - if( IsZoneLayer( aLayer ) ) + if( IsZoneFillLayer( aLayer ) ) aLayer = aLayer - LAYER_ZONE_START; } @@ -1742,8 +1742,12 @@ void PCB_PAINTER::draw( const ZONE* aZone, int aLayer ) * The color for the zone comes from the associated copper layer ( aLayer - LAYER_ZONE_START ) * and the visibility comes from the combination of that copper layer and LAYER_ZONES */ - wxASSERT( IsZoneLayer( aLayer ) ); - PCB_LAYER_ID layer = static_cast( aLayer - LAYER_ZONE_START ); + PCB_LAYER_ID layer; + + if( IsZoneFillLayer( aLayer ) ) + layer = ToLAYER_ID( aLayer - LAYER_ZONE_START ); + else + layer = ToLAYER_ID( aLayer ); if( !aZone->IsOnLayer( layer ) ) return; @@ -1753,41 +1757,45 @@ void PCB_PAINTER::draw( const ZONE* aZone, int aLayer ) ZONE_DISPLAY_MODE displayMode = m_pcbSettings.m_zoneDisplayMode; // Draw the outline - const SHAPE_POLY_SET* outline = aZone->Outline(); - - if( m_pcbSettings.m_zoneOutlines && outline && outline->OutlineCount() > 0 ) + if( !IsZoneFillLayer( aLayer ) ) { - m_gal->SetStrokeColor( color.a > 0.0 ? color.WithAlpha( 1.0 ) : color ); - m_gal->SetIsFill( false ); - m_gal->SetIsStroke( true ); - m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth ); + const SHAPE_POLY_SET* outline = aZone->Outline(); - // Draw each contour (main contour and holes) + if( !m_pcbSettings.m_isPrinting && outline && outline->OutlineCount() > 0 ) + { + m_gal->SetStrokeColor( color.a > 0.0 ? color.WithAlpha( 1.0 ) : color ); + m_gal->SetIsFill( false ); + m_gal->SetIsStroke( true ); + m_gal->SetLineWidth( m_pcbSettings.m_outlineWidth ); - /* - * m_gal->DrawPolygon( *outline ); - * should be enough, but currently does not work to draw holes contours in a complex - * polygon so each contour is draw as a simple polygon - */ + // Draw each contour (main contour and holes) - // Draw the main contour - m_gal->DrawPolyline( outline->COutline( 0 ) ); + /* + * m_gal->DrawPolygon( *outline ); + * should be enough, but currently does not work to draw holes contours in a complex + * polygon so each contour is draw as a simple polygon + */ - // Draw holes - int holes_count = outline->HoleCount( 0 ); + // Draw the main contour + m_gal->DrawPolyline( outline->COutline( 0 ) ); - for( int ii = 0; ii < holes_count; ++ii ) - m_gal->DrawPolyline( outline->CHole( 0, ii ) ); + // Draw holes + int holes_count = outline->HoleCount( 0 ); - // Draw hatch lines - for( const SEG& hatchLine : aZone->GetHatchLines() ) - m_gal->DrawLine( hatchLine.A, hatchLine.B ); + for( int ii = 0; ii < holes_count; ++ii ) + m_gal->DrawPolyline( outline->CHole( 0, ii ) ); + + // Draw hatch lines + for( const SEG& hatchLine : aZone->GetHatchLines() ) + m_gal->DrawLine( hatchLine.A, hatchLine.B ); + } } // Draw the filling - if( displayMode == ZONE_DISPLAY_MODE::SHOW_FILLED - || displayMode == ZONE_DISPLAY_MODE::SHOW_FRACTURE_BORDERS - || displayMode == ZONE_DISPLAY_MODE::SHOW_TRIANGULATION ) + if( IsZoneFillLayer( aLayer ) + && ( displayMode == ZONE_DISPLAY_MODE::SHOW_FILLED + || displayMode == ZONE_DISPLAY_MODE::SHOW_FRACTURE_BORDERS + || displayMode == ZONE_DISPLAY_MODE::SHOW_TRIANGULATION ) ) { const SHAPE_POLY_SET& polySet = aZone->GetFilledPolysList( layer ); diff --git a/pcbnew/zone.cpp b/pcbnew/zone.cpp index 42931f2fd5..39b644fd02 100644 --- a/pcbnew/zone.cpp +++ b/pcbnew/zone.cpp @@ -309,12 +309,14 @@ LSET ZONE::GetLayerSet() const void ZONE::ViewGetLayers( int aLayers[], int& aCount ) const { + aCount = 0; LSEQ layers = m_layerSet.Seq(); - for( unsigned int idx = 0; idx < layers.size(); idx++ ) - aLayers[idx] = LAYER_ZONE_START + layers[idx]; - - aCount = layers.size(); + for( PCB_LAYER_ID layer : m_layerSet.Seq() ) + { + aLayers[ aCount++ ] = layer; // For outline (always full opacity) + aLayers[ aCount++ ] = layer + LAYER_ZONE_START; // For fill (obeys global zone opacity) + } }