← Back to team overview

kicad-developers team mailing list archive

[PATCH] Allow selecting footprints that are only silkscreen using silk layers

 

See: https://bugs.launchpad.net/kicad/+bug/1741350
From d80d2dddd66bb6740f659f79d85b0efdb4008369 Mon Sep 17 00:00:00 2001
From: Jon Evans <jon@xxxxxxxxxxxxx>
Date: Thu, 4 Jan 2018 17:39:36 -0500
Subject: [PATCH] Allow selecting footprints that are only silkscreen using
 silk layers

In high-contrast mode, items that don't exist on the current layer are
not selectable, but this is problematic since there are library
components that only exist in the silkscreen layer (logos, etc).

By adding one of the silkscreen layers to the ViewGetLayers() output,
these components are now editable when viewing the silkscreen layer in
high-contrast mode.  Silkscreens attached to footprints that have pads
or drawings on non-silkscreen layers are still not selectable.

Fixes: lp:1741350
* https://bugs.launchpad.net/kicad/+bug/1741350
---
 pcbnew/class_module.cpp | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/pcbnew/class_module.cpp b/pcbnew/class_module.cpp
index 2b4e5d4b2..791ee007b 100644
--- a/pcbnew/class_module.cpp
+++ b/pcbnew/class_module.cpp
@@ -888,6 +888,30 @@ void MODULE::ViewGetLayers( int aLayers[], int& aCount ) const
         aLayers[1] = LAYER_MOD_BK;
         break;
     }
+
+    // If there are no pads, and only drawings on a silkscreen layer, then
+    // report the silkscreen layer as well so that the component can be edited
+    // with the silkscreen layer
+    bool f_silk = false, b_silk = false, non_silk = false;
+
+    for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
+    {
+        if( item->GetLayer() == F_SilkS )
+            f_silk = true;
+        else if( item->GetLayer() == B_SilkS )
+            b_silk = true;
+        else
+            non_silk = true;
+    }
+
+    if( ( f_silk || b_silk ) && !non_silk && m_Pads.GetCount() == 0 )
+    {
+        if( f_silk )
+            aLayers[ aCount++ ] = F_SilkS;
+
+        if( b_silk )
+            aLayers[ aCount++ ] = B_SilkS;
+    }
 }
 
 
-- 
2.14.1


Follow ups