summaryrefslogtreecommitdiffstats
path: root/ds9/library/plotconfig.tcl
blob: c79c1e24551d7bd11ed804d5312035dfe20477b1 (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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
#  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

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

    PlotLoadConfigFile $varname [OpenFileDialog apconfigfbox]
}

# used by backup
proc PlotLoadConfigFile {varname filename} {
    upvar #0 $varname var
    global $varname

    if {$filename == {}} {
	return
    }

    source $filename

    set var(graph,title,family) $analysisplot(graph,title,family)
    set var(graph,title,size) $analysisplot(graph,title,size) 
    set var(graph,title,weight) $analysisplot(graph,title,weight) 
    set var(graph,title,slant) $analysisplot(graph,title,slant) 

    set var(legend) $analysisplot(legend) 
    set var(legend,position) $analysisplot(legend,position) 
    set var(legend,title,family) $analysisplot(legend,title,family) 
    set var(legend,title,size) $analysisplot(legend,title,size) 
    set var(legend,title,weight) $analysisplot(legend,title,weight) 
    set var(legend,title,slant) $analysisplot(legend,title,slant) 
    set var(legend,font,family) $analysisplot(legend,font,family) 
    set var(legend,font,size) $analysisplot(legend,font,size) 
    set var(legend,font,weight) $analysisplot(legend,font,weight) 
    set var(legend,font,slant) $analysisplot(legend,font,slant) 

    set var(axis,title,family) $analysisplot(axis,title,family) 
    set var(axis,title,size) $analysisplot(axis,title,size) 
    set var(axis,title,weight) $analysisplot(axis,title,weight) 
    set var(axis,title,slant) $analysisplot(axis,title,slant) 

    set var(axis,font,family) $analysisplot(axis,font,family) 
    set var(axis,font,size) $analysisplot(axis,font,size) 
    set var(axis,font,weight) $analysisplot(axis,font,weight) 
    set var(axis,font,slant) $analysisplot(axis,font,slant) 

    # per Graph
    set var(graph,title) $analysisplot(graph,title)

    set var(graph,legend,title) $analysisplot(legend,title) 

    set var(graph,axis,x,title) $analysisplot(axis,x,title) 
    set var(graph,axis,x,grid) $analysisplot(axis,x,grid) 
    set var(graph,axis,x,log) $analysisplot(axis,x,log) 
    set var(graph,axis,x,flip) $analysisplot(axis,x,flip) 
    set var(graph,axis,x,auto) $analysisplot(axis,x,auto) 
    set var(graph,axis,x,min) $analysisplot(axis,x,min) 
    set var(graph,axis,x,max) $analysisplot(axis,x,max) 
    set var(graph,axis,x,format) $analysisplot(axis,x,format)

    set var(graph,axis,y,title) $analysisplot(axis,y,title) 
    set var(graph,axis,y,grid) $analysisplot(axis,y,grid) 
    set var(graph,axis,y,log) $analysisplot(axis,y,log) 
    set var(graph,axis,y,flip) $analysisplot(axis,y,flip) 
    set var(graph,axis,y,auto) $analysisplot(axis,y,auto) 
    set var(graph,axis,y,min) $analysisplot(axis,y,min) 
    set var(graph,axis,y,max) $analysisplot(axis,y,max) 
    set var(graph,axis,y,format) $analysisplot(axis,y,format) 

    # per Dataset
    set var(graph,ds,show) $analysisplot(show) 
    set var(graph,ds,smooth) $analysisplot(smooth) 
    set var(graph,ds,color) $analysisplot(color) 
    set var(graph,ds,fill) $analysisplot(fill) 
    set var(graph,ds,fill,color) $analysisplot(fill,color) 
    set var(graph,ds,width) $analysisplot(width) 
    set var(graph,ds,dash) $analysisplot(dash) 

    set var(graph,ds,shape,symbol) $analysisplot(shape,symbol) 
    set var(graph,ds,shape,fill) $analysisplot(shape,fill) 
    set var(graph,ds,shape,color) $analysisplot(shape,color) 

    set var(graph,ds,error) $analysisplot(error) 
    set var(graph,ds,error,cap) $analysisplot(error,cap) 
    set var(graph,ds,error,color) $analysisplot(error,color) 
    set var(graph,ds,error,width) $analysisplot(error,width) 

    set var(graph,ds,bar,relief) $analysisplot(bar,relief) 

    unset analysisplot

    # backward compatibility
    FixVar ${varname}(graph,title,family) ${varname}(titleFont)
    FixVar ${varname}(graph,title,size) ${varname}(titleSize)
    FixVar ${varname}(graph,title,weight) ${varname}(titleWeight)
    FixVar ${varname}(graph,title,slant) ${varname}(titleSlant)

    FixVar ${varname}(axis,title,family) ${varname}(textlabFont)
    FixVar ${varname}(axis,title,size) ${varname}(textlabSize)
    FixVar ${varname}(axis,title,weight) ${varname}(textlabWeight)
    FixVar ${varname}(axis,title,slant) ${varname}(textlabSlant)

    FixVar ${varname}(axis,font,family) ${varname}(numlabFont)
    FixVar ${varname}(axis,font,size) ${varname}(numlabSize)
    FixVar ${varname}(axis,font,weight) ${varname}(numlabWeight)
    FixVar ${varname}(axis,font,slant) ${varname}(numlabSlant)

    FixVar ${varname}(graph,ds,show) ${varname}(linear)
    FixVar ${varname}(graph,ds,width) ${varname}(linear,width)
    FixVar ${varname}(graph,ds,color) ${varname}(linear,color)
    if {[info exists ${varname}(linear,dash)]} {
	set var(linear,dash) [FromYesNo $var(linear,dash)]
    }
    FixVar ${varname}(graph,ds,dash) ${varname}(linear,dash)

    FixVar ${varname}(graph,ds,shape,color) ${varname}(discrete,color)
    FixVar ${varname}(graph,ds,shape,fill) ${varname}(discrete,fill)

    if {[info exists ${varname}(discrete)]} {
	if {$var(discrete)} {
	    FixVar ${varname}(graph,ds,shape,symbol) \
		${varname}(discrete,symbol)
	} else {
	    FixVarRm ${varname}(discrete,symbol)
	}
    }

    FixVarRm ${varname}(bar)
    FixVarRm ${varname}(bar,color)

    FixVarRm ${varname}(discrete)

    FixVarRm ${varname}(quadratic)
    FixVarRm ${varname}(quadratic,width)
    FixVarRm ${varname}(quadratic,color)
    FixVarRm ${varname}(quadratic,dash)

    FixVarRm ${varname}(step)
    FixVarRm ${varname}(step,color)
    FixVarRm ${varname}(step,dash)
    FixVarRm ${varname}(step,width)

    if {[info exists var(grid)]} {
	set var(graph,axis,x,grid) $var(grid)
	set var(graph,axis,y,grid) $var(grid)
	unset var(grid)
    }
    if {[info exists var(format)]} {
	set var(graph,format) $var(format)
	set var(graph,axis,x,format) $var(format,x)
	set var(graph,axis,y,format) $var(format,y)
	unset var(format)
	unset var(format,x)
	unset var(format,y)
    }

    if {[info exists var(grid,log)]} {
	switch $var(grid,log) {
	    linearlinear {
		set var(graph,axis,x,log) 0
		set var(graph,axis,y,log) 0
	    }
	    linearlog {
		set var(graph,axis,x,log) 0
		set var(graph,axis,y,log) 1
	    }
	    loglinear {
		set var(graph,axis,x,log) 1
		set var(graph,axis,y,log) 0
	    }
	    loglog {
		set var(graph,axis,x,log) 1
		set var(graph,axis,y,log) 1
	    }
	}
	unset var(grid,log)
    }

    $var(graph,proc,updateelement) $varname
    PlotUpdateCanvas $varname
    PlotUpdateGraph $varname

    PlotUpdateMenus $varname
}

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

    PlotSaveConfigFile $varname [SaveFileDialog apconfigfbox]
}

proc PlotSaveConfigFile {varname filename} {
    upvar #0 $varname var
    global $varname

    if {$filename == {}} {
	return
    }

    set ch [open $filename w]

    set analysisplot(graph,title,family) $var(graph,title,family) 
    set analysisplot(graph,title,size) $var(graph,title,size) 
    set analysisplot(graph,title,weight) $var(graph,title,weight) 
    set analysisplot(graph,title,slant) $var(graph,title,slant) 

    set analysisplot(legend) $var(legend)
    set analysisplot(legend,position) $var(legend,position)
    set analysisplot(legend,title,family) $var(legend,title,family)
    set analysisplot(legend,title,size) $var(legend,title,size)
    set analysisplot(legend,title,weight) $var(legend,title,weight)
    set analysisplot(legend,title,slant) $var(legend,title,slant)
    set analysisplot(legend,font,family) $var(legend,font,family)
    set analysisplot(legend,font,size) $var(legend,font,size)
    set analysisplot(legend,font,weight) $var(legend,font,weight)
    set analysisplot(legend,font,slant) $var(legend,font,slant)

    set analysisplot(axis,title,family) $var(axis,title,family) 
    set analysisplot(axis,title,size) $var(axis,title,size) 
    set analysisplot(axis,title,weight) $var(axis,title,weight) 
    set analysisplot(axis,title,slant) $var(axis,title,slant) 

    set analysisplot(axis,font,family) $var(axis,font,family) 
    set analysisplot(axis,font,size) $var(axis,font,size) 
    set analysisplot(axis,font,weight) $var(axis,font,weight)
    set analysisplot(axis,font,slant) $var(axis,font,slant)

    # per Graph
    set analysisplot(graph,title) $var(graph,title) 

    set analysisplot(legend,title) $var(graph,legend,title)

    set analysisplot(axis,x,title) $var(graph,axis,x,title) 
    set analysisplot(axis,x,grid) $var(graph,axis,x,grid)
    set analysisplot(axis,x,log) $var(graph,axis,x,log) 
    set analysisplot(axis,x,flip) $var(graph,axis,x,flip) 
    set analysisplot(axis,x,auto) $var(graph,axis,x,auto)
    set analysisplot(axis,x,min) $var(graph,axis,x,min)
    set analysisplot(axis,x,max) $var(graph,axis,x,max)
    set analysisplot(axis,x,format) $var(graph,axis,x,format)

    set analysisplot(axis,y,title) $var(graph,axis,y,title)
    set analysisplot(axis,y,grid) $var(graph,axis,y,grid)
    set analysisplot(axis,y,log) $var(graph,axis,y,log) 
    set analysisplot(axis,y,flip) $var(graph,axis,y,flip) 
    set analysisplot(axis,y,auto) $var(graph,axis,y,auto)
    set analysisplot(axis,y,min) $var(graph,axis,y,min)
    set analysisplot(axis,y,max) $var(graph,axis,y,max)
    set analysisplot(axis,y,format) $var(graph,axis,y,format)

    # per Dataset
    set analysisplot(show) $var(graph,ds,show)
    set analysisplot(smooth) $var(graph,ds,smooth)
    set analysisplot(color) $var(graph,ds,color)
    set analysisplot(fill) $var(graph,ds,fill)
    set analysisplot(fill,color) $var(graph,ds,fill,color)
    set analysisplot(width) $var(graph,ds,width)
    set analysisplot(dash) $var(graph,ds,dash)

    set analysisplot(shape,symbol) $var(graph,ds,shape,symbol)
    set analysisplot(shape,fill) $var(graph,ds,shape,fill)
    set analysisplot(shape,color) $var(graph,ds,shape,color)

    set analysisplot(error) $var(graph,ds,error)
    set analysisplot(error,cap) $var(graph,ds,error,cap)
    set analysisplot(error,color) $var(graph,ds,error,color)
    set analysisplot(error,width) $var(graph,ds,error,width)

    set analysisplot(bar,relief) $var(graph,ds,bar,relief)

    puts $ch "array set analysisplot \{ [array get analysisplot] \}"
    close $ch
}