Changeset 3717 for trunk/gui


Ignore:
Timestamp:
Jun 27, 2013, 1:26:46 PM (11 years ago)
Author:
gah
Message:

fixes for R build, can now make clean, make

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/xyresult.tcl

    r3711 r3717  
    190190        [itcl::code $this Hilite off %x %y]
    191191
    192     # Add support for editing axes:
    193     if 0 {
    194     Rappture::Balloon $itk_component(hull).axes -title "Axis Options"
    195     set inner [$itk_component(hull).axes component inner]
    196 
    197     label $inner.labell -text "Label:"
    198     entry $inner.label -width 15 -highlightbackground $itk_option(-background)
    199 
    200     label $inner.formatl -text "Format:"
    201     Rappture::Combobox $inner.format -width 15 -editable no
    202     $inner.format choices insert end \
    203         "%.6g"  "Auto"         \
    204         "%.0f"  "X"          \
    205         "%.1f"  "X.X"          \
    206         "%.2f"  "X.XX"         \
    207         "%.3f"  "X.XXX"        \
    208         "%.6f"  "X.XXXXXX"     \
    209         "%.1e"  "X.Xe+XX"      \
    210         "%.2e"  "X.XXe+XX"     \
    211         "%.3e"  "X.XXXe+XX"    \
    212         "%.6e"  "X.XXXXXXe+XX"
    213 
    214     label $inner.rangel -text "Range:"
    215     radiobutton $inner.auto -text "automatic" \
    216         -variable [itcl::scope _axisPopup(auto)] -value 1 \
    217         -command [itcl::code $this SetAxis range]
    218     radiobutton $inner.manual -text "manual" \
    219         -variable [itcl::scope _axisPopup(auto)] -value 0 \
    220         -command [itcl::code $this SetAxis range]
    221 
    222     radiobutton $inner.loose -text "loose" \
    223         -variable [itcl::scope _axisPopup(loose)] -value 1 \
    224         -command [itcl::code $this SetAxis loose]
    225     radiobutton $inner.tight -text "tight" \
    226         -variable [itcl::scope _axisPopup(loose)] -value 0 \
    227         -command [itcl::code $this SetAxis loose]
    228 
    229     label $inner.minl -text "min"
    230     entry $inner.min \
    231         -width 15 -highlightbackground $itk_option(-background) \
    232         -textvariable [itcl::scope _axisPopup(min)]
    233     bind $inner.min <Return> [itcl::code $this SetAxis min]
    234     label $inner.maxl -text "max"
    235     entry $inner.max \
    236         -width 15 -highlightbackground $itk_option(-background) \
    237         -textvariable [itcl::scope _axisPopup(max)]
    238     bind $inner.min <Return> [itcl::code $this SetAxis max]
    239 
    240     label $inner.scalel -text "Scale:"
    241     radiobutton $inner.linear -text "linear" \
    242         -variable [itcl::scope _axisPopup(logscale)] -value 0 \
    243         -command [itcl::code $this SetAxis logscale]
    244     radiobutton $inner.log -text "logarithmic" \
    245         -variable [itcl::scope _axisPopup(logscale)] -value 1 \
    246         -command [itcl::code $this Axis SetAxis logscale]
    247 
    248     blt::table $inner \
    249         0,0 $inner.labell -anchor e \
    250         0,1 $inner.label -anchor w -fill x  -cspan 2 \
    251         1,0 $inner.formatl -anchor e \
    252         1,1 $inner.format -anchor w -fill x  -cspan 2 \
    253         2,0 $inner.scalel -anchor e \
    254         2,1 $inner.linear -anchor w \
    255         2,2 $inner.log -anchor w \
    256         3,0 $inner.rangel -anchor e \
    257         3,1 $inner.manual -anchor w \
    258         3,2 $inner.auto -anchor w \
    259         4,1 $inner.minl -anchor w \
    260         4,2 $inner.min -anchor w \
    261         5,1 $inner.maxl -anchor w \
    262         5,2 $inner.max -anchor w \
    263         6,1 $inner.loose -anchor w \
    264         6,2 $inner.tight -anchor w \
    265 
    266     foreach axis {x y} {
    267         set _axisPopup($axis-format) "%.6g"
    268     }
    269     Axis scale x linear
    270     Axis scale y linear
    271     }
    272192    $itk_component(plot) legend configure -hide yes
    273193
     
    464384    lappend allx x  ;# fix main x-axis too
    465385
    466     if 0 {
    467     foreach axis $allx {
    468         Axis scale $axis linear
    469     }
    470     }
    471386    set ally [$itk_component(plot) y2axis use]
    472387    lappend ally y  ;# fix main y-axis too
    473     if 0 {
    474     foreach axis $ally {
    475         Axis scale $axis linear
    476     }
    477     }
    478388    catch {unset _limits}
    479389    foreach dataobj $args {
     
    640550    eval $g element delete [$g element names]
    641551    eval $g marker delete [$g marker names]
     552
    642553    foreach axis [$g axis names] {
    643554        if { [$g axis cget $axis -logscale] } {
     
    878789        $g axis configure $axis -min "" -max ""
    879790    }
    880     return
    881     #
    882     # HACK ALERT!
    883     # Use this code to fix up the y-axis limits for the BLT graph.
    884     # The auto-limits don't always work well.  We want them to be
    885     # set to a "nice" number slightly above or below the min/max
    886     # limits.
    887     #
    888     # I don't get what's better about this.  It's replicating what's
    889     # in the BLT graph. It's missing pieces like handling bar elements.
    890     #
    891     foreach axis [$g axis names] {
    892         if {[info exists _limits(${axis}lin-min)]} {
    893             set log [$g axis cget $axis -logscale]
    894             if {$log} {
    895                 set min $_limits(${axis}log-min)
    896                 if {$min == 0} { set min 1 }
    897                 set max $_limits(${axis}log-max)
    898                 if {$max == 0} { set max 1 }
    899 
    900                 if {$min == $max} {
    901                     set logmin [expr {floor(log10(abs(0.9*$min)))}]
    902                     set logmax [expr {ceil(log10(abs(1.1*$max)))}]
    903                 } else {
    904                     set logmin [expr {floor(log10(abs($min)))}]
    905                     set logmax [expr {ceil(log10(abs($max)))}]
    906                     if 0 {
    907                     if {[string match y* $axis]} {
    908                         # add a little padding
    909                         set delta [expr {$logmax-$logmin}]
    910                         if {$delta == 0} { set delta 1 }
    911                         set logmin [expr {$logmin-0.05*$delta}]
    912                         set logmax [expr {$logmax+0.05*$delta}]
    913                     }
    914                     }
    915                 }
    916                 if {$logmin < -300} {
    917                     set min 1e-300
    918                 } elseif {$logmin > 300} {
    919                     set min 1e+300
    920                 } else {
    921                     set min [expr {pow(10.0,$logmin)}]
    922                 }
    923 
    924                 if {$logmax < -300} {
    925                     set max 1e-300
    926                 } elseif {$logmax > 300} {
    927                     set max 1e+300
    928                 } else {
    929                     set max [expr {pow(10.0,$logmax)}]
    930                 }
    931             } else {
    932                 set min $_limits(${axis}lin-min)
    933                 set max $_limits(${axis}lin-max)
    934 
    935                 if 0 {
    936                 if {[string match y* $axis]} {
    937                     # add a little padding
    938                     set delta [expr {$max-$min}]
    939                     set min [expr {$min-0.05*$delta}]
    940                     set max [expr {$max+0.05*$delta}]
    941                 }
    942                 }
    943             }
    944             if {$min < $max} {
    945                 $g axis configure $axis -min $min -max $max
    946             } else {
    947                 $g axis configure $axis -min "" -max ""
    948             }
    949         } else {
    950             $g axis configure $axis -min "" -max ""
    951         }
    952     }
    953791}
    954792
     
    11851023# USAGE: Axis drag <axis> <x> <y>
    11861024# USAGE: Axis release <axis> <x> <y>
    1187 #
    1188 # USAGE: Axis edit <axis>
    1189 # USAGE: Axis changed <axis> <what>
    1190 # USAGE: Axis format <axis> <widget> <value>
    1191 # USAGE: Axis scale <axis> linear|log
    11921025#
    11931026# Used internally to handle editing of the x/y axes.  The hilite
     
    13131146                if {$dx < 2 && $dy < 2} {
    13141147                    ShowAxisPopup $axis
    1315                     #Axis edit $axis
    13161148                    return
    13171149                }
     
    13261158            catch {unset _axis}
    13271159        }
    1328         edit {
    1329             if {[llength $args] != 1} {
    1330                 error "wrong # args: should be \"Axis edit axis\""
    1331             }
    1332             set axis [lindex $args 0]
    1333             set _axisPopup(current) $axis
    1334             set _axisPopup(axis) $axis
    1335             # apply last value when deactivating
    1336             $itk_component(hull).axes configure -deactivatecommand \
    1337                 [itcl::code $this Axis changed $axis focus]
    1338 
    1339             # fix axis label controls...
    1340             set inner [$itk_component(hull).axes component inner]
    1341             set label [$itk_component(plot) axis cget $axis -title]
    1342             $inner.label delete 0 end
    1343             $inner.label insert end $label
    1344             bind $inner.label <Return> \
    1345                 [itcl::code $this Axis changed $axis label]
    1346             bind $inner.label <KP_Enter> \
    1347                 [itcl::code $this Axis changed $axis label]
    1348             bind $inner.label <FocusOut> \
    1349                 [itcl::code $this Axis changed $axis label]
    1350 
    1351             # fix min/max controls...
    1352             foreach {min max} [$itk_component(plot) axis limits $axis] break
    1353             $inner.min delete 0 end
    1354             $inner.min insert end $min
    1355             bind $inner.min <Return> \
    1356                 [itcl::code $this Axis changed $axis min]
    1357             bind $inner.min <KP_Enter> \
    1358                 [itcl::code $this Axis changed $axis min]
    1359             bind $inner.min <FocusOut> \
    1360                 [itcl::code $this Axis changed $axis min]
    1361 
    1362             $inner.max delete 0 end
    1363             $inner.max insert end $max
    1364             bind $inner.max <Return> \
    1365                 [itcl::code $this Axis changed $axis max]
    1366             bind $inner.max <KP_Enter> \
    1367                 [itcl::code $this Axis changed $axis max]
    1368             bind $inner.max <FocusOut> \
    1369                 [itcl::code $this Axis changed $axis max]
    1370 
    1371             # fix format control...
    1372             set fmts [$inner.format choices get -value]
    1373             set i [lsearch -exact $fmts $_axisPopup($axis-format)]
    1374             if {$i < 0} { set i 0 }  ;# use Auto choice
    1375             $inner.format value [$inner.format choices get -label $i]
    1376 
    1377             bind $inner.format <<Value>> \
    1378                 [itcl::code $this Axis changed $axis format]
    1379 
    1380             # fix scale control...
    1381             if {[$itk_component(plot) axis cget $axis -logscale]} {
    1382                 set _axisPopup(logscale) 1
    1383                 $inner.format configure -state disabled
    1384             } else {
    1385                 set _axisPopup(logscale) 0
    1386                 $inner.format configure -state normal
    1387             }
    1388             $inner.linear configure \
    1389                 -command [itcl::code $this Axis changed $axis scale]
    1390             $inner.log configure \
    1391                 -command [itcl::code $this Axis changed $axis scale]
    1392 
    1393             #
    1394             # Figure out where the window should pop up.
    1395             #
    1396             set x [winfo rootx $itk_component(plot)]
    1397             set y [winfo rooty $itk_component(plot)]
    1398             set w [winfo width $itk_component(plot)]
    1399             set h [winfo height $itk_component(plot)]
    1400             foreach {x0 y0 pw ph} [$itk_component(plot) extents plotarea] break
    1401             switch -glob -- $axis {
    1402                 x {
    1403                     set x [expr {round($x + $x0+0.5*$pw)}]
    1404                     set y [expr {round($y + $y0+$ph + 0.5*($h-$y0-$ph))}]
    1405                     set dir "above"
    1406                 }
    1407                 x* {
    1408                     set x [expr {round($x + $x0+0.5*$pw)}]
    1409                     set dir "below"
    1410                     set allx [$itk_component(plot) x2axis use]
    1411                     set max [llength $allx]
    1412                     set i [lsearch -exact $allx $axis]
    1413                     set y [expr {round($y + ($i+0.5)*$y0/double($max))}]
    1414                 }
    1415                 y {
    1416                     set x [expr {round($x + 0.5*$x0)}]
    1417                     set y [expr {round($y + $y0+0.5*$ph)}]
    1418                     set dir "right"
    1419                 }
    1420                 y* {
    1421                     set y [expr {round($y + $y0+0.5*$ph)}]
    1422                     set dir "left"
    1423                     set ally [$itk_component(plot) y2axis use]
    1424                     set max [llength $ally]
    1425                     set i [lsearch -exact $ally $axis]
    1426                     set y [expr {round($y + ($i+0.5)*$y0/double($max))}]
    1427                     set x [expr {round($x+$x0+$pw + ($i+0.5)*($w-$x0-$pw)/double($max))}]
    1428                 }
    1429             }
    1430             $itk_component(hull).axes activate @$x,$y $dir
    1431         }
    1432         changed {
    1433             set inner [$itk_component(hull).axes component inner]
    1434             if {[llength $args] != 2} {
    1435                 error "wrong # args: should be \"Axis changed axis what\""
    1436             }
    1437             set axis [lindex $args 0]
    1438             set what [lindex $args 1]
    1439             if {$what == "focus"} {
    1440                 set what [focus]
    1441                 if {[winfo exists $what]} {
    1442                     set what [winfo name $what]
    1443                 }
    1444             }
    1445 
    1446             switch -- $what {
    1447                 label {
    1448                     set val [$inner.label get]
    1449                     $itk_component(plot) axis configure $axis -title $val
    1450                     Rappture::Logger::log curve axis $axis -title $val
    1451                 }
    1452                 min {
    1453                     set val [$inner.min get]
    1454                     if {![string is double -strict $val]} {
    1455                         Rappture::Tooltip::cue $inner.min "Must be a number"
    1456                         bell
    1457                         return
    1458                     }
    1459 
    1460                     set max [lindex [$itk_component(plot) axis limits $axis] 1]
    1461                     if {$val >= $max} {
    1462                         Rappture::Tooltip::cue $inner.min "Must be <= max ($max)"
    1463                         bell
    1464                         return
    1465                     }
    1466                     catch {
    1467                         # can fail in log mode
    1468                         $itk_component(plot) axis configure $axis -min $val
    1469                         Rappture::Logger::log curve axis $axis -min $val
    1470                     }
    1471                     foreach {min max} [$itk_component(plot) axis limits $axis] break
    1472                     $inner.min delete 0 end
    1473                     $inner.min insert end $min
    1474                 }
    1475                 max {
    1476                     set val [$inner.max get]
    1477                     if {![string is double -strict $val]} {
    1478                         Rappture::Tooltip::cue $inner.max "Should be a number"
    1479                         bell
    1480                         return
    1481                     }
    1482 
    1483                     set min [lindex [$itk_component(plot) axis limits $axis] 0]
    1484                     if {$val <= $min} {
    1485                         Rappture::Tooltip::cue $inner.max "Must be >= min ($min)"
    1486                         bell
    1487                         return
    1488                     }
    1489                     catch {
    1490                         # can fail in log mode
    1491                         $itk_component(plot) axis configure $axis -max $val
    1492                         Rappture::Logger::log curve axis $axis -max $val
    1493                     }
    1494                     foreach {min max} [$itk_component(plot) axis limits $axis] break
    1495                     $inner.max delete 0 end
    1496                     $inner.max insert end $max
    1497                 }
    1498                 format {
    1499                     set fmt [$inner.format translate [$inner.format value]]
    1500                     set _axisPopup($axis-format) $fmt
    1501 
    1502                     # force a refresh
    1503                     $itk_component(plot) axis configure $axis -min \
    1504                         [$itk_component(plot) axis cget $axis -min]
    1505                 }
    1506                 scale {
    1507                     Axis scale $axis $_axisPopup(logscale)
    1508                     Rappture::Logger::log curve axis $axis -scale $_axisPopup(logscale)
    1509 
    1510                     if { $_axisPopup(logscale) } {
    1511                         $inner.format configure -state disabled
    1512                     } else {
    1513                         $inner.format configure -state normal
    1514                     }
    1515 
    1516                     foreach {min max} [$itk_component(plot) axis limits $axis] break
    1517                     $inner.min delete 0 end
    1518                     $inner.min insert end $min
    1519                     $inner.max delete 0 end
    1520                     $inner.max insert end $max
    1521                 }
    1522                 default {
    1523                     # be lenient so we can handle the "focus" case
    1524                 }
    1525             }
    1526         }
    1527         format {
    1528             if {[llength $args] != 3} {
    1529                 error "wrong # args: should be \"Axis format axis widget value\""
    1530             }
    1531             set axis [lindex $args 0]
    1532             set value [lindex $args 2]
    1533 
    1534             if {[$itk_component(plot) axis cget $axis -logscale]} {
    1535                 set fmt "%.6g"
    1536             } else {
    1537                 set fmt $_axisPopup($axis-format)
    1538             }
    1539             return [format $fmt $value]
    1540         }
    1541         scale {
    1542             if {[llength $args] != 2} {
    1543                 error "wrong # args: should be \"Axis scale axis type\""
    1544             }
    1545             set axis [lindex $args 0]
    1546             set type [lindex $args 1]
    1547 
    1548             if {$type == "log"} {
    1549                 catch {$itk_component(plot) axis configure $axis -logscale 1}
    1550                 # leave format alone in log mode
    1551                 $itk_component(plot) axis configure $axis -command ""
    1552             } else {
    1553                 catch {$itk_component(plot) axis configure $axis -logscale 0}
    1554                 # use special formatting for linear mode
    1555                 $itk_component(plot) axis configure $axis -command \
    1556                     [itcl::code $this Axis format $axis]
    1557             }
    1558         }
    15591160        default {
    1560             error "bad option \"$option\": should be changed, edit, hilite, or format"
     1161            error "bad option \"$option\": should be hilite"
    15611162        }
    15621163    }
     
    19671568    set _axisPopup(max)   $_axisPopup($axis-max)
    19681569    set _axisPopup(axis) $axis
    1969     if 0 {
    1970     $popup configure -deactivatecommand \
    1971         [itcl::code $this Axis changed $axis focus]
    1972     }
    19731570
    19741571    #
Note: See TracChangeset for help on using the changeset viewer.