X-Authentication-Warning: delorie.com: mail set sender to geda-user-bounces using -f X-Recipient: geda-user AT delorie DOT com X-Original-DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=mail.ud03.udmedia.de; h= to:from:subject:message-id:date:mime-version:content-type :content-transfer-encoding; s=beta; bh=6qSpqoCOGGsd33uWAqxRN7CHd DTG4In5esmPjuWjRPQ=; b=FpSFfsfIRscELGAFm5z8zpbZloiHcG9SaDFYDbBcG ReymIoXAjUbxH+2SgE5IgzyyB9abkvt4YCfezqJCfrzcxvjDnNsyJ/53JV0ZTQgz 7OOdeHk+IkP6p62chX4MK6+S+ALq4VmuuJtmDBeVQ8hFQwSSOu0StOzuR09mkmre IU= To: geda-user AT delorie DOT com From: "Markus Hitter (mah AT jump-ing DOT de) [via geda-user AT delorie DOT com]" Subject: [geda-user] Notice to developers: layers have now a type. Message-ID: <55F1F75F.8010809@jump-ing.de> Date: Thu, 10 Sep 2015 23:34:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Reply-To: geda-user AT delorie DOT com Dear developers, unless there appears evidence it doesn't work as expected, I'll forward branch LP1493557 to master tomorrow. It's the essence of a patch made by DJ Delorie in 2007 and some of my work for refining. Every single commit passes the regression test. The new code will give layers a type. These types exist (see hid.h and strflags.c): "copper", /* LT_COPPER */ "silk", /* LT_SILK */ "mask", /* LT_MASK */ "pdrill", /* LT_PDRILL */ "udrill", /* LT_UDRILL */ "paste", /* LT_PASTE */ "invisible", /* LT_INVISIBLE */ "fab", /* LT_FAB */ "assy", /* LT_ASSY */ "outline", /* LT_OUTLINE */ "route", /* LT_ROUTE */ "notes", /* LT_NOTES */ "keepout", /* LT_KEEPOUT */ "no_type" /* LT_NUM_LAYERTYPES */ To the left the name as it appears in the saved file, to the right the flag to test for in code. - - - Examples: To test wether a specific layer is a copper (conductive) layer, do it like this: if (PCB->Data->Layer[index].Type == LT_COPPER) ... To iterate through all layers of a specific type, there's now a comfortable macro. For example to loop over all paste layers: LAYER_TYPE_LOOP (PCB->Data, max_copper_layer + SILK_LAYER, LT_PASTE) do_something_with (layer); layer_number_is (n); END_LOOP; N.B. the term 'max_copper_layer + SILK_LAYER' is simply the number of defined layers, so you get all defined layers. For details see src/const.h. - - - How does this meet existing design files? Currently the above techniques aren't in use, yet, all code still uses various voodoo heuristics in many places to guess the type of a layer as it did the last 20 years. So, no immediate change in behaviour expected. When loading older files, some such voodoo heuristics ("guess_layertype()") is now used right at load time. So all future code can rely on an existing layertype from now on. Patches replacing old heuristics by simple tests or loops, like shown above, are very welcome. At save time, layer types are saved, so this guessing is done only once. Former layer definition: Layer(1 "component") From now on Layer(1 "component" "copper") Easy to edit, it's Layer( ) Older versions of pcb can load files saved with newer version, they simply ignore the type field. As said, code is currently on the LP1493557 branch in the official Git repo: http://git.geda-project.org/pcb/log/?h=LP1493557 Happy hacking, Markus -- - - - - - - - - - - - - - - - - - - - Dipl. Ing. (FH) Markus Hitter http://www.jump-ing.de/