aboutsummaryrefslogtreecommitdiff
path: root/noao/rv/rvidlines/idmark.x
blob: 8f874560650eaec0105b09d47525a87d0669171b (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
include	<gset.h>
include <smw.h>
include	"identify.h"

procedure id_mark (id, feature)

pointer	id				# ID pointer
int	feature

int	pix, color, gstati()
real	x, y
real	mx, my, x1, x2, y1, y2, tick, gap
pointer	sp, format, label, ptr
double	smw_c1trand()

define	TICK	.03	# Tick size in NDC
define	GAP	.02	# Gap size in NDC

begin
	call ggwind (ID_GP(id), x1, x2, y1, y2)

	x = FIT(id,feature)

	if ((x < min (x1, x2)) || (x > max (x1, x2)))
	    return

	pix = smw_c1trand (ID_PL(id),  PIX(id,feature)) - NP1(ID_SH(id)) + 1
	pix = max (1, min (pix, ID_NPTS(id)-1))

	call smark (sp)
	call salloc (format, SZ_LINE, TY_CHAR)
	call salloc (label, SZ_LINE, TY_CHAR)
	switch (FTYPE(id,feature)) {
	case EMISSION, GEMISSION:
	    y = max (IMDATA(id,pix), IMDATA(id,pix+1))
	    tick = TICK
	    gap = GAP
	    call strcpy ("u=180;h=c;v=b;s=0.5", Memc[format], SZ_LINE)
	case ABSORPTION, GABSORPTION:
	    y = min (IMDATA(id,pix), IMDATA(id,pix+1))
	    tick = -TICK
	    gap = -GAP
	    call strcpy ("u=0;h=c;v=t;s=0.5", Memc[format], SZ_LINE)
	}

	call gctran (ID_GP(id), x, y, mx, my, 1, 0)
	call gctran (ID_GP(id), mx, my + gap, x1, y1, 0, 1)
	call gctran (ID_GP(id), mx, my + gap + tick, x1, y2, 0, 1)
	color = gstati (ID_GP(id), G_PLCOLOR)
	call gseti (ID_GP(id), G_PLCOLOR, color+1)
	call gline (ID_GP(id), x1, y1, x1, y2)
	call gseti (ID_GP(id), G_PLCOLOR, color)

	call gctran (ID_GP(id), mx, my + tick + 2 * gap, x1, y2, 0, 1)
	color = gstati (ID_GP(id), G_TXCOLOR)
	call gseti (ID_GP(id), G_TXCOLOR, color+1)
	switch (ID_LABELS(id)) {
	case 2:
	    call sprintf (Memc[label], SZ_LINE, "%d")
		call pargi (feature)
	    call gtext (ID_GP(id), x1, y2, Memc[label], Memc[format])
	case 3:
	    call sprintf (Memc[label], SZ_LINE, "%0.2f")
		call pargd (PIX(id,feature))
	    call gtext (ID_GP(id), x1, y2, Memc[label], Memc[format])
	case 4:
	    if (!IS_INDEFD (USER(id,feature))) {
	        call sprintf (Memc[label], SZ_LINE, "%0.4f")
		    call pargd (USER(id,feature))
		call gtext (ID_GP(id), x1, y2, Memc[label], Memc[format])
	    }
	case 5:
	    label = Memi[ID_LABEL(id)+feature-1]
	    if (label != NULL)
		call gtext (ID_GP(id), x1, y2, Memc[label], Memc[format])
	case 6:
	    Memc[label] = EOS
	    ptr = Memi[ID_LABEL(id)+feature-1]
	    if (!IS_INDEFD (USER(id,feature))) {
		if (ptr != NULL) {
		    call sprintf (Memc[label], SZ_LINE, "%0.4f %s")
			call pargd (USER(id,feature))
			call pargstr (Memc[ptr])
		} else {
		    call sprintf (Memc[label], SZ_LINE, "%0.4f")
			call pargd (USER(id,feature))
		}
	    } else if (ptr != NULL)
		call strcpy (Memc[ptr], Memc[label], SZ_LINE)
	    if (Memc[label] != EOS)
		call gtext (ID_GP(id), x1, y2, Memc[label], Memc[format])
	}
	call gseti (ID_GP(id), G_TXCOLOR, color)

	call sfree (sp)
	call gflush (ID_GP(id))
end