summaryrefslogtreecommitdiffstats
path: root/ds9/library/comm.tcl
blob: 83157366a61860ead6a662d095aaa92abe67dc80 (plain)
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
#  Copyright (C) 1999-2017
#  Smithsonian Astrophysical Observatory, Cambridge, MA, USA
#  For conditions of distribution and use, see copyright notice in "copyright"

package provide DS9 1.0

# used to access ProcessSend*Cmd via tcl
proc CommReturn {id rr} {
    return "$id $rr"
}

proc CommSet {fn paramlist {safemode 0}} {
    global debug
    if {$debug(tcl,hv) || $debug(tcl,samp)} {
	puts stderr "CommSet:$fn:$paramlist:$safemode"
    }

    set cmd [lindex $paramlist 0]
    set param [lrange $paramlist 1 end]
    set len 0

    set i 0

    catch {
    switch -- $cmd {
	2mass {Process2MASSCmd param i}
	3d {Process3DCmd param i}
	about {}
	align {ProcessAlignCmd param i}
	analysis {ProcessAnalysisCmd param i {} $fn}
	array {ProcessArrayCmd param i {} $fn}
	bg -
	background {ProcessBgCmd param i}
	backup {ProcessBackupCmd param i}
	blink {ProcessBlinkCmd param i}
	bin {ProcessBinCmd param i}
	block {ProcessBlockCmd param i}
	cat -
	catalog {ProcessCatalogCmd param i}
	cd {ProcessCDCmd param i}
	cmap {ProcessCmapCmd param i}
	colorbar {ProcessColorbarCmd param i}
	console {ProcessConsoleCmd param i}
	contours -
	contour {ProcessContourCmd param i}
	crop {ProcessCropCmd param i}
	crosshair {ProcessCrosshairCmd param i}
	cursor {ProcessCursorCmd param i}
	data {}
	datacube -
	cube {ProcessCubeCmd param i}
	dss -
	dsssao {ProcessSAOCmd param i}
	dsseso {ProcessESOCmd param i}
	dssstsci {ProcessSTSCICmd param i}
	envi {ProcessENVICmd param i {} $fn}
	export {ProcessExportCmd param i}
	file {ProcessFileCmd param i {} {} {}}
	fits {ProcessFitsCmd param i {} $fn}
	frame {ProcessFrameCmd param i}
	gif {ProcessGIFCmd param i {} $fn}
	grid {ProcessGridCmd param i}
	header {ProcessHeaderCmd param i}
	height {ProcessHeightCmd param i}
	iconify {ProcessIconifyCmd param i}
	iexam -
	imexam {}
	iis {ProcessIISCmd param i}
	irafalign {
	    # backward compatibility
	    ProcessIRAFAlignCmd param i
	}
	jpg -
	jpeg {ProcessJPEGCmd param i {} $fn}
	lock {ProcessLockCmd param i}
	lower {ProcessLowerCmd param i}
	magnifier {ProcessMagnifierCmd param i}
	mask {ProcessMaskCmd param i}
	match {ProcessMatchCmd param i}
	mecube {ProcessMECubeCmd param i {} $fn}
	minmax {ProcessMinMaxCmd param i}
	mode {ProcessModeCmd param i}
	mosaic {ProcessMosaicCmd param i {} $fn}
	mosaicimage {ProcessMosaicImageCmd param i {} $fn}
	mosaicwcs {
	    # backward compatibility
	    ProcessMosaicWCSCmd param i {} $fn
	}
	mosaiciraf {
	    # backward compatibility
	    ProcessMosaicIRAFCmd param i {} $fn
	}
	mosaicimagewcs {
	    # backward compatibility
	    ProcessMosaicImageWCSCmd param i {} $fn
	}
	mosaicimageiraf {
	    # backward compatibility
	    ProcessMosaicImageIRAFCmd param i {} $fn
	}
	mosaicimagewfpc2 {
	    # backward compatibility
	    ProcessMosaicImageWFPC2Cmd param i {} $fn
	}
	savempeg -
	movie {ProcessMovieCmd param i}
	memf -
	multiframe {ProcessMultiFrameCmd param i {} $fn}
	nameserver {ProcessNRESCmd param i}
	nan {ProcessNanCmd param i}
	nrrd {ProcessNRRDCmd param i {} $fn}
	nvss {ProcessNVSSCmd param i}
	orient {ProcessOrientCmd param i}
	{page setup} -
	pagesetup {ProcessPageSetupCmd param i}
	pspagesetup {ProcessPSPageSetupCmd param i}
	pan {ProcessPanCmd param i}
	pixeltable {ProcessPixelTableCmd param i}
	plot {ProcessPlotCmd param i {} $fn}
	png {ProcessPNGCmd param i {} $fn}
	prefs {ProcessPrefsCmd param i}
	preserve {ProcessPreserveCmd param i}
	print {
	    if {$safemode} {
		Error [msgcat::mc {Command not allowed}]
	    } else {
		ProcessPrintCmd param i
	    }
	}
	psprint {
	    if {$safemode} {
		Error [msgcat::mc {Command not allowed}]
	    } else {
		ProcessPSPrintCmd param i
	    }
	}
	exit -
	quit {ProcessQuitCmd param i}
	raise {ProcessRaiseCmd param i}
	restore {ProcessRestoreCmd param i}
	region -
	regions {ProcessRegionsCmd param i {} $fn}
	rgb {ProcessRGBCmd param i}
	rgbarray {ProcessRGBArrayCmd param i {} $fn}
	rgbcube {ProcessRGBCubeCmd param i {} $fn}
	rgbimage {ProcessRGBImageCmd param i {} $fn}
	rotate {ProcessRotateCmd param i}
	samp {ProcessSAMPCmd param i}
	save -
	savefits {ProcessSaveCmd param i}
	saveimage {ProcessSaveImageCmd param i}
	scale {ProcessScaleCmd param i}
	sfits {
	    # backward compatibility
	    ProcessSFitsCmd param i {} $fn
	}
	sia {ProcessSIACmd param i}
	single {ProcessSingleCmd param i}
	shm {ProcessShmCmd param i 0}
	skyview {ProcessSkyViewCmd param i}
	sleep {ProcessSleepCmd param i}
	smosaic {
	    # backward compatibility
	    ProcessSMosaicCmd param i {} $fn
	}
	smosaicwcs {
	    # backward compatibility
	    ProcessSMosaicWCSCmd param i {} $fn
	}
	smosaiciraf {
	    # backward compatibility
	    ProcessSMosaicIRAFCmd param i {} $fn
	}
	smooth {ProcessSmoothCmd param i}
	source {
	    if {$safemode} {
		Error [msgcat::mc {Command not allowed}]
	    } else {
		ProcessSourceCmd param i
	    }
	}
	srgbcube {ProcessSRGBCubeCmd param i {} $fn}
	tcl {
	    if {$safemode} {
		Error [msgcat::mc {Command not allowed}]
	    } else {
		ProcessTclCmd param i {} $fn
	    }
	}
	theme {
	    # backward compatibility
	    ProcessThemeCmd param i
	}
	threads {ProcessThreadsCmd param i}
	tif -
	tiff {ProcessTIFFCmd param i {} $fn}
	tile {ProcessTileCmd param i}
	update {ProcessUpdateCmd param i}
	url {ProcessURLFitsCmd param i}
	version {}
	view {ProcessViewCmd param i}
	vla -
	first {ProcessVLACmd param i}
	vlss {ProcessVLSSCmd param i}
	vo {ProcessVOCmd param i}
	wcs {ProcessWCSCmd param i {} $fn}
	web {ProcessWebCmd param i}
	width {ProcessWidthCmd param i}
	zoom {ProcessZoomCmd param i}
	zscale {ProcessZScaleCmd param i}
	default {Error "[msgcat::mc {Unknown command}]: $cmd"}
    }
    }
}

proc CommGet {proc id paramlist fn} {
    global debug
    if {$debug(tcl,samp)} {
	puts stderr "CommGet:$proc:$id:$paramlist:$fn"
    }

    set cmd [lindex $paramlist 0]
    set param [lrange $paramlist 1 end]

    catch {
    switch -- $cmd {
	2mass {ProcessSend2MASSCmd $proc $id $param}
	3d {ProcessSend3DCmd $proc $id $param}
	about {ProcessSendAboutCmd $proc $id $param {} $fn}
	align {ProcessSendAlignCmd $proc $id $param}
	analysis {ProcessSendAnalysisCmd $proc $id $param {} $fn}
	array {ProcessSendArrayCmd $proc $id $param {} $fn}
	bg -
	background {ProcessSendBgCmd $proc $id $param}
	blink {ProcessSendBlinkCmd $proc $id $param}
	bin {ProcessSendBinCmd $proc $id $param}
	block {ProcessSendBlockCmd $proc $id $param}
	cat -
	catalog {ProcessSendCatalogCmd $proc $id $param {} $fn}
	cd {ProcessSendCDCmd $proc $id $param}
	cmap {ProcessSendCmapCmd $proc $id $param}
	colorbar {ProcessSendColorbarCmd $proc $id $param}
	console {}
	contours -
	contour {ProcessSendContourCmd $proc $id $param {} $fn}
	crop {ProcessSendCropCmd $proc $id $param}
	crosshair {ProcessSendCrosshairCmd $proc $id $param}
	cursor {}
	data {ProcessSendDataCmd $proc $id $param {} $fn}
	datacube -
	cube {ProcessSendCubeCmd $proc $id $param}
	dss -
	dsssao {ProcessSendSAOCmd $proc $id $param}
	dsseso {ProcessSendESOCmd $proc $id $param}
	dssstsci {ProcessSendSTSCICmd $proc $id $param}
	envi {}
	exit {}
	export {}
	file {ProcessSendFileCmd $proc $id $param}
	fits {ProcessSendFitsCmd $proc $id $param {} $fn}
	frame {ProcessSendFrameCmd $proc $id $param}
	gif {ProcessSendGIFCmd $proc $id $param {} $fn}
	grid {ProcessSendGridCmd $proc $id $param}
	header {}
	height {ProcessSendHeightCmd $proc $id $param}
	iconify {ProcessSendIconifyCmd $proc $id $param}
	iexam -
	imexam {ProcessSendIExamCmd $proc $id $param}
	iis {ProcessSendIISCmd $proc $id $param}
	irafalign {
	    # backward compatibility
	    ProcessSendIRAFAlignCmd $proc $id $param
	}
	jpg -
	jpeg {ProcessSendJPEGCmd $proc $id $param {} $fn}
	lock {ProcessSendLockCmd $proc $id $param}
	lower {}
	magnifier {ProcessSendMagnifierCmd $proc $id $param}
	mask {ProcessSendMaskCmd $proc $id $param}
	match {}
	mecube {ProcessSendMECubeCmd $proc $id $param {} $fn}
	minmax {ProcessSendMinMaxCmd $proc $id $param}
	mode {ProcessSendModeCmd $proc $id $param}
	mosaic {ProcessSendMosaicCmd $proc $id $param {} $fn}
	mosaicimage {ProcessSendMosaicImageCmd $proc $id $param {} $fn}
	mosaicwcs {
	    # backward compatibility
	    ProcessSendMosaicWCSCmd $proc $id $param {} $fn
	}
	mosaiciraf {
	    # backward compatibility
	}
	mosaicimagewcs {
	    # backward compatibility
	    ProcessSendMosaicImageWCSCmd $proc $id $param {} $fn
	}
	mosaicimageiraf {
	    # backward compatibility
	}
	mosaicimagewfpc2 {
	    # backward compatibility
	}
	savempeg -
	movie {}
	memf -
	multiframe {}
	nameserver {ProcessSendNRESCmd $proc $id $param}
	nan {ProcessSendNanCmd $proc $id $param}
	nrrd {ProcessSendNRRDCmd $proc $id $param {} $fn}
	nvss {ProcessSendNVSSCmd $proc $id $param}
	orient {ProcessSendOrientCmd $proc $id $param}
	{page setup} -
	pagesetup {ProcessSendPageSetupCmd $proc $id $param}
	pan {ProcessSendPanCmd $proc $id $param}
	pixeltable {ProcessSendPixelTableCmd $proc $id $param {} $fn}
	plot {ProcessSendPlotCmd $proc $id $param}
	png {ProcessSendPNGCmd $proc $id $param {} $fn}
	prefs {ProcessSendPrefsCmd $proc $id $param}
	preserve {ProcessSendPreserveCmd $proc $id $param}
	pspagesetup {ProcessSendPSPageSetupCmd $proc $id $param}
	print {ProcessSendPrintCmd $proc $id $param}
	psprint {ProcessSendPSPrintCmd $proc $id $param}
	exit -
	quit {}
	raise {}
	region -
	regions {ProcessSendRegionsCmd $proc $id $param {} $fn}
	rgb {ProcessSendRGBCmd $proc $id $param}
	rgbarray {ProcessSendRGBArrayCmd $proc $id $param {} $fn}
	rgbcube {ProcessSendRGBCubeCmd $proc $id $param {} $fn}
	rgbimage {ProcessSendRGBImageCmd $proc $id $param {} $fn}
	rotate {ProcessSendRotateCmd $proc $id $param}
	samp {}
	save -
	savefits {}
	saveimage {}
	scale {ProcessSendScaleCmd $proc $id $param}
	sfits {	
	    # backward compatibility
	}
	single {ProcessSendSingleCmd $proc $id $param}
	shm {ProcessSendShmCmd $proc $id $param}
	skyview {ProcessSendSkyViewCmd $proc $id $param}
	smosaic {
	    # backward compatibility
	}
	smosaiciraf {
	    # backward compatibility
	}
	smosaicwcs {
	    # backward compatibility
	}
	smooth {ProcessSendSmoothCmd $proc $id $param}
	source {}
	srgbcube {}
	tcl {}
	theme {
	    # backward compatibility
	    ProcessSendThemeCmd $proc $id $param
	}
	threads {ProcessSendThreadsCmd $proc $id $param}
	tif -
	tiff {ProcessSendTIFFCmd $proc $id $param {} $fn}
	tile {ProcessSendTileCmd $proc $id $param}
	update {}
	url {}
	version {ProcessSendVersionCmd $proc $id $param}
	view {ProcessSendViewCmd $proc $id $param}
	vla -
	first {ProcessSendVLACmd $proc $id $param}
	vlss {ProcessSendVLSSCmd $proc $id $param}
	vo {ProcessSendVOCmd $proc $id $param}
	wcs {ProcessSendWCSCmd $proc $id $param}
	web {ProcessSendWebCmd $proc $id $param}
	width {ProcessSendWidthCmd $proc $id $param}
	zscale {ProcessSendZScaleCmd $proc $id $param}
	zoom {ProcessSendZoomCmd $proc $id $param} 
	default {
	    Error "[msgcat::mc {Unknown command}]: $cmd"
	    $proc $id {}
	}
    }
    }
}