Minsky
plots.tcl File Reference

Go to the source code of this file.

Functions

 deiconifyPltWindowOptions
 
 setPlotOptions plot
 
 doPlotOptions plot
 
 plotDoubleClick plotId
 
 hex x
 
 colourName x
 
 configColourButton b
 
 makeRow i p
 
 penStyles plot
 
 penStyleOK plot
 
 addRow plot
 

Function Documentation

◆ addRow()

addRow   plot  

Definition at line 227 of file plots.tcl.

References makeRow(), and pack().

227 proc addRow plot {
228  set i [$plot.palette.size]
229  $plot.extendPalette
230  makeRow $i [$plot.palette.@elem $i]
231  pack .penStyles.row$i -before .penStyles.buttonBar
232 }
Here is the call graph for this function:

◆ colourName()

colourName   x  

Definition at line 181 of file plots.tcl.

References hex().

Referenced by makeRow().

181 proc colourName {x} {
182  return "#[hex [$x.r]][hex [$x.g]][hex [$x.b]]"
183 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ configColourButton()

configColourButton   b  

Definition at line 185 of file plots.tcl.

185 proc configColourButton b {
186  $b configure -background [tk_chooseColor -initialcolor [$b cget -background]]
187 }

◆ deiconifyPltWindowOptions()

deiconifyPltWindowOptions

Definition at line 21 of file plots.tcl.

References pack().

Referenced by doPlotOptions().

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
29 
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
34 
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
39 
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
44 
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
49 
50 
51 
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
57 
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
62 
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
67 
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
72 
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
77 
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
82 
83  pack .pltWindowOptions.title .pltWindowOptions.xaxislabel .pltWindowOptions.yaxislabel .pltWindowOptions.y1axislabel .pltWindowOptions.plotType
84 
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
90  }
91  pack .pltWindowOptions.buttonBar.ok .pltWindowOptions.buttonBar.cancel -side left
92  pack .pltWindowOptions.buttonBar -side bottom
93 
94  pack .pltWindowOptions.xticks .pltWindowOptions.yticks .pltWindowOptions.options .pltWindowOptions.logscale
95  } else {
96  wm deiconify .pltWindowOptions
97  }
98 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ doPlotOptions()

doPlotOptions   plot  

Definition at line 127 of file plots.tcl.

References deiconifyPltWindowOptions().

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]
136 
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]
153 
154  .pltWindowOptions.buttonBar.ok configure -command "setPlotOptions $plot"
155  set plotWindowOptions(legend) [$plot.legend]
156  grab .pltWindowOptions
157 }
Here is the call graph for this function:

◆ hex()

hex   x  

Definition at line 176 of file plots.tcl.

Referenced by colourName().

176 proc hex x {
177  return [format "%02x" [expr int(256*($x-1e-3))]]
178 }
Here is the caller graph for this function:

◆ makeRow()

makeRow   i p  

Definition at line 189 of file plots.tcl.

References colourName(), and pack().

Referenced by addRow(), and penStyles().

189 proc makeRow {i p} {
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
197 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ penStyleOK()

penStyleOK   plot  

Definition at line 212 of file plots.tcl.

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}
222  }
223  }
224  $plot.requestRedraw
225 }

◆ penStyles()

penStyles   plot  

Definition at line 199 of file plots.tcl.

References buttonBar(), makeRow(), and pack().

199 proc penStyles {plot} {
200  toplevel .penStyles
201  for {set i 0} {$i<[$plot.palette.size]} {incr i} {
202  makeRow $i [$plot.palette.@elem $i]
203  pack .penStyles.row$i
204  }
205  buttonBar .penStyles "penStyleOK $plot"
206  button .penStyles.buttonBar.add -text "+" -command "addRow $plot"
207  pack .penStyles.buttonBar.add -before .penStyles.buttonBar.cancel -side left
208  grab set .penStyles
209  wm transient .penStyles
210 }
Here is the call graph for this function:

◆ plotDoubleClick()

plotDoubleClick   plotId  

Definition at line 160 of file plots.tcl.

References pack().

Referenced by editItem().

160 proc plotDoubleClick {plotId} {
161  toplevel .plot$plotId
162  wm title .plot$plotId [$plotId.title]
163 
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
167 
168  pack .plot$plotId.menubar -side top -fill x
169 
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
174 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setPlotOptions()

setPlotOptions   plot  

Definition at line 103 of file plots.tcl.

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
121  canvas.requestRedraw
122  catch {wm title .plot$id [plot.title]}
123  wm withdraw .pltWindowOptions
124  grab release .pltWindowOptions
125 }