/* $Id$ */ /* * COPYRIGHT * * PCB, interactive printed circuit board design * Copyright (C) 1994,1995,1996 Thomas Nau * Copyright (C) 1998,1999,2000,2001 harry eaton * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * Contact addresses for paper mail and Email: * harry eaton, 6697 Buttonhole Ct, Columbia, MD 21044 USA * haceaton@aplcomm.jhuapl.edu * */ #ifndef __LAYER_INCLUDED__ #define __LAYER_INCLUDED__ #include "global.h" #define DEFAULT_LAYERSTACK_SIZE 8 /* * The layer structuring works as follows: * 1. At the top level, each PCB has a layer stack. This is the ordered * list of physical layers, plus one "internal" layer that is never * saved out or edited. (For now, this will contain the ratsnest layer * and nothing else.) * * 2. Each physical layer is called a "layer group". It can contain * indefinitely many drawing layers. Layer groups are one of TOP, * BOTTOM, INNER or OUTER. There is at most one of each TOP, BOTTOM * and OUTER layers. There can be any number of INNER layers, which * will be ordered by their z-index. * * 3. Each drawing layer has a type associated with it - one of COPPER * (conductive), SILK (non-conductive) or INTERNAL (not saved out: * DRC highlights, etc, will be on such a layer). * * 4. TODO: There is no way to do keepouts. I have heard arguments for * allowing global keepouts, per-layer keepouts, per-function-block * keepouts, etc, and I don't know how it should be structured. */ /*! * The type of drawing layer (conductor/nonconductor/internal use) */ typedef enum { LYR_COPPER, /*! conductive */ LYR_SILK, /*! non-conductive */ LYR_VIRTUAL /*! internal (ie, ratsnest) */ } LayerStyle; /*! * Qualitive position in the physical layer stack * TOP and BOTTOM are single layers; INNER layers are ordered by their z-index. */ typedef enum { LYR_TOP, /*! top ("component side") */ LYR_INNER, /*! middle */ LYR_BOTTOM /*! bottom ("solder side") */ LYR_OUTER /*! both top and bottom */ } LayerPos; /*! * Drawing layer structure * Drawing layers are contained within "layer groups" or physical layers, * which in turn are placed on the layer stack. */ typedef struct { const char *name; /*! Layer name */ const char *color; /*! Layer color */ LayerStyle style; /*! Layer material */ int b_visible; /*! Visible in GUI */ int b_active; /*! Active layer in GUI */ int b_vacuum; /*! "Hole mode" in GUI */ int b_locked; /*! Un-editable in GUI */ } Layer; /*! * Layer group structure * Groups correspond to physical layers on the stack. * When setting z_index, lower numbers are closer to the top. */ typedef struct { const char *name; /*! Group name */ LayerPos position; /*! Top/Inner/Bottom */ unsigned z_index; /*! Stacking order */ Layer **layer; /*! List of layers */ unsigned n_layers; /*! Number of layers */ } LayerGroup; /*! * Layer stack structure */ typedef struct { Layer **layer_group; /*! List of groups */ unsigned n_groups; /*! Number of groups */ unsigned _allocated_layers; /*! private */ } LayerStack; /* Layer functions */ Layer *layer_new (const char *name, const char *color, LayerStyle style); Layer *layer_dup (Layer *target); void layer_del (Layer *target); /* Layer group functions */ LayerGroup *layergroup_new (const char *name, const char *color, LayerPos position); void layergroup_del (LayerGroup *group, int b_deep); unsigned layergroup_add_layer (LayerGroup *group, Layer *group); Layer *layergroup_del_layer (LayerGroup *group, unsigned index); Layer *layergroup_get_layer (const LayerGroup *group, unsigned index); /* Layer stack functions */ LayerStack *layerstack_new (); void layerstack_del (LayerStack *stack, int b_deep); unsigned layerstack_add_group (LayerStack *stack, Layer *group); Layer *layerstack_del_group (LayerStack *stack, unsigned index); Layer *layerstack_get_group (const LayerStack *stack, unsigned index); #endif