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

package provide DS9 1.0

proc MarkerBaseCenterDialog {varname} {
    upvar #0 $varname var
    global $varname

    # variables
    set var(x) 0
    set var(y) 0

    # base
    MarkerBaseDialog $varname

    # init
    MarkerBaseCenterMoveCB $varname

    # callbacks
    $var(frame) marker $var(id) callback move MarkerBaseCenterMoveCB $varname

    set f $var(top).param

    # Center
    ttk::label $f.tcenter -text [msgcat::mc {Center}]
    ttk::entry $f.centerx -textvariable ${varname}(x) -width 13
    ttk::entry $f.centery -textvariable ${varname}(y) -width 13

    CoordMenuButton $f.ucenter $varname system 1 sky skyformat \
	[list $var(proc,coordCB) $varname]
    CoordMenuEnable $f.ucenter.menu $varname system 1 sky skyformat

    grid $f.tcenter $f.centerx $f.centery $f.ucenter -padx 2 -pady 2 -sticky w
}

proc MarkerBaseCenterClose {varname} {
    upvar #0 $varname var
    global $varname

    $var(frame) marker $var(id) delete callback move MarkerBaseCenterMoveCB

    MarkerBaseClose $varname
}

proc MarkerBaseCenterApply {varname} {
    upvar #0 $varname var
    global $varname

    if {$var(x) != {} &&
	$var(y) != {}} {
	$var(frame) marker $var(id) move to $var(system) $var(sky) \
	    $var(x) $var(y)
    }

    MarkerBaseApply $varname
}

proc MarkerBaseCenterRotate {varname} {
    upvar #0 $varname var
    global $varname

    $var(frame) marker $var(id) angle $var(angle) $var(system) $var(sky)
}

# callbacks

proc MarkerBaseCenterMoveCB {varname {dummy {}}} {
    upvar #0 $varname var
    global $varname

    global debug
    if {$debug(tcl,marker)} {
	puts stderr "MarkerBaseCenterMoveCB"
    }

    set center [$var(frame) get marker $var(id) center $var(system) $var(sky) \
		    $var(skyformat)]
    set var(x) [lindex $center 0]
    set var(y) [lindex $center 1]
}

proc MarkerBaseCenterRotateCB {varname {dummy {}}} {
    upvar #0 $varname var
    global $varname

    set var(angle) [$var(frame) get marker $var(id) angle \
			$var(system) $var(sky)]
}