aboutsummaryrefslogtreecommitdiff
path: root/pkg/xtools/icfit/icguishowd.x
blob: dee7401dd6138d1ed1c8f22c312ef79258d1117d (plain) (blame)
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
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include	<error.h>
include	<gset.h>
include	<gio.h>
include "icfit.h"
include	"names.h"

define	CMDS "|show|vshow|xyshow|errors|"

define	SHOW		1	# Show information
define	VSHOW		2	# Show verbose information
define	XYSHOW		3	# Show points 
define	ERRORS		4	# Show errors

# IC_GUISHOW -- GUI show.
#
# Note there is currently an interface violation to determine if the graphics
# stream is connected to a GUI.

procedure ic_guishowd (ic, cmd, cv, x, y, wts, npts)

pointer	ic				#I ICFIT pointer
char	cmd[ARB]			#I Command
pointer cv                              #I CURFIT pointer for error listing
double   x[npts], y[npts], wts[npts]     #I Data arrays
int     npts                            #I Number of data points

int	ncmd, deact, fd
pointer	sp, str, msg
int	strdic(), nscan(), stropen(), open()
errchk	stropen, open, ic_fshow, ic_fvshowd, ic_fxyshowd, ic_ferrorsd

begin
	call smark (sp)
	call salloc (str, SZ_LINE, TY_CHAR)

	# Scan the command.
	call sscan (cmd)
	call gargwrd (Memc[str], SZ_LINE)
	ncmd = strdic (Memc[str], Memc[str], SZ_LINE, CMDS)
	call gargwrd (Memc[str], SZ_LINE)

	iferr {
	    # Setup the output.
	    deact = NO
	    msg = NULL

	    if (nscan() == 1) {
		if (GP_UIFNAME(IC_GP(ic)) != EOS) {
		    call malloc (msg, 100000, TY_CHAR)
		    fd = stropen (Memc[msg], 100000, WRITE_ONLY)
		} else {
		    fd = open ("STDOUT", APPEND, TEXT_FILE)
		    call gdeactivate (IC_GP(ic), AW_CLEAR)
		    deact = YES
		}
	    } else
		fd = open (Memc[str], APPEND, TEXT_FILE)

	    # Write the results to the output.
	    switch (ncmd) {
	    case SHOW:
		call ic_fshow (ic, fd)
	    case VSHOW:
		call ic_fvshowd (ic, cv, x, y, wts, npts, fd)
	    case XYSHOW:
		call ic_fxyshowd (ic, cv, x, y, wts, npts, fd)
	    case ERRORS:
		call ic_fshow (ic, fd)
		call ic_ferrorsd (ic, cv, x, y, wts, npts, fd)
	    }

	    # Flush the output.
	    call close (fd)
	    if (msg != NULL)
		call gmsg (IC_GP(ic), "icshow", Memc[msg])
	} then
	    call erract (EA_WARN)

	if (msg != NULL)
	    call mfree (msg, TY_CHAR)
	if (deact == YES)
	    call greactivate (IC_GP(ic), AW_PAUSE)
	call sfree (sp)
end