Changeset 3102
- Timestamp:
- Jul 17, 2012 7:02:05 AM (12 years ago)
- Location:
- branches/blt4
- Files:
-
- 3 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/blt4/examples/zoo/drawing/tool.xml
r2966 r3102 87 87 <dash>4 2</dash> 88 88 </grid> 89 <string>90 <about>91 <label>String:</label>92 </about>93 <coords>.1 1.1</coords>94 <color>blue</color>95 <font>Arial 9</font>96 <anchor>nw</anchor>97 <default>value</default>98 </string>99 <number>100 <about>101 <label>Number:</label>102 </about>103 <coords></coords>104 <color>blue</color>105 <font>Arial 12</font>106 <anchor>n</anchor>107 <default></default>108 <min></min>109 <max></max>110 </number>111 89 </components> 112 90 </drawing> -
branches/blt4/gui/scripts/Makefile.in
r3029 r3102 30 30 $(srcdir)/color.tcl \ 31 31 $(srcdir)/combobox.tcl \ 32 $(srcdir)/combochecks.tcl \ 32 33 $(srcdir)/contourresult.tcl \ 33 34 $(srcdir)/controlOwner.tcl \ … … 43 44 $(srcdir)/dispatcher.tcl \ 44 45 $(srcdir)/drawing.tcl \ 45 $(srcdir)/drawingentry.tcl \46 46 $(srcdir)/drawingcontrols.tcl \ 47 47 $(srcdir)/drawingentry.tcl \ 48 48 $(srcdir)/dropdown.tcl \ 49 $(srcdir)/dropdownchecks.tcl \ 49 50 $(srcdir)/dropdownlist.tcl \ 50 51 $(srcdir)/editor.tcl \ -
branches/blt4/gui/scripts/controls.tcl
r3025 r3102 522 522 set _name2info($name-label) $label 523 523 524 $_tabs insert end $ label -fill both524 $_tabs insert end $name -text $label -fill both 525 525 incr gn 526 526 } -
branches/blt4/gui/scripts/drawingentry.tcl
r3000 r3102 27 27 private variable _drawingWidth 0 28 28 private variable _owner 29 private variable _parser "" 29 private variable _parser ""; # Slave interpreter where all 30 # substituted variables are stored. 30 31 private variable _path 31 32 private variable _showing "" … … 40 41 private variable _cursor "" 41 42 42 constructor {owner path args} { # defined below } 43 43 constructor {owner path args} { 44 # defined below 45 } 46 destructor { 47 # defined below 48 } 44 49 public method value { args } 45 50 public method label {} … … 48 53 private method Activate { tag } 49 54 private method AdjustDrawingArea { xAspect yAspect } 55 private method ControlValue {path {units ""}} 50 56 private method Deactivate { tag } 51 57 private method Highlight { tag } … … 69 75 private method ScreenY { y } 70 76 private method XmlGet { path } 71 private method Withdraw {} 77 private method XmlGetSubst { path } 78 private method Withdraw { cname } 79 private method Hotspot { option cname item args } 80 private method IsEnabled { path } 81 private method NumControlsEnabled { cname } 72 82 } 73 83 … … 99 109 pack $itk_component(drawing) -expand yes -fill both 100 110 bind $itk_component(drawing) <Configure> [itcl::code $this Redraw] 111 set _parser [interp create -safe] 101 112 Redraw 102 113 eval itk_initialize $args 103 114 } 104 115 116 itcl::body Rappture::DrawingEntry::destructor {} { 117 if { $_parser != "" } { 118 $_parser delete 119 } 120 } 105 121 # ---------------------------------------------------------------------- 106 122 # USAGE: label … … 226 242 } 227 243 # Coords 228 set xcoords [XmlGet $cpath.xcoords]244 set xcoords [XmlGetSubst $cpath.xcoords] 229 245 set xcoords [string trim $xcoords] 230 set ycoords [XmlGet $cpath.ycoords]246 set ycoords [XmlGetSubst $cpath.ycoords] 231 247 set ycoords [string trim $ycoords] 232 248 if { $ycoords == "" } { … … 275 291 if { [info exists attr2option($attr)] } { 276 292 set option $attr2option($attr) 277 set value [XmlGet $cpath.$attr]293 set value [XmlGetSubst $cpath.$attr] 278 294 set options($option) $value 279 295 } … … 311 327 if { [info exists attr2option($attr)] } { 312 328 set option $attr2option($attr) 313 set value [XmlGet $cpath.$attr]329 set value [XmlGetSubst $cpath.$attr] 314 330 set options($option) $value 315 331 } elseif { [string match "controls*" $attr] } { 316 set value [XmlGet $cpath.$attr]332 set value [XmlGetSubst $cpath.$attr] 317 333 lappend _cname2controls($cname) $value 318 334 $_owner xml put $value.hide 1 … … 320 336 } 321 337 # Coordinates 322 set coords [XmlGet $cpath.coords]338 set coords [XmlGetSubst $cpath.coords] 323 339 set coords [ScreenCoords $coords] 324 340 if { $coords == "" } { … … 326 342 } 327 343 set c $itk_component(drawing) 328 set img [Rappture::icon question_mark12]344 set img [Rappture::icon hotspot_normal] 329 345 foreach { x1 y1 } $coords break 330 346 set id [$itk_component(drawing) create image $x1 $y1] … … 337 353 $c bind $id <Leave> [itcl::code $this Deactivate $cname] 338 354 #$c bind $id <ButtonPress-1> [itcl::code $this Depress $cname] 339 $c bind $id <ButtonRelease-1> [itcl::code $this Invoke $cname $x1 $y1] 355 set bbox [$c bbox $id] 356 set y1 [lindex $bbox 1] 357 $c bind $id <ButtonPress-1> [itcl::code $this Invoke $cname $x1 $y1] 340 358 } 341 359 … … 359 377 # Coords 360 378 set coords {} 361 set coords [XmlGet $cpath.coords]379 set coords [XmlGetSubst $cpath.coords] 362 380 set coords [string trim $coords] 363 381 if { $coords == "" } { … … 371 389 if { [info exists attr2option($attr)] } { 372 390 set option $attr2option($attr) 373 set value [XmlGet $cpath.$attr]391 set value [XmlGetSubst $cpath.$attr] 374 392 set options($option) $value 375 393 } … … 388 406 "outline" "-outline" 389 407 "fill" "-fill" 390 "linewidth" "- linewidth"408 "linewidth" "-width" 391 409 } 392 410 #puts stderr "ParseOval owner=$_owner cpath=$cpath" … … 395 413 array set options { 396 414 -fill blue 397 - linewidth 1415 -width 1 398 416 -outline black 399 417 } … … 401 419 if { [info exists attr2option($attr)] } { 402 420 set option $attr2option($attr) 403 set value [XmlGet $cpath.$attr]421 set value [XmlGetSubst $cpath.$attr] 404 422 set options($option) $value 405 423 } … … 407 425 # Coordinates 408 426 set coords {} 409 set coords [XmlGet $cpath.coords]427 set coords [XmlGetSubst $cpath.coords] 410 428 set coords [string trim $coords] 411 429 if { $coords == "" } { … … 413 431 } 414 432 foreach { x1 y1 x2 y2 } [ScreenCoords $coords] break 415 set id [ eval $itk_component(drawing) create oval $coords]433 set id [$itk_component(drawing) create oval $x1 $y1 $x2 $y2] 416 434 set _cname2id($cname) $id 435 eval $itk_component(drawing) itemconfigure $id [array get options] 417 436 } 418 437 … … 432 451 if { [info exists attr2option($attr)] } { 433 452 set option $attr2option($attr) 434 set value [XmlGet $cpath.$attr]453 set value [XmlGetSubst $cpath.$attr] 435 454 set options($option) $value 436 455 } 437 456 } 438 set contents [XmlGet $cpath.contents]457 set contents [XmlGetSubst $cpath.contents] 439 458 set img "" 440 459 if { [string compare -length 5 $contents "file:"] == 0 } { … … 453 472 } 454 473 # Coordinates 455 set coords [XmlGet $cpath.coords]474 set coords [XmlGetSubst $cpath.coords] 456 475 set coords [ScreenCoords $coords] 457 476 if { [llength $coords] == 2 } { 458 477 foreach { x1 y1 } $coords break 459 set w [XmlGet $cpath.width]478 set w [XmlGetSubst $cpath.width] 460 479 if { $w == "" || ![string is number $w] || $w <= 0.0 } { 461 480 set width [expr [image width $img] / 4] … … 463 482 set width [expr [ScreenX $w] - [ScreenX 0]] 464 483 } 465 set h [XmlGet $cpath.height]484 set h [XmlGetSubst $cpath.height] 466 485 if { $h == "" || ![string is number $h] || $h <= 0.0 } { 467 486 set height [expr [image height $img] / 4] … … 517 536 array set attr2option { 518 537 "linewidth" "-width" 519 "arrow" "-arrow"520 538 "color" "-fill" 521 539 } 522 540 # Set default options first and then let tool.xml override them. 523 541 array set options { 524 - arrow none525 - width 0526 - fillblack542 -width 1 543 -fill blue 544 -outline black 527 545 } 528 546 # Coords 529 set coords [XmlGet $cpath.coords]547 set coords [XmlGetSubst $cpath.coords] 530 548 set coords [string trim $coords] 531 549 if { $coords == "" } { … … 542 560 if { [info exists attr2option($attr)] } { 543 561 set option $attr2option($attr) 544 set value [XmlGet $cpath.$attr]562 set value [XmlGetSubst $cpath.$attr] 545 563 set options($option) $value 546 564 } … … 559 577 "outline" "-outline" 560 578 "fill" "-fill" 561 "linewidth" "-linewidth" 579 "color" "-fill" 580 "linewidth" "-width" 562 581 } 563 582 #puts stderr "ParseRectangle owner=$_owner cpath=$cpath" … … 566 585 array set options { 567 586 -fill blue 568 - linewidth 1587 -width 1 569 588 -outline black 570 589 } … … 572 591 if { [info exists attr2option($attr)] } { 573 592 set option $attr2option($attr) 574 set value [XmlGet $cpath.$attr]593 set value [XmlGetSubst $cpath.$attr] 575 594 set options($option) $value 576 595 } 577 596 } 578 597 # Coordinates 579 set coords [XmlGet $cpath.coords]598 set coords [XmlGetSubst $cpath.coords] 580 599 set coords [string trim $coords] 581 600 if { $coords == "" } { … … 583 602 } 584 603 foreach { x1 y1 x2 y2 } [ScreenCoords $coords] break 585 set id [ eval $itk_component(drawing) create rectangle $coords]604 set id [$itk_component(drawing) create rectangle $x1 $y1 $x2 $y2] 586 605 set _cname2id($cname) $id 606 eval $itk_component(drawing) itemconfigure $id [array get options] 587 607 } 588 608 … … 593 613 array set attr2option { 594 614 "font" "-font" 595 "color" "-fill" 615 "color" "-foreground" 616 "valuecolor" "-valueforeground" 596 617 "text" "-text" 597 618 "anchor" "-anchor" … … 601 622 # Set default options first and then let tool.xml override them. 602 623 array set options { 603 -font {Arial 8} 624 -font {Arial 12} 625 -valuefont {Arial 12} 626 -valueforeground blue3 604 627 -text {} 605 -fill black628 -fill {} 606 629 -anchor c 607 630 } … … 609 632 if { [info exists attr2option($attr)] } { 610 633 set option $attr2option($attr) 611 set value [XmlGet $cpath.$attr] 634 if { $attr == "text" } { 635 set value [XmlGet $cpath.$attr] 636 } else { 637 set value [XmlGetSubst $cpath.$attr] 638 } 612 639 set options($option) $value 613 640 } 614 641 } 615 642 # Coords 616 set coords [XmlGet $cpath.coords]643 set coords [XmlGetSubst $cpath.coords] 617 644 set coords [string trim $coords] 618 645 if { $coords == "" } { … … 621 648 set coords [ScreenCoords $coords] 622 649 } 650 set hotspot [XmlGetSubst $cpath.hotspot] 651 if { $hotspot == "inline" } { 652 set options(-showicons) 1 653 } 654 set c $itk_component(drawing) 623 655 set options(-tags) $cname 624 set id [eval $itk_component(drawing) create text $coords] 656 set img [Rappture::icon hotspot_normal] 657 set options(-image) $img 658 set img [Rappture::icon hotspot_active] 659 set options(-activeimage) $img 660 set id [eval $c create hotspot $coords] 625 661 set _cname2id($cname) $id 626 eval $itk_component(drawing) itemconfigure $id [array get options] 662 set options(-interp) $_parser 663 eval $c itemconfigure $id [array get options] 664 if { $hotspot == "inline" } { 665 array unset _cname2controls $cname 666 foreach varName [Rappture::hotspot variables $c $id] { 667 if { [info exists _name2path($varName)] } { 668 set path $_name2path($varName) 669 $_owner xml put $path.hide 1 670 lappend _cname2controls($cname) $path 671 } else { 672 puts stderr "unknown varName=$varName" 673 } 674 } 675 $c bind $id <Motion> \ 676 [itcl::code $this Hotspot watch $cname $id %x %y] 677 $c bind $id <Leave> \ 678 [itcl::code $this Hotspot deactivate $cname $id] 679 $c bind $id <Enter> \ 680 [itcl::code $this Hotspot activate $cname $id %x %y] 681 $c bind $id <ButtonRelease-1> \ 682 [itcl::code $this Hotspot invoke $cname $id %x %y] 683 } 684 } 685 686 687 itcl::body Rappture::DrawingEntry::Hotspot { option cname item args } { 688 if { [NumControlsEnabled $cname] == 0 } { 689 return 690 } 691 set c $itk_component(drawing) 692 switch -- $option { 693 "activate" { 694 foreach { x y } $args break 695 set varName [Rappture::hotspot identify $c $item $x $y] 696 $c itemconfigure $item -activevalue $varName 697 } 698 "deactivate" { 699 $c itemconfigure $item -activevalue "" 700 } 701 "watch" { 702 foreach { x y } $args break 703 set active [$c itemcget $item -activevalue] 704 set varName [Rappture::hotspot identify $c $item $x $y] 705 if { $varName != $active } { 706 $c itemconfigure $item -activevalue $varName 707 } 708 } 709 "invoke" { 710 foreach { x y } $args break 711 set active [$c itemcget $item -activevalue] 712 set varName [Rappture::hotspot identify $c $item $x $y] 713 if { $varName != "" } { 714 set bbox [$c bbox $item] 715 Invoke $cname $x [lindex $bbox 1] 716 } 717 } 718 } 627 719 } 628 720 … … 825 917 set popup .drawingentrypopup 826 918 if { ![winfo exists $popup] } { 827 # Create a popup for the printdialog919 # Create a popup for the controls dialog 828 920 Rappture::Balloon $popup -title "Change values..." \ 829 -deactivatecommand [itcl::code $this Withdraw ]921 -deactivatecommand [itcl::code $this Withdraw $cname] 830 922 set inner [$popup component inner] 831 923 Rappture::DrawingControls $inner.controls $_owner \ … … 836 928 $inner.controls delete all 837 929 } 930 set count 0 838 931 foreach path $controls { 839 $inner.controls add $path 932 if { [IsEnabled $path] } { 933 $inner.controls add $path 934 incr count 935 } 936 } 937 if { $count == 0 } { 938 return 840 939 } 841 940 update … … 843 942 incr x [winfo rootx $itk_component(drawing)] 844 943 incr y [winfo rooty $itk_component(drawing)] 845 846 944 $popup activate @$x,$y above 847 945 } … … 851 949 # 852 950 itcl::body Rappture::DrawingEntry::Activate { cname } { 853 $itk_component(drawing) configure -cursor center_ptr 951 $itk_component(drawing) configure -cursor center_ptr 952 $itk_component(drawing) itemconfigure $_cname2id($cname) \ 953 -image [Rappture::icon hotspot_active] 854 954 } 855 955 … … 858 958 # 859 959 itcl::body Rappture::DrawingEntry::Deactivate { cname } { 860 $itk_component(drawing) configure -cursor left_ptr 861 } 862 863 # 864 # Invoke -- 865 # 866 itcl::body Rappture::DrawingEntry::Withdraw {} { 960 $itk_component(drawing) configure -cursor left_ptr 961 $itk_component(drawing) itemconfigure $_cname2id($cname) \ 962 -image [Rappture::icon hotspot_normal] 963 } 964 965 # 966 # Withdraw -- 967 # 968 itcl::body Rappture::DrawingEntry::Withdraw { cname } { 867 969 Redraw 868 970 } … … 888 990 itcl::body Rappture::DrawingEntry::InitSubstitutions {} { 889 991 # Load a new parser with the variables representing the substitution 890 set _parser [interp create -safe]891 992 foreach name [array names _name2path] { 892 993 set path $_name2path($name) … … 903 1004 itcl::body Rappture::DrawingEntry::XmlGet { path } { 904 1005 set value [$_owner xml get $path] 1006 return [string trim $value] 1007 } 1008 1009 itcl::body Rappture::DrawingEntry::XmlGetSubst { path } { 1010 set value [$_owner xml get $path] 905 1011 if { $_parser == "" } { 906 1012 return $value 907 1013 } 908 return [$_parser eval [list subst -nocommands $value]] 909 } 910 1014 return [string trim [$_parser eval [list subst -nocommands $value]]] 1015 } 1016 1017 itcl::body Rappture::DrawingEntry::IsEnabled { path } { 1018 set enable [string trim [$_owner xml get $path.about.enable]] 1019 if {"" == $enable} { 1020 return 1 1021 } 1022 if {![string is boolean $enable]} { 1023 set re {([a-zA-Z_]+[0-9]*|\([^\(\)]+\)|[a-zA-Z_]+[0-9]*\([^\(\)]+\))(\.([a-zA-Z_]+[0-9]*|\([^\(\)]+\)|[a-zA-Z_]+[0-9]*\([^\(\)]+\)))*(:[-a-zA-Z0-9/]+)?} 1024 set rest $enable 1025 set enable "" 1026 set deps "" 1027 while {1} { 1028 if {[regexp -indices $re $rest match]} { 1029 foreach {s0 s1} $match break 1030 1031 if {[string index $rest [expr {$s0-1}]] == "\"" 1032 && [string index $rest [expr {$s1+1}]] == "\""} { 1033 # string in ""'s? then leave it alone 1034 append enable [string range $rest 0 $s1] 1035 set rest [string range $rest [expr {$s1+1}] end] 1036 } else { 1037 # 1038 # This is a symbol which should be substituted 1039 # it can be either: 1040 # input.foo.bar 1041 # input.foo.bar:units 1042 # 1043 set cpath [string range $rest $s0 $s1] 1044 set parts [split $cpath :] 1045 set ccpath [lindex $parts 0] 1046 set units [lindex $parts 1] 1047 1048 # make sure we have the standard path notation 1049 set stdpath [$_owner regularize $ccpath] 1050 if {"" == $stdpath} { 1051 puts stderr "WARNING: don't recognize parameter $cpath in <enable> expression for $path. This may be buried in a structure that is not yet loaded." 1052 set stdpath $ccpath 1053 } 1054 # substitute [_controlValue ...] call in place of path 1055 append enable [string range $rest 0 [expr {$s0-1}]] 1056 append enable [format {[ControlValue %s %s]} $stdpath $units] 1057 lappend deps $stdpath 1058 set rest [string range $rest [expr {$s1+1}] end] 1059 } 1060 } else { 1061 append enable $rest 1062 break 1063 } 1064 } 1065 } 1066 return [expr $enable] 1067 } 1068 1069 # ---------------------------------------------------------------------- 1070 # USAGE: ControlValue <path> ?<units>? 1071 # 1072 # Used internally to get the value of a control with the specified 1073 # <path>. Returns the current value for the control. 1074 # ---------------------------------------------------------------------- 1075 itcl::body Rappture::DrawingEntry::ControlValue {path {units ""}} { 1076 if {"" != $_owner} { 1077 set val [$_owner valuefor $path] 1078 if {"" != $units} { 1079 set val [Rappture::Units::convert $val -to $units -units off] 1080 } 1081 return $val 1082 } 1083 return "" 1084 } 1085 1086 itcl::body Rappture::DrawingEntry::NumControlsEnabled { cname } { 1087 set controls $_cname2controls($cname) 1088 set count 0 1089 foreach path $controls { 1090 if { [IsEnabled $path] } { 1091 incr count 1092 } 1093 } 1094 return $count 1095 } -
branches/blt4/gui/scripts/htmlviewer.tcl
r2985 r3102 304 304 if {"" != $node} { 305 305 set bbox [$itk_component(html) bbox $node] 306 set realht [expr {[lindex $bbox 3]-[lindex $bbox 1]}] 306 if { $bbox != "" } { 307 set realht [expr {[lindex $bbox 3]-[lindex $bbox 1]}] 308 } 307 309 } 308 310 if {$itk_option(-maxlines) > 0} { -
branches/blt4/gui/scripts/vtkviewer.tcl
r3068 r3102 1306 1306 } 1307 1307 "glyphs" { 1308 #SendCmd "glyphs colormap $colormap $tag" 1308 SendCmd "glyphs colormap $colormap $tag" 1309 } 1310 "molecule" { 1311 SendCmd "molecule colormap $colormap $tag" 1309 1312 } 1310 1313 } -
branches/blt4/gui/src/Makefile.in
r2742 r3102 51 51 OBJS = \ 52 52 RapptureGUI_Init.o \ 53 RpCanvHotspot.o \ 53 54 RpCanvPlacard.o \ 54 55 RpDiffview.o \ -
branches/blt4/gui/src/RapptureGUI_Init.c
r2742 r3102 23 23 24 24 extern Tcl_AppInitProc Rappturegui_Init; 25 extern Tcl_AppInitProc RpCanvHotspot_Init; 25 26 extern Tcl_AppInitProc RpCanvPlacard_Init; 27 extern Tcl_AppInitProc RpConvertDxToVtk_Init; 26 28 extern Tcl_AppInitProc RpDiffview_Init; 27 29 … … 48 50 return TCL_ERROR; 49 51 } 52 if (RpCanvHotspot_Init(interp) != TCL_OK) { 53 return TCL_ERROR; 54 } 50 55 return TCL_OK; 51 56 } -
branches/blt4/gui/src/RpDiffview.c
r2227 r3102 2774 2774 layoutPtr->lines = (DiffviewLayoutLine*)ckalloc( 2775 2775 (unsigned)(layoutPtr->numLines * sizeof(DiffviewLayoutLine))); 2776 layoutPtr->maxLines = layoutPtr->numLines; 2776 2777 } 2777 2778 layoutPtr->numLines = 0;
Note: See TracChangeset
for help on using the changeset viewer.