← Back to team overview

kicad-developers team mailing list archive

Change behaviour of selectCopper and selectNet feature

 

Hy,

I think the "select Copper" and "select Net" feature should also select
zones, and not only track's and via's.

When thinking about a user which doesn't know the behavior of the
"select Copper" feature, it should be the expected assumption that this
feature is really selecting the interconnected copper area, and not only
interconnected track's and via's.

This patch adds this behavior.

Unfortunately the patch is not working in all cases at the moment, due
to a regression which triggers an assert, when someone want's to "select
Copper" on a zone which is not filled but the internal state say's
other. It seems IsFilled return's true in some cases where the zone is
actually not filled.

I created a video which I illustrates such a case where the variable is
not set as expected: https://owncloud.oe5tpo.com/index.php/s/YxqNpq4NxebmJGW

Regards, Thomas

From fa155e76d34430c14069ed76a03031febb3c37b1 Mon Sep 17 00:00:00 2001
From: Thomas Pointhuber <thomas.pointhuber@xxxxxx>
Date: Thu, 23 Feb 2017 22:32:51 +0100
Subject: [PATCH] Select zones using selectCopper or selectNet command

---
 pcbnew/tools/selection_tool.cpp | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp
index 96eda2c07..db3c514ed 100644
--- a/pcbnew/tools/selection_tool.cpp
+++ b/pcbnew/tools/selection_tool.cpp
@@ -33,6 +33,7 @@ using namespace std::placeholders;
 #include <class_module.h>
 #include <class_pcb_text.h>
 #include <class_drawsegment.h>
+#include <class_zone.h>
 
 #include <wxPcbStruct.h>
 #include <collectors.h>
@@ -133,11 +134,12 @@ private:
         const auto& selection = getToolManager()->GetTool<SELECTION_TOOL>()->GetSelection();
 
         bool connItem = ( S_C::OnlyType( PCB_VIA_T ) || S_C::OnlyType( PCB_TRACE_T ) )( selection );
+        bool connArea = ( S_C::OnlyType( PCB_ZONE_AREA_T ) )( selection );
         bool sheetSelEnabled = ( S_C::OnlyType( PCB_MODULE_T ) )( selection );
 
-        Enable( getMenuId( PCB_ACTIONS::selectNet ), connItem );
-        Enable( getMenuId( PCB_ACTIONS::selectCopper ), connItem );
         Enable( getMenuId( PCB_ACTIONS::selectConnection ), connItem );
+        Enable( getMenuId( PCB_ACTIONS::selectCopper ), connItem || connArea );
+        Enable( getMenuId( PCB_ACTIONS::selectNet ), connItem || connArea );
         Enable( getMenuId( PCB_ACTIONS::selectSameSheet ), sheetSelEnabled );
     }
 
@@ -722,9 +724,16 @@ void SELECTION_TOOL::selectAllItemsConnectedToTrack( TRACK& aSourceTrack )
 
 void SELECTION_TOOL::selectAllItemsConnectedToItem( BOARD_CONNECTED_ITEM& aSourceItem )
 {
+    if( aSourceItem.Type() == PCB_ZONE_AREA_T ) {
+        ZONE_CONTAINER& zone = static_cast<ZONE_CONTAINER&>( aSourceItem );
+
+        if( !zone.IsFilled() ) {
+            return;
+        }
+    }
     RN_DATA* ratsnest = getModel<BOARD>()->GetRatsnest();
     std::list<BOARD_CONNECTED_ITEM*> itemsList;
-    ratsnest->GetConnectedItems( &aSourceItem, itemsList, (RN_ITEM_TYPE)( RN_TRACKS | RN_VIAS ) );
+    ratsnest->GetConnectedItems( &aSourceItem, itemsList, (RN_ITEM_TYPE)( RN_TRACKS | RN_VIAS | RN_ZONES) );
 
     for( BOARD_CONNECTED_ITEM* i : itemsList )
         select( i );
@@ -736,7 +745,7 @@ void SELECTION_TOOL::selectAllItemsOnNet( int aNetCode )
     RN_DATA* ratsnest = getModel<BOARD>()->GetRatsnest();
     std::list<BOARD_CONNECTED_ITEM*> itemsList;
 
-    ratsnest->GetNetItems( aNetCode, itemsList, (RN_ITEM_TYPE)( RN_TRACKS | RN_VIAS ) );
+    ratsnest->GetNetItems( aNetCode, itemsList, (RN_ITEM_TYPE)( RN_TRACKS | RN_VIAS | RN_ZONES ) );
 
     for( BOARD_CONNECTED_ITEM* i : itemsList )
         select( i );
-- 
2.11.1

Attachment: signature.asc
Description: OpenPGP digital signature


Follow ups