=================================================================== RCS file: /home/cvs/OpenXM_contrib/gnuplot/Attic/graph3d.c,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.2 diff -u -p -r1.1.1.1 -r1.1.1.2 --- OpenXM_contrib/gnuplot/Attic/graph3d.c 2000/01/09 17:00:51 1.1.1.1 +++ OpenXM_contrib/gnuplot/Attic/graph3d.c 2000/01/22 14:15:58 1.1.1.2 @@ -1,5 +1,5 @@ #ifndef lint -static char *RCSid = "$Id: graph3d.c,v 1.1.1.1 2000/01/09 17:00:51 maekawa Exp $"; +static char *RCSid = "$Id: graph3d.c,v 1.1.1.2 2000/01/22 14:15:58 maekawa Exp $"; #endif /* GNUPLOT - graph3d.c */ @@ -397,13 +397,20 @@ int count; key_rows = ptitl_cnt; key_cols = 1; if (key == -1 && key_vpos == TUNDER) { + if (ptitl_cnt > 0) { /* calculate max no cols, limited by label-length */ key_cols = (int) (xright - xleft) / ((max_ptitl_len + 4) * (t->h_char) + key_sample_width); + /* HBB 991019: fix division by zero problem */ + if (key_cols == 0) + key_cols = 1; key_rows = (int) (ptitl_cnt / key_cols) + ((ptitl_cnt % key_cols) > 0); /* now calculate actual no cols depending on no rows */ key_cols = (int) (ptitl_cnt / key_rows) + ((ptitl_cnt % key_rows) > 0); key_col_wth = (int) (xright - xleft) / key_cols; /* key_rows += ktitle_lines; - messes up key - div */ + } else { + key_rows = key_cols = key_col_wth = 0; + } } /* this should also consider the view and number of lines in * xformat || yformat || xlabel || ylabel */ @@ -443,7 +450,7 @@ int count; /* HBB 980308: sigh... another 16bit glitch: on term's with more than * 8000 pixels in either direction, these calculations produce garbage * results if done in (16bit) ints */ - xscaler = (xright - xleft) * 4 / 7; /* HBB: Magic number alert! */ + xscaler = ((xright - xleft) * 4L) / 7L; /* HBB: Magic number alert! */ yscaler = ((ytop - ybot) * 4L) / 7L; } @@ -487,13 +494,13 @@ int pcount; /* count of plots in linked list */ struct surface_points *this_plot = NULL; unsigned int xl, yl; int linetypeOffset = 0; - double ztemp, temp; + /* double ztemp, temp; unused */ struct text_label *this_label; struct arrow_def *this_arrow; TBOOLEAN scaling; transform_matrix mat; int key_count; - char ss[MAX_LINE_LEN+1], *s, *e; + char *s, *e; /* Initiate transformation matrix using the global view variables. */ mat_rot_z(surface_rot_z, trans_mat); @@ -502,13 +509,15 @@ int pcount; /* count of plots in linked list */ mat_scale(surface_scale / 2.0, surface_scale / 2.0, surface_scale / 2.0, mat); mat_mult(trans_mat, trans_mat, mat); +#if 0 + /* HBB 19990609: this is *not* the way to implement 'set view' */ /* modify min_z/max_z so it will zscale properly. */ ztemp = (z_max3d - z_min3d) / (2.0 * surface_zscale); temp = (z_max3d + z_min3d) / 2.0; z_min3d = temp - ztemp; z_max3d = temp + ztemp; +#endif /* 0 */ - /* The extrema need to be set even when a surface is not being * drawn. Without this, gnuplot used to assume that the X and * Y axis started at zero. -RKC @@ -573,7 +582,7 @@ int pcount; /* count of plots in linked list */ boundary3d(scaling, plots, pcount); /* SCALE FACTORS */ - zscale3d = 2.0 / (ceiling_z - floor_z); + zscale3d = 2.0 / (ceiling_z - floor_z) * surface_zscale; yscale3d = 2.0 / (y_max3d - y_min3d); xscale3d = 2.0 / (x_max3d - x_min3d); @@ -581,10 +590,9 @@ int pcount; /* count of plots in linked list */ /* PLACE TITLE */ if (*title.text != 0) { - safe_strncpy(ss, title.text, sizeof(ss)); write_multiline((unsigned int) ((xleft + xright) / 2 + title.xoffset * t->h_char), (unsigned int) (ytop + (titlelin + title.yoffset) * (t->h_char)), - ss, CENTRE, JUST_TOP, 0, title.font); + title.text, CENTRE, JUST_TOP, 0, title.font); } /* PLACE TIMEDATE */ if (*timelabel.text) { @@ -619,7 +627,6 @@ int pcount; /* count of plots in linked list */ map_position(&this_label->place, &x, &y, "label"); - safe_strncpy(ss, this_label->text, sizeof(ss)); if (this_label->rotate && (*t->text_angle) (1)) { write_multiline(x, y, this_label->text, this_label->pos, CENTRE, 1, this_label->font); (*t->text_angle) (0); @@ -675,6 +682,9 @@ int pcount; /* count of plots in linked list */ xl /= 1000; xl += xleft; #else + /* HBB 19990608: why calculate these again? boundary3d has already + * done it... */ + if (ptitl_cnt > 0) { /* maximise no cols, limited by label-length */ key_cols = (int) (xright - xleft) / key_col_wth; key_rows = (int) (ptitl_cnt + key_cols - 1) / key_cols; @@ -689,6 +699,7 @@ int pcount; /* count of plots in linked list */ */ xl = xleft + ((xright - xleft) * key_size_left) / (key_cols * (key_size_left + key_size_right)); yl = yoffset * t->ymax + (key_rows) * key_entry_height + (ktitle_lines + 2) * t->v_char; + } #endif } else { if (key_vpos == TTOP) { @@ -735,7 +746,9 @@ int pcount; /* count of plots in linked list */ /* KEY TITLE */ if (key != 0 && strlen(key_title)) { - sprintf(ss, "%s\n", key_title); + char *ss = gp_alloc(strlen(key_title) + 2, "tmp string ss"); + strcpy(ss, key_title); + strcat(ss, "\n"); s = ss; yl -= t->v_char / 2; while ((e = (char *) strchr(s, '\n')) != NULL) { @@ -757,6 +770,7 @@ int pcount; /* count of plots in linked list */ yl -= t->v_char; } yl += t->v_char / 2; + free(ss); } key_count = 0; yl_ref = yl -= key_entry_height / 2; /* centralise the keys */ @@ -1618,8 +1632,7 @@ else if (height[i][j] != depth[i][j]) \ y1 -= tic_unity * ticscale * (t->v_tic); } /* write_multiline mods it */ - safe_strncpy(ss, xlabel.text, sizeof(ss)); - write_multiline(x1, y1, ss, CENTRE, JUST_TOP, 0, xlabel.font); + write_multiline(x1, y1, xlabel.text, CENTRE, JUST_TOP, 0, xlabel.font); } } if (ytics || *ylabel.text) { @@ -1665,16 +1678,16 @@ else if (height[i][j] != depth[i][j]) \ gen_tics(FIRST_Z_AXIS, &zticdef, work_grid.l_type & (GRID_Z | GRID_MZ), mztics, mztfreq, ztick_callback); } - if ((xzeroaxis.l_type >= -2) && !is_log_y && inrange(0, y_min3d, y_max3d)) { + if ((yzeroaxis.l_type >= -2) && !is_log_x && inrange(0, x_min3d, x_max3d)) { unsigned int x, y, x1, y1; - term_apply_lp_properties(&xzeroaxis); + term_apply_lp_properties(&yzeroaxis); map3d_xy(0.0, y_min3d, base_z, &x, &y); /* line through x=0 */ map3d_xy(0.0, y_max3d, base_z, &x1, &y1); draw_clip_line(x, y, x1, y1); } - if ((yzeroaxis.l_type >= -2) && !is_log_x && inrange(0, x_min3d, x_max3d)) { + if ((xzeroaxis.l_type >= -2) && !is_log_y && inrange(0, y_min3d, y_max3d)) { unsigned int x, y, x1, y1; - term_apply_lp_properties(&yzeroaxis); + term_apply_lp_properties(&xzeroaxis); map3d_xy(x_min3d, 0.0, base_z, &x, &y); /* line through y=0 */ map3d_xy(x_max3d, 0.0, base_z, &x1, &y1); draw_clip_line(x, y, x1, y1); @@ -1686,8 +1699,7 @@ else if (height[i][j] != depth[i][j]) \ x += zlabel.xoffset * t->h_char; y += zlabel.yoffset * t->v_char; - safe_strncpy(ss, zlabel.text, sizeof(ss)); - write_multiline(x, y, ss, CENTRE, CENTRE, 0, zlabel.font); + write_multiline(x, y, zlabel.text, CENTRE, CENTRE, 0, zlabel.font); } }