aboutsummaryrefslogtreecommitdiff
path: root/noao/onedspec/sensfunc/sfundelete.x
blob: 25161cc39ced38143feb561dd3bb79ee647805c1 (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
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
include	<gset.h>
include "sensfunc.h"


# SF_UNDELETE -- Unelete point, star, or wavelength.

procedure sf_undelete (gp, stds, nstds, key, istd, ipt)

pointer	gp			# GIO pointer
pointer	stds[nstds]		# Standard star data
int	nstds			# Number of standard stars
int	key			# Delete point, star, or wavelength
int	istd			# Index of standard star
int	ipt			# Index of point

int	i, j, n, wcs, mark, mdel, color, stridx()
real	wave, szmark, szmdel
pointer	x, y, z, w, w1, gio

begin
	gio = GP_GIO(gp)
	mdel = GP_MDEL(gp)
	szmdel = GP_SZMDEL(gp)
	szmark = GP_SZMARK(gp)

	# Undelete points from each displayed graph.
	for (wcs = 1; GP_GRAPHS(gp,wcs) != EOS; wcs = wcs + 1) {
	    if (stridx (GP_GRAPHS(gp,wcs), "ars") == 0)
	        next

	    call gseti (gio, G_WCS, wcs)
	    call gseti (gio, G_PMLTYPE, 0)
	    call sf_data (stds, nstds, GP_GRAPHS(gp,wcs))
	    switch (key) {
	    case 'p':
		if (istd != nstds-1) {
		    mark = GP_MARK(gp)
		    color = GP_CMARK(gp)
		} else {
		    mark = GP_MADD(gp)
		    color = GP_CADD(gp)
		}
	        x = STD_X(stds[istd])+ipt-1
	        y = STD_Y(stds[istd])+ipt-1
	        w = STD_WTS(stds[istd])+ipt-1
	        w1 = STD_IWTS(stds[istd])+ipt-1
		call gseti (gio, G_PMLTYPE, 0)
	        call gmark (gio, Memr[x], Memr[y], mdel, szmdel, szmdel)
		call gseti (gio, G_PMLTYPE, 1)
		call gseti (gio, G_PLCOLOR, color)
	        call gmark (gio, Memr[x], Memr[y], mark, szmark , szmark)
	    case 's':
		if (istd != nstds-1) {
		    mark = GP_MARK(gp)
		    color = GP_CMARK(gp)
		} else {
		    mark = GP_MADD(gp)
		    color = GP_CADD(gp)
		}
	        n = STD_NWAVES(stds[istd])
	        x = STD_X(stds[istd])
	        y = STD_Y(stds[istd])
	        w = STD_WTS(stds[istd])
		do j = 1, n {
		    if (Memr[w] == 0.) {
			call gseti (gio, G_PMLTYPE, 0)
	        	call gmark (gio, Memr[x], Memr[y], mdel, szmdel, szmdel)
			call gseti (gio, G_PMLTYPE, 1)
			call gseti (gio, G_PLCOLOR, color)
	        	call gmark (gio, Memr[x], Memr[y], mark, szmark, szmark)
		    }
		    x = x + 1
		    y = y + 1
		    w = w + 1
	        }
	    case 'w':
	        wave = Memr[STD_WAVES(stds[istd])+ipt-1]
	        do i = 1, nstds {
	            if (STD_FLAG(stds[i]) != SF_INCLUDE)
		        next
		    if (i != nstds-1) {
			mark = GP_MARK(gp)
			color = GP_CMARK(gp)
		    } else {
			mark = GP_MADD(gp)
			color = GP_CADD(gp)
		    }
	            n = STD_NWAVES(stds[i])
	            x = STD_X(stds[i])
	            y = STD_Y(stds[i])
		    z = STD_WAVES(stds[i])
	            w = STD_WTS(stds[i])
		    do j = 1, n {
		        if ((Memr[z] == wave) && (Memr[w] == 0.)) {
			    call gseti (gio, G_PMLTYPE, 0)
	    		    call gmark (gio, Memr[x], Memr[y], mdel, szmdel,
				szmdel)
			    call gseti (gio, G_PMLTYPE, 1)
			    call gseti (gio, G_PLCOLOR, color)
	    		    call gmark (gio, Memr[x], Memr[y], mark, szmark,
				szmark)
		        }
			x = x + 1
			y = y + 1
			z = z + 1
			w = w + 1
		    }
	        }
	    }
	}

	# Now actually undelete the points by resetting the weights.
	switch (key) {
	case 'p':
	    w = STD_WTS(stds[istd])+ipt-1
	    w1 = STD_IWTS(stds[istd])+ipt-1
	    Memr[w] = Memr[w1]
	case 's':
	    n = STD_NWAVES(stds[istd])
	    w = STD_WTS(stds[istd])
	    w1 = STD_IWTS(stds[istd])
	    call amovr (Memr[w1], Memr[w], n)
	case 'w':
	    wave = Memr[STD_WAVES(stds[istd])+ipt-1]
	    do i = 1, nstds {
	        if (STD_FLAG(stds[i]) != SF_INCLUDE)
		    next
	        n = STD_NWAVES(stds[i])
		z = STD_WAVES(stds[i])
	        w = STD_WTS(stds[i])
	        w1 = STD_IWTS(stds[i])
		do j = 1, n {
		    if (Memr[z] == wave)
			Memr[w] = Memr[w1]
		    z = z + 1
		    w = w + 1
		    w1 = w1 + 1
		}
	    }
	}
end