Ignore:
Timestamp:
Sep 25, 2005, 12:40:17 PM (19 years ago)
Author:
mmc
Message:

Lots of fixes for app-pntoy and other tools:

  • Fixed plotting to recognize "-color name" in the style section, and to use auto colors for overlayed plots.
  • Fixed x-y plotting to keep axes instead of resetting when flipping back and forth between plots.
  • Fixed 1D fields to support new lin/log limits queries, so it plots properly.
  • Added support for <string> output values.
  • Fixed molecular viewer so that 3D rotation is unconstrained and more intuitive.
  • Fixed Rappture::exec to handle newlines properly. Sometimes output would get all mixed together without newlines. Works better now.
File:
1 edited

Legend:

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

    r17 r64  
    180180# axis.
    181181# ----------------------------------------------------------------------
    182 itcl::body Rappture::Field::limits {axis} {
    183     foreach val {xmin xmax ymin ymax zmin zmax vmin vmax} {
    184         set results($val) ""
    185     }
     182itcl::body Rappture::Field::limits {which} {
     183    set min ""
     184    set max ""
     185
     186    blt::vector create tmp zero
    186187    foreach comp [array names _comp2dims] {
    187188        switch -- $_comp2dims($comp) {
    188189            1D {
    189                 foreach {xv yv} $_comp2xy($comp) break
    190 
    191                 $xv variable x
    192                 set lims(xmin) $x(min)
    193                 set lims(xmax) $x(max)
    194 
    195                 set lims(ymin) 0
    196                 set lims(ymax) 0
    197                 set lims(zmin) 0
    198                 set lims(zmax) 0
    199 
    200                 $yv variable v
    201                 set lims(vmin) $v(min)
    202                 set lims(vmax) $v(max)
     190                switch -- $which {
     191                    x - xlin { set pos 0; set log 0; set axis xaxis }
     192                    xlog { set pos 0; set log 1; set axis xaxis }
     193                    y - ylin - v - vlin { set pos 1; set log 0; set axis yaxis }
     194                    ylog - vlog { set pos 1; set log 1; set axis yaxis }
     195                    default {
     196                        error "bad option \"$which\": should be x, xlin, xlog, y, ylin, ylog, v, vlin, vlog"
     197                    }
     198                }
     199
     200                set vname [lindex $_comp2xy($comp) $pos]
     201                $vname variable vec
     202
     203                if {$log} {
     204                    # on a log scale, use abs value and ignore 0's
     205                    $vname dup tmp
     206                    $vname dup zero
     207                    zero expr {tmp == 0}            ;# find the 0's
     208                    tmp expr {abs(tmp)}             ;# get the abs value
     209                    tmp expr {tmp + zero*max(tmp)}  ;# replace 0's with abs max
     210                    set vmin [blt::vector expr min(tmp)]
     211                    set vmax [blt::vector expr max(tmp)]
     212                } else {
     213                    set vmin $vec(min)
     214                    set vmax $vec(max)
     215                }
     216
     217                if {"" == $min} {
     218                    set min $vmin
     219                } elseif {$vmin < $min} {
     220                    set min $vmin
     221                }
     222                if {"" == $max} {
     223                    set max $vmax
     224                } elseif {$vmax > $max} {
     225                    set max $vmax
     226                }
    203227            }
    204228            2D - 3D {
    205229                foreach {xv yv} $_comp2vtk($comp) break
    206 
    207                 foreach {lims(xmin) lims(xmax)} [$xv limits x] break
    208                 foreach {lims(ymin) lims(ymax)} [$xv limits y] break
    209                 foreach {lims(zmin) lims(zmax)} [$xv limits z] break
    210                 foreach {lims(vmin) lims(vmax)} [$yv GetRange] break
    211             }
    212         }
    213         foreach val {xmin ymin zmin vmin} {
    214             if {"" == $results($val) || $lims($val) < $results($val)} {
    215                 set results($val) $lims($val)
    216             }
    217         }
    218         foreach val {xmax ymax zmax vmax} {
    219             if {"" == $results($val) || $lims($val) > $results($val)} {
    220                 set results($val) $lims($val)
    221             }
    222         }
    223     }
    224     return [list $results(${axis}min) $results(${axis}max)]
     230                switch -- $which {
     231                    x - xlin - xlog {
     232                        foreach {vmin vmax} [$xv limits x] break
     233                        set axis xaxis
     234                    }
     235                    y - ylin - ylog {
     236                        foreach {vmin vmax} [$xv limits y] break
     237                        set axis yaxis
     238                    }
     239                    z - zlin - zlog {
     240                        foreach {vmin vmax} [$xv limits z] break
     241                        set axis zaxis
     242                    }
     243                    v - vlin - vlog {
     244                        foreach {vmin vmax} [$yv GetRange] break
     245                        set axis vaxis
     246                    }
     247                    default {
     248                        error "bad option \"$which\": should be x, xlin, xlog, y, ylin, ylog, v, vlin, vlog"
     249                    }
     250                }
     251            }
     252        }
     253        if {"" == $min} {
     254            set min $vmin
     255        } elseif {$vmin < $min} {
     256            set min $vmin
     257        }
     258        if {"" == $max} {
     259            set max $vmax
     260        } elseif {$vmax > $max} {
     261            set max $vmax
     262        }
     263    }
     264    blt::vector destroy tmp zero
     265
     266    set val [$_field get $axis.min]
     267    if {"" != $val && "" != $min} {
     268        if {$val > $min} {
     269            # tool specified this min -- don't go any lower
     270            set min $val
     271        }
     272    }
     273
     274    set val [$_field get $axis.max]
     275    if {"" != $val && "" != $max} {
     276        if {$val < $max} {
     277            # tool specified this max -- don't go any higher
     278            set max $val
     279        }
     280    }
     281
     282    return [list $min $max]
    225283}
    226284
Note: See TracChangeset for help on using the changeset viewer.