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

# SF_DELETE -- Delete point, star, or wavelength identified by the
# star index and index within the array of values.

procedure sf_delete (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, cdel, stridx()
real	wave, szmark, szmdel
pointer	x, y, z, w, gio

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

	# Delete the point or points from each displayed graph.
	# When deleting multiple points check if point already deleted.
	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 sf_data (stds, nstds, GP_GRAPHS(gp,wcs))
	    switch (key) {
	    case 'p':
		if (istd != nstds-1)
		    mark = GP_MARK(gp)
		else
		    mark = GP_MADD(gp)
	        x = STD_X(stds[istd])+ipt-1
	        y = STD_Y(stds[istd],1)+ipt-1
		call gseti (gio, G_PMLTYPE, 0)
	        call gmark (gio, Memr[x], Memr[y], mark, szmark, szmark)
		call gseti (gio, G_PMLTYPE, 1)
		call gseti (gio, G_PLCOLOR, cdel)
	        call gmark (gio, Memr[x], Memr[y], mdel, szmdel, szmdel)
	    case 's':
		if (istd != nstds-1)
		    mark = GP_MARK(gp)
		else
		    mark = GP_MADD(gp)
	        n = STD_NWAVES(stds[istd])
	        x = STD_X(stds[istd])
	        y = STD_Y(stds[istd])
	        w = STD_WTS(stds[istd])
		do i = 1, n {
		    if (Memr[w] != 0.) {
		        call gseti (gio, G_PMLTYPE, 0)
	                call gmark (gio, Memr[x], Memr[y], mark, szmark, szmark)
		        call gseti (gio, G_PMLTYPE, 1)
			call gseti (gio, G_PLCOLOR, cdel)
	                call gmark (gio, Memr[x], Memr[y], mdel, szmdel, szmdel)
		    }
		    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)
		    else
			mark = GP_MADD(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], mark, szmark,
				    szmark)
		            call gseti (gio, G_PMLTYPE, 1)
			    call gseti (gio, G_PLCOLOR, cdel)
	                    call gmark (gio, Memr[x], Memr[y], mdel, szmdel,
				szmdel)
		        }
			x = x + 1
			y = y + 1
			z = z + 1
			w = w + 1
		    }
	        }
	    }
	}

	# Mark the points as deleted by setting their weights to zero.
	switch (key) {
	case 'p':
	    w = STD_WTS(stds[istd])+ipt-1
	    Memr[w] = 0.
	case 's':
	    n = STD_NWAVES(stds[istd])
	    w = STD_WTS(stds[istd])
	    call aclrr (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])
		do j = 1, n {
		    if (Memr[z] == wave)
	                Memr[w] = 0.
		    w = w + 1
		    z = z + 1
		}
	    }
	}
end