📄 xmethods.c
字号:
(void) build_filename(scrat, "", foutput); if( !(fp = fopen(scrat,"w"))) { sprintf(notice_msg, "Can't open file %s to output global parameters.", scrat); show_notice(1, notice_msg); return(null); } } if(!strcmp("global",attr)) { /* GLOBAL ATTRIBUTES (.wave_pro) */ Selector *sp = &g1; char *cpp = (char*)malloc(MES_BUF_SIZE); int nstr = MES_BUF_SIZE; if(*aname) { char attname[MAXPATHLEN], *c = aname, *cp, *value_as_string(); while(*c) { sscanf(c,"%s",attname); if(strcmp(attname,"objects")) { cp = value_as_string(&g1,attname); } else { /* special case for "objects" */ cp = view_get_value(NULL, "objects"); } if(cp) fprintf(fp,"%s %s\n",attname,(*cp)? cp : "\"\""); c = get_next_item(c); } } else /* just print them all */ while(sp) { if(arg_to_string(&cpp, &nstr, sp)) fprintf(fp,"%s",cpp); sp = sp->next; } if(fp != stdout) fclose(fp); if(cpp) free(cpp); return(ok); } if (*file) (void) apply_waves_input_path(file, file); if((! *file) || (!(s = find_signal(o,file))) || !s->views || !s->views->canvas || (!strcmp(attr,"display") && xv_get(xv_get(s->views->canvas,XV_OWNER),FRAME_CLOSED))) { /* must try to guess file */ /* This is the simplest method of choosing which display to sync the external function to. It could stand considerable improvement. */ s = o->signals; while(s) { /* Just find the first signal with a view! */ if((v = s->views) && v->canvas && !xv_get(xv_get(v->canvas,XV_OWNER),FRAME_CLOSED)) break; s = s->others; } if(!s) { /* Maybe all views were closed. Try again. */ s = o->signals; while(s) { /* Just find the first signal with a view! */ if((v = s->views) && v->canvas) break; s = s->others; } } } if(s) v = s->views; else v = NULL; if(!strcmp("view",attr)) { /* Attributes of a signal view */ int used = 0; if(*aname) { char attname[MAXPATHLEN], *c = aname, *cp, *view_get_value(); while(*c) { sscanf(c,"%s",attname); if((cp = view_get_value(v,attname))) { if(*foutput) { fprintf(fp,"%s",cp); if(*cp && (cp[strlen(cp)-1] != '\n')) fprintf(fp,"\n"); } if( ! used ) block_build(&oblock,&used,&oblocksize,"returned "); else block_build(&oblock,&used,&oblocksize," "); /* space between items */ block_build(&oblock,&used,&oblocksize,(*cp)? cp : "\"\""); } else { sprintf(notice_msg, "Can't get value of variable named \"%s\".", attname); show_notice(1, notice_msg); } c = get_next_item(c); } } if(fp != stdout) fclose(fp); if(used) return(oblock); else return(null); } if(!(s && (v = s->views))) { fprintf(stderr,"Signal %s does not have a view in object %s\n",file,o->name); return(null); } if(!strcmp("display",attr) && *func) { /* DISPLAY ATTRIBUTES FOR ATTACHMENT */ *scrat = 0; augment_external_command(s,v,scrat); if(!id) sprintf(reply,"returned %s\n", scrat); else sprintf(reply,"%s completion %d %s\n",func,id,scrat); xwaves_ipc_send(func, reply); return(reply); } } return(null);}/***********************************************************************/send_kill_file(o,s) Object *o; Signal *s;{ char mess[200]; int itsok; if((!s) || (!o) || (!o->name)) return(FALSE); sprintf(mess,"%s kill file %s\n", o->name, s->name); xwaves_ipc_send("all",mess); return(TRUE);}/***********************************************************************/send_kill_object(o) Object *o;{ char mess[MES_BUF_SIZE]; if((!o) || (!o->name)) return(FALSE); sprintf(mess,"%s kill\n",o->name); xwaves_ipc_send("all",mess); return(TRUE);}/***********************************************************************/send_redisplay(s) Signal *s;{ char mess[1000]; Object *o; View *v; if(!s || !(o = (Object*)s->obj) || !o || !o->name) return(FALSE); sprintf(mess,"%s redisplay signal %s\n",o->name,s->name); xwaves_ipc_send("all",mess); return(TRUE);}#define ITIMER_NULL ((struct itimerval*)0)/*********************************************************************//* Start an interval timer to time a "sleep" in a waves command file. Return to the notifier for the duration of the sleep to permit completion of all plotting operations and allow interaction with other windows during the "sleep." */char * meth_sleep(ob, str)Object *ob;char *str;{ static double dur = 1.0; static Selector a1 = {"seconds", "%lf", (char*)&dur, NULL}; struct itimerval tim; extern int command_paused; extern Panel control_panel; extern Notify_value waves_timeout_proc(); dur = 1.0; CHECK_QUERY(str,&a1) get_args(str,&a1); if(dur < .2) dur = .2; /* Interrupts ("clock ticks") occur every .2 sec. */ command_paused = (((int)(dur*5.0)) & 0x1fff) | SLEEPING; tim.it_interval.tv_usec = 200000; tim.it_interval.tv_sec = 0; tim.it_value.tv_usec = 200000; tim.it_value.tv_sec = 0; /* Note that the Control Panel FRAME, rather than window, is specified as the "client." This prevents the window border blinker from clobbering my setting of the itimer (not sure why, but it works...). */ notify_set_itimer_func(daddy,waves_timeout_proc,ITIMER_REAL,&tim, ITIMER_NULL); ipc_callback_data = in_a_ipc_dispatch(); return(ok);}/*********************************************************************/check_ipc_response_pending(str)char *str;{ do_ipc_response_if_any(ipc_callback_data, str); ipc_callback_data = NULL;}/*********************************************************************//* This proc decrements the sleep counter every 200ms as the interval timer tics. */Notify_value waves_timeout_proc(item, which)Panel_item item;int which;{ extern Panel control_panel; extern Panel_item newControl_item; if(which == ITIMER_REAL) { if((command_paused & SLEEPING)) { int i = (command_paused ^ SLEEPING) - 1; if(i <= 0) { notify_set_itimer_func(daddy,waves_timeout_proc,ITIMER_REAL, ITIMER_NULL,ITIMER_NULL); check_ipc_response_pending(ok); command_proc(newControl_item, NULL); } else command_paused = i | SLEEPING; } } return(NOTIFY_DONE);}#undef ITIMER_NULL/*********************************************************************/char * meth_shell(ob, str)Object *ob;char *str;{ void meth_shell_done(); CHECK_QUERY(str,NULL) if(str && *str) { run_esps_prog(str,"","",0,0,meth_shell_done); command_paused = TRUE; } return(ok);}/*********************************************************************/void meth_shell_done(pid)int pid;{ extern FILE *fp_command; extern Panel_item newControl_item; if (w_verbose || debug_level) fprintf(stderr,"Shell command completed.\n"); if(*commandname && fp_command) command_proc(newControl_item, NULL);}/*********************************************************************/char * meth_mark(ob, str)Object *ob;char *str;{ static double time; static int color; static Selector a2 = {"time", "%lf", (char*)&time, NULL }, a1 = {"color", "%d", (char*)&color, &a2}; time = 0.0; color = MARKER_COLOR; CHECK_QUERY(str, &a1) if(get_args(str, &a1)) { object_enter_mark(ob, time, color); return(ok); } return(null);}/***********************************************************************/char *meth_unmark(o,str) Object *o; char *str;{ static double time; static int color; static char really[6]; static Selector a3 = {"all", "%s", really, NULL}, a2 = {"time", "%lf", (char*)&time, &a3}, a1 = {"color", "%d", (char*)&color, &a2}; Marks *ma; time = 0.0; color = MARKER_COLOR; *really = 'f'; CHECK_QUERY(str, &a1) if((ma = o->marks)) { if(get_args(str, &a1)) { if((*really == 't') || (*really == 'T')) { kill_all_marks(o); return(ok); } if(object_kill_mark(o, time, color)) return(ok); } } return(null);}/*********************************************************************/char * meth_redisplay(ob,str)Object *ob;char *str;{ return(ok);}/*********************************************************************/Object * make_new_object(str)char *str;{#ifndef SETUP_MESSAGE return(NULL);}#elsechar name[200], command[100];if (str && sscanf(str,"%s",name) == 1 && strlen(name)) { sprintf(command,"name %s",name); if(!strcmp(ok,meth_make_object(NULL,command))) { return((Object *)get_receiver(name)); }}return(NULL);}#endif/***********************************************************************//* This utility expands a filename as a command file. If a file * is found, the expanded name is substituted for the original name * and we attempt to open the file. Otherwise we just return null * without modifying the original name */static FILE *fopen_command_file(filename, type)char *filename, *type;{ char *fullname = NULL; fullname = FIND_WAVES_COMMAND(NULL, filename); if (fullname == NULL) { fprintf(stderr, "Couldn't find readable command file %s\n", filename); return(NULL); } strcpy(filename, fullname); return(fopen(filename, type)); } /***********************************************************************/char *meth_insert(o, str) Object *o; char *str;{ static char file[NAMELEN], source[NAMELEN]; static double time; static Selector s1 = {"file", "%s", file, NULL}, s2 = {"source", "%s", source, &s1}, s3b = {"output", "%s", outputname, &s2}, s3 = {"time", "%lf", (char*)&time, &s3b}; *file = *source = 0; time = -123.0; CHECK_QUERY(str, &s3) get_args(str, &s3); if(*file && *source && (time > -122.0)) { apply_waves_input_path(source,source); set_designated_source(source); (void)apply_waves_input_path(file,file); if(paste(find_signal(o,file),time)) return(ok); *source = 0; set_designated_source(source); } else { sprintf(notice_msg, "Bad arguments to meth_insert(%s).", str); show_notice(1, notice_msg); } return(null);}/***********************************************************************/char *meth_disconnect(o, str) Object *o; char *str;{ static char fname[NAMELEN]; static Selector a1 = {"function", "%s", fname, NULL}; CHECK_QUERY(str, &a1) if(get_args(str, &a1)) { destroy_function_client(fname); return(ok); } else show_notice(1, "Unspecified function name in meth_disconnect (ignored)."); return(null);}/***********************************************************************//* operations on Objects and signals */Methods meth19 = {"print_ensemble", meth_print_ensemble, NULL}, meth18 = {"print_graphic", meth_print_graphic, &meth19}, meth17 = {"play_wind", meth_play_window, &meth18}, meth16 = {"page", meth_page, &meth17}, meth15 = {"save", meth_save_seg, &meth16}, meth14 = {"bracket", meth_bracket_markers, &meth15}, meth13 = {"open", meth_open_frame, &meth14}, meth12 = {"close", meth_close_frame, &meth13}, meth11 = {"align", meth_align, &meth12}, meth10 = {"activate", meth_active_channels, &meth11}, meth9 = {"overlay", meth_overlay, &meth10}, meth8 = {"get", meth_get, &meth9}, meth7b = {"cursor", meth_move_cursors, &meth8}, meth7 = {"marker", meth_move_markers, &meth7b}, meth6 = {"colormap", meth_remap_colors, &meth7}, meth5a = {"insert", meth_insert, &meth6}, meth5 = {"spectrogram", meth_spectrogram, &meth5a}, meth4 = {"play", meth_play_seg, &meth5}, meth3b = {"stop_play", meth_stop_play, &meth4}, meth3 = {"set", meth_set_attr, &meth3b}, meth2b = {"op", meth_call_operator, &meth3}, meth2c = {"insert", meth_insert, &meth2b}, meth2 = {"mark", meth_mark, &meth2c}, public_view_methods = {"unmark", meth_unmark, &meth2}, meth1 = {"completion", meth_return, &public_view_methods };/* operations on the main program */Methods bmeth33 = {"get_attach_list", meth_get_attach_list, NULL}, bmeth32 = {"print_setup",meth_print_setup_cover,&bmeth33}, bmeth30 = {"auto_plot_limits", meth_auto_plotlims, &bmeth32}, bmeth29 = {"open_ctlwin", meth_open_ctlwin, &bmeth30}, bmeth28 = {"close_ctlwin", meth_close_ctlwin, &bmeth29}, bmeth27 = {"disable_server", meth_disable_server, &bmeth28}, bmeth26b = {"enable_server", meth_enable_server, &bmeth27}, bmeth25 = {"add_waves", meth_add_waves, &bmeth26b}, bmeth24b = {"add_op_panel", meth_make_add_op_panel, &bmeth25}, bmeth24 = {"make_panel", meth_make_panel, &bmeth24b}, bmeth23 = {"open_panel", meth_open_panel, &bmeth24}, bmeth22 = {"close_panel", meth_close_panel, &bmeth23}, bmeth21 = {"kill_panel", meth_kill_panel, &bmeth22}, bmeth20b = {"delete_all_items", meth_delete_all, &bmeth21}, bmeth20 = {"delete_item", meth_delete_item, &bmeth20b}, bmeth19 = {"add_espsn", meth_add_espsn, &bmeth20}, bmeth18 = {"add_espst", meth_add_espst, &bmeth19}, bmeth17c = {"add_op", meth_add_operator, &bmeth18}, bmeth17b = {"add_espsf", meth_add_espsf, &bmeth17c}, bmeth17 = {"cd", meth_chdir, &bmeth17b}, bmeth13b = {"setenv", meth_setenv, &bmeth17}, bmeth13 = {"shell", meth_shell, &bmeth13b}, bmeth12g = {"save_panels", meth_save_panels, &bmeth13}, bmeth12f = {"save_menus", meth_save_menus, &bmeth12g}, bmeth12e = {"save_add_ops", meth_dump_add_ops, &bmeth12f}, bmeth12d = {"save_keymaps", meth_dump_keymaps, &bmeth12e}, bmeth12c = {"key_map", meth_add_keymap, &bmeth12d}, bmeth12b = {"key_unmap", meth_delete_keymap, &bmeth12c}, bmeth12 = {"set", meth_set_attr, &bmeth12b}, bmeth11 = {"detach", meth_detach, &bmeth12}, bmeth10 = {"attach", meth_attach, &bmeth11}, bmeth9 = {"send", meth_send, &bmeth10}, bmeth8b ={"get", meth_get, &bmeth9}, bmeth7 = {"kill", meth_kill, &bmeth8b}, bmeth5 = {"make", meth_make_object, &bmeth7}, bmeth4 = {"quit", meth_quit, &bmeth5}, bmeth8 = {"pause", meth_pause, &bmeth4}, bmeth16 = {"call", meth_call_script, &bmeth8}, bmeth15 = {"return", meth_return_from_script, &bmeth16},
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -