1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
|
include <xwhen.h>
include <config.h>
include <mach.h>
include <error.h>
include <ctype.h>
include <fset.h> # FIO
include <gset.h> # GIO
include <tbset.h> # TBtables
define HELPFILE "tables$pkg/ttools/gtedit/gtedit.key" # (BPS 05.31.94)
define GT_QUIT 0
define GT_EXIT 1
procedure gteplot (device, input, tp, tpr, deleted, xcolumn, ycolumn, x, y,
size, null, npix, table_name, status)
char device[SZ_FNAME] # Graphics device
char input[SZ_FNAME] # Input table name
pointer tp # Table descriptor
pointer tpr # Reject Table descriptor
pointer deleted # Pointer for array of delete flags
char xcolumn[SZ_COLNAME] # X column in table
char ycolumn[SZ_COLNAME] # Y column in table
pointer x
pointer y
pointer size # Size of markers to plot
pointer null #
int npix # Number of points per curve
char table_name[SZ_FNAME] # Table name
int status # return status
pointer gd
int mode, npix_save
char col_save[SZ_COLNAME]
char xlabel[SZ_LINE], ylabel[SZ_LINE]
char plotitle[2*SZ_LINE]
char marker[SZ_FNAME]
char cmd[SZ_LINE]
char bad_column[SZ_COLNAME]
bool xautoscale, yautoscale, mark_del
bool drawbox, rdmarks
bool silent, readonly, inplace, auto_replot
int xtran, ytran, ticklabels, marker_type, j, drawgrid
int wcs, key, ip
int undelete
real px, py
real wx1, wx2, wy1, wy2, szmarker, vx1, vx2, vy1, vy2
real wb, wt, wl, wr
real tol, xx, yy, sz
real x1, y1, x2, y2
pointer sp, system_id, errmsg
string bell "\007"
define replot_ 91
define next_ 92
pointer gopen()
bool clgetb()
int strncmp()
int clgeti(), gstati()
int clgcur()
real clgetr()
pointer tbtopn()
errchk clgetb, clgeti, clgstr, clgetr, glabax, gpmark
errchk gswind, gseti, gascale, grscale
begin
call smark (sp)
call salloc (system_id, SZ_LINE, TY_CHAR)
call salloc (errmsg, SZ_LINE, TY_CHAR)
mode = NEW_FILE
mark_del = false
undelete = NO
# Get the marker character to be drawn at
# each point. The size of the character is given by szmarker. If
# zero and the input operadd is a list, marker sizes are taken
# individually from the third column of each list element. If
# negative, all markers are of size |szmarker| in NDC. If
# positive and the input operand is a list, the size of a marker
# is the third column of each list element times szmarker.
szmarker = 0.0
rdmarks = false
# Draw markers only
call clgstr ("marker", marker, SZ_FNAME)
call init_mark2 (marker, marker_type)
if (marker_type != GM_POINT) {
szmarker = clgetr ("szmarker")
rdmarks = (szmarker <= 0)
}
gd = gopen (device, mode, STDGRAPH)
call gsetr (gd, G_PLWIDTH, 2.0)
tol = 10.0 * EPSILONR
xautoscale = false
yautoscale = false
# Set window and viewport. If user window has not been set, enable
# autoscaling. If device viewport has not been set, let glabax
# handle the viewport internally.
call gclear (gd)
wx1 = clgetr ("wx1")
wx2 = clgetr ("wx2")
wy1 = clgetr ("wy1")
wy2 = clgetr ("wy2")
if (abs (wx2 - wx1) < tol)
xautoscale = true
if (abs (wy2 - wy1) < tol)
yautoscale = true
vx1 = clgetr ("vx1")
vx2 = clgetr ("vx2")
vy1 = clgetr ("vy1")
vy2 = clgetr ("vy2")
if ((abs (vx2 - vx1) > tol) && (abs (vy2 - vy1) > tol))
call gsview (gd, vx1, vx2, vy1, vy2)
if (!clgetb ("fill"))
call gseti (gd, G_ASPECT, 1)
if (clgetb ("round"))
call gseti (gd, G_ROUND, YES)
replot_
# Draw box around plot?
drawbox = false
if (mode != APPEND)
if (clgetb ("box"))
drawbox = true
if (drawbox) {
# Get number of major and minor tick marks.
call gseti (gd, G_XNMAJOR, clgeti ("majrx"))
call gseti (gd, G_XNMINOR, clgeti ("minrx"))
call gseti (gd, G_YNMAJOR, clgeti ("majry"))
call gseti (gd, G_YNMINOR, clgeti ("minry"))
# Fetch labels and plot title string.
call clgstr ("xlabel", xlabel, SZ_LINE)
call clgstr ("ylabel", ylabel, SZ_LINE)
call gt_hinfo (tp, xlabel, ylabel, xcolumn, ycolumn, SZ_LINE)
# Label tick marks on axes?
ticklabels = NO
if (clgetb ("ticklabels"))
ticklabels = YES
# Draw grid ?
drawgrid = NO
if (clgetb ("grid"))
drawgrid = YES
call gseti (gd, G_DRAWGRID, drawgrid)
}
# Log scale? Call gswind to set log scaling regardless of whether
# the user window is known; if the user window was not input,
# autoscaling will reset it later.
if (mode == APPEND) {
xtran = gstati (gd, G_XTRAN)
ytran = gstati (gd, G_YTRAN)
call ggwind (gd, wx1, wx2, wy1, wy2)
} else {
xtran = GW_LINEAR
if (clgetb ("logx"))
xtran = GW_LOG
ytran = GW_LINEAR
if (clgetb ("logy"))
ytran = GW_LOG
call gswind (gd, wx1, wx2, wy1, wy2)
call gseti (gd, G_XTRAN, xtran)
call gseti (gd, G_YTRAN, ytran)
}
# Autoscale if enabled.
if (xautoscale) {
call gascale (gd, Memr[x], npix, 1)
}
call ggwind (gd, wl, wr, wb, wt)
if (yautoscale) {
# Overplot multiple curves on the same viewport
call gascale (gd, Memr[y], npix, 2)
}
if (drawbox) {
# Draw box around plot
call gseti (gd, G_LABELTICKS, ticklabels)
# Overplot multiple curves on the same viewport
call strcpy ("", plotitle, SZ_FNAME)
call glabax (gd, plotitle, xlabel, ylabel)
}
# Markers at each point with no connection
if (rdmarks) {
# Variable marker sizes
if (szmarker < 0)
# World coordinate marker sizes
call amulkr (Memr[size], -szmarker, Memr[size],
npix)
do j = 1, npix { # For each point in the curve
xx = Memr[x+j-1]
yy = Memr[y+j-1]
sz = Memr[size+j-1]
call gmark (gd, xx, yy, marker_type, sz, sz)
}
} else {
call gpmark (gd, Memr[x], Memr[y],npix, marker_type,
szmarker, szmarker)
}
# We have plotted things so now is the time to let the user
# do his thing.
# Over plot crosses for those points which have been deleted
if (mark_del) {
call gt_pdel (gd, Memr[x], Memr[y], Memr[deleted], npix)
mark_del = false
}
next_
while (clgcur ("commands", px, py, wcs, key, cmd, SZ_LINE)
!= EOF) {
switch (key) {
# Quit and do not make changes
case 'q':
status = GT_QUIT
break
# Exit and do the changes
case 'e':
status = GT_EXIT
break
# Help page
case '?':
if (gd == NULL)
call pagefile (HELPFILE, "")
else
call gpagefile (gd, HELPFILE, "")
# Simply replot (may have new columns)
case 'p':
call gclear (gd)
mark_del = true
goto replot_
# Mark the corners of a box and delete the points within
case 'c':
x1 = px; y1 = py
call gmark (gd, x1, y1, GM_DIAMOND, 1., 1.)
call printf ("again:")
if (clgcur ("commands", px, py, wcs, key, cmd, SZ_LINE) == EOF)
goto next_
call gt_dbox (gd, npix, Memi[deleted], undelete, Memr[x],
Memr[y], x1, y1, px, py)
# Mark the end points of a line segment and delete points on
# one side of this segment (indicated by user) for points with
# X values between x1 and x2
case 's':
x1 = px; y1 = py
call gmark (gd, x1, y1, GM_DIAMOND, 1., 1.)
call printf ("again:")
if (clgcur ("commands", px, py, wcs, key, cmd, SZ_LINE) == EOF)
goto next_
x2 = px
y2 = py
call gmark (gd, x1, y1, GM_DIAMOND, 1., 1.)
call gline (gd, x1, y1, x2, y2)
call printf ("Move cursor to one side of line and hit any key")
if (clgcur ("commands", px, py, wcs, key, cmd, SZ_LINE) == EOF)
goto next_
call gt_dseg (gd, npix, Memi[deleted], undelete, Memr[x],
Memr[y], x1, y1, x2, y2, px, py)
# Update graph (delete points and replot)
case 'f':
call gt_update (tp, tpr, Memr[x], Memr[y], Memi[deleted], npix)
call gclear (gd)
goto replot_
# Print out the complete record for this point
case 'a':
call gt_wrdata (gd, tp, px, py, Memr[x], Memr[y], npix)
# Print out the column names
case 'h':
call gt_wrhead (gd, tp)
# Delete a point
case 'd':
call gt_delpt (gd,px, py, Memr[x], Memr[y], npix,
Memi[deleted], undelete)
# Undelete a point
case 'u':
if (undelete == YES) {
undelete = NO
call printf ("Now deleting points\n")
} else {
undelete = YES
call printf ("Now undeleting points\n")
}
# Revert to normal table editor
case 'v':
silent = false
readonly = false
inplace = false
# First update the table
call gt_update (tp, tpr, Memr[x], Memr[y], Memi[deleted], npix)
call tbtclo (tp)
call gdeactivate (gd, 0)
call edit (table_name, " ", silent, readonly, inplace)
# Now read in the data (which may have been edited
npix_save = npix
tp = tbtopn (table_name, READ_WRITE, NULL)
call gt_rdxycol (tp, xcolumn, ycolumn, x, y, size, null, npix,
bad_column)
if (npix < 0) {
npix = npix_save
call printf ("Cannot find column %s")
call pargstr (bad_column)
}
call greactivate (gd, AW_PAUSE)
call gclear (gd)
goto replot_
# Undelete status
case 'z':
if (undelete == NO) {
call printf ("Currently deleting points\n")
} else {
call printf ("Currently undeleting points\n")
}
# Delete points > Y
case 't':
call gt_dygt (gd, py, Memr[x], Memr[y], npix,
Memi[deleted], undelete)
# Delete points < Y
case 'b':
call gt_dylt (gd, py, Memr[x], Memr[y], npix,
Memi[deleted], undelete)
# Delete points > X
case 'r':
call gt_dxgt (gd, px, Memr[x], Memr[y], npix,
Memi[deleted], undelete)
# Delete points < X
case 'l':
call gt_dxlt (gd, px, Memr[x], Memr[y], npix,
Memi[deleted], undelete)
# Colon commands:
case ':':
# Command mode
for (ip=1; IS_WHITE (cmd[ip]); ip = ip + 1)
;
switch (cmd[ip]) {
case 'x':
# Read in a new X column
ip = ip + 1
auto_replot = true
if (strncmp (cmd[ip], "-", 1) == 0) {
ip = ip + 1
auto_replot = false
}
call amovc (xcolumn, col_save, SZ_COLNAME)
call ctowrd (cmd, ip, xcolumn, SZ_FNAME)
npix_save = npix
call gt_rdxycol (tp, xcolumn, ycolumn, x, y, size, null,
npix, bad_column)
if (npix < 0) {
npix = npix_save
call gdeactivate (gd, 0)
call printf ("Cannot find column %s")
call pargstr (bad_column)
call greactivate (gd, 0)
call amovc (col_save, xcolumn, SZ_COLNAME)
}
if (auto_replot) {
call gclear (gd)
mark_del = true
goto replot_
}
case 'y':
# Read in a new Y column
ip = ip + 1
auto_replot = true
if (strncmp (cmd[ip], "-", 1) == 0) {
ip = ip + 1
auto_replot = false
}
call amovc (ycolumn, col_save, SZ_COLNAME)
call ctowrd (cmd, ip, ycolumn, SZ_FNAME)
npix_save = npix
call gt_rdxycol (tp, xcolumn, ycolumn, x, y,
size, null, npix, bad_column)
if (npix < 0) {
call gdeactivate (gd, 0)
npix = npix_save
call printf ("Cannot find column %s")
call pargstr (bad_column)
call greactivate (gd, 0)
call amovc (col_save, ycolumn, SZ_COLNAME)
}
if (auto_replot) {
call gclear (gd)
mark_del = true
goto replot_
}
default:
call printf (bell)
}
default:
call printf (bell)
}
}
call sfree (sp)
call gclose (gd)
end
# TGR_ONINT2 -- Interrupt handler for the task graph. Branches back to ZSVJMP
# in the main routine to permit shutdown without an error message.
procedure tgr_onint2 (vex, next_handler)
int vex # Virtual exception
int next_handler # not used
int tgrjmp[LEN_JUMPBUF]
common /tgrcom/ tgrjmp
begin
call xer_reset()
call zdojmp (tgrjmp, vex)
end
# INIT_MARK2 -- Returns integers code for marker type string.
procedure init_mark2 (marker, imark)
char marker[SZ_FNAME] # Marker type as a string
int imark # Integer code for marker - returned
bool streq()
begin
if (streq (marker, "point"))
imark = GM_POINT
else if (streq (marker, "box"))
imark = GM_BOX
else if (streq (marker, "plus"))
imark = GM_PLUS
else if (streq (marker, "cross"))
imark = GM_CROSS
else if (streq (marker, "circle"))
imark = GM_CIRCLE
else if (streq (marker, "hebar"))
imark = GM_HEBAR
else if (streq (marker, "vebar"))
imark = GM_VEBAR
else if (streq (marker, "hline"))
imark = GM_HLINE
else if (streq (marker, "vline"))
imark = GM_VLINE
else if (streq (marker, "diamond"))
imark = GM_DIAMOND
else {
call eprintf ("Unrecognized marker type, using 'box'\n")
imark = GM_BOX
}
end
|