19 .menubar.ops add command -label Plot -command "addPlot"
21 proc deiconifyPltWindowOptions {} {
22 if {![
winfo exists .pltWindowOptions]} {
23 global plotWindowOptions_legend plotWindowOptions_grid
24 toplevel .pltWindowOptions
25 frame .pltWindowOptions.xticks
26 label .pltWindowOptions.xticks.label -text "Number of x ticks"
27 entry .pltWindowOptions.xticks.val -width 20
28 pack .pltWindowOptions.xticks.label .pltWindowOptions.xticks.val -side left
30 frame .pltWindowOptions.yticks
31 label .pltWindowOptions.yticks.label -text "Number of y ticks"
32 entry .pltWindowOptions.yticks.val -width 20
33 pack .pltWindowOptions.yticks.label .pltWindowOptions.yticks.val -side left
35 frame .pltWindowOptions.xtickAngle
36 label .pltWindowOptions.xtickAngle.label -text "x ticks angle"
37 entry .pltWindowOptions.xtickAngle.val -width 20
38 pack .pltWindowOptions.xtickAngle.label .pltWindowOptions.xtickAngle.val -side left
40 frame .pltWindowOptions.exp_threshold
41 label .pltWindowOptions.exp_threshold.label -text "exp threshold"
42 entry .pltWindowOptions.exp_threshold.val -width 20
43 pack .pltWindowOptions.exp_threshold.label .pltWindowOptions.exp_threshold.val -side left
45 frame .pltWindowOptions.plotType
46 label .pltWindowOptions.plotType.label -text "Plot type"
47 ttk::combobox .pltWindowOptions.plotType.val -width 20 -state readonly -textvariable plotWindowOptions(plotType) -value {line bar automatic}
48 pack .pltWindowOptions.plotType.label .pltWindowOptions.plotType.val -side left
52 frame .pltWindowOptions.options
53 checkbutton .pltWindowOptions.options.grid -text "Grid" -variable plotWindowOptions(grid)
54 checkbutton .pltWindowOptions.options.subgrid -text "Subgrid" -variable plotWindowOptions(subgrid)
55 checkbutton .pltWindowOptions.options.legend -text "Legend:" -variable plotWindowOptions(legend)
56 pack .pltWindowOptions.options.grid .pltWindowOptions.options.subgrid .pltWindowOptions.options.legend -side left
58 frame .pltWindowOptions.logscale
59 checkbutton .pltWindowOptions.logscale.xv -text "x log scale" -variable plotWindowOptions(xlog)
60 checkbutton .pltWindowOptions.logscale.yv -text "y log scale" -variable plotWindowOptions(ylog)
61 pack .pltWindowOptions.logscale.xv .pltWindowOptions.logscale.yv -side left
63 frame .pltWindowOptions.title
64 label .pltWindowOptions.title.label -text Title
65 entry .pltWindowOptions.title.val -width 20
66 pack .pltWindowOptions.title.label .pltWindowOptions.title.val -side left
68 frame .pltWindowOptions.xaxislabel
69 label .pltWindowOptions.xaxislabel.label -text "X label"
70 entry .pltWindowOptions.xaxislabel.val -width 20
71 pack .pltWindowOptions.xaxislabel.label .pltWindowOptions.xaxislabel.val -side left
73 frame .pltWindowOptions.yaxislabel
74 label .pltWindowOptions.yaxislabel.label -text "Y label"
75 entry .pltWindowOptions.yaxislabel.val -width 20
76 pack .pltWindowOptions.yaxislabel.label .pltWindowOptions.yaxislabel.val -side left
78 frame .pltWindowOptions.y1axislabel
79 label .pltWindowOptions.y1axislabel.label -text "RHS Y label"
80 entry .pltWindowOptions.y1axislabel.val -width 20
81 pack .pltWindowOptions.y1axislabel.label .pltWindowOptions.y1axislabel.val -side left
83 pack .pltWindowOptions.title .pltWindowOptions.xaxislabel .pltWindowOptions.yaxislabel .pltWindowOptions.y1axislabel .pltWindowOptions.plotType
85 frame .pltWindowOptions.buttonBar
86 button .pltWindowOptions.buttonBar.ok -text OK
87 button .pltWindowOptions.buttonBar.cancel -text Cancel -command {
88 wm withdraw .pltWindowOptions
89 grab release .pltWindowOptions
91 pack .pltWindowOptions.buttonBar.ok .pltWindowOptions.buttonBar.cancel -side left
92 pack .pltWindowOptions.buttonBar -side bottom
94 pack .pltWindowOptions.xticks .pltWindowOptions.yticks .pltWindowOptions.options .pltWindowOptions.logscale
96 wm deiconify .pltWindowOptions
101 wm withdraw .pltWindowOptions
103 proc setPlotOptions {plot} {
104 global plotWindowOptions
105 $plot.grid $plotWindowOptions(grid)
106 $plot.subgrid $plotWindowOptions(subgrid)
107 $plot.logx $plotWindowOptions(xlog)
108 $plot.logy $plotWindowOptions(ylog)
109 $plot.percent $plotWindowOptions(ypercent)
110 $plot.plotType $plotWindowOptions(plotType)
111 $plot.nxTicks [.pltWindowOptions.xticks.val get]
112 $plot.nyTicks [.pltWindowOptions.yticks.val get]
113 $plot.xtickAngle [.pltWindowOptions.xtickAngle.val get]
114 $plot.exp_threshold [.pltWindowOptions.exp_threshold.val get]
115 $plot.title [.pltWindowOptions.title.val get]
116 $plot.xlabel [.pltWindowOptions.xaxislabel.val get]
117 $plot.ylabel [.pltWindowOptions.yaxislabel.val get]
118 $plot.y1label [.pltWindowOptions.y1axislabel.val get]
119 $plot.legend $plotWindowOptions(legend)
120 $plot.legendSide boundingBox
122 catch {
wm title .plot$id [plot.title]}
123 wm withdraw .pltWindowOptions
124 grab release .pltWindowOptions
127 proc doPlotOptions {plot} {
128 global plotWindowOptions
129 set plotWindowOptions(grid) [$plot.grid]
130 set plotWindowOptions(subgrid) [$plot.subgrid]
131 set plotWindowOptions(xlog) [$plot.logx]
132 set plotWindowOptions(ylog) [$plot.logy]
133 set plotWindowOptions(ypercent) [$plot.percent]
134 set plotWindowOptions(plotType) [$plot.plotType]
137 .pltWindowOptions.xticks.val delete 0 end
138 .pltWindowOptions.xticks.val insert 0 [$plot.nxTicks]
139 .pltWindowOptions.yticks.val delete 0 end
140 .pltWindowOptions.yticks.val insert 0 [$plot.nyTicks]
141 .pltWindowOptions.xtickAngle.val delete 0 end
142 .pltWindowOptions.xtickAngle.val insert 0 [$plot.xtickAngle]
143 .pltWindowOptions.exp_threshold.val delete 0 end
144 .pltWindowOptions.exp_threshold.val insert 0 [$plot.exp_threshold]
145 .pltWindowOptions.title.val delete 0 end
146 .pltWindowOptions.title.val insert 0 [$plot.title]
147 .pltWindowOptions.xaxislabel.val delete 0 end
148 .pltWindowOptions.xaxislabel.val insert 0 [$plot.xlabel]
149 .pltWindowOptions.yaxislabel.val delete 0 end
150 .pltWindowOptions.yaxislabel.val insert 0 [$plot.ylabel]
151 .pltWindowOptions.y1axislabel.val delete 0 end
152 .pltWindowOptions.y1axislabel.val insert 0 [$plot.y1label]
154 .pltWindowOptions.buttonBar.ok configure -command "setPlotOptions $plot"
155 set plotWindowOptions(legend) [$plot.legend]
156 grab .pltWindowOptions
160 proc plotDoubleClick {plotId} {
161 toplevel .plot$plotId
162 wm title .plot$plotId [$plotId.title]
164 labelframe .plot$plotId.menubar -relief raised
165 button .plot$plotId.menubar.options -text Options -command "doPlotOptions $plotId" -relief flat
166 pack .plot$plotId.menubar.options -side left
168 pack .plot$plotId.menubar -side top -fill x
170 image create cairoSurface .plot$plotId.image -surface $plotId -width 400 -height 400
171 $plotId.deleteCallback "destroy .plot$plotId"
172 label .plot$plotId.label -image .plot$plotId.image -width 400 -height 400
173 pack .plot$plotId.label -fill both -expand 1
177 return [
format "%02x" [
expr int(256*($x-1e-3))]]
181 proc colourName {x} {
182 return "#[
hex [$x.r]][
hex [$x.g]][
hex [$x.b]]"
185 proc configColourButton b {
186 $b configure -background [
tk_chooseColor -initialcolor [$b cget -background]]
190 frame .penStyles.row$i
191 label .penStyles.row$i.no -text $i
192 button .penStyles.row$i.colour -background [
colourName $p.colour] -command "configColourButton .penStyles.row$i.colour"
193 entry .penStyles.row$i.width -width 10
194 .penStyles.row$i.width insert 0 [$p.width]
195 ttk::combobox .penStyles.row$i.style -width 10 -state readonly -values {"————" "- - -" "· · ·" "- · -"}
196 pack .penStyles.row$i.no .penStyles.row$i.colour .penStyles.row$i.width .penStyles.row$i.style -side left
199 proc penStyles {plot} {
201 for {
set i 0} {$i<[$plot.palette.size]} {
incr i} {
202 makeRow $i [$plot.palette.@elem $i]
203 pack .penStyles.row$i
206 button .penStyles.buttonBar.add -text "+" -command "addRow $plot"
207 pack .penStyles.buttonBar.add -before .penStyles.buttonBar.cancel -side left
209 wm transient .penStyles
212 proc penStyleOK plot {
213 for {
set i 0} {$i<[$plot.palette.size]} {
incr i} {
214 set p [$plot.palette.@elem $i]
215 minsky.setColour $i [.penStyles.row$i.colour cget -background]
216 $p.width [.penStyles.row$i.width get]
217 switch [.penStyles.row$i.style get] {
218 "————" {$p.dashStyle solid}
219 "- - -" {$p.dashStyle dash}
220 "· · ·" {$p.dashStyle dot}
221 "- · -" {$p.dashStyle dashDot}
228 set i [$plot.palette.size]
230 makeRow $i [$plot.palette.@elem $i]
231 pack .penStyles.row$i -before .penStyles.buttonBar