Index: trunk/scconfig/Rev.h =================================================================== --- trunk/scconfig/Rev.h (revision 13363) +++ trunk/scconfig/Rev.h (revision 13364) @@ -1 +1 @@ -static const int myrev = 13269; +static const int myrev = 13364; Index: trunk/scconfig/Rev.tab =================================================================== --- trunk/scconfig/Rev.tab (revision 13363) +++ trunk/scconfig/Rev.tab (revision 13364) @@ -1,3 +1,4 @@ +13364 configure new plugin: extedit 13269 configure remove free_atexit 13171 configure io_eagle: new source file for parsing dru files 13037 configure code simplification: PCB_INLINE Index: trunk/scconfig/plugins.h =================================================================== --- trunk/scconfig/plugins.h (revision 13363) +++ trunk/scconfig/plugins.h (revision 13364) @@ -30,6 +30,7 @@ plugin_def("draw_csect", "draw cross-section (layers)", sdisable, 1) plugin_def("draw_fab", "fab layer in some exports", sbuildin, 1) plugin_def("draw_fontsel", "font selection GUI", sdisable, 1) +plugin_def("extedit", "edit with external program", sbuildin, 1) plugin_def("fontmode", "font editor", sbuildin, 1) plugin_def("gpmi", "GPMI scripting", sbuildin, 1) plugin_def("jostle", "push lines out of the way", sbuildin, 1) @@ -112,6 +113,7 @@ plugin_dep("export_lpr", "export_ps") plugin_dep("export_openscad", "lib_polyhelp") plugin_dep("export_xy", "export_bom") +plugin_dep("extedit", "io_lihata") plugin_dep("fp_wget", "fp_fs") plugin_dep("hid_gtk2_gdk", "draw_csect") plugin_dep("hid_gtk2_gdk", "draw_fontsel") Index: trunk/src/Makefile.dep =================================================================== --- trunk/src/Makefile.dep (revision 13363) +++ trunk/src/Makefile.dep (revision 13364) @@ -927,6 +927,33 @@ ../src_3rd/puplug/error.h compat_misc.h obj_pinvia.h netlist.h \ route_style.h safe_fs.h hid.h hid_nogui.h hid_attrib.h hid_helper.h \ hid_init.h ../src_plugins/export_xy/default_templ.h +../src_plugins/extedit/extedit.o: ../src_plugins/extedit/extedit.c \ + ../config.h hid.h error.h drc.h unit.h global_typedefs.h pcb_bool.h \ + attrib.h layer.h globalconst.h obj_all_list.h obj_arc_list.h \ + obj_common.h ../src_3rd/genht/hash.h ../src_3rd/genlist/gendlist.h \ + flag.h data_parent.h obj_arc.h ../src_3rd/genlist/gentdlist_impl.h \ + ../src_3rd/genlist/gendlist.h ../src_3rd/genlist/gentdlist_undef.h \ + obj_elem_list.h obj_elem.h obj_line_list.h obj_line.h obj_pad_list.h \ + obj_pad.h obj_pinvia_list.h obj_pinvia.h obj_text.h font.h \ + ../src_3rd/genht/htip.h ../src_3rd/genht/ht.h obj_poly.h polyarea.h \ + obj_poly_list.h box.h math_helper.h macro.h move.h misc_util.h \ + ht_element.h ../src_3rd/genht/ht.h obj_pstk_list.h obj_pstk.h \ + obj_text_list.h obj_rat_list.h obj_rat.h layer_grp.h hid_attrib.h hid.h \ + hid_actions.h hid_dad.h compat_misc.h hid_attrib.h pcb-printf.h \ + ../src_3rd/genvector/gds_char.h ../src_3rd/genvector/genvector_impl.h \ + ../src_3rd/genvector/genvector_undef.h action_helper.h board.h const.h \ + vtroutestyle.h library.h rats_patch.h board.h compat_fs.h const.h \ + conf_core.h conf.h ../src_3rd/liblihata/lihata.h \ + ../src_3rd/liblihata/dom.h ../src_3rd/liblihata/lihata.h \ + ../src_3rd/liblihata/parser.h ../src_3rd/genht/htsp.h \ + ../src_3rd/genvector/vtp0.h list_conf.h data.h crosshair.h vtonpoint.h \ + route.h buffer.h obj_subc_list.h obj_subc.h \ + ../src_3rd/libminuid/libminuid.h rtree.h ht_subc.h vtpadstack.h \ + obj_pstk_shape.h polygon.h vtpadstack_t.h buffer.h safe_fs.h search.h \ + rats.h netlist.h route_style.h ../src_plugins/io_lihata/io_lihata.h \ + conf.h ../src_plugins/io_lihata/lht_conf.h \ + ../src_plugins/io_lihata/write.h ../src_plugins/io_lihata/read.h \ + dolists.h ../src_plugins/fontmode/fontmode.o: ../src_plugins/fontmode/fontmode.c \ ../config.h conf_core.h conf.h global_typedefs.h pcb_bool.h unit.h \ pcb-printf.h ../src_3rd/genvector/gds_char.h \ @@ -4968,9 +4995,9 @@ conf_core.h conf.h pcb-printf.h ../src_3rd/genvector/gds_char.h \ ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/dom.h \ ../src_3rd/liblihata/lihata.h ../src_3rd/liblihata/parser.h \ - ../src_3rd/genvector/vtp0.h list_conf.h error.h math_helper.h obj_poly.h \ - obj_poly_draw.h rotate.h ../src_plugins/shape/shape_dialog.c hid_dad.h \ - compat_misc.h hid_attrib.h dolists.h + ../src_3rd/genvector/vtp0.h list_conf.h error.h event.h math_helper.h \ + obj_poly.h obj_poly_draw.h rotate.h ../src_plugins/shape/shape_dialog.c \ + hid_dad.h compat_misc.h hid_attrib.h dolists.h ../src_plugins/smartdisperse/smartdisperse.o: \ ../src_plugins/smartdisperse/smartdisperse.c ../src_3rd/genht/htpi.h \ ../src_3rd/genht/ht.h ../config.h board.h const.h macro.h \ Index: trunk/src_plugins/extedit/Makefile =================================================================== --- trunk/src_plugins/extedit/Makefile (nonexistent) +++ trunk/src_plugins/extedit/Makefile (revision 13364) @@ -0,0 +1,5 @@ +all: + cd ../../src && $(MAKE) mod_extedit + +clean: + rm *.o *.so 2>/dev/null ; true Index: trunk/src_plugins/extedit/Plug.tmpasm =================================================================== --- trunk/src_plugins/extedit/Plug.tmpasm (nonexistent) +++ trunk/src_plugins/extedit/Plug.tmpasm (revision 13364) @@ -0,0 +1,10 @@ +put /local/pcb/mod {extedit} +put /local/pcb/mod/OBJS [@ + $(PLUGDIR)/extedit/extedit.o +@] + +switch /local/pcb/extedit/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/extedit/extedit.c =================================================================== --- trunk/src_plugins/extedit/extedit.c (nonexistent) +++ trunk/src_plugins/extedit/extedit.c (revision 13364) @@ -0,0 +1,184 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * Copyright (C) 2017 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. + * + */ + +#include "config.h" + +#include "hid.h" +#include "hid_attrib.h" +#include "hid_actions.h" +#include "hid_dad.h" +#include "action_helper.h" + +#include "board.h" +#include "compat_fs.h" +#include "const.h" +#include "conf_core.h" +#include "data.h" +#include "buffer.h" +#include "safe_fs.h" +#include "search.h" +#include "../src_plugins/io_lihata/io_lihata.h" +#include "../src_plugins/io_lihata/write.h" +#include "../src_plugins/io_lihata/read.h" + +typedef enum { + EEF_LIHATA +} extedit_fmt_t; + +typedef struct extedit_method_s { + char *name; + long types; + extedit_fmt_t fmt; + char *command; +} extedit_method_t; + +static extedit_method_t methods[] = { + {"pcb-rnd", PCB_TYPE_SUBC | PCB_TYPE_ELEMENT, EEF_LIHATA, "pcb-rnd %f"}, + {"text editor", PCB_TYPE_SUBC | PCB_TYPE_ELEMENT, EEF_LIHATA, "editor %f"}, + {NULL, 0, 0, NULL} +}; + +/* DAD-based interactive method editor */ +static extedit_method_t *extedit_interactive(void) +{ +#warning TODO + return NULL; +} + +static const char pcb_acts_extedit[] = "extedit(object|selected, [interactive|method])\n"; +static const char pcb_acth_extedit[] = "Invoke an external program to edit a specific part of the current board."; +static int pcb_act_extedit(int argc, const char **argv, pcb_coord_t x, pcb_coord_t y) +{ + long type; + void *ptr1, *ptr2, *ptr3; + extedit_method_t *mth = NULL; + char *tmp_fn; + int ret = 1; + FILE *f; + + /* pick up the object to edit */ + if ((argc == 0) || (pcb_strcasecmp(argv[0], "object") == 0)) { + pcb_gui->get_coords("Click on object to edit", &x, &y); + type = pcb_search_screen(x, y, 0xFFFFFFFF, &ptr1, &ptr2, &ptr3); + } + else if ((argc > 0) && (pcb_strcasecmp(argv[0], "selected") == 0)) { +#warning TODO + pcb_message(PCB_MSG_ERROR, "\"Selected\" not supported yet\n"); + return 1; + } + else { + pcb_message(PCB_MSG_ERROR, "Wrong 1st argument '%s'\n", argv[0]); + return 1; + } + + /* determine the method */ + if (argc > 1) { + for(mth = methods; mth->name != NULL; mth++) { + if (pcb_strcasecmp(mth->name, argv[1]) == 0) + break; + } + if (mth == NULL) { + pcb_message(PCB_MSG_ERROR, "unknown method '%s'; available methods:\n", argv[1]); + for(mth = methods; mth->name != NULL; mth++) + pcb_message(PCB_MSG_ERROR, "%s ", mth->name); + pcb_message(PCB_MSG_ERROR, "\n"); + return 1; + } + } + if (mth == NULL) { + mth = extedit_interactive(); + if (mth == NULL) /* no method selected */ + return 1; + } + + tmp_fn = pcb_tempfile_name_new("extedit"); + if (tmp_fn == NULL) { + pcb_message(PCB_MSG_ERROR, "Failed to create temporary file\n"); + return 1; + } + + /* export */ + switch(mth->fmt) { + case EEF_LIHATA: + { + int bn =PCB_MAX_BUFFER - 1; + + pcb_buffer_set_number(bn); + pcb_buffer_clear(PCB, PCB_PASTEBUFFER); + if (pcb_copy_obj_to_buffer(PCB, pcb_buffers[bn].Data, PCB->Data, type, ptr1, ptr2, ptr3) == NULL) { + pcb_message(PCB_MSG_ERROR, "Failed to copy target objects to temporary paste buffer\n"); + goto quit1; + } + + f = pcb_fopen(tmp_fn, "w"); + if (f == NULL) { + pcb_message(PCB_MSG_ERROR, "Failed to open temporary file\n"); + goto quit1; + } + + if (io_lihata_write_element(&plug_io_lihata_v4, f, pcb_buffers[bn].Data) != 0) { + fclose(f); + pcb_message(PCB_MSG_ERROR, "Failed to export target objects to lihata footprint.\n"); + goto quit1; + } + fclose(f); + printf("tmp=%s\n", tmp_fn); + } + break; + } + + /* invoke external program */ +#warning TODO + + /* load the result */ +#warning TODO + + quit1:; +/* pcb_tempfile_unlink(tmp_fn);*/ + return ret; +} + +static pcb_hid_action_t extedit_action_list[] = { + {"extedit", 0, pcb_act_extedit, + pcb_acts_extedit, pcb_acth_extedit} +}; + +static const char *extedit_cookie = "extedit plugin"; + +PCB_REGISTER_ACTIONS(extedit_action_list, extedit_cookie) + +int pplg_check_ver_extedit(int ver_needed) { return 0; } + +void pplg_uninit_extedit(void) +{ + pcb_hid_remove_actions_by_cookie(extedit_cookie); +} + +#include "dolists.h" +int pplg_init_extedit(void) +{ + PCB_REGISTER_ACTIONS(extedit_action_list, extedit_cookie) + return 0; +} Index: trunk/src_plugins/extedit/extedit.pup =================================================================== --- trunk/src_plugins/extedit/extedit.pup (nonexistent) +++ trunk/src_plugins/extedit/extedit.pup (revision 13364) @@ -0,0 +1,7 @@ +$class feature +$short edit with external program +$long invoke external program to edit parts of the current board +$state works +dep io_lihata +default buildin +autoload 1 Index: trunk/src_plugins/plugins_ALL.tmpasm =================================================================== --- trunk/src_plugins/plugins_ALL.tmpasm (revision 13363) +++ trunk/src_plugins/plugins_ALL.tmpasm (revision 13364) @@ -29,6 +29,7 @@ include {../src_plugins/export_svg/Plug.tmpasm} include {../src_plugins/export_test/Plug.tmpasm} include {../src_plugins/export_xy/Plug.tmpasm} +include {../src_plugins/extedit/Plug.tmpasm} include {../src_plugins/fontmode/Plug.tmpasm} include {../src_plugins/fp_board/Plug.tmpasm} include {../src_plugins/fp_fs/Plug.tmpasm}