1 | |
---|
2 | # ---------------------------------------------------------------------- |
---|
3 | # COMPONENT: xyprint - Print X-Y plot. |
---|
4 | # |
---|
5 | # ====================================================================== |
---|
6 | # AUTHOR: Michael McLennan, Purdue University |
---|
7 | # Copyright (c) 2004-2005 Purdue Research Foundation |
---|
8 | # |
---|
9 | # See the file "license.terms" for information on usage and |
---|
10 | # redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
11 | # ====================================================================== |
---|
12 | package require Itk |
---|
13 | package require BLT |
---|
14 | |
---|
15 | #option add *XyPrint.width 3i widgetDefault |
---|
16 | #option add *XyPrint.height 3i widgetDefault |
---|
17 | option add *XyPrint.gridColor #d9d9d9 widgetDefault |
---|
18 | option add *XyPrint.activeColor blue widgetDefault |
---|
19 | option add *XyPrint.dimColor gray widgetDefault |
---|
20 | option add *XyPrint.controlBackground gray widgetDefault |
---|
21 | option add *XyPrint*Font "Arial 9" widgetDefault |
---|
22 | option add *XyPrint*Entry*width "6" widgetDefault |
---|
23 | option add *XyPrint*Entry*background "white" widgetDefault |
---|
24 | |
---|
25 | itk::usual ComboMenu { |
---|
26 | } |
---|
27 | itk::usual ComboEntry { |
---|
28 | } |
---|
29 | |
---|
30 | itcl::class Rappture::XyPrint { |
---|
31 | inherit itk::Widget |
---|
32 | |
---|
33 | constructor {args} {} |
---|
34 | destructor {} |
---|
35 | |
---|
36 | private variable _graph ""; # Original graph. |
---|
37 | private variable _clone ""; # Cloned graph. |
---|
38 | private variable _preview ""; # Preview image. |
---|
39 | private variable _savedSettings; # Array of settings. |
---|
40 | private variable _legendFontFamily "" |
---|
41 | private variable _legendFontSize "" |
---|
42 | private variable _tickFontFamily "" |
---|
43 | private variable _titleFontFamily "" |
---|
44 | private variable _tickFontSize "" |
---|
45 | private variable _titleFontSize "" |
---|
46 | private variable _format "" |
---|
47 | private variable _axis "" |
---|
48 | private variable _style "" |
---|
49 | private variable _position "" |
---|
50 | |
---|
51 | private common _oldSettingsFile "~/.rpsettings" |
---|
52 | private common _settingsFile "~/.rp_settings" |
---|
53 | |
---|
54 | public method print { graph toolName plotName } |
---|
55 | public method reset {} |
---|
56 | |
---|
57 | private method CopyOptions { cmd orig clone {exclude {}}} |
---|
58 | private method CloneGraph { orig } |
---|
59 | |
---|
60 | private method BuildGeneralTab {} |
---|
61 | private method BuildLayoutTab {} |
---|
62 | private method BuildLegendTab {} |
---|
63 | private method BuildAxisTab {} |
---|
64 | private method SetOption { opt } |
---|
65 | private method SetComponentOption { comp opt } |
---|
66 | private method SetNamedComponentOption { comp name opt } |
---|
67 | private method GetAxis {} |
---|
68 | private method GetElement { args } |
---|
69 | private method RegeneratePreview {} |
---|
70 | private method InitClone {} |
---|
71 | private method Pixels2Inches { pixels } |
---|
72 | private method Inches2Pixels { inches {defValue ""}} |
---|
73 | private method Color2RGB { color } |
---|
74 | |
---|
75 | private method ApplyGeneralSettings {} |
---|
76 | private method ApplyLegendSettings {} |
---|
77 | private method ApplyAxisSettings {} |
---|
78 | private method ApplyElementSettings {} |
---|
79 | private method ApplyLayoutSettings {} |
---|
80 | private method InitializeSettings {} |
---|
81 | private method CreateSettings { toolName plotName } |
---|
82 | private method RestoreSettings { toolName plotName } |
---|
83 | private method SaveSettings { toolName plotName } |
---|
84 | private method DestroySettings {} |
---|
85 | private method ResetSettings { } |
---|
86 | private method GetOutput {} |
---|
87 | private method SetWaitVariable { state } |
---|
88 | private method SetLayoutOption { option } |
---|
89 | private method GetAxisType { axis } |
---|
90 | private method restore { toolName plotName data } |
---|
91 | private common _settings |
---|
92 | private common _fonts |
---|
93 | private common _wait |
---|
94 | } |
---|
95 | |
---|
96 | # ---------------------------------------------------------------------- |
---|
97 | # CONSTRUCTOR |
---|
98 | # ---------------------------------------------------------------------- |
---|
99 | itcl::body Rappture::XyPrint::constructor { args } { |
---|
100 | Rappture::dispatcher _dispatcher |
---|
101 | $_dispatcher register !rebuild |
---|
102 | $_dispatcher dispatch $this !rebuild "[itcl::code $this Rebuild]; list" |
---|
103 | |
---|
104 | set w [winfo pixels . 2.5i] |
---|
105 | set h [winfo pixels . 2i] |
---|
106 | set _preview [image create picture -width $w -height $h] |
---|
107 | itk_component add tabs { |
---|
108 | blt::tabset $itk_interior.tabs \ |
---|
109 | -highlightthickness 0 -tearoff 0 -side top \ |
---|
110 | -outerborderwidth 0 -gap 0 -borderwidth 1 \ |
---|
111 | -outerpad 1 -troughcolor grey |
---|
112 | } { |
---|
113 | keep -cursor |
---|
114 | ignore -highlightthickness -borderwidth -background |
---|
115 | } |
---|
116 | itk_component add preview { |
---|
117 | label $itk_interior.preview \ |
---|
118 | -highlightthickness 0 -bd 0 -image $_preview -width 2.5i \ |
---|
119 | -height 2.25i -background grey -padx 10 -pady 10 |
---|
120 | } { |
---|
121 | ignore -background |
---|
122 | } |
---|
123 | itk_component add ok { |
---|
124 | button $itk_interior.ok -text "Save" \ |
---|
125 | -highlightthickness 0 -pady 2 -padx 0 \ |
---|
126 | -command [itcl::code $this SetWaitVariable 1] \ |
---|
127 | -compound left \ |
---|
128 | -image [Rappture::icon download] |
---|
129 | } |
---|
130 | itk_component add cancel { |
---|
131 | button $itk_interior.cancel -text "Cancel" \ |
---|
132 | -highlightthickness 0 -pady 2 -padx 0 \ |
---|
133 | -command [itcl::code $this SetWaitVariable 0] \ |
---|
134 | -compound left \ |
---|
135 | -image [Rappture::icon cancel] |
---|
136 | } |
---|
137 | blt::table $itk_interior \ |
---|
138 | 0,0 $itk_component(preview) -cspan 2 -fill both \ |
---|
139 | 1,0 $itk_component(tabs) -fill both -cspan 2 \ |
---|
140 | 2,1 $itk_component(cancel) -padx 2 -pady 2 -width .9i -fill y \ |
---|
141 | 2,0 $itk_component(ok) -padx 2 -pady 2 -width .9i -fill y |
---|
142 | blt::table configure $itk_interior r1 -resize none |
---|
143 | blt::table configure $itk_interior r1 -resize both |
---|
144 | |
---|
145 | BuildGeneralTab |
---|
146 | BuildAxisTab |
---|
147 | BuildLegendTab |
---|
148 | BuildLayoutTab |
---|
149 | eval itk_initialize $args |
---|
150 | } |
---|
151 | |
---|
152 | # ---------------------------------------------------------------------- |
---|
153 | # DESTRUCTOR |
---|
154 | # ---------------------------------------------------------------------- |
---|
155 | itcl::body Rappture::XyPrint::destructor {} { |
---|
156 | destroy $_clone |
---|
157 | image delete $_preview |
---|
158 | array unset _settings $this-* |
---|
159 | } |
---|
160 | |
---|
161 | itcl::body Rappture::XyPrint::DestroySettings {} { |
---|
162 | destroy $_clone |
---|
163 | set _clone "" |
---|
164 | set _graph "" |
---|
165 | foreach font [array names _fonts] { |
---|
166 | font delete $font |
---|
167 | } |
---|
168 | array unset _fonts |
---|
169 | } |
---|
170 | |
---|
171 | itcl::body Rappture::XyPrint::reset {} { |
---|
172 | SetWaitVariable 0 |
---|
173 | } |
---|
174 | |
---|
175 | itcl::body Rappture::XyPrint::SetWaitVariable { state } { |
---|
176 | set _wait($this) $state |
---|
177 | } |
---|
178 | |
---|
179 | itcl::body Rappture::XyPrint::print { graph toolName plotName } { |
---|
180 | set _graph $graph |
---|
181 | CloneGraph $graph |
---|
182 | InitClone |
---|
183 | RestoreSettings $toolName $plotName |
---|
184 | InitializeSettings |
---|
185 | SetWaitVariable 0 |
---|
186 | tkwait variable [itcl::scope _wait($this)] |
---|
187 | SaveSettings $toolName $plotName |
---|
188 | set output "" |
---|
189 | if { $_wait($this) } { |
---|
190 | set output [GetOutput] |
---|
191 | } |
---|
192 | DestroySettings |
---|
193 | return $output |
---|
194 | } |
---|
195 | |
---|
196 | itcl::body Rappture::XyPrint::GetOutput {} { |
---|
197 | # Get the selected format of the download. |
---|
198 | set page $itk_component(graph_page) |
---|
199 | set format $_settings($this-general-format) |
---|
200 | |
---|
201 | # Handle JPEG or PNG image formats. |
---|
202 | if { $format == "jpg" } { |
---|
203 | set img [image create picture] |
---|
204 | $_clone snap $img |
---|
205 | $img export jpg -quality 100 -data bytes |
---|
206 | image delete $img |
---|
207 | return [list .jpg $bytes] |
---|
208 | } elseif { $format == "png" } { |
---|
209 | set img [image create picture] |
---|
210 | $_clone snap $img |
---|
211 | $img export png -data bytes |
---|
212 | image delete $img |
---|
213 | return [list .png $bytes] |
---|
214 | } elseif { $format == "gif" } { |
---|
215 | set img [image create picture] |
---|
216 | $_clone snap $img |
---|
217 | $img export gif -data bytes |
---|
218 | image delete $img |
---|
219 | return [list .gif $bytes] |
---|
220 | } |
---|
221 | |
---|
222 | # Handle encapsulated postscript or portable document format. |
---|
223 | |
---|
224 | # Append an "i" for the graph postscript component. |
---|
225 | set w $_settings($this-layout-width)i |
---|
226 | set h $_settings($this-layout-height)i |
---|
227 | |
---|
228 | $_clone postscript configure \ |
---|
229 | -decoration yes \ |
---|
230 | -center yes \ |
---|
231 | -width $w -height $h |
---|
232 | |
---|
233 | set psdata [$_clone postscript output] |
---|
234 | |
---|
235 | if 0 { |
---|
236 | set f [open "junk.raw" "w"] |
---|
237 | puts -nonewline $f $psdata |
---|
238 | close $f |
---|
239 | } |
---|
240 | if { $format == "eps" } { |
---|
241 | return [list .$format $psdata] |
---|
242 | } |
---|
243 | |
---|
244 | set cmd "" |
---|
245 | # | eps2eps << $psdata |
---|
246 | lappend cmd "|" "/usr/bin/gs" \ |
---|
247 | "-q" "-sDEVICE=epswrite" "-sstdout=%stderr" \ |
---|
248 | "-sOutputFile=-" "-dNOPAUSE" "-dBATCH" "-dSAFER" \ |
---|
249 | "-dDEVICEWIDTH=250000" "-dDEVICEHEIGHT=250000" "-" "<<" "$psdata" |
---|
250 | if { $format == "pdf" } { |
---|
251 | # | eps2eps << $psdata | ps2pdf |
---|
252 | lappend cmd "|" "/usr/bin/gs" \ |
---|
253 | "-q" "-sDEVICE=pdfwrite" "-sstdout=%stderr" \ |
---|
254 | "-sOutputFile=-" "-dNOPAUSE" "-dBATCH" "-dSAFER" \ |
---|
255 | "-dCompatibilityLevel=1.4" "-c" ".setpdfwrite" "-f" "-" |
---|
256 | } |
---|
257 | if { [catch { |
---|
258 | set f [open $cmd "r"] |
---|
259 | fconfigure $f -translation binary -encoding binary |
---|
260 | set output [read $f] |
---|
261 | close $f |
---|
262 | } err ] != 0 } { |
---|
263 | global errorInfo |
---|
264 | puts stderr "failed to generate file: $err\n$errorInfo" |
---|
265 | return "" |
---|
266 | } |
---|
267 | if 0 { |
---|
268 | set f [open "junk.$format" "w"] |
---|
269 | fconfigure $f -translation binary -encoding binary |
---|
270 | puts -nonewline $f $output |
---|
271 | close $f |
---|
272 | } |
---|
273 | return [list .$format $output] |
---|
274 | } |
---|
275 | |
---|
276 | itcl::body Rappture::XyPrint::CopyOptions { cmd orig clone {exclude {}} } { |
---|
277 | set all [eval $orig $cmd] |
---|
278 | set configLine $clone |
---|
279 | foreach name $exclude { |
---|
280 | set ignore($name) 1 |
---|
281 | } |
---|
282 | foreach arg $cmd { |
---|
283 | lappend configLine $arg |
---|
284 | } |
---|
285 | foreach option $all { |
---|
286 | if { [llength $option] != 5 } { |
---|
287 | continue |
---|
288 | } |
---|
289 | set switch [lindex $option 0] |
---|
290 | set initial [lindex $option 3] |
---|
291 | set current [lindex $option 4] |
---|
292 | if { [info exists ignore($switch)] } { |
---|
293 | continue |
---|
294 | } |
---|
295 | if { [string compare $initial $current] == 0 } { |
---|
296 | continue |
---|
297 | } |
---|
298 | lappend configLine $switch $current |
---|
299 | } |
---|
300 | eval $configLine |
---|
301 | } |
---|
302 | |
---|
303 | itcl::body Rappture::XyPrint::CloneGraph { orig } { |
---|
304 | set top $itk_interior |
---|
305 | if { [winfo exists $top.graph] } { |
---|
306 | destroy $top.graph |
---|
307 | } |
---|
308 | set _clone [blt::graph $top.graph] |
---|
309 | CopyOptions "configure" $orig $_clone |
---|
310 | # Axis component |
---|
311 | foreach axis [$orig axis names] { |
---|
312 | if { [$orig axis cget $axis -hide] } { |
---|
313 | continue |
---|
314 | } |
---|
315 | if { [$_clone axis name $axis] == "" } { |
---|
316 | $_clone axis create $axis |
---|
317 | } |
---|
318 | CopyOptions [list axis configure $axis] $orig $_clone |
---|
319 | } |
---|
320 | foreach axis { x y x2 y2 } { |
---|
321 | $_clone ${axis}axis use [$orig ${axis}axis use] |
---|
322 | } |
---|
323 | # Pen component |
---|
324 | foreach pen [$orig pen names] { |
---|
325 | if { [$_clone pen name $pen] == "" } { |
---|
326 | $_clone pen create $pen |
---|
327 | } |
---|
328 | CopyOptions [list pen configure $pen] $orig $_clone |
---|
329 | } |
---|
330 | # Marker component |
---|
331 | foreach marker [$orig marker names] { |
---|
332 | $_clone marker create [$orig marker type $marker] -name $marker |
---|
333 | CopyOptions [list marker configure $marker] $orig $_clone -name |
---|
334 | } |
---|
335 | # Element component |
---|
336 | foreach elem [$orig element names] { |
---|
337 | set oper [$orig element type $elem] |
---|
338 | $_clone $oper create $elem |
---|
339 | CopyOptions [list $oper configure $elem] $orig $_clone -data |
---|
340 | if { [$_clone $oper cget $elem -hide] } { |
---|
341 | $_clone $oper configure $elem -label "" |
---|
342 | puts stderr [$_clone $oper configure] |
---|
343 | } |
---|
344 | } |
---|
345 | # Fix element display list |
---|
346 | $_clone element show [$orig element show] |
---|
347 | # Legend component |
---|
348 | CopyOptions {legend configure} $orig $_clone |
---|
349 | # Postscript component |
---|
350 | CopyOptions {postscript configure} $orig $_clone |
---|
351 | # Crosshairs component |
---|
352 | CopyOptions {crosshairs configure} $orig $_clone |
---|
353 | |
---|
354 | # Create markers representing lines at zero for the x and y axis. |
---|
355 | $_clone marker create line -name x-zero \ |
---|
356 | -coords "0 -Inf 0 Inf" -dashes 1 -hide yes |
---|
357 | $_clone marker create line -name y-zero \ |
---|
358 | -coords "-Inf 0 Inf 0" -dashes 1 -hide yes |
---|
359 | } |
---|
360 | |
---|
361 | itcl::body Rappture::XyPrint::InitClone {} { |
---|
362 | |
---|
363 | $_clone configure -width 3.4i -height 3.4i -background white \ |
---|
364 | -borderwidth 0 \ |
---|
365 | -leftmargin 0 \ |
---|
366 | -rightmargin 0 \ |
---|
367 | -topmargin 0 \ |
---|
368 | -bottommargin 0 |
---|
369 | |
---|
370 | # Kill the title and create a border around the plot |
---|
371 | $_clone configure \ |
---|
372 | -title "" \ |
---|
373 | -plotborderwidth 1 -plotrelief solid \ |
---|
374 | -plotbackground white -plotpadx 0 -plotpady 0 |
---|
375 | |
---|
376 | set _settings($this-layout-width) [Pixels2Inches [$_clone cget -width]] |
---|
377 | set _settings($this-layout-height) [Pixels2Inches [$_clone cget -height]] |
---|
378 | set _fonts(legend) [font create legend \ |
---|
379 | -family helvetica -size 10 -weight normal] |
---|
380 | update |
---|
381 | $_clone legend configure \ |
---|
382 | -position right \ |
---|
383 | -font $_fonts(legend) \ |
---|
384 | -hide yes -borderwidth 0 -background white -relief solid \ |
---|
385 | -anchor nw -activeborderwidth 0 |
---|
386 | # |
---|
387 | foreach axis [$_clone axis names] { |
---|
388 | if { [$_clone axis cget $axis -hide] } { |
---|
389 | continue |
---|
390 | } |
---|
391 | set _fonts($axis-ticks) [font create $axis-ticks \ |
---|
392 | -family helvetica -size 10 \ |
---|
393 | -weight normal -slant roman] |
---|
394 | set _fonts($axis-title) [font create $axis-title \ |
---|
395 | -family helvetica -size 10 \ |
---|
396 | -weight normal -slant roman] |
---|
397 | update |
---|
398 | $_clone axis configure $axis -ticklength 5 \ |
---|
399 | -majorticks {} -minorticks {} |
---|
400 | $_clone axis configure $axis \ |
---|
401 | -tickfont $_fonts($axis-ticks) \ |
---|
402 | -titlefont $_fonts($axis-title) |
---|
403 | } |
---|
404 | foreach elem [$_clone element names] { |
---|
405 | if { [$_clone element type $elem] == "bar" } { |
---|
406 | continue |
---|
407 | } |
---|
408 | if { [$_clone element cget $elem -linewidth] > 1 } { |
---|
409 | $_clone element configure $elem -linewidth 1 -pixels 3 |
---|
410 | } |
---|
411 | } |
---|
412 | } |
---|
413 | |
---|
414 | itcl::body Rappture::XyPrint::SetOption { opt } { |
---|
415 | set new $_settings($this-graph$opt) |
---|
416 | set old [$_clone cget $opt] |
---|
417 | set code [catch [list $_clone configure $opt $new] err] |
---|
418 | if { $code != 0 } { |
---|
419 | bell |
---|
420 | global errorInfo |
---|
421 | puts stderr "$err: $errorInfo" |
---|
422 | set _settings($this-graph$opt) $old |
---|
423 | $_clone configure $opt $old |
---|
424 | } |
---|
425 | } |
---|
426 | |
---|
427 | itcl::body Rappture::XyPrint::SetComponentOption { comp opt } { |
---|
428 | set new $_settings($this-$comp$opt) |
---|
429 | set old [$_clone $comp cget $opt] |
---|
430 | set code [catch [list $_clone $comp configure $opt $new] err] |
---|
431 | if { $code != 0 } { |
---|
432 | bell |
---|
433 | global errorInfo |
---|
434 | puts stderr "$err: $errorInfo" |
---|
435 | set _settings($this-$comp$opt) $old |
---|
436 | $_clone $comp configure $opt $old |
---|
437 | } |
---|
438 | } |
---|
439 | |
---|
440 | itcl::body Rappture::XyPrint::SetNamedComponentOption { comp name opt } { |
---|
441 | set new $_settings($this-$comp$opt) |
---|
442 | set old [$_clone $comp cget $name $opt] |
---|
443 | set code [catch [list $_clone $comp configure $name $opt $new] err] |
---|
444 | if { $code != 0 } { |
---|
445 | bell |
---|
446 | global errorInfo |
---|
447 | puts stderr "$err: $errorInfo" |
---|
448 | set _settings($this-$comp$opt) $old |
---|
449 | $_clone $comp configure $name $opt $old |
---|
450 | } |
---|
451 | } |
---|
452 | |
---|
453 | itcl::body Rappture::XyPrint::RegeneratePreview {} { |
---|
454 | update |
---|
455 | set img [image create picture] |
---|
456 | set w [Inches2Pixels $_settings($this-layout-width) 3.4] |
---|
457 | set h [Inches2Pixels $_settings($this-layout-height) 3.4] |
---|
458 | set pixelsPerInch [winfo pixels . 1i] |
---|
459 | set sx [expr 2.5*$pixelsPerInch/$w] |
---|
460 | set sy [expr 2.0*$pixelsPerInch/$h] |
---|
461 | set s [expr min($sx,$sy)] |
---|
462 | $_clone snap $img -width $w -height $h |
---|
463 | |
---|
464 | if 0 { |
---|
465 | if { ![winfo exists .labeltest] } { |
---|
466 | toplevel .labeltest -bg red |
---|
467 | label .labeltest.label -image $img |
---|
468 | pack .labeltest.label -fill both |
---|
469 | } |
---|
470 | } |
---|
471 | set pw [expr int(round($s * $w))] |
---|
472 | set ph [expr int(round($s * $h))] |
---|
473 | $_preview configure -width $pw -height $ph |
---|
474 | #.labeltest.label configure -image $img |
---|
475 | $_preview resample $img -filter box |
---|
476 | image delete $img |
---|
477 | } |
---|
478 | |
---|
479 | itcl::body Rappture::XyPrint::Pixels2Inches { pixels } { |
---|
480 | if { [llength $pixels] == 2 } { |
---|
481 | set pixels [lindex $pixels 0] |
---|
482 | } |
---|
483 | set pixelsPerInch [winfo pixels . 1i] |
---|
484 | set inches [expr { double($pixels) / $pixelsPerInch }] |
---|
485 | return [format %.3g ${inches}] |
---|
486 | } |
---|
487 | |
---|
488 | itcl::body Rappture::XyPrint::Inches2Pixels { inches {defValue ""}} { |
---|
489 | set n [scan $inches %g dummy] |
---|
490 | if { $n != 1 && $defValue != "" } { |
---|
491 | set inches $defValue |
---|
492 | } |
---|
493 | return [winfo pixels . ${inches}i] |
---|
494 | } |
---|
495 | |
---|
496 | itcl::body Rappture::XyPrint::Color2RGB { color } { |
---|
497 | foreach { r g b } [winfo rgb $_clone $color] { |
---|
498 | set r [expr round($r / 257.0)] |
---|
499 | set g [expr round($g / 257.0)] |
---|
500 | set b [expr round($b / 257.0)] |
---|
501 | } |
---|
502 | return [format "\#%02x%02x%02x" $r $g $b] |
---|
503 | } |
---|
504 | |
---|
505 | itcl::body Rappture::XyPrint::GetAxisType { axis } { |
---|
506 | return [$_clone axis type $axis] |
---|
507 | } |
---|
508 | |
---|
509 | itcl::body Rappture::XyPrint::GetAxis {} { |
---|
510 | set axis $_settings($this-axis-selected) |
---|
511 | foreach option { -grid -min -max -loose -title -stepsize -subdivisions } { |
---|
512 | set _settings($this-axis$option) [$_clone axis cget $axis $option] |
---|
513 | } |
---|
514 | set type [GetAxisType $axis] |
---|
515 | if { $type != "" } { |
---|
516 | set _settings($this-axis-plotpad${type}) \ |
---|
517 | [Pixels2Inches [$_clone cget -plotpad${type}]] |
---|
518 | set _settings($this-axis-zero) [$_clone marker cget ${type}-zero -hide] |
---|
519 | } |
---|
520 | } |
---|
521 | |
---|
522 | itcl::body Rappture::XyPrint::GetElement { args } { |
---|
523 | set index 1 |
---|
524 | array unset _settings $this-element-* |
---|
525 | foreach elem [$_clone element show] { |
---|
526 | set _settings($this-element-$index) $elem |
---|
527 | incr index |
---|
528 | } |
---|
529 | set index [$itk_component(element_slider) get] |
---|
530 | set elem $_settings($this-element-$index) |
---|
531 | set _settings($this-element-label) [$_clone element cget $elem -label] |
---|
532 | set _settings($this-element-color) [$_clone element cget $elem -color] |
---|
533 | if { [$_clone element type $elem] != "bar" } { |
---|
534 | set _settings($this-element-symbol) [$_clone element cget $elem -symbol] |
---|
535 | set _settings($this-element-dashes) [$_clone element cget $elem -dashes] |
---|
536 | } |
---|
537 | set page $itk_component(legend_page) |
---|
538 | set color [$page.color label $_settings($this-element-color)] |
---|
539 | if { $color == "" } { |
---|
540 | set color [Color2RGB $_settings($this-element-color)] |
---|
541 | $page.color choices insert end $color $color |
---|
542 | $page.color value $color |
---|
543 | } else { |
---|
544 | $page.color value [$page.color label $_settings($this-element-color)] |
---|
545 | } |
---|
546 | if { [$_clone element type $elem] != "bar" } { |
---|
547 | $page.symbol value [$page.symbol label $_settings($this-element-symbol)] |
---|
548 | $page.dashes value [$page.dashes label $_settings($this-element-dashes)] |
---|
549 | } |
---|
550 | #FixElement |
---|
551 | } |
---|
552 | |
---|
553 | itcl::body Rappture::XyPrint::BuildLayoutTab {} { |
---|
554 | itk_component add layout_page { |
---|
555 | frame $itk_component(tabs).layout_page |
---|
556 | } |
---|
557 | set page $itk_component(layout_page) |
---|
558 | $itk_component(tabs) insert end "layout" \ |
---|
559 | -text "Layout" -padx 2 -pady 2 -window $page -fill both |
---|
560 | |
---|
561 | label $page.width_l -text "width" |
---|
562 | entry $page.width -width 6 \ |
---|
563 | -textvariable [itcl::scope _settings($this-layout-width)] |
---|
564 | bind $page.width <KeyPress-Return> [itcl::code $this ApplyLayoutSettings] |
---|
565 | Rappture::Tooltip::for $page.width \ |
---|
566 | "Set the width (inches) of the output image. Must be a positive number." |
---|
567 | |
---|
568 | label $page.height_l -text "height" |
---|
569 | entry $page.height -width 6 \ |
---|
570 | -textvariable [itcl::scope _settings($this-layout-height)] |
---|
571 | bind $page.height <KeyPress-Return> [itcl::code $this ApplyLayoutSettings] |
---|
572 | Rappture::Tooltip::for $page.height \ |
---|
573 | "Set the height (inches) of the output image. Must be a positive number" |
---|
574 | |
---|
575 | label $page.margin_l -text "Margins" |
---|
576 | |
---|
577 | label $page.left_l -text "left" |
---|
578 | entry $page.left -width 6 \ |
---|
579 | -textvariable [itcl::scope _settings($this-layout-leftmargin)] |
---|
580 | bind $page.left <KeyPress-Return> [itcl::code $this ApplyLayoutSettings] |
---|
581 | Rappture::Tooltip::for $page.left \ |
---|
582 | "Set the size (inches) of the left margin. If zero, the size is automatically determined." |
---|
583 | |
---|
584 | label $page.right_l -text "right" |
---|
585 | entry $page.right -width 6 \ |
---|
586 | -textvariable [itcl::scope _settings($this-layout-rightmargin)] |
---|
587 | bind $page.right <KeyPress-Return> [itcl::code $this ApplyLayoutSettings] |
---|
588 | Rappture::Tooltip::for $page.right \ |
---|
589 | "Set the size (inches) of the right margin. If zero, the size is automatically determined." |
---|
590 | |
---|
591 | |
---|
592 | label $page.top_l -text "top" |
---|
593 | entry $page.top -width 6 \ |
---|
594 | -textvariable [itcl::scope _settings($this-layout-topmargin)] |
---|
595 | bind $page.top <KeyPress-Return> [itcl::code $this ApplyLayoutSettings] |
---|
596 | Rappture::Tooltip::for $page.top \ |
---|
597 | "Set the size (inches) of the top margin. If zero, the size is automatically determined." |
---|
598 | |
---|
599 | label $page.bottom_l -text "bottom" |
---|
600 | entry $page.bottom -width 6 \ |
---|
601 | -textvariable [itcl::scope _settings($this-layout-bottommargin)] |
---|
602 | bind $page.bottom <KeyPress-Return> [itcl::code $this ApplyLayoutSettings] |
---|
603 | Rappture::Tooltip::for $page.bottom \ |
---|
604 | "Set the size (inches) of the bottom margin. If zero, the size is automatically determined." |
---|
605 | |
---|
606 | |
---|
607 | label $page.map -image [Rappture::icon graphmargins] |
---|
608 | blt::table $page \ |
---|
609 | 0,0 $page.width_l -anchor e \ |
---|
610 | 0,1 $page.width -fill x \ |
---|
611 | 1,0 $page.height_l -anchor e \ |
---|
612 | 1,1 $page.height -fill x \ |
---|
613 | 3,0 $page.left_l -anchor e \ |
---|
614 | 3,1 $page.left -fill x \ |
---|
615 | 4,0 $page.right_l -anchor e \ |
---|
616 | 4,1 $page.right -fill x \ |
---|
617 | 5,0 $page.top_l -anchor e \ |
---|
618 | 5,1 $page.top -fill x \ |
---|
619 | 6,0 $page.bottom_l -anchor e \ |
---|
620 | 6,1 $page.bottom -fill x \ |
---|
621 | 0,2 $page.map -fill both -rspan 7 -padx 2 |
---|
622 | |
---|
623 | blt::table configure $page c0 r* -resize none |
---|
624 | blt::table configure $page c1 r2 -resize both |
---|
625 | } |
---|
626 | |
---|
627 | |
---|
628 | itcl::body Rappture::XyPrint::BuildGeneralTab {} { |
---|
629 | itk_component add graph_page { |
---|
630 | frame $itk_component(tabs).graph_page |
---|
631 | } |
---|
632 | set page $itk_component(graph_page) |
---|
633 | $itk_component(tabs) insert end "graph" \ |
---|
634 | -text "General" -padx 2 -pady 2 -window $page -fill both |
---|
635 | |
---|
636 | label $page.format_l -text "format" |
---|
637 | set m $page.format.menu |
---|
638 | blt::comboentry $page.format \ |
---|
639 | -width 30 \ |
---|
640 | -textvariable [itcl::scope _format] \ |
---|
641 | -editable no -menu $m \ |
---|
642 | -command [itcl::code $this ApplyGeneralSettings] |
---|
643 | blt::combomenu $m \ |
---|
644 | -xscrollbar $m.xs \ |
---|
645 | -yscrollbar $m.ys \ |
---|
646 | -textvariable [itcl::scope _format] \ |
---|
647 | -height { 0 2i } |
---|
648 | blt::tk::scrollbar $m.xs |
---|
649 | blt::tk::scrollbar $m.ys |
---|
650 | $m add -value "pdf" -text "PDF Portable Document Format" |
---|
651 | $m add -value "ps" -text "PS PostScript Format" |
---|
652 | $m add -value "eps" -text "EPS Encapsulated PostScript" |
---|
653 | $m add -value "jpg" -text "JPEG Joint Photographic Experts Group Format" |
---|
654 | $m add -value "png" -text "PNG Portable Network Graphics Format" |
---|
655 | $m add -value "gif" -text "GIF Graphics Interchange Format" |
---|
656 | $m item configure all \ |
---|
657 | -variable [itcl::scope _settings($this-general-format)] |
---|
658 | Rappture::Tooltip::for $page.format "Set the format of the image." |
---|
659 | |
---|
660 | label $page.style_l -text "style" |
---|
661 | set m $page.style.menu |
---|
662 | blt::comboentry $page.style \ |
---|
663 | -width 30 \ |
---|
664 | -textvariable [itcl::scope _style] \ |
---|
665 | -editable no -menu $m \ |
---|
666 | -command [itcl::code $this ApplyGeneralSettings] |
---|
667 | blt::combomenu $m \ |
---|
668 | -xscrollbar $m.xs \ |
---|
669 | -yscrollbar $m.ys \ |
---|
670 | -textvariable [itcl::scope _style] \ |
---|
671 | -height { 0 2i } |
---|
672 | blt::tk::scrollbar $m.xs |
---|
673 | blt::tk::scrollbar $m.ys |
---|
674 | $m add -value "ieee" -text "IEEE Journal" |
---|
675 | $m add -value "gekco" -text "G Klimeck" |
---|
676 | $m item configure all \ |
---|
677 | -variable [itcl::scope _settings($this-general-style)] |
---|
678 | Rappture::Tooltip::for $page.format "Set the style template." |
---|
679 | |
---|
680 | blt::tk::checkbutton $page.remember -text "remember settings" \ |
---|
681 | -variable [itcl::scope _settings($this-general-remember)] |
---|
682 | Rappture::Tooltip::for $page.remember \ |
---|
683 | "Remember the settings. They will be override the default settings." |
---|
684 | |
---|
685 | button $page.revert -text "revert" -image [Rappture::icon revert] \ |
---|
686 | -compound left -padx 3 -pady 1 -overrelief raised -relief flat \ |
---|
687 | -command [itcl::code $this ResetSettings] |
---|
688 | Rappture::Tooltip::for $page.revert \ |
---|
689 | "Revert to the default settings." |
---|
690 | |
---|
691 | blt::table $page \ |
---|
692 | 2,0 $page.format_l -anchor e \ |
---|
693 | 2,1 $page.format -fill x -cspan 2 \ |
---|
694 | 3,0 $page.style_l -anchor e \ |
---|
695 | 3,1 $page.style -fill x -cspan 2 \ |
---|
696 | 5,0 $page.remember -cspan 2 -anchor w \ |
---|
697 | 5,2 $page.revert -anchor e |
---|
698 | blt::table configure $page r* -resize none -pady { 0 2 } |
---|
699 | blt::table configure $page r4 -resize both |
---|
700 | |
---|
701 | } |
---|
702 | |
---|
703 | itcl::body Rappture::XyPrint::ApplyLegendSettings {} { |
---|
704 | set page $itk_component(legend_page) |
---|
705 | set _settings($this-legend-anchor) [$page.anchor current] |
---|
706 | if { $_clone != "" } { |
---|
707 | font configure $_fonts(legend) \ |
---|
708 | -family $_settings($this-legend-font-family) \ |
---|
709 | -size $_settings($this-legend-font-size) \ |
---|
710 | -weight $_settings($this-legend-font-weight) \ |
---|
711 | -slant $_settings($this-legend-font-slant) |
---|
712 | foreach option { -hide -position -anchor -borderwidth } { |
---|
713 | SetComponentOption legend $option |
---|
714 | } |
---|
715 | $_clone legend configure -font fixed -font $_fonts(legend) |
---|
716 | } |
---|
717 | ApplyElementSettings |
---|
718 | } |
---|
719 | |
---|
720 | itcl::body Rappture::XyPrint::BuildLegendTab {} { |
---|
721 | itk_component add legend_page { |
---|
722 | frame $itk_component(tabs).legend_page |
---|
723 | } |
---|
724 | set page $itk_component(legend_page) |
---|
725 | $itk_component(tabs) insert end "legend" \ |
---|
726 | -text "Legend" -padx 2 -pady 2 -window $page -fill both |
---|
727 | |
---|
728 | blt::tk::checkbutton $page.show -text "show legend" \ |
---|
729 | -offvalue 1 -onvalue 0 \ |
---|
730 | -variable [itcl::scope _settings($this-legend-hide)] \ |
---|
731 | -command [itcl::code $this ApplyLegendSettings] |
---|
732 | Rappture::Tooltip::for $page.show \ |
---|
733 | "Display the legend." |
---|
734 | |
---|
735 | label $page.position_l -text "position" |
---|
736 | set m $page.position.menu |
---|
737 | blt::comboentry $page.position \ |
---|
738 | -width 15 \ |
---|
739 | -textvariable [itcl::scope _position] \ |
---|
740 | -editable no -menu $m \ |
---|
741 | -command [itcl::code $this ApplyLegendSettings] |
---|
742 | blt::combomenu $m \ |
---|
743 | -xscrollbar $m.xs \ |
---|
744 | -yscrollbar $m.ys \ |
---|
745 | -textvariable [itcl::scope _position] \ |
---|
746 | -height { 0 2i } |
---|
747 | blt::tk::scrollbar $m.xs |
---|
748 | blt::tk::scrollbar $m.ys |
---|
749 | $m add -value "leftmargin" -text "left margin" |
---|
750 | $m add -value "rightmargin" -text "right margin" |
---|
751 | $m add -value "bottommargin" -text "bottom margin" |
---|
752 | $m add -value "topmargin" -text "top margin" |
---|
753 | $m add -value "plotarea" -text "inside plot" |
---|
754 | $m item configure all \ |
---|
755 | -variable [itcl::scope _settings($this-legend-position)] |
---|
756 | Rappture::Tooltip::for $page.position \ |
---|
757 | "Set the position of the legend. This option and the anchor determine the legend's location." |
---|
758 | |
---|
759 | Rappture::Combobox $page.anchor -width 10 -editable no |
---|
760 | $page.anchor choices insert end \ |
---|
761 | "nw" "northwest" \ |
---|
762 | "n" "north" \ |
---|
763 | "ne" "northeast" \ |
---|
764 | "sw" "southwest" \ |
---|
765 | "s" "south" \ |
---|
766 | "se" "southeast" \ |
---|
767 | "c" "center" \ |
---|
768 | "e" "east" \ |
---|
769 | "w" "west" |
---|
770 | bind $page.anchor <<Value>> [itcl::code $this ApplyLegendSettings] |
---|
771 | Rappture::Tooltip::for $page.anchor \ |
---|
772 | "Set the anchor of the legend. This option and the anchor determine the legend's location." |
---|
773 | |
---|
774 | blt::tk::checkbutton $page.border -text "border" \ |
---|
775 | -variable [itcl::scope _settings($this-legend-borderwidth)] \ |
---|
776 | -onvalue 1 -offvalue 0 \ |
---|
777 | -command [itcl::code $this ApplyLegendSettings] |
---|
778 | Rappture::Tooltip::for $page.border \ |
---|
779 | "Display a solid border around the legend." |
---|
780 | |
---|
781 | label $page.slider_l -text "legend\nentry" -justify right |
---|
782 | itk_component add element_slider { |
---|
783 | ::scale $page.slider -from 1 -to 1 \ |
---|
784 | -orient horizontal -width 12 \ |
---|
785 | -command [itcl::code $this GetElement] |
---|
786 | } |
---|
787 | Rappture::Tooltip::for $page.slider \ |
---|
788 | "Select the current entry." |
---|
789 | |
---|
790 | label $page.label_l -text "label" |
---|
791 | entry $page.label \ |
---|
792 | -background white \ |
---|
793 | -textvariable [itcl::scope _settings($this-element-label)] |
---|
794 | bind $page.label <KeyPress-Return> [itcl::code $this ApplyElementSettings] |
---|
795 | Rappture::Tooltip::for $page.label \ |
---|
796 | "Set the label of the current entry in the legend." |
---|
797 | |
---|
798 | label $page.color_l -text "color " |
---|
799 | Rappture::Combobox $page.color -width 15 -editable no |
---|
800 | $page.color choices insert end \ |
---|
801 | "#000000" "black" \ |
---|
802 | "#ffffff" "white" \ |
---|
803 | "#0000cd" "blue" \ |
---|
804 | "#cd0000" "red" \ |
---|
805 | "#00cd00" "green" \ |
---|
806 | "#3a5fcd" "royal blue" \ |
---|
807 | "#cdcd00" "yellow" \ |
---|
808 | "#cd1076" "deep pink" \ |
---|
809 | "#009acd" "deep sky blue" \ |
---|
810 | "#00c5cd" "torquise" \ |
---|
811 | "#a2b5cd" "light steel blue" \ |
---|
812 | "#7ac5cd" "cadet blue" \ |
---|
813 | "#66cdaa" "aquamarine" \ |
---|
814 | "#a2cd5a" "dark olive green" \ |
---|
815 | "#cd9b9b" "rosy brown" \ |
---|
816 | "#0000ff" "blue1" \ |
---|
817 | "#ff0000" "red1" \ |
---|
818 | "#00ff00" "green1" |
---|
819 | bind $page.color <<Value>> [itcl::code $this ApplyElementSettings] |
---|
820 | Rappture::Tooltip::for $page.color \ |
---|
821 | "Set the color of the current entry." |
---|
822 | |
---|
823 | label $page.dashes_l -text "line style" |
---|
824 | Rappture::Combobox $page.dashes -width 15 -editable no |
---|
825 | $page.dashes choices insert end \ |
---|
826 | "" "solid" \ |
---|
827 | "1" "dot" \ |
---|
828 | "5 2" "dash" \ |
---|
829 | "2 4 2" "dashdot" \ |
---|
830 | "2 4 2 2" "dashdotdot" |
---|
831 | bind $page.dashes <<Value>> [itcl::code $this ApplyElementSettings] |
---|
832 | Rappture::Tooltip::for $page.dashes \ |
---|
833 | "Set the line style of the current entry." |
---|
834 | |
---|
835 | label $page.symbol_l -text "symbol" |
---|
836 | Rappture::Combobox $page.symbol -editable no |
---|
837 | $page.symbol choices insert end \ |
---|
838 | "none" "none" \ |
---|
839 | "square" "square" \ |
---|
840 | "circle" "circle" \ |
---|
841 | "diamond" "diamond" \ |
---|
842 | "plus" "plus" \ |
---|
843 | "cross" "cross" \ |
---|
844 | "splus" "skinny plus" \ |
---|
845 | "scross" "skinny cross" \ |
---|
846 | "triangle" "triangle" |
---|
847 | bind $page.symbol <<Value>> [itcl::code $this ApplyElementSettings] |
---|
848 | Rappture::Tooltip::for $page.symbol \ |
---|
849 | "Set the symbol of the current entry. \"none\" display no symbols." |
---|
850 | |
---|
851 | label $page.font_l -text "font" |
---|
852 | set m $page.fontfamily.menu |
---|
853 | blt::comboentry $page.fontfamily \ |
---|
854 | -width 10 \ |
---|
855 | -textvariable [itcl::scope _legendFontFamily] \ |
---|
856 | -editable no -menu $m \ |
---|
857 | -command [itcl::code $this ApplyLegendSettings] |
---|
858 | blt::combomenu $m \ |
---|
859 | -xscrollbar $m.xs \ |
---|
860 | -yscrollbar $m.ys \ |
---|
861 | -textvariable [itcl::scope _legendFontFamily] \ |
---|
862 | -height { 0 2i } |
---|
863 | blt::tk::scrollbar $m.xs |
---|
864 | blt::tk::scrollbar $m.ys |
---|
865 | $m style create "courier" -font "{courier new} 9" |
---|
866 | $m style create "helvetica" -font "{arial} 9" |
---|
867 | $m style create "newcentury" -font "{new century schoolbook} 9" |
---|
868 | $m style create "times" -font "{times new roman} 9" |
---|
869 | $m add -text "courier" -value "courier" -style "courier" |
---|
870 | $m add -text "helvetica" -value "helvetica" -style "helvetica" |
---|
871 | $m add -text "new century schoolbook" -value "new*century*schoolbook" \ |
---|
872 | -style "newcentury" |
---|
873 | $m add -text "symbol" -value "symbol" |
---|
874 | $m add -text "times" -value "times" -style "times" |
---|
875 | $m item configure all \ |
---|
876 | -variable [itcl::scope _settings($this-legend-font-family)] |
---|
877 | $m select "helvetica" |
---|
878 | Rappture::Tooltip::for $page.fontfamily \ |
---|
879 | "Set the font of entries in the legend." |
---|
880 | |
---|
881 | set m $page.fontsize.menu |
---|
882 | blt::comboentry $page.fontsize \ |
---|
883 | -width .4i \ |
---|
884 | -textvariable [itcl::scope _legendFontSize] \ |
---|
885 | -editable no -menu $m \ |
---|
886 | -command [itcl::code $this ApplyLegendSettings] |
---|
887 | blt::combomenu $m \ |
---|
888 | -xscrollbar $m.xs \ |
---|
889 | -yscrollbar $m.ys \ |
---|
890 | -textvariable [itcl::scope _legendFontSize] \ |
---|
891 | -height { 0 2i } |
---|
892 | blt::tk::scrollbar $m.xs |
---|
893 | blt::tk::scrollbar $m.ys |
---|
894 | $m add -text "8" -value "8" |
---|
895 | $m add -text "9" -value "9" |
---|
896 | $m add -text "10" -value "10" |
---|
897 | $m add -text "11" -value "11" |
---|
898 | $m add -text "12" -value "12" |
---|
899 | $m add -text "14" -value "14" |
---|
900 | $m add -text "17" -value "17" |
---|
901 | $m add -text "18" -value "18" |
---|
902 | $m add -text "20" -value "20" |
---|
903 | $m item configure all \ |
---|
904 | -variable [itcl::scope _settings($this-legend-font-size)] |
---|
905 | Rappture::Tooltip::for $page.fontsize \ |
---|
906 | "Set the size (points) of the font." |
---|
907 | |
---|
908 | blt::tk::pushbutton $page.fontweight \ |
---|
909 | -width 18 -height 18 \ |
---|
910 | -onimage [Rappture::icon font-bold] \ |
---|
911 | -offimage [Rappture::icon font-bold] \ |
---|
912 | -onvalue "bold" -offvalue "normal" \ |
---|
913 | -command [itcl::code $this ApplyLegendSettings] \ |
---|
914 | -variable [itcl::scope _settings($this-legend-font-weight)] |
---|
915 | Rappture::Tooltip::for $page.fontweight \ |
---|
916 | "Use the bold version of the font." |
---|
917 | |
---|
918 | blt::tk::pushbutton $page.fontslant \ |
---|
919 | -width 18 -height 18 \ |
---|
920 | -onimage [Rappture::icon font-italic] \ |
---|
921 | -offimage [Rappture::icon font-italic] \ |
---|
922 | -onvalue "italic" -offvalue "roman" \ |
---|
923 | -command [itcl::code $this ApplyLegendSettings] \ |
---|
924 | -variable [itcl::scope _settings($this-legend-font-slant)] |
---|
925 | Rappture::Tooltip::for $page.fontslant \ |
---|
926 | "Use the italic version of the font." |
---|
927 | |
---|
928 | blt::table $page \ |
---|
929 | 1,0 $page.show -cspan 2 -anchor w \ |
---|
930 | 1,2 $page.border -cspan 2 -anchor w \ |
---|
931 | 2,0 $page.position_l -anchor e \ |
---|
932 | 2,1 $page.position -fill x \ |
---|
933 | 2,2 $page.anchor -fill x -cspan 3 \ |
---|
934 | 3,0 $page.font_l -anchor e \ |
---|
935 | 3,1 $page.fontfamily -fill x \ |
---|
936 | 3,2 $page.fontsize -fill x \ |
---|
937 | 3,3 $page.fontweight -anchor e \ |
---|
938 | 3,4 $page.fontslant -anchor e \ |
---|
939 | 4,0 $page.slider_l -anchor e \ |
---|
940 | 4,1 $page.slider -fill x -cspan 5 \ |
---|
941 | 5,0 $page.label_l -anchor e \ |
---|
942 | 5,1 $page.label -fill x -cspan 5 \ |
---|
943 | 6,0 $page.color_l -anchor e \ |
---|
944 | 6,1 $page.color -fill x \ |
---|
945 | 6,2 $page.symbol_l -anchor e \ |
---|
946 | 6,3 $page.symbol -fill both -cspan 3 \ |
---|
947 | 7,0 $page.dashes_l -anchor e \ |
---|
948 | 7,1 $page.dashes -fill x \ |
---|
949 | |
---|
950 | blt::table configure $page r* -resize none -pady { 0 2 } |
---|
951 | blt::table configure $page r8 -resize both |
---|
952 | |
---|
953 | } |
---|
954 | |
---|
955 | itcl::body Rappture::XyPrint::BuildAxisTab {} { |
---|
956 | itk_component add axis_page { |
---|
957 | frame $itk_component(tabs).axis_page |
---|
958 | } |
---|
959 | set page $itk_component(axis_page) |
---|
960 | $itk_component(tabs) insert end "axis" \ |
---|
961 | -text "Axis" -padx 2 -pady 2 -window $page -fill both |
---|
962 | |
---|
963 | label $page.axis_l -text "axis" |
---|
964 | set m $page.axis.menu |
---|
965 | blt::comboentry $page.axis \ |
---|
966 | -width 10 \ |
---|
967 | -textvariable [itcl::scope _axis] \ |
---|
968 | -editable no -menu $m \ |
---|
969 | -command [itcl::code $this GetAxis] |
---|
970 | itk_component add axis_menu { |
---|
971 | blt::combomenu $m \ |
---|
972 | -xscrollbar $m.xs \ |
---|
973 | -yscrollbar $m.ys \ |
---|
974 | -textvariable [itcl::scope _axis] \ |
---|
975 | -height { 0 2i } |
---|
976 | } |
---|
977 | blt::tk::scrollbar $m.xs |
---|
978 | blt::tk::scrollbar $m.ys |
---|
979 | Rappture::Tooltip::for $page.axis "Select the current axis." |
---|
980 | |
---|
981 | label $page.title_l -text "title" |
---|
982 | entry $page.title \ |
---|
983 | -textvariable [itcl::scope _settings($this-axis-title)] |
---|
984 | bind $page.title <KeyPress-Return> [itcl::code $this ApplyAxisSettings] |
---|
985 | Rappture::Tooltip::for $page.title \ |
---|
986 | "Set the title of the current axis." |
---|
987 | |
---|
988 | label $page.min_l -text "min" |
---|
989 | entry $page.min -width 10 \ |
---|
990 | -textvariable [itcl::scope _settings($this-axis-min)] |
---|
991 | bind $page.min <KeyPress-Return> [itcl::code $this ApplyAxisSettings] |
---|
992 | Rappture::Tooltip::for $page.min \ |
---|
993 | "Set the minimum limit for the current axis. If empty, the minimum is automatically determined." |
---|
994 | |
---|
995 | label $page.max_l -text "max" |
---|
996 | entry $page.max -width 10 \ |
---|
997 | -textvariable [itcl::scope _settings($this-axis-max)] |
---|
998 | bind $page.max <KeyPress-Return> [itcl::code $this ApplyAxisSettings] |
---|
999 | Rappture::Tooltip::for $page.max \ |
---|
1000 | "Set the maximum limit for the current axis. If empty, the maximum is automatically determined." |
---|
1001 | |
---|
1002 | label $page.subdivisions_l -text "subdivisions" |
---|
1003 | entry $page.subdivisions \ |
---|
1004 | -textvariable [itcl::scope _settings($this-axis-subdivisions)] |
---|
1005 | bind $page.subdivisions <KeyPress-Return> \ |
---|
1006 | [itcl::code $this ApplyAxisSettings] |
---|
1007 | Rappture::Tooltip::for $page.subdivisions \ |
---|
1008 | "Set the number of subdivisions (minor ticks) for the current axis." |
---|
1009 | |
---|
1010 | label $page.stepsize_l -text "step size" |
---|
1011 | entry $page.stepsize \ |
---|
1012 | -textvariable [itcl::scope _settings($this-axis-stepsize)] |
---|
1013 | bind $page.stepsize <KeyPress-Return> [itcl::code $this ApplyAxisSettings] |
---|
1014 | Rappture::Tooltip::for $page.stepsize \ |
---|
1015 | "Set the interval between major ticks for the current axis. If zero, the interval is automatically determined." |
---|
1016 | |
---|
1017 | blt::tk::checkbutton $page.loose -text "loose limits" \ |
---|
1018 | -onvalue "always" -offvalue "0" \ |
---|
1019 | -variable [itcl::scope _settings($this-axis-loose)] \ |
---|
1020 | -command [itcl::code $this ApplyAxisSettings] |
---|
1021 | Rappture::Tooltip::for $page.loose \ |
---|
1022 | "Set major ticks outside of the limits for the current axis." |
---|
1023 | |
---|
1024 | label $page.plotpad_l -text "pad" |
---|
1025 | entry $page.plotpad -width 6 \ |
---|
1026 | -textvariable [itcl::scope _settings($this-axis-plotpad)] |
---|
1027 | bind $page.plotpad <KeyPress-Return> [itcl::code $this ApplyAxisSettings] |
---|
1028 | Rappture::Tooltip::for $page.plotpad \ |
---|
1029 | "Set padding (points) between the current axis and the plot." |
---|
1030 | |
---|
1031 | blt::tk::checkbutton $page.grid -text "show grid lines" \ |
---|
1032 | -variable [itcl::scope _settings($this-axis-grid)] \ |
---|
1033 | -command [itcl::code $this ApplyAxisSettings] |
---|
1034 | Rappture::Tooltip::for $page.grid \ |
---|
1035 | "Display grid lines for the current axis." |
---|
1036 | |
---|
1037 | blt::tk::checkbutton $page.zero -text "mark zero" \ |
---|
1038 | -offvalue 1 -onvalue 0 \ |
---|
1039 | -variable [itcl::scope _settings($this-axis-zero)] \ |
---|
1040 | -command [itcl::code $this ApplyAxisSettings] |
---|
1041 | Rappture::Tooltip::for $page.zero \ |
---|
1042 | "Display a line at zero for the current axis." |
---|
1043 | |
---|
1044 | label $page.tickfont_l -text "tick font" |
---|
1045 | set m $page.tickfontfamily.menu |
---|
1046 | blt::comboentry $page.tickfontfamily \ |
---|
1047 | -width 10 \ |
---|
1048 | -textvariable [itcl::scope _tickFontFamily] \ |
---|
1049 | -editable no -menu $m \ |
---|
1050 | -command [itcl::code $this ApplyAxisSettings] |
---|
1051 | blt::combomenu $m \ |
---|
1052 | -xscrollbar $m.xs \ |
---|
1053 | -yscrollbar $m.ys \ |
---|
1054 | -textvariable [itcl::scope _tickFontFamily] \ |
---|
1055 | -height { 0 2i } |
---|
1056 | blt::tk::scrollbar $m.xs |
---|
1057 | blt::tk::scrollbar $m.ys |
---|
1058 | $m style create "courier" -font "{courier new} 9" |
---|
1059 | $m style create "helvetica" -font "{arial} 9" |
---|
1060 | $m style create "newcentury" -font "{new century schoolbook} 9" |
---|
1061 | $m style create "times" -font "{times new roman} 9" |
---|
1062 | $m add -text "courier" -value "courier" -style "courier" |
---|
1063 | $m add -text "helvetica" -value "helvetica" -style "helvetica" |
---|
1064 | $m add -text "new century schoolbook" -value "new*century*schoolbook" \ |
---|
1065 | -style "newcentury" |
---|
1066 | $m add -text "symbol" -value "symbol" |
---|
1067 | $m add -text "times" -value "times" -style "times" |
---|
1068 | $m item configure all \ |
---|
1069 | -variable [itcl::scope _settings($this-axis-tickfont-family)] |
---|
1070 | Rappture::Tooltip::for $page.tickfontfamily \ |
---|
1071 | "Set the font of the ticks for the current axis." |
---|
1072 | |
---|
1073 | set m $page.tickfontsize.menu |
---|
1074 | blt::comboentry $page.tickfontsize \ |
---|
1075 | -width .4i \ |
---|
1076 | -textvariable [itcl::scope _tickFontSize] \ |
---|
1077 | -editable no -menu $m \ |
---|
1078 | -command [itcl::code $this ApplyAxisSettings] |
---|
1079 | blt::combomenu $m \ |
---|
1080 | -xscrollbar $m.xs \ |
---|
1081 | -yscrollbar $m.ys \ |
---|
1082 | -textvariable [itcl::scope _tickFontSize] \ |
---|
1083 | -height { 0 2i } |
---|
1084 | blt::tk::scrollbar $m.xs |
---|
1085 | blt::tk::scrollbar $m.ys |
---|
1086 | $m add -text "8" -value "8" |
---|
1087 | $m add -text "9" -value "9" |
---|
1088 | $m add -text "10" -value "10" |
---|
1089 | $m add -text "11" -value "11" |
---|
1090 | $m add -text "12" -value "12" |
---|
1091 | $m add -text "14" -value "14" |
---|
1092 | $m add -text "17" -value "17" |
---|
1093 | $m add -text "18" -value "18" |
---|
1094 | $m add -text "20" -value "20" |
---|
1095 | $m item configure all \ |
---|
1096 | -variable [itcl::scope _settings($this-axis-tickfont-size)] |
---|
1097 | Rappture::Tooltip::for $page.tickfontsize \ |
---|
1098 | "Set the size (points) of the tick font." |
---|
1099 | |
---|
1100 | blt::tk::pushbutton $page.tickfontweight \ |
---|
1101 | -width 18 -height 18 \ |
---|
1102 | -onimage [Rappture::icon font-bold] \ |
---|
1103 | -offimage [Rappture::icon font-bold] \ |
---|
1104 | -onvalue "bold" -offvalue "normal" \ |
---|
1105 | -command [itcl::code $this ApplyAxisSettings] \ |
---|
1106 | -variable [itcl::scope _settings($this-axis-tickfont-weight)] |
---|
1107 | Rappture::Tooltip::for $page.tickfontweight \ |
---|
1108 | "Use the bold version of the tick font." |
---|
1109 | |
---|
1110 | blt::tk::pushbutton $page.tickfontslant \ |
---|
1111 | -width 18 -height 18 \ |
---|
1112 | -onimage [Rappture::icon font-italic] \ |
---|
1113 | -offimage [Rappture::icon font-italic] \ |
---|
1114 | -onvalue "italic" -offvalue "roman" \ |
---|
1115 | -command [itcl::code $this ApplyAxisSettings] \ |
---|
1116 | -variable [itcl::scope _settings($this-axis-tickfont-slant)] |
---|
1117 | Rappture::Tooltip::for $page.tickfontslant \ |
---|
1118 | "Use the italic version of the tick font." |
---|
1119 | |
---|
1120 | label $page.titlefont_l -text "title font" |
---|
1121 | set m $page.titlefontfamily.menu |
---|
1122 | blt::comboentry $page.titlefontfamily \ |
---|
1123 | -width 10 \ |
---|
1124 | -textvariable [itcl::scope _titleFontFamily] \ |
---|
1125 | -editable no -menu $m \ |
---|
1126 | -command [itcl::code $this ApplyAxisSettings] |
---|
1127 | blt::combomenu $m \ |
---|
1128 | -xscrollbar $m.xs \ |
---|
1129 | -yscrollbar $m.ys \ |
---|
1130 | -textvariable [itcl::scope _titleFontFamily] \ |
---|
1131 | -height { 0 2i } |
---|
1132 | blt::tk::scrollbar $m.xs |
---|
1133 | blt::tk::scrollbar $m.ys |
---|
1134 | $m style create "courier" -font "{courier new} 9" |
---|
1135 | $m style create "helvetica" -font "{arial} 9" |
---|
1136 | $m style create "newcentury" -font "{new century schoolbook} 9" |
---|
1137 | $m style create "times" -font "{times new roman} 9" |
---|
1138 | $m add -text "courier" -value "courier" -style "courier" |
---|
1139 | $m add -text "helvetica" -value "helvetica" -style "helvetica" |
---|
1140 | $m add -text "new century schoolbook" -value "new*century*schoolbook" \ |
---|
1141 | -style "newcentury" |
---|
1142 | $m add -text "symbol" -value "symbol" |
---|
1143 | $m add -text "times" -value "times" -style "times" |
---|
1144 | $m item configure all \ |
---|
1145 | -variable [itcl::scope _settings($this-axis-titlefont-family)] |
---|
1146 | Rappture::Tooltip::for $page.titlefontfamily \ |
---|
1147 | "Set the font of the title for the current axis." |
---|
1148 | |
---|
1149 | set m $page.titlefontsize.menu |
---|
1150 | blt::comboentry $page.titlefontsize \ |
---|
1151 | -width .4i \ |
---|
1152 | -textvariable [itcl::scope _titleFontSize] \ |
---|
1153 | -editable no -menu $m \ |
---|
1154 | -command [itcl::code $this ApplyAxisSettings] |
---|
1155 | blt::combomenu $m \ |
---|
1156 | -xscrollbar $m.xs \ |
---|
1157 | -yscrollbar $m.ys \ |
---|
1158 | -textvariable [itcl::scope _titleFontSize] \ |
---|
1159 | -height { 0 2i } |
---|
1160 | blt::tk::scrollbar $m.xs |
---|
1161 | blt::tk::scrollbar $m.ys |
---|
1162 | $m add -text "8" -value "8" |
---|
1163 | $m add -text "9" -value "9" |
---|
1164 | $m add -text "10" -value "10" |
---|
1165 | $m add -text "11" -value "11" |
---|
1166 | $m add -text "12" -value "12" |
---|
1167 | $m add -text "14" -value "14" |
---|
1168 | $m add -text "17" -value "17" |
---|
1169 | $m add -text "18" -value "18" |
---|
1170 | $m add -text "20" -value "20" |
---|
1171 | $m item configure all \ |
---|
1172 | -variable [itcl::scope _settings($this-axis-titlefont-size)] |
---|
1173 | Rappture::Tooltip::for $page.titlefontsize \ |
---|
1174 | "Set the size (point) of the title font." |
---|
1175 | |
---|
1176 | blt::tk::pushbutton $page.titlefontweight \ |
---|
1177 | -width 18 -height 18 \ |
---|
1178 | -onimage [Rappture::icon font-bold] \ |
---|
1179 | -offimage [Rappture::icon font-bold] \ |
---|
1180 | -onvalue "bold" -offvalue "normal" \ |
---|
1181 | -command [itcl::code $this ApplyAxisSettings] \ |
---|
1182 | -variable [itcl::scope _settings($this-axis-titlefont-weight)] |
---|
1183 | Rappture::Tooltip::for $page.titlefontweight \ |
---|
1184 | "Use the bold version of the title font." |
---|
1185 | |
---|
1186 | blt::tk::pushbutton $page.titlefontslant \ |
---|
1187 | -width 18 -height 18 \ |
---|
1188 | -onimage [Rappture::icon font-italic] \ |
---|
1189 | -offimage [Rappture::icon font-italic] \ |
---|
1190 | -onvalue "italic" -offvalue "roman" \ |
---|
1191 | -command [itcl::code $this ApplyAxisSettings] \ |
---|
1192 | -variable [itcl::scope _settings($this-axis-titlefont-slant)] |
---|
1193 | Rappture::Tooltip::for $page.titlefontslant \ |
---|
1194 | "Use the italic version of the title font." |
---|
1195 | |
---|
1196 | blt::table $page \ |
---|
1197 | 1,1 $page.axis_l -anchor e -pady 6 \ |
---|
1198 | 1,2 $page.axis -fill x -cspan 6 \ |
---|
1199 | 2,1 $page.title_l -anchor e \ |
---|
1200 | 2,2 $page.title -fill x -cspan 5 \ |
---|
1201 | 3,1 $page.min_l -anchor e \ |
---|
1202 | 3,2 $page.min -fill x \ |
---|
1203 | 3,3 $page.stepsize_l -anchor e \ |
---|
1204 | 3,4 $page.stepsize -fill both -cspan 3 \ |
---|
1205 | 4,1 $page.max_l -anchor e \ |
---|
1206 | 4,2 $page.max -fill both \ |
---|
1207 | 4,3 $page.subdivisions_l -anchor e \ |
---|
1208 | 4,4 $page.subdivisions -fill both -cspan 3 \ |
---|
1209 | 5,1 $page.titlefont_l -anchor e \ |
---|
1210 | 5,2 $page.titlefontfamily -fill x -cspan 2 \ |
---|
1211 | 5,4 $page.titlefontsize -fill x \ |
---|
1212 | 5,5 $page.titlefontweight -anchor e \ |
---|
1213 | 5,6 $page.titlefontslant -anchor e \ |
---|
1214 | 6,1 $page.tickfont_l -anchor e \ |
---|
1215 | 6,2 $page.tickfontfamily -fill x -cspan 2 \ |
---|
1216 | 6,4 $page.tickfontsize -fill x \ |
---|
1217 | 6,5 $page.tickfontweight -anchor e \ |
---|
1218 | 6,6 $page.tickfontslant -anchor e \ |
---|
1219 | 7,1 $page.loose -cspan 2 -anchor w \ |
---|
1220 | 7,3 $page.grid -anchor w -cspan 2 \ |
---|
1221 | 8,1 $page.zero -cspan 2 -anchor w \ |
---|
1222 | 8,3 $page.plotpad_l -anchor e \ |
---|
1223 | 8,4 $page.plotpad -fill both -cspan 3 |
---|
1224 | |
---|
1225 | blt::table configure $page c0 c7 c8 -resize none |
---|
1226 | } |
---|
1227 | |
---|
1228 | itcl::body Rappture::XyPrint::ApplyGeneralSettings {} { |
---|
1229 | RegeneratePreview |
---|
1230 | } |
---|
1231 | |
---|
1232 | |
---|
1233 | itcl::body Rappture::XyPrint::ApplyAxisSettings {} { |
---|
1234 | if { $_clone == "" } { |
---|
1235 | return |
---|
1236 | } |
---|
1237 | set axis $_settings($this-axis-selected) |
---|
1238 | set type [GetAxisType $axis] |
---|
1239 | set page $itk_component(axis_page) |
---|
1240 | $_clone configure -plotpad${type} $_settings($this-axis-plotpad) |
---|
1241 | foreach option { -grid -min -max -loose -title -stepsize -subdivisions } { |
---|
1242 | SetNamedComponentOption axis $axis $option |
---|
1243 | } |
---|
1244 | $_clone marker configure ${type}-zero -hide $_settings($this-axis-zero) |
---|
1245 | font configure $axis-title \ |
---|
1246 | -family $_settings($this-axis-titlefont-family) \ |
---|
1247 | -size $_settings($this-axis-titlefont-size) \ |
---|
1248 | -weight $_settings($this-axis-titlefont-weight) \ |
---|
1249 | -slant $_settings($this-axis-titlefont-slant) |
---|
1250 | font configure $axis-ticks \ |
---|
1251 | -family $_settings($this-axis-tickfont-family) \ |
---|
1252 | -size $_settings($this-axis-tickfont-size) \ |
---|
1253 | -weight $_settings($this-axis-tickfont-weight) \ |
---|
1254 | -slant $_settings($this-axis-tickfont-slant) |
---|
1255 | $_clone axis configure $axis -tickfont fixed -titlefont fixed |
---|
1256 | $_clone axis configure $axis -tickfont $axis-ticks -titlefont $axis-title |
---|
1257 | GetAxis |
---|
1258 | RegeneratePreview |
---|
1259 | } |
---|
1260 | |
---|
1261 | itcl::body Rappture::XyPrint::ApplyElementSettings {} { |
---|
1262 | set index [$itk_component(element_slider) get] |
---|
1263 | set page $itk_component(legend_page) |
---|
1264 | set _settings($this-element-color) [$page.color current] |
---|
1265 | if { $_clone != "" } { |
---|
1266 | set elem $_settings($this-element-$index) |
---|
1267 | if { [$_clone element type $elem] != "bar" } { |
---|
1268 | set _settings($this-element-symbol) [$page.symbol current] |
---|
1269 | set _settings($this-element-dashes) [$page.dashes current] |
---|
1270 | foreach option { -symbol -dashes } { |
---|
1271 | SetNamedComponentOption element $elem $option |
---|
1272 | } |
---|
1273 | } |
---|
1274 | foreach option { -color -label } { |
---|
1275 | SetNamedComponentOption element $elem $option |
---|
1276 | } |
---|
1277 | RegeneratePreview |
---|
1278 | } |
---|
1279 | } |
---|
1280 | |
---|
1281 | itcl::body Rappture::XyPrint::SetLayoutOption { opt } { |
---|
1282 | set new [Inches2Pixels $_settings($this-layout$opt)] |
---|
1283 | $_clone configure $opt $new |
---|
1284 | } |
---|
1285 | |
---|
1286 | itcl::body Rappture::XyPrint::ApplyLayoutSettings {} { |
---|
1287 | foreach opt { -width -height -leftmargin -rightmargin -topmargin |
---|
1288 | -bottommargin } { |
---|
1289 | set old [$_clone cget $opt] |
---|
1290 | set code [catch { SetLayoutOption $opt } err] |
---|
1291 | if { $code != 0 } { |
---|
1292 | bell |
---|
1293 | global errorInfo |
---|
1294 | puts stderr "$err: $errorInfo" |
---|
1295 | set _settings($this-layout$opt) [Pixels2Inches $old] |
---|
1296 | $_clone configure $opt [Pixels2Inches $old] |
---|
1297 | } |
---|
1298 | } |
---|
1299 | RegeneratePreview |
---|
1300 | } |
---|
1301 | |
---|
1302 | |
---|
1303 | itcl::body Rappture::XyPrint::InitializeSettings {} { |
---|
1304 | # General settings |
---|
1305 | |
---|
1306 | # Always set to "ps" "ieee" |
---|
1307 | set _settings($this-general-format) ps |
---|
1308 | set _settings($this-general-style) ieee |
---|
1309 | set _settings($this-general-remember) 0 |
---|
1310 | set page $itk_component(graph_page) |
---|
1311 | |
---|
1312 | # Layout settings |
---|
1313 | set _settings($this-layout-width) [Pixels2Inches [$_clone cget -width]] |
---|
1314 | set _settings($this-layout-height) [Pixels2Inches [$_clone cget -height]] |
---|
1315 | set _settings($this-layout-leftmargin) \ |
---|
1316 | [Pixels2Inches [$_clone cget -leftmargin]] |
---|
1317 | set _settings($this-layout-rightmargin) \ |
---|
1318 | [Pixels2Inches [$_clone cget -rightmargin]] |
---|
1319 | set _settings($this-layout-topmargin) \ |
---|
1320 | [Pixels2Inches [$_clone cget -topmargin]] |
---|
1321 | set _settings($this-layout-bottommargin) \ |
---|
1322 | [Pixels2Inches [$_clone cget -bottommargin]] |
---|
1323 | |
---|
1324 | # Legend settings |
---|
1325 | set page $itk_component(legend_page) |
---|
1326 | |
---|
1327 | set names [$_clone element show] |
---|
1328 | $itk_component(element_slider) configure -from 1 -to [llength $names] |
---|
1329 | set state [expr { ([llength $names] < 2) ? "disabled" : "normal" } ] |
---|
1330 | $page.slider configure -state $state |
---|
1331 | $page.slider_l configure -state $state |
---|
1332 | # Always initialize the slider to the first entry in the element list. |
---|
1333 | $itk_component(element_slider) set 1 |
---|
1334 | # Always set the borderwidth to be not displayed |
---|
1335 | set _settings($this-legend-borderwidth) 0 |
---|
1336 | |
---|
1337 | array unset info |
---|
1338 | array set info [font configure legend] |
---|
1339 | set _settings($this-legend-font-family) $info(-family) |
---|
1340 | set _settings($this-legend-font-size) $info(-size) |
---|
1341 | set _settings($this-legend-font-weight) $info(-weight) |
---|
1342 | set _settings($this-legend-font-slant) $info(-slant) |
---|
1343 | if { $info(-weight) == "bold" } { |
---|
1344 | set _settings($this-legend-font-bold) 1 |
---|
1345 | } |
---|
1346 | set _settings($this-legend-hide) [$_clone legend cget -hide] |
---|
1347 | set _settings($this-legend-position) [$_clone legend cget -position] |
---|
1348 | set _settings($this-legend-anchor) [$_clone legend cget -anchor] |
---|
1349 | $page.anchor value [$page.anchor label $_settings($this-legend-anchor)] |
---|
1350 | GetElement |
---|
1351 | |
---|
1352 | # Axis settings |
---|
1353 | set page $itk_component(axis_page) |
---|
1354 | set names [lsort [$_clone axis names]] |
---|
1355 | $itk_component(axis_menu) delete all |
---|
1356 | foreach axis $names { |
---|
1357 | if { ![$_clone axis cget $axis -hide] } { |
---|
1358 | $itk_component(axis_menu) add -text $axis -value $axis \ |
---|
1359 | -variable [itcl::scope _settings($this-axis-selected)] |
---|
1360 | } |
---|
1361 | lappend axisnames $axis |
---|
1362 | } |
---|
1363 | set axis [lindex $axisnames 0] |
---|
1364 | set _settings($this-axis-selected) $axis |
---|
1365 | |
---|
1366 | array set info [font configure $axis-title] |
---|
1367 | set _settings($this-axis-titlefont-family) $info(-family) |
---|
1368 | set _settings($this-axis-titlefont-size) $info(-size) |
---|
1369 | set _settings($this-axis-titlefont-weight) $info(-weight) |
---|
1370 | set _settings($this-axis-titlefont-slant) $info(-slant) |
---|
1371 | |
---|
1372 | array set info [font configure $axis-ticks] |
---|
1373 | set _settings($this-axis-tickfont-family) $info(-family) |
---|
1374 | set _settings($this-axis-tickfont-size) $info(-size) |
---|
1375 | set _settings($this-axis-tickfont-weight) $info(-weight) |
---|
1376 | set _settings($this-axis-tickfont-slant) $info(-slant) |
---|
1377 | |
---|
1378 | # Always hide the zero line. |
---|
1379 | set _settings($this-axis-zero) 1 |
---|
1380 | set _settings($this-axis-plotpad) [Pixels2Inches [$_clone cget -plotpadx]] |
---|
1381 | # Pick the first axis to initially display |
---|
1382 | set axis [lindex $axisnames 0] |
---|
1383 | set $_settings($this-axis-selected) $axis |
---|
1384 | GetAxis |
---|
1385 | } |
---|
1386 | |
---|
1387 | |
---|
1388 | itcl::body Rappture::XyPrint::restore { toolName plotName data } { |
---|
1389 | set key [list $toolName $plotName] |
---|
1390 | set _savedSettings($key) $data |
---|
1391 | } |
---|
1392 | |
---|
1393 | itcl::body Rappture::XyPrint::RestoreSettings { toolName plotName } { |
---|
1394 | if { ![file readable $_settingsFile] } { |
---|
1395 | return; # No file or not readable |
---|
1396 | } |
---|
1397 | if { [file exists $_oldSettingsFile] } { |
---|
1398 | file delete $_oldSettingsFile |
---|
1399 | } |
---|
1400 | # Read the file by sourcing it into a safe interpreter The only commands |
---|
1401 | # executed will be "xyprint" which will simply add the data into an array |
---|
1402 | # _savedSettings. |
---|
1403 | set parser [interp create -safe] |
---|
1404 | $parser alias xyprint [itcl::code $this restore] |
---|
1405 | $parser alias font font |
---|
1406 | set f [open $_settingsFile "r"] |
---|
1407 | set code [read $f] |
---|
1408 | close $f |
---|
1409 | $parser eval $code |
---|
1410 | |
---|
1411 | # Now see if there's an entry for this tool/plot combination. The data |
---|
1412 | # associated with the variable is itself code to update the graph (clone). |
---|
1413 | set key [list $toolName $plotName] |
---|
1414 | if { [info exists _savedSettings($key)] } { |
---|
1415 | $parser alias "preview" $_clone |
---|
1416 | $parser eval $_savedSettings($key) |
---|
1417 | } |
---|
1418 | foreach {name value} [$parser eval "array get general"] { |
---|
1419 | set _settings($this-graph-$name) $value |
---|
1420 | } |
---|
1421 | interp delete $parser |
---|
1422 | } |
---|
1423 | |
---|
1424 | itcl::body Rappture::XyPrint::ResetSettings {} { |
---|
1425 | set graph $_graph |
---|
1426 | DestroySettings |
---|
1427 | set _graph $graph |
---|
1428 | CloneGraph $graph |
---|
1429 | InitClone |
---|
1430 | InitializeSettings |
---|
1431 | } |
---|
1432 | |
---|
1433 | itcl::body Rappture::XyPrint::SaveSettings { toolName plotName } { |
---|
1434 | if { !$_settings($this-general-remember) } { |
---|
1435 | return |
---|
1436 | } |
---|
1437 | if { [catch { open $_settingsFile "w" 0600 } f ] != 0 } { |
---|
1438 | puts stderr "$_settingsFile isn't writable: $f" |
---|
1439 | bell |
---|
1440 | return |
---|
1441 | } |
---|
1442 | set key [list $toolName $plotName] |
---|
1443 | set _savedSettings($key) [CreateSettings $toolName $plotName] |
---|
1444 | # Write the settings out |
---|
1445 | foreach key [lsort [array names _savedSettings]] { |
---|
1446 | set tool [lindex $key 0] |
---|
1447 | set plot [lindex $key 1] |
---|
1448 | puts $f "xyprint \"$tool\" \"$plot\" \{" |
---|
1449 | set settings [string trim $_savedSettings($key) \n] |
---|
1450 | puts $f "$settings" |
---|
1451 | puts $f "\}\n" |
---|
1452 | } |
---|
1453 | close $f |
---|
1454 | } |
---|
1455 | |
---|
1456 | itcl::body Rappture::XyPrint::CreateSettings { toolName plotName } { |
---|
1457 | # Create stanza associated with tool and plot title. |
---|
1458 | # General settings |
---|
1459 | append out " set general(format) $_settings($this-general-format)\n" |
---|
1460 | append out " set general(style) $_settings($this-general-style)\n" |
---|
1461 | |
---|
1462 | foreach font [array names _fonts] { |
---|
1463 | append out " font configure $font" |
---|
1464 | array unset info |
---|
1465 | array set info [font configure $font] |
---|
1466 | foreach opt { -family -size -weight -slant } { |
---|
1467 | set value [list $info($opt)] |
---|
1468 | append out " $opt $value" |
---|
1469 | } |
---|
1470 | append out "\n" |
---|
1471 | } |
---|
1472 | append out "\n" |
---|
1473 | |
---|
1474 | # Layout settings |
---|
1475 | append out " preview configure" |
---|
1476 | foreach opt { -width -height -leftmargin -rightmargin -topmargin |
---|
1477 | -bottommargin -plotpadx -plotpady } { |
---|
1478 | set value [list [$_clone cget $opt]] |
---|
1479 | append out " $opt $value" |
---|
1480 | } |
---|
1481 | append out "\n" |
---|
1482 | |
---|
1483 | # Legend settings |
---|
1484 | append out " preview legend configure" |
---|
1485 | foreach opt { -position -anchor -borderwidth -hide } { |
---|
1486 | set value [list [$_clone legend cget $opt]] |
---|
1487 | append out " $opt $value" |
---|
1488 | } |
---|
1489 | append out " -font legend\n" |
---|
1490 | |
---|
1491 | # Element settings |
---|
1492 | foreach elem [$_clone element show] { |
---|
1493 | set label [$_clone element cget $elem -label] |
---|
1494 | if { $label == "" } { |
---|
1495 | continue |
---|
1496 | } |
---|
1497 | append out " if \{ \[preview element exists \"$label\"\] \} \{\n" |
---|
1498 | append out " preview element configure \"$label\"" |
---|
1499 | if { [$_clone element type $elem] != "bar" } { |
---|
1500 | set options { -symbol -color -dashes -label } |
---|
1501 | } else { |
---|
1502 | set options { -color -label } |
---|
1503 | } |
---|
1504 | foreach opt $options { |
---|
1505 | set value [list [$_clone element cget $elem $opt]] |
---|
1506 | append out " $opt $value" |
---|
1507 | } |
---|
1508 | append out " \}\n" |
---|
1509 | } |
---|
1510 | |
---|
1511 | # Axis settings |
---|
1512 | foreach axis [$_clone axis names] { |
---|
1513 | if { [$_clone axis cget $axis -hide] } { |
---|
1514 | continue |
---|
1515 | } |
---|
1516 | append out " if \{ \[preview axis names \"$axis\"\] == \"$axis\" \} \{\n" |
---|
1517 | append out " preview axis configure \"$axis\"" |
---|
1518 | foreach opt { -hide -min -max -loose -title -stepsize -subdivisions } { |
---|
1519 | set value [list [$_clone axis cget $axis $opt]] |
---|
1520 | append out " $opt $value" |
---|
1521 | } |
---|
1522 | append out " -tickfont \"$axis-ticks\"" |
---|
1523 | append out " -titlefont \"$axis-title\"\n" |
---|
1524 | set hide [$_clone marker cget ${axis}-zero -hide] |
---|
1525 | append out " preview marker configure \"${axis}-zero\" -hide $hide\n" |
---|
1526 | append out " \}\n" |
---|
1527 | } |
---|
1528 | return $out |
---|
1529 | } |
---|