1 /*****************************************************************************
6 ** This is part of the CTSim program
7 ** Copyright (C) 1983-2000 Kevin Rosenberg
9 ** $Id: ezplot.cpp,v 1.2 2000/06/19 19:04:05 kevin Exp $
11 ** This program is free software; you can redistribute it and/or modify
12 ** it under the terms of the GNU General Public License (version 2) as
13 ** published by the Free Software Foundation.
15 ** This program is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ** GNU General Public License for more details.
20 ** You should have received a copy of the GNU General Public License
21 ** along with this program; if not, write to the Free Software
22 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 ******************************************************************************/
29 static int plot (SGP_ID *gid);
30 static void drawaxis(void);
31 static void symbol (int sym, double symwidth, double symheight);
33 /*-------------------------------------*/
34 /* GLOBAL variables for EZPLOT & EZSET */
35 /*-------------------------------------*/
37 bool ezplot_firstcall = TRUE; /* set to false on first call to EZSET or EZPLOT */
38 struct ezplot_var ez; /* ezplot variables */
44 #define TICKRATIO 0.4 /* ratio of minor to major tick lengths */
45 #define MAXNUMFMT 15 /* maximum length of a numeric format */
47 #define DEF_CRTMODE 0 /*GM_HIGHRES*/ /* default crt mode */
48 #define DEF_CHARHEIGHT (1./43.) /* default size of characters in NDC */
49 #define DEF_CHARWIDTH (1./80.)
51 #define DEF_CURVE_CLR C_YELLOW
54 /*----------------------------------------------------------------------*/
55 /* GLOBAL VARIABLES */
56 /*----------------------------------------------------------------------*/
59 double charwidth, charheight; /* Size of characters in NDC */
62 double xp_min, xp_max,
63 yp_min, yp_max; /* boundry of plot frame in NDC */
65 double xa_min, xa_max,
66 ya_min, ya_max; /* extent of axes in NDC */
68 double xgw_min, xgw_max,
69 ygw_min, ygw_max; /* boundary of graph in input coords */
71 double xgn_min, xgn_max,
72 ygn_min, ygn_max; /* boundy of graph in NDC */
74 double xt_min, xt_max,
75 yt_min, yt_max; /* boundary of axis ticks */
78 double xl_min, xl_max,
79 yl_min, yl_max; /* boundary of legend box */
81 static double title_row; /* y-coord of title row */
83 static double xtl_ofs; /* Offset y-coord of x tick labels from axis */
84 static double ytl_ofs; /* Offset x-coord of y tick labels from axis */
86 static double xlbl_row; /* row of x label in world coord */
87 static double ylbl_col; /* column of y label in world coord */
90 double xw_tickinc, yw_tickinc; /* increment between major ticks in WC */
93 double xn_tickinc, yn_tickinc; /* increment between major ticks in NDC */
95 static int x_nint, y_nint; /* number of intervals along x & y axes */
96 static int x_fldwid, x_frac; /* numeric field sizes & number of digits */
97 static int y_fldwid, y_frac; /* in fraction of number, used for printf() */
99 static double xtl_wid, ytl_wid; /* length of ticks labels in NDC */
100 static double tl_height; /* height of tick labels in NDC */
102 static char x_numfmt[10]; /* format to print x tick labels */
103 static char y_numfmt[10]; /* format to print y tick labels */
106 /*----------------------------------------------------------------------
107 * FUNCTION IDENTICIFATION
110 * Programmer: Kevin Rosenberg
111 * Date: 5-83 Version 1
116 * double x[] x-coordinates of point makeing up a curve
117 * double y[] y-coordinates of points makeing up a curve
118 * int n Number of points in curve
121 * This is a sophisticated plotting program.
123 *----------------------------------------------------------------------*/
127 ezplot (double x[], double y[], int num)
129 unsigned int size, i;
132 if (ez.i_plotimmediate == TRUE) {
140 if (ezplot_firstcall == TRUE)
143 if (ez.o_unknowncurves == FALSE && ez.i_numcurves >= ez.o_reqcurves)
146 if (ez.i_numcurves < MAXCURVES &&
147 (ez.o_unknowncurves == TRUE || ez.i_numcurves < ez.o_reqcurves)) {
148 size = num * sizeof(double);
149 ez.curve[ez.i_numcurves].x = new double [size];
150 ez.curve[ez.i_numcurves].y = new double [size];
151 for (i = 0; i < num; i++) {
152 ez.curve[ez.i_numcurves].x[i] = x[i];
153 ez.curve[ez.i_numcurves].y[i] = y[i];
155 ez.curve[ez.i_numcurves].numpts = num;
156 ez.curve[ez.i_numcurves].color = ez.o_color;
157 ez.curve[ez.i_numcurves].linestyle = ez.o_linestyle;
158 ez.curve[ez.i_numcurves].symbol = ez.o_symbol;
159 ez.curve[ez.i_numcurves].symfreq = ez.o_symfreq;
160 strncpy (ez.curve[ez.i_numcurves].legend, ez.c_legend, MAXLEGEND);
164 if (ez.o_unknowncurves == FALSE && ez.i_numcurves >= ez.o_reqcurves) {
174 * plot INTERNAL: Plots all curves collected by ezplot()
180 * This routine plots the curves that have stored by ezplot().
186 * drawaxis() & make_numfmt()
189 static int plot (SGP_ID *gid)
191 double xmin, xmax; /* extend of curves in world coord */
193 double x_added_ticks; /* number of tick spaces added to axis */
194 double y_added_ticks;
195 double symwidth, symheight; /* size of symbol in NDC */
196 double leg_width, leg_height; /* size of legend box */
197 int num_leg; /* number of legend titles */
198 int max_leg; /* longest legend in characters */
201 if (ez.i_numcurves <= 0)
204 if (ez.o_ustart == FALSE && *gid == NULL) {
205 *gid = sgp2_init (0, 0, "Ezplot");
208 if (ez.s_textsize == TRUE)
209 charheight = ez.v_textsize;
211 charheight = DEF_CHARHEIGHT;
213 gp_set_aspect (CRTDEV, 1.0);
215 xmin = xmax = ez.curve[0].x[0];
216 ymin = ymax = ez.curve[0].y[0];
218 for (ic = 0; ic < ez.i_numcurves; ic++) {
219 for (ip = 0; ip < ez.curve[ic].numpts; ip++) {
220 if (ez.curve[ic].x[ip] > xmax)
221 xmax = ez.curve[ic].x[ip];
222 else if (ez.curve[ic].x[ip] < xmin)
223 xmin = ez.curve[ic].x[ip];
224 if (ez.curve[ic].y[ip] > ymax)
225 ymax = ez.curve[ic].y[ip];
226 else if (ez.curve[ic].y[ip] < ymin)
227 ymin = ez.curve[ic].y[ip];
231 /* extend graph limits for user defined axis cross positions */
233 if (ez.s_xcross == TRUE)
235 if (ez.v_xcross < xmin)
237 else if (ez.v_xcross > xmax)
241 if (ez.s_ycross == TRUE)
243 if (ez.v_ycross < ymin)
245 else if (ez.v_ycross > ymax)
249 /* find nice endpoints for axes */
251 axis_scale (xmin, xmax, ez.o_xmajortick - 1, &xgw_min, &xgw_max, &x_nint);
252 axis_scale (ymin, ymax, ez.o_ymajortick - 1, &ygw_min, &ygw_max, &y_nint);
254 /* check if user set x-axis extents */
256 if (ez.s_xmin == TRUE) {
258 x_nint = ez.o_xmajortick - 1;
260 if (ez.s_xmax == TRUE) {
262 x_nint = ez.o_xmajortick - 1;
265 /* check if user set y-axis extents */
267 if (ez.s_ymin == TRUE) {
269 y_nint = ez.o_ymajortick - 1;
271 if (ez.s_ymax == TRUE) {
273 y_nint = ez.o_ymajortick - 1;
276 /* calculate increment between major axis in world coordinates */
278 xw_tickinc = (xgw_max - xgw_min) / x_nint;
279 yw_tickinc = (ygw_max - ygw_min) / y_nint;
281 /* we have now calcuated xgw_min, xyw_max, ygw_min, & ygw_max */
283 /* set the number of decimal point to users' setting or default */
284 /* Two formats for numbers
286 Exponent: -n.fffE+eee
289 if (ez.s_lxfrac == TRUE)
290 x_frac = ez.v_lxfrac;
294 if (ez.s_lyfrac == TRUE)
295 y_frac = ez.v_lyfrac;
299 make_numfmt (x_numfmt, &x_fldwid, &x_frac, xgw_min, xgw_max, x_nint);
300 make_numfmt (y_numfmt, &y_fldwid, &y_frac, ygw_min, ygw_max, y_nint);
302 xtl_wid = x_fldwid * charwidth; /* calc size of tick labels */
303 ytl_wid = y_fldwid * charwidth;
304 tl_height = charheight;
306 /* calculate the extent of the plot frame */
308 xp_min = ez.o_xporigin;
309 yp_min = ez.o_yporigin;
310 xp_max = xp_min + ez.o_xlength;
311 yp_max = yp_min + ez.o_ylength;
313 xp_min = clamp (xp_min, 0., 1.);
314 xp_max = clamp (xp_max, 0., 1.);
315 yp_min = clamp (yp_min, 0., 1.);
316 yp_max = clamp (yp_max, 0., 1.);
318 xa_min = xp_min; /* extent of axes */
323 /* adjust frame for title */
325 if (strlen(ez.c_title) != 0)
326 ya_max -= 2.5 * charheight;
327 title_row = ya_max + 0.5 * charheight;
329 /* calculate legend box boundaries */
331 max_leg = 0; /* longest legend in characters */
332 num_leg = 0; /* number of legend titles */
333 for (i = 0; i < ez.i_numcurves; i++)
334 if ((n = strlen(ez.curve[i].legend)) > 0) {
336 max_leg = max(max_leg, n);
339 if (num_leg > 0 && ez.o_legendbox != NOLEGEND) {
340 leg_width = (max_leg + 2) * charwidth;
341 leg_height = num_leg * 3 * charheight;
343 if (ez.s_xlegend == TRUE)
344 xl_max = ez.v_xlegend;
347 if (ez.o_legendbox == OUTSIDE)
348 xa_max -= (leg_width + 0.5 * charwidth);
350 xl_min = xl_max - leg_width;
352 if (ez.s_ylegend == TRUE)
353 yl_max = ez.v_ylegend;
357 yl_min = yl_max - leg_height;
359 sgp2_window (xl_min, yl_min, xl_max, yl_max);
360 sgp2_viewport (xl_min, yl_min, xl_max, yl_max);
362 sgp2_color (ez.clr_legend);
363 sgp2_draw_rect (xl_min, yl_min, xl_max, yl_max);
365 n = 0; /* current legend position */
366 for (i = 0; i < ez.i_numcurves; i++) {
367 double xmin, xmax, xinc, y;
369 if (strlen(ez.curve[i].legend) == 0)
372 xmin = xl_min + 1.0 * charwidth;
373 xmax = xl_max - 1.0 * charwidth;
374 y = yl_max - (2.0 + n * 3) * charheight;
376 sgp2_move_abs (xmin, y + 0.5 * charheight);
377 sgp2_draw_text (ez.curve[i].legend);
378 sgp2_color (ez.curve[i].color);
379 if (ez.curve[i].linestyle != LS_NOLINE) {
380 sgp2_line_style (ez.curve[i].linestyle);
381 sgp2_move_abs (xmin, y);
382 sgp2_line_abs (xmax, y);
384 if (ez.curve[i].symbol > 0) {
385 xinc = (xmax - xmin) / (5 - 1);
386 sgp2_line_style (LS_SOLID);
387 for (j = 0; j < 5; j++) {
388 sgp2_move_abs (xmin + j * xinc, y);
389 symbol(ez.curve[i].symbol,
390 0.5 * charwidth, 0.5 * charheight);
393 ++n; /* move to next legend position */
395 } /* end legend printing */
397 /* calculate the extent of the axes */
399 /*-------------------------*/
400 /* adjust frame for labels */
401 /*-------------------------*/
405 if (strlen(ez.c_xlabel) > 0)
406 ya_min += 3.0 * charheight;
407 xlbl_row = xp_min; /* put x-label on bottom of plot frame */
411 if (strlen(ez.c_ylabel) > 0)
412 xa_min += 3.0 * charwidth; /* reverse charsize because writing */
414 ylbl_col = xp_min + 2 * charwidth;
416 /*------------------------------*/
417 /* adjust frame for tick labels */
418 /*------------------------------*/
420 /* calc offset of tick labels from axes */
422 if (ez.o_xaxis == NOAXIS || ez.o_xtlabel == FALSE)
424 else if (ez.o_xticks == BELOW)
425 xtl_ofs = -2.5 * charheight;
426 else if (ez.o_xticks == ABOVE)
427 xtl_ofs = 1.5 * charheight;
429 if (ez.o_yaxis == NOAXIS || ez.o_ytlabel == FALSE)
431 else if (ez.o_yticks == LEFT)
432 ytl_ofs = -(1 + y_fldwid) * charwidth;
433 else if (ez.o_yticks == RIGHT)
434 ytl_ofs = 1.5 * charwidth;
436 /* see if need to shrink axis extents and/or tick extents */
438 if (xtl_ofs != 0.0 && ez.s_ycross == FALSE) {
439 if (ez.o_xticks == BELOW) {
440 ya_min += 2.5 * charheight;
442 } else if (ez.o_xticks == ABOVE) {
444 yt_min = ya_min + 2.5 * charheight;
446 } else /* noaxis, no t-labels, or user set cross */
449 if (ytl_ofs != 0.0 && ez.s_xcross == FALSE) {
450 if (ez.o_yticks == LEFT) {
451 xa_min += (1 + y_fldwid) * charwidth;
453 } else if (ez.o_yticks == RIGHT) {
455 xt_min = xa_min + ytl_ofs + y_fldwid * charwidth;
463 /* decrease size of graph, if necessary, to accommadate space */
464 /* between axis boundary and boundary of ticks */
469 if (ez.o_xaxis == NOAXIS || ez.o_xtlabel == FALSE)
471 if (ez.o_yaxis == NOAXIS || ez.o_ytlabel == FALSE)
474 if (ez.o_grid == TRUE) {
475 if (x_added_ticks < 0)
477 if (y_added_ticks < 0)
481 if (x_added_ticks < 0)
483 if (ez.o_yticks == LEFT || ez.s_ycross)
489 if (y_added_ticks < 0)
491 if (ez.o_xticks == BELOW || ez.s_xcross)
497 xn_tickinc = (xt_max - xt_min) / (x_nint + x_added_ticks);
498 yn_tickinc = (yt_max - yt_min) / (y_nint + y_added_ticks);
500 xt_min += 0.5 * x_added_ticks * xn_tickinc;
501 xt_max -= 0.5 * x_added_ticks * xn_tickinc;
502 yt_min += 0.5 * y_added_ticks * yn_tickinc;
503 yt_max -= 0.5 * y_added_ticks * yn_tickinc;
510 /*---------------------------------------------------------------------------*/
514 sgp2_line_style (LS_SOLID);
517 /* Convert WC in graph boundary to axis boundary */
519 double xmin, xmax, ymin, ymax;
521 sgp2_window (xgw_min, ygw_min, xgw_max, ygw_max); /* Graph boundary */
522 sgp2_viewport (xgn_min, ygn_min, xgn_max, ygn_max);
524 ndc_to_wc (xa_min, ya_min, &xmin, &ymin); /* calc WC of axis */
525 ndc_to_wc (xa_max, ya_max, &xmax, &ymax); /* boundaries */
527 sgp2_window (xmin, ymin, xmax, ymax); /* Set window to axis */
528 sgp2_viewport (xa_min, ya_min, xa_max, ya_max); /* boundaries */
531 symwidth = charwidth * (xgw_max - xgw_min);
532 symheight = charheight * (ygw_max - ygw_min);
534 for (ic = 0; ic < ez.i_numcurves; ic++) {
535 sgp2_color (ez.curve[ic].color);
536 if (ez.curve[ic].linestyle != LS_NOLINE) {
537 sgp2_line_style (ez.curve[ic].linestyle);
538 sgp2_polyline_abs (ez.curve[ic].x, ez.curve[ic].y, ez.curve[ic].numpts);
540 if (ez.curve[ic].symbol > 0) {
541 sgp2_line_style(LS_SOLID);
542 sgp2_move_abs (ez.curve[ic].x[0], ez.curve[ic].y[0]);
543 symbol (ez.curve[ic].symbol, symwidth, symheight);
544 for (i = 1; i < ez.curve[ic].numpts; i++)
545 if (i % ez.curve[ic].symfreq == 0 || i == ez.curve[ic].numpts - 1) {
546 sgp2_move_abs (ez.curve[ic].x[i], ez.curve[ic].y[i]);
547 symbol (ez.curve[ic].symbol, symwidth, symheight);
552 if (ez.o_ufinish == FALSE)
560 * drawaxis INTERNAL routine to draw axis & label them
566 static void drawaxis(void)
568 double xticklen = 0, yticklen = 0; /* length of ticks in NDC */
569 double minorinc; /* increment between minor axes */
570 double xaxispos, yaxispos; /* crossing of axes */
572 bool axis_near; /* TRUE if axis too close to print t-label */
577 charsize (charwidth, charheight);
580 if (ez.o_xticks == ABOVE)
581 xticklen = charheight;
582 else if (ez.o_xticks == BELOW)
583 xticklen = -charheight;
585 if (ez.o_yticks == RIGHT)
586 yticklen = charwidth;
587 else if (ez.o_yticks == LEFT)
588 yticklen = -charwidth;
590 sgp2_window (xp_min, yp_min, xp_max, yp_max);
591 sgp2_viewport (xp_min, yp_min, xp_max, yp_max);
593 if (strlen (ez.c_title) != 0) {
594 sgp2_move_abs (xa_min + (xa_max-xa_min)/2 - strlen(ez.c_title)*charwidth, title_row);
595 charsize (charwidth * 2.0, charheight * 2.0);
596 settextclr (ez.clr_title, -1);
597 sgp2_draw_text (ez.c_title);
598 charsize (charwidth, charheight);
601 if (ez.o_grid == TRUE || ez.o_box == TRUE) {
602 sgp2_color (ez.clr_axis);
603 sgp2_move_abs (xa_min, ya_min);
604 sgp2_line_abs (xa_max, ya_min);
605 sgp2_line_abs (xa_max, ya_max);
606 sgp2_line_abs (xa_min, ya_max);
607 sgp2_line_abs (xa_min, ya_min);
610 /* calculate position of axes */
613 if (ez.s_ycross == TRUE) { /* convert users' world-coord */
614 xaxispos = ez.v_ycross; /* axis to its position in NDC */
615 sgp2_window (xgw_min, ygw_min, xgw_max, ygw_max);
616 sgp2_viewport (xgn_min, ygn_min, xgn_max, ygn_max);
618 wc_to_ndc (x, xaxispos, &x, &xaxispos);
623 if (ez.s_xcross == TRUE) { /* convert users' world-coord */
624 yaxispos = ez.v_xcross; /* axis to its NDC position */
625 sgp2_window (xgw_min, ygw_min, xgw_max, ygw_max);
626 sgp2_viewport (xgn_min, ygn_min, xgn_max, ygn_max);
628 wc_to_ndc (yaxispos, y, &yaxispos, &y);
636 if (ez.o_xaxis == LINEAR) {
637 sgp2_window (xp_min, yp_min, xp_max, yp_max);
638 sgp2_viewport (xp_min, yp_min, xp_max, yp_max);
642 sgp2_color (ez.clr_axis);
643 if (ez.o_tag && !ez.o_grid && !ez.o_box && ez.s_xcross) {
644 sgp2_move_abs (xa_min, xaxispos - charheight);
645 sgp2_line_abs (xa_min, xaxispos + charheight);
647 sgp2_move_abs (xa_min, xaxispos);
648 sgp2_line_abs (xa_max, xaxispos);
649 if (ez.o_tag && !ez.o_grid && !ez.o_box) {
650 sgp2_move_abs (xa_max, xaxispos - charheight);
651 sgp2_line_abs (xa_max, xaxispos + charheight);
654 if (ez.o_grid == TRUE) {
655 sgp2_color (ez.clr_grid);
656 for (i = 0; i <= x_nint; i++) {
657 sgp2_move_abs (xt_min + xn_tickinc * i, ya_max);
658 sgp2_line_abs (xt_min + xn_tickinc * i, ya_min);
661 sgp2_move_abs (xa_min + (xa_max-xa_min)/2 - strlen(ez.c_xlabel)*charwidth, xlbl_row);
662 charsize (charwidth * 2.0, charheight * 2.0);
663 settextclr (ez.clr_label, -1);
664 sgp2_draw_text (ez.c_xlabel);
665 charsize (charwidth, charheight);
666 minorinc = xn_tickinc / (ez.o_xminortick + 1);
668 for (i = 0; i <= x_nint; i++) {
669 x = xt_min + xn_tickinc * i;
670 sgp2_color (ez.clr_axis);
671 sgp2_move_abs (x, xaxispos);
672 sgp2_line_abs (x, xaxispos + xticklen);
674 for (j = 1; j <= ez.o_xminortick; j++) {
675 x2 = x + minorinc * j;
676 sgp2_move_abs (x2, xaxispos);
677 sgp2_line_abs (x2, xaxispos + TICKRATIO * xticklen);
680 if (xaxispos + xtl_ofs > ya_min && ez.o_yaxis != NOAXIS) {
683 xw = xgw_min + i * xw_tickinc;
684 sgp2_window (xgw_min, ygw_min, xgw_max, ygw_max);
685 sgp2_viewport (xgn_min, ygn_min, xgn_max, ygn_max);
686 wc_to_ndc (xw, y, &x, &y);
687 sgp2_window (xp_min, yp_min, xp_max, yp_max);
688 sgp2_viewport (xp_min, yp_min, xp_max, yp_max);
690 if (ez.o_yticks == RIGHT && d >= 0 && d < 0.9 * xn_tickinc)
692 if (ez.o_yticks == LEFT && d <= 0 && d > -0.9 * xn_tickinc)
696 if (ez.o_xtlabel == TRUE && axis_near == FALSE) {
697 snprintf (str, sizeof(str), x_numfmt, xgw_min + xw_tickinc * i);
698 numstr = str_skip_head (str, " ");
699 sgp2_move_abs (x-strlen(numstr)*charwidth/2,xaxispos + xtl_ofs);
700 settextclr (ez.clr_number, -1);
701 sgp2_draw_text (numstr);
711 if (ez.o_yaxis == LINEAR) {
712 sgp2_window (xp_min, yp_min, xp_max, yp_max);
713 sgp2_viewport (xp_min, yp_min, xp_max, yp_max);
715 sgp2_color (ez.clr_axis);
716 if (ez.o_tag && !ez.o_grid && !ez.o_box && ez.s_ycross) {
717 sgp2_move_abs (yaxispos - charwidth, ya_min);
718 sgp2_line_abs (yaxispos + charwidth, ya_min);
720 sgp2_move_abs (yaxispos, ya_min);
721 sgp2_line_abs (yaxispos, ya_max);
722 if (ez.o_tag && !ez.o_grid && !ez.o_box) {
723 sgp2_move_abs (yaxispos - charwidth, ya_max);
724 sgp2_line_abs (yaxispos + charwidth, ya_max);
727 if (ez.o_grid == TRUE) {
728 sgp2_color (ez.clr_grid);
729 for (i = 0; i <= y_nint; i++) {
730 y = yt_min + yn_tickinc * i;
731 sgp2_move_abs (xa_max, y);
732 sgp2_line_abs (xa_min, y);
735 sgp2_move_abs (ylbl_col,ya_min + (ya_max-ya_min)/2 - strlen(ez.c_ylabel)*charheight);
737 charsize (2 * charheight, 2 * charwidth); /* axis reversed */
738 settextclr (ez.clr_label, -1);
739 sgp2_draw_text (ez.c_ylabel);
741 charsize (charwidth, charheight);
742 minorinc = yn_tickinc / (ez.o_yminortick + 1);
744 for (i = 0; i <= y_nint; i++) {
745 y = yt_min + yn_tickinc * i;
746 sgp2_color (ez.clr_axis);
747 sgp2_move_abs (yaxispos, y);
748 sgp2_line_abs (yaxispos + yticklen, y);
750 for (j = 1; j <= ez.o_yminortick; j++) {
751 y2 = y + minorinc * j;
752 sgp2_move_abs (yaxispos, y2);
753 sgp2_line_abs (yaxispos + TICKRATIO * yticklen, y2);
756 if (yaxispos + ytl_ofs > xa_min && ez.o_xaxis != NOAXIS) {
759 yw = ygw_min + i * yw_tickinc;
760 sgp2_window (xgw_min, ygw_min, xgw_max, ygw_max);
761 sgp2_viewport (xgn_min, ygn_min, xgn_max, ygn_max);
762 wc_to_ndc (x, yw, &x, &y);
763 sgp2_window (xp_min, yp_min, xp_max, yp_max);
764 sgp2_viewport (xp_min, yp_min, xp_max, yp_max);
766 if (ez.o_xticks == ABOVE && d >= 0 && d < 0.9 * yn_tickinc)
768 if (ez.o_xticks == BELOW && d <= 0 && d > -0.9 * yn_tickinc)
771 if (ez.o_ytlabel == TRUE && axis_near == FALSE) {
772 snprintf (str, sizeof(str), y_numfmt, ygw_min + yw_tickinc * i);
773 sgp2_move_abs (yaxispos + ytl_ofs, y - 0.5 * charheight);
774 settextclr (ez.clr_number, -1);
775 sgp2_draw_text (str);
783 symbol (int sym, double symwidth, double symheight)
788 if (sym == SB_CROSS) {
789 sgp2_move_rel (-0.5 * symwidth, -0.5 * symheight);
790 sgp2_line_rel (symwidth, symheight);
791 sgp2_move_rel (-symwidth, 0.0);
792 sgp2_line_rel (symwidth, -symheight);
793 sgp2_move_rel (-0.5 * symwidth, 0.5 * symheight);
794 } else if (sym == SB_PLUS) {
795 sgp2_move_rel (-0.5 * symwidth, 0.0);
796 sgp2_line_rel (symwidth, 0.0);
797 sgp2_move_rel (-0.5 * symwidth, -0.5 * symheight);
798 sgp2_line_rel (0.0, symheight);
799 sgp2_move_rel (0.0, -0.5 * symheight);
800 } else if (sym == SB_BOX) {
801 sgp2_move_rel (-0.5 * symwidth, -0.5 * symheight);
802 sgp2_line_rel (symwidth, 0.0);
803 sgp2_line_rel (0.0, symheight);
804 sgp2_line_rel (-symwidth, 0.0);
805 sgp2_line_rel (0.0, -symheight);
806 sgp2_move_rel (0.5 * symwidth, 0.5 * symheight);
807 } else if (sym == SB_CIRCLE) {
808 sgp2_draw_circle (symwidth);
809 } else if (sym == SB_ERRORBAR) {
810 sgp2_move_rel (-0.5 * symwidth, 0.5 * symheight);
811 sgp2_line_rel (symwidth, 0.0);
812 sgp2_move_rel (-0.5 * symwidth, 0.0);
813 sgp2_line_rel (0.0, -symheight);
814 sgp2_move_rel (-0.5 * symwidth, 0.0);
815 sgp2_line_rel (symwidth, 0.0);
816 sgp2_move_rel (-0.5 * symwidth, 0.5 * symheight);
823 /* EZPLOT Variables */
825 charwidth = DEF_CHARWIDTH; /* KR_FIX: Make these ez.o_ variables */
826 charheight = DEF_CHARHEIGHT;
828 /* EZPLOT & EZSET Variables */
830 strcpy (ez.c_xlabel, "X axis");
831 strcpy (ez.c_ylabel, "Y axis");
832 strcpy (ez.c_title, "");
833 strcpy (ez.c_legend, "");
835 ezplot_firstcall = FALSE;
838 ez.i_plotimmediate = FALSE;
841 ez.o_unknowncurves = FALSE;
844 ez.o_ufinish = FALSE;
857 ez.o_xmajortick = 10;
862 ez.o_color = DEF_CURVE_CLR;
865 ez.o_linestyle = LS_SOLID;
872 ez.o_legendbox = INSIDE;
881 ez.s_xlegend = FALSE;
882 ez.s_ylegend = FALSE;
883 ez.s_textsize = FALSE;
887 ez.d_crtmode = DEF_CRTMODE;
888 ez.d_prtmode = PRTMODE_DEF;
889 ez.d_xprtbuf = XBUF_DEF;
890 ez.d_yprtbuf = YBUF_DEF;
892 ez.clr_axis = C_WHITE; /* set fixed colors */
893 ez.clr_title = (C_CYAN+8);
894 ez.clr_label = (C_CYAN+8);
895 ez.clr_legend = (C_RED+8);
896 ez.clr_number = (C_GREEN+8);
897 ez.clr_grid = (C_BLACK+8);
902 static char errmsg[] = "EZFREE in EZPLOT";
905 for (i = 0; i < ez.i_numcurves; i++) {
906 delete ez.curve[i].x;
907 delete ez.curve[i].y;