Changeset 729 for trunk/gui/scripts/deviceViewer1D.tcl
- Timestamp:
- May 12, 2007, 2:14:49 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/deviceViewer1D.tcl
r464 r729 32 32 destructor { # defined below } 33 33 34 public method add {dataobj {settings ""}} 35 public method get {} 36 public method delete {args} 37 34 38 public method controls {option args} 35 39 public method download {option args} … … 48 52 49 53 private variable _owner "" ;# thing managing this control 54 private variable _dlist "" ;# list of dataobj objects 55 private variable _dobj2raise ;# maps dataobj => raise flag 50 56 private variable _device "" ;# XML library with <structure> 51 57 private variable _tab2fields ;# maps tab name => list of fields 52 58 private variable _field2parm ;# maps field path => parameter name 53 59 private variable _units "" ;# units for field being edited 54 private variable _restrict "" ;# restriction expr for field being edited55 60 private variable _marker ;# marker currently being edited 56 61 } … … 137 142 after cancel [list catch [itcl::code $this _fixAxes]] 138 143 after cancel [list catch [itcl::code $this _align]] 144 after cancel [list catch [itcl::code $this _loadDevice]] 145 } 146 147 # ---------------------------------------------------------------------- 148 # USAGE: add <dataobj> ?<settings>? 149 # 150 # Clients use this to add a data object to the plot. The optional 151 # <settings> are used to configure the plot. Allowed settings are 152 # -color, -brightness, -width, -linestyle, and -raise. Only 153 # -brightness and -raise do anything. 154 # ---------------------------------------------------------------------- 155 itcl::body Rappture::DeviceViewer1D::add {dataobj {settings ""}} { 156 array set params { 157 -color auto 158 -brightness 0 159 -width 1 160 -raise 0 161 -linestyle solid 162 -description "" 163 } 164 foreach {opt val} $settings { 165 if {![info exists params($opt)]} { 166 error "bad settings \"$opt\": should be [join [lsort [array names params]] {, }]" 167 } 168 set params($opt) $val 169 } 170 171 set pos [lsearch -exact $dataobj $_dlist] 172 173 if {$pos < 0} { 174 if {![Rappture::library isvalid $dataobj]} { 175 error "bad value \"$dataobj\": should be Rappture::library object" 176 } 177 178 lappend _dlist $dataobj 179 set _dobj2raise($dataobj) $params(-raise) 180 181 after cancel [list catch [itcl::code $this _loadDevice]] 182 after idle [list catch [itcl::code $this _loadDevice]] 183 } 184 } 185 186 # ---------------------------------------------------------------------- 187 # USAGE: get 188 # 189 # Clients use this to query the list of objects being plotted, in 190 # order from bottom to top of this result. 191 # ---------------------------------------------------------------------- 192 itcl::body Rappture::DeviceViewer1D::get {} { 193 # put the dataobj list in order according to -raise options 194 set dlist $_dlist 195 foreach obj $dlist { 196 if {[info exists _dobj2raise($obj)] && $_dobj2raise($obj)} { 197 set i [lsearch -exact $dlist $obj] 198 if {$i >= 0} { 199 set dlist [lreplace $dlist $i $i] 200 lappend dlist $obj 201 } 202 } 203 } 204 return $dlist 205 } 206 207 # ---------------------------------------------------------------------- 208 # USAGE: delete ?<dataobj> <dataobj> ...? 209 # 210 # Clients use this to delete a dataobj from the plot. If no dataobjs 211 # are specified, then all dataobjs are deleted. 212 # ---------------------------------------------------------------------- 213 itcl::body Rappture::DeviceViewer1D::delete {args} { 214 if {[llength $args] == 0} { 215 set args $_dlist 216 } 217 218 # delete all specified dataobjs 219 set changed 0 220 foreach dataobj $args { 221 set pos [lsearch -exact $_dlist $dataobj] 222 if {$pos >= 0} { 223 set _dlist [lreplace $_dlist $pos $pos] 224 catch {unset _dobj2raise($dataobj)} 225 set changed 1 226 } 227 } 228 229 # if anything changed, then rebuild the plot 230 if {$changed} { 231 after cancel [list catch [itcl::code $this _loadDevice]] 232 after idle [list catch [itcl::code $this _loadDevice]] 233 } 139 234 } 140 235 … … 203 298 # ---------------------------------------------------------------------- 204 299 itcl::body Rappture::DeviceViewer1D::_loadDevice {} { 300 set _device [lindex [get] end] 301 205 302 # 206 303 # Release any info left over from the last device. … … 418 515 } 419 516 420 if {[info exists hints(restrict)]} {421 set _restrict $hints(restrict)422 } else {423 set _restrict ""424 }425 426 517 if {[info exists hints(scale)] 427 518 && [string match log* $hints(scale)]} { … … 645 736 return 0 646 737 } 647 if {"" != $_restrict 648 && [catch {Rappture::Units::convert $result \ 649 -context $_units -to $_units -units off} value] == 0} { 650 651 set rexpr $_restrict 652 regsub -all value $rexpr {$value} rexpr 653 if {[catch {expr $rexpr} result] == 0 && !$result} { 654 bell 655 Rappture::Tooltip::cue $itk_component(geditor) "Should satisfy the condition: $_restrict" 656 return 0 657 } 658 } 738 } 739 if {[catch {$_marker(fobj) controls validate $_marker(path) $name} result]} { 740 bell 741 Rappture::Tooltip::cue $itk_component(geditor) $result 742 return 0 659 743 } 660 744 return 1 … … 779 863 } 780 864 } 781 set _device $itk_option(-device) 782 _loadDevice 783 } 865 866 delete 867 if {"" != $itk_option(-device)} { 868 add $itk_option(-device) 869 } 870 after cancel [list catch [itcl::code $this _loadDevice]] 871 after idle [list catch [itcl::code $this _loadDevice]] 872 }
Note: See TracChangeset
for help on using the changeset viewer.