Changeset 3671
- Timestamp:
- May 22, 2013, 6:44:15 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/drawingentry.tcl
r3670 r3671 848 848 849 849 itcl::body Rappture::DrawingEntry::ScreenX { x } { 850 set norm [expr {($x - $_xMin) * $_xScale}] 851 set x [expr {int($norm * $_drawingWidth) + $_xOffset}] 852 return $x 850 return [expr {($x - $_xMin)*$_xScale + $_xOffset}] 853 851 } 854 852 855 853 itcl::body Rappture::DrawingEntry::ScreenY { y } { 856 set norm [expr {($y - $_yMin) * $_yScale}] 857 set y [expr {int($norm * $_drawingHeight) + $_yOffset}] 858 return $y 854 return [expr {($y - $_yMin)*$_yScale + $_yOffset}] 859 855 } 860 856 … … 927 923 928 924 itcl::body Rappture::DrawingEntry::ParseScreenCoordinates { values } { 929 set len [llength $values] 930 if { $len == 4 } { 931 if { [scan $values "%g %g %g %g" x1 y1 x2 y2] != 4 } { 932 error "bad coordinates specification \"$values\"" 933 } 934 set _xScale [expr 1.0 / ($x2 - $x1)] 935 set _yScale [expr 1.0 / ($y2 - $y1)] 936 set _xMin $x1 937 set _yMin $y1 938 } elseif { $len == 10 } { 939 if { [scan $values "%g %g %s %d%% %d%% %g %g %s %d%% %d%%" \ 940 sx1 sy1 at1 x1 y1 sx2 sy2 at2 x2 y2] != 10 } { 941 error "bad coordinates specification \"$values\"" 942 } 943 if { $at1 != "at" || $at2 != "at" } { 944 error "bad coordinates specification \"$values\"" 945 } 946 set x1 [expr $x1 / 100.0] 947 set x2 [expr $x2 / 100.0] 948 set y1 [expr $y1 / 100.0] 949 set y2 [expr $y2 / 100.0] 950 set _xScale [expr ($sx2 - $sx1) / ($x2 - $x1)] 951 set _yScale [expr ($sy2 - $sy2) / ($y2 - $y2)] 952 set _xMin $x1 953 set _yMin $y1 954 } 925 set bad "" 926 foreach point {1 2} { 927 set xvals($point) [lindex $values 0] 928 if {![string is double -strict $xvals($point)]} { 929 set bad "missing background coordinate point $point in \"$values\"" 930 break 931 } 932 933 set yvals($point) [lindex $values 1] 934 if {![string is double -strict $yvals($point)]} { 935 set bad "missing background coordinate point $point in \"$values\"" 936 break 937 } 938 set values [lrange $values 2 end] 939 940 # each corner point can be place anywhere from 0% to 100% 941 if {[lindex $values 0] eq "at"} { 942 if {[regexp {^([0-9]+)%$} [lindex $values 1] match xpcnt] 943 && [regexp {^([0-9]+)%$} [lindex $values 2] match ypcnt]} { 944 set wherex($point) [expr {0.01*$xpcnt}] 945 set wherey($point) [expr {0.01*$ypcnt}] 946 set values [lrange $values 3 end] 947 } else { 948 set bad "expected \"at XX% YY%\" but got \"$values\""; break 949 } 950 } else { 951 set wherex($point) [expr {($point == 1) ? 0 : 1}] 952 set wherey($point) [expr {($point == 1) ? 0 : 1}] 953 } 954 } 955 if {$bad eq "" && $wherex(1) == $wherex(2)} { 956 set bad [format "drawing background limits have x points both at %d%%" [expr {round($wherex(1)*100)}]] 957 } 958 if {$bad eq "" && $wherey(1) == $wherey(2)} { 959 set bad [format "drawing background limits have y points both at %d%%" [expr {round($wherex(1)*100)}]] 960 } 961 962 if {$bad eq "" && $xvals(1) == $xvals(2)} { 963 set bad "drawing background coordinates have 0 range in x" 964 } 965 if {$bad eq "" && $yvals(1) == $yvals(2)} { 966 set bad "drawing background coordinates have 0 range in y" 967 } 968 if {$bad eq "" && [llength $values] > 0} { 969 set bad "extra coordinates \"$values\"" 970 } 971 972 if {$bad ne ""} { 973 puts "WARNING: $bad" 974 puts "assuming default \"0 0 1 1\" coordinates" 975 array set xvals {1 0 2 1} 976 array set yvals {1 0 2 1} 977 array set wherex {1 0 2 1} 978 array set wherey {1 0 2 1} 979 } 980 981 # compute min/scale for each axis based on the input values 982 if {$wherex(1) < $wherex(2)} { 983 set min 1; set max 2 984 } else { 985 set min 2; set max 1 986 } 987 988 set slope [expr {double($xvals($max)-$xvals($min)) 989 / ($wherex($max)-$wherex($min))}] 990 set _xMin [expr {-$wherex($min)*$slope + $xvals($min)}] 991 set xmax [expr {(1-$wherex($max))*$slope + $xvals($max)}] 992 set _xScale [expr {[winfo width $itk_component(drawing)]/($xmax-$_xMin)}] 993 994 if {$wherey(1) < $wherey(2)} { 995 set min 1; set max 2 996 } else { 997 set min 2; set max 1 998 } 999 1000 set slope [expr {double($yvals($max)-$yvals($min)) 1001 / ($wherey($max)-$wherey($min))}] 1002 set _yMin [expr {-$wherey($min)*$slope + $yvals($min)}] 1003 set ymax [expr {(1-$wherey($max))*$slope + $yvals($max)}] 1004 set _yScale [expr {[winfo height $itk_component(drawing)]/($ymax-$_yMin)}] 955 1005 } 956 1006 957 1007 itcl::body Rappture::DrawingEntry::ParseBackground {} { 958 1008 foreach elem [$_xmlobj children $_path.background] { 959 switch - glob -- $elem {960 "color *" {1009 switch -- $elem { 1010 "color" { 961 1011 # Background color of the drawing canvas (default white) 962 1012 set value [XmlGet $_path.background.$elem] 963 1013 $itk_component(drawing) configure -background $value 964 1014 } 965 "aspect *" {1015 "aspect" { 966 1016 set value [XmlGet $_path.background.$elem] 967 1017 foreach { xAspect yAspect } $value break 968 1018 AdjustDrawingArea $xAspect $yAspect 969 1019 } 970 "coord inates*" {1020 "coords" - "coordinates" { 971 1021 set value [XmlGet $_path.background.$elem] 972 1022 ParseScreenCoordinates $value 973 1023 } 974 "width *" {1024 "width" { 975 1025 set width [XmlGet $_path.background.$elem] 976 1026 $itk_component(drawing) configure -width $width 977 1027 } 978 "height *" {1028 "height" { 979 1029 set height [XmlGet $_path.background.$elem] 980 1030 $itk_component(drawing) configure -height $height 981 1031 } 1032 default { 1033 puts "WARNING: don't understand \"$elem\" in $_path" 1034 } 982 1035 } 983 1036 } … … 989 1042 itcl::body Rappture::DrawingEntry::Invoke {cpath x y} { 990 1043 if {![info exists _cpath2popup($cpath)]} { 991 error "internal error: no controls for hotspot at $cpath" 1044 puts "WARNING: no controls for hotspot at $cpath" 1045 return 992 1046 } 993 1047 set popup $_cpath2popup($cpath) -
trunk/lang/tcl/scripts/objects.tcl
r3177 r3671 819 819 array set object $extra 820 820 } else { 821 array set object [list type [type] palettes $palettes help $help] 822 } 823 824 # handle checks defined in a base class 825 foreach baseobj [cget -inherit] { 826 eval lappend rlist [$baseobj check $side $data $debug [array get object]] 827 } 828 829 # add checks defined in the current class 821 array set object [list type [type] palettes $palettes help $help checked ""] 822 } 823 824 # do checks defined in the current class 830 825 for {set n 1} {$n <= $_checks(num)} {incr n} { 826 set aname $_checks($n-attr) 827 828 # if we already did this check on a derived class, then skip it 829 # derived classes override the base class 830 if {[lsearch $object(checked) $aname] >= 0} { 831 continue 832 } 833 831 834 # look at the -only option and see if the check applies here 832 set aname $_checks($n-attr)833 835 set only [getAttr $aname -only] 834 836 if {$only ne "" && [lsearch $only $side] < 0} { … … 838 840 # execute the code to look for errors in the value 839 841 set status [catch $_checks($n-code) result] 842 lappend object(checked) $aname 843 840 844 if {$status != 0 && $status != 2} { 841 845 puts stderr "ERROR DURING VALUE CHECK:\n$result" … … 848 852 } 849 853 } 854 855 # handle checks defined in a base class 856 foreach baseobj [cget -inherit] { 857 eval lappend rlist [$baseobj check $side $data $debug [array get object]] 858 } 859 850 860 return $rlist 851 861 } -
trunk/lang/tcl/scripts/objects/group/group.rp
r3177 r3671 18 18 help http://rappture.org/wiki/rp_xml_ele_group 19 19 terminal no 20 21 check label { 22 # it's okay to have a blank label for invisible groups 23 } 24 25 check description { 26 set label [string trim $attr(label)] 27 set desc [string trim $attr(description)] 28 if {$label ne ""} { 29 # label is set, so must have a good description 30 if {$desc eq ""} { 31 return [list warning "You should include a description of what this group represents."] 32 } elseif {$desc eq $label} { 33 return [list warning "The description should be different from the label and give additional information about this group."] 34 } 35 } 36 } 20 37 } -
trunk/lang/tcl/scripts/objects/string/string.rp
r3177 r3671 20 20 attr default -title "Default Value" -type string -path default -only input -tooltip "Sets the value that this input has when the program first starts. This value is used by default unless the user explicitly changes it." 21 21 22 attr size -title "Size" -type string:validate=size -path size -only input -tooltip "Sets the desired size for the string. Strings are normally 1 line of text, but if the size is set to some WxH, then the entry area will be at least W chars wide and H lines tall. For example, 40x5 says that the string should be 40 chars wide and 10lines tall."22 attr size -title "Size" -type string:validate=size -path size -only input -tooltip "Sets the desired size for the string. Strings are normally 1 line of text, but if the size is set to some WxH, then the entry area will be at least W chars wide and H lines tall. For example, 40x5 says that the string should be 40 chars wide and 5 lines tall." 23 23 24 24 attr hints -title "Hint String" -type string -path about.hints -only input -tooltip "Sets a line of text displayed beneath the entry area for the string. This is used to give a hint to the user about what should be entered in the string area."
Note: See TracChangeset
for help on using the changeset viewer.