From 2ac8ab2a8f611546863533dc0f017eec2b16aafe Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 8 May 2017 10:26:48 +0200 Subject: [PATCH] Eagle layers as enums --- include/eagle_parser.h | 70 +++++++++++++++++++++++ pcbnew/eagle_plugin.cpp | 122 ++++++++-------------------------------- 2 files changed, 94 insertions(+), 98 deletions(-) diff --git a/include/eagle_parser.h b/include/eagle_parser.h index c45f72d282..fbbab2ec3e 100644 --- a/include/eagle_parser.h +++ b/include/eagle_parser.h @@ -668,6 +668,76 @@ struct ELAYER ELAYER( wxXmlNode* aLayer ); }; + +struct EAGLE_LAYER +{ + enum + { + TOP = 1, + ROUTE2 = 2, + ROUTE3 = 3, + ROUTE4 = 4, + ROUTE5 = 5, + ROUTE6 = 6, + ROUTE7 = 7, + ROUTE8 = 8, + ROUTE9 = 9, + ROUTE10 = 10, + ROUTE11 = 11, + ROUTE12 = 12, + ROUTE13 = 13, + ROUTE14 = 14, + ROUTE15 = 15, + BOTTOM = 16, + PADS = 17, + VIAS = 18, + UNROUTED = 19, + DIMENSION = 20, + TPLACE = 21, + BPLACE = 22, + TORIGINS = 23, + BORIGINS = 24, + TNAMES = 25, + BNAMES = 26, + TVALUES = 27, + BVALUES = 28, + TSTOP = 29, + BSTOP = 30, + TCREAM = 31, + BCREAM = 32, + TFINISH = 33, + BFINISH = 34, + TGLUE = 35, + BGLUE = 36, + TTEST = 37, + BTEST = 38, + TKEEPOUT = 39, + BKEEPOUT = 40, + TRESTRICT = 41, + BRESTRICT = 42, + VRESTRICT = 43, + DRILLS = 44, + HOLES = 45, + MILLING = 46, + MEASURES = 47, + DOCUMENT = 48, + REFERENCELC = 49, + REFERENCELS = 50, + TDOCU = 51, + BDOCU = 52, + NETS = 91, + BUSSES = 92, + PINS = 93, + SYMBOLS = 94, + NAMES = 95, + VALUES = 96, + INFO = 97, + GUIDE = 98, + USERLAYER1 = 160, + USERLAYER2 = 161 + }; +}; + /** * Function MapChildren * provides an easy access to the children of an XML node via their names. diff --git a/pcbnew/eagle_plugin.cpp b/pcbnew/eagle_plugin.cpp index cf7fe29b56..4ac1fd61a1 100644 --- a/pcbnew/eagle_plugin.cpp +++ b/pcbnew/eagle_plugin.cpp @@ -1882,82 +1882,6 @@ void EAGLE_PLUGIN::loadSignals( wxXmlNode* aSignals ) PCB_LAYER_ID EAGLE_PLUGIN::kicad_layer( int aEagleLayer ) const { - /* will assume this is a valid mapping for all eagle boards until I get paid more: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - * These layers are used only in eagle schematic. - * They should not be found in board files. - * They are listed for info only. - - - - - - - - - - * These layers are user layers - - - - - - */ - int kiLayer; // eagle copper layer: @@ -1971,39 +1895,41 @@ PCB_LAYER_ID EAGLE_PLUGIN::kicad_layer( int aEagleLayer ) const // translate non-copper eagle layer to pcbnew layer switch( aEagleLayer ) { - case 20: kiLayer = Edge_Cuts; break; // eagle says "Dimension" layer, but it's for board perimeter - case 21: kiLayer = F_SilkS; break; - case 22: kiLayer = B_SilkS; break; - case 25: kiLayer = F_SilkS; break; - case 26: kiLayer = B_SilkS; break; - case 27: kiLayer = F_SilkS; break; - case 28: kiLayer = B_SilkS; break; - case 29: kiLayer = F_Mask; break; - case 30: kiLayer = B_Mask; break; - case 31: kiLayer = F_Paste; break; - case 32: kiLayer = B_Paste; break; - case 33: kiLayer = F_Mask; break; - case 34: kiLayer = B_Mask; break; - case 35: kiLayer = F_Adhes; break; - case 36: kiLayer = B_Adhes; break; - case 48: kiLayer = Cmts_User; break; - case 49: kiLayer = Cmts_User; break; - case 50: kiLayer = Cmts_User; break; + // Eagle says "Dimension" layer, but it's for board perimeter + case EAGLE_LAYER::DIMENSION: kiLayer = Edge_Cuts; break; + case EAGLE_LAYER::TPLACE: kiLayer = F_SilkS; break; + case EAGLE_LAYER::BPLACE: kiLayer = B_SilkS; break; + case EAGLE_LAYER::TNAMES: kiLayer = F_SilkS; break; + case EAGLE_LAYER::BNAMES: kiLayer = B_SilkS; break; + case EAGLE_LAYER::TVALUES: kiLayer = F_SilkS; break; + case EAGLE_LAYER::BVALUES: kiLayer = B_SilkS; break; + case EAGLE_LAYER::TSTOP: kiLayer = F_Mask; break; + case EAGLE_LAYER::BSTOP: kiLayer = B_Mask; break; + case EAGLE_LAYER::TCREAM: kiLayer = F_Paste; break; + case EAGLE_LAYER::BCREAM: kiLayer = B_Paste; break; + case EAGLE_LAYER::TFINISH: kiLayer = F_Mask; break; + case EAGLE_LAYER::BFINISH: kiLayer = B_Mask; break; + case EAGLE_LAYER::TGLUE: kiLayer = F_Adhes; break; + case EAGLE_LAYER::BGLUE: kiLayer = B_Adhes; break; + case EAGLE_LAYER::DOCUMENT: kiLayer = Cmts_User; break; + case EAGLE_LAYER::REFERENCELC: kiLayer = Cmts_User; break; + case EAGLE_LAYER::REFERENCELS: kiLayer = Cmts_User; break; // Packages show the future chip pins on SMD parts using layer 51. // This is an area slightly smaller than the PAD/SMD copper area. // Carry those visual aids into the MODULE on the fabrication layer, // not silkscreen. This is perhaps not perfect, but there is not a lot // of other suitable paired layers - case 51: kiLayer = F_Fab; break; - case 52: kiLayer = B_Fab; break; + case EAGLE_LAYER::TDOCU: kiLayer = F_Fab; break; + case EAGLE_LAYER::BDOCU: kiLayer = B_Fab; break; // thes layers are defined as user layers. put them on ECO layers - case 160: kiLayer = Eco1_User; break; - case 161: kiLayer = Eco2_User; break; + case EAGLE_LAYER::USERLAYER1: kiLayer = Eco1_User; break; + case EAGLE_LAYER::USERLAYER2: kiLayer = Eco2_User; break; default: // some layers do not map to KiCad // DBG( printf( "unsupported eagle layer: %d\n", aEagleLayer );) + // kiLayer = UNDEFINED_LAYER; break; } }