aboutsummaryrefslogtreecommitdiff
path: root/noao/digiphot/daophot/psf/dpqverify.x
blob: 6fff239fd3c4e1744e0698cae1e5a7798bf9edc6 (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
include <fset.h>

define	QUERY "[Hit return to continue, q to quit, w to force update of PSF]"

# DP_QVERIFY -- Print a message in the status line asking the user if they
# really want to quit, returning YES if they really want to quit, NO otherwise.

int procedure dp_qverify (dao, im, psfim, opst, psfgr, psf_new, psf_computed,
	psf_written)

pointer	dao		# pointer to the daophot structure
pointer	im		# the input image descriptor
pointer	psfim		# the output psf image descriptor
int	opst		# the output psf star list file descriptor
int	psfgr		# the output psf group file descriptor
bool	psf_new		# has the psf star list been defined ?
bool	psf_computed	# is the psf fit defined ?
bool	psf_written	# has the psf been saved ?

int	ch
pointer	tty
bool	dp_updatepsf()
int	getci()
pointer	ttyodes()

begin
	# Print status warning message.
	if (psf_new)
	     call printf ("Warning: The PSF star list is undefined.\n")
	else if (! psf_computed)
	    call printf ("Warning: The PSF fit is not current.\n")
	else if (! psf_written)
	    call printf ("Warning: The PSF has not been saved.\n")

	# Open terminal and print query.
	tty = ttyodes ("terminal")
	call ttyclearln (STDOUT, tty)
	call ttyso (STDOUT, tty, YES)
	call printf (QUERY)
	call flush (STDOUT)

	# Get character.
	call fseti (STDIN, F_RAW, YES)
	if (getci (STDIN, ch) == EOF)
	    ;

	# Reset and close terminal.
	call fseti (STDIN, F_RAW, NO)
	call ttyso (STDOUT, tty, NO)
	call ttyclearln (STDOUT, tty)
	call printf ("\n")
	call flush (STDOUT)
	call ttycdes (tty)

	# Return YES for the quit command, otherwise NO.
	if (ch == 'q') {
	    return (YES)
	} else if (ch == 'w') {
	    if (dp_updatepsf (dao, im, psfim, opst, psfgr, psf_new,
	        psf_computed, psf_written)) {
		psf_computed = true
		psf_written = true
	    }
	    return (NO)
	} else {
	    return (NO)
	}
end