← Back to team overview

kicad-developers team mailing list archive

[PATCH] Adding 'Hide all layers' and Show all layers' to the pcbnew layer manager pop-up window.

 

Hi everybody,

In the last few days I used kicad and i noticed that It was useful to me to have 'hide all layers' and a 'show all layers' in the pcbnew layer toolbar popup.

I'm attaching the (small) patch, so that (if useful) can be used.

Bye,
Dino.
>From ec31006cf8714f65aa939e33c2ebd5b68dbc86c5 Mon Sep 17 00:00:00 2001
From: dino <dino.ghilardi@xxxxxxxx>
Date: Sat, 24 Sep 2016 11:35:33 +0200
Subject: [PATCH] pcbnew: Added 'show all layers' and 'hide all layers' option
 in layers pop-up menu
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="------------2.1.4"

This is a multi-part message in MIME format.
--------------2.1.4
Content-Type: text/plain; charset=UTF-8; format=fixed
Content-Transfer-Encoding: 8bit

---
 pcbnew/class_pcb_layer_widget.cpp | 38 ++++++++++++++++++++++++++++++++++++--
 pcbnew/class_pcb_layer_widget.h   |  3 +++
 2 files changed, 39 insertions(+), 2 deletions(-)


--------------2.1.4
Content-Type: text/x-patch; name="0001-pcbnew-Added-show-all-layers-and-hide-all-layers-opt.patch"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="0001-pcbnew-Added-show-all-layers-and-hide-all-layers-opt.patch"

diff --git a/pcbnew/class_pcb_layer_widget.cpp b/pcbnew/class_pcb_layer_widget.cpp
index f040262..d7e4adc 100644
--- a/pcbnew/class_pcb_layer_widget.cpp
+++ b/pcbnew/class_pcb_layer_widget.cpp
@@ -105,10 +105,10 @@ PCB_LAYER_WIDGET::PCB_LAYER_WIDGET( PCB_BASE_FRAME* aParent, wxWindow* aFocusOwn
 
     // since Popupmenu() calls this->ProcessEvent() we must call this->Connect()
     // and not m_LayerScrolledWindow->Connect()
-    Connect( ID_SHOW_ALL_COPPERS, ID_ALWAYS_SHOW_NO_COPPERS_BUT_ACTIVE,
+
+    Connect( ID_SHOW_ALL_COPPERS, ID_SHOW_ALL_LAYERS,
         wxEVT_COMMAND_MENU_SELECTED,
         wxCommandEventHandler( PCB_LAYER_WIDGET::onPopupSelection ), NULL, this );
-
     // install the right click handler into each control at end of ReFill()
     // using installRightLayerClickHandler
 }
@@ -165,6 +165,10 @@ void PCB_LAYER_WIDGET::onRightDownLayers( wxMouseEvent& event )
                                  _( "Always Hide All Copper Layers But Active" ) ) );
     menu.Append( new wxMenuItem( &menu, ID_SHOW_NO_COPPERS,
                                  _( "Hide All Copper Layers" ) ) );
+    menu.Append( new wxMenuItem( &menu, ID_SHOW_NO_LAYERS,
+                                 _( "Hide All Layers" ) ) );
+    menu.Append( new wxMenuItem( &menu, ID_SHOW_ALL_LAYERS,
+                                 _( "Show All Layers" ) ) );
 
     PopupMenu( &menu );
 
@@ -186,10 +190,39 @@ void PCB_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
 
     switch( menuId )
     {
+
+    case ID_SHOW_NO_LAYERS:
+    case ID_SHOW_ALL_LAYERS:
+        bool loc_visible;
+	if (menuId==ID_SHOW_ALL_LAYERS) 
+		loc_visible= true;
+			else
+	        loc_visible = false; 
+
+	rowCount = GetLayerRowCount();
+
+   	for( int row=0;  row<rowCount;  ++row )
+        {
+	    bool isLast;
+            wxCheckBox* cb = (wxCheckBox*) getLayerComp( row, COLUMN_COLOR_LYR_CB );
+            LAYER_ID    layer = ToLAYER_ID( getDecodedId( cb->GetId() ) );
+            cb->SetValue( loc_visible );
+
+	    if (row==rowCount-1)
+		isLast=true;
+	    else
+		isLast=false;
+
+	    OnLayerVisible( layer, loc_visible, isLast );
+	   if (isLast) break;
+         }
+	break;
+
     case ID_SHOW_ALL_COPPERS:
     case ID_ALWAYS_SHOW_NO_COPPERS_BUT_ACTIVE:
     case ID_SHOW_NO_COPPERS_BUT_ACTIVE:
     case ID_SHOW_NO_COPPERS:
+
         // Search the last copper layer row index:
         int lastCu = -1;
         rowCount = GetLayerRowCount();
@@ -228,6 +261,7 @@ void PCB_LAYER_WIDGET::onPopupSelection( wxCommandEvent& event )
             }
         }
         break;
+
     }
 }
 
diff --git a/pcbnew/class_pcb_layer_widget.h b/pcbnew/class_pcb_layer_widget.h
index 7908d80..04890c3 100644
--- a/pcbnew/class_pcb_layer_widget.h
+++ b/pcbnew/class_pcb_layer_widget.h
@@ -122,6 +122,9 @@ protected:
 #define ID_SHOW_NO_COPPERS                      (wxID_HIGHEST+1)
 #define ID_SHOW_NO_COPPERS_BUT_ACTIVE           (wxID_HIGHEST+2)
 #define ID_ALWAYS_SHOW_NO_COPPERS_BUT_ACTIVE    (wxID_HIGHEST+3)
+#define ID_SHOW_NO_LAYERS			(wxID_HIGHEST+4)
+#define ID_SHOW_ALL_LAYERS                      (wxID_HIGHEST+5)
+
 
     /**
      * Function isAllowedInFpMode

--------------2.1.4--



Follow ups