summaryrefslogtreecommitdiffstats
path: root/ds9/library/mwcs.tcl
blob: e9b0c6c2cf66b995fa505ec606c1c65e2fa1862c (plain)
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
142
#  Copyright (C) 1999-2018
#  Smithsonian Astrophysical Observatory, Cambridge, MA, USA
#  For conditions of distribution and use, see copyright notice in "copyright"

package provide DS9 1.0

# Menu

proc WCSMainMenu {} {
    global ds9
    global wcs

    CoordMenu $ds9(mb).wcs wcs system 0 sky skyformat UpdateWCS
    $ds9(mb).wcs add separator
    $ds9(mb).wcs add command -label "[msgcat::mc {WCS Parameters}]..." \
	-command WCSDialog
}

proc UpdateWCSMenu {} {
    global wcs
    global ds9
    global current
    global bin

    global debug
    if {$debug(tcl,update)} {
	puts stderr "UpdateWCSMenu"
    }

    if {$current(frame) != {}} {
	$ds9(mb) entryconfig [msgcat::mc {WCS}] -state normal
	ConfigureButtons wcs normal

	set ww [$current(frame) get wcs]
	set wcs(system) [lindex $ww 0]
	set wcs(sky) [lindex $ww 1]
	set wcs(skyformat) [lindex $ww 2]

	set wcs(frame) $current(frame)
	if {[$current(frame) has fits]} {
	    CoordMenuEnable $ds9(mb).wcs wcs system {} sky skyformat
	} else {
	    CoordMenuReset $ds9(mb).wcs wcs system {} sky skyformat
	}
	LayoutWCSInfoBox $current(frame)
    } else {
	$ds9(mb) entryconfig [msgcat::mc {WCS}] -state disabled
	ConfigureButtons wcs disabled
    }
}

proc PrefsDialogWCSMenu {w} {
    set f [ttk::labelframe $w.mwcs -text [msgcat::mc {WCS}]]

    ttk::menubutton $f.menu -text [msgcat::mc {Menu}] -menu $f.menu.menu
    PrefsDialogButtonbarWCS $f.buttonbar

    grid $f.menu $f.buttonbar -padx 2 -pady 2 -sticky w

    CoordMenu $f.menu.menu pwcs system 0 sky skyformat {}

    pack $f -side top -fill both -expand true
}

# Buttons

proc ButtonsWCSDef {} {
    global pbuttons

    array set pbuttons {
	wcs,fk4 1
	wcs,fk5 1
	wcs,icrs 1
	wcs,galactic 1
	wcs,ecliptic 1
	wcs,degrees 1
	wcs,sexagesimal 1
    }
}

proc CreateButtonsWCS {} {
    global buttons
    global ds9
    global wcs

    ttk::frame $ds9(buttons).wcs

    RadioButton $ds9(buttons).wcs.fk4 {fk4} \
	wcs(sky) fk4 UpdateWCS
    RadioButton $ds9(buttons).wcs.fk5 {fk5} \
	wcs(sky) fk5 UpdateWCS
    RadioButton $ds9(buttons).wcs.icrs \
	[string tolower [msgcat::mc {ICRS}]] \
	wcs(sky) icrs UpdateWCS
    RadioButton $ds9(buttons).wcs.galactic \
	[string tolower [msgcat::mc {Galactic}]] \
	wcs(sky) galactic UpdateWCS
    RadioButton $ds9(buttons).wcs.ecliptic \
	[string tolower [msgcat::mc {Ecliptic}]] \
	wcs(sky) ecliptic UpdateWCS
    RadioButton $ds9(buttons).wcs.degrees \
	[string tolower [msgcat::mc {Degrees}]] \
	wcs(skyformat) degrees UpdateWCS
    RadioButton $ds9(buttons).wcs.sexagesimal {sexagesimal} \
	wcs(skyformat) sexagesimal UpdateWCS

    set buttons(wcs) "
        $ds9(buttons).wcs.fk4 pbuttons(wcs,fk4)
        $ds9(buttons).wcs.fk5 pbuttons(wcs,fk5)
        $ds9(buttons).wcs.icrs pbuttons(wcs,icrs)
        $ds9(buttons).wcs.galactic pbuttons(wcs,galactic)
        $ds9(buttons).wcs.ecliptic pbuttons(wcs,ecliptic)
        $ds9(buttons).wcs.degrees pbuttons(wcs,degrees)
        $ds9(buttons).wcs.sexagesimal pbuttons(wcs,sexagesimal)
    "
}

proc PrefsDialogButtonbarWCS {f} {
    global buttons
    global pbuttons

    ttk::menubutton $f -text [msgcat::mc {Buttonbar}] -menu $f.menu
    
    set m $f.menu
    menu $m
    $m add checkbutton -label [msgcat::mc {FK4}] \
	-variable pbuttons(wcs,fk4) -command {UpdateButtons buttons(wcs)}
    $m add checkbutton -label [msgcat::mc {FK5}] \
	-variable pbuttons(wcs,fk5) -command {UpdateButtons buttons(wcs)}
    $m add checkbutton -label [msgcat::mc {ICRS}] \
	-variable pbuttons(wcs,icrs) -command {UpdateButtons buttons(wcs)}
    $m add checkbutton -label [msgcat::mc {Galactic}] \
	-variable pbuttons(wcs,galactic) -command {UpdateButtons buttons(wcs)}
    $m add checkbutton -label [msgcat::mc {Ecliptic}] \
	-variable pbuttons(wcs,ecliptic) -command {UpdateButtons buttons(wcs)}
    $m add separator
    $m add checkbutton -label [msgcat::mc {Degrees}] \
	-variable pbuttons(wcs,degrees) -command {UpdateButtons buttons(wcs)}
    $m add checkbutton -label [msgcat::mc {Sexagesimal}] \
	-variable pbuttons(wcs,sexagesimal) -command {UpdateButtons buttons(wcs)}
}