← Back to team overview

kicad-developers team mailing list archive

GAL layers

 

OK, I'm trying to follow the road to isolate GAL layers and pcbnew
layers. Let's see if it can work:

- pcbnew still uses LAYER_NUM (for layers) and PCB_VISIBLE (for other
  stuff)

- GAL *doesn't* use LAYER_NUM, because a) it wouldn't work anyway with
  eeschema in future and b) it extends the range to contain PCB_VISIBLE
  values (offset at the end of the layers)

- PCB_VISIBLE was extended to handle more things, like the overlay and
  the netnames; at the moment I don't see problems with that.

I added a GAL_LAYER_NUM type (another enum) to be used in the GAL/View
stuff. There was already the ITEM_GAL_LAYER macro (not function since it
needs to 'run' at compile time for initializers) for going from
PCB_VISIBLE to GAL_LAYER_NUM. Simply added a PCB_GAL_LAYER to do the
LAYER_NUM to GAL_LAYER_NUM domain cross (little more than a cast,
actually). Luckily there is (until now) need to do the reverse (which is
impossible in the general case...).

Aside note: GAL_LAYER_NUM could be a base class and PCB_VISIBLE and
LAYER_NUM could be subclasses. It seems to me that the IS-A relationship
holds. However in C++ that would be actually very inconvenient since you
can't have literal instances... except maybe in C++x1; so I'm keeping
the enum representation which works and (un)fortunately has an implicit
conversion to int.

The idea is that all the 'view' stuff shouldn't be contaminated by
LAYER_NUM to ensure future reuse. 

First strange thing I found: the ViewGetLayers seems to be a callback
(added in EDA_ITEM, probably) to interrogate an object and schedule it's
drawing (or something like that, didn't study the whole trip). The
returned array seems to be of GAL_LAYER_NUM values (it make sense). The
fact that LAYER_NUM values are valid and correct GAL_LAYER_NUM values is
an (handy!) coincidence.

However in ROUTER_PREVIEW_ITEM::ViewGetLayers, the GP_OVERLAY value is
stored back (the type is PCB_DISPLAY) which interpreted as
a GAL_LAYER_NUM would go more or less in the via display layers...
should it be instead ITEM_GAL_LAYER(GP_OVERLAY) or did I miss some trick
along the way?

By the way I find the view machinery most interesting, good work with
that!

-- 
Lorenzo Marcantonio
Logos Srl


Follow ups