diff --git a/src/mged/attach.c b/src/mged/attach.c index d242be124d..7e71edcbfb 100644 --- a/src/mged/attach.c +++ b/src/mged/attach.c @@ -108,8 +108,8 @@ mged_dm_init( #ifdef HAVE_TK if (dm_graphical(DMP) && !BU_STR_EQUAL(dm_get_dm_name(DMP), "swrast")) { - Tk_DeleteGenericHandler(doEvent, (ClientData)NULL); - Tk_CreateGenericHandler(doEvent, (ClientData)NULL); + Tk_DeleteGenericHandler(doEvent, (ClientData)s); + Tk_CreateGenericHandler(doEvent, (ClientData)s); } #endif (void)dm_configure_win(DMP, 0); @@ -200,7 +200,7 @@ release(struct mged_state *s, char *name, int need_close) if (mged_variables->mv_listen) { /* drop all clients */ mged_variables->mv_listen = 0; - fbserv_set_port(s, NULL, NULL, NULL, NULL, NULL); + fbserv_set_port(NULL, NULL, NULL, NULL, s); } /* release framebuffer resources */ @@ -328,7 +328,7 @@ f_attach(ClientData clientData, Tcl_Interp *interpreter, int argc, const char *a int -gui_setup(const char *dstr) +gui_setup(struct mged_state *s, const char *dstr) { #ifdef HAVE_TK Tk_GenericProc *handler = doEvent; @@ -393,7 +393,7 @@ gui_setup(const char *dstr) } /* create the event handler */ - Tk_CreateGenericHandler(handler, (ClientData)NULL); + Tk_CreateGenericHandler(handler, (ClientData)s); Tcl_Eval(INTERP, "wm withdraw ."); Tcl_Eval(INTERP, "tk appname mged"); @@ -436,14 +436,14 @@ mged_attach(struct mged_state *s, const char *wp_name, int argc, const char *arg struct bu_vls *dname = dm_get_dname(tmp_dmp); if (dname && bu_vls_strlen(dname)) { - if (gui_setup(bu_vls_cstr(dname)) == TCL_ERROR) { + if (gui_setup(s, bu_vls_cstr(dname)) == TCL_ERROR) { bu_free((void *)mged_curr_dm, "f_attach: dm_list"); set_curr_dm(s, o_dm); bu_vls_free(&tmp_vls); dm_close(tmp_dmp); return TCL_ERROR; } - } else if (gui_setup((char *)NULL) == TCL_ERROR) { + } else if (gui_setup(s, (char *)NULL) == TCL_ERROR) { bu_free((void *)mged_curr_dm, "f_attach: dm_list"); set_curr_dm(s, o_dm); bu_vls_free(&tmp_vls); diff --git a/src/mged/buttons.c b/src/mged/buttons.c index 74e61157e2..12c7ce98e5 100644 --- a/src/mged/buttons.c +++ b/src/mged/buttons.c @@ -361,8 +361,12 @@ bv_zoomout(ClientData UNUSED(clientData), Tcl_Interp *UNUSED(interp), int UNUSED int -bv_rate_toggle(ClientData UNUSED(clientData), Tcl_Interp *UNUSED(interp), int UNUSED(argc), char *UNUSED(argv[])) +bv_rate_toggle(ClientData clientData, Tcl_Interp *UNUSED(interp), int UNUSED(argc), char *UNUSED(argv[])) { + struct cmdtab *ctp = (struct cmdtab *)clientData; + MGED_CK_CMD(ctp); + struct mged_state *s = ctp->s; + mged_variables->mv_rateknobs = !mged_variables->mv_rateknobs; { @@ -371,7 +375,7 @@ bv_rate_toggle(ClientData UNUSED(clientData), Tcl_Interp *UNUSED(interp), int UN const char name[] = "name"; void *base = 0; const char value[] = "value"; - set_scroll_private(sdp, name, base, value, NULL); + set_scroll_private(sdp, name, base, value, s); } return TCL_OK; diff --git a/src/mged/cmd.c b/src/mged/cmd.c index 3420723f1e..e1a7f2d016 100644 --- a/src/mged/cmd.c +++ b/src/mged/cmd.c @@ -856,8 +856,12 @@ cmd_ged_dm_wrapper(ClientData clientData, Tcl_Interp *interpreter, int argc, con * Usage: loadtk [displayname[.screennum]] */ int -cmd_tk(ClientData UNUSED(clientData), Tcl_Interp *interpreter, int argc, const char *argv[]) +cmd_tk(ClientData clientData, Tcl_Interp *interpreter, int argc, const char *argv[]) { + struct cmdtab *ctp = (struct cmdtab *)clientData; + MGED_CK_CMD(ctp); + struct mged_state *s = ctp->s; + int status; if (argc < 1 || 2 < argc) { @@ -870,9 +874,9 @@ cmd_tk(ClientData UNUSED(clientData), Tcl_Interp *interpreter, int argc, const c } if (argc == 1) - status = gui_setup((char *)NULL); + status = gui_setup(s, (char *)NULL); else - status = gui_setup(argv[1]); + status = gui_setup(s, argv[1]); return status; } diff --git a/src/mged/color_scheme.c b/src/mged/color_scheme.c index 6a90dc2f65..771c866215 100644 --- a/src/mged/color_scheme.c +++ b/src/mged/color_scheme.c @@ -260,8 +260,6 @@ cs_update(const struct bu_structparse *sdp, const char *value, void *data) { - struct cmdtab *ctp = (struct cmdtab *)data; - MGED_CK_CMD(ctp); struct bu_structparse *sp; struct bu_vls vls = BU_VLS_INIT_ZERO; int offset; diff --git a/src/mged/doevent.c b/src/mged/doevent.c index a52cb90b3d..f7e8ba93a0 100644 --- a/src/mged/doevent.c +++ b/src/mged/doevent.c @@ -115,9 +115,7 @@ static int button0 = 0; int doEvent(ClientData clientData, XEvent *eventPtr) { - struct cmdtab *ctp = (struct cmdtab *)clientData; - MGED_CK_CMD(ctp); - struct mged_state *s = ctp->s; + struct mged_state *s = (struct mged_state *)clientData; struct mged_dm *save_dm_list; int status; diff --git a/src/mged/fbserv.c b/src/mged/fbserv.c index 131b3cb6be..fe4b8ba36c 100644 --- a/src/mged/fbserv.c +++ b/src/mged/fbserv.c @@ -253,7 +253,7 @@ fbserv_new_client_handler(ClientData clientData, void -fbserv_set_port(const struct bu_structparse *UNUSED(sp), const char *UNUSED(c1), void *UNUSED(v1), const char *UNUSED(c2), void *UNUSED(v2)) +fbserv_set_port(const struct bu_structparse *UNUSED(sp), const char *UNUSED(c1), void *UNUSED(v1), const char *UNUSED(c2), void *v2) { int i; int save_port; @@ -440,7 +440,7 @@ fbserv_new_client_handler(ClientData clientData, int UNUSED(mask)) void -fbserv_set_port(struct mged_state *s, const struct bu_structparse *UNUSED(sp), const char *UNUSED(c1), void *UNUSED(v1), const char *UNUSED(c2), void *UNUSED(v2)) +fbserv_set_port(const struct bu_structparse *UNUSED(sp), const char *UNUSED(c1), void *UNUSED(v1), const char *UNUSED(c2), void *v2) { int i; int save_port; @@ -499,7 +499,7 @@ fbserv_set_port(struct mged_state *s, const struct bu_structparse *UNUSED(sp), c struct c_data *ncdata; BU_GET(ncdata, struct c_data); ncdata->fd = netfd; - ncdata->s = s; + ncdata->s = (struct mged_state *)v2; Tcl_CreateFileHandler(netfd, TCL_READABLE, fbserv_new_client_handler, (ClientData)ncdata); } diff --git a/src/mged/grid.c b/src/mged/grid.c index 52be577336..3b817b56fc 100644 --- a/src/mged/grid.c +++ b/src/mged/grid.c @@ -449,8 +449,12 @@ update_grids(fastf_t sf) int -f_grid_set (ClientData UNUSED(clientData), Tcl_Interp *interpreter, int argc, const char *argv[]) +f_grid_set (ClientData clientData, Tcl_Interp *interpreter, int argc, const char *argv[]) { + struct cmdtab *ctp = (struct cmdtab *)clientData; + MGED_CK_CMD(ctp); + struct mged_state *s = ctp->s; + struct bu_vls vls = BU_VLS_INIT_ZERO; if (argc < 1 || 5 < argc) { @@ -461,7 +465,7 @@ f_grid_set (ClientData UNUSED(clientData), Tcl_Interp *interpreter, int argc, co return TCL_ERROR; } - mged_vls_struct_parse(&vls, "Grid", grid_vparse, + mged_vls_struct_parse(s, &vls, "Grid", grid_vparse, (char *)grid_state, argc, argv); Tcl_AppendResult(interpreter, bu_vls_addr(&vls), (char *)NULL); bu_vls_free(&vls); diff --git a/src/mged/mged.h b/src/mged/mged.h index 040f500bc1..292424ddc0 100644 --- a/src/mged/mged.h +++ b/src/mged/mged.h @@ -466,7 +466,7 @@ int is_dm_null(void); int mged_attach(struct mged_state *s, const char *wp_name, int argc, const char *argv[]); void mged_link_vars(struct mged_dm *p); void mged_slider_free_vls(struct mged_dm *p); -int gui_setup(const char *dstr); +int gui_setup(struct mged_state *s, const char *dstr); /* buttons.c */ @@ -664,7 +664,7 @@ int epain(struct rt_db_internal *ip, fastf_t thick[2]); int etoin(struct rt_db_internal *ip, fastf_t thick[1]); /* set.c */ -extern void fbserv_set_port(struct mged_state *s, const struct bu_structparse *, const char *, void *, const char *, void *); +extern void fbserv_set_port(const struct bu_structparse *, const char *, void *, const char *, void *); extern void set_scroll_private(const struct bu_structparse *, const char *, void *, const char *, void *); extern void mged_variable_setup(Tcl_Interp *interpreter); @@ -687,8 +687,8 @@ struct wdb_pipe_pnt *pipe_del_pnt(struct wdb_pipe_pnt *); void pipe_move_pnt(struct rt_pipe_internal *, struct wdb_pipe_pnt *, const point_t); /* vparse.c */ -extern void mged_vls_struct_parse(struct bu_vls *vls, const char *title, struct bu_structparse *how_to_parse, const char *structp, int argc, const char *argv[]); /* defined in vparse.c */ -extern void mged_vls_struct_parse_old(struct bu_vls *vls, const char *title, struct bu_structparse *how_to_parse, char *structp, int argc, const char *argv[]); +extern void mged_vls_struct_parse(struct mged_state *s, struct bu_vls *vls, const char *title, struct bu_structparse *how_to_parse, const char *structp, int argc, const char *argv[]); /* defined in vparse.c */ +extern void mged_vls_struct_parse_old(struct mged_state *s, struct bu_vls *vls, const char *title, struct bu_structparse *how_to_parse, char *structp, int argc, const char *argv[]); /* rtif.c */ int build_tops(char **start, char **end); diff --git a/src/mged/scroll.c b/src/mged/scroll.c index e0f9e8ad0c..83c234cc81 100644 --- a/src/mged/scroll.c +++ b/src/mged/scroll.c @@ -131,7 +131,7 @@ sl_halt_scroll(int UNUSED(a), int UNUSED(b), int UNUSED(c)) void -sl_toggle_scroll(int UNUSED(a), int UNUSED(b), int UNUSED(c)) +sl_toggle_scroll(struct mged_state *s, int UNUSED(a), int UNUSED(b), int UNUSED(c)) { mged_variables->mv_sliders = mged_variables->mv_sliders ? 0 : 1; @@ -141,7 +141,7 @@ sl_toggle_scroll(int UNUSED(a), int UNUSED(b), int UNUSED(c)) const char name[] = "name"; void *base = 0; const char value[] = "value"; - set_scroll_private(sdp, name, base, value, NULL); + set_scroll_private(sdp, name, base, value, s); } } diff --git a/src/mged/set.c b/src/mged/set.c index ec6331a666..af17912cb1 100644 --- a/src/mged/set.c +++ b/src/mged/set.c @@ -281,8 +281,12 @@ mged_variable_setup(Tcl_Interp *interp) int -f_set(ClientData UNUSED(clientData), Tcl_Interp *interp, int argc, const char *argv[]) +f_set(ClientData clientData, Tcl_Interp *interp, int argc, const char *argv[]) { + struct cmdtab *ctp = (struct cmdtab *)clientData; + MGED_CK_CMD(ctp); + struct mged_state *s = ctp->s; + struct bu_vls vls = BU_VLS_INIT_ZERO; if (argc < 1 || 2 < argc) { @@ -293,7 +297,7 @@ f_set(ClientData UNUSED(clientData), Tcl_Interp *interp, int argc, const char *a return TCL_ERROR; } - mged_vls_struct_parse_old(&vls, "mged variables", mged_vparse, + mged_vls_struct_parse_old(s, &vls, "mged variables", mged_vparse, (char *)mged_variables, argc, argv); Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL); bu_vls_free(&vls); @@ -307,8 +311,9 @@ set_scroll_private(const struct bu_structparse *UNUSED(sdp), const char *UNUSED(name), void *UNUSED(base), const char *UNUSED(value), - void *UNUSED(data)) + void *data) { + struct mged_state *s = (struct mged_state *)data; struct mged_dm *save_m_dmp; save_m_dmp = mged_curr_dm; @@ -316,7 +321,7 @@ set_scroll_private(const struct bu_structparse *UNUSED(sdp), for (size_t di = 0; di < BU_PTBL_LEN(&active_dm_set); di++) { struct mged_dm *m_dmp = (struct mged_dm *)BU_PTBL_GET(&active_dm_set, di); if (m_dmp->dm_mged_variables == save_m_dmp->dm_mged_variables) { - set_curr_dm(m_dmp); + set_curr_dm(s, m_dmp); if (mged_variables->mv_faceplate && mged_variables->mv_orig_gui) { if (mged_variables->mv_sliders) /* zero slider variables */ @@ -329,7 +334,7 @@ set_scroll_private(const struct bu_structparse *UNUSED(sdp), } } - set_curr_dm(save_m_dmp); + set_curr_dm(s, save_m_dmp); } @@ -374,8 +379,9 @@ set_dlist(const struct bu_structparse *UNUSED(sdp), const char *UNUSED(name), void *UNUSED(base), const char *UNUSED(value), - void *UNUSED(data)) + void *data) { + struct mged_state *s = (struct mged_state *)data; struct mged_dm *save_dlp; /* save current display manager */ @@ -395,8 +401,8 @@ set_dlist(const struct bu_structparse *UNUSED(sdp), if (dm_get_displaylist(dlp1->dm_dmp) && dlp1->dm_dlist_state->dl_active == 0) { - set_curr_dm(dlp1); - createDLists(GEDP->ged_gdp->gd_headDisplay); + set_curr_dm(s, dlp1); + createDLists(s->GEDP->ged_gdp->gd_headDisplay); dlp1->dm_dlist_state->dl_active = 1; dlp1->dm_dirty = 1; dm_set_dirty(dlp1->dm_dmp, 1); @@ -439,8 +445,8 @@ set_dlist(const struct bu_structparse *UNUSED(sdp), dlp1->dm_dlist_state->dl_active = 0; - gdlp = BU_LIST_NEXT(display_list, GEDP->ged_gdp->gd_headDisplay); - while (BU_LIST_NOT_HEAD(gdlp, GEDP->ged_gdp->gd_headDisplay)) { + gdlp = BU_LIST_NEXT(display_list, s->GEDP->ged_gdp->gd_headDisplay); + while (BU_LIST_NOT_HEAD(gdlp, s->GEDP->ged_gdp->gd_headDisplay)) { next_gdlp = BU_LIST_PNEXT(display_list, gdlp); (void)dm_make_current(dlp1->dm_dmp); @@ -457,7 +463,7 @@ set_dlist(const struct bu_structparse *UNUSED(sdp), } /* restore current display manager */ - set_curr_dm(save_dlp); + set_curr_dm(s, save_dlp); } diff --git a/src/mged/setup.c b/src/mged/setup.c index fe82f0a15e..4a2632550d 100644 --- a/src/mged/setup.c +++ b/src/mged/setup.c @@ -533,7 +533,7 @@ mged_setup(Tcl_Interp **interpreter) history_setup(); mged_global_variable_setup(*interpreter); - mged_variable_setup(s, *interpreter); + mged_variable_setup(*interpreter); s->GEDP->cmd_interp = (void *)*interpreter; /* Tcl needs to write nulls onto subscripted variable names */ diff --git a/src/mged/share.c b/src/mged/share.c index ebf1826594..55a4878d4f 100644 --- a/src/mged/share.c +++ b/src/mged/share.c @@ -283,25 +283,29 @@ f_share(ClientData clientData, Tcl_Interp *interpreter, int argc, const char *ar * rset c bg 0 0 50 ---> sets the background color to dark blue */ int -f_rset (ClientData UNUSED(clientData), Tcl_Interp *interpreter, int argc, const char *argv[]) +f_rset (ClientData clientData, Tcl_Interp *interpreter, int argc, const char *argv[]) { + struct cmdtab *ctp = (struct cmdtab *)clientData; + MGED_CK_CMD(ctp); + struct mged_state *s = ctp->s; + struct bu_vls vls = BU_VLS_INIT_ZERO; /* print values for all resources */ if (argc == 1) { - mged_vls_struct_parse(&vls, "Axes, res_type - ax", axes_vparse, + mged_vls_struct_parse(s, &vls, "Axes, res_type - ax", axes_vparse, (const char *)axes_state, argc, argv); bu_vls_printf(&vls, "\n"); - mged_vls_struct_parse(&vls, "Color Schemes, res_type - c", color_scheme_vparse, + mged_vls_struct_parse(s, &vls, "Color Schemes, res_type - c", color_scheme_vparse, (const char *)color_scheme, argc, argv); bu_vls_printf(&vls, "\n"); - mged_vls_struct_parse(&vls, "Grid, res_type - g", grid_vparse, + mged_vls_struct_parse(s, &vls, "Grid, res_type - g", grid_vparse, (const char *)grid_state, argc, argv); bu_vls_printf(&vls, "\n"); - mged_vls_struct_parse(&vls, "Rubber Band, res_type - r", rubber_band_vparse, + mged_vls_struct_parse(s, &vls, "Rubber Band, res_type - r", rubber_band_vparse, (const char *)rubber_band, argc, argv); bu_vls_printf(&vls, "\n"); - mged_vls_struct_parse(&vls, "MGED Variables, res_type - var", mged_vparse, + mged_vls_struct_parse(s, &vls, "MGED Variables, res_type - var", mged_vparse, (const char *)mged_variables, argc, argv); Tcl_AppendResult(interpreter, bu_vls_addr(&vls), (char *)NULL); @@ -316,7 +320,7 @@ f_rset (ClientData UNUSED(clientData), Tcl_Interp *interpreter, int argc, const if (argv[1][1] == 'd' || argv[1][1] == 'D') bu_vls_printf(&vls, "rset: use the adc command for the 'adc' resource"); else if (argv[1][1] == 'x' || argv[1][1] == 'X') - mged_vls_struct_parse(&vls, "Axes", axes_vparse, + mged_vls_struct_parse(s, &vls, "Axes", axes_vparse, (const char *)axes_state, argc-1, argv+1); else { bu_vls_printf(&vls, "rset: resource type '%s' unknown\n", argv[1]); @@ -328,24 +332,24 @@ f_rset (ClientData UNUSED(clientData), Tcl_Interp *interpreter, int argc, const break; case 'c': case 'C': - mged_vls_struct_parse(&vls, "Color Schemes", color_scheme_vparse, + mged_vls_struct_parse(s, &vls, "Color Schemes", color_scheme_vparse, (const char *)color_scheme, argc-1, argv+1); break; case 'g': case 'G': - mged_vls_struct_parse(&vls, "Grid", grid_vparse, + mged_vls_struct_parse(s, &vls, "Grid", grid_vparse, (const char *)grid_state, argc-1, argv+1); break; case 'r': case 'R': - mged_vls_struct_parse(&vls, "Rubber Band", rubber_band_vparse, + mged_vls_struct_parse(s, &vls, "Rubber Band", rubber_band_vparse, (const char *)rubber_band, argc-1, argv+1); break; case 'v': case 'V': if ((argv[1][1] == 'a' || argv[1][1] == 'A') && (argv[1][2] == 'r' || argv[1][2] == 'R')) - mged_vls_struct_parse(&vls, "mged variables", mged_vparse, + mged_vls_struct_parse(s, &vls, "mged variables", mged_vparse, (const char *)mged_variables, argc-1, argv+1); else if (argv[1][1] == 'i' || argv[1][1] == 'I') bu_vls_printf(&vls, "rset: no support available for the 'view' resource"); diff --git a/src/mged/vparse.c b/src/mged/vparse.c index 201d13d922..54f6391ead 100644 --- a/src/mged/vparse.c +++ b/src/mged/vparse.c @@ -32,12 +32,14 @@ void -mged_vls_struct_parse(struct bu_vls *vls, - const char *title, - struct bu_structparse *how_to_parse, - const char *structp, - int argc, - const char *argv[]) +mged_vls_struct_parse( + struct mged_state *s, + struct bu_vls *vls, + const char *title, + struct bu_structparse *how_to_parse, + const char *structp, + int argc, + const char *argv[]) { if (argc < 2) { /* Bare set command, print out current settings */ @@ -50,7 +52,7 @@ mged_vls_struct_parse(struct bu_vls *vls, bu_vls_printf(&tmp_vls, "%s=\"", argv[1]); bu_vls_from_argv(&tmp_vls, argc-2, (const char **)argv+2); bu_vls_putc(&tmp_vls, '\"'); - if (bu_struct_parse(&tmp_vls, how_to_parse, structp, NULL) < 0) bu_log("Warning - bu_struct_parse failure, mged_vls_struct_parse.\n"); + if (bu_struct_parse(&tmp_vls, how_to_parse, structp, s) < 0) bu_log("Warning - bu_struct_parse failure, mged_vls_struct_parse.\n"); bu_vls_free(&tmp_vls); } } @@ -58,6 +60,7 @@ mged_vls_struct_parse(struct bu_vls *vls, void mged_vls_struct_parse_old( + struct mged_state *s, struct bu_vls *vls, const char *title, struct bu_structparse *how_to_parse, @@ -72,7 +75,7 @@ mged_vls_struct_parse_old( struct bu_vls tmp_vls = BU_VLS_INIT_ZERO; bu_vls_strcpy(&tmp_vls, argv[1]); - if (bu_struct_parse(&tmp_vls, how_to_parse, structp, NULL) < 0) bu_log("Warning - bu_struct_parse failure, mged_vls_struct_parse_old.\n"); + if (bu_struct_parse(&tmp_vls, how_to_parse, structp, s) < 0) bu_log("Warning - bu_struct_parse failure, mged_vls_struct_parse_old.\n"); bu_vls_free(&tmp_vls); } }