Changeset 6071
- Timestamp:
- Feb 28, 2016, 2:40:31 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/map.tcl
r6061 r6071 61 61 public method viewpoints {} 62 62 63 protected method Parse { xmlobj path } 63 public proc getFilesFromStylesheet { stylesheet } 64 65 protected method parseXML { xmlobj path } 66 67 protected proc isFileProp { prop } 68 protected proc parseStylesheet { stylesheet } 64 69 65 70 private variable _tree ""; # Tree of information about the map. … … 105 110 error "bad value \"$xmlobj\": should be LibraryObj" 106 111 } 107 Parse$xmlobj $path112 parseXML $xmlobj $path 108 113 } 109 114 } … … 134 139 135 140 # 136 # Parse--141 # parseXML -- 137 142 # 138 143 # Parses the map description in the XML object. 139 144 # 140 itcl::body Rappture::Map:: Parse{ xmlobj path } {145 itcl::body Rappture::Map::parseXML { xmlobj path } { 141 146 142 147 set map [$xmlobj element -as object $path] … … 884 889 return [expr {[hints "type"] eq "geocentric"}] 885 890 } 891 892 itcl::body Rappture::Map::isFileProp { prop } { 893 foreach fileprop { 894 icon 895 model 896 } { 897 if { $prop eq $fileprop } { 898 return 1 899 } 900 } 901 return 0 902 } 903 904 tcl::body Rappture::Map::parseStylesheet { stylesheet } { 905 set styles [list] 906 # First split into style blocks 907 set blocks [split $stylesheet "\{\}"] 908 if {[llength $blocks] == 1} { 909 set blocks [list style $blocks] 910 } 911 foreach {styleName block} $blocks { 912 # Get name/value pairs 913 set styleName [string trim $styleName] 914 if {$styleName == ""} { set styleName "style" } 915 set block [string trim $block " \t\n\r\{\}"] 916 if {$block == ""} { continue } 917 #puts stderr "styleName: \"$styleName\"" 918 #puts stderr "block: \"$block\"" 919 set lines [split $block ";"] 920 foreach line $lines { 921 set line [string trim $line] 922 if {$line == "" || [string index $line 0] == "#"} { continue } 923 #puts stderr "line: \"$line\"" 924 set delim [string first ":" $line] 925 set prop [string trim [string range $line 0 [expr {$delim-1}]]] 926 set val [string trim [string range $line [expr {$delim+1}] end]] 927 set ${styleName}($prop) $val 928 } 929 lappend styles $styleName [array get $styleName] 930 } 931 return $styles 932 } 933 934 itcl::body Rappture::Map::getFilesFromStylesheet { stylesheet } { 935 set files [list] 936 set styles [parseStylesheet $stylesheet] 937 foreach {name style} $styles { 938 #puts stderr "Style: \"$name\"" 939 array unset info 940 array set info $style 941 foreach key [array names info] { 942 #puts stderr "Prop: \"$key\" Val: \"$info($key)\"" 943 if {[isFileProp $key]} { 944 lappend files $info($key) 945 } 946 } 947 } 948 return $files 949 }
Note: See TracChangeset
for help on using the changeset viewer.