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 *XyResult.width 3i widgetDefault |
---|
16 | #option add *XyResult.height 3i widgetDefault |
---|
17 | option add *XyResult.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 10" |
---|
22 | option add *XyPrint*Entry*width "6" widgetDefault |
---|
23 | option add *XyPrint*Entry*background "white" widgetDefault |
---|
24 | |
---|
25 | array set Rappture::axistypes { |
---|
26 | x x |
---|
27 | y y |
---|
28 | x2 x |
---|
29 | y2 y |
---|
30 | } |
---|
31 | |
---|
32 | itcl::class Rappture::XyPrint { |
---|
33 | inherit itk::Widget |
---|
34 | |
---|
35 | constructor {args} {} |
---|
36 | destructor {} |
---|
37 | |
---|
38 | private variable _graph ""; # Original graph. |
---|
39 | private variable _clone ""; # Cloned graph. |
---|
40 | private variable _preview ""; # Preview image. |
---|
41 | |
---|
42 | public method print { graph } |
---|
43 | |
---|
44 | private method CopyOptions { cmd orig clone } |
---|
45 | private method CopyBindings { oper orig clone args } |
---|
46 | private method CloneGraph { orig } |
---|
47 | |
---|
48 | private method BuildGraphTab {} |
---|
49 | private method BuildLayoutTab {} |
---|
50 | private method BuildLegendTab {} |
---|
51 | private method BuildAxisTab {} |
---|
52 | private method SetOption { opt } |
---|
53 | private method SetComponentOption { comp opt } |
---|
54 | private method SetNamedComponentOption { comp name opt } |
---|
55 | private method GetAxis {} |
---|
56 | private method GetElement { args } |
---|
57 | private method RegeneratePreview {} |
---|
58 | private method InitClone {} |
---|
59 | private method Pixels2Inches { pixels } |
---|
60 | private method Inches2Pixels { inches } |
---|
61 | |
---|
62 | private method BuildLayoutTab {} |
---|
63 | private method BuildGeneralTab {} |
---|
64 | private method ApplyLegendSettings {} |
---|
65 | private method BuildLegendTab {} |
---|
66 | private method BuildAxisTab {} |
---|
67 | |
---|
68 | private method ApplyGeneralSettings {} |
---|
69 | private method ApplyLegendSettings {} |
---|
70 | private method ApplyAxisSettings {} |
---|
71 | private method ApplyElementSettings {} |
---|
72 | private method ApplyLayoutSettings {} |
---|
73 | private method InitializeSettings {} |
---|
74 | private method RestoreSettings { file } |
---|
75 | private method SaveSettings { file } |
---|
76 | private method Done { state } |
---|
77 | private common _settings |
---|
78 | private common _wait |
---|
79 | } |
---|
80 | |
---|
81 | # ---------------------------------------------------------------------- |
---|
82 | # CONSTRUCTOR |
---|
83 | # ---------------------------------------------------------------------- |
---|
84 | itcl::body Rappture::XyPrint::constructor { args } { |
---|
85 | Rappture::dispatcher _dispatcher |
---|
86 | $_dispatcher register !rebuild |
---|
87 | $_dispatcher dispatch $this !rebuild "[itcl::code $this Rebuild]; list" |
---|
88 | |
---|
89 | # option add hull.width hull.height |
---|
90 | # pack propagate $itk_component(hull) no |
---|
91 | |
---|
92 | set w [winfo pixels . 2.5i] |
---|
93 | set h [winfo pixels . 2i] |
---|
94 | set _preview [image create photo -width $w -height $h] |
---|
95 | itk_component add tabs { |
---|
96 | blt::tabset $itk_interior.tabs \ |
---|
97 | -highlightthickness 0 -tearoff 0 -side top \ |
---|
98 | -bd 0 -gap 0 -tabborderwidth 1 \ |
---|
99 | -outerpad 1 -background grey |
---|
100 | } { |
---|
101 | keep -cursor |
---|
102 | ignore -highlightthickness -borderwidth -background |
---|
103 | } |
---|
104 | itk_component add preview { |
---|
105 | label $itk_interior.preview \ |
---|
106 | -highlightthickness 0 -bd 0 -image $_preview -width 2.5i \ |
---|
107 | -height 2.25i -background grey -padx 10 -pady 10 |
---|
108 | } { |
---|
109 | ignore -background |
---|
110 | } |
---|
111 | itk_component add ok { |
---|
112 | button $itk_interior.ok -text "Print" \ |
---|
113 | -highlightthickness 0 \ |
---|
114 | -command [itcl::code $this Done 1] \ |
---|
115 | -compound left \ |
---|
116 | -image [Rappture::icon download] |
---|
117 | } |
---|
118 | itk_component add cancel { |
---|
119 | button $itk_interior.cancel -text "Cancel" \ |
---|
120 | -highlightthickness 0 \ |
---|
121 | -command [itcl::code $this Done 0] \ |
---|
122 | -compound left \ |
---|
123 | -image [Rappture::icon dialog-cancel] |
---|
124 | } |
---|
125 | blt::table $itk_interior \ |
---|
126 | 0,0 $itk_component(preview) -cspan 2 -fill both \ |
---|
127 | 1,0 $itk_component(tabs) -fill both -cspan 2 \ |
---|
128 | 2,0 $itk_component(cancel) -padx 2 -pady 2 -width .9i -fill y \ |
---|
129 | 2,1 $itk_component(ok) -padx 2 -pady 2 -width .9i -fill y |
---|
130 | blt::table configure $itk_interior r1 -resize none |
---|
131 | blt::table configure $itk_interior r1 -resize both |
---|
132 | |
---|
133 | BuildGraphTab |
---|
134 | BuildAxisTab |
---|
135 | BuildLegendTab |
---|
136 | BuildLayoutTab |
---|
137 | eval itk_initialize $args |
---|
138 | } |
---|
139 | |
---|
140 | # ---------------------------------------------------------------------- |
---|
141 | # DESTRUCTOR |
---|
142 | # ---------------------------------------------------------------------- |
---|
143 | itcl::body Rappture::XyResult::destructor {} { |
---|
144 | destroy $_clone |
---|
145 | image delete $_preview |
---|
146 | array unset _settings $this-* |
---|
147 | } |
---|
148 | |
---|
149 | itcl::body Rappture::XyResult::DestroyData {} { |
---|
150 | destroy $_clone |
---|
151 | array unset _settings $this-* |
---|
152 | set _clone "" |
---|
153 | set _graph "" |
---|
154 | } |
---|
155 | |
---|
156 | itcl::body Rappture::XyPrint::Done { state } { |
---|
157 | set _wait($this) $state |
---|
158 | } |
---|
159 | |
---|
160 | itcl::body Rappture::XyPrint::print { graph } { |
---|
161 | set _graph $graph |
---|
162 | set _clone [CloneGraph $graph] |
---|
163 | InitClone |
---|
164 | InitializeSettings |
---|
165 | # RestoreSettings |
---|
166 | set _wait($this) 0 |
---|
167 | tkwait variable [itcl::scope _wait($this)] |
---|
168 | if { _wait($this) } { |
---|
169 | return [GetOutput] |
---|
170 | } |
---|
171 | # SaveSettings |
---|
172 | # DestroyData |
---|
173 | return "" |
---|
174 | } |
---|
175 | |
---|
176 | itcl::body Rappture::XyPrint::GetOutput {} { |
---|
177 | # Get the selected format of the download. |
---|
178 | set page $itk_component(graph_page) |
---|
179 | set format [$page.format current] |
---|
180 | |
---|
181 | if { $format == "jpg" } { |
---|
182 | set img [image create photo] |
---|
183 | $_clone snap $img |
---|
184 | set bytes [$img data -format "jpeg -quality 100"] |
---|
185 | set bytes [Rappture::encoding::decode -as b64 $bytes] |
---|
186 | image delete $img |
---|
187 | return [list .jpg $bytes] |
---|
188 | } elseif { $format == "png" } { |
---|
189 | set img [image create photo] |
---|
190 | $_clone snap $img |
---|
191 | set bytes [$img data -format "png"] |
---|
192 | set bytes [Rappture::encoding::decode -as b64 $bytes] |
---|
193 | image delete $img |
---|
194 | return [list .png $bytes] |
---|
195 | } |
---|
196 | |
---|
197 | # Handle encapsulated postscript or portable document format. |
---|
198 | |
---|
199 | # Append an "i" for the graph postscript component. |
---|
200 | set w $_settings($this-layout-width)i |
---|
201 | set h $_settings($this-layout-height)i |
---|
202 | |
---|
203 | $_clone postscript configure \ |
---|
204 | -maxpect false \ |
---|
205 | -decoration yes \ |
---|
206 | -center yes \ |
---|
207 | -width $w -height $h |
---|
208 | |
---|
209 | set psdata [$_clone postscript output] |
---|
210 | set f [open "junk.raw" "w"] |
---|
211 | puts -nonewline $f $psdata |
---|
212 | close $f |
---|
213 | |
---|
214 | if { $format == "eps" } { |
---|
215 | set cmd [list | eps2eps -dEPSCrop - - << $psdata] |
---|
216 | } elseif { $format == "pdf" } { |
---|
217 | set cmd [list | eps2eps - - << $psdata | ps2pdf - -] |
---|
218 | } |
---|
219 | if { [catch { |
---|
220 | set f [open $cmd "r"] |
---|
221 | fconfigure $f -translation binary -encoding binary |
---|
222 | set output [read $f] |
---|
223 | close $f |
---|
224 | } err ] != 0 } { |
---|
225 | global errorInfo |
---|
226 | puts stderr "failed to generate file: $err\n$errorInfo" |
---|
227 | return "" |
---|
228 | } |
---|
229 | set f [open "junk.$format" "w"] |
---|
230 | fconfigure $f -translation binary -encoding binary |
---|
231 | puts -nonewline $f $output |
---|
232 | close $f |
---|
233 | return [list .$format $output] |
---|
234 | } |
---|
235 | |
---|
236 | itcl::body Rappture::XyPrint::CopyOptions { cmd orig clone } { |
---|
237 | set all [eval $orig $cmd] |
---|
238 | set configLine $clone |
---|
239 | foreach arg $cmd { |
---|
240 | lappend configLine $arg |
---|
241 | } |
---|
242 | foreach option $all { |
---|
243 | if { [llength $option] != 5 } { |
---|
244 | continue |
---|
245 | } |
---|
246 | set switch [lindex $option 0] |
---|
247 | set initial [lindex $option 3] |
---|
248 | set current [lindex $option 4] |
---|
249 | if { [string compare $initial $current] == 0 } { |
---|
250 | continue |
---|
251 | } |
---|
252 | lappend configLine $switch $current |
---|
253 | } |
---|
254 | eval $configLine |
---|
255 | } |
---|
256 | |
---|
257 | itcl::body Rappture::XyPrint::CloneGraph { orig } { |
---|
258 | set top $itk_interior |
---|
259 | set clone [blt::graph $top.graph] |
---|
260 | CopyOptions "configure" $orig $clone |
---|
261 | # Axis component |
---|
262 | foreach axis [$orig axis names] { |
---|
263 | if { [$orig axis cget $axis -hide] } { |
---|
264 | continue |
---|
265 | } |
---|
266 | if { [$clone axis name $axis] == "" } { |
---|
267 | $clone axis create $axis |
---|
268 | } |
---|
269 | CopyOptions [list axis configure $axis] $orig $clone |
---|
270 | } |
---|
271 | foreach axis { x y x2 y2 } { |
---|
272 | $clone ${axis}axis use [$orig ${axis}axis use] |
---|
273 | } |
---|
274 | # Pen component |
---|
275 | foreach pen [$orig pen names] { |
---|
276 | if { [$clone pen name $pen] == "" } { |
---|
277 | $clone pen create $pen |
---|
278 | } |
---|
279 | CopyOptions [list pen configure $pen] $orig $clone |
---|
280 | } |
---|
281 | # Marker component |
---|
282 | foreach marker [$orig marker names] { |
---|
283 | $clone marker create [$orig marker type $marker] -name $marker |
---|
284 | CopyBindings marker $orig $clone $marker |
---|
285 | CopyOptions [list marker configure $marker] $orig $clone |
---|
286 | } |
---|
287 | # Element component |
---|
288 | foreach elem [$orig element names] { |
---|
289 | $clone element create $elem |
---|
290 | CopyOptions [list element configure $elem] $orig $clone |
---|
291 | } |
---|
292 | # Fix element display list |
---|
293 | $clone element show [$orig element show] |
---|
294 | # Legend component |
---|
295 | CopyOptions {legend configure} $orig $clone |
---|
296 | # Postscript component |
---|
297 | CopyOptions {postscript configure} $orig $clone |
---|
298 | # Grid component |
---|
299 | CopyOptions {grid configure} $orig $clone |
---|
300 | # Grid component |
---|
301 | CopyOptions {crosshairs configure} $orig $clone |
---|
302 | return $clone |
---|
303 | } |
---|
304 | |
---|
305 | itcl::body Rappture::XyPrint::InitClone {} { |
---|
306 | |
---|
307 | $_clone configure -width 3.4i -height 3.4i -background white \ |
---|
308 | -borderwidth 0 \ |
---|
309 | -leftmargin 0 \ |
---|
310 | -rightmargin 0 \ |
---|
311 | -topmargin 0 \ |
---|
312 | -bottommargin 0 |
---|
313 | |
---|
314 | # Kill the title and create a border around the plot |
---|
315 | $_clone configure \ |
---|
316 | -title "" \ |
---|
317 | -plotborderwidth 1 -plotrelief solid \ |
---|
318 | -plotbackground white -plotpadx 0 -plotpady 0 |
---|
319 | # |
---|
320 | $_clone legend configure \ |
---|
321 | -position right \ |
---|
322 | -font "*-helvetica-medium-r-normal-*-12-*" \ |
---|
323 | -hide yes -borderwidth 0 -background white -relief solid \ |
---|
324 | -anchor nw -activeborderwidth 0 |
---|
325 | # |
---|
326 | foreach axis [$_clone axis names] { |
---|
327 | if { [$_clone axis cget $axis -hide] } { |
---|
328 | continue |
---|
329 | } |
---|
330 | $_clone axis configure $axis -ticklength 5 \ |
---|
331 | -majorticks {} -minorticks {} |
---|
332 | $_clone axis configure $axis \ |
---|
333 | -tickfont "*-helvetica-medium-r-normal-*-12-*" \ |
---|
334 | -titlefont "*-helvetica-medium-r-normal-*-12-*" |
---|
335 | } |
---|
336 | #$_clone grid off |
---|
337 | #$_clone yaxis configure -rotate 90 |
---|
338 | #$_clone y2axis configure -rotate 270 |
---|
339 | foreach elem [$_clone element names] { |
---|
340 | $_clone element configure $elem -linewidth 1 \ |
---|
341 | -pixels 3 |
---|
342 | } |
---|
343 | # Create markers representing lines at zero for the x and y axis. |
---|
344 | $_clone marker create line -name x-zero \ |
---|
345 | -coords "0 -Inf 0 Inf" -dashes dot -hide yes |
---|
346 | $_clone marker create line -name y-zero \ |
---|
347 | -coords "-Inf 0 Inf 0" -dashes dot -hide yes |
---|
348 | } |
---|
349 | |
---|
350 | itcl::body Rappture::XyPrint::SetOption { opt } { |
---|
351 | set new $_settings($this-graph-$opt) |
---|
352 | set old [$_clone cget -$opt] |
---|
353 | set code [catch [list $_clone configure -$opt $new] err] |
---|
354 | if { $code != 0 } { |
---|
355 | bell |
---|
356 | global errorInfo |
---|
357 | puts stderr "$err: $errorInfo" |
---|
358 | set _settings($this-graph-$opt) $old |
---|
359 | } |
---|
360 | } |
---|
361 | |
---|
362 | itcl::body Rappture::XyPrint::SetComponentOption { comp opt } { |
---|
363 | set new $_settings($this-$comp-$opt) |
---|
364 | set old [$_clone $comp cget -$opt] |
---|
365 | set code [catch [list $_clone $comp configure -$opt $new] err] |
---|
366 | if { $code != 0 } { |
---|
367 | bell |
---|
368 | global errorInfo |
---|
369 | puts stderr "$err: $errorInfo" |
---|
370 | set _settings($this-$comp-$opt) $old |
---|
371 | } |
---|
372 | } |
---|
373 | |
---|
374 | itcl::body Rappture::XyPrint::SetNamedComponentOption { comp name opt } { |
---|
375 | set new $_settings($this-$comp-$opt) |
---|
376 | set old [$_clone $comp cget $name -$opt] |
---|
377 | set code [catch [list $_clone $comp configure $name -$opt $new] err] |
---|
378 | if { $code != 0 } { |
---|
379 | bell |
---|
380 | global errorInfo |
---|
381 | puts stderr "$err: $errorInfo" |
---|
382 | set _settings($this-$comp-$opt) $old |
---|
383 | } |
---|
384 | } |
---|
385 | |
---|
386 | itcl::body Rappture::XyPrint::RegeneratePreview {} { |
---|
387 | update |
---|
388 | set img [image create photo] |
---|
389 | |
---|
390 | set w [Inches2Pixels $_settings($this-layout-width)] |
---|
391 | set h [Inches2Pixels $_settings($this-layout-height)] |
---|
392 | puts stderr "w=$w h=$h" |
---|
393 | set pixelsPerInch [winfo pixels . 1i] |
---|
394 | set sx [expr 2.5*$pixelsPerInch/$w] |
---|
395 | set sy [expr 2.0*$pixelsPerInch/$h] |
---|
396 | puts stderr "sx=$sx sy=$sy" |
---|
397 | set s [expr min($sx,$sy)] |
---|
398 | $_clone snap $img -width $w -height $h |
---|
399 | |
---|
400 | if 0 { |
---|
401 | if { ![winfo exists .labeltest] } { |
---|
402 | toplevel .labeltest -bg red |
---|
403 | label .labeltest.label -image $img |
---|
404 | pack .labeltest.label -fill both |
---|
405 | } |
---|
406 | } |
---|
407 | set pw [expr int(round($s * $w))] |
---|
408 | set ph [expr int(round($s * $h))] |
---|
409 | $_preview configure -width $pw -height $ph |
---|
410 | #.labeltest.label configure -image $img |
---|
411 | blt::winop resample $img $_preview box |
---|
412 | image delete $img |
---|
413 | } |
---|
414 | |
---|
415 | itcl::body Rappture::XyPrint::Pixels2Inches { pixels } { |
---|
416 | if { [llength $pixels] == 2 } { |
---|
417 | set pixels [lindex $pixels 0] |
---|
418 | } |
---|
419 | set pixelsPerInch [winfo pixels . 1i] |
---|
420 | set inches [expr { double($pixels) / $pixelsPerInch }] |
---|
421 | return [format %.3g ${inches}] |
---|
422 | } |
---|
423 | |
---|
424 | itcl::body Rappture::XyPrint::Inches2Pixels { inches } { |
---|
425 | return [winfo pixels . ${inches}i] |
---|
426 | } |
---|
427 | |
---|
428 | |
---|
429 | itcl::body Rappture::XyPrint::GetAxis {} { |
---|
430 | set axis [$itk_component(axis_combo) current] |
---|
431 | foreach option { min max loose title stepsize subdivisions } { |
---|
432 | set _settings($this-axis-$option) [$_clone axis cget $axis -$option] |
---|
433 | } |
---|
434 | set type $Rappture::axistypes($axis) |
---|
435 | if { [$_clone grid cget -map${type}] == $axis } { |
---|
436 | set _settings($this-axis-grid) 1 |
---|
437 | } else { |
---|
438 | set _settings($this-axis-grid) 0 |
---|
439 | } |
---|
440 | set _settings($this-axis-zero) [$_clone marker cget ${type}-zero -hide] |
---|
441 | } |
---|
442 | |
---|
443 | itcl::body Rappture::XyPrint::GetElement { args } { |
---|
444 | set index 1 |
---|
445 | foreach elem [$_clone element show] { |
---|
446 | set _settings($this-element-$index) $elem |
---|
447 | incr index |
---|
448 | } |
---|
449 | set index [$itk_component(element_slider) get] |
---|
450 | set elem $_settings($this-element-$index) |
---|
451 | set _settings($this-element-symbol) [$_clone element cget $elem -symbol] |
---|
452 | set _settings($this-element-color) [$_clone element cget $elem -color] |
---|
453 | set _settings($this-element-dashes) [$_clone element cget $elem -dashes] |
---|
454 | set _settings($this-element-hide) [$_clone element cget $elem -hide] |
---|
455 | set _settings($this-element-label) [$_clone element cget $elem -label] |
---|
456 | set page $itk_component(legend_page) |
---|
457 | $page.color value [$page.color label $_settings($this-element-color)] |
---|
458 | $page.symbol value [$page.symbol label $_settings($this-element-symbol)] |
---|
459 | $page.dashes value [$page.dashes label $_settings($this-element-dashes)] |
---|
460 | #FixElement |
---|
461 | } |
---|
462 | |
---|
463 | itcl::body Rappture::XyPrint::BuildLayoutTab {} { |
---|
464 | itk_component add layout_page { |
---|
465 | frame $itk_component(tabs).layout_page |
---|
466 | } |
---|
467 | set page $itk_component(layout_page) |
---|
468 | $itk_component(tabs) insert end "layout" \ |
---|
469 | -text "Layout" -padx 2 -pady 2 -window $page -fill both |
---|
470 | |
---|
471 | label $page.width_l -text "width" |
---|
472 | entry $page.width -width 6 \ |
---|
473 | -textvariable [itcl::scope _settings($this-layout-width)] |
---|
474 | bind $page.width <KeyPress-Return> [itcl::code $this ApplyLayoutSettings] |
---|
475 | |
---|
476 | label $page.height_l -text "height" |
---|
477 | entry $page.height -width 6 \ |
---|
478 | -textvariable [itcl::scope _settings($this-layout-height)] |
---|
479 | bind $page.height <KeyPress-Return> [itcl::code $this ApplyLayoutSettings] |
---|
480 | |
---|
481 | label $page.margin_l -text "Margins" |
---|
482 | |
---|
483 | label $page.left_l -text "left" |
---|
484 | entry $page.left -width 6 \ |
---|
485 | -textvariable [itcl::scope _settings($this-layout-leftmargin)] |
---|
486 | bind $page.left <KeyPress-Return> [itcl::code $this ApplyLayoutSettings] |
---|
487 | |
---|
488 | label $page.right_l -text "right" |
---|
489 | entry $page.right -width 6 \ |
---|
490 | -textvariable [itcl::scope _settings($this-layout-rightmargin)] |
---|
491 | bind $page.right <KeyPress-Return> [itcl::code $this ApplyLayoutSettings] |
---|
492 | |
---|
493 | label $page.top_l -text "top" |
---|
494 | entry $page.top -width 6 \ |
---|
495 | -textvariable [itcl::scope _settings($this-layout-topmargin)] |
---|
496 | bind $page.top <KeyPress-Return> [itcl::code $this ApplyLayoutSettings] |
---|
497 | |
---|
498 | label $page.bottom_l -text "bottom" |
---|
499 | entry $page.bottom -width 6 \ |
---|
500 | -textvariable [itcl::scope _settings($this-layout-bottommargin)] |
---|
501 | bind $page.bottom <KeyPress-Return> [itcl::code $this ApplyLayoutSettings] |
---|
502 | |
---|
503 | blt::table $page \ |
---|
504 | 1,0 $page.width_l -anchor e \ |
---|
505 | 1,1 $page.width -fill x -cspan 2 \ |
---|
506 | 1,3 $page.height_l -anchor e \ |
---|
507 | 1,4 $page.height -fill x -cspan 2 \ |
---|
508 | 3,2 $page.top_l -anchor e \ |
---|
509 | 3,3 $page.top -fill x \ |
---|
510 | 4,0 $page.left_l -anchor e \ |
---|
511 | 4,1 $page.left -fill x \ |
---|
512 | 4,4 $page.right_l -anchor e \ |
---|
513 | 4,5 $page.right -fill x \ |
---|
514 | 5,2 $page.bottom_l -anchor e \ |
---|
515 | 5,3 $page.bottom -fill x |
---|
516 | |
---|
517 | blt::table configure $page r* -resize none |
---|
518 | blt::table configure $page r2 -resize both |
---|
519 | blt::table configure $page c2 c4 -width .5i |
---|
520 | blt::table configure $page r6 -height .125i |
---|
521 | } |
---|
522 | |
---|
523 | |
---|
524 | itcl::body Rappture::XyPrint::BuildGeneralTab {} { |
---|
525 | itk_component add graph_page { |
---|
526 | frame $itk_component(tabs).graph_page |
---|
527 | } |
---|
528 | set page $itk_component(graph_page) |
---|
529 | $itk_component(tabs) insert end "graph" \ |
---|
530 | -text "General" -padx 2 -pady 2 -window $page -fill both |
---|
531 | |
---|
532 | label $page.format_l -text "format" |
---|
533 | Rappture::Combobox $page.format -width 30 -editable no |
---|
534 | $page.format choices insert end \ |
---|
535 | "eps" "EPS Encapsulated PostScript" \ |
---|
536 | "pdf" "PDF Portable Document Format" \ |
---|
537 | "jpg" "JPEG Joint Photographic Experts Group Format" \ |
---|
538 | "png" "PNG Portable Network Graphics Format" |
---|
539 | |
---|
540 | bind $page.format <<Value>> [itcl::code $this ApplyGeneralSettings] |
---|
541 | |
---|
542 | label $page.style_l -text "style" |
---|
543 | Rappture::Combobox $page.style -width 20 -editable no |
---|
544 | $page.style choices insert end \ |
---|
545 | "ieee" "IEEE Journal" \ |
---|
546 | "gekco" "G Klimeck" |
---|
547 | bind $page.style <<Value>> [itcl::code $this ApplyGeneralSettings] |
---|
548 | |
---|
549 | checkbutton $page.remember -text "remember settings" \ |
---|
550 | -variable [itcl::scope _settings($this-general-remember)] |
---|
551 | |
---|
552 | blt::table $page \ |
---|
553 | 2,0 $page.format_l -anchor e \ |
---|
554 | 2,1 $page.format -fill x \ |
---|
555 | 3,0 $page.style_l -anchor e \ |
---|
556 | 3,1 $page.style -fill x \ |
---|
557 | 5,0 $page.remember -cspan 2 -anchor w |
---|
558 | blt::table configure $page r* -resize none |
---|
559 | blt::table configure $page r4 -resize both |
---|
560 | |
---|
561 | } |
---|
562 | |
---|
563 | itcl::body Rappture::XyPrint::ApplyLegendSettings {} { |
---|
564 | set page $itk_component(legend_page) |
---|
565 | set _settings($this-legend-position) [$page.position current] |
---|
566 | set _settings($this-legend-anchor) [$page.anchor current] |
---|
567 | foreach option { hide position anchor borderwidth } { |
---|
568 | SetComponentOption legend $option |
---|
569 | } |
---|
570 | ApplyElementSettings |
---|
571 | } |
---|
572 | |
---|
573 | itcl::body Rappture::XyPrint::BuildLegendTab {} { |
---|
574 | itk_component add legend_page { |
---|
575 | frame $itk_component(tabs).legend_page |
---|
576 | } |
---|
577 | set page $itk_component(legend_page) |
---|
578 | $itk_component(tabs) insert end "legend" \ |
---|
579 | -text "Legend" -padx 2 -pady 2 -window $page -fill both |
---|
580 | |
---|
581 | checkbutton $page.show -text "show legend" \ |
---|
582 | -offvalue 1 -onvalue 0 \ |
---|
583 | -variable [itcl::scope _settings($this-legend-hide)] \ |
---|
584 | -command [itcl::code $this ApplyLegendSettings] |
---|
585 | |
---|
586 | label $page.position_l -text "position" |
---|
587 | Rappture::Combobox $page.position -width 15 -editable no |
---|
588 | $page.position choices insert end \ |
---|
589 | "leftmargin" "left margin" \ |
---|
590 | "rightmargin" "right margin" \ |
---|
591 | "bottommargin" "bottom margin" \ |
---|
592 | "topmargin" "top margin" \ |
---|
593 | "plotarea" "inside plot" |
---|
594 | bind $page.position <<Value>> [itcl::code $this ApplyLegendSettings] |
---|
595 | |
---|
596 | Rappture::Combobox $page.anchor -width 10 -editable no |
---|
597 | $page.anchor choices insert end \ |
---|
598 | "nw" "northwest" \ |
---|
599 | "n" "north" \ |
---|
600 | "ne" "northeast" \ |
---|
601 | "sw" "southwest" \ |
---|
602 | "s" "south" \ |
---|
603 | "se" "southeast" \ |
---|
604 | "c" "center" \ |
---|
605 | "e" "east" \ |
---|
606 | "w" "west" |
---|
607 | bind $page.anchor <<Value>> [itcl::code $this ApplyLegendSettings] |
---|
608 | |
---|
609 | checkbutton $page.border -text "border" \ |
---|
610 | -font "Arial 10" \ |
---|
611 | -variable [itcl::scope _settings($this-legend-borderwidth)] \ |
---|
612 | -onvalue 1 -offvalue 0 \ |
---|
613 | -command [itcl::code $this ApplyLegendSettings] |
---|
614 | |
---|
615 | label $page.slider_l -text "legend\nentry" -font "Arial 10" -justify right |
---|
616 | set names [$_clone element show] |
---|
617 | itk_component add element_slider { |
---|
618 | ::scale $page.slider -from 1 -to [llength $names] \ |
---|
619 | -orient horizontal -width 12 \ |
---|
620 | -command [itcl::code $this GetElement] |
---|
621 | } |
---|
622 | if { [llength $names] < 2 } { |
---|
623 | $page.slider configure -state disabled |
---|
624 | $page.slider_l configure -state disabled |
---|
625 | } |
---|
626 | checkbutton $page.hide -text "hide" \ |
---|
627 | -font "Arial 10" \ |
---|
628 | -variable [itcl::scope _settings($this-element-hide)] \ |
---|
629 | -command [itcl::code $this ApplyElementSettings] |
---|
630 | |
---|
631 | label $page.label_l -text "label" -font "Arial 10" |
---|
632 | entry $page.label \ |
---|
633 | -background white \ |
---|
634 | -font "Arial 10" \ |
---|
635 | -textvariable [itcl::scope _settings($this-element-label)] |
---|
636 | bind $page.label <KeyPress-Return> [itcl::code $this ApplyElementSettings] |
---|
637 | |
---|
638 | label $page.color_l -text "color " -font "Arial 10" |
---|
639 | Rappture::Combobox $page.color -width 15 -editable no |
---|
640 | $page.color choices insert end \ |
---|
641 | "#000000" "black" \ |
---|
642 | "#ffffff" "white" \ |
---|
643 | "#0000cd" "blue" \ |
---|
644 | "#cd0000" "red" \ |
---|
645 | "#00cd00" "green" \ |
---|
646 | "#3a5fcd" "royal blue" \ |
---|
647 | "#cdcd00" "yellow" \ |
---|
648 | "#cd1076" "deep pink" \ |
---|
649 | "#009acd" "deep sky blue" \ |
---|
650 | "#00c5cd" "torquise" \ |
---|
651 | "#a2b5cd" "light steel blue" \ |
---|
652 | "#7ac5cd" "cadet blue" \ |
---|
653 | "#66cdaa" "aquamarine" \ |
---|
654 | "#a2cd5a" "dark olive green" \ |
---|
655 | "#cd9b9b" "rosy brown" |
---|
656 | bind $page.color <<Value>> [itcl::code $this ApplyElementSettings] |
---|
657 | |
---|
658 | label $page.dashes_l -text "line style" -font "Arial 10" |
---|
659 | Rappture::Combobox $page.dashes -width 15 -editable no |
---|
660 | $page.dashes choices insert end \ |
---|
661 | "" "solid" \ |
---|
662 | "1" "dot" \ |
---|
663 | "5 2" "dash" \ |
---|
664 | "2 4 2" "dashdot" \ |
---|
665 | "2 4 2 2" "dashdotdot" |
---|
666 | bind $page.dashes <<Value>> [itcl::code $this ApplyElementSettings] |
---|
667 | |
---|
668 | label $page.symbol_l -text "symbol" -font "Arial 10" |
---|
669 | Rappture::Combobox $page.symbol -editable no |
---|
670 | $page.symbol choices insert end \ |
---|
671 | "none" "none" \ |
---|
672 | "square" "square" \ |
---|
673 | "circle" "circle" \ |
---|
674 | "diamond" "diamond" \ |
---|
675 | "plus" "plus" \ |
---|
676 | "cross" "cross" \ |
---|
677 | "splus" "skinny plus" \ |
---|
678 | "scross" "skinny cross" \ |
---|
679 | "triangle" "triangle" |
---|
680 | bind $page.symbol <<Value>> [itcl::code $this ApplyElementSettings] |
---|
681 | |
---|
682 | blt::table $page \ |
---|
683 | 1,0 $page.show -cspan 2 -anchor w \ |
---|
684 | 1,2 $page.border -cspan 2 -anchor w \ |
---|
685 | 2,0 $page.position_l -anchor e \ |
---|
686 | 2,1 $page.position -fill x \ |
---|
687 | 2,2 $page.anchor -fill x -cspan 2 \ |
---|
688 | 3,0 $page.slider_l -anchor e \ |
---|
689 | 3,1 $page.slider -fill x -cspan 4 \ |
---|
690 | 4,0 $page.label_l -anchor e \ |
---|
691 | 4,1 $page.label -fill x -cspan 3 \ |
---|
692 | 5,0 $page.color_l -anchor e \ |
---|
693 | 5,1 $page.color -fill x \ |
---|
694 | 5,2 $page.symbol_l -anchor e \ |
---|
695 | 5,3 $page.symbol -fill both \ |
---|
696 | 6,0 $page.dashes_l -anchor e \ |
---|
697 | 6,1 $page.dashes -fill x \ |
---|
698 | |
---|
699 | blt::table configure $page r* -resize none |
---|
700 | blt::table configure $page r8 -resize both |
---|
701 | |
---|
702 | } |
---|
703 | |
---|
704 | itcl::body Rappture::XyPrint::BuildAxisTab {} { |
---|
705 | itk_component add axis_page { |
---|
706 | frame $itk_component(tabs).axis_page |
---|
707 | } |
---|
708 | set page $itk_component(axis_page) |
---|
709 | $itk_component(tabs) insert end "axis" \ |
---|
710 | -text "Axis" -padx 2 -pady 2 -window $page -fill both |
---|
711 | |
---|
712 | label $page.axis_l -text "axis" -font "Arial 10" |
---|
713 | itk_component add axis_combo { |
---|
714 | Rappture::Combobox $page.axis -width 20 -editable no |
---|
715 | } |
---|
716 | set names [lsort [$_clone axis names]] |
---|
717 | foreach axis $names { |
---|
718 | if { ![$_clone axis cget $axis -hide] } { |
---|
719 | $itk_component(axis_combo) choices insert end $axis $axis |
---|
720 | } |
---|
721 | } |
---|
722 | bind $itk_component(axis_combo) <<Value>> [itcl::code $this GetAxis] |
---|
723 | |
---|
724 | label $page.title_l -text "title" -font "Arial 10" |
---|
725 | entry $page.title \ |
---|
726 | -textvariable [itcl::scope _settings($this-axis-title)] |
---|
727 | bind $page.title <KeyPress-Return> [itcl::code $this ApplyAxisSettings] |
---|
728 | |
---|
729 | label $page.min_l -text "min" -font "Arial 10" |
---|
730 | entry $page.min -width 10 \ |
---|
731 | -textvariable [itcl::scope _settings($this-axis-min)] |
---|
732 | bind $page.min <KeyPress-Return> [itcl::code $this ApplyAxisSettings] |
---|
733 | |
---|
734 | label $page.max_l -text "max" -font "Arial 10" |
---|
735 | entry $page.max -width 10 \ |
---|
736 | -textvariable [itcl::scope _settings($this-axis-max)] |
---|
737 | bind $page.max <KeyPress-Return> [itcl::code $this ApplyAxisSettings] |
---|
738 | |
---|
739 | label $page.subdivisions_l -text "subdivisions" -font "Arial 10" |
---|
740 | entry $page.subdivisions \ |
---|
741 | -textvariable [itcl::scope _settings($this-axis-subdivisions)] |
---|
742 | bind $page.subdivisions <KeyPress-Return> \ |
---|
743 | [itcl::code $this ApplyAxisSettings] |
---|
744 | |
---|
745 | label $page.stepsize_l -text "step size" -font "Arial 10" |
---|
746 | entry $page.stepsize \ |
---|
747 | -textvariable [itcl::scope _settings($this-axis-stepsize)] |
---|
748 | bind $page.stepsize <KeyPress-Return> [itcl::code $this ApplyAxisSettings] |
---|
749 | |
---|
750 | checkbutton $page.loose -text "loose limits" \ |
---|
751 | -onvalue "always" -offvalue "0" \ |
---|
752 | -variable [itcl::scope _settings($this-axis-loose)] \ |
---|
753 | -command [itcl::code $this ApplyAxisSettings] |
---|
754 | |
---|
755 | label $page.plotpadx_l -text "pad x-axis" |
---|
756 | entry $page.plotpadx -width 6 \ |
---|
757 | -textvariable [itcl::scope _settings($this-axis-plotpadx)] |
---|
758 | bind $page.plotpadx <KeyPress-Return> [itcl::code $this ApplyAxisSettings] |
---|
759 | |
---|
760 | label $page.plotpady_l -text "pad y-axis" |
---|
761 | entry $page.plotpady -width 6 \ |
---|
762 | -textvariable [itcl::scope _settings($this-axis-plotpady)] |
---|
763 | bind $page.plotpady <KeyPress-Return> [itcl::code $this ApplyAxisSettings] |
---|
764 | |
---|
765 | checkbutton $page.grid -text "show grid lines" \ |
---|
766 | -variable [itcl::scope _settings($this-axis-grid)] \ |
---|
767 | -command [itcl::code $this ApplyAxisSettings] |
---|
768 | |
---|
769 | checkbutton $page.zero -text "mark zero" \ |
---|
770 | -offvalue 1 -onvalue 0 \ |
---|
771 | -variable [itcl::scope _settings($this-axis-zero)] \ |
---|
772 | -command [itcl::code $this ApplyAxisSettings] |
---|
773 | |
---|
774 | blt::table $page \ |
---|
775 | 1,0 $page.axis_l -anchor e -pady 4 \ |
---|
776 | 1,1 $page.axis -fill x -cspan 4 \ |
---|
777 | 2,1 $page.title_l -anchor e \ |
---|
778 | 2,2 $page.title -fill x -cspan 3 \ |
---|
779 | 3,1 $page.min_l -anchor e \ |
---|
780 | 3,2 $page.min -fill x \ |
---|
781 | 3,3 $page.max_l -anchor e \ |
---|
782 | 3,4 $page.max -fill both \ |
---|
783 | 5,1 $page.stepsize_l -anchor e \ |
---|
784 | 5,2 $page.stepsize -fill both \ |
---|
785 | 5,3 $page.subdivisions_l -anchor e \ |
---|
786 | 5,4 $page.subdivisions -fill both \ |
---|
787 | 6,1 $page.plotpadx_l -anchor e \ |
---|
788 | 6,2 $page.plotpadx -fill both \ |
---|
789 | 6,3 $page.plotpady_l -anchor e \ |
---|
790 | 6,4 $page.plotpady -fill both \ |
---|
791 | 7,1 $page.loose -cspan 2 -anchor w \ |
---|
792 | 7,3 $page.grid -anchor w -cspan 2 \ |
---|
793 | 8,1 $page.zero -cspan 2 -anchor w |
---|
794 | |
---|
795 | } |
---|
796 | |
---|
797 | itcl::body Rappture::XyPrint::ApplyGeneralSettings {} { |
---|
798 | RegeneratePreview |
---|
799 | } |
---|
800 | |
---|
801 | itcl::body Rappture::XyPrint::ApplyLegendSettings {} { |
---|
802 | set page $itk_component(legend_page) |
---|
803 | set _settings($this-legend-position) [$page.position current] |
---|
804 | set _settings($this-legend-anchor) [$page.anchor current] |
---|
805 | |
---|
806 | foreach option { hide position anchor borderwidth } { |
---|
807 | SetComponentOption legend $option |
---|
808 | } |
---|
809 | ApplyElementSettings |
---|
810 | } |
---|
811 | |
---|
812 | itcl::body Rappture::XyPrint::ApplyAxisSettings {} { |
---|
813 | set plotpadx [Inches2Pixels $_settings($this-axis-plotpadx)] |
---|
814 | set plotpady [Inches2Pixels $_settings($this-axis-plotpady)] |
---|
815 | SetOption plotpadx |
---|
816 | SetOption plotpady |
---|
817 | set axis [$itk_component(axis_combo) current] |
---|
818 | set type $Rappture::axistypes($axis) |
---|
819 | if { $_settings($this-axis-grid) } { |
---|
820 | $_clone grid configure -hide no -map${type} ${axis} |
---|
821 | } else { |
---|
822 | $_clone grid configure -hide no -map${type} "" |
---|
823 | } |
---|
824 | foreach option { min max loose title stepsize subdivisions } { |
---|
825 | SetNamedComponentOption axis $axis $option |
---|
826 | } |
---|
827 | $_clone marker configure ${type}-zero -hide $_settings($this-axis-zero) |
---|
828 | puts stderr "$axis: [$_clone axis configure $axis]" |
---|
829 | GetAxis |
---|
830 | RegeneratePreview |
---|
831 | } |
---|
832 | |
---|
833 | itcl::body Rappture::XyPrint::ApplyElementSettings {} { |
---|
834 | set index [$itk_component(element_slider) get] |
---|
835 | set elem $_settings($this-element-$index) |
---|
836 | set page $itk_component(legend_page) |
---|
837 | set _settings($this-element-color) [$page.color current] |
---|
838 | set _settings($this-element-symbol) [$page.symbol current] |
---|
839 | set _settings($this-element-dashes) [$page.dashes current] |
---|
840 | foreach option { symbol color dashes hide label } { |
---|
841 | SetNamedComponentOption element $elem $option |
---|
842 | } |
---|
843 | RegeneratePreview |
---|
844 | } |
---|
845 | |
---|
846 | itcl::body Rappture::XyPrint::ApplyLayoutSettings {} { |
---|
847 | foreach opt { leftmargin rightmargin topmargin bottommargin } { |
---|
848 | set new [Inches2Pixels $_settings($this-layout-$opt)] |
---|
849 | set old [$_clone cget -$opt] |
---|
850 | set code [catch [list $_clone configure -$opt $new] err] |
---|
851 | if { $code != 0 } { |
---|
852 | bell |
---|
853 | global errorInfo |
---|
854 | puts stderr "$err: $errorInfo" |
---|
855 | set _settings($this-layout-$opt) [Pixel2Inches $old] |
---|
856 | } |
---|
857 | } |
---|
858 | RegeneratePreview |
---|
859 | } |
---|
860 | |
---|
861 | |
---|
862 | itcl::body Rappture::XyPrint::InitializeSettings {} { |
---|
863 | # General settings |
---|
864 | |
---|
865 | # Always set to "eps" "ieee" |
---|
866 | set _settings($this-general-format) eps |
---|
867 | set _settings($this-general-style) ieee |
---|
868 | set _settings($this-general-remember) 1 |
---|
869 | set page $itk_component(graph_page) |
---|
870 | $page.format value [$page.format label $_settings($this-general-format)] |
---|
871 | $page.style value [$page.style label $_settings($this-general-style)] |
---|
872 | |
---|
873 | # Layout settings |
---|
874 | set _settings($this-layout-width) [Pixels2Inches [$_clone cget -width]] |
---|
875 | set _settings($this-layout-height) [Pixels2Inches [$_clone cget -height]] |
---|
876 | set _settings($this-layout-leftmargin) \ |
---|
877 | [Pixels2Inches [$_clone cget -leftmargin]] |
---|
878 | set _settings($this-layout-rightmargin) \ |
---|
879 | [Pixels2Inches [$_clone cget -rightmargin]] |
---|
880 | set _settings($this-layout-topmargin) \ |
---|
881 | [Pixels2Inches [$_clone cget -topmargin]] |
---|
882 | set _settings($this-layout-bottommargin) \ |
---|
883 | [Pixels2Inches [$_clone cget -bottommargin]] |
---|
884 | |
---|
885 | # Legend settings |
---|
886 | set page $itk_component(legend_page) |
---|
887 | |
---|
888 | set names [$_clone element show] |
---|
889 | $itk_component(element_slider) configure -from 1 -to [llength $names] |
---|
890 | if { [llength $names] < 2 } { |
---|
891 | $page.slider configure -state disabled |
---|
892 | $page.slider_l configure -state disabled |
---|
893 | } |
---|
894 | # Always initialize the slider to the first entry in the element list. |
---|
895 | $itk_component(element_slider) set 1 |
---|
896 | # Always set the borderwidth to be not displayed |
---|
897 | set _settings($this-legend-borderwidth) 0 |
---|
898 | |
---|
899 | set _settings($this-legend-hide) [$_clone legend cget -hide] |
---|
900 | set _settings($this-legend-position) [$_clone legend cget -position] |
---|
901 | set _settings($this-legend-anchor) [$_clone legend cget -anchor] |
---|
902 | $page.position value \ |
---|
903 | [$page.position label $_settings($this-legend-position)] |
---|
904 | $page.anchor value [$page.anchor label $_settings($this-legend-anchor)] |
---|
905 | GetElement |
---|
906 | |
---|
907 | # Axis settings |
---|
908 | set names [lsort [$_clone axis names]] |
---|
909 | $itk_component(axis_combo) choices delete 0 end |
---|
910 | foreach axis $names { |
---|
911 | if { ![$_clone axis cget $axis -hide] } { |
---|
912 | $itk_component(axis_combo) choices insert end $axis $axis |
---|
913 | } |
---|
914 | lappend axisnames $axis |
---|
915 | } |
---|
916 | # Always hide the zero line. |
---|
917 | set _settings($this-axis-zero) 1 |
---|
918 | |
---|
919 | # Pick the first axis to initially display |
---|
920 | set axis [lindex $axisnames 0] |
---|
921 | $itk_component(axis_combo) value $axis |
---|
922 | blt::table configure $page r* -resize none |
---|
923 | blt::table configure $page r9 -resize both |
---|
924 | set _settings($this-axis-plotpadx) [Pixels2Inches [$_clone cget -plotpadx]] |
---|
925 | set _settings($this-axis-plotpady) [Pixels2Inches [$_clone cget -plotpady]] |
---|
926 | GetAxis |
---|
927 | } |
---|
928 | |
---|
929 | |
---|
930 | itcl::body Rappture::XyPrint::RestoreSettings { file } { |
---|
931 | # Get the settings associated with the tool and plot title |
---|
932 | n} |
---|
933 | |
---|
934 | itcl::body Rappture::XyPrint::ResetSettings { file } { |
---|
935 | # Revert the widget back to the original graph's settings |
---|
936 | destroy $_clone |
---|
937 | set _clone [CloneGraph $graph] |
---|
938 | InitClone |
---|
939 | InitializeSettings |
---|
940 | } |
---|
941 | |
---|
942 | itcl::body Rappture::XyPrint::SaveSettings { file } { |
---|
943 | # Create stanza associated with tool and plot title. |
---|
944 | # General settings |
---|
945 | append out "set settings(general-format) $_settings($this-general-format)\n" |
---|
946 | append out "set settings(general-style) $_settings($this-general-style)\n" |
---|
947 | append out "set settings(general-remember) 1" |
---|
948 | |
---|
949 | # Layout settings |
---|
950 | append out "\$graph configure " |
---|
951 | foreach opt { |
---|
952 | -width -height -leftmargin -rightmargin -topmargin -bottommargin } { |
---|
953 | append out "$opt [Pixels2Inches [$_clone cget $opt]] " |
---|
954 | } |
---|
955 | append out "\n" |
---|
956 | |
---|
957 | # Legend settings |
---|
958 | append out "\$graph legend configure " |
---|
959 | foreach opt { -hide -position -anchor -borderwidth } { |
---|
960 | append out " $opt [$_clone legend cget $opt] " |
---|
961 | } |
---|
962 | append out "\n" |
---|
963 | |
---|
964 | # Element settings |
---|
965 | foreach elem [$_clone element show] { |
---|
966 | append out "if \{ \[\$graph element exists $elem\] \} \{\n" |
---|
967 | set cmd {} |
---|
968 | lappend cmd {$graph} "element" $elem |
---|
969 | lappend cmd "-symbol" [$_clone element cget $elem -symbol] |
---|
970 | lappend cmd "-color" [$_clone element cget $elem -color] |
---|
971 | lappend cmd "-dashes" [$_clone element cget $elem -dashes] |
---|
972 | lappend cmd "-hide" [$_clone element cget $elem -hide] |
---|
973 | lappend cmd "-label" [$_clone element cget $elem -label] |
---|
974 | append out " $cmd\n" |
---|
975 | append out "\}\n" |
---|
976 | } |
---|
977 | |
---|
978 | # Axis settings |
---|
979 | append out "\$graph configure " |
---|
980 | append out "-plotpadx [Pixels2Inches [$_clone cget -plotpadx]] " |
---|
981 | append out "-plotpady [Pixels2Inches [$_clone cget -plotpady]]" |
---|
982 | append out "\n" |
---|
983 | |
---|
984 | foreach axis [$_clone axis names] { |
---|
985 | append out "if \{ \[\$graph axis names \"$axis\"\] == \"$axis\" \} \{\n" |
---|
986 | set cmd {} |
---|
987 | lappend cmd {$graph} "axis" "configure" $axis |
---|
988 | foreach opt {-hide -min -max -dashes -title -stepsize -subdivisions} { |
---|
989 | lappend cmd $opt [$_clone axis cget $axis $opt] |
---|
990 | } |
---|
991 | append out "$cmd\n" |
---|
992 | append out "\}\n" |
---|
993 | set hide [$_clone marker cget ${axis}-zero -hide] |
---|
994 | append out "\$graph marker configure ${axis}-zero -hide $hide\n" |
---|
995 | } |
---|
996 | set cmd {} |
---|
997 | append out "\$graph grid configure " |
---|
998 | foreach opt { -hide -mapx -mapy } { |
---|
999 | append out " $opt [$_clone grid cget $opt] " |
---|
1000 | } |
---|
1001 | append out "\n" |
---|
1002 | append out "\}\n" |
---|
1003 | # Write the settings out |
---|
1004 | return $out |
---|
1005 | } |
---|