Index: trunk/scconfig/Rev.h =================================================================== --- trunk/scconfig/Rev.h (revision 25816) +++ trunk/scconfig/Rev.h (revision 25817) @@ -1 +1 @@ -static const int myrev = 25789; +static const int myrev = 25817; Index: trunk/scconfig/Rev.tab =================================================================== --- trunk/scconfig/Rev.tab (revision 25816) +++ trunk/scconfig/Rev.tab (revision 25817) @@ -1,3 +1,4 @@ +25817 configure new plugin for data access actions 25789 configure centralize the unit selector widget in a DAD compound 25783 congigure hidlib: remove unused parts of the gtk HID 25758 configure compound DAD widgets, for DAD based spinboxes: remove old, gtk-only coord entry Index: trunk/scconfig/plugins.h =================================================================== --- trunk/scconfig/plugins.h (revision 25816) +++ trunk/scconfig/plugins.h (revision 25817) @@ -19,6 +19,7 @@ plugin_header("\nFeature plugins:\n") plugin_def("acompnet", "net auto-completion", sdisable, 1) plugin_def("act_draw", "action wrappers for drawing", sbuildin, 1) +plugin_def("act_read", "action wrappers for data access", sbuildin, 1) plugin_def("ar_cpcb", "autoroute with c-pcb", sbuildin, 1) plugin_def("asm", "assembly GUI", sbuildin, 1) plugin_def("autocrop", "crop board to fit objects", sbuildin, 1) Index: trunk/src_plugins/act_read/Makefile =================================================================== --- trunk/src_plugins/act_read/Makefile (nonexistent) +++ trunk/src_plugins/act_read/Makefile (revision 25817) @@ -0,0 +1,6 @@ +all: + cd ../../src && $(MAKE) mod_act_read + + +clean: + rm *.o *.so 2>/dev/null ; true Index: trunk/src_plugins/act_read/Plug.tmpasm =================================================================== --- trunk/src_plugins/act_read/Plug.tmpasm (nonexistent) +++ trunk/src_plugins/act_read/Plug.tmpasm (revision 25817) @@ -0,0 +1,10 @@ +put /local/pcb/mod {act_read} +put /local/pcb/mod/OBJS [@ + $(PLUGDIR)/act_read/act_read.o +@] + +switch /local/pcb/act_read/controls + case {buildin} include /local/pcb/tmpasm/buildin; end; + case {plugin} include /local/pcb/tmpasm/plugin; end; + case {disable} include /local/pcb/tmpasm/disable; end; +end Index: trunk/src_plugins/act_read/act_read.c =================================================================== --- trunk/src_plugins/act_read/act_read.c (nonexistent) +++ trunk/src_plugins/act_read/act_read.c (revision 25817) @@ -0,0 +1,96 @@ +/* + * 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 "actions.h" +#include "misc_util.h" + +static const char pcb_acts_GetValue[] = "GetValue(input, units, relative, default_unit)"; +static const char pcb_acth_GetValue[] = "Convert a coordinate value. Returns an unitless double or FGW_ERR_ARG_CONV. The 3rd parameter controls whether to require relative coordinates (+- prefix). Wraps pcb_get_value_ex()."; +static fgw_error_t pcb_act_GetValue(fgw_arg_t *res, int argc, fgw_arg_t *argv) +{ + const char *input, *units, *def_unit; + int relative, a; + double v; + pcb_bool success; + + PCB_ACT_CONVARG(1, FGW_STR, GetValue, input = argv[1].val.str); + PCB_ACT_CONVARG(2, FGW_STR, GetValue, units = argv[2].val.str); + PCB_ACT_CONVARG(3, FGW_INT, GetValue, relative = argv[3].val.nat_int); + PCB_ACT_CONVARG(4, FGW_STR, GetValue, def_unit = argv[1].val.str); + + if (*units == '\0') + units = NULL; + + v = pcb_get_value_ex(input, units, &a, NULL, def_unit, &success); + if (!success || (relative && a)) + return FGW_ERR_ARG_CONV; + + res->type = FGW_DOUBLE; + res->val.nat_double = v; + return 0; +} + +static int flg_error(const char *msg) +{ + pcb_message(PCB_MSG_ERROR, "act_read flag conversion error: %s\n", msg); + return 0; +} + +#define DRAWOPTARG \ + int noundo = 0, ao = 0; \ + if ((argv[1].type == FGW_STR) && (strcmp(argv[1].val.str, "noundo") == 0)) { \ + noundo = 1; \ + ao++; \ + } + + +pcb_action_t act_read_action_list[] = { + {"GetValue", pcb_act_GetValue, pcb_acth_GetValue, pcb_acts_GetValue}, +}; + +static const char *act_read_cookie = "act_read"; + +PCB_REGISTER_ACTIONS(act_read_action_list, act_read_cookie) + +int pplg_check_ver_act_read(int ver_needed) { return 0; } + +void pplg_uninit_act_read(void) +{ + pcb_remove_actions_by_cookie(act_read_cookie); +} + +#include "dolists.h" +int pplg_init_act_read(void) +{ + PCB_API_CHK_VER; + PCB_REGISTER_ACTIONS(act_read_action_list, act_read_cookie) + return 0; +} Index: trunk/src_plugins/act_read/act_read.pup =================================================================== --- trunk/src_plugins/act_read/act_read.pup (nonexistent) +++ trunk/src_plugins/act_read/act_read.pup (revision 25817) @@ -0,0 +1,7 @@ +$class feature +$short action wrappers for data access +$long Data access related API as actions +$state works +$package (core) +default buildin +autoload 1 Index: trunk/src_plugins/plugins_ALL.tmpasm =================================================================== --- trunk/src_plugins/plugins_ALL.tmpasm (revision 25816) +++ trunk/src_plugins/plugins_ALL.tmpasm (revision 25817) @@ -1,6 +1,7 @@ # List of all plugins - generated by make map_plugins - do NOT edit include {../src_plugins/acompnet/Plug.tmpasm} include {../src_plugins/act_draw/Plug.tmpasm} +include {../src_plugins/act_read/Plug.tmpasm} include {../src_plugins/ar_cpcb/Plug.tmpasm} include {../src_plugins/asm/Plug.tmpasm} include {../src_plugins/autocrop/Plug.tmpasm}