From ecb5c5e0d4a528027be605c3c6f647a942ab6830 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 13 Apr 2025 13:12:11 +0100 Subject: [PATCH] Visibility control is for *filled* shapes. Fixes https://gitlab.com/kicad/code/kicad/-/issues/20635 --- common/lset.cpp | 2 +- common/project/project_local_settings.cpp | 4 +- common/settings/layer_settings_utils.cpp | 6 +-- include/layer_ids.h | 2 +- include/settings/layer_settings_utils.h | 2 +- pcbnew/pcbnew_printout.cpp | 4 +- pcbnew/tools/drawing_tool.cpp | 10 +--- pcbnew/tools/pcb_selection_tool.cpp | 5 +- pcbnew/widgets/appearance_controls.cpp | 63 ++++++++++++----------- 9 files changed, 46 insertions(+), 52 deletions(-) diff --git a/common/lset.cpp b/common/lset.cpp index fc496deec5..b498eb9367 100644 --- a/common/lset.cpp +++ b/common/lset.cpp @@ -813,7 +813,7 @@ GAL_SET GAL_SET::DefaultVisible() LAYER_DRAW_BITMAPS, LAYER_PADS, LAYER_ZONES, - LAYER_SHAPES, + LAYER_FILLED_SHAPES, LAYER_LOCKED_ITEM_SHADOW, LAYER_CONFLICTS_SHADOW }; diff --git a/common/project/project_local_settings.cpp b/common/project/project_local_settings.cpp index d517732e5e..985a1753bb 100644 --- a/common/project/project_local_settings.cpp +++ b/common/project/project_local_settings.cpp @@ -439,14 +439,14 @@ PROJECT_LOCAL_SETTINGS::PROJECT_LOCAL_SETTINGS( PROJECT* aProject, const wxStrin registerMigration( 3, 4, [&]() { - // Schema version 3 to 4: LAYER_SHAPES added to visibility controls + // Schema version 3 to 4: LAYER_FILLED_SHAPES added to visibility controls std::string ptr( "board.visible_items" ); if( Contains( ptr ) ) { if( At( ptr ).is_array() ) - At( ptr ).push_back( LAYER_SHAPES - GAL_LAYER_ID_START ); + At( ptr ).push_back( LAYER_FILLED_SHAPES - GAL_LAYER_ID_START ); else At( "board" ).erase( "visible_items" ); diff --git a/common/settings/layer_settings_utils.cpp b/common/settings/layer_settings_utils.cpp index 3902d9818f..ba53c33e66 100644 --- a/common/settings/layer_settings_utils.cpp +++ b/common/settings/layer_settings_utils.cpp @@ -31,7 +31,7 @@ GAL_SET UserVisbilityLayers() LAYER_VIAS, LAYER_PADS, LAYER_ZONES, - LAYER_SHAPES, + LAYER_FILLED_SHAPES, LAYER_DRAW_BITMAPS, LAYER_FOOTPRINTS_FR, LAYER_FOOTPRINTS_BK, @@ -62,7 +62,7 @@ GAL_LAYER_ID RenderLayerFromVisibilityLayer( VISIBILITY_LAYER aLayer ) case VISIBILITY_LAYER::VIAS: return LAYER_VIAS; case VISIBILITY_LAYER::PADS: return LAYER_PADS; case VISIBILITY_LAYER::ZONES: return LAYER_ZONES; - case VISIBILITY_LAYER::SHAPES: return LAYER_SHAPES; + case VISIBILITY_LAYER::FILLED_SHAPES: return LAYER_FILLED_SHAPES; case VISIBILITY_LAYER::BITMAPS: return LAYER_DRAW_BITMAPS; case VISIBILITY_LAYER::FOOTPRINTS_FRONT: return LAYER_FOOTPRINTS_FR; case VISIBILITY_LAYER::FOOTPRINTS_BACK: return LAYER_FOOTPRINTS_BK; @@ -92,7 +92,7 @@ std::optional VisibilityLayerFromRenderLayer( GAL_LAYER_ID aLa case LAYER_VIAS: return VISIBILITY_LAYER::VIAS; case LAYER_PADS: return VISIBILITY_LAYER::PADS; case LAYER_ZONES: return VISIBILITY_LAYER::ZONES; - case LAYER_SHAPES: return VISIBILITY_LAYER::SHAPES; + case LAYER_FILLED_SHAPES: return VISIBILITY_LAYER::FILLED_SHAPES; case LAYER_DRAW_BITMAPS: return VISIBILITY_LAYER::BITMAPS; case LAYER_FOOTPRINTS_FR: return VISIBILITY_LAYER::FOOTPRINTS_FRONT; case LAYER_FOOTPRINTS_BK: return VISIBILITY_LAYER::FOOTPRINTS_BACK; diff --git a/include/layer_ids.h b/include/layer_ids.h index 61e900108b..d906b5951a 100644 --- a/include/layer_ids.h +++ b/include/layer_ids.h @@ -309,7 +309,7 @@ enum GAL_LAYER_ID: int LAYER_CONFLICTS_SHADOW = GAL_LAYER_ID_START + 40, /// Copper graphic shape opacity/visibility (color ignored). - LAYER_SHAPES = GAL_LAYER_ID_START + 41, + LAYER_FILLED_SHAPES = GAL_LAYER_ID_START + 41, LAYER_DRC_SHAPE1 = GAL_LAYER_ID_START + 42, ///< Custom shape for DRC marker. LAYER_DRC_SHAPE2 = GAL_LAYER_ID_START + 43, ///< Custom shape for DRC marker. diff --git a/include/settings/layer_settings_utils.h b/include/settings/layer_settings_utils.h index f14e5d1c50..04cd392969 100644 --- a/include/settings/layer_settings_utils.h +++ b/include/settings/layer_settings_utils.h @@ -35,7 +35,7 @@ enum class VISIBILITY_LAYER VIAS, PADS, ZONES, - SHAPES, + FILLED_SHAPES, BITMAPS, FOOTPRINTS_FRONT, FOOTPRINTS_BACK, diff --git a/pcbnew/pcbnew_printout.cpp b/pcbnew/pcbnew_printout.cpp index 0ddd137baa..938519a589 100644 --- a/pcbnew/pcbnew_printout.cpp +++ b/pcbnew/pcbnew_printout.cpp @@ -187,7 +187,7 @@ void PCBNEW_PRINTOUT::setupViewLayers( KIGFX::VIEW& aView, const LSET& aLayerSet setVisibility( LAYER_VIA_BBLIND ); setVisibility( LAYER_VIA_THROUGH ); setVisibility( LAYER_ZONES ); - setVisibility( LAYER_SHAPES ); + setVisibility( LAYER_FILLED_SHAPES ); setVisibility( LAYER_DRC_WARNING ); setVisibility( LAYER_DRC_ERROR ); @@ -217,7 +217,7 @@ void PCBNEW_PRINTOUT::setupViewLayers( KIGFX::VIEW& aView, const LSET& aLayerSet LAYER_FP_TEXT, LAYER_FP_VALUES, LAYER_FP_REFERENCES, LAYER_FOOTPRINTS_FR, LAYER_FOOTPRINTS_BK, LAYER_TRACKS, LAYER_VIAS, - LAYER_ZONES, LAYER_SHAPES, + LAYER_ZONES, LAYER_FILLED_SHAPES, LAYER_PADS }; diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index cc670daa61..aaea45953f 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -1916,7 +1916,7 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent ) } // Turn shapes on if they are off, so that the created object will be visible after completion - m_frame->SetObjectVisible( LAYER_SHAPES ); + m_frame->SetObjectVisible( LAYER_FILLED_SHAPES ); if( !m_view->IsLayerVisible( layer ) ) { @@ -2178,7 +2178,7 @@ bool DRAWING_TOOL::drawShape( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic, } // Turn shapes on if they are off, so that the created object will be visible after completion - m_frame->SetObjectVisible( LAYER_SHAPES ); + m_frame->SetObjectVisible( LAYER_FILLED_SHAPES ); // geometric construction manager KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER twoPointMgr; @@ -2578,9 +2578,6 @@ bool DRAWING_TOOL::drawArc( const TOOL_EVENT& aTool, PCB_SHAPE** aGraphic, m_stroke.SetColor( COLOR4D::UNSPECIFIED ); } - // Turn shapes on if they are off, so that the created object will be visible after completion - m_frame->SetObjectVisible( LAYER_SHAPES ); - // Arc geometric construction manager KIGFX::PREVIEW::ARC_GEOM_MANAGER arcManager; @@ -2884,9 +2881,6 @@ std::unique_ptr DRAWING_TOOL::drawOneBezier( const TOOL_EVENT& aToo m_stroke.SetColor( COLOR4D::UNSPECIFIED ); } - // Turn shapes on if they are off, so that the created object will be visible after completion - m_frame->SetObjectVisible( LAYER_SHAPES ); - // Arc geometric construction manager KIGFX::PREVIEW::BEZIER_GEOM_MANAGER bezierManager; diff --git a/pcbnew/tools/pcb_selection_tool.cpp b/pcbnew/tools/pcb_selection_tool.cpp index dfbdf7f1a2..c8f00178ef 100644 --- a/pcbnew/tools/pcb_selection_tool.cpp +++ b/pcbnew/tools/pcb_selection_tool.cpp @@ -3036,10 +3036,7 @@ bool PCB_SELECTION_TOOL::Selectable( const BOARD_ITEM* aItem, bool checkVisibili KI_FALLTHROUGH; case PCB_SHAPE_T: - // Note: LAYER_SHAPES does not control the visibility of a PCB_SHAPE_T, only - // the opacity of filled areas - // The visibility is managed by the item layer - if( options.m_FilledShapeOpacity == 0.0 ) + if( options.m_FilledShapeOpacity == 0.0 && static_cast( aItem )->IsAnyFill() ) return false; KI_FALLTHROUGH; diff --git a/pcbnew/widgets/appearance_controls.cpp b/pcbnew/widgets/appearance_controls.cpp index 266753e3b4..2356561b14 100644 --- a/pcbnew/widgets/appearance_controls.cpp +++ b/pcbnew/widgets/appearance_controls.cpp @@ -327,30 +327,33 @@ const APPEARANCE_CONTROLS::APPEARANCE_SETTING APPEARANCE_CONTROLS::s_objectSetti #define RR APPEARANCE_CONTROLS::APPEARANCE_SETTING // Render Row abbreviation to reduce source width - // text id tooltip opacity slider visibility checkbox - RR( _HKI( "Tracks" ), LAYER_TRACKS, _HKI( "Show tracks" ), true ), - RR( _HKI( "Vias" ), LAYER_VIAS, _HKI( "Show all vias" ), true ), - RR( _HKI( "Pads" ), LAYER_PADS, _HKI( "Show all pads" ), true ), - RR( _HKI( "Zones" ), LAYER_ZONES, _HKI( "Show copper zones" ), true ), - RR( _HKI( "Filled Shapes" ), LAYER_SHAPES, _HKI( "Opacity of filled shapes" ), true, false ), - RR( _HKI( "Images" ), LAYER_DRAW_BITMAPS, _HKI( "Show user images" ), true ), + // clang-format off + + // text id tooltip opacity slider visibility checkbox + RR( _HKI( "Tracks" ), LAYER_TRACKS, _HKI( "Show tracks" ), true ), + RR( _HKI( "Vias" ), LAYER_VIAS, _HKI( "Show all vias" ), true ), + RR( _HKI( "Pads" ), LAYER_PADS, _HKI( "Show all pads" ), true ), + RR( _HKI( "Zones" ), LAYER_ZONES, _HKI( "Show copper zones" ), true ), + RR( _HKI( "Filled Shapes" ), LAYER_FILLED_SHAPES, _HKI( "Opacity of filled shapes" ), true, false ), + RR( _HKI( "Images" ), LAYER_DRAW_BITMAPS, _HKI( "Show user images" ), true ), RR(), - RR( _HKI( "Footprints Front" ), LAYER_FOOTPRINTS_FR, _HKI( "Show footprints that are on board's front" ) ), - RR( _HKI( "Footprints Back" ), LAYER_FOOTPRINTS_BK, _HKI( "Show footprints that are on board's back" ) ), - RR( _HKI( "Values" ), LAYER_FP_VALUES, _HKI( "Show footprint values" ) ), - RR( _HKI( "References" ), LAYER_FP_REFERENCES, _HKI( "Show footprint references" ) ), - RR( _HKI( "Footprint Text" ), LAYER_FP_TEXT, _HKI( "Show all footprint text" ) ), + RR( _HKI( "Footprints Front" ), LAYER_FOOTPRINTS_FR, _HKI( "Show footprints that are on board's front" ) ), + RR( _HKI( "Footprints Back" ), LAYER_FOOTPRINTS_BK, _HKI( "Show footprints that are on board's back" ) ), + RR( _HKI( "Values" ), LAYER_FP_VALUES, _HKI( "Show footprint values" ) ), + RR( _HKI( "References" ), LAYER_FP_REFERENCES, _HKI( "Show footprint references" ) ), + RR( _HKI( "Footprint Text" ), LAYER_FP_TEXT, _HKI( "Show all footprint text" ) ), RR(), RR(), - RR( _HKI( "Ratsnest" ), LAYER_RATSNEST, _HKI( "Show unconnected nets as a ratsnest") ), - RR( _HKI( "DRC Warnings" ), LAYER_DRC_WARNING, _HKI( "DRC violations with a Warning severity" ) ), - RR( _HKI( "DRC Errors" ), LAYER_DRC_ERROR, _HKI( "DRC violations with an Error severity" ) ), - RR( _HKI( "DRC Exclusions" ), LAYER_DRC_EXCLUSION, _HKI( "DRC violations which have been individually excluded" ) ), - RR( _HKI( "Anchors" ), LAYER_ANCHOR, _HKI( "Show footprint and text origins as a cross" ) ), - RR( _HKI( "Locked Item Shadow" ), LAYER_LOCKED_ITEM_SHADOW, _HKI( "Show a shadow marker on locked items" ) ), - RR( _HKI( "Conflict Footprint Shadow" ), LAYER_CONFLICTS_SHADOW, _HKI( "Show a shadow marker on conflicting footprints" ) ), - RR( _HKI( "Drawing Sheet" ), LAYER_DRAWINGSHEET, _HKI( "Show drawing sheet borders and title block" ) ), - RR( _HKI( "Grid" ), LAYER_GRID, _HKI( "Show the (x,y) grid dots" ) ) + RR( _HKI( "Ratsnest" ), LAYER_RATSNEST, _HKI( "Show unconnected nets as a ratsnest") ), + RR( _HKI( "DRC Warnings" ), LAYER_DRC_WARNING, _HKI( "DRC violations with a Warning severity" ) ), + RR( _HKI( "DRC Errors" ), LAYER_DRC_ERROR, _HKI( "DRC violations with an Error severity" ) ), + RR( _HKI( "DRC Exclusions" ), LAYER_DRC_EXCLUSION, _HKI( "DRC violations which have been individually excluded" ) ), + RR( _HKI( "Anchors" ), LAYER_ANCHOR, _HKI( "Show footprint and text origins as a cross" ) ), + RR( _HKI( "Locked Item Shadow" ), LAYER_LOCKED_ITEM_SHADOW, _HKI( "Show a shadow on locked items" ) ), + RR( _HKI( "Colliding Courtyards" ), LAYER_CONFLICTS_SHADOW, _HKI( "Show colliding footprint courtyards" ) ), + RR( _HKI( "Drawing Sheet" ), LAYER_DRAWINGSHEET, _HKI( "Show drawing sheet borders and title block" ) ), + RR( _HKI( "Grid" ), LAYER_GRID, _HKI( "Show the (x,y) grid dots" ) ) + // clang-format on }; /// These GAL layers are shown in the Objects tab in the footprint editor @@ -360,7 +363,7 @@ static std::set s_allowedInFpEditor = LAYER_VIAS, LAYER_PADS, LAYER_ZONES, - LAYER_SHAPES, + LAYER_FILLED_SHAPES, LAYER_FP_VALUES, LAYER_FP_REFERENCES, LAYER_FP_TEXT, @@ -2400,14 +2403,14 @@ void APPEARANCE_CONTROLS::syncObjectSettings() && m_objectSettingsMap.count( LAYER_PADS ) && m_objectSettingsMap.count( LAYER_ZONES ) && m_objectSettingsMap.count( LAYER_DRAW_BITMAPS ) - && m_objectSettingsMap.count( LAYER_SHAPES ) ); + && m_objectSettingsMap.count( LAYER_FILLED_SHAPES ) ); m_objectSettingsMap[LAYER_TRACKS]->ctl_opacity->SetValue( opts.m_TrackOpacity * 100 ); m_objectSettingsMap[LAYER_VIAS]->ctl_opacity->SetValue( opts.m_ViaOpacity * 100 ); m_objectSettingsMap[LAYER_PADS]->ctl_opacity->SetValue( opts.m_PadOpacity * 100 ); m_objectSettingsMap[LAYER_ZONES]->ctl_opacity->SetValue( opts.m_ZoneOpacity * 100 ); m_objectSettingsMap[LAYER_DRAW_BITMAPS]->ctl_opacity->SetValue( opts.m_ImageOpacity * 100 ); - m_objectSettingsMap[LAYER_SHAPES]->ctl_opacity->SetValue( opts.m_FilledShapeOpacity * 100 ); + m_objectSettingsMap[LAYER_FILLED_SHAPES]->ctl_opacity->SetValue( opts.m_FilledShapeOpacity * 100 ); } @@ -3113,12 +3116,12 @@ void APPEARANCE_CONTROLS::onObjectOpacitySlider( int aLayer, float aOpacity ) switch( aLayer ) { - case static_cast( LAYER_TRACKS ): options.m_TrackOpacity = aOpacity; break; - case static_cast( LAYER_VIAS ): options.m_ViaOpacity = aOpacity; break; - case static_cast( LAYER_PADS ): options.m_PadOpacity = aOpacity; break; - case static_cast( LAYER_ZONES ): options.m_ZoneOpacity = aOpacity; break; - case static_cast( LAYER_DRAW_BITMAPS ): options.m_ImageOpacity = aOpacity; break; - case static_cast( LAYER_SHAPES ): options.m_FilledShapeOpacity = aOpacity; break; + case static_cast( LAYER_TRACKS ): options.m_TrackOpacity = aOpacity; break; + case static_cast( LAYER_VIAS ): options.m_ViaOpacity = aOpacity; break; + case static_cast( LAYER_PADS ): options.m_PadOpacity = aOpacity; break; + case static_cast( LAYER_ZONES ): options.m_ZoneOpacity = aOpacity; break; + case static_cast( LAYER_DRAW_BITMAPS ): options.m_ImageOpacity = aOpacity; break; + case static_cast( LAYER_FILLED_SHAPES ): options.m_FilledShapeOpacity = aOpacity; break; default: return; }