📄 xcursors.c
字号:
/* Copyright (c) 1995 Entropic Research Laboratory, Inc. *//* Copyright (c) 1987, 1988 AT&T *//* and Entropic Speech, Inc. *//* All Rights Reserved. *//* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T *//* AND ENTROPIC SPEECH, INC. *//* The copyright notice above does not evidence any *//* actual or intended publication of such source code. *//* xcursors.c */#ifndef lintstatic char *sccs_id = "@(#)xcursors.c 1.13 9/28/98 ERL/ATT";#endif#include <Objects.h>#include <xview/font.h>#include <Xp_pw.h>extern Xv_Font def_font;extern int def_font_height, def_font_width;extern int doing_print_graphic, print_only_plot;View *focus_view;/*********************************************************************/transform_xy(v, x, y) View *v; int x, y;{ if(v) { Signal *s = v->sig; Object *o = (Object*)s->obj; double freq = -1.0, time = 0.0, level_crossing_time(); int chan = 0, sdim = s->dim, sigtype; if(v->xy_to_chan) chan = v->xy_to_chan(v,x,y); if(v->find_crossing) time = level_crossing_time(v,x,v->cross_level,chan); else if(v->x_to_time) time = v->x_to_time(v,x); if(v->y_to_yval) freq = v->y_to_yval(v,y); if(freq < v->start_yval) freq = v->start_yval; else if(freq > v->end_yval) freq = v->end_yval; v->cursor_channel = chan; focus_view = v; sigtype = type_of_signal(s); /* Check other views */ s = o->signals; while( s ) { View *v2 = s->views; while( v2 ) { if (v2 != v) { if(v2->xy_to_chan && isa_spectrogram_view(v2)) v2->cursor_channel = v2->xy_to_chan(v2,v2->time_to_x(v2,time), v2->yval_to_y(v2,freq)); else if((type_of_signal(v2->sig) == sigtype) && (sdim == v2->sig->dim)) v2->cursor_channel = chan; else if((v2->extra_type == VIEW_OVERLAY) && ((View*)(v2->extra) == v) && v2->xy_to_chan) v2->cursor_channel = v2->xy_to_chan(v2,x,y); } v2 = v2->next; } s = s->others; } move_cursors(v,time,freq); return(TRUE); } else return(FALSE);}/*********************************************************************/link_views(v) View *v;{ if(v) { Signal *s = v->sig; Object *o = (Object*)s->obj; double freq = v->cursor_yval, time = v->cursor_time; int chan = v->cursor_channel, sdim = s->dim, sigtype; sigtype = type_of_signal(s); /* Check other views */ s = o->signals; while( s ) { View *v2 = s->views; while( v2 ) { if (v2 != v) { if(v2->xy_to_chan && isa_spectrogram_view(v2)) v2->cursor_channel = v2->xy_to_chan(v2,v2->time_to_x(v2,time), v2->yval_to_y(v2,freq)); else if((type_of_signal(v2->sig) == sigtype) && (sdim == v2->sig->dim)) v2->cursor_channel = chan; else if((v2->extra_type == VIEW_OVERLAY) && ((View*)(v2->extra) == v)) v2->cursor_channel = v2->xy_to_chan(v2,v2->time_to_x(v2,time), v2->yval_to_y(v2,freq)); } v2 = v2->next; } s = s->others; } move_cursors(v,time,freq); return(TRUE); } else return(FALSE);}/*********************************************************************/move_cursors(v, time, freq) register View *v; double time, freq;{ extern int options; if(v) { Signal *s; Object *o; /* This bit of magic "fixes" the swapped-out-process-on-a-sparc2-crashing bug! (dt 7/29/92)! */ if(options & ENABLE_CURSOR_HACK) { if(v && v->canvas) { Xv_Window pw; pw = canvas_paint_window(v->canvas); pw_text(pw, 0, 800, PIX_SRC|PIX_COLOR(FOREGROUND_COLOR), def_font, "."); } } s = v->sig; o = (Object*)s->obj; /* Display local cursors first. */ if (v->cursor_plot) v->cursor_plot(v, CURSOR_COLOR); v->cursor_yval = freq; v->cursor_time = time; if (v->cursor_plot) v->cursor_plot(v, CURSOR_COLOR); if (v->x_print) v->x_print(v); if (v->y_print) v->y_print(v); /* display other cursors */ s = o->signals; while( s ) { View *v2 = s->views; while( v2 ) { if (v2 != v) { if (v2->cursor_plot) v2->cursor_plot(v2, CURSOR_COLOR); v2->cursor_time = v->cursor_time; if(v->cursor_yval >= v2->start_yval) v2->cursor_yval = v->cursor_yval; if (v2->cursor_plot) v2->cursor_plot(v2, CURSOR_COLOR); if (v2->x_print) v2->x_print(v2); if (v2->y_print) v2->y_print(v2); } v2 = v2->next; } s = s->others; } }}/*********************************************************************/move_markers(v, time, do_left) View *v; double time; int do_left; /* 0=>right; 1=>left; 2=>both */{ Signal *s; Object *o; double temp; s = ((Object*)((Signal*)v->sig)->obj)->signals; while( s ) { v = s->views; while( v ) { if (v->vmarker_plot) v->vmarker_plot(v,do_left); if ((do_left & 1)) v->lmarker_time = time; else v->rmarker_time = time; if((!(do_left & 1)) && (v->lmarker_time > v->rmarker_time)) { /* swap left & right */ if(v->vmarker_plot) v->vmarker_plot(v, 1); /* turn off left marker */ temp = v->lmarker_time; /* do the swap */ v->lmarker_time = v->rmarker_time; v->rmarker_time = temp; if(v->vmarker_plot) v->vmarker_plot(v, 1); /* turn on (new) left marker */ } if (v->vmarker_plot) v->vmarker_plot(v, do_left); v = v->next; } s = s->others; }}/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/move_ord_markers(v, x, y, do_top) View *v; int x, y, do_top;{ Signal *s, *s0; View *v0; Object *o; double temp; int sigtype, itmp; s = ((Object*)((Signal*)v->sig)->obj)->signals; s0 = v->sig; v0 = v; sigtype = type_of_signal(s0); /* First do the target view, since it's values will be needed. */ if (v->hmarker_plot) /* XOR off old marker */ v->hmarker_plot(v,do_top); if ((do_top & 1)) { v->tmarker_chan = v->cursor_channel; v->tmarker_yval = v->y_to_yval(v,y); } else { v->bmarker_chan = v->cursor_channel; v->bmarker_yval = v->y_to_yval(v,y); } /* Now, do all other views in the ensemble. */ while( s ) { /* The semantics of moving horizontal markers across views is very unclear. The following heuristic will fail in some cases. This situation can be improved, but probably not fixed completely. */ if((type_of_signal(s) == sigtype) && (v = s->views)) { if(v != v0) { /* if this is a different view... */ if (v->hmarker_plot) /* XOR off old marker */ v->hmarker_plot(v,do_top); if ((do_top & 1)) { if(v->xy_to_chan && isa_spectrogram_view(v)) { v->tmarker_yval = v0->tmarker_yval; v->tmarker_chan = v->xy_to_chan(v,v->time_to_x(v,v0->cursor_time), v->yval_to_y(v,v->tmarker_yval)); } else if(s0->dim == s->dim) { v->tmarker_yval = v0->tmarker_yval; v->tmarker_chan = v0->tmarker_chan; } } else { if(v->xy_to_chan && isa_spectrogram_view(v)) { v->bmarker_yval = v0->bmarker_yval; v->bmarker_chan = v->xy_to_chan(v,v->time_to_x(v,v0->cursor_time), v->yval_to_y(v,v->bmarker_yval)); } else if(s0->dim == s->dim) { v->bmarker_yval = v0->bmarker_yval; v->bmarker_chan = v0->bmarker_chan; } } if((!(do_top & 1)) && (v->tmarker_yval < v->bmarker_yval)) { /* swap top & bottom */ if(v->hmarker_plot) v->hmarker_plot(v, 1); /* turn off top marker */ temp = v->tmarker_yval; /* do the swap */ itmp = v->tmarker_chan; v->tmarker_yval = v->bmarker_yval; v->tmarker_chan = v->bmarker_chan; v->bmarker_yval = temp; v->bmarker_chan = itmp; if(v->hmarker_plot) v->hmarker_plot(v, 1); /* turn on (new) top marker */ } if (v->hmarker_plot) v->hmarker_plot(v, do_top); v = v->next; } } s = s->others; } v = v0; /* Now finish up the original. */ if((!(do_top & 1)) && (((v->tmarker_chan == v->bmarker_chan) && (v->tmarker_yval < v->bmarker_yval)) || (v->tmarker_chan < v->bmarker_chan))) { /* swap top & bottom */ if(v->hmarker_plot) v->hmarker_plot(v, 1); /* turn off top marker */ temp = v->tmarker_yval; /* do the swap */ itmp = v->tmarker_chan; v->tmarker_yval = v->bmarker_yval; v->tmarker_chan = v->bmarker_chan; v->bmarker_yval = temp; v->bmarker_chan = itmp; if(v->hmarker_plot) v->hmarker_plot(v, 1); /* turn on (new) top marker */ } if (v->hmarker_plot) v->hmarker_plot(v, do_top);}/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/plot_cursors(v,color) View *v; int color;{ Pixwin *pw; Rect *rec; int x, y1, y2; if(doing_print_graphic && print_only_plot) return(TRUE); if(!v || !v->canvas) return(FALSE); x = v->time_to_x(v, v->cursor_time); pw = canvas_pixwin(v->canvas); rec = (Rect *) xv_get((Xv_opaque)pw, WIN_RECT); if (v->scrollbar && (v->scrollbar->height > 0) && v->scrollbar->is_on) y1 = v->scrollbar->y + v->scrollbar->height; else y1 = 0; y2 = rec->r_height - 1; pw_vector(pw, x, y1, x, y2, PIX_COLOR(color)|(PIX_SRC^PIX_DST), color); return(TRUE);}/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/plot_markers(v, which) View *v; int which; /* 0=>right; 1=>left; 2=>both */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -