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
|
include <error.h>
include <pkg/gtools.h>
include <smw.h>
include <units.h>
include <ctype.h>
# List of colon commands.
define CMDS "|show|nolog|log|dispaxis|nsum|#|units|auto|zero\
|xydraw|histogram|nosysid|wreset|flip|overplot\
|label|mabove|mbelow|"
define SHOW 1 # Show logged data
define NOLOG 2 # Turn off logging
define LOG 3 # Turn on logging
define DA 4 # Dispersion axis
define NS 5 # Summing parameter
define COMMENT 6 # Comment
define UNITS 7 # Units
define AUTO 8 # Option auto graph
define ZERO 9 # Option for zero y minimum
define XYDRAW 10 # Draw connection X,Y pairs
define HIST 11 # Draw histogram style lines
define NOSYSID 12 # Don't include system id
define WRESET 13 # Reset window for each new spectrum
define FLIP 14 # Flip the dispersion coordinates
define OVERPLOT 15 # Toggle overplot
define LABEL 16 # Label spectrum
define MABOVE 17 # Tick mark plus label above spectrum
define MBELOW 18 # Tick mark plus label below spectrum
define OPOFF 7 # Offset in options array
# SPLOT_COLON -- Respond to colon command.
procedure splot_colon (command, options, gp, gt, sh, x, y, units,
fname1, fname2, fd1, fd2, newgraph)
char command[ARB] # Colon command
int options[ARB] # Options
pointer gp # GIO pointer
pointer gt # GTOOLS pointer
pointer sh # SHIO pointer
real x, y # Coordinate
char units[SZ_FNAME] # Units string
char fname1[SZ_FNAME] # Log file
char fname2[SZ_FNAME] # Temporary log file
int fd1, fd2 # Log file descriptors
int newgraph # New graph?
bool bval
char cmd[SZ_LINE]
real xval, gt_getr()
int ncmd, ival, access(), nscan(), strdic(), btoi(), gt_geti()
pointer sp, str, smw
errchk un_changer
begin
call smark (sp)
call salloc (str, SZ_LINE, TY_CHAR)
# Scan the command string and get the first word.
call sscan (command)
call gargwrd (cmd, SZ_LINE)
ncmd = strdic (cmd, cmd, SZ_LINE, CMDS)
smw = MW(sh)
switch (ncmd) {
case SHOW:
if (fd2 != NULL) {
call close (fd2)
fd2 = NULL
}
if (access (fname2, 0, 0) == YES)
call gpagefile (gp, fname2, "splot data")
else
call printf ("No measurements\n")
case NOLOG:
call printf ("Logging to %s disabled")
call pargstr (fname1)
fname1[1] = EOS
if (fd1 != NULL) {
call close (fd1)
fd1 = NULL
}
case LOG:
call clgstr ("save_file", fname1, SZ_FNAME)
call printf ("Logging to %s enabled")
call pargstr (fname1)
case DA:
if (SMW_FORMAT(smw) == SMW_ND) {
call gargi (ival)
if (nscan() == 2) {
if (ival < 1) {
call printf ("Bad value for dispaxis (%d)\n")
call pargi (ival)
} else if (ival != SMW_PAXIS(smw,1)) {
call smw_daxis (smw, IM(sh), ival, INDEFI, INDEFI)
call smw_saxes (smw, NULL, IM(sh))
call shdr_close (sh)
}
} else {
call printf ("dispaxis %d\n")
call pargi (SMW_PAXIS(smw,1))
}
} else
call printf ("Image is not two dimensional\n")
case NS:
if (SMW_FORMAT(smw) == SMW_ND) {
call gargi (ival)
call gargi (ncmd)
if (nscan() == 1) {
call printf ("nsum %d %d\n")
call pargi (SMW_NSUM(smw,1))
call pargi (SMW_NSUM(smw,2))
} else {
if (nscan() == 2)
ncmd = INDEFI
if ((!IS_INDEFI(ival) && ival != SMW_NSUM(smw,1)) ||
(!IS_INDEFI(ncmd) && ncmd != SMW_NSUM(smw,2))) {
call smw_daxis (smw, IM(sh), INDEFI, ival, ncmd)
call smw_saxes (smw, NULL, IM(sh))
call shdr_close (sh)
}
}
} else
call printf ("Invalid image format\n")
case COMMENT:
call ans_hdr (sh, NO, 'm', fname1, fname2, fd1, fd2)
call gargstr (cmd, SZ_LINE)
if (fd1 != NULL) {
call fprintf (fd1, "%s\n")
call pargstr (command)
}
if (fd2 != NULL) {
call fprintf (fd2, "%s\n")
call pargstr (command)
}
case UNITS:
call gargstr (cmd, SZ_LINE)
for (ival=1; IS_WHITE(cmd[ival]); ival=ival+1)
;
iferr {
xval = gt_getr (gt, GTXMIN)
if (!IS_INDEF(xval)) {
call un_changer (UN(sh), cmd[ival], xval, 1, NO)
call gt_setr (gt, GTXMIN, xval)
}
xval = gt_getr (gt, GTXMAX)
if (!IS_INDEF(xval)) {
call un_changer (UN(sh), cmd[ival], xval, 1, NO)
call gt_setr (gt, GTXMAX, xval)
}
call un_changer (UN(sh), cmd[ival], Memr[SX(sh)], SN(sh), YES)
call strcpy (cmd[ival], units, SZ_FNAME)
call gt_sets (gt, GTXLABEL, UN_LABEL(UN(sh)))
call gt_sets (gt, GTXUNITS, UN_UNITS(UN(sh)))
newgraph = YES
} then
call erract (EA_WARN)
case AUTO:
call gargb (bval)
if (nscan() == 2)
options[AUTO-OPOFF] = btoi (bval)
else {
call printf ("auto %b\n")
call pargi (options[AUTO-OPOFF])
}
case ZERO:
call gargb (bval)
if (nscan() == 2) {
options[ZERO-OPOFF] = btoi (bval)
if (bval)
call gt_setr (gt, GTYMIN, 0.)
newgraph = options[AUTO-OPOFF]
} else {
call printf ("zero %b\n")
call pargi (options[ZERO-OPOFF])
}
case XYDRAW:
call gargb (bval)
if (nscan() == 2)
options[XYDRAW-OPOFF] = btoi (bval)
else {
call printf ("xydraw %b\n")
call pargi (options[XYDRAW-OPOFF])
}
case HIST:
call gargb (bval)
if (nscan() == 2) {
options[HIST-OPOFF] = btoi (bval)
if (bval)
call gt_sets (gt, GTTYPE, "histogram")
else
call gt_sets (gt, GTTYPE, "line")
newgraph = options[AUTO-OPOFF]
} else {
call printf ("hist %b\n")
call pargi (options[HIST-OPOFF])
}
case NOSYSID:
call gargb (bval)
if (nscan() == 2) {
options[NOSYSID-OPOFF] = btoi (bval)
if (bval)
call gt_seti (gt, GTSYSID, NO)
else
call gt_seti (gt, GTSYSID, YES)
newgraph = options[AUTO-OPOFF]
} else {
call printf ("nosysid %b\n")
call pargi (options[NOSYSID-OPOFF])
}
case WRESET:
call gargb (bval)
if (nscan() == 2)
options[WRESET-OPOFF] = btoi (bval)
else {
call printf ("wreset %b\n")
call pargi (options[WRESET-OPOFF])
}
case FLIP:
call gargb (bval)
if (nscan() == 2) {
options[FLIP-OPOFF] = btoi (bval)
call gt_seti (gt, GTXFLIP, options[FLIP-OPOFF])
} else {
options[FLIP-OPOFF] = gt_geti (gt, GTXFLIP)
call printf ("flip %b\n")
call pargi (options[FLIP-OPOFF])
}
case OVERPLOT:
call gargb (bval)
if (nscan() == 2) {
options[OVERPLOT-OPOFF] = btoi (bval)
} else {
call printf ("overplot %b\n")
call pargi (options[OVERPLOT-OPOFF])
}
case LABEL, MABOVE, MBELOW:
call gargwrd (cmd, SZ_LINE)
for (ival=1; IS_WHITE(cmd[ival]); ival=ival+1)
;
call strcpy (cmd[ival], cmd, SZ_LINE)
call gargwrd (Memc[str], SZ_LINE)
for (ival=1; IS_WHITE(Memc[str+ival-1]); ival=ival+1)
;
call strcpy (Memc[str+ival-1], Memc[str], SZ_LINE)
switch (ncmd) {
case LABEL:
call splabel ("label", sh, gp, x, y, cmd, Memc[str])
case MABOVE:
call splabel ("mabove", sh, gp, x, y, cmd, Memc[str])
case MBELOW:
call splabel ("mbelow", sh, gp, x, y, cmd, Memc[str])
}
default:
call printf ("Unrecognized or ambiguous command\007")
}
call sfree (sp)
end
|