1 /*****************************************************************************
6 ** This is part of the CTSim program
7 ** Copyright (C) 1983-2000 Kevin Rosenberg
9 ** $Id: ezplot.cpp,v 1.3 2000/06/20 17:54:51 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 (float x[], double y[], int num)
131 for (int i = 0; i < num; i++)
139 ezplot (double x[], double y[], int num)
141 unsigned int size, i;
144 if (ez.i_plotimmediate == TRUE) {
152 if (ezplot_firstcall == TRUE)
155 if (ez.o_unknowncurves == FALSE && ez.i_numcurves >= ez.o_reqcurves)
158 if (ez.i_numcurves < MAXCURVES &&
159 (ez.o_unknowncurves == TRUE || ez.i_numcurves < ez.o_reqcurves)) {
160 size = num * sizeof(double);
161 ez.curve[ez.i_numcurves].x = new double [size];
162 ez.curve[ez.i_numcurves].y = new double [size];
163 for (i = 0; i < num; i++) {
164 ez.curve[ez.i_numcurves].x[i] = x[i];
165 ez.curve[ez.i_numcurves].y[i] = y[i];
167 ez.curve[ez.i_numcurves].numpts = num;
168 ez.curve[ez.i_numcurves].color = ez.o_color;
169 ez.curve[ez.i_numcurves].linestyle = ez.o_linestyle;
170 ez.curve[ez.i_numcurves].symbol = ez.o_symbol;
171 ez.curve[ez.i_numcurves].symfreq = ez.o_symfreq;
172 strncpy (ez.curve[ez.i_numcurves].legend, ez.c_legend, MAXLEGEND);
176 if (ez.o_unknowncurves == FALSE && ez.i_numcurves >= ez.o_reqcurves) {
186 * plot INTERNAL: Plots all curves collected by ezplot()
192 * This routine plots the curves that have stored by ezplot().
198 * drawaxis() & make_numfmt()
201 static int plot (SGP_ID *gid)
203 double xmin, xmax; /* extend of curves in world coord */
205 double x_added_ticks; /* number of tick spaces added to axis */
206 double y_added_ticks;
207 double symwidth, symheight; /* size of symbol in NDC */
208 double leg_width, leg_height; /* size of legend box */
209 int num_leg; /* number of legend titles */
210 int max_leg; /* longest legend in characters */
213 if (ez.i_numcurves <= 0)
216 if (ez.o_ustart == FALSE && *gid == NULL) {
217 *gid = sgp2_init (0, 0, "Ezplot");
220 if (ez.s_textsize == TRUE)
221 charheight = ez.v_textsize;
223 charheight = DEF_CHARHEIGHT;
225 gp_set_aspect (CRTDEV, 1.0);
227 xmin = xmax = ez.curve[0].x[0];
228 ymin = ymax = ez.curve[0].y[0];
230 for (ic = 0; ic < ez.i_numcurves; ic++) {
231 for (ip = 0; ip < ez.curve[ic].numpts; ip++) {
232 if (ez.curve[ic].x[ip] > xmax)
233 xmax = ez.curve[ic].x[ip];
234 else if (ez.curve[ic].x[ip] < xmin)
235 xmin = ez.curve[ic].x[ip];
236 if (ez.curve[ic].y[ip] > ymax)
237 ymax = ez.curve[ic].y[ip];
238 else if (ez.curve[ic].y[ip] < ymin)
239 ymin = ez.curve[ic].y[ip];
243 /* extend graph limits for user defined axis cross positions */
245 if (ez.s_xcross == TRUE)
247 if (ez.v_xcross < xmin)
249 else if (ez.v_xcross > xmax)
253 if (ez.s_ycross == TRUE)
255 if (ez.v_ycross < ymin)
257 else if (ez.v_ycross > ymax)
261 /* find nice endpoints for axes */
263 axis_scale (xmin, xmax, ez.o_xmajortick - 1, &xgw_min, &xgw_max, &x_nint);
264 axis_scale (ymin, ymax, ez.o_ymajortick - 1, &ygw_min, &ygw_max, &y_nint);
266 /* check if user set x-axis extents */
268 if (ez.s_xmin == TRUE) {
270 x_nint = ez.o_xmajortick - 1;
272 if (ez.s_xmax == TRUE) {
274 x_nint = ez.o_xmajortick - 1;
277 /* check if user set y-axis extents */
279 if (ez.s_ymin == TRUE) {
281 y_nint = ez.o_ymajortick - 1;
283 if (ez.s_ymax == TRUE) {
285 y_nint = ez.o_ymajortick - 1;
288 /* calculate increment between major axis in world coordinates */
290 xw_tickinc = (xgw_max - xgw_min) / x_nint;
291 yw_tickinc = (ygw_max - ygw_min) / y_nint;
293 /* we have now calcuated xgw_min, xyw_max, ygw_min, & ygw_max */
295 /* set the number of decimal point to users' setting or default */
296 /* Two formats for numbers
298 Exponent: -n.fffE+eee
301 if (ez.s_lxfrac == TRUE)
302 x_frac = ez.v_lxfrac;
306 if (ez.s_lyfrac == TRUE)
307 y_frac = ez.v_lyfrac;
311 make_numfmt (x_numfmt, &x_fldwid, &x_frac, xgw_min, xgw_max, x_nint);
312 make_numfmt (y_numfmt, &y_fldwid, &y_frac, ygw_min, ygw_max, y_nint);
314 xtl_wid = x_fldwid * charwidth; /* calc size of tick labels */
315 ytl_wid = y_fldwid * charwidth;
316 tl_height = charheight;
318 /* calculate the extent of the plot frame */
320 xp_min = ez.o_xporigin;
321 yp_min = ez.o_yporigin;
322 xp_max = xp_min + ez.o_xlength;
323 yp_max = yp_min + ez.o_ylength;
325 xp_min = clamp (xp_min, 0., 1.);
326 xp_max = clamp (xp_max, 0., 1.);
327 yp_min = clamp (yp_min, 0., 1.);
328 yp_max = clamp (yp_max, 0., 1.);
330 xa_min = xp_min; /* extent of axes */
335 /* adjust frame for title */
337 if (strlen(ez.c_title) != 0)
338 ya_max -= 2.5 * charheight;
339 title_row = ya_max + 0.5 * charheight;
341 /* calculate legend box boundaries */
343 max_leg = 0; /* longest legend in characters */
344 num_leg = 0; /* number of legend titles */
345 for (i = 0; i < ez.i_numcurves; i++)
346 if ((n = strlen(ez.curve[i].legend)) > 0) {
348 max_leg = max(max_leg, n);
351 if (num_leg > 0 && ez.o_legendbox != NOLEGEND) {
352 leg_width = (max_leg + 2) * charwidth;
353 leg_height = num_leg * 3 * charheight;
355 if (ez.s_xlegend == TRUE)
356 xl_max = ez.v_xlegend;
359 if (ez.o_legendbox == OUTSIDE)
360 xa_max -= (leg_width + 0.5 * charwidth);
362 xl_min = xl_max - leg_width;
364 if (ez.s_ylegend == TRUE)
365 yl_max = ez.v_ylegend;
369 yl_min = yl_max - leg_height;
371 sgp2_window (xl_min, yl_min, xl_max, yl_max);
372 sgp2_viewport (xl_min, yl_min, xl_max, yl_max);
374 sgp2_color (ez.clr_legend);
375 sgp2_draw_rect (xl_min, yl_min, xl_max, yl_max);
377 n = 0; /* current legend position */
378 for (i = 0; i < ez.i_numcurves; i++) {
379 double xmin, xmax, xinc, y;
381 if (strlen(ez.curve[i].legend) == 0)
384 xmin = xl_min + 1.0 * charwidth;
385 xmax = xl_max - 1.0 * charwidth;
386 y = yl_max - (2.0 + n * 3) * charheight;
388 sgp2_move_abs (xmin, y + 0.5 * charheight);
389 sgp2_draw_text (ez.curve[i].legend);
390 sgp2_color (ez.curve[i].color);
391 if (ez.curve[i].linestyle != LS_NOLINE) {
392 sgp2_line_style (ez.curve[i].linestyle);
393 sgp2_move_abs (xmin, y);
394 sgp2_line_abs (xmax, y);
396 if (ez.curve[i].symbol > 0) {
397 xinc = (xmax - xmin) / (5 - 1);
398 sgp2_line_style (LS_SOLID);
399 for (j = 0; j < 5; j++) {
400 sgp2_move_abs (xmin + j * xinc, y);
401 symbol(ez.curve[i].symbol,
402 0.5 * charwidth, 0.5 * charheight);
405 ++n; /* move to next legend position */
407 } /* end legend printing */
409 /* calculate the extent of the axes */
411 /*-------------------------*/
412 /* adjust frame for labels */
413 /*-------------------------*/
417 if (strlen(ez.c_xlabel) > 0)
418 ya_min += 3.0 * charheight;
419 xlbl_row = xp_min; /* put x-label on bottom of plot frame */
423 if (strlen(ez.c_ylabel) > 0)
424 xa_min += 3.0 * charwidth; /* reverse charsize because writing */
426 ylbl_col = xp_min + 2 * charwidth;
428 /*------------------------------*/
429 /* adjust frame for tick labels */
430 /*------------------------------*/
432 /* calc offset of tick labels from axes */
434 if (ez.o_xaxis == NOAXIS || ez.o_xtlabel == FALSE)
436 else if (ez.o_xticks == BELOW)
437 xtl_ofs = -2.5 * charheight;
438 else if (ez.o_xticks == ABOVE)
439 xtl_ofs = 1.5 * charheight;
441 if (ez.o_yaxis == NOAXIS || ez.o_ytlabel == FALSE)
443 else if (ez.o_yticks == LEFT)
444 ytl_ofs = -(1 + y_fldwid) * charwidth;
445 else if (ez.o_yticks == RIGHT)
446 ytl_ofs = 1.5 * charwidth;
448 /* see if need to shrink axis extents and/or tick extents */
450 if (xtl_ofs != 0.0 && ez.s_ycross == FALSE) {
451 if (ez.o_xticks == BELOW) {
452 ya_min += 2.5 * charheight;
454 } else if (ez.o_xticks == ABOVE) {
456 yt_min = ya_min + 2.5 * charheight;
458 } else /* noaxis, no t-labels, or user set cross */
461 if (ytl_ofs != 0.0 && ez.s_xcross == FALSE) {
462 if (ez.o_yticks == LEFT) {
463 xa_min += (1 + y_fldwid) * charwidth;
465 } else if (ez.o_yticks == RIGHT) {
467 xt_min = xa_min + ytl_ofs + y_fldwid * charwidth;
475 /* decrease size of graph, if necessary, to accommadate space */
476 /* between axis boundary and boundary of ticks */
481 if (ez.o_xaxis == NOAXIS || ez.o_xtlabel == FALSE)
483 if (ez.o_yaxis == NOAXIS || ez.o_ytlabel == FALSE)
486 if (ez.o_grid == TRUE) {
487 if (x_added_ticks < 0)
489 if (y_added_ticks < 0)
493 if (x_added_ticks < 0)
495 if (ez.o_yticks == LEFT || ez.s_ycross)
501 if (y_added_ticks < 0)
503 if (ez.o_xticks == BELOW || ez.s_xcross)
509 xn_tickinc = (xt_max - xt_min) / (x_nint + x_added_ticks);
510 yn_tickinc = (yt_max - yt_min) / (y_nint + y_added_ticks);
512 xt_min += 0.5 * x_added_ticks * xn_tickinc;
513 xt_max -= 0.5 * x_added_ticks * xn_tickinc;
514 yt_min += 0.5 * y_added_ticks * yn_tickinc;
515 yt_max -= 0.5 * y_added_ticks * yn_tickinc;
522 /*---------------------------------------------------------------------------*/
526 sgp2_line_style (LS_SOLID);
529 /* Convert WC in graph boundary to axis boundary */
531 double xmin, xmax, ymin, ymax;
533 sgp2_window (xgw_min, ygw_min, xgw_max, ygw_max); /* Graph boundary */
534 sgp2_viewport (xgn_min, ygn_min, xgn_max, ygn_max);
536 ndc_to_wc (xa_min, ya_min, &xmin, &ymin); /* calc WC of axis */
537 ndc_to_wc (xa_max, ya_max, &xmax, &ymax); /* boundaries */
539 sgp2_window (xmin, ymin, xmax, ymax); /* Set window to axis */
540 sgp2_viewport (xa_min, ya_min, xa_max, ya_max); /* boundaries */
543 symwidth = charwidth * (xgw_max - xgw_min);
544 symheight = charheight * (ygw_max - ygw_min);
546 for (ic = 0; ic < ez.i_numcurves; ic++) {
547 sgp2_color (ez.curve[ic].color);
548 if (ez.curve[ic].linestyle != LS_NOLINE) {
549 sgp2_line_style (ez.curve[ic].linestyle);
550 sgp2_polyline_abs (ez.curve[ic].x, ez.curve[ic].y, ez.curve[ic].numpts);
552 if (ez.curve[ic].symbol > 0) {
553 sgp2_line_style(LS_SOLID);
554 sgp2_move_abs (ez.curve[ic].x[0], ez.curve[ic].y[0]);
555 symbol (ez.curve[ic].symbol, symwidth, symheight);
556 for (i = 1; i < ez.curve[ic].numpts; i++)
557 if (i % ez.curve[ic].symfreq == 0 || i == ez.curve[ic].numpts - 1) {
558 sgp2_move_abs (ez.curve[ic].x[i], ez.curve[ic].y[i]);
559 symbol (ez.curve[ic].symbol, symwidth, symheight);
564 if (ez.o_ufinish == FALSE)
572 * drawaxis INTERNAL routine to draw axis & label them
578 static void drawaxis(void)
580 double xticklen = 0, yticklen = 0; /* length of ticks in NDC */
581 double minorinc; /* increment between minor axes */
582 double xaxispos, yaxispos; /* crossing of axes */
584 bool axis_near; /* TRUE if axis too close to print t-label */
589 charsize (charwidth, charheight);
592 if (ez.o_xticks == ABOVE)
593 xticklen = charheight;
594 else if (ez.o_xticks == BELOW)
595 xticklen = -charheight;
597 if (ez.o_yticks == RIGHT)
598 yticklen = charwidth;
599 else if (ez.o_yticks == LEFT)
600 yticklen = -charwidth;
602 sgp2_window (xp_min, yp_min, xp_max, yp_max);
603 sgp2_viewport (xp_min, yp_min, xp_max, yp_max);
605 if (strlen (ez.c_title) != 0) {
606 sgp2_move_abs (xa_min + (xa_max-xa_min)/2 - strlen(ez.c_title)*charwidth, title_row);
607 charsize (charwidth * 2.0, charheight * 2.0);
608 settextclr (ez.clr_title, -1);
609 sgp2_draw_text (ez.c_title);
610 charsize (charwidth, charheight);
613 if (ez.o_grid == TRUE || ez.o_box == TRUE) {
614 sgp2_color (ez.clr_axis);
615 sgp2_move_abs (xa_min, ya_min);
616 sgp2_line_abs (xa_max, ya_min);
617 sgp2_line_abs (xa_max, ya_max);
618 sgp2_line_abs (xa_min, ya_max);
619 sgp2_line_abs (xa_min, ya_min);
622 /* calculate position of axes */
625 if (ez.s_ycross == TRUE) { /* convert users' world-coord */
626 xaxispos = ez.v_ycross; /* axis to its position in NDC */
627 sgp2_window (xgw_min, ygw_min, xgw_max, ygw_max);
628 sgp2_viewport (xgn_min, ygn_min, xgn_max, ygn_max);
630 wc_to_ndc (x, xaxispos, &x, &xaxispos);
635 if (ez.s_xcross == TRUE) { /* convert users' world-coord */
636 yaxispos = ez.v_xcross; /* axis to its NDC position */
637 sgp2_window (xgw_min, ygw_min, xgw_max, ygw_max);
638 sgp2_viewport (xgn_min, ygn_min, xgn_max, ygn_max);
640 wc_to_ndc (yaxispos, y, &yaxispos, &y);
648 if (ez.o_xaxis == LINEAR) {
649 sgp2_window (xp_min, yp_min, xp_max, yp_max);
650 sgp2_viewport (xp_min, yp_min, xp_max, yp_max);
654 sgp2_color (ez.clr_axis);
655 if (ez.o_tag && !ez.o_grid && !ez.o_box && ez.s_xcross) {
656 sgp2_move_abs (xa_min, xaxispos - charheight);
657 sgp2_line_abs (xa_min, xaxispos + charheight);
659 sgp2_move_abs (xa_min, xaxispos);
660 sgp2_line_abs (xa_max, xaxispos);
661 if (ez.o_tag && !ez.o_grid && !ez.o_box) {
662 sgp2_move_abs (xa_max, xaxispos - charheight);
663 sgp2_line_abs (xa_max, xaxispos + charheight);
666 if (ez.o_grid == TRUE) {
667 sgp2_color (ez.clr_grid);
668 for (i = 0; i <= x_nint; i++) {
669 sgp2_move_abs (xt_min + xn_tickinc * i, ya_max);
670 sgp2_line_abs (xt_min + xn_tickinc * i, ya_min);
673 sgp2_move_abs (xa_min + (xa_max-xa_min)/2 - strlen(ez.c_xlabel)*charwidth, xlbl_row);
674 charsize (charwidth * 2.0, charheight * 2.0);
675 settextclr (ez.clr_label, -1);
676 sgp2_draw_text (ez.c_xlabel);
677 charsize (charwidth, charheight);
678 minorinc = xn_tickinc / (ez.o_xminortick + 1);
680 for (i = 0; i <= x_nint; i++) {
681 x = xt_min + xn_tickinc * i;
682 sgp2_color (ez.clr_axis);
683 sgp2_move_abs (x, xaxispos);
684 sgp2_line_abs (x, xaxispos + xticklen);
686 for (j = 1; j <= ez.o_xminortick; j++) {
687 x2 = x + minorinc * j;
688 sgp2_move_abs (x2, xaxispos);
689 sgp2_line_abs (x2, xaxispos + TICKRATIO * xticklen);
692 if (xaxispos + xtl_ofs > ya_min && ez.o_yaxis != NOAXIS) {
695 xw = xgw_min + i * xw_tickinc;
696 sgp2_window (xgw_min, ygw_min, xgw_max, ygw_max);
697 sgp2_viewport (xgn_min, ygn_min, xgn_max, ygn_max);
698 wc_to_ndc (xw, y, &x, &y);
699 sgp2_window (xp_min, yp_min, xp_max, yp_max);
700 sgp2_viewport (xp_min, yp_min, xp_max, yp_max);
702 if (ez.o_yticks == RIGHT && d >= 0 && d < 0.9 * xn_tickinc)
704 if (ez.o_yticks == LEFT && d <= 0 && d > -0.9 * xn_tickinc)
708 if (ez.o_xtlabel == TRUE && axis_near == FALSE) {
709 snprintf (str, sizeof(str), x_numfmt, xgw_min + xw_tickinc * i);
710 numstr = str_skip_head (str, " ");
711 sgp2_move_abs (x-strlen(numstr)*charwidth/2,xaxispos + xtl_ofs);
712 settextclr (ez.clr_number, -1);
713 sgp2_draw_text (numstr);
723 if (ez.o_yaxis == LINEAR) {
724 sgp2_window (xp_min, yp_min, xp_max, yp_max);
725 sgp2_viewport (xp_min, yp_min, xp_max, yp_max);
727 sgp2_color (ez.clr_axis);
728 if (ez.o_tag && !ez.o_grid && !ez.o_box && ez.s_ycross) {
729 sgp2_move_abs (yaxispos - charwidth, ya_min);
730 sgp2_line_abs (yaxispos + charwidth, ya_min);
732 sgp2_move_abs (yaxispos, ya_min);
733 sgp2_line_abs (yaxispos, ya_max);
734 if (ez.o_tag && !ez.o_grid && !ez.o_box) {
735 sgp2_move_abs (yaxispos - charwidth, ya_max);
736 sgp2_line_abs (yaxispos + charwidth, ya_max);
739 if (ez.o_grid == TRUE) {
740 sgp2_color (ez.clr_grid);
741 for (i = 0; i <= y_nint; i++) {
742 y = yt_min + yn_tickinc * i;
743 sgp2_move_abs (xa_max, y);
744 sgp2_line_abs (xa_min, y);
747 sgp2_move_abs (ylbl_col,ya_min + (ya_max-ya_min)/2 - strlen(ez.c_ylabel)*charheight);
749 charsize (2 * charheight, 2 * charwidth); /* axis reversed */
750 settextclr (ez.clr_label, -1);
751 sgp2_draw_text (ez.c_ylabel);
753 charsize (charwidth, charheight);
754 minorinc = yn_tickinc / (ez.o_yminortick + 1);
756 for (i = 0; i <= y_nint; i++) {
757 y = yt_min + yn_tickinc * i;
758 sgp2_color (ez.clr_axis);
759 sgp2_move_abs (yaxispos, y);
760 sgp2_line_abs (yaxispos + yticklen, y);
762 for (j = 1; j <= ez.o_yminortick; j++) {
763 y2 = y + minorinc * j;
764 sgp2_move_abs (yaxispos, y2);
765 sgp2_line_abs (yaxispos + TICKRATIO * yticklen, y2);
768 if (yaxispos + ytl_ofs > xa_min && ez.o_xaxis != NOAXIS) {
771 yw = ygw_min + i * yw_tickinc;
772 sgp2_window (xgw_min, ygw_min, xgw_max, ygw_max);
773 sgp2_viewport (xgn_min, ygn_min, xgn_max, ygn_max);
774 wc_to_ndc (x, yw, &x, &y);
775 sgp2_window (xp_min, yp_min, xp_max, yp_max);
776 sgp2_viewport (xp_min, yp_min, xp_max, yp_max);
778 if (ez.o_xticks == ABOVE && d >= 0 && d < 0.9 * yn_tickinc)
780 if (ez.o_xticks == BELOW && d <= 0 && d > -0.9 * yn_tickinc)
783 if (ez.o_ytlabel == TRUE && axis_near == FALSE) {
784 snprintf (str, sizeof(str), y_numfmt, ygw_min + yw_tickinc * i);
785 sgp2_move_abs (yaxispos + ytl_ofs, y - 0.5 * charheight);
786 settextclr (ez.clr_number, -1);
787 sgp2_draw_text (str);
795 symbol (int sym, double symwidth, double symheight)
800 if (sym == SB_CROSS) {
801 sgp2_move_rel (-0.5 * symwidth, -0.5 * symheight);
802 sgp2_line_rel (symwidth, symheight);
803 sgp2_move_rel (-symwidth, 0.0);
804 sgp2_line_rel (symwidth, -symheight);
805 sgp2_move_rel (-0.5 * symwidth, 0.5 * symheight);
806 } else if (sym == SB_PLUS) {
807 sgp2_move_rel (-0.5 * symwidth, 0.0);
808 sgp2_line_rel (symwidth, 0.0);
809 sgp2_move_rel (-0.5 * symwidth, -0.5 * symheight);
810 sgp2_line_rel (0.0, symheight);
811 sgp2_move_rel (0.0, -0.5 * symheight);
812 } else if (sym == SB_BOX) {
813 sgp2_move_rel (-0.5 * symwidth, -0.5 * symheight);
814 sgp2_line_rel (symwidth, 0.0);
815 sgp2_line_rel (0.0, symheight);
816 sgp2_line_rel (-symwidth, 0.0);
817 sgp2_line_rel (0.0, -symheight);
818 sgp2_move_rel (0.5 * symwidth, 0.5 * symheight);
819 } else if (sym == SB_CIRCLE) {
820 sgp2_draw_circle (symwidth);
821 } else if (sym == SB_ERRORBAR) {
822 sgp2_move_rel (-0.5 * symwidth, 0.5 * symheight);
823 sgp2_line_rel (symwidth, 0.0);
824 sgp2_move_rel (-0.5 * symwidth, 0.0);
825 sgp2_line_rel (0.0, -symheight);
826 sgp2_move_rel (-0.5 * symwidth, 0.0);
827 sgp2_line_rel (symwidth, 0.0);
828 sgp2_move_rel (-0.5 * symwidth, 0.5 * symheight);
835 /* EZPLOT Variables */
837 charwidth = DEF_CHARWIDTH; /* KR_FIX: Make these ez.o_ variables */
838 charheight = DEF_CHARHEIGHT;
840 /* EZPLOT & EZSET Variables */
842 strcpy (ez.c_xlabel, "X axis");
843 strcpy (ez.c_ylabel, "Y axis");
844 strcpy (ez.c_title, "");
845 strcpy (ez.c_legend, "");
847 ezplot_firstcall = FALSE;
850 ez.i_plotimmediate = FALSE;
853 ez.o_unknowncurves = FALSE;
856 ez.o_ufinish = FALSE;
869 ez.o_xmajortick = 10;
874 ez.o_color = DEF_CURVE_CLR;
877 ez.o_linestyle = LS_SOLID;
884 ez.o_legendbox = INSIDE;
893 ez.s_xlegend = FALSE;
894 ez.s_ylegend = FALSE;
895 ez.s_textsize = FALSE;
899 ez.d_crtmode = DEF_CRTMODE;
900 ez.d_prtmode = PRTMODE_DEF;
901 ez.d_xprtbuf = XBUF_DEF;
902 ez.d_yprtbuf = YBUF_DEF;
904 ez.clr_axis = C_WHITE; /* set fixed colors */
905 ez.clr_title = (C_CYAN+8);
906 ez.clr_label = (C_CYAN+8);
907 ez.clr_legend = (C_RED+8);
908 ez.clr_number = (C_GREEN+8);
909 ez.clr_grid = (C_BLACK+8);
914 static char errmsg[] = "EZFREE in EZPLOT";
917 for (i = 0; i < ez.i_numcurves; i++) {
918 delete ez.curve[i].x;
919 delete ez.curve[i].y;