1 /*****************************************************************************
2 ** This is part of the CTSim program
3 ** Copyright (C) 1983-2000 Kevin Rosenberg
5 ** $Id: ezplot.h,v 1.6 2000/06/18 10:27:11 kevin Exp $
7 ** This program is free software; you can redistribute it and/or modify
8 ** it under the terms of the GNU General Public License (version 2) as
9 ** published by the Free Software Foundation.
11 ** This program is distributed in the hope that it will be useful,
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ** GNU General Public License for more details.
16 ** You should have received a copy of the GNU General Public License
17 ** along with this program; if not, write to the Free Software
18 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ******************************************************************************/
21 /*----------------------------------------------------------------------*/
24 /*----------------------------------------------------------------------*/
39 #define MAXLABEL 40 /* maximum length of axis label */
40 #define MAXTITLE 40 /* maximum length of a title */
41 #define MAXLEGEND 20 /* maximum length of a legend */
42 #define MAXCURVES 10 /* maximum number of curves that can be plotted */
43 #define MAXPTS 200 /* max number of points that can be read with
44 DATA command in INTERACTIVE mode */
53 char legend[MAXLEGEND+1];
60 /*----------------------------------------------------------------------*/
62 /*----------------------------------------------------------------------*/
101 #define S_XAUTOSCALE -43
102 #define S_YAUTOSCALE -44
111 #define S_NOXAXIS -53
112 #define S_NOYAXIS -54
113 #define S_XPORIGIN -55
114 #define S_YPORIGIN -56
121 #define S_RESTORE -63
123 #define S_UFINISH -65
126 #define S_INTERACTIVE -68
134 #define S_NOGRID -103
138 #define S_LEGENDBOX -107
144 #define S_TEXTSIZE -120
147 #define S_PRTMODE -123
149 /*----------------------------------------------------------------------*/
150 /* GLOBAL VARIABLES */
151 /*----------------------------------------------------------------------*/
153 /* axis definitions */
154 #define LINEAR 1 /* linear axis */
155 #define LOG 2 /* logrithmic axis */
156 #define NOAXIS 3 /* don't plot axis */
158 /* tick definitions */
173 /* symbol definitions */
178 #define SB_ERRORBAR 5
181 #define INSIDE 1 /* values of o_legendbox */
185 /*-----------------------------------------------------------------------------
189 * i_ Internal variable
192 * Normal variable that is user modifiable
193 * These variables must always have a valid value
195 * Variables controlling devices
196 * clr_ Color variable
197 * Holds a color value
198 * c_ Character string variable
199 * Contains a character string
201 * User modifiable variable associated with the set variable (s_)
202 * These variables do not always have a valid value
203 * These variables change assumption EZPLOT makes about the plot
205 * TRUE if associated value variable (v_) has been set by the user
206 *---------------------------------------------------------------------------*/
215 struct ezp_curve_st curve[MAXCURVES];
217 /*--------------------*/
218 /* INTERNAL VARIABLES */
219 /*--------------------*/
221 bool i_plotimmediate; /* indicates that a call to EZPLOT is a signal
222 to print all received arrays. EZSET uses
223 this variable to force EZPLOT to replot
225 int i_numcurves; /* number of curves received by EZPLOT */
227 /*------------------*/
228 /* DEVICE VARIABLES */
229 /*------------------*/
231 bool d_usecrt; /* TRUE if want to use CRT as output device */
232 bool d_useprt; /* TRUE if wamt to use printer as output device */
234 int d_crtmode; /* Controls which crt mode to use for plot */
235 int d_prtmode; /* Controls mode of printer output */
237 int d_xprtbuf, d_yprtbuf; /* Size of printer buffer in pixels */
239 /*-----------------*/
240 /* COLOR VARIABLES */
241 /*-----------------*/
243 int clr_axis; /* color of all axis lines */
244 int clr_title; /* color of main title */
245 int clr_label; /* color of axis labels */
246 int clr_legend; /* color of legend box */
247 int clr_grid; /* color of grid lines */
248 int clr_number; /* color of axis number labels */
250 /*------------------*/
251 /* OPTION VARIABLES */
252 /*------------------*/
254 int o_reqcurves; /* # of curves specified in CURVES command */
255 /* default value is 1, so that a call to EZPLOT
257 bool o_unknowncurves; /* TRUE when the user specifies that the
258 number of curves is unknown */
260 bool o_ustart, o_ufinish; /* TRUE if user initiates or terminate sgp */
262 double o_xporigin, o_yporigin; /* origin of plot frame in NDC */
263 double o_xlength, o_ylength; /* length of plot frame in NDC */
265 char c_xlabel[MAXLABEL+1]; /* label for x axis */
266 char c_ylabel[MAXLABEL+1]; /* label for y axis */
267 char c_title[MAXTITLE+1]; /* title to print above graph */
268 char c_legend[MAXLEGEND+1]; /* current legend specified */
270 int o_linestyle, o_color; /* style to use for curves all subsequent */
271 /* curves to EZPLOT */
272 bool o_xaxis, o_yaxis; /* Specifies where axis & labels are drawn */
273 bool o_grid; /* Flag to draw a grid at major ticks */
274 bool o_box; /* Flag to draw a box around the graph */
276 int o_xticks, o_yticks; /* direction to draw tick marks */
277 bool o_xtlabel, o_ytlabel; /* TRUE if label tick marks */
279 int o_xmajortick, o_ymajortick; /* number of major ticks to draw */
280 int o_xminortick, o_yminortick; /* number of minor ticks between major ticks */
282 int o_symbol; /* Symbol type, (0 = no symbol) */
283 int o_symfreq; /* frequency to draw symbols at curve points */
285 int o_legendbox; /* controls whether legend is inside */
286 /* or outside of the axis extents */
287 int o_tag; /* controls whether to draw tag at end of axes */
289 /*-----------------------*/
290 /* VALUE & SET variables */
291 /*-----------------------*/
293 double v_xmin, v_xmax, v_ymin, v_ymax; /* user supplied axis endpoints */
294 bool s_xmin, s_xmax, s_ymin, s_ymax; /* TRUE is endpoint has been set */
296 double v_xtitle, v_ytitle; /* NDC position to plot title */
297 bool s_xtitle, s_ytitle; /* TRUE if set position for title */
298 double v_xcross, v_ycross; /* position that axes cross */
299 bool s_xcross, s_ycross; /* TRUE if set axes cross position */
301 double v_xlegend, v_ylegend; /* upper-left position of legend box in NDC */
302 bool s_xlegend, s_ylegend; /* TRUE if set position of legend box */
304 int v_lxfrac, v_lyfrac; /* number of digits to right of decimal place */
305 bool s_lxfrac, s_lyfrac; /* TRUE if set number of fractional digits */
307 double v_textsize; /* size of text in NDC */
308 bool s_textsize; /* TRUE if user set size of text */
310 }; /* end of EZPLOT VARIABLES */
314 extern struct ezplot_var ez;
315 extern bool ezplot_firstcall; /* set to false on first call to EZSET or EZPLOT */
319 SGP_ID ezplot(double x[], double y[], int num);
325 int ezset(char *command);
328 void ezplot_1d(double *y, int n);
331 void make_numfmt(char *fmtstr, int *fldwid, int *nfrac, double min, double max, int nint);
334 int axis_scale (double min, double max, int nint, double *minp, double *maxp, int *nintp);