← Back to team overview

kicad-developers team mailing list archive

[PATCH] LSET::UIOrder and LSET::Technicals now match layer widget order

 

Fixes: https://bugs.launchpad.net/kicad/+bug/1673792
From 3212a211cc04d81eac4fcc2a1ebe0e0383b5a821 Mon Sep 17 00:00:00 2001
From: Jon Evans <jon@xxxxxxxxxxxxx>
Date: Thu, 11 Jan 2018 22:32:14 -0500
Subject: [PATCH] LSET::UIOrder and LSET::Technicals now match layer widget
 order

Fixes: lp:1673792
* https://bugs.launchpad.net/kicad/+bug/1673792
---
 common/lset.cpp                           | 52 ++++++++++++++++++++++---------
 include/layers_id_colors_and_visibility.h |  3 ++
 2 files changed, 40 insertions(+), 15 deletions(-)

diff --git a/common/lset.cpp b/common/lset.cpp
index 8008b0ac4..9ef9de2f5 100644
--- a/common/lset.cpp
+++ b/common/lset.cpp
@@ -190,18 +190,18 @@ LSEQ LSET::Technicals( LSET aSetToOmit ) const
 {
     // desired sequence
     static const PCB_LAYER_ID sequence[] = {
-        B_Adhes,
         F_Adhes,
-        B_Paste,
+        B_Adhes,
         F_Paste,
-        B_SilkS,
+        B_Paste,
         F_SilkS,
-        B_Mask,
+        B_SilkS,
         F_Mask,
-        B_CrtYd,
+        B_Mask,
         F_CrtYd,
-        B_Fab,
+        B_CrtYd,
         F_Fab,
+        B_Fab,
     };
 
     LSET subset = ~aSetToOmit & *this;
@@ -226,6 +226,33 @@ LSEQ LSET::Users() const
 }
 
 
+LSEQ LSET::TechAndUserUIOrder() const
+{
+    static const PCB_LAYER_ID sequence[] = {
+        F_Adhes,
+        B_Adhes,
+        F_Paste,
+        B_Paste,
+        F_SilkS,
+        B_SilkS,
+        F_Mask,
+        B_Mask,
+        Dwgs_User,
+        Cmts_User,
+        Eco1_User,
+        Eco2_User,
+        Edge_Cuts,
+        Margin,
+        F_CrtYd,
+        B_CrtYd,
+        F_Fab,
+        B_Fab,
+   };
+
+   return Seq( sequence, DIM( sequence ) );
+}
+
+
 std::string LSET::FmtBin() const
 {
     std::string ret;
@@ -758,16 +785,11 @@ LSET LSET::BackMask()
 
 LSEQ LSET::UIOrder() const
 {
-    PCB_LAYER_ID order[PCB_LAYER_ID_COUNT];
-
-    // Assmuming that the PCB_LAYER_ID order is according to preferred UI order, as of
-    // today this is true.  When that becomes not true, its easy to change the order
-    // in here to compensate.
-
-    for( unsigned i=0;  i<DIM(order);  ++i )
-        order[i] = PCB_LAYER_ID( i );
+    LSEQ order = CuStack();
+    LSEQ techuser = TechAndUserUIOrder();
+    order.insert( order.end(), techuser.begin(), techuser.end() );
 
-    return Seq( order, DIM( order ) );
+    return order;
 }
 
 
diff --git a/include/layers_id_colors_and_visibility.h b/include/layers_id_colors_and_visibility.h
index a3d70c936..01b5df900 100644
--- a/include/layers_id_colors_and_visibility.h
+++ b/include/layers_id_colors_and_visibility.h
@@ -546,6 +546,9 @@ public:
     /// *_User layers.
     LSEQ Users() const;
 
+    /// Returns the technical and user layers in the order shown in layer widget
+    LSEQ TechAndUserUIOrder() const;
+
     LSEQ UIOrder() const;
 
     /**
-- 
2.14.1


Follow ups