diff options
author | Alessio Treglia <alessio@debian.org> | 2010-09-22 11:13:01 +0200 |
---|---|---|
committer | Alessio Treglia <alessio@debian.org> | 2010-09-22 11:13:01 +0200 |
commit | 21c0acaad1b1fa3d17c911ff7e4ad05d63310195 (patch) | |
tree | 78c71c4b3e27b7e107e5023c67123a3cacc018de /snd-axis.c | |
parent | 6d99b2e313fc5878ab1ac115460f0e85595825a0 (diff) |
Imported Upstream version 11.9
Diffstat (limited to 'snd-axis.c')
-rw-r--r-- | snd-axis.c | 83 |
1 files changed, 49 insertions, 34 deletions
@@ -369,7 +369,7 @@ static int tick_grf_x(double val, axis_info *ap, x_axis_style_t style, int srate #if HAVE_GL - #if MUS_WITH_GL2PS + #if WITH_GL2PS void gl2ps_text(const char *msg); #endif @@ -448,7 +448,7 @@ void reload_number_font(void) #endif -static void draw_horizontal_grid_line(int y, axis_info *ap, axis_context *ax) +static void draw_horizontal_grid_line(int y, axis_info *ap, graphics_context *ax) { color_t old_color; old_color = get_foreground_color(ax); @@ -460,7 +460,7 @@ static void draw_horizontal_grid_line(int y, axis_info *ap, axis_context *ax) } -static void draw_vertical_grid_line(int x, axis_info *ap, axis_context *ax) +static void draw_vertical_grid_line(int x, axis_info *ap, graphics_context *ax) { color_t old_color; old_color = get_foreground_color(ax); @@ -472,7 +472,7 @@ static void draw_vertical_grid_line(int x, axis_info *ap, axis_context *ax) } -static void draw_x_number(const char *label, int x, int y, int hgt, axis_info *ap, axis_context *ax, printing_t printing) +static void draw_x_number(const char *label, int x, int y, int hgt, axis_info *ap, graphics_context *ax, printing_t printing) { /* from motif point of view, gtk is down by font height (ascent) in pixels */ @@ -489,7 +489,7 @@ static void draw_x_number(const char *label, int x, int y, int hgt, axis_info *a } -static void draw_y_number(const char *label, int x, int y, int hgt, axis_info *ap, axis_context *ax, printing_t printing) +static void draw_y_number(const char *label, int x, int y, int hgt, axis_info *ap, graphics_context *ax, printing_t printing) { /* from motif point of view, gtk is down by font height (ascent) in pixels */ #if USE_MOTIF @@ -503,19 +503,19 @@ static void draw_y_number(const char *label, int x, int y, int hgt, axis_info *a } -static void draw_label(const char *label, int x, int y, int yoff, axis_info *ap, axis_context *ax, printing_t printing) +static void draw_label(const char *label, int x, int y, int yoff, axis_info *ap, graphics_context *ax, printing_t printing) { /* from motif point of view, gtk is down by font height (ascent) in pixels */ #if USE_GTK y -= yoff; #endif - draw_string(ax, x, y, label, mus_strlen(label)); + draw_string(ax, x - 10, y, label, mus_strlen(label)); if (printing) - ps_draw_string(ap, x, y, label); + ps_draw_string(ap, x - 10, y, label); } -static void draw_vertical_tick(int x, int y0, int y1, axis_info *ap, axis_context *ax, printing_t printing, bool include_grid) +static void draw_vertical_tick(int x, int y0, int y1, axis_info *ap, graphics_context *ax, printing_t printing, bool include_grid) { draw_line(ax, x, y1, x, y0); if (printing) ps_draw_line(ap, x, y1, x, y0); @@ -523,7 +523,7 @@ static void draw_vertical_tick(int x, int y0, int y1, axis_info *ap, axis_contex } -static void draw_horizontal_tick(int x0, int x1, int y, axis_info *ap, axis_context *ax, printing_t printing, bool include_grid) +static void draw_horizontal_tick(int x0, int x1, int y, axis_info *ap, graphics_context *ax, printing_t printing, bool include_grid) { draw_line(ax, x0, y, x1, y); if (printing) ps_draw_line(ap, x0, y, x1, y); @@ -532,7 +532,7 @@ static void draw_horizontal_tick(int x0, int x1, int y, axis_info *ap, axis_cont static void draw_log_tick_label(const char *label, int logx, int y, int hgt, int x_label_width, int right_border_width, - axis_info *ap, axis_context *ax, printing_t printing, bool use_tiny_font) + axis_info *ap, graphics_context *ax, printing_t printing, bool use_tiny_font) { /* is there room for a label? */ /* the main label is at ap->x_label_x to that plus x_label_width */ @@ -549,7 +549,7 @@ static void draw_log_tick_label(const char *label, int logx, int y, int hgt, int } -static void use_tiny(axis_context *ax, printing_t printing) +static void use_tiny(graphics_context *ax, printing_t printing) { #if USE_MOTIF ax->current_font = ((XFontStruct *)(TINY_FONT(ss)))->fid; @@ -563,7 +563,7 @@ static void use_tiny(axis_context *ax, printing_t printing) } -static void set_numbers_font(axis_context *ax, printing_t printing, bool use_tiny_font) +static void set_numbers_font(graphics_context *ax, printing_t printing, bool use_tiny_font) { if (use_tiny_font) use_tiny(ax, printing); @@ -582,7 +582,7 @@ static void set_numbers_font(axis_context *ax, printing_t printing, bool use_tin } -static void set_labels_font(axis_context *ax, printing_t printing, bool use_tiny_font) +static void set_labels_font(graphics_context *ax, printing_t printing, bool use_tiny_font) { if (use_tiny_font) use_tiny(ax, printing); @@ -613,7 +613,7 @@ void make_axes_1(axis_info *ap, x_axis_style_t x_style, int srate, show_axes_t a int num_ticks; tick_descriptor *tdx = NULL, *tdy = NULL; int curx, cury; - axis_context *ax; + graphics_context *ax; #if HAVE_GL mus_float_t xthick, ythick, xmajorlen, xminorlen, ymajorlen, yminorlen; #endif @@ -650,11 +650,12 @@ void make_axes_1(axis_info *ap, x_axis_style_t x_style, int srate, show_axes_t a init_axis_scales(ap); return; } + left_border_width = 10; #if USE_MOTIF bottom_border_width = 10; #else - bottom_border_width = 4; + bottom_border_width = 8; #endif top_border_width = 10; right_border_width = 14; @@ -945,7 +946,7 @@ void make_axes_1(axis_info *ap, x_axis_style_t x_style, int srate, show_axes_t a glColor3f(0.0, 0.0, 0.0); glRasterPos3f(-0.1, 0.0, yl); glListBase(label_base); - #if MUS_WITH_GL2PS + #if WITH_GL2PS if (ss->gl_printing) gl2ps_text(ap->xlabel); #endif glCallLists(mus_strlen(ap->xlabel), GL_UNSIGNED_BYTE, (GLubyte *)(ap->xlabel)); @@ -1040,7 +1041,7 @@ void make_axes_1(axis_info *ap, x_axis_style_t x_style, int srate, show_axes_t a xl = -0.5 - ythick - ((mus_float_t)(3 * tdy->maj_tick_len + tdy->min_label_width + inner_border_width) / (mus_float_t)width); glRasterPos3f(xl, 0.0, (tdy->mlo - ap->y0) / (ap->y1 - ap->y0) - 0.51); glListBase(number_base); - #if MUS_WITH_GL2PS + #if WITH_GL2PS if (ss->gl_printing) gl2ps_text(tdy->min_label); #endif glCallLists(mus_strlen(tdy->min_label), GL_UNSIGNED_BYTE, (GLubyte *)(tdy->min_label)); @@ -1048,7 +1049,7 @@ void make_axes_1(axis_info *ap, x_axis_style_t x_style, int srate, show_axes_t a xl = -0.5 - ythick - ((mus_float_t)(3 * tdy->maj_tick_len + tdy->max_label_width + inner_border_width) / (mus_float_t)width); glRasterPos3f(xl, 0.0, (tdy->mhi - ap->y0) / (ap->y1 - ap->y0) - 0.51); glListBase(number_base); - #if MUS_WITH_GL2PS + #if WITH_GL2PS if (ss->gl_printing) gl2ps_text(tdy->max_label); #endif glCallLists(mus_strlen(tdy->max_label), GL_UNSIGNED_BYTE, (GLubyte *)(tdy->max_label)); @@ -1087,7 +1088,7 @@ void make_axes_1(axis_info *ap, x_axis_style_t x_style, int srate, show_axes_t a yl = -0.5 - xthick - ((mus_float_t)(3 * major_tick_length + x_number_height + inner_border_width) / (mus_float_t)height); glRasterPos3f((tdx->mlo - ap->x0) / (ap->x1 - ap->x0) - 0.53, 0.0, yl); glListBase(number_base); - #if MUS_WITH_GL2PS + #if WITH_GL2PS if (ss->gl_printing) gl2ps_text(tdx->min_label); #endif glCallLists(mus_strlen(tdx->min_label), GL_UNSIGNED_BYTE, (GLubyte *)(tdx->min_label)); @@ -1112,7 +1113,7 @@ void make_axes_1(axis_info *ap, x_axis_style_t x_style, int srate, show_axes_t a yl = -0.5 - xthick - ((mus_float_t)(3 * major_tick_length + x_number_height + inner_border_width) / (mus_float_t)height); glRasterPos3f((tdx->mhi - ap->x0) / (ap->x1 - ap->x0) - 0.53, 0.0, yl); glListBase(number_base); - #if MUS_WITH_GL2PS + #if WITH_GL2PS if (ss->gl_printing) gl2ps_text(tdx->max_label); #endif glCallLists(mus_strlen(tdx->max_label), GL_UNSIGNED_BYTE, (GLubyte *)(tdx->max_label)); @@ -1489,6 +1490,30 @@ axis_info *make_axis_info (chan_info *cp, double xmin, double xmax, mus_float_t #if (!USE_NO_GUI) +static axis_info *get_ap(chan_info *cp, axis_info_t ap_id, const char *caller) +{ + #define AXIS_INFO_ID_OK(Id) (Id <= (int)LISP_AXIS_INFO) + + if ((cp) && (AXIS_INFO_ID_OK(ap_id))) + switch (ap_id) + { + case TIME_AXIS_INFO: return(cp->axis); break; + case TRANSFORM_AXIS_INFO: if (cp->fft) return(cp->fft->axis); break; + case LISP_AXIS_INFO: if (cp->lisp_info) return(lisp_info_axis(cp)); break; + } + + XEN_ERROR(XEN_ERROR_TYPE("no-such-axis"), + XEN_LIST_6(((!(cp->squelch_update)) || (!(AXIS_INFO_ID_OK(ap_id)))) ? + C_TO_XEN_STRING("~A: no such axis: ~A of sound ~A (~A), chan: ~A (axis should be " S_time_graph ", " S_lisp_graph ", or " S_transform_graph ")") : + C_TO_XEN_STRING("~A: no such axis: ~A of sound ~A (~A), chan: ~A does not exist, probably because output is squelched"), + C_TO_XEN_STRING(caller), + C_TO_XEN_INT((int)(ap_id)), + C_INT_TO_XEN_SOUND(cp->sound->index), + C_TO_XEN_STRING(cp->sound->short_filename), + C_TO_XEN_INT(cp->chan))); + return(NULL); +} + #define TO_C_AXIS_INFO(Snd, Chn, Ap, Caller) \ get_ap(get_cp(Snd, Chn, Caller), \ (axis_info_t)XEN_TO_C_INT_OR_ELSE(Ap, (int)TIME_AXIS_INFO), \ @@ -1579,17 +1604,10 @@ x0 y0 x1 y1 xmin ymin xmax ymax pix_x0 pix_y0 pix_x1 pix_y1 y_offset xscale ysca (strcmp("GC", XEN_SYMBOL_TO_C_STRING(XEN_CAR(Value))) == 0)) #else #if USE_GTK - #if USE_CAIRO #define XEN_UNWRAP_SND_GC(Value) (gc_t *)(XEN_UNWRAP_C_POINTER(XEN_CADR(Value))) #define XEN_SND_GC_P(Value) (XEN_LIST_P(Value) && (XEN_LIST_LENGTH(Value) >= 2) && \ (XEN_SYMBOL_P(XEN_CAR(Value))) && \ (strcmp("gc_t_", XEN_SYMBOL_TO_C_STRING(XEN_CAR(Value))) == 0)) - #else - #define XEN_UNWRAP_SND_GC(Value) (gc_t *)(XEN_UNWRAP_C_POINTER(XEN_CADR(Value))) - #define XEN_SND_GC_P(Value) (XEN_LIST_P(Value) && (XEN_LIST_LENGTH(Value) >= 2) && \ - (XEN_SYMBOL_P(XEN_CAR(Value))) && \ - (strcmp("GdkGC_", XEN_SYMBOL_TO_C_STRING(XEN_CAR(Value))) == 0)) - #endif #else #define XEN_UNWRAP_SND_GC(Value) 0 #define XEN_SND_GC_P(Value) 0 @@ -1619,7 +1637,7 @@ Returns actual (pixel) axis bounds -- a list (x0 y0 x1 y1)." mus_float_t y0 = -1.0, y1 = 1.0; x_axis_style_t x_style = X_AXIS_IN_SECONDS; show_axes_t axes = SHOW_ALL_AXES; - axis_context *ax; + graphics_context *ax; axis_info *ap; int len; @@ -1682,7 +1700,7 @@ Returns actual (pixel) axis bounds -- a list (x0 y0 x1 y1)." }}}}}} ap = (axis_info *)calloc(1, sizeof(axis_info)); - ax = (axis_context *)calloc(1, sizeof(axis_context)); + ax = (graphics_context *)calloc(1, sizeof(graphics_context)); ap->ax = ax; #if USE_MOTIF ax->dp = XtDisplay(w); @@ -1691,9 +1709,6 @@ Returns actual (pixel) axis bounds -- a list (x0 y0 x1 y1)." #if USE_GTK ax->wn = WIDGET_TO_WINDOW(w); ax->w = w; -#endif - -#if USE_CAIRO ax->cr = gdk_cairo_create(ax->wn); #endif @@ -1725,7 +1740,7 @@ Returns actual (pixel) axis bounds -- a list (x0 y0 x1 y1)." XEN_CONS(C_TO_XEN_INT(ap->y_axis_y1), XEN_EMPTY_LIST)))); -#if USE_CAIRO +#if USE_GTK cairo_destroy(ax->cr); #endif free_axis_info(ap); |