Changeset 1929 for trunk/gui/scripts/xyprint.tcl
- Timestamp:
- Oct 22, 2010, 4:06:10 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/xyprint.tcl
r1788 r1929 102 102 label $itk_interior.preview \ 103 103 -highlightthickness 0 -bd 0 -image $_preview -width 2.5i \ 104 104 -height 2.25i -background grey -padx 10 -pady 10 105 105 } { 106 106 ignore -background 107 107 } 108 108 itk_component add ok { 109 109 button $itk_interior.ok -text "Save" \ 110 110 -highlightthickness 0 -pady 2 -padx 0 \ 111 112 113 111 -command [itcl::code $this SetWaitVariable 1] \ 112 -compound left \ 113 -image [Rappture::icon download] 114 114 } 115 115 itk_component add cancel { 116 116 button $itk_interior.cancel -text "Cancel" \ 117 117 -highlightthickness 0 -pady 2 -padx 0 \ 118 119 120 118 -command [itcl::code $this SetWaitVariable 0] \ 119 -compound left \ 120 -image [Rappture::icon cancel] 121 121 } 122 122 blt::table $itk_interior \ 123 124 123 0,0 $itk_component(preview) -cspan 2 -fill both \ 124 1,0 $itk_component(tabs) -fill both -cspan 2 \ 125 125 2,1 $itk_component(cancel) -padx 2 -pady 2 -width .9i -fill y \ 126 126 2,0 $itk_component(ok) -padx 2 -pady 2 -width .9i -fill y 127 127 blt::table configure $itk_interior r1 -resize none 128 128 blt::table configure $itk_interior r1 -resize both … … 149 149 set _graph "" 150 150 foreach font [array names _fonts] { 151 151 font delete $font 152 152 } 153 153 array unset _fonts … … 173 173 set output "" 174 174 if { $_wait($this) } { 175 175 set output [GetOutput] 176 176 } 177 177 DestroySettings … … 185 185 186 186 if { $format == "jpg" } { 187 188 189 190 191 192 187 set img [image create photo] 188 $_clone snap $img 189 set bytes [$img data -format "jpeg -quality 100"] 190 set bytes [Rappture::encoding::decode -as b64 $bytes] 191 image delete $img 192 return [list .jpg $bytes] 193 193 } elseif { $format == "png" } { 194 195 196 197 198 199 194 set img [image create photo] 195 $_clone snap $img 196 set bytes [$img data -format "png"] 197 set bytes [Rappture::encoding::decode -as b64 $bytes] 198 image delete $img 199 return [list .png $bytes] 200 200 } 201 201 … … 207 207 208 208 $_clone postscript configure \ 209 210 211 212 209 -maxpect false \ 210 -decoration yes \ 211 -center yes \ 212 -width $w -height $h 213 213 214 214 set psdata [$_clone postscript output] 215 215 216 216 if 0 { 217 218 219 217 set f [open "junk.raw" "w"] 218 puts -nonewline $f $psdata 219 close $f 220 220 } 221 221 if { $format == "eps" } { 222 222 return [list .$format $psdata] 223 223 } 224 224 … … 226 226 # | eps2eps << $psdata 227 227 lappend cmd "|" "/usr/bin/gs" \ 228 229 230 228 "-q" "-sDEVICE=epswrite" "-sstdout=%stderr" \ 229 "-sOutputFile=-" "-dNOPAUSE" "-dBATCH" "-dSAFER" \ 230 "-dDEVICEWIDTH=250000" "-dDEVICEHEIGHT=250000" "-" "<<" "$psdata" 231 231 if { $format == "pdf" } { 232 233 234 235 236 232 # | eps2eps << $psdata | ps2pdf 233 lappend cmd "|" "/usr/bin/gs" \ 234 "-q" "-sDEVICE=pdfwrite" "-sstdout=%stderr" \ 235 "-sOutputFile=-" "-dNOPAUSE" "-dBATCH" "-dSAFER" \ 236 "-dCompatibilityLevel=1.4" "-c" ".setpdfwrite" "-f" "-" 237 237 } 238 238 if { [catch { 239 240 241 242 239 set f [open $cmd "r"] 240 fconfigure $f -translation binary -encoding binary 241 set output [read $f] 242 close $f 243 243 } err ] != 0 } { 244 245 246 244 global errorInfo 245 puts stderr "failed to generate file: $err\n$errorInfo" 246 return "" 247 247 } 248 248 if 0 { 249 250 251 252 249 set f [open "junk.$format" "w"] 250 fconfigure $f -translation binary -encoding binary 251 puts -nonewline $f $output 252 close $f 253 253 } 254 254 return [list .$format $output] … … 259 259 set configLine $clone 260 260 foreach name $exclude { 261 261 set ignore($name) 1 262 262 } 263 263 foreach arg $cmd { 264 264 lappend configLine $arg 265 265 } 266 266 foreach option $all { 267 268 269 270 271 272 273 274 275 276 277 278 279 267 if { [llength $option] != 5 } { 268 continue 269 } 270 set switch [lindex $option 0] 271 set initial [lindex $option 3] 272 set current [lindex $option 4] 273 if { [info exists ignore($switch)] } { 274 continue 275 } 276 if { [string compare $initial $current] == 0 } { 277 continue 278 } 279 lappend configLine $switch $current 280 280 } 281 281 eval $configLine … … 285 285 set top $itk_interior 286 286 if { [winfo exists $top.graph] } { 287 287 destroy $top.graph 288 288 } 289 289 set _clone [blt::graph $top.graph] … … 291 291 # Axis component 292 292 foreach axis [$orig axis names] { 293 294 295 296 297 298 299 293 if { [$orig axis cget $axis -hide] } { 294 continue 295 } 296 if { [$_clone axis name $axis] == "" } { 297 $_clone axis create $axis 298 } 299 CopyOptions [list axis configure $axis] $orig $_clone 300 300 } 301 301 foreach axis { x y x2 y2 } { 302 302 $_clone ${axis}axis use [$orig ${axis}axis use] 303 303 } 304 304 # Pen component 305 305 foreach pen [$orig pen names] { 306 307 308 309 306 if { [$_clone pen name $pen] == "" } { 307 $_clone pen create $pen 308 } 309 CopyOptions [list pen configure $pen] $orig $_clone 310 310 } 311 311 # Marker component 312 312 foreach marker [$orig marker names] { 313 314 313 $_clone marker create [$orig marker type $marker] -name $marker 314 CopyOptions [list marker configure $marker] $orig $_clone -name 315 315 } 316 316 # Element component 317 317 foreach elem [$orig element names] { 318 319 320 321 322 318 $_clone element create $elem 319 CopyOptions [list element configure $elem] $orig $_clone -data 320 if { [$_clone element cget $elem -hide] } { 321 $_clone element configure $elem -label "" 322 } 323 323 } 324 324 # Fix element display list … … 335 335 # Create markers representing lines at zero for the x and y axis. 336 336 $_clone marker create line -name x-zero \ 337 337 -coords "0 -Inf 0 Inf" -dashes 1 -hide yes 338 338 $_clone marker create line -name y-zero \ 339 339 -coords "-Inf 0 Inf 0" -dashes 1 -hide yes 340 340 } 341 341 … … 343 343 344 344 $_clone configure -width 3.4i -height 3.4i -background white \ 345 346 347 348 349 345 -borderwidth 0 \ 346 -leftmargin 0 \ 347 -rightmargin 0 \ 348 -topmargin 0 \ 349 -bottommargin 0 350 350 351 351 # Kill the title and create a border around the plot 352 352 $_clone configure \ 353 354 355 353 -title "" \ 354 -plotborderwidth 1 -plotrelief solid \ 355 -plotbackground white -plotpadx 0 -plotpady 0 356 356 # 357 357 set _settings($this-layout-width) [Pixels2Inches [$_clone cget -width]] … … 359 359 360 360 set _fonts(legend) [font create legend \ 361 361 -family helvetica -size 10 -weight normal] 362 362 update 363 363 $_clone legend configure \ 364 365 366 367 364 -position right \ 365 -font $_fonts(legend) \ 366 -hide yes -borderwidth 0 -background white -relief solid \ 367 -anchor nw -activeborderwidth 0 368 368 # 369 369 foreach axis [$_clone axis names] { 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 370 if { [$_clone axis cget $axis -hide] } { 371 continue 372 } 373 set _fonts($axis-ticks) [font create $axis-ticks \ 374 -family helvetica -size 10 \ 375 -weight normal -slant roman] 376 set _fonts($axis-title) [font create $axis-title \ 377 -family helvetica -size 10 \ 378 -weight normal -slant roman] 379 update 380 $_clone axis configure $axis -ticklength 5 \ 381 -majorticks {} -minorticks {} 382 $_clone axis configure $axis \ 383 -tickfont $_fonts($axis-ticks) \ 384 -titlefont $_fonts($axis-title) 385 385 } 386 386 foreach elem [$_clone element names] { 387 388 389 387 if { [$_clone element cget $elem -linewidth] > 1 } { 388 $_clone element configure $elem -linewidth 1 -pixels 3 389 } 390 390 } 391 391 } … … 396 396 set code [catch [list $_clone configure $opt $new] err] 397 397 if { $code != 0 } { 398 399 400 401 402 398 bell 399 global errorInfo 400 puts stderr "$err: $errorInfo" 401 set _settings($this-graph$opt) $old 402 $_clone configure $opt $old 403 403 } 404 404 } … … 409 409 set code [catch [list $_clone $comp configure $opt $new] err] 410 410 if { $code != 0 } { 411 412 413 414 415 411 bell 412 global errorInfo 413 puts stderr "$err: $errorInfo" 414 set _settings($this-$comp$opt) $old 415 $_clone $comp configure $opt $old 416 416 } 417 417 } … … 422 422 set code [catch [list $_clone $comp configure $name $opt $new] err] 423 423 if { $code != 0 } { 424 425 426 427 428 424 bell 425 global errorInfo 426 puts stderr "$err: $errorInfo" 427 set _settings($this-$comp$opt) $old 428 $_clone $comp configure $name $opt $old 429 429 } 430 430 } … … 443 443 if 0 { 444 444 if { ![winfo exists .labeltest] } { 445 446 447 445 toplevel .labeltest -bg red 446 label .labeltest.label -image $img 447 pack .labeltest.label -fill both 448 448 } 449 449 } … … 458 458 itcl::body Rappture::XyPrint::Pixels2Inches { pixels } { 459 459 if { [llength $pixels] == 2 } { 460 460 set pixels [lindex $pixels 0] 461 461 } 462 462 set pixelsPerInch [winfo pixels . 1i] … … 468 468 set n [scan $inches %g dummy] 469 469 if { $n != 1 && $defValue != "" } { 470 470 set inches $defValue 471 471 } 472 472 return [winfo pixels . ${inches}i] … … 475 475 itcl::body Rappture::XyPrint::Color2RGB { color } { 476 476 foreach { r g b } [winfo rgb $_clone $color] { 477 478 479 477 set r [expr round($r / 257.0)] 478 set g [expr round($g / 257.0)] 479 set b [expr round($b / 257.0)] 480 480 } 481 481 return [format "\#%02x%02x%02x" $r $g $b] … … 484 484 itcl::body Rappture::XyPrint::GetAxisType { axis } { 485 485 foreach type { x y x2 y2 } { 486 487 488 489 486 set axes [$_clone ${type}axis use] 487 if { [lsearch $axes $axis] >= 0 } { 488 return [string range $type 0 0] 489 } 490 490 } 491 491 return "" … … 495 495 set axis [$itk_component(axis_combo) current] 496 496 foreach option { -min -max -loose -title -stepsize -subdivisions } { 497 497 set _settings($this-axis$option) [$_clone axis cget $axis $option] 498 498 } 499 499 set type [GetAxisType $axis] 500 500 if { [$_clone grid cget -map${type}] == $axis } { 501 501 set _settings($this-axis-grid) 1 502 502 } else { 503 503 set _settings($this-axis-grid) 0 504 504 } 505 505 set _settings($this-axis-plotpad${type}) \ 506 506 [Pixels2Inches [$_clone cget -plotpad${type}]] 507 507 set _settings($this-axis-zero) [$_clone marker cget ${type}-zero -hide] 508 508 } … … 512 512 array unset _settings $this-element-* 513 513 foreach elem [$_clone element show] { 514 515 514 set _settings($this-element-$index) $elem 515 incr index 516 516 } 517 517 set index [$itk_component(element_slider) get] … … 524 524 set color [$page.color label $_settings($this-element-color)] 525 525 if { $color == "" } { 526 527 528 526 set color [Color2RGB $_settings($this-element-color)] 527 $page.color choices insert end $color $color 528 $page.color value $color 529 529 } else { 530 530 $page.color value [$page.color label $_settings($this-element-color)] 531 531 } 532 532 $page.symbol value [$page.symbol label $_settings($this-element-symbol)] … … 537 537 itcl::body Rappture::XyPrint::BuildLayoutTab {} { 538 538 itk_component add layout_page { 539 539 frame $itk_component(tabs).layout_page 540 540 } 541 541 set page $itk_component(layout_page) … … 545 545 label $page.width_l -text "width" 546 546 entry $page.width -width 6 \ 547 547 -textvariable [itcl::scope _settings($this-layout-width)] 548 548 bind $page.width <KeyPress-Return> [itcl::code $this ApplyLayoutSettings] 549 549 Rappture::Tooltip::for $page.width \ … … 552 552 label $page.height_l -text "height" 553 553 entry $page.height -width 6 \ 554 554 -textvariable [itcl::scope _settings($this-layout-height)] 555 555 bind $page.height <KeyPress-Return> [itcl::code $this ApplyLayoutSettings] 556 556 Rappture::Tooltip::for $page.height \ … … 561 561 label $page.left_l -text "left" 562 562 entry $page.left -width 6 \ 563 563 -textvariable [itcl::scope _settings($this-layout-leftmargin)] 564 564 bind $page.left <KeyPress-Return> [itcl::code $this ApplyLayoutSettings] 565 565 Rappture::Tooltip::for $page.left \ … … 568 568 label $page.right_l -text "right" 569 569 entry $page.right -width 6 \ 570 570 -textvariable [itcl::scope _settings($this-layout-rightmargin)] 571 571 bind $page.right <KeyPress-Return> [itcl::code $this ApplyLayoutSettings] 572 572 Rappture::Tooltip::for $page.right \ … … 576 576 label $page.top_l -text "top" 577 577 entry $page.top -width 6 \ 578 578 -textvariable [itcl::scope _settings($this-layout-topmargin)] 579 579 bind $page.top <KeyPress-Return> [itcl::code $this ApplyLayoutSettings] 580 580 Rappture::Tooltip::for $page.top \ … … 583 583 label $page.bottom_l -text "bottom" 584 584 entry $page.bottom -width 6 \ 585 585 -textvariable [itcl::scope _settings($this-layout-bottommargin)] 586 586 bind $page.bottom <KeyPress-Return> [itcl::code $this ApplyLayoutSettings] 587 587 Rappture::Tooltip::for $page.bottom \ … … 591 591 label $page.map -image [Rappture::icon graphmargins] 592 592 blt::table $page \ 593 594 595 596 597 598 599 600 601 602 603 604 605 593 0,0 $page.width_l -anchor e \ 594 0,1 $page.width -fill x \ 595 1,0 $page.height_l -anchor e \ 596 1,1 $page.height -fill x \ 597 3,0 $page.left_l -anchor e \ 598 3,1 $page.left -fill x \ 599 4,0 $page.right_l -anchor e \ 600 4,1 $page.right -fill x \ 601 5,0 $page.top_l -anchor e \ 602 5,1 $page.top -fill x \ 603 6,0 $page.bottom_l -anchor e \ 604 6,1 $page.bottom -fill x \ 605 0,2 $page.map -fill both -rspan 7 -padx 2 606 606 607 607 blt::table configure $page c0 r* -resize none … … 612 612 itcl::body Rappture::XyPrint::BuildGeneralTab {} { 613 613 itk_component add graph_page { 614 614 frame $itk_component(tabs).graph_page 615 615 } 616 616 set page $itk_component(graph_page) … … 621 621 Rappture::Combobox $page.format -width 30 -editable no 622 622 $page.format choices insert end \ 623 624 625 626 627 623 "pdf" "PDF Portable Document Format" \ 624 "ps" "PS PostScript Format" \ 625 "eps" "EPS Encapsulated PostScript" \ 626 "jpg" "JPEG Joint Photographic Experts Group Format" \ 627 "png" "PNG Portable Network Graphics Format" 628 628 629 629 bind $page.format <<Value>> [itcl::code $this ApplyGeneralSettings] … … 634 634 Rappture::Combobox $page.style -width 20 -editable no 635 635 $page.style choices insert end \ 636 637 636 "ieee" "IEEE Journal" \ 637 "gekco" "G Klimeck" 638 638 bind $page.style <<Value>> [itcl::code $this ApplyGeneralSettings] 639 639 Rappture::Tooltip::for $page.format \ … … 641 641 642 642 checkbutton $page.remember -text "remember settings" \ 643 643 -variable [itcl::scope _settings($this-general-remember)] 644 644 Rappture::Tooltip::for $page.remember \ 645 645 "Remember the settings. They will be override the default settings." 646 646 647 647 button $page.revert -text "revert" -image [Rappture::icon revert] \ 648 649 648 -compound left -padx 3 -pady 1 -overrelief raised -relief flat \ 649 -command [itcl::code $this ResetSettings] 650 650 Rappture::Tooltip::for $page.revert \ 651 651 "Revert to the default settings." 652 652 653 653 blt::table $page \ 654 655 656 657 658 659 654 2,0 $page.format_l -anchor e \ 655 2,1 $page.format -fill x -cspan 2 \ 656 3,0 $page.style_l -anchor e \ 657 3,1 $page.style -fill x -cspan 2 \ 658 5,0 $page.remember -cspan 2 -anchor w \ 659 5,2 $page.revert -anchor e 660 660 blt::table configure $page r* -resize none -pady { 0 2 } 661 661 blt::table configure $page r4 -resize both … … 668 668 set _settings($this-legend-anchor) [$page.anchor current] 669 669 foreach option { -hide -position -anchor -borderwidth } { 670 670 SetComponentOption legend $option 671 671 } 672 672 $_clone legend configure -font legend … … 676 676 itcl::body Rappture::XyPrint::BuildLegendTab {} { 677 677 itk_component add legend_page { 678 678 frame $itk_component(tabs).legend_page 679 679 } 680 680 set page $itk_component(legend_page) … … 683 683 684 684 checkbutton $page.show -text "show legend" \ 685 686 687 685 -offvalue 1 -onvalue 0 \ 686 -variable [itcl::scope _settings($this-legend-hide)] \ 687 -command [itcl::code $this ApplyLegendSettings] 688 688 Rappture::Tooltip::for $page.show \ 689 689 "Display the legend." … … 692 692 Rappture::Combobox $page.position -width 15 -editable no 693 693 $page.position choices insert end \ 694 695 696 697 698 694 "leftmargin" "left margin" \ 695 "rightmargin" "right margin" \ 696 "bottommargin" "bottom margin" \ 697 "topmargin" "top margin" \ 698 "plotarea" "inside plot" 699 699 bind $page.position <<Value>> [itcl::code $this ApplyLegendSettings] 700 700 Rappture::Tooltip::for $page.position \ … … 703 703 Rappture::Combobox $page.anchor -width 10 -editable no 704 704 $page.anchor choices insert end \ 705 706 707 708 709 710 711 712 713 705 "nw" "northwest" \ 706 "n" "north" \ 707 "ne" "northeast" \ 708 "sw" "southwest" \ 709 "s" "south" \ 710 "se" "southeast" \ 711 "c" "center" \ 712 "e" "east" \ 713 "w" "west" 714 714 bind $page.anchor <<Value>> [itcl::code $this ApplyLegendSettings] 715 715 Rappture::Tooltip::for $page.anchor \ … … 717 717 718 718 checkbutton $page.border -text "border" \ 719 720 721 719 -variable [itcl::scope _settings($this-legend-borderwidth)] \ 720 -onvalue 1 -offvalue 0 \ 721 -command [itcl::code $this ApplyLegendSettings] 722 722 Rappture::Tooltip::for $page.border \ 723 723 "Display a solid border around the legend." … … 725 725 label $page.slider_l -text "legend\nentry" -justify right 726 726 itk_component add element_slider { 727 728 729 727 ::scale $page.slider -from 1 -to 1 \ 728 -orient horizontal -width 12 \ 729 -command [itcl::code $this GetElement] 730 730 } 731 731 Rappture::Tooltip::for $page.slider \ … … 734 734 label $page.label_l -text "label" 735 735 entry $page.label \ 736 737 736 -background white \ 737 -textvariable [itcl::scope _settings($this-element-label)] 738 738 bind $page.label <KeyPress-Return> [itcl::code $this ApplyElementSettings] 739 739 Rappture::Tooltip::for $page.label \ … … 743 743 Rappture::Combobox $page.color -width 15 -editable no 744 744 $page.color choices insert end \ 745 746 747 748 749 750 745 "#000000" "black" \ 746 "#ffffff" "white" \ 747 "#0000cd" "blue" \ 748 "#cd0000" "red" \ 749 "#00cd00" "green" \ 750 "#3a5fcd" "royal blue" \ 751 751 "#cdcd00" "yellow" \ 752 752 "#cd1076" "deep pink" \ 753 753 "#009acd" "deep sky blue" \ 754 754 "#00c5cd" "torquise" \ 755 755 "#a2b5cd" "light steel blue" \ 756 757 758 756 "#7ac5cd" "cadet blue" \ 757 "#66cdaa" "aquamarine" \ 758 "#a2cd5a" "dark olive green" \ 759 759 "#cd9b9b" "rosy brown" \ 760 761 762 760 "#0000ff" "blue1" \ 761 "#ff0000" "red1" \ 762 "#00ff00" "green1" 763 763 bind $page.color <<Value>> [itcl::code $this ApplyElementSettings] 764 764 Rappture::Tooltip::for $page.color \ … … 768 768 Rappture::Combobox $page.dashes -width 15 -editable no 769 769 $page.dashes choices insert end \ 770 770 "" "solid" \ 771 771 "1" "dot" \ 772 772 "5 2" "dash" \ … … 780 780 Rappture::Combobox $page.symbol -editable no 781 781 $page.symbol choices insert end \ 782 783 784 785 786 787 788 789 790 782 "none" "none" \ 783 "square" "square" \ 784 "circle" "circle" \ 785 "diamond" "diamond" \ 786 "plus" "plus" \ 787 "cross" "cross" \ 788 "splus" "skinny plus" \ 789 "scross" "skinny cross" \ 790 "triangle" "triangle" 791 791 bind $page.symbol <<Value>> [itcl::code $this ApplyElementSettings] 792 792 Rappture::Tooltip::for $page.symbol \ … … 796 796 Rappture::Combobox $page.fontfamily -width 10 -editable no 797 797 $page.fontfamily choices insert end \ 798 799 800 801 802 798 "courier" "courier" \ 799 "helvetica" "helvetica" \ 800 "new*century*schoolbook" "new century schoolbook" \ 801 "symbol" "symbol" \ 802 "times" "times" 803 803 bind $page.fontfamily <<Value>> [itcl::code $this ApplyLegendSettings] 804 804 Rappture::Tooltip::for $page.fontfamily \ … … 807 807 Rappture::Combobox $page.fontsize -width 4 -editable no 808 808 $page.fontsize choices insert end \ 809 810 811 812 813 814 815 816 817 809 "8" "8" \ 810 "9" "9" \ 811 "10" "10" \ 812 "11" "11" \ 813 "12" "12" \ 814 "14" "14" \ 815 "17" "17" \ 816 "18" "18" \ 817 "20" "20" 818 818 bind $page.fontsize <<Value>> [itcl::code $this ApplyLegendSettings] 819 819 Rappture::Tooltip::for $page.fontsize \ … … 821 821 822 822 Rappture::PushButton $page.fontweight \ 823 824 825 826 827 828 823 -width 18 -height 18 \ 824 -onimage [Rappture::icon font-bold] \ 825 -offimage [Rappture::icon font-bold] \ 826 -onvalue "bold" -offvalue "normal" \ 827 -command [itcl::code $this ApplyLegendSettings] \ 828 -variable [itcl::scope _settings($this-legend-font-weight)] 829 829 Rappture::Tooltip::for $page.fontweight \ 830 830 "Use the bold version of the font." 831 831 832 832 Rappture::PushButton $page.fontslant \ 833 834 835 836 837 838 833 -width 18 -height 18 \ 834 -onimage [Rappture::icon font-italic] \ 835 -offimage [Rappture::icon font-italic] \ 836 -onvalue "italic" -offvalue "roman" \ 837 -command [itcl::code $this ApplyLegendSettings] \ 838 -variable [itcl::scope _settings($this-legend-font-slant)] 839 839 Rappture::Tooltip::for $page.fontslant \ 840 840 "Use the italic version of the font." 841 841 842 842 blt::table $page \ 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 843 1,0 $page.show -cspan 2 -anchor w \ 844 1,2 $page.border -cspan 2 -anchor w \ 845 2,0 $page.position_l -anchor e \ 846 2,1 $page.position -fill x \ 847 2,2 $page.anchor -fill x -cspan 3 \ 848 3,0 $page.font_l -anchor e \ 849 3,1 $page.fontfamily -fill x \ 850 3,2 $page.fontsize -fill x \ 851 3,3 $page.fontweight -anchor e \ 852 3,4 $page.fontslant -anchor e \ 853 4,0 $page.slider_l -anchor e \ 854 4,1 $page.slider -fill x -cspan 5 \ 855 5,0 $page.label_l -anchor e \ 856 5,1 $page.label -fill x -cspan 5 \ 857 6,0 $page.color_l -anchor e \ 858 6,1 $page.color -fill x \ 859 6,2 $page.symbol_l -anchor e \ 860 6,3 $page.symbol -fill both -cspan 3 \ 861 7,0 $page.dashes_l -anchor e \ 862 7,1 $page.dashes -fill x \ 863 863 864 864 blt::table configure $page r* -resize none -pady { 0 2 } … … 869 869 itcl::body Rappture::XyPrint::BuildAxisTab {} { 870 870 itk_component add axis_page { 871 871 frame $itk_component(tabs).axis_page 872 872 } 873 873 set page $itk_component(axis_page) … … 877 877 label $page.axis_l -text "axis" 878 878 itk_component add axis_combo { 879 879 Rappture::Combobox $page.axis -width 20 -editable no 880 880 } 881 881 bind $itk_component(axis_combo) <<Value>> [itcl::code $this GetAxis] … … 885 885 label $page.title_l -text "title" 886 886 entry $page.title \ 887 887 -textvariable [itcl::scope _settings($this-axis-title)] 888 888 bind $page.title <KeyPress-Return> [itcl::code $this ApplyAxisSettings] 889 889 Rappture::Tooltip::for $page.title \ … … 892 892 label $page.min_l -text "min" 893 893 entry $page.min -width 10 \ 894 894 -textvariable [itcl::scope _settings($this-axis-min)] 895 895 bind $page.min <KeyPress-Return> [itcl::code $this ApplyAxisSettings] 896 896 Rappture::Tooltip::for $page.min \ … … 899 899 label $page.max_l -text "max" 900 900 entry $page.max -width 10 \ 901 901 -textvariable [itcl::scope _settings($this-axis-max)] 902 902 bind $page.max <KeyPress-Return> [itcl::code $this ApplyAxisSettings] 903 903 Rappture::Tooltip::for $page.max \ … … 906 906 label $page.subdivisions_l -text "subdivisions" 907 907 entry $page.subdivisions \ 908 908 -textvariable [itcl::scope _settings($this-axis-subdivisions)] 909 909 bind $page.subdivisions <KeyPress-Return> \ 910 910 [itcl::code $this ApplyAxisSettings] 911 911 Rappture::Tooltip::for $page.subdivisions \ 912 912 "Set the number of subdivisions (minor ticks) for the current axis." … … 914 914 label $page.stepsize_l -text "step size" 915 915 entry $page.stepsize \ 916 916 -textvariable [itcl::scope _settings($this-axis-stepsize)] 917 917 bind $page.stepsize <KeyPress-Return> [itcl::code $this ApplyAxisSettings] 918 918 Rappture::Tooltip::for $page.stepsize \ … … 920 920 921 921 checkbutton $page.loose -text "loose limits" \ 922 923 924 922 -onvalue "always" -offvalue "0" \ 923 -variable [itcl::scope _settings($this-axis-loose)] \ 924 -command [itcl::code $this ApplyAxisSettings] 925 925 Rappture::Tooltip::for $page.loose \ 926 926 "Set major ticks outside of the limits for the current axis." … … 928 928 label $page.plotpad_l -text "pad" 929 929 entry $page.plotpad -width 6 \ 930 930 -textvariable [itcl::scope _settings($this-axis-plotpad)] 931 931 bind $page.plotpad <KeyPress-Return> [itcl::code $this ApplyAxisSettings] 932 932 Rappture::Tooltip::for $page.plotpad \ … … 934 934 935 935 checkbutton $page.grid -text "show grid lines" \ 936 937 936 -variable [itcl::scope _settings($this-axis-grid)] \ 937 -command [itcl::code $this ApplyAxisSettings] 938 938 Rappture::Tooltip::for $page.grid \ 939 939 "Display grid lines for the current axis." 940 940 941 941 checkbutton $page.zero -text "mark zero" \ 942 943 944 942 -offvalue 1 -onvalue 0 \ 943 -variable [itcl::scope _settings($this-axis-zero)] \ 944 -command [itcl::code $this ApplyAxisSettings] 945 945 Rappture::Tooltip::for $page.zero \ 946 946 "Display a line at zero for the current axis." … … 949 949 Rappture::Combobox $page.tickfontfamily -width 10 -editable no 950 950 $page.tickfontfamily choices insert end \ 951 952 953 954 955 951 "courier" "courier" \ 952 "helvetica" "helvetica" \ 953 "new*century*schoolbook" "new century schoolbook" \ 954 "symbol" "symbol" \ 955 "times" "times" 956 956 bind $page.tickfontfamily <<Value>> [itcl::code $this ApplyAxisSettings] 957 957 Rappture::Tooltip::for $page.tickfontfamily \ … … 960 960 Rappture::Combobox $page.tickfontsize -width 4 -editable no 961 961 $page.tickfontsize choices insert end \ 962 963 964 965 966 967 968 969 970 962 "8" "8" \ 963 "9" "9" \ 964 "10" "10" \ 965 "11" "11" \ 966 "12" "12" \ 967 "14" "14" \ 968 "17" "17" \ 969 "18" "18" \ 970 "20" "20" 971 971 bind $page.tickfontsize <<Value>> [itcl::code $this ApplyAxisSettings] 972 972 Rappture::Tooltip::for $page.tickfontsize \ … … 974 974 975 975 Rappture::PushButton $page.tickfontweight \ 976 977 978 979 980 981 976 -width 18 -height 18 \ 977 -onimage [Rappture::icon font-bold] \ 978 -offimage [Rappture::icon font-bold] \ 979 -onvalue "bold" -offvalue "normal" \ 980 -command [itcl::code $this ApplyAxisSettings] \ 981 -variable [itcl::scope _settings($this-axis-tickfont-weight)] 982 982 Rappture::Tooltip::for $page.tickfontweight \ 983 983 "Use the bold version of the tick font." 984 984 985 985 Rappture::PushButton $page.tickfontslant \ 986 987 988 989 990 991 986 -width 18 -height 18 \ 987 -onimage [Rappture::icon font-italic] \ 988 -offimage [Rappture::icon font-italic] \ 989 -onvalue "italic" -offvalue "roman" \ 990 -command [itcl::code $this ApplyAxisSettings] \ 991 -variable [itcl::scope _settings($this-axis-tickfont-slant)] 992 992 Rappture::Tooltip::for $page.tickfontslant \ 993 993 "Use the italic version of the tick font." … … 996 996 Rappture::Combobox $page.titlefontfamily -width 10 -editable no 997 997 $page.titlefontfamily choices insert end \ 998 999 1000 1001 1002 998 "courier" "courier" \ 999 "helvetica" "helvetica" \ 1000 "new*century*schoolbook" "new century schoolbook" \ 1001 "symbol" "symbol" \ 1002 "times" "times" 1003 1003 bind $page.titlefontfamily <<Value>> [itcl::code $this ApplyAxisSettings] 1004 1004 Rappture::Tooltip::for $page.titlefontfamily \ … … 1007 1007 Rappture::Combobox $page.titlefontsize -width 4 -editable no 1008 1008 $page.titlefontsize choices insert end \ 1009 1010 1011 1012 1013 1014 1015 1016 1017 1009 "8" "8" \ 1010 "9" "9" \ 1011 "10" "10" \ 1012 "11" "11" \ 1013 "12" "12" \ 1014 "14" "14" \ 1015 "17" "17" \ 1016 "18" "18" \ 1017 "20" "20" 1018 1018 bind $page.titlefontsize <<Value>> [itcl::code $this ApplyAxisSettings] 1019 1019 Rappture::Tooltip::for $page.titlefontsize \ … … 1021 1021 1022 1022 Rappture::PushButton $page.titlefontweight \ 1023 1024 1025 1026 1027 1028 1023 -width 18 -height 18 \ 1024 -onimage [Rappture::icon font-bold] \ 1025 -offimage [Rappture::icon font-bold] \ 1026 -onvalue "bold" -offvalue "normal" \ 1027 -command [itcl::code $this ApplyAxisSettings] \ 1028 -variable [itcl::scope _settings($this-axis-titlefont-weight)] 1029 1029 Rappture::Tooltip::for $page.titlefontweight \ 1030 1030 "Use the bold version of the title font." 1031 1031 1032 1032 Rappture::PushButton $page.titlefontslant \ 1033 1034 1035 1036 1037 1038 1033 -width 18 -height 18 \ 1034 -onimage [Rappture::icon font-italic] \ 1035 -offimage [Rappture::icon font-italic] \ 1036 -onvalue "italic" -offvalue "roman" \ 1037 -command [itcl::code $this ApplyAxisSettings] \ 1038 -variable [itcl::scope _settings($this-axis-titlefont-slant)] 1039 1039 Rappture::Tooltip::for $page.titlefontslant \ 1040 1040 "Use the italic version of the title font." 1041 1041 1042 1042 blt::table $page \ 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1043 1,1 $page.axis_l -anchor e -pady 6 \ 1044 1,2 $page.axis -fill x -cspan 6 \ 1045 2,1 $page.title_l -anchor e \ 1046 2,2 $page.title -fill x -cspan 5 \ 1047 3,1 $page.min_l -anchor e \ 1048 3,2 $page.min -fill x \ 1049 3,3 $page.stepsize_l -anchor e \ 1050 3,4 $page.stepsize -fill both -cspan 3 \ 1051 4,1 $page.max_l -anchor e \ 1052 4,2 $page.max -fill both \ 1053 4,3 $page.subdivisions_l -anchor e \ 1054 4,4 $page.subdivisions -fill both -cspan 3 \ 1055 5,1 $page.titlefont_l -anchor e \ 1056 5,2 $page.titlefontfamily -fill x -cspan 2 \ 1057 5,4 $page.titlefontsize -fill x \ 1058 5,5 $page.titlefontweight -anchor e \ 1059 5,6 $page.titlefontslant -anchor e \ 1060 6,1 $page.tickfont_l -anchor e \ 1061 6,2 $page.tickfontfamily -fill x -cspan 2 \ 1062 6,4 $page.tickfontsize -fill x \ 1063 6,5 $page.tickfontweight -anchor e \ 1064 6,6 $page.tickfontslant -anchor e \ 1065 7,1 $page.loose -cspan 2 -anchor w \ 1066 7,3 $page.grid -anchor w -cspan 2 \ 1067 8,1 $page.zero -cspan 2 -anchor w \ 1068 8,3 $page.plotpad_l -anchor e \ 1069 8,4 $page.plotpad -fill both -cspan 3 1070 1070 1071 1071 blt::table configure $page c0 c7 c8 -resize none … … 1082 1082 1083 1083 foreach option { -hide -position -anchor -borderwidth } { 1084 1084 SetComponentOption legend $option 1085 1085 } 1086 1086 font configure $_fonts(legend) \ 1087 1088 1089 1090 1087 -family [$page.fontfamily current] \ 1088 -size [$page.fontsize current] \ 1089 -weight $_settings($this-legend-font-weight) \ 1090 -slant $_settings($this-legend-font-slant) 1091 1091 $_clone legend configure -font fixed -font $_fonts(legend) 1092 1092 ApplyElementSettings … … 1098 1098 set page $itk_component(axis_page) 1099 1099 if { $_settings($this-axis-grid) } { 1100 1100 $_clone grid configure -hide no -map${type} ${axis} 1101 1101 } else { 1102 1102 $_clone grid configure -hide no -map${type} "" 1103 1103 } 1104 1104 $_clone configure -plotpad${type} $_settings($this-axis-plotpad) 1105 1105 foreach option { -min -max -loose -title -stepsize -subdivisions } { 1106 1106 SetNamedComponentOption axis $axis $option 1107 1107 } 1108 1108 $_clone marker configure ${type}-zero -hide $_settings($this-axis-zero) 1109 1109 font configure $axis-title \ 1110 1111 1112 1113 1110 -family [$page.titlefontfamily current] \ 1111 -size [$page.titlefontsize current] \ 1112 -weight $_settings($this-axis-titlefont-weight) \ 1113 -slant $_settings($this-axis-titlefont-slant) 1114 1114 font configure $axis-ticks \ 1115 1116 1117 1118 1115 -family [$page.tickfontfamily current] \ 1116 -size [$page.tickfontsize current] \ 1117 -weight $_settings($this-axis-tickfont-weight) \ 1118 -slant $_settings($this-axis-tickfont-slant) 1119 1119 $_clone axis configure $axis -tickfont $axis-ticks -titlefont $axis-title 1120 1120 GetAxis … … 1130 1130 set _settings($this-element-dashes) [$page.dashes current] 1131 1131 foreach option { -symbol -color -dashes -label } { 1132 1132 SetNamedComponentOption element $elem $option 1133 1133 } 1134 1134 RegeneratePreview … … 1142 1142 itcl::body Rappture::XyPrint::ApplyLayoutSettings {} { 1143 1143 foreach opt { -width -height -leftmargin -rightmargin -topmargin 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1144 -bottommargin } { 1145 set old [$_clone cget $opt] 1146 set code [catch { SetLayoutOption $opt } err] 1147 if { $code != 0 } { 1148 bell 1149 global errorInfo 1150 puts stderr "$err: $errorInfo" 1151 set _settings($this-layout$opt) [Pixels2Inches $old] 1152 $_clone configure $opt [Pixels2Inches $old] 1153 } 1154 1154 } 1155 1155 RegeneratePreview … … 1172 1172 set _settings($this-layout-height) [Pixels2Inches [$_clone cget -height]] 1173 1173 set _settings($this-layout-leftmargin) \ 1174 1174 [Pixels2Inches [$_clone cget -leftmargin]] 1175 1175 set _settings($this-layout-rightmargin) \ 1176 1176 [Pixels2Inches [$_clone cget -rightmargin]] 1177 1177 set _settings($this-layout-topmargin) \ 1178 1178 [Pixels2Inches [$_clone cget -topmargin]] 1179 1179 set _settings($this-layout-bottommargin) \ 1180 1180 [Pixels2Inches [$_clone cget -bottommargin]] 1181 1181 1182 1182 # Legend settings … … 1200 1200 set _settings($this-legend-font-slant) $info(-slant) 1201 1201 if { $info(-weight) == "bold" } { 1202 1202 set _settings($this-legend-font-bold) 1 1203 1203 } 1204 1204 set _settings($this-legend-hide) [$_clone legend cget -hide] … … 1206 1206 set _settings($this-legend-anchor) [$_clone legend cget -anchor] 1207 1207 $page.position value \ 1208 1208 [$page.position label $_settings($this-legend-position)] 1209 1209 $page.anchor value [$page.anchor label $_settings($this-legend-anchor)] 1210 1210 GetElement … … 1215 1215 $itk_component(axis_combo) choices delete 0 end 1216 1216 foreach axis $names { 1217 1218 1219 1220 1217 if { ![$_clone axis cget $axis -hide] } { 1218 $itk_component(axis_combo) choices insert end $axis $axis 1219 } 1220 lappend axisnames $axis 1221 1221 } 1222 1222 set axis [lindex $names 0] … … 1251 1251 itcl::body Rappture::XyPrint::RestoreSettings { toolName plotName } { 1252 1252 if { ![file readable $_settingsFile] } { 1253 1253 return; # No file or not readable 1254 1254 } 1255 1255 if { [file exists $_oldSettingsFile] } { 1256 1256 file delete $_oldSettingsFile 1257 1257 } 1258 1258 # Read the file by sourcing it into a safe interpreter The only commands … … 1271 1271 set key [list $toolName $plotName] 1272 1272 if { [info exists _savedSettings($key)] } { 1273 1274 1273 $parser alias "preview" $_clone 1274 $parser eval $_savedSettings($key) 1275 1275 } 1276 1276 foreach {name value} [$parser eval "array get general"] { 1277 1277 set _settings($this-graph-$name) $value 1278 1278 } 1279 1279 interp delete $parser … … 1291 1291 itcl::body Rappture::XyPrint::SaveSettings { toolName plotName } { 1292 1292 if { !$_settings($this-general-remember) } { 1293 1293 return 1294 1294 } 1295 1295 if { [catch { open $_settingsFile "w" 0600 } f ] != 0 } { 1296 1297 1298 1296 puts stderr "$_settingsFile isn't writable: $f" 1297 bell 1298 return 1299 1299 } 1300 1300 set key [list $toolName $plotName] … … 1302 1302 # Write the settings out 1303 1303 foreach key [lsort [array names _savedSettings]] { 1304 1305 1306 1307 1308 1309 1304 set tool [lindex $key 0] 1305 set plot [lindex $key 1] 1306 puts $f "xyprint \"$tool\" \"$plot\" \{" 1307 set settings [string trim $_savedSettings($key) \n] 1308 puts $f "$settings" 1309 puts $f "\}\n" 1310 1310 } 1311 1311 close $f … … 1319 1319 1320 1320 foreach font [array names _fonts] { 1321 1322 1323 1324 1325 1326 1327 1328 1321 append out " font configure $font" 1322 array unset info 1323 array set info [font configure $font] 1324 foreach opt { -family -size -weight -slant } { 1325 set value [list $info($opt)] 1326 append out " $opt $value" 1327 } 1328 append out "\n" 1329 1329 } 1330 1330 append out "\n" … … 1333 1333 append out " preview configure" 1334 1334 foreach opt { -width -height -leftmargin -rightmargin -topmargin 1335 1336 1337 1335 -bottommargin -plotpadx -plotpady } { 1336 set value [list [$_clone cget $opt]] 1337 append out " $opt $value" 1338 1338 } 1339 1339 append out "\n" … … 1342 1342 append out " preview legend configure" 1343 1343 foreach opt { -position -anchor -borderwidth -hide } { 1344 1345 1344 set value [list [$_clone legend cget $opt]] 1345 append out " $opt $value" 1346 1346 } 1347 1347 append out " -font legend\n" … … 1349 1349 # Element settings 1350 1350 foreach elem [$_clone element show] { 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1351 set label [$_clone element cget $elem -label] 1352 if { $label == "" } { 1353 continue 1354 } 1355 append out " if \{ \[preview element exists \"$label\"\] \} \{\n" 1356 append out " preview element configure \"$label\"" 1357 foreach opt { -symbol -color -dashes -label } { 1358 set value [list [$_clone element cget $elem $opt]] 1359 append out " $opt $value" 1360 } 1361 append out " \}\n" 1362 1362 } 1363 1363 1364 1364 # Axis settings 1365 1365 foreach axis [$_clone axis names] { 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1366 if { [$_clone axis cget $axis -hide] } { 1367 continue 1368 } 1369 append out " if \{ \[preview axis names \"$axis\"\] == \"$axis\" \} \{\n" 1370 append out " preview axis configure \"$axis\"" 1371 foreach opt { -hide -min -max -loose -title -stepsize -subdivisions } { 1372 set value [list [$_clone axis cget $axis $opt]] 1373 append out " $opt $value" 1374 } 1375 append out " -tickfont \"$axis-ticks\"" 1376 append out " -titlefont \"$axis-title\"\n" 1377 set hide [$_clone marker cget ${axis}-zero -hide] 1378 append out " preview marker configure \"${axis}-zero\" -hide $hide\n" 1379 append out " \}\n" 1380 1380 } 1381 1381
Note: See TracChangeset
for help on using the changeset viewer.