Changeset 3800 for branches/1.3/gui/scripts
- Timestamp:
- Jul 15, 2013, 9:29:39 AM (11 years ago)
- Location:
- branches/1.3/gui/scripts
- Files:
-
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3/gui/scripts/barchartresult.tcl
r3765 r3800 290 290 -param "" 291 291 } 292 foreach {opt val} $settings { 293 if {![info exists params($opt)]} { 294 error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]" 295 } 296 set params($opt) $val 297 } 298 292 array set params $settings 299 293 # if the color is "auto", then select a color from -autocolors 300 294 if {$params(-color) == "auto" || $params(-color) == "autoreset"} { -
branches/1.3/gui/scripts/contourresult.tcl
r3636 r3800 346 346 -param "" 347 347 } 348 foreach {opt val} $settings { 349 if {![info exists params($opt)]} { 350 error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]" 351 } 352 set params($opt) $val 353 } 348 array set params $settings 354 349 if {$params(-color) == "auto" || $params(-color) == "autoreset"} { 355 350 # can't handle -autocolors yet -
branches/1.3/gui/scripts/datatableresult.tcl
r3330 r3800 139 139 -param "" 140 140 } 141 foreach {opt val} $settings { 142 if {![info exists params($opt)]} { 143 error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]" 144 } 145 set params($opt) $val 146 } 141 array set params $settings 147 142 if { $params(-raise) } { 148 143 set _raised $dataobj -
branches/1.3/gui/scripts/deviceViewer1D.tcl
r3330 r3800 167 167 -param "" 168 168 } 169 foreach {opt val} $settings { 170 if {![info exists params($opt)]} { 171 error "bad settings \"$opt\": should be [join [lsort [array names params]] {, }]" 172 } 173 set params($opt) $val 174 } 169 array set params $settings 175 170 176 171 set pos [lsearch -exact $dataobj $_dlist] -
branches/1.3/gui/scripts/deviceresult.tcl
r3330 r3800 73 73 -param "" 74 74 } 75 foreach {opt val} $settings { 76 if {![info exists params($opt)]} { 77 error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]" 78 } 79 set params($opt) $val 80 } 75 array set params $settings 81 76 82 77 eval $itk_component(viewer) add $dataobj [list $settings] -
branches/1.3/gui/scripts/energyLevels.tcl
r3330 r3800 274 274 -param "" 275 275 } 276 foreach {opt val} $settings { 277 if {![info exists params($opt)]} { 278 error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]" 279 } 280 set params($opt) $val 281 } 276 array set params $settings 282 277 283 278 # convert -linestyle to BLT -dashes -
branches/1.3/gui/scripts/flowvisviewer.tcl
r3633 r3800 588 588 -param "" 589 589 } 590 foreach {opt val} $settings { 591 if {![info exists params($opt)]} { 592 error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]" 593 } 594 set params($opt) $val 595 } 590 array set params $settings 596 591 if {$params(-color) == "auto" || $params(-color) == "autoreset"} { 597 592 # can't handle -autocolors yet -
branches/1.3/gui/scripts/histogramresult.tcl
r3765 r3800 286 286 -param "" 287 287 } 288 foreach {opt val} $settings { 289 if {![info exists params($opt)]} { 290 error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]" 291 } 292 set params($opt) $val 293 } 288 array set params $settings 294 289 295 290 # if the color is "auto", then select a color from -autocolors -
branches/1.3/gui/scripts/imageresult.tcl
r3330 r3800 189 189 -param "" 190 190 } 191 foreach {opt val} $settings { 192 if {![info exists params($opt)]} { 193 error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]" 194 } 195 set params($opt) $val 196 } 191 array set params $settings 197 192 198 193 if {$params(-raise)} { -
branches/1.3/gui/scripts/meshresult.tcl
r3330 r3800 136 136 -param "" 137 137 } 138 foreach {opt val} $settings { 139 if {![info exists params($opt)]} { 140 error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]" 141 } 142 set params($opt) $val 143 } 138 array set params $settings 144 139 if {$params(-color) == "auto" || $params(-color) == "autoreset"} { 145 140 # can't handle -autocolors yet -
branches/1.3/gui/scripts/moleculeViewer.tcl
r3330 r3800 235 235 -param "" 236 236 } 237 foreach {opt val} $settings { 238 if {![info exists params($opt)]} { 239 error "bad settings \"$opt\": should be [join [lsort [array names params]] {, }]" 240 } 241 set params($opt) $val 242 } 237 array set params $settings 243 238 244 239 set pos [lsearch -exact $dataobj $_dlist] -
branches/1.3/gui/scripts/molvisviewer.tcl
r3637 r3800 450 450 -param "" 451 451 } 452 453 foreach {opt val} $options { 454 if {![info exists params($opt)]} { 455 error "bad settings \"$opt\": should be [join [lsort [array names params]] {, }]" 456 } 457 set params($opt) $val 458 } 452 array set params $settings 459 453 460 454 set pos [lsearch -exact $dataobj $_dlist] -
branches/1.3/gui/scripts/nanovisviewer.tcl
r3633 r3800 410 410 -param "" 411 411 } 412 foreach {opt val} $settings { 413 if {![info exists params($opt)]} { 414 error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]" 415 } 416 set params($opt) $val 417 } 412 array set params $settings 413 418 414 if {$params(-color) == "auto" || $params(-color) == "autoreset"} { 419 415 # can't handle -autocolors yet -
branches/1.3/gui/scripts/numberresult.tcl
r3765 r3800 276 276 -param "" 277 277 } 278 foreach {opt val} $settings { 279 if {![info exists params($opt)]} { 280 error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]" 281 } 282 set params($opt) $val 283 } 278 array set params $settings 284 279 285 280 # if type is set to "scatter", then override the width -
branches/1.3/gui/scripts/resultviewer.tcl
r3573 r3800 195 195 196 196 set index [_cleanIndex $index] 197 lappend opts "-simulation" [expr $index + 1] 197 198 set reset "-color autoreset" 198 199 set slot [lindex $_dataslots $index] -
branches/1.3/gui/scripts/sequenceresult.tcl
r3666 r3800 212 212 -param "" 213 213 } 214 foreach {opt val} $settings { 215 if {![info exists params($opt)]} { 216 error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]" 217 } 218 set params($opt) $val 219 } 214 array set params $settings 220 215 221 216 if {$params(-raise) && "" == $_topmost} { -
branches/1.3/gui/scripts/textresult.tcl
r3330 r3800 186 186 -param "" 187 187 } 188 foreach {opt val} $settings { 189 if {![info exists params($opt)]} { 190 error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]" 191 } 192 set params($opt) $val 193 } 188 array set params $settings 194 189 195 190 set replace 0 -
branches/1.3/gui/scripts/valueresult.tcl
r3330 r3800 84 84 -param "" 85 85 } 86 foreach {opt val} $settings { 87 if {![info exists params($opt)]} { 88 error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]" 89 } 90 set params($opt) $val 91 } 86 array set params $settings 87 92 88 if {$params(-color) == "auto" || $params(-color) == "autoreset"} { 93 89 # can't handle -autocolors yet -
branches/1.3/gui/scripts/vtkglyphviewer.tcl
r3790 r3800 526 526 set params(-description) "" 527 527 set params(-param) "" 528 foreach {opt val} $settings { 529 if {![info exists params($opt)]} { 530 error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]" 531 } 532 set params($opt) $val 533 } 528 array set params $settings 529 534 530 if {$params(-color) == "auto" || $params(-color) == "autoreset"} { 535 531 # can't handle -autocolors yet -
branches/1.3/gui/scripts/vtkheightmapviewer.tcl
r3739 r3800 88 88 private method BuildDownloadPopup { widget command } 89 89 private method Combo { option } 90 private method ConvertToVtkData { dataobj comp }91 90 private method DrawLegend {} 92 91 private method EnterLegend { x y } … … 389 388 390 389 set _image(download) [image create photo] 391 puts stderr "args=$args"392 390 eval itk_initialize $args 393 391 Connect … … 484 482 set params(-description) "" 485 483 set params(-param) "" 486 foreach {opt val} $settings { 487 if {![info exists params($opt)]} { 488 error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]" 489 } 490 set params($opt) $val 491 } 484 array set params $settings 485 492 486 if {$params(-color) == "auto" || $params(-color) == "autoreset"} { 493 487 # can't handle -autocolors yet … … 2172 2166 foreach comp [$dataobj components] { 2173 2167 set tag $dataobj-$comp 2174 #set contents [ConvertToVtkData $dataobj $comp]2175 2168 set contents [$dataobj vtkdata $comp] 2176 append bytes "$contents\n \n"2169 append bytes "$contents\n" 2177 2170 } 2178 2171 } -
branches/1.3/gui/scripts/vtkisosurfaceviewer.tcl
r3780 r3800 533 533 set params(-description) "" 534 534 set params(-param) "" 535 foreach {opt val} $settings { 536 if {![info exists params($opt)]} { 537 error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]" 538 } 539 set params($opt) $val 540 } 535 array set params $settings 536 541 537 if {$params(-color) == "auto" || $params(-color) == "autoreset"} { 542 538 # can't handle -autocolors yet -
branches/1.3/gui/scripts/vtkstreamlinesviewer.tcl
r3765 r3800 561 561 set params(-description) "" 562 562 set params(-param) "" 563 foreach {opt val} $settings { 564 if {![info exists params($opt)]} { 565 error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]" 566 } 567 set params($opt) $val 568 } 563 array set params $settings 564 569 565 if {$params(-color) == "auto" || $params(-color) == "autoreset"} { 570 566 # can't handle -autocolors yet -
branches/1.3/gui/scripts/vtkviewer.tcl
r3785 r3800 94 94 private method EventuallySetBondScale { args } 95 95 private method EventuallySetMoleculeOpacity { args } 96 private method EventuallySetMoleculeQuality { args } 96 97 private method EventuallySetPolydataOpacity { args } 97 98 private method EventuallyResize { w h } … … 109 110 private method SetLegendTip { x y } 110 111 private method SetMoleculeOpacity {} 112 private method SetMoleculeQuality {} 111 113 private method SetObjectStyle { dataobj comp } 112 114 private method SetOpacity { dataset } … … 152 154 private variable _bondScalePending 0 153 155 private variable _moleculeOpacityPending 0 156 private variable _moleculeQualityPending 0 154 157 private variable _polydataOpacityPending 0 155 158 private variable _glyphsOpacityPending 0 … … 203 206 $_dispatcher dispatch $this !moleculeOpacity \ 204 207 "[itcl::code $this SetMoleculeOpacity]; list" 208 209 # Molecule quality event 210 $_dispatcher register !moleculeQuality 211 $_dispatcher dispatch $this !moleculeQuality \ 212 "[itcl::code $this SetMoleculeQuality]; list" 205 213 206 214 # Polydata opacity event … … 259 267 array set _settings [subst { 260 268 legend 1 269 glyphs-opacity 100 270 glyphs-wireframe 0 261 271 polydata-edges 0 262 272 polydata-lighting 1 263 polydata-opacity 40273 polydata-opacity 100 264 274 polydata-palette rainbow 265 275 polydata-visible 1 266 276 polydata-wireframe 0 267 molecule-atomscale 1.0268 molecule-bondscale 1.0277 molecule-atomscale 0.3 278 molecule-bondscale 0.075 269 279 molecule-atoms-visible 1 270 280 molecule-bonds-visible 1 … … 274 284 molecule-opacity 100 275 285 molecule-palette elementDefault 286 molecule-quality 1.0 276 287 molecule-representation "Ball and Stick" 288 molecule-rscale "covalent" 277 289 molecule-visible 1 278 290 molecule-wireframe 0 … … 497 509 } 498 510 511 itcl::body Rappture::VtkViewer::SetMoleculeQuality {} { 512 SendCmd [subst {molecule aquality $_settings(molecule-quality) 513 molecule bquality $_settings(molecule-quality)}] 514 set _moleculeQualityPending 0 515 } 516 499 517 itcl::body Rappture::VtkViewer::SetPolydataOpacity {} { 500 518 set _polydataOpacityPending 0 … … 525 543 set _moleculeOpacityPending 1 526 544 $_dispatcher event -after $_scaleDelay !moleculeOpacity 545 } 546 } 547 548 itcl::body Rappture::VtkViewer::EventuallySetMoleculeQuality { args } { 549 if { !$_moleculeQualityPending } { 550 set _moleculeQualityPending 1 551 $_dispatcher event -after $_scaleDelay !moleculeQuality 527 552 } 528 553 } … … 556 581 set params(-description) "" 557 582 set params(-param) "" 558 foreach {opt val} $settings { 559 if {![info exists params($opt)]} { 560 error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]" 561 } 562 set params($opt) $val 563 } 583 array set params $settings 584 564 585 if {$params(-color) == "auto" || $params(-color) == "autoreset"} { 565 586 # can't handle -autocolors yet … … 1368 1389 if { $type == "polydata" } { 1369 1390 ChangeColormap $dataobj $comp $palette 1391 #SendCmd "polydata colormode scalar {} $dataset" 1370 1392 } 1371 1393 } … … 1445 1467 switch -- $value { 1446 1468 "ballandstick" { 1447 set rscalecovalent1469 set _settings(molecule-rscale) covalent 1448 1470 set _settings(molecule-atoms-visible) 1 1449 1471 set _settings(molecule-bonds-visible) 1 … … 1453 1475 } 1454 1476 "balls" - "spheres" { 1455 set rscalecovalent1477 set _settings(molecule-rscale) covalent 1456 1478 set _settings(molecule-atoms-visible) 1 1457 1479 set _settings(molecule-bonds-visible) 0 … … 1461 1483 } 1462 1484 "sticks" { 1463 set rscalenone1485 set _settings(molecule-rscale) none 1464 1486 set _settings(molecule-atoms-visible) 1 1465 1487 set _settings(molecule-bonds-visible) 1 … … 1469 1491 } 1470 1492 "spacefilling" { 1471 set rscalevan_der_waals1493 set _settings(molecule-rscale) van_der_waals 1472 1494 set _settings(molecule-atoms-visible) 1 1473 1495 set _settings(molecule-bonds-visible) 0 … … 1477 1499 } 1478 1500 "rods" { 1479 set rscalenone1501 set _settings(molecule-rscale) none 1480 1502 set _settings(molecule-atoms-visible) 1 1481 1503 set _settings(molecule-bonds-visible) 1 … … 1485 1507 } 1486 1508 "wireframe" - "lines" { 1487 set rscalenone1509 set _settings(molecule-rscale) none 1488 1510 set _settings(molecule-atoms-visible) 0 1489 1511 set _settings(molecule-bonds-visible) 1 … … 1496 1518 } 1497 1519 } 1520 $itk_component(rscale) value [$itk_component(rscale) label $_settings(molecule-rscale)] 1521 switch -- $value { 1522 "ballandstick" - "balls" - "spheres" { 1523 $itk_component(rscale) configure -state normal 1524 } 1525 default { 1526 $itk_component(rscale) configure -state disabled 1527 } 1528 } 1498 1529 foreach dataset [CurrentDatasets -visible $_first] { 1499 1530 foreach {dataobj comp} [split $dataset -] break 1500 1531 set type [$dataobj type $comp] 1501 1532 if { $type == "molecule" } { 1502 SendCmd [subst {molecule rscale $ rscale$dataset1533 SendCmd [subst {molecule rscale $_settings(molecule-rscale) $dataset 1503 1534 molecule ascale $_settings(molecule-atomscale) $dataset 1504 1535 molecule bscale $_settings(molecule-bondscale) $dataset … … 1506 1537 molecule atoms $_settings(molecule-atoms-visible) $dataset 1507 1538 molecule bonds $_settings(molecule-bonds-visible) $dataset}] 1539 } 1540 } 1541 } 1542 "molecule-rscale" { 1543 set value [$itk_component(rscale) value] 1544 set value [$itk_component(rscale) translate $value] 1545 set _settings(molecule-rscale) $value 1546 foreach dataset [CurrentDatasets -visible $_first] { 1547 foreach {dataobj comp} [split $dataset -] break 1548 set type [$dataobj type $comp] 1549 if { $type == "molecule" } { 1550 SendCmd [subst {molecule rscale $_settings(molecule-rscale) $dataset}] 1508 1551 } 1509 1552 } … … 1864 1907 -showvalue off \ 1865 1908 -command [itcl::code $this AdjustSetting polydata-opacity] 1909 $inner.opacity set $_settings(polydata-opacity) 1866 1910 1867 1911 blt::table $inner \ … … 2188 2232 [itcl::code $this AdjustSetting molecule-representation] 2189 2233 $inner.rep value "Ball and Stick" 2234 2235 label $inner.rscale_l -text "Atom Radii" \ 2236 -font "Arial 9" 2237 2238 itk_component add rscale { 2239 Rappture::Combobox $inner.rscale -width 20 -editable no 2240 } 2241 $inner.rscale choices insert end \ 2242 "atomic" "Atomic" \ 2243 "covalent" "Covalent" \ 2244 "van_der_waals" "VDW" \ 2245 "none" "Constant" 2246 2247 bind $inner.rscale <<Value>> \ 2248 [itcl::code $this AdjustSetting molecule-rscale] 2249 $inner.rscale value "Covalent" 2190 2250 2191 2251 label $inner.palette_l -text "Palette" -font "Arial 9" … … 2235 2295 label $inner.atomscale_l -text "Atom Scale" -font "Arial 9" 2236 2296 ::scale $inner.atomscale -width 15 -font "Arial 7" \ 2237 -from 0.0 -to 2.0 -resolution 0.05 -label "" \2297 -from 0.025 -to 2.0 -resolution 0.025 -label "" \ 2238 2298 -showvalue true -orient horizontal \ 2239 -command [itcl::code $this Eventually AtomScale] \2299 -command [itcl::code $this EventuallySetAtomScale] \ 2240 2300 -variable [itcl::scope _settings(molecule-atomscale)] 2241 2301 $inner.atomscale set $_settings(molecule-atomscale) 2242 2302 Rappture::Tooltip::for $inner.atomscale \ 2243 "Adjust scale of atoms (spheres or balls). 1.0 is the full VDW radius."2303 "Adjust relative scale of atoms (spheres or balls)." 2244 2304 2245 2305 label $inner.bondscale_l -text "Bond Scale" -font "Arial 9" 2246 2306 ::scale $inner.bondscale -width 15 -font "Arial 7" \ 2247 -from 0.0 -to 1.0 -resolution 0.025 -label "" \2307 -from 0.005 -to 0.3 -resolution 0.005 -label "" \ 2248 2308 -showvalue true -orient horizontal \ 2249 -command [itcl::code $this Eventually BondScale] \2309 -command [itcl::code $this EventuallySetBondScale] \ 2250 2310 -variable [itcl::scope _settings(molecule-bondscale)] 2251 2311 Rappture::Tooltip::for $inner.bondscale \ … … 2258 2318 -width 15 -font "Arial 7" \ 2259 2319 -showvalue on \ 2260 -command [itcl::code $this EventuallyMoleculeOpacity] 2320 -command [itcl::code $this EventuallySetMoleculeOpacity] 2321 2322 label $inner.quality_l -text "Quality" -font "Arial 9" 2323 ::scale $inner.quality -width 15 -font "Arial 7" \ 2324 -from 0.0 -to 10.0 -resolution 0.1 -label "" \ 2325 -showvalue true -orient horizontal \ 2326 -command [itcl::code $this EventuallySetMoleculeQuality] \ 2327 -variable [itcl::scope _settings(molecule-quality)] 2328 Rappture::Tooltip::for $inner.quality \ 2329 "Adjust tesselation quality" 2330 $inner.quality set $_settings(molecule-quality) 2261 2331 2262 2332 blt::table $inner \ 2263 0,0 $inner.molecule -anchor w -pady {1 0} \ 2264 1,0 $inner.label -anchor w -pady {1 0} \ 2265 2,0 $inner.edges -anchor w -pady {1 0} \ 2266 3,0 $inner.rep_l -anchor w -pady { 2 0 } \ 2267 4,0 $inner.rep -fill x -pady 2 \ 2268 5,0 $inner.palette_l -anchor w -pady 0 \ 2269 6,0 $inner.palette -fill x -padx 2 \ 2270 7,0 $inner.atomscale_l -anchor w -pady {3 0} \ 2271 8,0 $inner.atomscale -fill x -padx 2 \ 2272 9,0 $inner.bondscale_l -anchor w -pady {3 0} \ 2273 10,0 $inner.bondscale -fill x -padx 2 \ 2274 11,0 $inner.opacity_l -anchor w -pady {3 0} \ 2275 12,0 $inner.opacity -fill x -padx 2 2333 0,0 $inner.molecule -anchor w -pady {1 0} \ 2334 1,0 $inner.label -anchor w -pady {1 0} \ 2335 2,0 $inner.edges -anchor w -pady {1 0} \ 2336 3,0 $inner.rep_l -anchor w -pady { 2 0 } \ 2337 4,0 $inner.rep -fill x -pady 2 \ 2338 5,0 $inner.rscale_l -anchor w -pady { 2 0 } \ 2339 6,0 $inner.rscale -fill x -pady 2 \ 2340 7,0 $inner.palette_l -anchor w -pady 0 \ 2341 8,0 $inner.palette -fill x -padx 2 \ 2342 9,0 $inner.atomscale_l -anchor w -pady {3 0} \ 2343 10,0 $inner.atomscale -fill x -padx 2 \ 2344 11,0 $inner.bondscale_l -anchor w -pady {3 0} \ 2345 12,0 $inner.bondscale -fill x -padx 2 \ 2346 13,0 $inner.opacity_l -anchor w -pady {3 0} \ 2347 14,0 $inner.opacity -fill x -padx 2 \ 2348 15,0 $inner.quality_l -anchor w -pady {3 0} \ 2349 16,0 $inner.quality -fill x -padx 2 2276 2350 2277 2351 blt::table configure $inner r* -resize none 2278 blt::table configure $inner r1 3-resize expand2352 blt::table configure $inner r17 -resize expand 2279 2353 } 2280 2354 … … 2418 2492 "molecule" { 2419 2493 SendCmd "molecule add $tag" 2420 SendCmd "molecule rscale van_der_waals $tag"2421 2494 set _haveMolecules 1 2422 2495 } 2423 2496 "polydata" { 2424 2497 array set settings { 2425 -color \# 6666FF2498 -color \#FFFFFF 2426 2499 -edges 1 2427 2500 -edgecolor black … … 2444 2517 SendCmd "polydata linewidth $settings(-linewidth) $tag" 2445 2518 SendCmd "polydata opacity $settings(-opacity) $tag" 2446 set _settings(polydata-opacity) $settings(-opacity)2519 set _settings(polydata-opacity) [expr 100.0 * $settings(-opacity)] 2447 2520 SendCmd "polydata wireframe $settings(-wireframe) $tag" 2448 2521 set _settings(polydata-wireframe) $settings(-wireframe) -
branches/1.3/gui/scripts/vtkvolumeviewer.tcl
r3765 r3800 531 531 set params(-description) "" 532 532 set params(-param) "" 533 foreach {opt val} $settings { 534 if {![info exists params($opt)]} { 535 error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]" 536 } 537 set params($opt) $val 538 } 533 array set params $settings 534 539 535 if {$params(-color) == "auto" || $params(-color) == "autoreset"} { 540 536 # can't handle -autocolors yet -
branches/1.3/gui/scripts/xylegend.tcl
r3785 r3800 86 86 private method Raise { args } 87 87 private method PopupMenu { x y } 88 private method Recolor {}89 88 private method Rename {} 90 89 private method SelectAll {} … … 159 158 delete "" 160 159 rename "" 161 recolor ""162 160 } 163 161 foreach { but icon} $commands { … … 177 175 grid $controls.rename -column 1 -row 2 -sticky w 178 176 grid $controls.delete -column 1 -row 3 -sticky w 179 grid $controls.recolor -column 1 -row 4 -sticky w180 177 181 178 grid columnconfigure $controls 0 -weight 1 … … 396 393 set nodes [$itk_component(legend) curselection] 397 394 foreach n { hide show toggle raise lower 398 rename average difference delete recolor} {395 rename average difference delete } { 399 396 $itk_component(controls).$n configure -state disabled 400 397 } … … 414 411 } 415 412 1 { 416 foreach n { hide show toggle rename recolor} {413 foreach n { hide show toggle rename } { 417 414 $itk_component(controls).$n configure -state normal 418 415 } 419 416 } 420 417 2 { 421 foreach n { hide show toggle difference average recolor} {418 foreach n { hide show toggle difference average } { 422 419 $itk_component(controls).$n configure -state normal 423 420 } 424 421 } 425 422 default { 426 foreach n { hide show toggle average recolor} {423 foreach n { hide show toggle average } { 427 424 $itk_component(controls).$n configure -state normal 428 425 } … … 551 548 552 549 553 itcl::body Rappture::XyLegend::Recolor {} {554 set nodes [$itk_component(legend) curselection]555 if { $nodes == "" } {556 return557 }558 foreach node $nodes {559 set elem [$_tree label $node]560 if { $_lastColorIndex == 0 } {561 set _lastColorIndex [llength $_autocolors]562 }563 incr _lastColorIndex -1564 set color [lindex $_autocolors $_lastColorIndex]565 if { [$_graph element type $elem] == "bar" } {566 $_graph element configure $elem -background $color \567 -foreground $color568 } else {569 $_graph element configure $elem -color $color570 }571 set im [$itk_component(legend) entry cget $node -icon]572 $_graph legend icon $elem $im573 }574 }575 576 550 itcl::body Rappture::XyLegend::UnmapHidden {} { 577 551 $_graph configure -unmaphiddenelements $_unmapHidden -
branches/1.3/gui/scripts/xyresult.tcl
r3785 r3800 71 71 itk_option define -autocolors autoColors AutoColors "" 72 72 73 private variable _viewable ""; # Display list for widget. 73 private variable _viewable ""; # Display list for widget. 74 private variable _dispatcher ""; # Dispatcher for !events 75 private variable _dlist ""; # List of dataobj objects 76 private variable _dataobj2raise; # Maps dataobj => raise flag 0/1 77 private variable _dataobj2desc; # Maps dataobj => description of data 78 private variable _dataobj2sim; # Maps dataobj => type of graph element 79 private variable _elem2comp; # Maps graph element => dataobj 80 private variable _comp2elem; # Maps graph element => dataobj 81 private variable _label2axis; # Maps axis label => axis ID 82 private variable _limits; # Axis limits: x-min, x-max, etc. 83 private variable _nextColorIndex 0; # Index for next "-color auto" 84 private variable _hilite; # Info for element currently highlighted 85 private variable _axis; # Info for axis manipulations 86 private variable _axisPopup; # Info for axis being edited in popup 87 common _downloadPopup; # Download options from popup 88 private variable _markers 89 private variable _nextElement 0 90 74 91 constructor {args} { 75 92 # defined below … … 99 116 protected method LeaveMarker { g name } 100 117 101 private variable _dispatcher "" ;# dispatcher for !events 102 private variable _dlist "" ;# list of dataobj objects 103 private variable _dataobj2color ;# maps dataobj => plotting color 104 private variable _dataobj2width ;# maps dataobj => line width 105 private variable _dataobj2dashes ;# maps dataobj => BLT -dashes list 106 private variable _dataobj2raise ;# maps dataobj => raise flag 0/1 107 private variable _dataobj2desc ;# maps dataobj => description of data 108 private variable _dataobj2type ;# maps dataobj => type of graph element 109 private variable _dataobj2barwidth ;# maps dataobj => type of graph element 110 private variable _elem2comp ;# maps graph element => dataobj 111 private variable _comp2elem ;# maps graph element => dataobj 112 private variable _label2axis ;# maps axis label => axis ID 113 private variable _limits ;# axis limits: x-min, x-max, etc. 114 private variable _autoColorI 0 ;# index for next "-color auto" 115 private variable _hilite ;# info for element currently highlighted 116 private variable _axis ;# info for axis manipulations 117 private variable _axisPopup ;# info for axis being edited in popup 118 common _downloadPopup ;# download options from popup 119 private variable _markers 120 private variable _nextElement 0 121 122 private method BuildElements { dlist } 118 119 private method BuildGraph { dlist } 123 120 private method BuildMarkers { dataobj elem } 124 121 private method FormatAxis { axis w value } … … 127 124 private method ShowAxisPopup { axis } 128 125 private method SetAxis { setting } 126 private method SetElements { dataobj {settings ""} } 129 127 private method SetAxisRangeState { axis } 130 128 } … … 232 230 # ---------------------------------------------------------------------- 233 231 itcl::body Rappture::XyResult::add {dataobj {settings ""}} { 234 #puts stderr "XyResult::add dataobj=$dataobj settings=$settings" 235 array set params { 236 -color auto 237 -brightness 0 238 -width 1 239 -barwidth 1 240 -raise 0 241 -type "line" 242 -linestyle solid 243 -description "" 244 -param "" 245 } 246 # Override the defaults with first the <style> specified and then the 247 # settings list passed into this routoue. 248 array set params [$dataobj hints style] 249 set type [$dataobj hints type] 250 if { $type == "" } { 251 set type "line" 252 } 253 foreach {opt val} $settings { 254 if {![info exists params($opt)]} { 255 error "bad setting \"$opt\": should be [join [lsort [array names params]] {, }]" 256 } 257 set params($opt) $val 258 } 259 260 # if type is set to "scatter", then override the width 261 if { $type == "scatter" } { 262 set params(-width) 0 263 } 264 # if the color is "auto", then select a color from -autocolors 265 if { $params(-color) == "auto" || $params(-color) == "autoreset" } { 266 if {$params(-color) == "autoreset"} { 267 set _autoColorI 0 268 } 269 set color [lindex $itk_option(-autocolors) $_autoColorI] 232 #puts stderr "add: dataobj=$dataobj settings=$settings" 233 set g $itk_component(plot) 234 SetElements $dataobj $settings 235 236 array set attrs $settings 237 238 # Colors have to be set/reset here because of "-brightness" and "auto". 239 # Colors can't be overriden by the user. 240 241 # If the color is "auto", then select a color from -autocolors 242 if { ![info exists attrs(-color)] } { 243 set color "auto" 244 } else { 245 set color $attrs(-color) 246 } 247 if { $color == "auto" || $color == "autoreset" } { 248 if { $color == "autoreset" } { 249 set _nextColorIndex 0 250 } 251 set color [lindex $itk_option(-autocolors) $_nextColorIndex] 270 252 if { "" == $color} { 271 253 set color black 272 254 } 273 set params(-color) $color 274 # set up for next auto color 275 if {[incr _autoColorI] >= [llength $itk_option(-autocolors)]} { 276 set _autoColorI 0 277 } 278 } 279 280 # convert -linestyle to BLT -dashes 281 switch -- $params(-linestyle) { 282 dashed { set params(-linestyle) {4 4} } 283 dotted { set params(-linestyle) {2 4} } 284 default { set params(-linestyle) {} } 285 } 286 287 # if -brightness is set, then update the color 288 if {$params(-brightness) != 0} { 289 set params(-color) [Rappture::color::brightness \ 290 $params(-color) $params(-brightness)] 255 # Set up for next auto color 256 incr _nextColorIndex 257 if { $_nextColorIndex >= [llength $itk_option(-autocolors)] } { 258 set _nextColorIndex 0 259 } 260 } 261 # If -brightness is set, then update the color. 262 if { [info exists attrs(-brightness)] } { 263 set brightness $attrs(-brightness) 264 set color [Rappture::color::brightness $color $brightness] 291 265 set bg [$itk_component(plot) cget -plotbackground] 292 266 foreach {h s v} [Rappture::color::RGBtoHSV $bg] break 293 267 if {$v > 0.5} { 294 set params(-color) [Rappture::color::brightness_max \ 295 $params(-color) 0.8] 268 set color [Rappture::color::brightness_max $color 0.8] 296 269 } else { 297 set params(-color) [Rappture::color::brightness_min \ 298 $params(-color) 0.2] 299 } 300 } 301 302 set _dataobj2raise($dataobj) $params(-raise) 303 304 set g $itk_component(plot) 305 set color $params(-color) 306 set lwidth $params(-width) 307 set dashes $params(-linestyle) 308 set raise $params(-raise) 309 set desc $params(-description) 310 set barwidth $params(-barwidth) 311 foreach {mapx mapy} [GetAxes $dataobj] break 312 foreach comp [$dataobj components] { 313 set tag $dataobj-$comp 314 if { [info exists _comp2elem($tag)] } { 315 set elem $_comp2elem($tag) 316 # Ignore -type, it's already been set 317 switch -- [$g element type $elem] { 318 "line" - "scatter" { 319 $g line configure $elem \ 320 -linewidth $lwidth \ 321 -dashes $dashes -hide no 322 } "bar" { 323 $g bar configure $elem \ 324 -barwidth $barwidth \ 325 -hide no 326 } 327 } 270 set color [Rappture::color::brightness_min $color 0.2] 271 } 272 } 273 set type [$dataobj hints type] 274 foreach cname [$dataobj components] { 275 set tag $dataobj-$cname 276 set elem $_comp2elem($tag) 277 if { $type == "bar" } { 278 $g bar configure $elem -foreground $color -background $color \ 279 -hide no 328 280 } else { 329 set elem "$type[incr _nextElement]" 330 set label [$dataobj hints label] 331 set _elem2comp($elem) $tag 332 set _comp2elem($tag) $elem 333 lappend label2elem($label) $elem 334 set xv [$dataobj mesh $comp] 335 set yv [$dataobj values $comp] 336 switch -- $type { 337 "line" { 338 if {([$xv length] <= 1) || ($lwidth == 0)} { 339 set sym square 340 set pixels 2 341 } else { 342 set sym "" 343 set pixels 6 344 } 345 $g element create $elem -x $xv -y $yv \ 346 -symbol $sym -pixels $pixels -linewidth $lwidth \ 347 -label $label \ 348 -color $color -dashes $dashes \ 349 -mapx $mapx -mapy $mapy -hide no 350 } 351 "scatter" { 352 $g element create $elem -x $xv -y $yv \ 353 -symbol square -pixels 2 -linewidth $lwidth \ 354 -label $label \ 355 -color $color -dashes $dashes \ 356 -mapx $mapx -mapy $mapy -hide no 357 } 358 "bar" { 359 $g bar create $elem -x $xv -y $yv \ 360 -barwidth $barwidth \ 361 -label $label \ 362 -color $color \ 363 -mapx $mapx -mapy $mapy 364 } 365 } 281 $g line configure $elem -color $color -hide no 366 282 } 367 283 if { [lsearch $_viewable $elem] < 0 } { … … 442 358 #puts stderr "XyResult::scale args=$args" 443 359 set _dlist $args 444 Build Elements$args360 BuildGraph $args 445 361 } 446 362 … … 653 569 # Fix duplicate labels by appending the simulation number 654 570 # Collect the labels from all the viewable elements. 571 set above {} 572 set below {} 655 573 foreach elem $_viewable { 656 574 foreach {dataobj cname} [split $_elem2comp($elem) -] break … … 669 587 } 670 588 foreach {dataobj cname} [split $_elem2comp($elem) -] break 671 regexp {^::curve(?:Value)?([0-9]+)$} $dataobj match suffix 672 incr suffix 673 set elabel [format "%s \#%d" $label $suffix] 589 set sim $_dataobj2sim($dataobj) 590 set elabel [format "%s \#%d" $label $sim] 674 591 $g element configure $elem -label $elabel 675 592 } … … 1163 1080 } 1164 1081 } 1165 if {$_ autoColorI>= [llength $itk_option(-autocolors)]} {1166 set _ autoColorI01082 if {$_nextColorIndex >= [llength $itk_option(-autocolors)]} { 1083 set _nextColorIndex 0 1167 1084 } 1168 1085 } … … 1519 1436 1520 1437 # 1521 # Build Elements--1438 # BuildGraph -- 1522 1439 # 1523 1440 # This procedure loads each data objects specified into the … … 1527 1444 # for all datasets, even those not currently being displayed. 1528 1445 # 1529 itcl::body Rappture::XyResult::Build Elements{ dlist } {1446 itcl::body Rappture::XyResult::BuildGraph { dlist } { 1530 1447 set g $itk_component(plot) 1531 1448 … … 1622 1539 } 1623 1540 1624 # Create data elements and markers, but mark them as hidden.1625 # The "add" method will un-hide them.1626 set count 01627 1541 foreach dataobj $dlist { 1628 set label [$dataobj hints label] 1629 array set params [$dataobj hints style] 1630 set type [$dataobj hints type] 1631 # Default 1632 if {[info exists params(-color)]} { 1633 set color params(-color) 1542 SetElements $dataobj 1543 } 1544 ResetLegend 1545 } 1546 1547 # 1548 # SetElements -- 1549 # 1550 # This procedure loads each data objects specified into the 1551 # graph. The data object may already be loaded (from the "add" 1552 # method which gets called first). The graph elements that 1553 # are created, are hidden. This allows the graph to account 1554 # for all datasets, even those not currently being displayed. 1555 # 1556 itcl::body Rappture::XyResult::SetElements { dataobj {settings ""} } { 1557 set g $itk_component(plot) 1558 1559 array set attrs [$dataobj hints style] 1560 array set attrs $settings 1561 set type [$dataobj hints type] 1562 if { $type == "" } { 1563 set type "line" 1564 } 1565 1566 # Now fix attributes to a more usable form for the graph. 1567 1568 # Convert -linestyle to BLT -dashes 1569 if { ![info exists attrs(-linestyle)] } { 1570 set dashes {} 1571 } else { 1572 switch -- $attrs(-linestyle) { 1573 dashed { set dashes {4 4} } 1574 dotted { set dashes {2 4} } 1575 default { set dashes {} } 1576 } 1577 } 1578 if { ![info exists attrs(-barwidth)] } { 1579 set barwidth 1.0 1580 } else { 1581 set barwidth $attrs(-barwidth) 1582 } 1583 if { ![info exists attrs(-width)] } { 1584 set linewidth 1 1585 } else { 1586 set linewidth $attrs(-width) 1587 } 1588 if { ![info exists attrs(-raise)] } { 1589 set raise 0 1590 } else { 1591 set raise $attrs(-raise) 1592 } 1593 if { ![info exists attrs(-simulation)] } { 1594 set sim 0 1595 } else { 1596 set sim $attrs(-simulation) 1597 } 1598 1599 foreach {mapx mapy} [GetAxes $dataobj] break 1600 set label [$dataobj hints label] 1601 1602 foreach cname [$dataobj components] { 1603 set tag $dataobj-$cname 1604 set xv [$dataobj mesh $cname] 1605 set yv [$dataobj values $cname] 1606 1607 if {([$xv length] <= 1) || ($linewidth == 0)} { 1608 set sym square 1609 set pixels 2 1634 1610 } else { 1635 set color black 1636 } 1637 if { $type == "" } { 1638 set type "line" 1639 } 1640 if {[info exists parmas(-barwidth)]} { 1641 set barwidth $params(-barwidth) 1642 } else { 1643 set barwidth 1.0 1644 } 1645 if {[info exists params(-width)]} { 1646 set lwidth $params(-width) 1647 } else { 1648 set lwidth 2 1649 } 1650 if {[info exists params(-linestyle)]} { 1651 set dashes $parmas(-linestyle) 1652 } else { 1653 set dashes "" 1654 } 1655 foreach {mapx mapy} [GetAxes $dataobj] break 1656 foreach comp [$dataobj components] { 1657 set tag $dataobj-$comp 1658 if { [info exists _comp2elem($tag)] } { 1659 set found($_comp2elem($tag)) 1 1660 lappend label2elem($label) $_comp2elem($tag) 1661 # Element already created for data object/component. 1662 continue 1663 } 1664 set xv [$dataobj mesh $comp] 1665 set yv [$dataobj values $comp] 1666 1667 if {([$xv length] <= 1) || ($lwidth == 0)} { 1668 set sym square 1669 set pixels 2 1670 } else { 1671 set sym "" 1672 set pixels 6 1673 } 1611 set sym "" 1612 set pixels 6 1613 } 1614 if { ![info exists _comp2elem($tag)] } { 1674 1615 set elem "$type[incr _nextElement]" 1675 1616 set _elem2comp($elem) $tag … … 1678 1619 lappend label2elem($label) $elem 1679 1620 switch -- $type { 1680 "line" - "scatter"{1621 "line" { 1681 1622 $g line create $elem \ 1682 1623 -x $xv -y $yv \ 1683 1624 -symbol $sym \ 1684 1625 -pixels $pixels \ 1685 -linewidth $l width \1626 -linewidth $linewidth \ 1686 1627 -label $label \ 1687 -color $color \1688 1628 -dashes $dashes \ 1689 1629 -mapx $mapx \ 1690 1630 -mapy $mapy \ 1691 1631 -hide yes 1692 } "bar" { 1632 } 1633 "scatter" { 1634 $g line create $elem \ 1635 -x $xv -y $yv \ 1636 -symbol square \ 1637 -pixels 2 \ 1638 -linewidth 0 \ 1639 -label $label \ 1640 -dashes $dashes \ 1641 -mapx $mapx \ 1642 -mapy $mapy \ 1643 -hide yes 1644 } 1645 "bar" { 1693 1646 $g bar create $elem \ 1694 1647 -x $xv -y $yv \ 1695 1648 -barwidth $barwidth \ 1696 1649 -label $label \ 1697 -foreground $color \1698 -background $color \1699 1650 -mapx $mapx \ 1700 1651 -mapy $mapy \ … … 1702 1653 } 1703 1654 } 1704 if { [$dataobj info class] == "Rappture::Curve" } { 1705 BuildMarkers $dataobj $elem 1706 } 1707 } 1708 } 1709 foreach elem [$g element names] { 1710 if { ![info exists found($elem)] } { 1711 $g element delete $elem 1712 } 1713 } 1714 ResetLegend 1715 } 1655 } else { 1656 set elem $_comp2elem($tag) 1657 switch -- $type { 1658 "line" { 1659 $g line configure $elem \ 1660 -symbol $sym \ 1661 -pixels $pixels \ 1662 -linewidth $linewidth \ 1663 -dashes $dashes 1664 } 1665 "bar" { 1666 $g bar configure $elem \ 1667 -barwidth $barwidth \ 1668 -label $label 1669 } 1670 } 1671 } 1672 set _dataobj2raise($dataobj) $raise 1673 set _dataobj2sim($dataobj) $sim 1674 } 1675 }
Note: See TracChangeset
for help on using the changeset viewer.