1 /*****************************************************************************
5 ** Purpose: Header file for EZplot library
7 ** This is part of the CTSim program
8 ** Copyright (C) 1983-2000 Kevin Rosenberg
10 ** $Id: ezplot.h,v 1.10 2000/07/28 08:28:08 kevin Exp $
12 ** This program is free software; you can redistribute it and/or modify
13 ** it under the terms of the GNU General Public License (version 2) as
14 ** published by the Free Software Foundation.
16 ** This program is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ** GNU General Public License for more details.
21 ** You should have received a copy of the GNU General Public License
22 ** along with this program; if not, write to the Free Software
23 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 ******************************************************************************/
34 #include "ctsupport.h"
49 EZPlotCurve (const double* x, const double* y, int n, int color, int linestyle, int symbol, int sumbolFreq, const string& legend);
54 /*----------------------------------------------------------------------*/
55 /* GLOBAL VARIABLES */
56 /*----------------------------------------------------------------------*/
58 /* axis definitions */
59 #define LINEAR 1 /* linear axis */
60 #define LOG 2 /* logrithmic axis */
61 #define NOAXIS 3 /* don't plot axis */
63 /* tick definitions */
78 /* symbol definitions */
86 #define INSIDE 1 /* values of o_legendbox */
90 /*-----------------------------------------------------------------------------
94 * i_ Internal variable
97 * Normal variable that is user modifiable
98 * These variables must always have a valid value
100 * Variables controlling devices
101 * clr_ Color variable
102 * Holds a color value
103 * c_ Character string variable
104 * Contains a character string
106 * User modifiable variable associated with the set variable (s_)
107 * These variables do not always have a valid value
108 * These variables change assumption EZPLOT makes about the plot
110 * TRUE if associated value variable (v_) has been set by the user
111 *---------------------------------------------------------------------------*/
116 typedef vector<EZPlotCurve*>::iterator EZPlotCurveIterator;
117 typedef vector<EZPlotCurve*>::const_iterator EZPlotCurveConstIterator;
122 vector<class EZPlotCurve*> m_vecCurves;
125 int clr_axis; /* color of all axis lines */
126 int clr_title; /* color of main title */
127 int clr_label; /* color of axis labels */
128 int clr_legend; /* color of legend box */
129 int clr_grid; /* color of grid lines */
130 int clr_number; /* color of axis number labels */
133 int o_reqcurves; /* # of curves specified in CURVES command */
134 /* default value is 1, so that a call to EZPLOT
136 bool o_unknowncurves; /* TRUE when the user specifies that the
137 number of curves is unknown */
139 double o_xporigin, o_yporigin; /* origin of plot frame in NDC */
140 double o_xlength, o_ylength; /* length of plot frame in NDC */
142 string c_xlabel; /* label for x axis */
143 string c_ylabel; /* label for y axis */
144 string c_title; /* title to print above graph */
145 string c_legend;; /* current legend specified */
147 int o_linestyle, o_color; /* style to use for curves all subsequent curves to EZPLOT */
148 bool o_xaxis, o_yaxis; /* Specifies where axis & labels are drawn */
149 bool o_grid; /* Flag to draw a grid at major ticks */
150 bool o_box; /* Flag to draw a box around the graph */
152 int o_xticks, o_yticks; /* direction to draw tick marks */
153 bool o_xtlabel, o_ytlabel; /* TRUE if label tick marks */
155 int o_xmajortick, o_ymajortick; /* number of major ticks to draw */
156 int o_xminortick, o_yminortick; /* number of minor ticks between major ticks */
158 int o_symbol; /* Symbol type, (0 = no symbol) */
159 int o_symfreq; /* frequency to draw symbols at curve points */
161 int o_legendbox; /* controls whether legend is inside or outside of the axis extents */
162 int o_tag; /* controls whether to draw tag at end of axes */
164 // VALUE & SET variables
165 double v_xmin, v_xmax, v_ymin, v_ymax; /* user supplied axis endpoints */
166 bool s_xmin, s_xmax, s_ymin, s_ymax; /* TRUE is endpoint has been set */
167 double v_xtitle, v_ytitle; /* NDC position to plot title */
168 bool s_xtitle, s_ytitle; /* TRUE if set position for title */
169 double v_xcross, v_ycross; /* position that axes cross */
170 bool s_xcross, s_ycross; /* TRUE if set axes cross position */
171 double v_xlegend, v_ylegend; /* upper-left position of legend box in NDC */
172 bool s_xlegend, s_ylegend; /* TRUE if set position of legend box */
173 int v_lxfrac, v_lyfrac; /* number of digits to right of decimal place */
174 bool s_lxfrac, s_lyfrac; /* TRUE if set number of fractional digits */
175 double v_textsize; /* size of text in NDC */
176 bool s_textsize; /* TRUE if user set size of text */
179 double charheight; /* Height of characters in NDC */
180 double charwidth; /* Height of characters in NDC */
181 double xp_min, xp_max, yp_min, yp_max; /* boundry of plot frame in NDC */
182 double xa_min, xa_max, ya_min, ya_max; /* extent of axes in NDC */
183 double xgw_min, xgw_max, ygw_min, ygw_max; /* boundary of graph in input coords */
184 double xgn_min, xgn_max, ygn_min, ygn_max; /* boundy of graph in NDC */
185 double xt_min, xt_max, yt_min, yt_max; /* boundary of axis ticks */
186 double xl_min, xl_max, yl_min, yl_max; /* boundary of legend box */
187 double title_row; /* y-coord of title row */
188 double xtl_ofs; /* Offset y-coord of x tick labels from axis */
189 double ytl_ofs; /* Offset x-coord of y tick labels from axis */
190 double xlbl_row; /* row of x label in world coord */
191 double ylbl_col; /* column of y label in world coord */
192 double xw_tickinc, yw_tickinc; /* increment between major ticks in WC */
193 double xn_tickinc, yn_tickinc; /* increment between major ticks in NDC */
194 int x_nint, y_nint; /* number of intervals along x & y axes */
195 int x_fldwid, x_frac; /* numeric field sizes & number of digits */
196 int y_fldwid, y_frac; /* in fraction of number, used for printf() */
197 double xtl_wid, ytl_wid; /* length of ticks labels in NDC */
198 double tl_height; /* height of tick labels in NDC */
199 char x_numfmt[20]; /* format to print x tick labels */
200 char y_numfmt[20]; /* format to print y tick labels */
203 void symbol (int sym, double symwidth, double symheight);
204 void make_numfmt(char *fmtstr, int *fldwid, int *nfrac, double min, double max, int nint);
205 int axis_scale (double min, double max, int nint, double *minp, double *maxp, int *nintp);
211 bool ezcmd (char *comm);
213 void bad_option(char *opt);
214 static void initkw(void);
217 static bool ezset_initialized;
223 int ezset (char *command);
225 void addCurve (const float* x, const double* y, int num);
226 void addCurve (const double* x, const double* y, int num);
227 void addCurve (const double* y, int n);
232 /*----------------------------------------------------------------------*/
234 /*----------------------------------------------------------------------*/
252 #define S_UNKNOWN -22
255 #define S_XLEGEND -25
256 #define S_YLEGEND -26
263 #define S_XLENGTH -33
264 #define S_YLENGTH -34
270 #define S_NOLABEL -40
273 #define S_XAUTOSCALE -43
274 #define S_YAUTOSCALE -44
283 #define S_NOXAXIS -53
284 #define S_NOYAXIS -54
285 #define S_XPORIGIN -55
286 #define S_YPORIGIN -56
293 #define S_RESTORE -63
296 #define S_INTERACTIVE -68
304 #define S_NOGRID -103
308 #define S_LEGENDBOX -107
311 #define S_TEXTSIZE -120