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

package provide DS9 1.0

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

    # see if we already have a header window visible
    if {[winfo exists $var(top)]} {
	raise $var(top)
	return
    }

    # variables
    set arrows [$var(frame) get marker $var(id) line arrow]
    set var(p1arrow) [lindex $arrows 0]
    set var(p2arrow) [lindex $arrows 1]

    # procs
    set var(which) line
    set var(proc,apply) LineApply
    set var(proc,coordCB) LineCoordCB
    set var(proc,editCB) LineEditCB
    set var(proc,distCB) LineDistCB

    # base
    MarkerBaseLineDialog $varname 375 150
    # raise plot?
    global marker
    set var(plot2d) $marker(plot2d)

    # analysis
    $var(mb) add cascade -label [msgcat::mc {Analysis}] -menu $var(mb).analysis
    menu $var(mb).analysis

    # plot2d
    MarkerAnalysisPlot2dDialog $varname

    set f $var(top).param

    # Arrows
    ttk::label $f.tarrow -text [msgcat::mc {Arrow}]
    ttk::checkbutton $f.p1arrow -variable ${varname}(p1arrow) \
	-text [msgcat::mc {Left}] -command "LineArrow $varname"
    ttk::checkbutton $f.p2arrow -variable ${varname}(p2arrow) \
	-text [msgcat::mc {Right}] -command "LineArrow $varname"

    grid $f.tarrow $f.p1arrow $f.p2arrow -padx 2 -pady 2 -sticky w
}

# actions

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

    $var(frame) marker $var(id) line point $var(system) $var(sky) \
	$var(x) $var(y) $var(x2) $var(y2)

    MarkerBaseLineApply $varname
}

# support

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

    $var(frame) marker $var(id) line arrow $var(p1arrow) $var(p2arrow)
}

# callbacks

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

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

    MarkerAnalysisPlot2dSystem $varname
    MarkerBaseCoordCB $varname
    LineEditCB $varname
}

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

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

    MarkerBaseLineEditCB $varname

    set var(dist) [$var(frame) get marker $var(id) line length \
		       $var(dcoord) $var(dformat)]
    set var(angle) [$var(frame) get marker $var(id) angle \
			$var(system) $var(sky)]
}

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

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

    set var(dist) [$var(frame) get marker $var(id) line length \
		       $var(dcoord) $var(dformat)]
}