8
8
static int Supress_convmsg = 0;
9
9
static int N_convmsg = 0;
10
static int beginnum();
13
/* ====================== */
11
22
/* ====================== */
12
23
/* DA - access D as a 2-D array; return as char * */
19
if( r >= Nrecords[Dsel] ) {
20
fprintf( Errfp, "warning: %s data reference (rec=%d field=%d) is out of bounds\n",
21
Eprogname, r+1, c+1 );
24
if( c >= Nfields[Dsel] ) {
25
fprintf( Errfp, "warning: %s data reference (rec=%d field=%d) is out of bounds\n",
26
Eprogname, r+1, c+1 );
29
return( D[ base + ( r * Nfields[Dsel] ) + c ] );
29
base = PLD.dsfirstdf[ PLD.curds ];
31
fprintf( PLS.errfp, "warning: %s data reference (rec=%d field=%d) is out of bounds\n",
32
Eprogname, r+1, c+1 );
36
fprintf( PLS.errfp, "warning: %s data reference (rec=%d field=%d) is out of bounds\n",
37
Eprogname, r+1, c+1 );
40
return( PLD.df[ base + ( r * Nfields ) + c ] );
31
42
/* ====================== */
32
43
/* FDA - access D as a 2-D array; return as double;
33
44
For non-plottables 0.0 is returned, but Econv_error may be called to see if
34
45
there was a conversion error */
35
double fda( r, c, ax )
46
double PL_fda( r, c, ax )
80
91
/* ============================= */
81
92
/* GETBOX - extract two coordinate pairs (four posex's) from val */
82
getbox( parmname, val, x1, y1, x2, y2 )
93
PL_getbox( parmname, val, x1, y1, x2, y2 )
83
94
char *parmname, *val;
84
95
double *x1, *y1, *x2, *y2;
101
112
/* ================== */
102
113
/* GETRANGE - get a low/high range */
103
getrange( lineval, lo, hi, ax, deflo, defhi )
114
PL_getrange( lineval, lo, hi, ax, deflo, defhi )
132
143
Shell expandable file name is ok.
133
144
Returns 0 if ok, 1 if file not available */
135
file_to_buf( filename, mode, result, buflen )
146
PL_file_to_buf( filename, mode, result, buflen )
137
148
int mode; /* 1 = file 2 = command */
199
210
/* =========================== */
200
/* CONV_MSG - print a message to Errfp for a data item of invalid type */
201
conv_msg( row, col, aname )
211
/* CONV_MSG - print a message to errfp for a data item of invalid type */
212
PL_conv_msg( row, col, aname )
206
217
if( Supress_convmsg ) return( 0 );
207
fprintf( Errfp, "%s warning, %s skipping unplottable '%s' (rec=%d field=%d)\n",
218
fprintf( PLS.errfp, "%s warning, %s skipping unplottable '%s' (rec=%d field=%d)\n",
208
219
Eprogname, aname, da(row,col), row+1, col+1 );
212
223
/* =========================== */
213
/* OTH_MSG - print a message to Errfp for a data item of invalid type */
224
/* OTH_MSG - print a message to errfp for a data item of invalid type */
218
229
if( Supress_convmsg ) return( 0 );
219
fprintf( Errfp, "%s %s\n", Eprogname, msg );
230
fprintf( PLS.errfp, "%s %s\n", Eprogname, msg );
223
234
/* =========================== */
225
/* =========================== */
226
235
/* SUPPRESS_CONVMSG - suppress invalid type messages */
227
suppress_convmsg( mode )
236
PL_suppress_convmsg( mode )
230
239
Supress_convmsg = mode;
250
259
/* ========================== */
251
260
/* SCALEBEENSET - return 1 if scaling has been set, 0 if not */
254
263
if( EDXhi - EDXlo > 0.0000001 ) return( 1 );
255
264
else return( 0 );
258
/* ===================== */
259
/* CATITEM - add a new data item */
260
catitem( s, d, avail )
265
D[ (*d)++ ] = &Databuf[ *avail ];
266
strcpy( &Databuf[ (*avail) ], s );
267
(*avail) += (strlen( s ) + 1);
271
269
/* ======================== */
272
/* DEFAULTINC - given a min and a max, estimate a reasonable default inc */
273
static double threshvals[40] = { 0.000001, 0.00001, 0.0001, 0.001, 0.002, 0.005,
279
1000.0, 2000.0, 5000.0,
280
10000.0, 20000.0, 50000.0,
281
100000.0, 200000.0, 500000.0,
282
1000000.0, 2000000.0, 5000000.0,
283
10000000.0, 20000000.0, 50000000.0 };
270
/* DEFAULTINC - given a min and a max, estimate a reasonable default inc
272
* Improvements contributed by Dan Pelleg peldan@yahoo.com :
273
* we want to find a number that is:
274
* - the same order of magnitude of h, and greater than h
275
* - is either 1, 2, or 5, multiplied by the appropriate units
276
* - is the smallest such number
277
* For example, all numbers between 10000 and 19999 are mapped to 20000.
278
* Numbers 20000 - 49999 are mapped to 50000.
279
* Numbers 50000 - 99999 are mapped to 100000.
280
* Numbers 100000 - 199999 are mapped to 200000. And so on.
282
* Remaining scg code deleted 10/1/03...
285
defaultinc( min, max, inc )
285
PL_defaultinc( min, max, inc )
286
286
double min, max, *inc;
288
288
double diff, h, fabs();
289
double ret, mult, mant;
291
292
diff = max - min;
292
293
diff = fabs( diff );
293
294
h = diff / 10.0; /* we want to have about 10 tics on an axis.. */
295
for( i = 0; ; i++ ) {
296
if( h < threshvals[i] ) break;
297
if( threshvals[i] > 49999999.0 ) break;
296
/* normalize and write h = mant * mult, for 1 <= mant 10 */
297
mult = pow( 10.0, floor( log10(h) ) );
300
*inc = threshvals[i];
300
/* find the next step and multiply */
301
if(mant < 2.0) ret = 2.0 * mult;
302
else if(mant < 5.0) ret = 5.0 * mult;
303
else ret = 10.0 * mult;
305
310
/* ======================== */
306
311
/* REWRITENUMS - rewrite numbers, supplying a spacer (comma in US)
308
313
mode is presumed, decimal point is written as a comma, and
309
314
large numbers are spaced using dot.
316
Numbers in scientific notation are returned unaltered.
311
318
Parameter num is modified.
321
PL_rewritenums( num )
317
324
int i, j, k, decplace, len;
318
325
char s[40], tmp[40];
320
if( Bignumspacer == '\0' ) return( 0 ); /* do nothing */
327
if( PLS.bignumspacer == '\0' ) return( 0 ); /* do nothing */
322
329
sscanf( num, "%s", s ); /* strip off any leading spaces */
327
334
for( i = 0, len = strlen( s ); i < len; i++ ) {
335
if( s[i] == 'e' ) return( 0 ); /* scientific notation detected - leave it alone - scg 11/26/02 */
328
336
/* remember the char where number begins.. */
329
if( k < 0 && ( isdigit( s[i] ) || s[i] == '.' || s[i] == '-' ) ) k = i;
337
if( k < 0 && beginnum( s, i ) ) k = i;
338
/* ( isdigit( s[i] ) || (( s[i] == '.' || s[i] == '-' ) && isdigit( s[i+1]) ) ) ) k = i; */
330
339
if( s[i] == '.' ) {
331
340
decplace = i - k;
332
if( Bignumspacer == '.' ) tmp[i] = ',';
341
if( PLS.bignumspacer == '.' ) tmp[i] = ',';
333
342
else tmp[i] = '.';
335
344
else tmp[i] = s[i];
337
if( decplace < 0 ) decplace = i - k;
340
if( decplace > Bignumspacer_thres ) { /* add spacers.. */
350
for( ; i >= 0; i-- ) if( isdigit( s[i] ) || s[i] == '.' ) { i++; break; } /* added scg 3/25/02 */
354
if( decplace > PLS.bignumthres ) { /* add spacers.. */
341
355
/* process tmp; put result back in 's'.. */
342
356
for( i = -1, j = 0, k = 0; i < decplace; k++ ) {
343
357
/* just copy over any leading alpha portion.. */
344
if( i < 0 && ( ! isdigit( tmp[k] ) && tmp[k] != '.' && tmp[k] != '-' ) ) {
358
if( i < 0 && !beginnum( tmp, k ) ) {
359
/* ( ! isdigit( tmp[k] ) && tmp[k] != '.' && tmp[k] != '-' ) ) { */
346
361
continue; /* scg 2/28/02 */
350
365
if( i > 0 && decplace-i > 0 && (decplace-i) % 3 == 0 ) { /* insert 000 separator.. */
351
s[j++] = Bignumspacer;
366
s[j++] = PLS.bignumspacer;
354
else s[j++] = tmp[k];
369
else s[j++] = tmp[k];
357
strcat( s, &tmp[k] ); /* append decimal point and rightward */
372
if( k < strlen( tmp ) ) strcat( s, &tmp[k] ); /* append decimal point and rightward */
359
374
else strcpy( s, tmp );
405
/* =================================== */
406
/* STRIP_WS strip white-space off of front and end of string s */
430
/* ================================= */
433
PL_do_x_button( label )
412
/* don't do anything if first and last characters are non-space.. */
413
if( !isspace( s[0] ) && !isspace( s[ strlen( s ) - 1 ] ) ) return( 0 );
416
/* find last significant char and put a null after it */
417
for( j = strlen( s ) -1; j >= 0; j-- )
418
if( !GL_member( s[j], " \t\n" )) break;
420
/* find 1st significant char at position i */
421
for( i = 0, len = strlen( s ); i < len; i++ )
422
if( !GL_member( s[i], " \t\n" )) break;
440
if( PL_clickmap_getdemomode() ) clickmap_show( 'x' ); /* added scg 11/23/01 */
442
Elinetype( 0, 0.5, 1.0 );
443
Ecblock( 0.1, 0.1, 1.0, 0.3, "yellow", 0 );
447
Ecblockdress( 0.1, 0.1, 1.0, 0.3, 0.06, "0.6", "0.8", 0.0, "" );
449
Egetkey( &x, &y, &e );
450
if( e < 1000 || (y < 0.3 && x < 1.0 )) {
451
Ecblock( 0.1, 0.1, 1.0, 0.3, "black", 0 );
453
if( e == 'q' ) PLS.skipout = 1;
456
else if( PLS.usingcm ) fprintf( PLS.diagfp, "%g %g\n", x*2.54, y*2.54 ); /* in cm */
457
else fprintf( PLS.diagfp, "%g %g\n", x, y ); /* mouse click location in inches from lower-left */