⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xlabel.c

📁 speech signal process tools
💻 C
📖 第 1 页 / 共 5 页
字号:
}static void repaint(canvas, pw, repaint_area)     Canvas canvas;     Pixwin *pw;     Rectlist *repaint_area;{  Objects *ob = (Objects*)xv_get(canvas, WIN_CLIENT_DATA);    if(ob && ob_exists(ob)) {    Labelfile *lf = ob->labels;    redo_display(ob);    if(lf && (ob->resize_status & RESIZE_STATUS_RESIZE) &&       !(ob->resize_status & RESIZE_STATUS_FORCED_RESIZE)) {      wind_height = lf->height;    }    ob->resize_status = RESIZE_STATUS_RESET;  }  return;}/*********************************************************************/static voidresize(canvas, width, height)     Canvas canvas;     int width, height;{  Objects *ob;  if(canvas && (ob = (Objects *)xv_get(canvas, WIN_CLIENT_DATA)))    ob->resize_status |= RESIZE_STATUS_RESIZE;}/*********************************************************************/char *meth_new_labelmenu(ob,str)     Objects *ob;     char *str;{  static Selector a1 = {"menufile", "%s", menufile, NULL};    if(get_args(str,&a1)) {        xv_set(menu_item, PANEL_VALUE, menufile, 0);    newFile(menu_item,NULL);    return(Ok);  }  return(Null);}/*********************************************************************/char *meth_set_active_fields(ob,str)     Objects *ob;     char *str;{  static Selector a1 = {"file", "%s", inputname, NULL},  a2 = {"name", "%s", objectname, &a1},  a3 = {"fields", "#strq", active, &a2};  Labelfile *lf;    if(ob_exists(ob) && get_args(str,&a3)) {        xv_set(active_item, PANEL_VALUE, active, 0);    if(ob == program)      if(!(ob = (Objects*)get_receiver(objectname))) return(Null);    if(*inputname)      set_active_fields(ob->name,inputname,active);    else      if((lf = ob->labels))	while(lf) {	  set_active_fields(ob->name,lf->label_name,active);	  lf = lf->next;	}    return(Ok);  }  return(Null);}/***********************************************************************/char *meth_return(ob,str)     Objects *ob;     char *str;{  if(str && *str) {    int id;    char *get_next_item();    sscanf(str,"%d",&id);    do_return_callback(id,get_next_item(str));    return(Ok);  }  return(Null);}/*********************************************************************/char *meth_save_globals(ob,str)     Objects *ob;     char *str;{  static char name[NAMELEN];  static Selector s1 = {"output", "%s", name, NULL};  *name = 0;  get_args(str, &s1);  if(dump_local_variables(name, &gg4))    return(Ok);  else    return(Null);}	       /*********************************************************************//*********************************************************************/Methods  meth7 = {"print_EPS_temp", meth_print_EPS_temp, NULL},meth6 = {"print", meth_print, &meth7},meth5 = {"kill", meth_kill, &meth6},meth4 = {"activate", meth_set_active_fields, &meth5},meth3 = {"redisplay", meth_redisplay,&meth4},meth2 = { "mark", meth_mark, &meth3},meth1 = { "quit", meth_quit, &meth2};Methods   bm9 = {"print", meth_print, NULL},bm8 = {"completion", meth_return, &bm9},bm7 = {"unload", meth_unload, &bm8},bm6 = {"labelmenu", meth_new_labelmenu, &bm7},bm5 = {"kill", meth_kill, &bm6},bm4b = {"save_globals", meth_save_globals, &bm5},bm4 = {"activate",meth_set_active_fields, &bm4b},bm3 = {"labelfile", meth_make_object, &bm4},bm2 = {"quit", meth_quit, &bm3},bm1 = {"set", meth_set, &bm2},base_methods = {"make", meth_make_object, &bm1};/*********************************************************************/Notify_value kill_signal_view(client, status)     Canvas client;     Destroy_status status;{  Objects *o;  Canvas    canvas = xv_get(client, CANVAS_PAINT_CANVAS_WINDOW);    DEBUG(1)(stderr,"kill_signal_view()\n");  if(status == DESTROY_CLEANUP) {    DEBUG(1)(stderr,"DESTROY_CLEANUP\n");    if((o = (Objects*)xv_get(client, WIN_CLIENT_DATA))) {      DEBUG(1)(stderr,"Killing object %s\n",o->name);      kill_object(o,1);    }    DEBUG(1)(stderr,"setting client data null\n");    xv_set(client, WIN_CLIENT_DATA, NULL, 0);    if(canvas)      xv_set(canvas, WIN_CLIENT_DATA, NULL, 0);  }  DEBUG(1)(stderr,"Leaving kill_signal_view()\n");  return(notify_next_destroy_func(client, status));}/*********************************************************************/Objects *make_new_object(str)     char *str;{  char name[NAMELEN], command[MES_BUF_SIZE];    sscanf(str,"%s",name);  if(debug_level)    fprintf(stderr,"make_new_object(%s)\n",str);  if(strlen(name)) {    sprintf(command,"name %s",name);    if(!strcmp(Ok,meth_make_object(NULL,command))) {      return((Objects *)get_receiver(name));    }  }  return(NULL);}/*********************************************************************/Objects *new_objects(name)     char *name;{  Objects *ob;  char *c;    if((ob = (Objects*)malloc(sizeof(Objects))) &&     (c = malloc(MAXPATHLEN))) {       strcpy(c,name);       ob->name = c;       ob->signal_name = NULL;       ob->methods = &meth1;       ob->cursor = -1.0;       ob->oldcursor_x = ob->oldcursor_y = -1;       ob->sec_cm = .05;       ob->start = 0.0;       ob->xloc = 10;       ob->yloc = 5000;       ob->width = 1000;       ob->height = 200;       ob->x_off = 0;       ob->resize_status = RESIZE_STATUS_NEW;       ob->labels = NULL;       ob->next = NULL;       ob->canvas = XV_NULL;       return(ob);     }  fprintf(stderr,"Can't allocate space for another object\n");  return(NULL);}/*********************************************************************/kill_proc(){  char mess[MES_BUF_SIZE];    sprintf(mess,"%s disconnect function %s\n",host,thisprog);  terminal_message( mess );  terminate_communication(registry_name);  exit(0);}/*************************************************************************/Objects *obj_exists(input)     char *input;{  Objects *ob;  if(!*objectname || (!(ob = (Objects*)get_receiver(objectname)) &&		      !(ob = (Objects*)make_new_object(objectname)))) {    sprintf(notice_msg,"Object %s doesn't exist (can't add file %s)\n",	   objectname,input);    show_notice(0,notice_msg);    return(NULL);  }  return(ob);}/*************************************************************************/void newFile(item, event)     Panel_item item;     Event *event;{  Objects *ob;  Labelfile *lf;    if(item == file_item) {    strcpy(inputname,(char*)panel_get_value(item));    build_label_outout_name(inputname);    if(*inputname && (ob = obj_exists(inputname))) {      if((lf = read_labels(ob,inputname))) {	set_display_size(ob);        set_active_fields(ob->name,lf->label_name,active);	send_all_marks(lf);	make_labels_menu(lf);      }      set_active_fields(objectname,inputname,active);    }  }  if(item == top_word_item) {    strcpy(topword,(char*)panel_get_value(item));    if(*chartname && (ob = obj_exists(chartname))) {      Chartfile *cf;      Wobject *wob;      if((cf = get_chartfile(get_wobject(ob),chartname))) {	top_word(topword,cf);	return;      }    }  }      if(item == chart_item) {    strcpy(chartname,(char*)panel_get_value(item));    if(*chartname && (ob = obj_exists(chartname))) {      Chartfile *cf;      Wobject *wob;      if(!(wob = get_wobject(ob)) && !(wob = new_wobject(ob))) {	fprintf(stderr,"Problems creating new chart object\n");	return;      }      if((cf = read_charts(wob,chartname))) {	set_display_size(ob);	redo_display(ob);      }    }  }    if(item == object_item) {    strcpy(objectname,(char*)panel_get_value(item));    if(!(ob = (Objects*)get_receiver(objectname)) &&       !(ob = (Objects*)make_new_object(objectname))){      sprintf(notice_msg,"Object %s doesn't exist.\n",objectname);       show_notice(0,notice_msg);    }    else {      if(*inputname && ((lf = get_labelfile(ob,inputname)) ||	((lf = read_labels(ob,inputname)) && redo_display(ob) &&	  send_all_marks(lf)))) {	make_labels_menu(lf);	set_display_size(ob);	set_active_fields(objectname,inputname,active);      }    }  }    if(item == menu_item) {    strcpy(menufile,(char*)panel_get_value(item));    ob = (Objects*)get_receiver(objectname);    lf = get_labelfile(ob,inputname);    if(lf)      make_labels_menu(lf);    else      if(ob && (lf = ob->labels))	while(lf) {	  make_labels_menu(lf);	  lf = lf->next;	}  }  if(item == active_item) {    strcpy(active,(char*)panel_get_value(item));    if(*inputname)      set_active_fields(objectname,inputname,active);    else      if((ob = (Objects*)get_receiver(objectname)) && (lf = ob->labels))	while(lf) {	  set_active_fields(objectname,lf->label_name,active);	  lf = lf->next;	}      }}/*********************************************************************/set_active_fields(o,f,a)     char *o, *f, *a;{  Objects *ob;  Labelfile *lf;  char *s, *get_next_item();  int af;    if((ob = (Objects*)get_receiver(o)) && (lf = ob->labels)) {    while(lf) {      if(!strcmp(lf->label_name,f)) {	s = a;	replace_field = 1;	for(af=0; af < LAB_MAXFIELDS; af++) lf->active[af] = 0;	while(*s) {	  if(*s == '*') {	/* make this active for REPLACE mode */	    if(*(++s)) {	      sscanf(s,"%d",&af);	      replace_field = af;	    }	  } else	    sscanf(s,"%d",&af);	  if(af && (af < LAB_MAXFIELDS)) lf->active[af-1] = 1;	  s = get_next_item(s);	}        redo_display(ob);	return(TRUE);      }      lf = lf->next;    }  }  return(FALSE);}/*********************************************************************/void remove_cursor(canv, obj)Canvas canv;Objects *obj;{  Pixwin *pw;  Rect *rec;  int bot, top, left, right;  rec = (Rect *) xv_get(canv, WIN_RECT);  bot = 0;  top = rec->r_height;  left = 0;  right = rec->r_width;  pw = canvas_pixwin(canv);   if (obj->oldcursor_x != -1)     pw_vector(pw, obj->oldcursor_x, bot, obj->oldcursor_x, top,	      PIX_COLOR(CURSOR_COLOR)|(PIX_SRC^PIX_DST), CURSOR_COLOR);    if (obj->oldcursor_y != -1)     pw_vector(pw, left, obj->oldcursor_y, right, obj->oldcursor_y,		PIX_COLOR(CURSOR_COLOR)|(PIX_SRC^PIX_DST), CURSOR_COLOR);  obj->oldcursor_x = -1;  obj->oldcursor_y = -1;}/*********************************************************************/void add_cursor(canv, obj, x, y)Canvas canv;Objects *obj;int x, y;{  Pixwin *pw;  Rect *rec;  int bot, top, left, right;  rec = (Rect *) xv_get(canv, WIN_RECT);  bot = 0;  top = rec->r_height;  left = 0;  right = rec->r_width;  pw = canvas_pixwin(canv);   pw_vector(pw, x, bot, x, top,	    PIX_COLOR(CURSOR_COLOR)|(PIX_SRC^PIX_DST), CURSOR_COLOR);    pw_vector(pw, left, y, right, y,		PIX_COLOR(CURSOR_COLOR)|(PIX_SRC^PIX_DST), CURSOR_COLOR);  obj->oldcursor_x = x;  obj->oldcursor_y = y;}/*********************************************************************/void mark_window(ob,left, right)Objects *ob;double left, right;{	char mess[MES_BUF_SIZE];	sprintf(mess,"%s marker time %f do_left 1\n",ob->name,left);  	mess_write(mess);  	sprintf(mess,"%s marker time %f do_left 0\n",ob->name,right);  	mess_write(mess);}/*********************************************************************/typedef struct cur_ed {  Objects *ob;  Labelfile *lf;  Label *l;  Fields *f;  int active;} Editing;static Editing ed = {NULL, NULL, NULL, NULL, FALSE};static Textsw textwin = XV_NULL;static Frame editor = XV_NULL;/*********************************************************************/still_lives(e)     Editing *e;{  if(e && e->active) {    extern Objects *objlist;    Objects *o = objlist;    while(o) {      if(o == e->ob) {	Labelfile *lf = o->labels;	while(lf) {	  if(lf == e->lf) {	    Label *l = lf->first_label;	    while(l) {	      if(l == e->l) {		Fields *f = l->fields;		while(f) {		  if(f == e->f)		    return(TRUE);		  f = f->next;		}	      }	      l = l->next;	    }	  }	  lf = lf->next;	}      }      o = o->next;    }  }  return(FALSE);}     /*********************************************************************/finish_edit(){  if(still_lives(&ed)) {    int ncom_char = xv_get(textwin, TEXTSW_LENGTH);    if(ed.f->str)      free(ed.f->str);    ed.f->str = NULL;    ed.lf->changed = TRUE;    if(ncom_char > 0) {      char *newstr = malloc(ncom_char + 1);          if(newstr) {	register char *cp = newstr;	if(xv_get(textwin, TEXTSW_CONTENTS, 0, newstr, ncom_char) 	   != ncom_char) {	  Fprintf(stderr, "Error getting textsw contents.\n");	} else 	  newstr[ncom_char] = '\0';	ed.f->str = newstr;	do {	  if(*cp == '\n')	    *cp = ' ';

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -