From 64f8258f1f04fa09c0ae897ccbe93408de2e8cf0 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Fri, 25 Jul 2025 16:38:21 -0700 Subject: [PATCH] Don't prompt for rule areas and no-net shapes Highlighting and placing vias will pop up a potential net list. This should not include things without nets Fixes https://gitlab.com/kicad/code/kicad/-/issues/21381 (cherry picked from commit dd41e2b00b6c45188f52019154b186f686eaeda1) --- pcbnew/collectors.cpp | 31 +++++++++++++++++++++++++- pcbnew/collectors.h | 10 +++++++++ pcbnew/tools/board_inspection_tool.cpp | 1 + pcbnew/tools/drawing_tool.cpp | 3 +++ 4 files changed, 44 insertions(+), 1 deletion(-) diff --git a/pcbnew/collectors.cpp b/pcbnew/collectors.cpp index 07ec161955..84d88e3573 100644 --- a/pcbnew/collectors.cpp +++ b/pcbnew/collectors.cpp @@ -26,6 +26,7 @@ #include // class BOARD_ITEM #include +#include #include #include #include @@ -156,6 +157,7 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* aTestItem, void* aTestData PCB_FIELD* field = nullptr; PCB_TEXT* text = nullptr; PCB_DIMENSION_BASE* dimension = nullptr; + PCB_SHAPE* shape = nullptr; switch( aTestItem->Type() ) { @@ -194,13 +196,28 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* aTestItem, void* aTestData case PCB_ZONE_T: zone = static_cast( aTestItem ); + + if( m_Guide->IgnoreNoNets() && zone->GetNetCode() == NETINFO_LIST::UNCONNECTED ) + return INSPECT_RESULT::CONTINUE; + boardItem = zone; break; - case PCB_TEXTBOX_T: case PCB_SHAPE_T: + shape = static_cast( aTestItem ); + + if( m_Guide->IgnoreNoNets() && shape->GetNetCode() == NETINFO_LIST::UNCONNECTED ) + return INSPECT_RESULT::CONTINUE; + + boardItem = shape; + break; + + case PCB_TEXTBOX_T: case PCB_TABLE_T: case PCB_TABLECELL_T: + if( m_Guide->IgnoreNoNets() ) + return INSPECT_RESULT::CONTINUE; + boardItem = static_cast( aTestItem ); break; @@ -209,15 +226,24 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* aTestItem, void* aTestData case PCB_DIM_RADIAL_T: case PCB_DIM_ORTHOGONAL_T: case PCB_DIM_LEADER_T: + if( m_Guide->IgnoreNoNets() ) + return INSPECT_RESULT::CONTINUE; + dimension = static_cast( aTestItem ); boardItem = dimension; break; case PCB_TARGET_T: + if( m_Guide->IgnoreNoNets() ) + return INSPECT_RESULT::CONTINUE; + boardItem = static_cast( aTestItem ); break; case PCB_FIELD_T: + if( m_Guide->IgnoreNoNets() ) + return INSPECT_RESULT::CONTINUE; + field = static_cast( aTestItem ); if( !field->IsVisible() ) @@ -232,6 +258,9 @@ INSPECT_RESULT GENERAL_COLLECTOR::Inspect( EDA_ITEM* aTestItem, void* aTestData KI_FALLTHROUGH; case PCB_TEXT_T: + if( m_Guide->IgnoreNoNets() ) + return INSPECT_RESULT::CONTINUE; + text = static_cast( aTestItem ); boardItem = text; diff --git a/pcbnew/collectors.h b/pcbnew/collectors.h index 24de8eeb0c..5857956698 100644 --- a/pcbnew/collectors.h +++ b/pcbnew/collectors.h @@ -155,6 +155,11 @@ public: */ virtual bool IgnoreZoneFills() const = 0; + /** + * @return true if should ignore items with no net. + */ + virtual bool IgnoreNoNets() const = 0; + virtual int Accuracy() const = 0; virtual double OnePixelInIU() const = 0; @@ -359,6 +364,7 @@ public: m_ignoreMicroVias = false; m_ignoreTracks = false; m_ignoreZoneFills = true; + m_ignoreNoNets = false; m_onePixelInIU = abs( aView->ToWorld( one, false ).x ); m_accuracy = KiROUND( 5 * m_onePixelInIU ); @@ -466,6 +472,9 @@ public: bool IgnoreZoneFills() const override { return m_ignoreZoneFills; } void SetIgnoreZoneFills( bool ignore ) { m_ignoreZoneFills = ignore; } + bool IgnoreNoNets() const override { return m_ignoreNoNets; } + void SetIgnoreNoNets( bool ignore ) { m_ignoreNoNets = ignore; } + int Accuracy() const override { return m_accuracy; } void SetAccuracy( int aValue ) { m_accuracy = aValue; } @@ -496,6 +505,7 @@ private: bool m_ignoreMicroVias; bool m_ignoreTracks; bool m_ignoreZoneFills; + bool m_ignoreNoNets; double m_onePixelInIU; int m_accuracy; diff --git a/pcbnew/tools/board_inspection_tool.cpp b/pcbnew/tools/board_inspection_tool.cpp index d91f72f73d..46b1834892 100644 --- a/pcbnew/tools/board_inspection_tool.cpp +++ b/pcbnew/tools/board_inspection_tool.cpp @@ -1742,6 +1742,7 @@ int BOARD_INSPECTION_TOOL::HighlightItem( const TOOL_EVENT& aEvent ) { GENERAL_COLLECTORS_GUIDE guide = m_frame->GetCollectorsGuide(); guide.SetIgnoreZoneFills( false ); + guide.SetIgnoreNoNets( true ); PCB_LAYER_ID activeLayer = static_cast( view()->GetTopLayer() ); guide.SetPreferredLayer( activeLayer ); diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 81f2d40db1..36dc00371e 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -3844,6 +3844,9 @@ int DRAWING_TOOL::DrawVia( const TOOL_EVENT& aEvent ) for( ZONE* z : m_board->Zones() ) { + if( z->GetIsRuleArea() ) + continue; // ignore rule areas + for( PCB_LAYER_ID layer : lset.Seq() ) { if( z->IsOnLayer( layer ) )