Index: trunk/src_plugins/ar_extern/ar_extern.c =================================================================== --- trunk/src_plugins/ar_extern/ar_extern.c (revision 32362) +++ trunk/src_plugins/ar_extern/ar_extern.c (revision 32363) @@ -71,12 +71,11 @@ return NULL; } -static void extroute_gui(pcb_board_t *pcb) +static void extroute_query_conf(pcb_board_t *pcb) { const ext_router_t **r; - vts0_t methods = {0}; + vts0_t methods = {0}; - printf("GUI!\n"); for(r = routers; *r != NULL; r++) { int n; rnd_export_opt_t *table, *cfg; @@ -96,6 +95,9 @@ vts0_uninit(&methods); } +#include "dlg_extroute.c" + +/*** actions ***/ static const char pcb_acts_extroute[] = "extroute(board|selected, router, [confkey=value, ...])"; static const char pcb_acth_extroute[] = "Executed external autorouter to route the board or parts of the board"; fgw_error_t pcb_act_extroute(fgw_arg_t *res, int argc, fgw_arg_t *argv) Index: trunk/src_plugins/ar_extern/dlg_extroute.c =================================================================== --- trunk/src_plugins/ar_extern/dlg_extroute.c (nonexistent) +++ trunk/src_plugins/ar_extern/dlg_extroute.c (revision 32363) @@ -0,0 +1,76 @@ +/* + * COPYRIGHT + * + * pcb-rnd, interactive printed circuit board design + * + * auto routing with external router process: dialog box + * pcb-rnd Copyright (C) 2020 Tibor 'Igor2' Palinkas + * + * 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 + +typedef struct { + RND_DAD_DECL_NOINIT(dlg) + int active; /* already open - allow only one instance */ + int whatever; +} ar_ctx_t; + +static ar_ctx_t ar_ctx; + +static void ar_close_cb(void *caller_data, rnd_hid_attr_ev_t ev) +{ + ar_ctx_t *ctx = caller_data; + RND_DAD_FREE(ctx->dlg); + memset(ctx, 0, sizeof(ar_ctx_t)); /* reset all states to the initial - includes ctx->active = 0; */ +} + +static void extroute_gui(pcb_board_t *pcb) +{ + rnd_hid_dad_buttons_t clbtn[] = {{"Close", 0}, {NULL, 0}}; + + if (ar_ctx.active) + return; /* do not open another */ + + printf("GUI!\n"); + extroute_query_conf(pcb); + + RND_DAD_BEGIN_VBOX(ar_ctx.dlg); + RND_DAD_LABEL(ar_ctx.dlg, "woops\n"); + + + RND_DAD_BEGIN_HBOX(ar_ctx.dlg); + RND_DAD_BUTTON(ar_ctx.dlg, "Route"); + RND_DAD_BUTTON(ar_ctx.dlg, "Re-route"); + RND_DAD_BUTTON(ar_ctx.dlg, "Save conf"); + RND_DAD_BUTTON(ar_ctx.dlg, "Load conf"); + RND_DAD_BEGIN_VBOX(ar_ctx.dlg); + RND_DAD_COMPFLAG(ar_ctx.dlg, RND_HATF_EXPFILL); + RND_DAD_END(ar_ctx.dlg); + RND_DAD_BUTTON_CLOSES(ar_ctx.dlg, clbtn); + RND_DAD_END(ar_ctx.dlg); + RND_DAD_END(ar_ctx.dlg); + + /* set up the context */ + ar_ctx.active = 1; + + RND_DAD_NEW("external_autorouter", ar_ctx.dlg, "External autorouter", &ar_ctx, rnd_false, ar_close_cb); +}