Index: trunk/src_plugins/act_read/act_layer.c =================================================================== --- trunk/src_plugins/act_read/act_layer.c (nonexistent) +++ trunk/src_plugins/act_read/act_layer.c (revision 28931) @@ -0,0 +1,103 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 2019 Tibor 'Igor2' Palinkas + * + * This module, dialogs, was written and is Copyright (C) 2017 by Tibor Palinkas + * this module is also subject to the GNU GPL as described below + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Contact: + * Project page: http://repo.hu/projects/pcb-rnd + * lead developer: http://repo.hu/projects/pcb-rnd/contact.html + * mailing list: pcb-rnd (at) list.repo.hu (send "subscribe") + */ + +#include "config.h" + +#include "board.h" +#include "data.h" +#include "layer.h" +#include "actions.h" +#include "plugins.h" +#include "misc_util.h" +#include "idpath.h" +#include "search.h" +#include "find.h" + +static const char pcb_acts_ReadGroup[] = + "ReadGroup(length)\n" + "ReadGroup(field, group, [init_invis|ltype|name|open|purpose|vis|length])\n" + "ReadGroup(layerid, idx)\n" + ; +static const char pcb_acth_ReadGroup[] = "Length returns the number of groups on the current PCB. Field returns one of the fields of the group named in groupid. Layerid returns the integer layer ID (as interpreted within data) for the idxth layer of the group."; +static fgw_error_t pcb_act_ReadGroup(fgw_arg_t *res, int argc, fgw_arg_t *argv) +{ + pcb_board_t *pcb = PCB_ACT_BOARD; + int cmd, fld; + char *cmds, *flds; + pcb_layergrp_t *grp; + long idx; + + PCB_ACT_CONVARG(1, FGW_STR, ReadGroup, cmds = argv[1].val.str); +TODO("Get the group here"); + + cmd = act_read_keywords_sphash(cmds); + switch(cmd) { + case act_read_keywords_length: + PCB_ACT_IRES(0); + return 0; + case act_read_keywords_layerid: + PCB_ACT_CONVARG(3, FGW_LONG, ReadGroup, idx = argv[3].val.nat_long); + if ((idx < 0) || (idx >= grp->len)) + return FGW_ERR_ARG_CONV; + res->type = FGW_LONG; res->val.nat_long = grp->lid[idx]; + return 0; + case act_read_keywords_field: + PCB_ACT_CONVARG(3, FGW_STR, ReadGroup, flds = argv[3].val.str); + fld = act_read_keywords_sphash(flds); + switch(fld) { + case act_read_keywords_name: + res->type = FGW_STR; res->val.str = grp->name; + return 0; + case act_read_keywords_purpose: + res->type = FGW_STR; res->val.str = grp->purpose; + return 0; + case act_read_keywords_ltype: + res->type = FGW_LONG; res->val.nat_long = grp->ltype; + return 0; + case act_read_keywords_length: + res->type = FGW_LONG; res->val.nat_long = grp->len; + return 0; + case act_read_keywords_vis: + res->type = FGW_INT; res->val.nat_int = grp->vis; + return 0; + case act_read_keywords_init_invis: + res->type = FGW_INT; res->val.nat_int = grp->init_invis; + return 0; + case act_read_keywords_open: + res->type = FGW_INT; res->val.nat_int = grp->open; + return 0; + default: + return FGW_ERR_ARG_CONV; + } + default: + return FGW_ERR_ARG_CONV; + } + + return FGW_ERR_ARG_CONV; +} Index: trunk/src_plugins/act_read/act_read.c =================================================================== --- trunk/src_plugins/act_read/act_read.c (revision 28930) +++ trunk/src_plugins/act_read/act_read.c (revision 28931) @@ -42,6 +42,7 @@ #include "act_idpath.c" #include "act_geo.c" +#include "act_layer.c" static const char pcb_acts_GetValue[] = "GetValue(input, units, relative, default_unit)"; Index: trunk/src_plugins/act_read/keywords.sphash =================================================================== --- trunk/src_plugins/act_read/keywords.sphash (revision 28930) +++ trunk/src_plugins/act_read/keywords.sphash (revision 28931) @@ -2,8 +2,10 @@ append clear dup +field free get +layerid length pop push @@ -10,3 +12,10 @@ prepend print remove + +init_invis +ltype +name +open +purpose +vis