Changeset 2966


Ignore:
Timestamp:
Apr 13, 2012 12:04:37 PM (12 years ago)
Author:
gah
Message:

sync back with trunk

Location:
branches/blt4
Files:
5 added
1 deleted
59 edited

Legend:

Unmodified
Added
Removed
  • branches/blt4/Makefile.in

    r2692 r2966  
    3131
    3232ENABLE_GUI      = @ENABLE_GUI@
    33 
     33HAVE_FFMPEG     = @HAVE_FFMPEG_LIBS@
    3434TARGETS         = src lang lib
    3535
    3636ifneq ($(ENABLE_GUI),)
    3737  TARGETS += gui builder tester examples
     38endif
     39ifeq ($(HAVE_FFMEG),)
     40  TARGETS += video
    3841endif
    3942
     
    4447          $(MAKE) -C $$i all || exit 1 ;\
    4548        done
    46 test: 
     49test:
    4750        $(MAKE) -C test all
    4851
  • branches/blt4/gui/scripts/balloon.tcl

    r1923 r2966  
    3030    inherit itk::Toplevel
    3131
     32    itk_option define -background background Background ""
    3233    itk_option define -deactivatecommand deactivateCommand DeactivateCommand ""
    3334    itk_option define -dismissbutton dismissButton DismissButton "on"
     
    324325            set dark [Rappture::color::brightness $bg -0.4]
    325326            set rgb [winfo rgb . $bg]
    326             set bg [format "#%03x%03x%03x" [lindex $rgb 0] [lindex $rgb 1] [lindex $rgb 2]]
     327            set flatbg [format "#%04x%04x%04x" [lindex $rgb 0] [lindex $rgb 1] [lindex $rgb 2]]
     328            switch -- $itk_option(-relief) {
     329                raised {
     330                    set light [Rappture::color::brightness $bg 0.4]
     331                    set dark [Rappture::color::brightness $bg -0.4]
     332                    set bg $flatbg
     333                }
     334                flat - solid {
     335                    set light $flatbg
     336                    set dark $flatbg
     337                    set bg $flatbg
     338                }
     339                sunken {
     340                    set light [Rappture::color::brightness $bg -0.4]
     341                    set dark [Rappture::color::brightness $bg 0.4]
     342                    set bg $flatbg
     343                }
     344            }
     345            set bg [format "#%04x%04x%04x" [lindex $rgb 0] [lindex $rgb 1] [lindex $rgb 2]]
    327346
    328347            $_fills($dir) put $bg -to 0 0 $sw $sh
     
    485504
    486505# ----------------------------------------------------------------------
     506# CONFIGURATION OPTION: -background
     507# ----------------------------------------------------------------------
     508itcl::configbody Rappture::Balloon::background {
     509    _createStems
     510}
     511
     512# ----------------------------------------------------------------------
    487513# CONFIGURATION OPTION: -stemlength
    488514#
  • branches/blt4/gui/scripts/controlOwner.tcl

    r1923 r2966  
    5959    # in coordination with loaders inside the load function
    6060    array set _type2curpath {
     61        drawing components
    6162        choice current
    6263        boolean current
     
    6667        note contents
    6768        number current
     69        periodicelement current
    6870        string current
    6971    }
  • branches/blt4/gui/scripts/drawingentry.tcl

    r1923 r2966  
    1515itcl::class Rappture::DrawingEntry {
    1616    inherit itk::Widget
    17 
    1817    itk_option define -state state State "normal"
     18
     19    private variable _owner
     20    private variable _path
     21    private variable _cname2id
     22    private variable _worldX 0
     23    private variable _worldY 0
     24    private variable _worldWidth 0
     25    private variable _worldHeight 0
    1926
    2027    constructor {owner path args} { # defined below }
     
    2431    public method label {}
    2532    public method tooltip {}
     33
     34    private method ParseDescription {}
     35    private method ParseLineDescription { cname }
     36    private method ParseGridDescription { cname }
     37    private method ParseTextDescription { cname }
     38    private method ParseStringDescription { cname }
     39    private method ParseNumberDescription { cname }
     40    private method GetCanvasHeight { }
     41    private method GetCanvasWidth { }
     42    private method ScreenX { x }
     43    private method ScreenY { y }
     44    private method ScreenCoords { coords }
     45    private method Highlight { tag }
     46    private method Unhighlight { tag }
    2647}
    2748
     
    4162    }
    4263    set _path $path
    43 
     64    set _owner $owner
    4465    #
    4566    # Display the current drawing.
    4667    #
    4768    itk_component add drawing {
    48         Rappture::Drawing $itk_interior.drawing $owner $path
     69        canvas $itk_interior.canvas -background white -relief sunken -bd 1
     70    } {
     71        ignore -background
    4972    }
    5073    pack $itk_component(drawing) -expand yes -fill both
    51 
     74    ParseDescription
    5275    eval itk_initialize $args
    5376}
     
    128151    }
    129152}
     153
     154itcl::body Rappture::DrawingEntry::ParseLineDescription { cname } {
     155    array set attr2option {
     156        "linewidth"     "-width"
     157        "arrow"         "-arrow"
     158        "dash"          "-dash"
     159        "color"         "-fill"
     160    }
     161    # Set default options first and then let tool.xml override them.
     162    array set options {
     163        -arrow          none
     164        -width          0
     165        -fill           black
     166        -dash           ""
     167    }
     168    # Coords
     169    set coords {}
     170    set coords [$_owner xml get $_path.components.$cname.coords]
     171    set coords [string trim $coords]
     172    if { $coords == "" } {
     173        set coords "0 0"
     174    } else {
     175        set coords [ScreenCoords $coords]
     176    }
     177    puts stderr "ParseLineDescrption description owner=$_owner path=$_path coords=$coords"
     178    set list {}
     179    foreach attr [$_owner xml children $_path.components.$cname] {
     180        if { [info exists attr2option($attr)] } {
     181            set option $attr2option($attr)
     182            set value [$_owner xml get $_path.components.$cname.$attr]
     183            set options($option) $value
     184        }
     185    }
     186    puts stderr "$itk_component(drawing) create line $coords"
     187    set id [eval $itk_component(drawing) create line $coords]
     188    set _cname2id($cname) $id
     189    eval $itk_component(drawing) itemconfigure $id [array get options]
     190}
     191
     192#
     193# ParseGridDescription --
     194#
     195itcl::body Rappture::DrawingEntry::ParseGridDescription { cname } {
     196    puts stderr "ParseGridDescrption description owner=$_owner path=$_path"
     197    foreach attr [$_owner xml children $_path.components.$cname] {
     198        puts stderr attr=$attr
     199    }
     200    array set attr2option {
     201        "linewidth"     "-width"
     202        "arrow"         "-arrow"
     203        "dash"          "-dash"
     204        "color"         "-fill"
     205    }
     206    # Set default options first and then let tool.xml override them.
     207    array set options {
     208        -arrow          none
     209        -width          0
     210        -fill           black
     211        -dash           ""
     212    }
     213    # Coords
     214    set xcoords [$_owner xml get $_path.components.$cname.xcoords]
     215    set xcoords [string trim $xcoords]
     216    set ycoords [$_owner xml get $_path.components.$cname.ycoords]
     217    set ycoords [string trim $ycoords]
     218    if { $ycoords == "" } {
     219        set ycoords "0 1"
     220        set ymax 1
     221        set ymin 0
     222    } else {
     223        set list {}
     224        set ymax -10000
     225        set ymin 10000
     226        foreach c $ycoords {
     227            set y [ScreenY $c]
     228            if { $y > $ymax } {
     229                set ymax $y
     230            }
     231            if { $y < $ymin } {
     232                set ymin $y
     233            }
     234            lappend list $y
     235        }
     236        set ycoords $list
     237    }
     238    if { $xcoords == "" } {
     239        set xcoords "0 1"
     240        set xmax 1
     241        set xmin 0
     242    } else {
     243        set list {}
     244        set xmax -10000
     245        set xmin 10000
     246        foreach c $xcoords {
     247            set x [ScreenX $c]
     248            if { $x > $xmax } {
     249                set xmax $x
     250            }
     251            if { $x < $xmin } {
     252                set xmin $x
     253            }
     254            lappend list $x
     255        }
     256        set xcoords $list
     257    }
     258    puts stderr "ParseLineDescrption description owner=$_owner path=$_path xcoords=$xcoords ycoords=$ycoords"
     259    set list {}
     260    foreach attr [$_owner xml children $_path.components.$cname] {
     261        if { [info exists attr2option($attr)] } {
     262            set option $attr2option($attr)
     263            set value [$_owner xml get $_path.components.$cname.$attr]
     264            set options($option) $value
     265        }
     266    }
     267    foreach y $ycoords {
     268        lappend ids \
     269            [eval $itk_component(drawing) create line $xmin $y $xmax $y \
     270                 [array get options]]
     271    }
     272    foreach x $xcoords {
     273        lappend ids \
     274            [eval $itk_component(drawing) create line $x $ymin $x $ymax \
     275                 [array get options]]
     276    }
     277    set _cname2id($cname) $ids
     278}
     279
     280itcl::body Rappture::DrawingEntry::ParseTextDescription { cname } {
     281    array set attr2option {
     282        "font"          "-font"
     283        "default"       "-text"
     284        "color"         "-fill"
     285        "text"          "-text"
     286        "anchor"        "-anchor"
     287    }
     288    puts stderr "ParseStringDescrption description owner=$_owner path=$_path"
     289
     290    # Set default options first and then let tool.xml override them.
     291    array set options {
     292        -font {Arial 12}
     293        -text {}
     294        -fill black
     295        -anchor c
     296    }
     297    foreach attr [$_owner xml children $_path.components.$cname] {
     298        if { [info exists attr2option($attr)] } {
     299            set option $attr2option($attr)
     300            set value [$_owner xml get $_path.components.$cname.$attr]
     301            set options($option) $value
     302        }
     303    }
     304    # Coords
     305    set coords {}
     306    set coords [$_owner xml get $_path.components.$cname.coords]
     307    set coords [string trim $coords]
     308    if { $coords == "" } {
     309        set coords "0 0"
     310    } else {
     311        set coords [ScreenCoords $coords]
     312    }
     313    puts stderr "$itk_component(drawing) create text $coords"
     314    set id [eval $itk_component(drawing) create text $coords]
     315    set _cname2id($cname) $id
     316    puts stderr "$itk_component(drawing) itemconfigure $id [array get options]"
     317    eval $itk_component(drawing) itemconfigure $id [array get options]
     318}
     319
     320itcl::body Rappture::DrawingEntry::ParseStringDescription { cname } {
     321    array set attr2option {
     322        "font"          "-font"
     323        "default"       "-text"
     324        "color"         "-fill"
     325    }
     326    puts stderr "ParseStringDescrption description owner=$_owner path=$_path"
     327
     328    # Set default options first and then let tool.xml override them.
     329    array set options {
     330        -font {Arial 12}
     331        -text {}
     332        -fill black
     333    }
     334    foreach attr [$_owner xml children $_path.components.$cname] {
     335        if { [info exists attr2option($attr)] } {
     336            set option $attr2option($attr)
     337            set value [$_owner xml get $_path.components.$cname.$attr]
     338            set options($option) $value
     339        }
     340    }
     341    # Coords
     342    set coords {}
     343    set coords [$_owner xml get $_path.components.$cname.coords]
     344    set coords [string trim $coords]
     345    if { $coords == "" } {
     346        set coords "0 0"
     347    }
     348    # Is there a label?
     349    set label [$_owner xml get $_path.components.$cname.about.label]
     350    set labelWidth 0
     351    if { $label != "" } {
     352        set labelId [$itk_component(drawing) create text -1000 -1000 \
     353                         -text $label -font $options(-font)]
     354        set labelWidth [font measure $options(-font) $label]
     355    }
     356    set id [$itk_component(drawing) create text -1000 -1000  -tag $cname]
     357    set entryWidth [font measure $options(-font) $options(-text) ]
     358
     359    foreach { x y } [ScreenCoords $coords] break
     360    set lx $x
     361    set ly $y
     362    set tx [expr $x + $labelWidth]
     363    set ty $y
     364
     365    eval $itk_component(drawing) coords $id $tx $ty
     366    if { $labelWidth > 0 } {
     367        puts stderr "LABEL($labelWidth):$itk_component(drawing) coords $labelId $lx $ly"
     368        eval $itk_component(drawing) coords $labelId $lx $ly
     369    }
     370    set _cname2id($cname) $id
     371    puts stderr "$itk_component(drawing) itemconfigure $id [array get options]"
     372    eval $itk_component(drawing) itemconfigure $id [array get options]
     373    set bbox [$itk_component(drawing) bbox $id]
     374    puts stderr "cname=$cname bbox=$bbox"
     375    set sid [eval $itk_component(drawing) create rectangle $bbox]
     376    $itk_component(drawing) itemconfigure $sid -fill "" -outline "" \
     377        -tag $cname-bg
     378    set sid [eval $itk_component(drawing) create rectangle $bbox]
     379    $itk_component(drawing) itemconfigure $sid -fill "" -outline "" \
     380        -tag $cname-sensor
     381    $itk_component(drawing) bind $cname-sensor <Enter> \
     382        [itcl::code $this Highlight $cname]
     383    $itk_component(drawing) bind $cname-sensor <Leave> \
     384        [itcl::code $this Unhighlight $cname]
     385    $itk_component(drawing) lower $cname-bg
     386    $itk_component(drawing) raise $cname-sensor
     387}
     388
     389itcl::body Rappture::DrawingEntry::ParseNumberDescription { cname } {
     390    puts stderr "ParseNumberDescrption description owner=$_owner path=$_path"
     391    foreach attr [$_owner xml children $_path.components.$cname] {
     392        puts stderr attr=$attr
     393    }
     394}
     395
     396itcl::body Rappture::DrawingEntry::ScreenX { x } {
     397    set norm [expr ($x - $_worldX) / double($_worldWidth)]
     398    puts stderr "ScreenX x=$x, norm=$norm wx=$_worldX ww=$_worldWidth"
     399    set x [expr int($norm * [GetCanvasWidth])]
     400    puts stderr "ScreenX after x=$x cw=[GetCanvasWidth]"
     401    return $x
     402}
     403
     404itcl::body Rappture::DrawingEntry::ScreenY { y } {
     405    set norm [expr ($y - $_worldY) / double($_worldWidth)]
     406    set y [expr int($norm * [GetCanvasHeight])]
     407    return $y
     408}
     409
     410itcl::body Rappture::DrawingEntry::ScreenCoords { coords } {
     411    set list {}
     412    foreach {x y} $coords {
     413        lappend list [ScreenX $x] [ScreenY $y]
     414    }
     415    return $list
     416}
     417
     418itcl::body Rappture::DrawingEntry::GetCanvasWidth { } {
     419    set w [winfo width $itk_component(drawing)]
     420    if { $w < 2 } {
     421        set w [winfo reqwidth $itk_component(drawing)]
     422    }
     423    return $w
     424}
     425
     426itcl::body Rappture::DrawingEntry::GetCanvasHeight { } {
     427    set h [winfo height $itk_component(drawing)]
     428    if { $h < 2 } {
     429        set h [winfo reqheight $itk_component(drawing)]
     430    }
     431    return $h
     432}
     433
     434itcl::body Rappture::DrawingEntry::ParseDescription {} {
     435    puts stderr "ParseDescrption description owner=$_owner path=$_path"
     436    set bbox [$_owner xml get $_path.about.bbox]
     437    puts stderr bbox=$bbox
     438    if { [llength $bbox] != 4 } {
     439        set bbox "0 0 [GetCanvasWidth] [GetCanvasHeight]"
     440    }
     441    foreach { x1 y1 x2 y2 } $bbox break
     442    set _worldWidth [expr $x2 - $x1]
     443    set _worldHeight [expr $y2 - $y1]
     444    set _worldX $x1
     445    set _worldY $y1
     446    foreach cname [$_owner xml children $_path.components] {
     447        switch -glob -- $cname {
     448            "line*" {
     449                ParseLineDescription $cname
     450            }
     451            "grid*" {
     452                ParseGridDescription $cname
     453            }
     454            "text*" {
     455                ParseTextDescription $cname
     456            }
     457            "string*" {
     458                ParseStringDescription $cname
     459            }
     460            "number*" {
     461                ParseNumberDescription $cname
     462            }
     463        }
     464    }
     465}
     466
     467
     468
     469itcl::body Rappture::DrawingEntry::Highlight { tag } {
     470    $itk_component(drawing) itemconfigure $tag-bg -outline black \
     471        -fill lightblue
     472}
     473
     474itcl::body Rappture::DrawingEntry::Unhighlight { tag } {
     475    $itk_component(drawing) itemconfigure $tag-bg -outline "" \
     476        -fill ""
     477}
  • branches/blt4/gui/scripts/icons.tcl

    r2745 r2966  
    1818    variable iconpath [list [file join $RapptureGUI::library scripts images]]
    1919    variable icons
     20}
     21
     22# ----------------------------------------------------------------------
     23# USAGE: Rappture::icon::searchpath ?<dirname> <dirname>...?
     24#
     25# Adds one or more directories onto the icon path searched when
     26# locating icons in Rappture::icon.  You can do the same thing by
     27# lappend'ing onto the "iconpath" variable, but this call avoids
     28# duplicates and makes it easier
     29# ----------------------------------------------------------------------
     30proc Rappture::icon::searchpath {args} {
     31    variable iconpath
     32    foreach dir $args {
     33        if {[file isdirectory $dir]} {
     34            if {[lsearch $iconpath $dir] < 0} {
     35                lappend iconpath $dir
     36            }
     37        }
     38    }
    2039}
    2140
  • branches/blt4/gui/scripts/page.tcl

    r2327 r2966  
    7979            continue
    8080        }
    81 
    8281        if {$type == "loader"} {
    8382            #
     
    139138            #
    140139            set w "$frame.drawing[incr num]"
    141             Rappture::DrawingEntry ::$w $_owner $path.$cname.current
     140            Rappture::DrawingEntry ::$w $_owner $path.$cname
    142141            pack $w -expand yes -fill both
    143142            $_owner widgetfor $path.$cname $w
  • branches/blt4/gui/scripts/periodictable.tcl

    r2745 r2966  
    461461    set elem [FindElement $name]
    462462    if { $elem == "" || $_state($elem) == "disabled" } {
     463        if { $elem != "" } {
     464            puts stderr "element $elem is disabled"
     465        }
    463466        return ""
    464467    }
     
    608611
    609612# ----------------------------------------------------------------------
    610 # USAGE: select <name>
     613# USAGE: FindElement
    611614#
    612615# Used to manipulate the selection in the table.
     
    615618itcl::body Rappture::PeriodicTable::FindElement { what } {
    616619    foreach name [array names _table] {
     620        array unset info
    617621        array set info $_table($name)
    618622        if { $what == $info(name) || $what == $info(number) ||
    619623             $what == $info(symbol) } {
    620             break
    621         }
    622         array unset info
    623     }
    624     if { [info exists info] } {
    625         return $info(name)
     624            return $info(name)
     625        }
    626626    }
    627627    return ""
  • branches/blt4/gui/scripts/resultset.tcl

    r2791 r2966  
    4141    itk_option define -boldfont boldFont Font ""
    4242    itk_option define -foreground foreground Foreground ""
    43     itk_option define -missingdata missingData MissingData ""
    4443    itk_option define -clearcommand clearCommand ClearCommand ""
    4544    itk_option define -settingscommand settingsCommand SettingsCommand ""
     
    5049
    5150    public method add {xmlobj}
    52     public method clear {}
     51    public method clear {{xmlobj ""}}
    5352    public method activate {column}
    5453    public method contains {xmlobj}
    5554    public method size {{what -results}}
    5655
    57     protected method _doClear {}
     56    protected method _doClear {what}
    5857    protected method _doSettings {{cmd ""}}
    59     protected method _doPrompt {state}
    6058    protected method _control {option args}
    6159    protected method _fixControls {args}
    6260    protected method _fixLayout {args}
     61    protected method _fixNumResults {}
    6362    protected method _fixSettings {args}
    64     protected method _fixExplore {}
    6563    protected method _fixValue {column why}
    6664    protected method _drawValue {column widget wmax}
     
    6967    protected method _getTooltip {role column}
    7068    protected method _getParamDesc {which {index "current"}}
     69    protected method _addOneResult {tuples xmlobj {simnum ""}}
    7170
    7271    private variable _dispatcher ""  ;# dispatchers for !events
    7372    private variable _results ""     ;# tuple of known results
     73    private variable _resultnum 0    ;# counter for result #1, #2, etc.
    7474    private variable _recent ""      ;# most recent result in _results
    7575    private variable _active ""      ;# column with active control
     
    7878    private variable _counter 0      ;# counter for unique control names
    7979    private variable _settings 0     ;# non-zero => _fixSettings in progress
    80     private variable _explore 0      ;# non-zero => explore all parameters
    8180
    8281    private common _cntlInfo         ;# maps column name => control info
     
    8584itk::usual ResultSet {
    8685    keep -background -foreground -cursor -font
    87 }
    88 itk::usual Scrollset {
    8986}
    9087
     
    118115    set _results [Rappture::Tuples ::#auto]
    119116    $_results column insert end -name xmlobj -label "top-level XML object"
     117    $_results column insert end -name simnum -label "simulation number"
    120118
    121119
     
    129127    pack $itk_component(cntls) -fill x -pady {0 2}
    130128
    131     itk_component add clear {
    132         button $itk_component(cntls).clear -text "Clear" -state disabled \
     129    itk_component add clearall {
     130        button $itk_component(cntls).clearall -text "Clear" -state disabled \
    133131            -padx 1 -pady 1 \
    134132            -relief flat -overrelief raised \
    135             -command [itcl::code $this _doClear]
     133            -command [itcl::code $this _doClear all]
    136134    } {
    137135        usual
     
    140138        rename -highlightbackground -controlbarbackground controlbarBackground Background
    141139    }
     140    pack $itk_component(clearall) -side right -padx 2 -pady 1
     141    Rappture::Tooltip::for $itk_component(clearall) \
     142        "Clears all results collected so far."
     143
     144    itk_component add clear {
     145        button $itk_component(cntls).clear -text "Clear One" -state disabled \
     146            -padx 1 -pady 1 \
     147            -relief flat -overrelief raised \
     148            -command [itcl::code $this _doClear current]
     149    } {
     150        usual
     151        rename -background -controlbarbackground controlbarBackground Background
     152        rename -foreground -controlbarforeground controlbarForeground Foreground
     153        rename -highlightbackground -controlbarbackground controlbarBackground Background
     154    }
    142155    pack $itk_component(clear) -side right -padx 2 -pady 1
    143156    Rappture::Tooltip::for $itk_component(clear) \
    144         "Clears all results collected so far."
     157        "Clears the result that is currently selected."
    145158
    146159    itk_component add status {
     
    155168    pack $itk_component(status) -side left -padx 2 -pady {2 0}
    156169
    157     itk_component add parameters {
    158         button $itk_component(cntls).params -text "Parameters..." \
    159             -state disabled -padx 1 -pady 1 \
    160             -relief flat -overrelief raised \
    161             -command [list $itk_component(hull).popup activate $itk_component(cntls).params above]
    162     } {
    163         usual
    164         rename -background -controlbarbackground controlbarBackground Background
    165         rename -foreground -controlbarforeground controlbarForeground Foreground
    166         rename -highlightbackground -controlbarbackground controlbarBackground Background
    167     }
    168     pack $itk_component(parameters) -side left -padx 8 -pady 1
    169     Rappture::Tooltip::for $itk_component(parameters) \
    170         "Click to access all parameters."
    171 
    172170    itk_component add dials {
    173171        frame $itk_interior.dials
     
    194192    label $dials.labelmore.arrow -bitmap [Rappture::icon empty] -borderwidth 0
    195193    pack $dials.labelmore.arrow -side left -fill y
    196     _control bind $dials.labelmore.arrow @more
    197194    label $dials.labelmore.name -text "more parameters..." -font $fn \
    198195        -borderwidth 0 -padx 0 -pady 1
     
    200197    label $dials.labelmore.value
    201198    pack $dials.labelmore.value -side left
    202     _control bind $dials.labelmore.name @more
    203     Rappture::Tooltip::for $dials.labelmore \
    204         "@[itcl::code $this _getTooltip more more]"
    205 
    206     # use this pop-up for access to all controls
    207     Rappture::Balloon $itk_component(hull).popup \
    208         -title "Change Parameters" -padx 0 -pady 0
    209     set inner [$itk_component(hull).popup component inner]
    210 
    211     frame $inner.cntls
    212     pack $inner.cntls -side bottom -fill x
    213     frame $inner.cntls.sep -height 2 -borderwidth 1 -relief sunken
    214     pack $inner.cntls.sep -side top -fill x -padx 4 -pady 4
    215     checkbutton $inner.cntls.explore -font $fn \
    216         -text "Explore combinations with no results" \
    217         -variable [itcl::scope _explore] \
    218         -command [itcl::code $this _fixExplore]
    219     pack $inner.cntls.explore -side top -anchor w
    220     Rappture::Tooltip::for $inner.cntls.explore \
    221         "When this option is turned on, you can set parameters to various combinations that have not yet been simulated.  The Simulate button will light up, and you can simulate these missing combinations.\n\nWhen turned off, controls will avoid missing combinations, and automatically snap to the closest available dataset."
    222 
    223     itk_component add options {
    224         blt::scrollset $inner.scrl \
    225             -xscrollbar $inner.scrl.xs \
    226             -yscrollbar $inner.scrl.ys \
    227             -window $inner.scrl.frame
    228     }
    229     pack $itk_component(options) -expand yes -fill both
    230     blt::tk::scrollbar $inner.scrl.xs           
    231     blt::tk::scrollbar $inner.scrl.ys           
    232     itk_component add popup {
    233         frame $inner.scrl.frame
    234     }
    235     frame $itk_component(popup).bg
    236199
    237200    eval itk_initialize $args
     
    250213# Adds a new result to this result set.  Scans through all existing
    251214# results to look for a difference compared to previous results.
    252 # Returns the index of this new result to the caller.  The various
    253 # data objects for this result set should be added to their result
    254 # viewers at the same index.
     215# Returns the simulation number (#1, #2, #3, etc.) of this new result
     216# to the caller.  The various data objects for this result set should
     217# be added to their result viewers at the same index.
    255218# ----------------------------------------------------------------------
    256219itcl::body Rappture::ResultSet::add {xmlobj} {
     
    265228    if {"" == $xmlobj0} {
    266229        # first element -- always add
    267         $_results insert end [list $xmlobj]
     230        set simnum "#[incr _resultnum]"
     231        $_results insert end [list $xmlobj $simnum]
     232        _fixNumResults
    268233        set _recent $xmlobj
    269         $itk_component(status) configure -text "1 result"
    270         $itk_component(clear) configure -state normal
    271         if {[$_results size] >= 2} {
    272             $itk_component(parameters) configure -state normal
    273         } else {
    274             $itk_component(parameters) configure -state disabled
    275         }
     234        return $simnum
     235    }
     236
     237    #
     238    # For all later results, find the diffs and add any new columns
     239    # into the results tuple.  The latest result is the most recent.
     240    #
     241    set simnum [_addOneResult $_results $xmlobj]
     242    set _recent $xmlobj
     243    _fixNumResults
     244
     245    return $simnum
     246}
     247
     248# ----------------------------------------------------------------------
     249# USAGE: clear ?<xmlobj>?
     250#
     251# Clears one or all results in this result set.  If no specific
     252# result object is specified, then all results are cleared.
     253# ----------------------------------------------------------------------
     254itcl::body Rappture::ResultSet::clear {{xmlobj ""}} {
     255    set shortlist $itk_component(dials)
     256    set controlsChanged 0
     257
     258    # clear any currently highlighted result
     259    _doSettings
     260
     261    if {$xmlobj ne ""} {
     262        #
     263        # Delete just one result.  Look for the result among the
     264        # tuples and remove it.  Then, rebuild all of the tuples
     265        # by scanning back through them and building them back up.
     266        # This will rebuild the columns/controls as they should
     267        # be now, removing anything that is no longer necessary.
     268        #
     269        set irun [$_results find -format xmlobj $xmlobj]
     270        if {[llength $irun] == 1} {
     271            # figure out where we are in the active control, and
     272            # what value we should display after this one is deleted
     273            set vlist ""
     274            foreach {label val} [_getValues $_active all] {
     275                lappend vlist $label
     276            }
     277            set ipos [lsearch $vlist $_cntlInfo($this-$_active-value)]
     278
     279            set vcurr ""
     280            set vnext ""
     281            if {$ipos >= 0} {
     282                # try to stay at this value, if we can
     283                set vcurr [lindex $vlist $ipos]
     284
     285                # fall back to this value, if we have to
     286                if {$ipos > 0} { incr ipos -1 } else { incr ipos }
     287                set vnext [lindex $vlist $ipos]
     288            }
     289
     290            # delete the value from the tuples of all results
     291            $_results delete $irun
     292
     293            set new [Rappture::Tuples ::#auto]
     294            $new column insert end -name xmlobj -label "top-level XML object"
     295            $new column insert end -name simnum -label "simulation number"
     296
     297            for {set n 0} {$n < [$_results size]} {incr n} {
     298                set rec [lindex [$_results get -format {xmlobj simnum} $n] 0]
     299                foreach {obj num} $rec break
     300                if {$n == 0} {
     301                    $new insert end [list $obj $num]
     302                } else {
     303                    _addOneResult $new $obj $num
     304                }
     305            }
     306
     307            # plug in the new set of rebuilt tuples
     308            itcl::delete object $_results
     309            set _results $new
     310
     311            # delete any adjuster controls that disappeared
     312            foreach col $_cntlInfo($this-all) {
     313                if {[$_results column names $col] eq ""} {
     314                    set id $_cntlInfo($this-$col-id)
     315                    destroy $shortlist.label$id
     316                    array unset _cntlInfo $this-$col*
     317
     318                    set i [lsearch -exact $_cntlInfo($this-all) $col]
     319                    if {$i >= 0} {
     320                        set _cntlInfo($this-all) [lreplace $_cntlInfo($this-all) $i $i]
     321                    }
     322
     323                    if {$col == $_active} {
     324                        # control is going away -- switch to sim # control
     325                        set simnum0 [$_results get -format simnum 0]
     326                        set _cntlInfo($this-simnum-value) $simnum0
     327                        activate simnum
     328                    }
     329                    set controlsChanged 1
     330                }
     331            }
     332
     333            # can we find a tuple with the desired value for the active col?
     334            if {$_active ne "" && $vcurr ne ""} {
     335                set found ""
     336                if {[$_results find -format $_active $vcurr] ne ""} {
     337                    set found $vcurr
     338                } elseif {$vnext ne "" && [$_results find -format $_active $vnext] ne ""} {
     339                    set found $vnext
     340                }
     341
     342                if {$found ne ""} {
     343                    # set the control to a value we were able to find
     344                    # this will trigger !settings and other adjustments
     345                    set _cntlInfo($this-$_active-value) $found
     346                } else {
     347                    # if all else fails, show solution #1
     348                    set simnum0 [$_results get -format simnum 0]
     349                    set _cntlInfo($this-simnum-value) $simnum0
     350                    activate simnum
     351                }
     352            }
     353        }
     354    } else {
     355        #
     356        # Delete all results.
     357        #
     358        $_results delete 0 end
     359
     360        # delete all adjuster controls
     361        foreach col $_cntlInfo($this-all) {
     362            set id $_cntlInfo($this-$col-id)
     363            destroy $shortlist.label$id
     364        }
     365        set controlsChanged 1
     366    }
     367
     368    if {[$_results size] == 0} {
     369        #
     370        # No results left?  Then clean everything up.
     371        #
     372
     373        array unset _cntlInfo $this-*
     374        # clean up control info
     375        foreach key [array names _cntlInfo $this-*] {
     376            catch {unset _cntlInfo($key)}
     377        }
     378        set _cntlInfo($this-all) ""
     379        set _counter 0
     380        set _resultnum 0
     381
     382        # clear out all results
     383        eval $_results column delete [lrange [$_results column names] 2 end]
     384        set _recent ""
     385        set _active ""
     386
     387        set _plotall 0
     388        $itk_component(dials).all configure -relief raised \
     389            -background $itk_option(-background) \
     390            -foreground $itk_option(-foreground)
     391    }
     392
     393    # update status and Clear button
     394    _fixNumResults
     395    $_dispatcher event -idle !fixcntls
     396
     397    # let clients know that the number of controls has changed
     398    if {$controlsChanged} {
     399        event generate $itk_component(hull) <<Control>>
     400    }
     401
     402    # if there's a callback for clearing, invoke it now...
     403    if {[string length $itk_option(-clearcommand)] > 0} {
     404        uplevel #0 $itk_option(-clearcommand) $xmlobj
     405    }
     406}
     407
     408# ----------------------------------------------------------------------
     409# USAGE: activate <column>
     410#
     411# Clients use this to activate a particular column in the set of
     412# controls.  When a column is active, its label is bold and its
     413# value has a radiodial in the "short list" area.
     414# ----------------------------------------------------------------------
     415itcl::body Rappture::ResultSet::activate {column} {
     416    set allowed [$_results column names]
     417    if {[lsearch $allowed $column] < 0} {
     418        error "bad value \"$column\": should be one of [join $allowed {, }]"
     419    }
     420
     421    # column is now active
     422    set _active $column
     423
     424    # keep track of usage, so we know which controls are popular
     425    incr _cntlInfo($this-$column-usage)
     426
     427    # fix controls at next idle point
     428    $_dispatcher event -idle !layout why data
     429    $_dispatcher event -idle !settings column $_active
     430}
     431
     432# ----------------------------------------------------------------------
     433# USAGE: contains <xmlobj>
     434#
     435# Checks to see if the given <xmlobj> is already represented by
     436# some result in this result set.  This comes in handy when checking
     437# to see if an input case is already covered.
     438#
     439# Returns 1 if the result set already contains this result, and
     440# 0 otherwise.
     441# ----------------------------------------------------------------------
     442itcl::body Rappture::ResultSet::contains {xmlobj} {
     443    # no results? then this must be new
     444    if {[$_results size] == 0} {
    276445        return 0
    277446    }
     
    282451    # is a column to represent the quantity with the difference.
    283452    #
     453    set xmlobj0 [$_results get -format xmlobj end]
    284454    foreach {op vpath oldval newval} [$xmlobj0 diff $xmlobj] {
    285455        if {[$xmlobj get $vpath.about.diffs] == "ignore"} {
     
    291461            continue
    292462        }
    293 
    294         # make sure that these values really are different
    295         set oldval [lindex [Rappture::LibraryObj::value $xmlobj0 $vpath] 0]
    296         set newval [lindex [Rappture::LibraryObj::value $xmlobj $vpath] 0]
    297 
    298         if {$oldval != $newval && [$_results column names $vpath] == ""} {
    299             # no column for this quantity yet
    300             $_results column insert end -name $vpath -default $oldval
    301         }
    302     }
    303 
    304     # build a tuple for this new object
    305     set cols ""
    306     set tuple ""
    307     foreach col [lrange [$_results column names] 1 end] {
    308         lappend cols $col
    309         set raw [lindex [Rappture::LibraryObj::value $xmlobj $col] 0]
    310         lappend tuple $raw  ;# use the "raw" (user-readable) label
    311     }
    312 
    313     # find a matching tuple? then replace it -- only need one
    314     if {[llength $cols] > 0} {
    315         set ilist [$_results find -format $cols -- $tuple]
    316     } else {
    317         set ilist 0  ;# no diffs -- must match first entry
    318     }
    319 
    320     # add all remaining columns for this new entry
    321     set tuple [linsert $tuple 0 $xmlobj]
    322 
    323     if {[llength $ilist] > 0} {
    324         if {[llength $ilist] > 1} {
    325             error "why so many matching results?"
    326         }
    327 
    328         # overwrite the first matching entry
    329         set index [lindex $ilist 0]
    330         $_results put $index $tuple
    331         set _recent $xmlobj
    332     } else {
    333         set index [$_results size]
    334         $_results insert end $tuple
    335         set _recent $xmlobj
    336     }
    337 
    338     if {[$_results size] == 1} {
    339         $itk_component(status) configure -text "1 result"
    340     } else {
    341         $itk_component(status) configure -text "[$_results size] results"
    342         $itk_component(parameters) configure -state normal
    343     }
    344     $itk_component(clear) configure -state normal
    345 
    346     return $index
    347 }
    348 
    349 # ----------------------------------------------------------------------
    350 # USAGE: clear
    351 #
    352 # Clears all results in this result set.
    353 # ----------------------------------------------------------------------
    354 itcl::body Rappture::ResultSet::clear {} {
    355     _doSettings
    356 
    357     # delete all adjuster controls
    358     set popup $itk_component(popup)
    359     set shortlist $itk_component(dials)
    360     foreach col $_cntlInfo($this-all) {
    361         set id $_cntlInfo($this-$col-id)
    362         destroy $popup.label$id $popup.dial$id $popup.all$id
    363         destroy $shortlist.label$id
    364     }
    365 
    366     array unset _cntlInfo $this-*
    367     # clean up control info
    368     foreach key [array names _cntlInfo $this-*] {
    369         catch {unset _cntlInfo($key)}
    370     }
    371     set _cntlInfo($this-all) ""
    372     set _counter 0
    373 
    374     # clear out all results
    375     $_results delete 0 end
    376     eval $_results column delete [lrange [$_results column names] 1 end]
    377     set _recent ""
    378     set _active ""
    379 
    380     set _plotall 0
    381     $itk_component(dials).all configure -relief raised \
    382         -background $itk_option(-background) \
    383         -foreground $itk_option(-foreground)
    384 
    385     # update status and Clear button
    386     $itk_component(status) configure -text "No results"
    387     $itk_component(parameters) configure -state disabled
    388     $itk_component(clear) configure -state disabled
    389     $_dispatcher event -idle !fixcntls
    390 
    391     # let clients know that the number of controls has changed
    392     event generate $itk_component(hull) <<Control>>
    393 }
    394 
    395 # ----------------------------------------------------------------------
    396 # USAGE: activate <column>
    397 #
    398 # Clients use this to activate a particular column in the set of
    399 # controls.  When a column is active, its label is bold and its
    400 # value has a radiodial in the "short list" area.
    401 # ----------------------------------------------------------------------
    402 itcl::body Rappture::ResultSet::activate {column} {
    403     if {$column == "@more"} {
    404         $itk_component(hull).popup activate \
    405             $itk_component(dials).labelmore.name above
    406         return
    407     }
    408 
    409     set allowed [$_results column names]
    410     if {[lsearch $allowed $column] < 0} {
    411         error "bad value \"$column\": should be one of [join $allowed {, }]"
    412     }
    413 
    414     # column is now active
    415     set _active $column
    416 
    417     # keep track of usage, so we know which controls are popular
    418     incr _cntlInfo($this-$column-usage)
    419 
    420     # fix controls at next idle point
    421     $_dispatcher event -idle !layout why data
    422     $_dispatcher event -idle !settings column $_active
    423 }
    424 
    425 # ----------------------------------------------------------------------
    426 # USAGE: contains <xmlobj>
    427 #
    428 # Checks to see if the given <xmlobj> is already represented by
    429 # some result in this result set.  This comes in handy when checking
    430 # to see if an input case is already covered.
    431 #
    432 # Returns 1 if the result set already contains this result, and
    433 # 0 otherwise.
    434 # ----------------------------------------------------------------------
    435 itcl::body Rappture::ResultSet::contains {xmlobj} {
    436     # no results? then this must be new
    437     if {[$_results size] == 0} {
    438         return 0
    439     }
    440 
    441     #
    442     # Compare this new object against the last XML object in the
    443     # results set.  If it has a difference, make sure that there
    444     # is a column to represent the quantity with the difference.
    445     #
    446     set xmlobj0 [$_results get -format xmlobj end]
    447     foreach {op vpath oldval newval} [$xmlobj0 diff $xmlobj] {
    448         if {[$xmlobj get $vpath.about.diffs] == "ignore"} {
    449             continue
    450         }
    451         if {$op == "+" || $op == "-"} {
    452             # ignore differences where parameters come and go
    453             # such differences make it hard to work controls
    454             continue
    455         }
    456463        if {[$_results column names $vpath] == ""} {
    457464            # no column for this quantity yet
     
    466473    set format ""
    467474    set tuple ""
    468     foreach col [lrange [$_results column names] 1 end] {
     475    foreach col [lrange [$_results column names] 2 end] {
    469476        lappend format $col
    470477        set raw [lindex [Rappture::LibraryObj::value $xmlobj $col] 0]
     
    543550
    544551# ----------------------------------------------------------------------
    545 # USAGE: _doClear
    546 #
    547 # Invoked automatically when the user presses the Clear button.
    548 # Invokes the -clearcommand to clear all data from this resultset
    549 # and all other resultsets in an Analyzer.
    550 # ----------------------------------------------------------------------
    551 itcl::body Rappture::ResultSet::_doClear {} {
    552     if {[string length $itk_option(-clearcommand)] > 0} {
    553         uplevel #0 $itk_option(-clearcommand)
     552# USAGE: _doClear all|current
     553#
     554# Invoked automatically when the user presses the "Clear One" or
     555# "Clear All" buttons.  Invokes the -clearcommand to clear all data
     556# from this resultset and all other resultsets in an Analyzer.
     557# ----------------------------------------------------------------------
     558itcl::body Rappture::ResultSet::_doClear {what} {
     559    switch -- $what {
     560        current {
     561            set xmlobj ""
     562            # value of xmlobj control is something like "#1" or "#2"
     563            set irun [$_results find -format simnum $_cntlInfo($this-simnum-value)]
     564            if {$irun ne ""} {
     565                # convert index to a real xmlobj object
     566                set xmlobj [$_results get -format xmlobj $irun]
     567            }
     568            clear $xmlobj
     569        }
     570        all {
     571            clear
     572        }
     573        default { error "bad option \"$what\": should be current or all" }
    554574    }
    555575}
     
    565585    if {[string length $itk_option(-settingscommand)] > 0} {
    566586        uplevel #0 $itk_option(-settingscommand) $cmd
    567     }
    568 }
    569 
    570 # ----------------------------------------------------------------------
    571 # USAGE: _doPrompt <state>
    572 #
    573 # Used internally whenever the current settings represent a point
    574 # with no data.  Invokes the -promptcommand with an explanation of
    575 # the missing data, prompting the user to simulate it.
    576 # ----------------------------------------------------------------------
    577 itcl::body Rappture::ResultSet::_doPrompt {state} {
    578     if {[string length $itk_option(-promptcommand)] > 0} {
    579         if {$state} {
    580             set message "No data for these settings"
    581             set settings ""
    582             foreach col [lrange [$_results column names] 1 end] {
    583                 set val $_cntlInfo($this-$col-value)
    584                 lappend settings $col $val
    585             }
    586             uplevel #0 $itk_option(-promptcommand) [list on $message $settings]
    587         } else {
    588             uplevel #0 $itk_option(-promptcommand) off
    589         }
    590587    }
    591588}
     
    689686    }
    690687
    691     set popup $itk_component(popup)
    692     grid columnconfigure $popup 0 -minsize 16
    693     grid columnconfigure $popup 1 -weight 1
    694 
    695688    set shortlist $itk_component(dials)
    696689    grid columnconfigure $shortlist 1 -weight 1
     
    711704        #
    712705        if {![info exists _cntlInfo($this-$col-id)]} {
    713             set row [lindex [grid size $popup] 1]
    714             set row2 [expr {$row+1}]
    715 
    716706            set tip ""
    717             if {$col == "xmlobj"} {
     707            if {$col eq "xmlobj"} {
     708                continue
     709            } elseif {$col eq "simnum"} {
    718710                set quantity "Simulation"
    719711                set tip "List of all simulations that you have performed so far."
     
    732724            }
    733725
    734             #
    735             # Build the main control in the pop-up panel.
    736             #
     726            # Create the controls for the "short list" area.
    737727            set fn $itk_option(-textfont)
    738             set w $popup.label$_counter
     728            set w $shortlist.label$_counter
     729            set row [lindex [grid size $shortlist] 1]
    739730            frame $w
    740             grid $w -row $row -column 2 -sticky ew -padx 4 -pady {4 0}
     731            grid $w -row $row -column 1 -sticky ew
    741732            label $w.arrow -bitmap [Rappture::icon empty] -borderwidth 0
    742733            pack $w.arrow -side left -fill y
     
    757748            Rappture::Tooltip::for $w \
    758749                "@[itcl::code $this _getTooltip label $col]"
    759 
    760             set w $popup.dial$_counter
    761             Rappture::Radiodial $w -valuewidth 0
    762             grid $w -row $row2 -column 2 -sticky ew -padx 4 -pady {0 4}
    763             $w configure -variable ::Rappture::ResultSet::_cntlInfo($this-$col-value)
    764             Rappture::Tooltip::for $w \
    765                 "@[itcl::code $this _getTooltip dial $col]"
    766 
    767             set w $popup.all$_counter
    768             label $w -text "All" -padx 8 \
    769                 -borderwidth 1 -relief raised -font $fn
    770             grid $w -row $row -rowspan 2 -column 1 -sticky nsew -padx 2 -pady 4
    771             Rappture::Tooltip::for $w \
    772                 "@[itcl::code $this _getTooltip all $col]"
    773             bind $w <ButtonRelease> [itcl::code $this _toggleAll $col]
    774 
    775             # Create the controls for the "short list" area.
    776             set w $shortlist.label$_counter
    777             frame $w
    778             grid $w -row $row -column 1 -sticky ew
    779             label $w.arrow -bitmap [Rappture::icon empty] -borderwidth 0
    780             pack $w.arrow -side left -fill y
    781             _control bind $w.arrow $col
    782 
    783             label $w.name -text $quantity -anchor w \
    784                 -borderwidth 0 -padx 0 -pady 1 -font $fn
    785             pack $w.name -side left
    786             bind $w.name <Configure> [itcl::code $this _fixValue $col resize]
    787             _control bind $w.name $col
    788 
    789             label $w.value -anchor w \
    790                 -borderwidth 0 -padx 0 -pady 1 -font $fn
    791             pack $w.value -side left
    792             bind $w.value <Configure> [itcl::code $this _fixValue $col resize]
    793             _control bind $w.value $col
    794 
    795             Rappture::Tooltip::for $w \
    796                 "@[itcl::code $this _getTooltip label $col]"
    797 
    798             # if this is the "Simulation #" control, add a separator
    799             if {$col == "xmlobj"} {
    800                 grid $popup.all$_counter -column 0
    801                 grid $popup.label$_counter -column 1 -columnspan 2
    802                 grid $popup.dial$_counter -column 1 -columnspan 2
    803 
    804                 if {![winfo exists $popup.sep]} {
    805                     frame $popup.sep -height 1 -borderwidth 0 -background black
    806                 }
    807                 grid $popup.sep -row [expr {$row+2}] -column 0 \
    808                     -columnspan 3 -sticky ew -pady 4
    809 
    810                 if {![winfo exists $popup.paraml]} {
    811                     label $popup.paraml -text "Parameters:" -font $fn
    812                 }
    813                 grid $popup.paraml -row [expr {$row+3}] -column 0 \
    814                     -columnspan 3 -sticky w -padx 4 -pady {0 4}
    815             }
    816750
    817751            # create a record for this control
     
    844778        #
    845779        set id $_cntlInfo($this-$col-id)
    846         set popup $itk_component(popup)
    847         set dial $popup.dial$id
    848 
    849         _control load $popup.dial$id $col
    850780
    851781        if {$col == $_layout(active)} {
     
    862792    #
    863793    if {$nadded > 0} {
    864         if {[$_results column names] == 2 || $nadded == 1} {
     794        if {[$_results column names] == 3 || $nadded == 1} {
    865795            activate [lindex $_cntlInfo($this-all) end]
    866796        } else {
    867             activate xmlobj
     797            activate simnum
    868798        }
    869799    }
     
    874804    # will then fix all other controls to match the one that changed.
    875805    #
    876     if {"" != $_recent} {
    877         set raw [lindex [$_results find -format xmlobj $_recent] 0]
    878         set raw "#[expr {$raw+1}]"
    879         set _cntlInfo($this-xmlobj-value) $raw
     806    set irun [lindex [$_results find -format xmlobj $_recent] 0]
     807    if {$irun ne ""} {
     808        set simnum [$_results get -format simnum $irun]
     809        set _cntlInfo($this-simnum-value) $simnum
    880810    }
    881811}
     
    888818# so that the active control is displayed, and other recent controls
    889819# are shown above and/or below.  At the very least, we must show the
    890 # "more options..." control, which pops up a panel of all controls.
     820# "more options..." control.
    891821# ----------------------------------------------------------------------
    892822itcl::body Rappture::ResultSet::_fixLayout {args} {
    893823    array set eventdata $args
    894824
    895     set popup $itk_component(popup)
    896825    set shortlist $itk_component(dials)
    897826
     
    907836    foreach col $_cntlInfo($this-all) {
    908837        set id $_cntlInfo($this-$col-id)
    909         $popup.label$id configure -background $bg
    910         $popup.label$id.arrow configure -background $bg \
    911             -bitmap [Rappture::icon empty]
    912         $popup.label$id.name configure -font $fn -background $bg
    913         $popup.label$id.value configure -background $bg
    914         $popup.all$id configure -background $bg -foreground $fg \
    915             -relief raised
    916         $popup.dial$id configure -background $bg
    917838        $shortlist.label$id configure -background $bg
    918839        $shortlist.label$id.arrow configure -background $bg \
     
    995916
    996917        if {$col == $_active} {
    997             # put the background behind the active control in the popup
    998             set id $_cntlInfo($this-$_active-id)
    999             array set ginfo [grid info $popup.label$id]
    1000             grid $popup.bg -row $ginfo(-row) -rowspan 2 \
    1001                 -column 0 -columnspan 3 -sticky nsew
    1002             lower $popup.bg
    1003 
    1004918            if {$_layout(mode) == "usual"} {
    1005919                # put the background behind the active control in the shortlist
     
    1033947        set fg $itk_option(-activecontrolforeground)
    1034948        set bg $itk_option(-activecontrolbackground)
    1035 
    1036         $popup.label$id configure -background $bg
    1037         $popup.label$id.arrow configure -foreground $fg -background $bg \
    1038             -bitmap [Rappture::icon rarrow]
    1039         $popup.label$id.name configure -foreground $fg -background $bg \
    1040             -font $bf
    1041         $popup.label$id.value configure -foreground $fg -background $bg
    1042         $popup.dial$id configure -background $bg
    1043         $popup.bg configure -background $bg
    1044 
    1045         if {$_plotall} {
    1046             $popup.all$id configure -relief sunken \
    1047                 -background $itk_option(-togglebackground) \
    1048                 -foreground $itk_option(-toggleforeground)
    1049         } else {
    1050             $popup.all$id configure -relief raised \
    1051                 -background $itk_option(-activecontrolbackground) \
    1052                 -foreground $itk_option(-activecontrolforeground)
    1053         }
    1054949
    1055950        if {$_layout(mode) == "usual"} {
     
    1072967
    1073968# ----------------------------------------------------------------------
     969# USAGE: _fixNumResults
     970#
     971# Used internally to update the number of results displayed near the
     972# top of this widget.  If there is only 1 result, then there is also
     973# a single "Clear" button.  If there are no results, the clear button
     974# is diabled.
     975# ----------------------------------------------------------------------
     976itcl::body Rappture::ResultSet::_fixNumResults {} {
     977    switch [$_results size] {
     978        0 {
     979            $itk_component(status) configure -text "No results"
     980            $itk_component(clearall) configure -state disabled -text "Clear"
     981            pack forget $itk_component(clear)
     982        }
     983        1 {
     984            $itk_component(status) configure -text "1 result"
     985            $itk_component(clearall) configure -state normal -text "Clear"
     986            pack forget $itk_component(clear)
     987        }
     988        default {
     989            $itk_component(status) configure -text "[$_results size] results"
     990            $itk_component(clearall) configure -state normal -text "Clear All"
     991            $itk_component(clear) configure -state normal
     992            pack $itk_component(clear) -side right \
     993                -after $itk_component(clearall) -padx {0 6}
     994        }
     995    }
     996}
     997
     998# ----------------------------------------------------------------------
    1074999# USAGE: _fixSettings ?<eventArgs...>?
    10751000#
     
    10881013        set changed ""
    10891014    }
    1090     _doPrompt off
    10911015
    10921016    if {[info exists _cntlInfo($this-$_active-label)]} {
     
    11071031        1 {
    11081032            # only one data set? then plot it
     1033            set simnum [$_results get -format simnum 0]
    11091034            _doSettings [list \
    1110                 0 [list -width 2 \
     1035                $simnum [list -width 2 \
    11111036                        -param [_getValues $_active current] \
    11121037                        -description [_getParamDesc all] \
     
    11231048    # for a tuple that matches the current settings.
    11241049    #
    1125     if {$changed == "xmlobj"} {
    1126         # value is "#2" -- skip # and adjust range starting from 0
    1127         set irun [string range $_cntlInfo($this-xmlobj-value) 1 end]
    1128         if {"" != $irun} { set irun [expr {$irun-1}] }
     1050    if {$changed == "xmlobj" || $changed == "simnum"} {
     1051        set irun [$_results find -format simnum $_cntlInfo($this-simnum-value)]
    11291052    } else {
    11301053        set format ""
    11311054        set tuple ""
    1132         foreach col [lrange [$_results column names] 1 end] {
     1055        foreach col [lrange [$_results column names] 2 end] {
    11331056            lappend format $col
    11341057            lappend tuple $_cntlInfo($this-$col-value)
     
    11361059        set irun [lindex [$_results find -format $format -- $tuple] 0]
    11371060
    1138         if {"" == $irun && "" != $changed
    1139              && $itk_option(-missingdata) == "skip"} {
    1140             #
    1141             # No data for these settings.  Try leaving the next
    1142             # column open, then the next, and so forth, until
    1143             # we find some data.
    1144             #
    1145             # allcols:  foo bar baz qux
    1146             #               ^^^changed
    1147             #
    1148             # search:   baz qux foo
    1149             #
    1150             set val $_cntlInfo($this-$changed-value)
    1151             set allcols [lrange [$_results column names] 1 end]
    1152             set i [lsearch -exact $allcols $changed]
    1153             set search [concat \
    1154                 [lrange $allcols [expr {$i+1}] end] \
    1155                 [lrange $allcols 0 [expr {$i-1}]] \
    1156             ]
    1157             set nsearch [llength $search]
    1158 
    1159             for {set i 0} {$i < $nsearch} {incr i} {
    1160                 set format $changed
    1161                 set tuple [list $val]
    1162                 for {set j [expr {$i+1}]} {$j < $nsearch} {incr j} {
    1163                     set col [lindex $search $j]
    1164                     lappend format $col
    1165                     lappend tuple $_cntlInfo($this-$col-value)
    1166                 }
    1167                 set irun [lindex [$_results find -format $format -- $tuple] 0]
    1168                 if {"" != $irun} {
    1169                     break
    1170                 }
    1171             }
    1172         }
     1061        if {"" == $irun && "" != $changed} {
     1062            #
     1063            # No data for these settings.  Try leaving the next
     1064            # column open, then the next, and so forth, until
     1065            # we find some data.
     1066            #
     1067            # allcols:  foo bar baz qux
     1068            #               ^^^changed
     1069            #
     1070            # search:   baz qux foo
     1071            #
     1072            set val $_cntlInfo($this-$changed-value)
     1073            set allcols [lrange [$_results column names] 2 end]
     1074            set i [lsearch -exact $allcols $changed]
     1075            set search [concat \
     1076                [lrange $allcols [expr {$i+1}] end] \
     1077                [lrange $allcols 0 [expr {$i-1}]] \
     1078            ]
     1079            set nsearch [llength $search]
     1080
     1081            for {set i 0} {$i < $nsearch} {incr i} {
     1082                set format $changed
     1083                set tuple [list $val]
     1084                for {set j [expr {$i+1}]} {$j < $nsearch} {incr j} {
     1085                    set col [lindex $search $j]
     1086                    lappend format $col
     1087                    lappend tuple $_cntlInfo($this-$col-value)
     1088                }
     1089                set irun [lindex [$_results find -format $format -- $tuple] 0]
     1090                if {"" != $irun} {
     1091                    break
     1092                }
     1093            }
     1094        }
    11731095    }
    11741096
     
    11811103        set _settings 1
    11821104
    1183         set format [lrange [$_results column names] 1 end]
     1105        set format [lrange [$_results column names] 2 end]
    11841106        if {[llength $format] == 1} {
    11851107            set data [$_results get -format $format $irun]
     
    11911113            set _cntlInfo($this-$col-value) $val
    11921114        }
    1193         set _cntlInfo($this-xmlobj-value) "#[expr {$irun+1}]"
     1115        set simnum [$_results get -format simnum $irun]
     1116        set _cntlInfo($this-simnum-value) $simnum
    11941117
    11951118        # okay, react to value changes again
     
    12011124    # plot them.
    12021125    #
    1203     if {$_plotall && $_active == "xmlobj"} {
     1126    if {$_plotall && $_active == "simnum"} {
    12041127        set format ""
    12051128    } else {
    12061129        set format ""
    12071130        set tuple ""
    1208         foreach col [lrange [$_results column names] 1 end] {
     1131        foreach col [lrange [$_results column names] 2 end] {
    12091132            if {!$_plotall || $col != $_active} {
    12101133                lappend format $col
     
    12241147        set format ""
    12251148        set tuple ""
    1226         foreach col [lrange [$_results column names] 1 end] {
     1149        foreach col [lrange [$_results column names] 2 end] {
    12271150            lappend format $col
    12281151            lappend tuple $_cntlInfo($this-$col-value)
    12291152        }
    12301153        set icurr [$_results find -format $format -- $tuple]
    1231 
    1232         # no data for these settings? prompt the user to simulate
    1233         if {"" == $icurr} {
    1234             _doPrompt on
    1235         }
    12361154
    12371155        if {[llength $ilist] == 1} {
    12381156            # single result -- always use active color
    12391157            set i [lindex $ilist 0]
     1158            set simnum [$_results get -format simnum $i]
    12401159            set plist [list \
    1241                 $i [list -width 2 \
     1160                $simnum [list -width 2 \
    12421161                         -param [_getValues $_active $i] \
    12431162                         -description [_getParamDesc all $i] \
     
    12521171            set plist [list params $params]
    12531172            foreach i $ilist {
     1173                set simnum [$_results get -format simnum $i]
    12541174                if {$i == $icurr} {
    1255                     lappend plist $i [list -width 3 -raise 1 \
     1175                    lappend plist $simnum [list -width 3 -raise 1 \
    12561176                        -param [_getValues $_active $i] \
    12571177                        -description [_getParamDesc all $i]]
    12581178                } else {
    1259                     lappend plist $i [list -brightness 0.7 -width 1 \
     1179                    lappend plist $simnum [list -brightness 0.7 -width 1 \
    12601180                        -param [_getValues $_active $i] \
    12611181                        -description [_getParamDesc all $i]]
     
    12681188        #
    12691189        _doSettings $plist
    1270 
    1271     } elseif {$itk_option(-missingdata) == "prompt"} {
    1272         # prompt the user to simulate these settings
    1273         _doPrompt on
    1274         _doSettings  ;# clear plotting area
    1275 
    1276         # clear the current run selection -- there is no run for this
    1277         set _settings 1
    1278         set _cntlInfo($this-xmlobj-value) ""
    1279         set _settings 0
    1280     }
    1281 }
    1282 
    1283 # ----------------------------------------------------------------------
    1284 # USAGE: _fixExplore
    1285 #
    1286 # Called automatically whenever the user toggles the "Explore" button
    1287 # on the parameter popup.  Changes the -missingdata option back and
    1288 # forth, to allow for missing data or skip it.
    1289 # ----------------------------------------------------------------------
    1290 itcl::body Rappture::ResultSet::_fixExplore {} {
    1291     if {$_explore} {
    1292         configure -missingdata prompt
    1293     } else {
    1294         configure -missingdata skip
    12951190    }
    12961191}
     
    13071202    if {[info exists _cntlInfo($this-$col-id)]} {
    13081203        set id $_cntlInfo($this-$col-id)
    1309 
    1310         set popup $itk_component(popup)
    1311         set widget $popup.label$id
    1312         set wmax [winfo width $popup.dial$id]
    1313         _drawValue $col $widget $wmax
    13141204
    13151205        set widget $itk_component(dials).label$id
     
    14321322    }
    14331323    set id $_cntlInfo($this-$col-id)
    1434     set popup $itk_component(popup)
    1435     set pbutton $popup.all$id
    1436     set current [$pbutton cget -relief]
    14371324    set sbutton $itk_component(dials).all
    1438 
    1439     foreach c $_cntlInfo($this-all) {
    1440         set id $_cntlInfo($this-$c-id)
    1441         $popup.all$id configure -relief raised \
    1442             -background $itk_option(-background) \
    1443             -foreground $itk_option(-foreground)
    1444     }
     1325    set current [$sbutton cget -relief]
    14451326
    14461327    if {$current == "sunken"} {
    1447         $pbutton configure -relief raised \
    1448             -background $itk_option(-activecontrolbackground) \
    1449             -foreground $itk_option(-activecontrolforeground)
    14501328        $sbutton configure -relief raised \
    14511329            -background $itk_option(-activecontrolbackground) \
     
    14531331        set _plotall 0
    14541332    } else {
    1455         $pbutton configure -relief sunken \
    1456             -background $itk_option(-togglebackground) \
    1457             -foreground $itk_option(-toggleforeground)
    14581333        $sbutton configure -relief sunken \
    14591334            -background $itk_option(-togglebackground) \
     
    14761351# ----------------------------------------------------------------------
    14771352itcl::body Rappture::ResultSet::_getValues {col {which ""}} {
    1478     if {$col == "xmlobj"} {
     1353    if {$col == "simnum"} {
    14791354        # load the Simulation # control
    14801355        set nruns [$_results size]
    14811356        for {set n 0} {$n < $nruns} {incr n} {
    1482             set v "#[expr {$n+1}]"
     1357            set v [$_results get -format simnum $n]
    14831358            set label2val($v) $n
    14841359        }
     
    15261401        default {
    15271402            if {[string is integer $which]} {
    1528                 if {$col == "xmlobj"} {
    1529                     set val "#[expr {$which+1}]"
     1403                if {$col == "simnum"} {
     1404                    set val [$_results get -format simnum $which]
    15301405                } else {
    15311406                    # Be careful giving singleton elements as the "columns"
     
    15841459            append tip "\n\nCurrently, plotting $what.  Click to toggle."
    15851460        }
    1586         more {
    1587             set tip "Click to access all parameters."
    1588         }
    15891461    }
    15901462    return [string trim $tip]
     
    16031475        set format ""
    16041476        set tuple ""
    1605         foreach col [lrange [$_results column names] 1 end] {
     1477        foreach col [lrange [$_results column names] 2 end] {
    16061478            lappend format $col
    16071479            lappend tuple $_cntlInfo($this-$col-value)
     
    16261498                # argument to "Tuples::get". It is expecting a list.
    16271499                set val [lindex [$_results get -format [list $col] $index] 0]
    1628                 if {$col == "xmlobj"} {
    1629                     set num [lindex [$_results find -format xmlobj $val] 0]
    1630                     set val "#[expr {$num+1}]"
     1500                if {$col == "simnum"} {
     1501                    set irun [lindex [$_results find -format xmlobj $val] 0]
     1502                    set val [$_results get -format simnum $irun]
    16311503                }
    16321504                append desc "$quantity = $val\n"
     
    16411513
    16421514# ----------------------------------------------------------------------
    1643 # OPTION: -missingdata
    1644 # ----------------------------------------------------------------------
    1645 itcl::configbody Rappture::ResultSet::missingdata {
    1646     set opts {prompt skip}
    1647     if {[lsearch -exact $opts $itk_option(-missingdata)] < 0} {
    1648         error "bad value \"$itk_option(-missingdata)\": should be [join $opts {, }]"
    1649     }
    1650     set _explore [expr {$itk_option(-missingdata) != "skip"}]
     1515# USAGE: _addOneResult <tuples> <xmlobj> ?<simNum>?
     1516#
     1517# Used internally to add one new <xmlobj> to the given <tuples>
     1518# object.  If the new xmlobj contains different input parameters
     1519# that are not already columns in the tuple, then this routine
     1520# creates the new columns.  If the optional <simNum> is specified,
     1521# then it is added as the simulation number #1, #2, #3, etc.  If
     1522# not, then the new object is automatically numbered.
     1523# ----------------------------------------------------------------------
     1524itcl::body Rappture::ResultSet::_addOneResult {tuples xmlobj {simnum ""}} {
     1525    #
     1526    # Compare this new object against the last XML object in the
     1527    # results set.  If it has a difference, make sure that there
     1528    # is a column to represent the quantity with the difference.
     1529    #
     1530    set xmlobj0 [$tuples get -format xmlobj end]
     1531    foreach {op vpath oldval newval} [$xmlobj0 diff $xmlobj] {
     1532        if {[$xmlobj get $vpath.about.diffs] == "ignore"} {
     1533            continue
     1534        }
     1535        if {$op == "+" || $op == "-"} {
     1536            # ignore differences where parameters come and go
     1537            # such differences make it hard to work controls
     1538            continue
     1539        }
     1540
     1541        # make sure that these values really are different
     1542        set oldval [lindex [Rappture::LibraryObj::value $xmlobj0 $vpath] 0]
     1543        set newval [lindex [Rappture::LibraryObj::value $xmlobj $vpath] 0]
     1544
     1545        if {$oldval != $newval && [$tuples column names $vpath] == ""} {
     1546            # no column for this quantity yet
     1547            $tuples column insert end -name $vpath -default $oldval
     1548        }
     1549    }
     1550
     1551    # build a tuple for this new object
     1552    set cols ""
     1553    set tuple ""
     1554    foreach col [lrange [$tuples column names] 2 end] {
     1555        lappend cols $col
     1556        set raw [lindex [Rappture::LibraryObj::value $xmlobj $col] 0]
     1557        lappend tuple $raw  ;# use the "raw" (user-readable) label
     1558    }
     1559
     1560    # find a matching tuple? then replace it -- only need one
     1561    if {[llength $cols] > 0} {
     1562        set ilist [$tuples find -format $cols -- $tuple]
     1563    } else {
     1564        set ilist 0  ;# no diffs -- must match first entry
     1565    }
     1566
     1567    # add all remaining columns for this new entry
     1568    set tuple [linsert $tuple 0 $xmlobj]
     1569    set cols [linsert $cols 0 "xmlobj"]
     1570
     1571    if {[llength $ilist] > 0} {
     1572        if {[llength $ilist] > 1} {
     1573            error "why so many matching results?"
     1574        }
     1575
     1576        # overwrite the first matching entry
     1577        set index [lindex $ilist 0]
     1578        $tuples put -format $cols $index $tuple
     1579    } else {
     1580        if {$simnum eq ""} {
     1581            set simnum "#[incr _resultnum]"
     1582        }
     1583        set tuple [linsert $tuple 1 $simnum]
     1584        $tuples insert end $tuple
     1585    }
     1586    return $simnum
    16511587}
    16521588
  • branches/blt4/gui/scripts/resultviewer.tcl

    r2745 r2966  
    3636    protected method _plotAdd {xmlobj {settings ""}}
    3737    protected method _fixScale {args}
    38     protected proc _xml2data {xmlobj path}
     38    protected method _xml2data {xmlobj path}
     39    protected method _cleanIndex {index}
    3940
    4041    private variable _dispatcher ""  ;# dispatchers for !events
     
    4243    private variable _mode2widget    ;# maps plotting mode => widget
    4344    private variable _dataslots ""   ;# list of all data objects in this widget
     45    private variable _xml2data       ;# maps xmlobj => data obj in _dataslots
    4446}
    4547
     
    7981# ----------------------------------------------------------------------
    8082itcl::body Rappture::ResultViewer::add {index xmlobj path} {
     83    set index [_cleanIndex $index]
    8184    set dobj [_xml2data $xmlobj $path]
    8285
     
    9699
    97100# ----------------------------------------------------------------------
    98 # USAGE: clear ?<index>?
    99 #
    100 # Clears one or all results in this result viewer.
     101# USAGE: clear ?<index>|<xmlobj>?
     102#
     103# Clears one or all results in this result viewer.  If a particular
     104# <index> is specified, then all data objects at that index are
     105# deleted.  If a particular <xmlobj> is specified, then all data
     106# objects related to that <xmlobj> are removed--regardless of whether
     107# they reside at one or more indices.
    101108# ----------------------------------------------------------------------
    102109itcl::body Rappture::ResultViewer::clear {{index ""}} {
    103     if {"" != $index} {
     110    if {$index ne ""} {
    104111        # clear one result
    105         if {$index >= 0 && $index < [llength $_dataslots]} {
    106             set slot [lindex $_dataslots $index]
    107             foreach dobj $slot {
     112        if {[catch {_cleanIndex $index} i] == 0} {
     113            if {$i >= 0 && $i < [llength $_dataslots]} {
     114                set slot [lindex $_dataslots $i]
     115                foreach dobj $slot {
     116                    itcl::delete object $dobj
     117                }
     118                set _dataslots [lreplace $_dataslots $i $i ""]
     119                $_dispatcher event -idle !scale
     120            }
     121        } else {
     122            foreach key [array names _xml2data $index-*] {
     123                set dobj $_xml2data($key)
     124
     125                # search for and remove all references to this data object
     126                for {set n 0} {$n < [llength $_dataslots]} {incr n} {
     127                    set slot [lindex $_dataslots $n]
     128                    set pos [lsearch -exact $slot $dobj]
     129                    if {$pos >= 0} {
     130                        set slot [lreplace $slot $pos $pos]
     131                        set _dataslots [lreplace $_dataslots $n $n $slot]
     132                        $_dispatcher event -idle !scale
     133                    }
     134                }
     135
     136                # destroy the object and forget it
    108137                itcl::delete object $dobj
    109             }
    110             set _dataslots [lreplace $_dataslots $index $index ""]
     138                unset _xml2data($key)
     139            }
    111140        }
    112141    } else {
     
    119148        }
    120149        set _dataslots ""
     150        catch {unset _xml2data}
    121151    }
    122152}
     
    139169
    140170# ----------------------------------------------------------------------
    141 # USAGE: plot add ?<index> <settings> <index> <settings> ...?
     171# USAGE: plot add ?<simnum> <settings> <simnum> <settings> ...?
    142172# USAGE: plot clear
    143173#
     
    145175# command clears the current viewer.  Data is still stored in the
    146176# widget, but the results are not shown on screen.  The "plot add"
    147 # command adds the data at the specified <index> to the plot.  If
     177# command adds the data at the specified <simnum> to the plot.  Each
     178# <simnum> is the simulation number, like "#1", "#2", "#3", etc.  If
    148179# the optional <settings> are specified, then they are applied
    149180# to the plot; otherwise, default settings are used.
     
    158189                    continue
    159190                }
     191
     192                set index [_cleanIndex $index]
    160193                set reset "-color autoreset"
    161194                set slot [lindex $_dataslots $index]
     
    263296                    set mode "contour"
    264297                    if {![info exists _mode2widget($mode)]} {
     298                        global env
    265299                        if { [$dataobj isunirect2d] } {
    266300                            if { [$dataobj hints type] == "contour" } {
     
    271305                                set resultMode "heightmap"
    272306                            }
     307                        } elseif { [info exists env(VTKCONTOUR)] } {
     308                            set resultMode "vtkcontour"
    273309                        } else {
    274310                            set resultMode "vtk"
     
    292328                                set fmt "vtk"
    293329                            }
    294                             "opendx" - "dx" - "points-on-mesh" {
     330                            "points-on-mesh" {
     331                                set mesh [$dataobj mesh]
     332                                set fmt [expr {("" != $mesh) ? "vtk" : "nanovis"}]
     333                                set extents [$dataobj extents]
     334                                if { $extents > 1 } {
     335                                    set fmt "flowvis"
     336                                }
     337                            }
     338                            "opendx" - "dx" {
    295339                                set fmt "nanovis"
    296340                                set extents [$dataobj extents]
     
    464508# ----------------------------------------------------------------------
    465509itcl::body Rappture::ResultViewer::_xml2data {xmlobj path} {
     510    if {[info exists _xml2data($xmlobj-$path)]} {
     511        return $_xml2data($xmlobj-$path)
     512    }
     513
    466514    set type [$xmlobj element -as type $path]
    467515    switch -- $type {
    468516        curve {
    469             return [Rappture::Curve ::#auto $xmlobj $path]
     517            set dobj [Rappture::Curve ::#auto $xmlobj $path]
    470518        }
    471519        datatable {
    472             return [Rappture::DataTable ::#auto $xmlobj $path]
     520            set dobj [Rappture::DataTable ::#auto $xmlobj $path]
    473521        }
    474522        histogram {
    475             return [Rappture::Histogram ::#auto $xmlobj $path]
     523            set dobj [Rappture::Histogram ::#auto $xmlobj $path]
    476524        }
    477525        field {
    478             return [Rappture::Field ::#auto $xmlobj $path]
     526            set dobj [Rappture::Field ::#auto $xmlobj $path]
    479527        }
    480528        mesh {
    481             return [Rappture::Mesh ::#auto $xmlobj $path]
     529            set dobj [Rappture::Mesh ::#auto $xmlobj $path]
    482530        }
    483531        table {
    484             return [Rappture::Table ::#auto $xmlobj $path]
     532            set dobj [Rappture::Table ::#auto $xmlobj $path]
    485533        }
    486534        image {
    487             return [Rappture::Image ::#auto $xmlobj $path]
     535            set dobj [Rappture::Image ::#auto $xmlobj $path]
    488536        }
    489537        sequence {
    490             return [Rappture::Sequence ::#auto $xmlobj $path]
     538            set dobj [Rappture::Sequence ::#auto $xmlobj $path]
    491539        }
    492540        string - log {
    493             return [$xmlobj element -as object $path]
     541            set dobj [$xmlobj element -as object $path]
    494542        }
    495543        structure {
    496             return [$xmlobj element -as object $path]
     544            set dobj [$xmlobj element -as object $path]
    497545        }
    498546        number - integer - boolean - choice {
    499             return [$xmlobj element -as object $path]
     547            set dobj [$xmlobj element -as object $path]
    500548        }
    501549        drawing3d - drawing {
    502             return [Rappture::Drawing ::#auto $xmlobj $path]
     550            set dobj [Rappture::Drawing ::#auto $xmlobj $path]
    503551        }
    504552        time - status {
    505             return ""
    506         }
    507     }
    508     error "don't know how to plot <$type> data path=$path"
     553            set dobj ""
     554        }
     555        default {
     556            error "don't know how to plot <$type> data path=$path"
     557        }
     558    }
     559
     560    # store the mapping xmlobj=>dobj so we can find this result later
     561    if {$dobj ne ""} {
     562        set _xml2data($xmlobj-$path) $dobj
     563    }
     564    return $dobj
     565}
     566
     567# ----------------------------------------------------------------------
     568# USAGE: _cleanIndex <index>
     569#
     570# Used internally to create a data object for the data at the
     571# specified <path> in the <xmlobj>.
     572# ----------------------------------------------------------------------
     573itcl::body Rappture::ResultViewer::_cleanIndex {index} {
     574    if {[regexp {^#([0-9]+)} $index match num]} {
     575        return [expr {$num-1}]  ;# start from 0 instead of 1
     576    } elseif {[string is integer -strict $index]} {
     577        return $index
     578    }
     579    error "bad plot index \"$index\": should be 0,1,2,... or #1,#2,#3,..."
    509580}
    510581
  • branches/blt4/gui/scripts/unirect3d.tcl

    r2745 r2966  
    6868    GetSize $m "zaxis.numpoints" _zNum
    6969    set _compNum $extents
     70    foreach {key path} {
     71        group   about.group
     72        label   about.label
     73        color   about.color
     74        style   about.style
     75        type    about.type
     76        xlabel  xaxis.label
     77        xdesc   xaxis.description
     78        xunits  xaxis.units
     79        xscale  xaxis.scale
     80        ylabel  yaxis.label
     81        ydesc   yaxis.description
     82        yunits  yaxis.units
     83        yscale  yaxis.scale
     84        zlabel  zaxis.label
     85        zdesc   zaxis.description
     86        zunits  zaxis.units
     87        zscale  zaxis.scale
     88        order   about.axisorder
     89    } {
     90        set str [$m get $path]
     91        if {"" != $str} {
     92            set _hints($key) $str
     93        }
     94    }
     95    foreach {key} { axisorder } {
     96        set str [$field get $cname.$key]
     97        if {"" != $str} {
     98            set _hints($key) $str
     99        }
     100    }
    70101    itcl::delete object $m
    71102
     
    193224# ----------------------------------------------------------------------
    194225itcl::body Rappture::Unirect3d::hints {{keyword ""}} {
    195     if {![info exists _hints]} {
    196         foreach {key path} {
    197             group   about.group
    198             label   about.label
    199             color   about.color
    200             style   about.style
    201             type    about.type
    202             xlabel  xaxis.label
    203             xdesc   xaxis.description
    204             xunits  xaxis.units
    205             xscale  xaxis.scale
    206             ylabel  yaxis.label
    207             ydesc   yaxis.description
    208             yunits  yaxis.units
    209             yscale  yaxis.scale
    210             zlabel  zaxis.label
    211             zdesc   zaxis.description
    212             zunits  zaxis.units
    213             zscale  zaxis.scale
    214             order   about.axisorder
    215         } {
    216             set str [$_curve get $path]
    217             if {"" != $str} {
    218                 set _hints($key) $str
    219             }
    220         }
    221 
    222         if {[info exists _hints(xlabel)] && "" != $_hints(xlabel)
    223               && [info exists _hints(xunits)] && "" != $_hints(xunits)} {
    224             set _hints(xlabel) "$_hints(xlabel) ($_hints(xunits))"
    225         }
    226         if {[info exists _hints(ylabel)] && "" != $_hints(ylabel)
    227               && [info exists _hints(yunits)] && "" != $_hints(yunits)} {
    228             set _hints(ylabel) "$_hints(ylabel) ($_hints(yunits))"
    229         }
    230         if {[info exists _hints(zlabel)] && "" != $_hints(zlabel)
    231               && [info exists _hints(zunits)] && "" != $_hints(zunits)} {
    232             set _hints(ylabel) "$_hints(zlabel) ($_hints(zunits))"
    233         }
    234         if {[info exists _hints(group)] && [info exists _hints(label)]} {
    235             # pop-up help for each curve
    236             set _hints(tooltip) $_hints(label)
    237         }
     226    if {[info exists _hints(xlabel)] && "" != $_hints(xlabel)
     227        && [info exists _hints(xunits)] && "" != $_hints(xunits)} {
     228        set _hints(xlabel) "$_hints(xlabel) ($_hints(xunits))"
     229    }
     230    if {[info exists _hints(ylabel)] && "" != $_hints(ylabel)
     231        && [info exists _hints(yunits)] && "" != $_hints(yunits)} {
     232        set _hints(ylabel) "$_hints(ylabel) ($_hints(yunits))"
     233    }
     234    if {[info exists _hints(zlabel)] && "" != $_hints(zlabel)
     235        && [info exists _hints(zunits)] && "" != $_hints(zunits)} {
     236        set _hints(ylabel) "$_hints(zlabel) ($_hints(zunits))"
     237    }
     238
     239    if {[info exists _hints(group)] && [info exists _hints(label)]} {
     240        # pop-up help for each curve
     241        set _hints(tooltip) $_hints(label)
    238242    }
    239243    if {$keyword != ""} {
  • branches/blt4/gui/scripts/visviewer.tcl

    r2745 r2966  
    4040    #private variable _idleTimeout 5000;    # 5 seconds
    4141    #private variable _idleTimeout 0;       # No timeout
     42    private variable _logging 0
    4243
    4344    protected variable _dispatcher "";  # dispatcher for !events
     
    163164    pack $itk_component(plotarea) -fill both -expand yes
    164165    set _image(plot) [image create picture]
     166
     167    global env
     168    if { [info exists env(VISRECORDER)] } {
     169        set _logging 1
     170    }
    165171    eval itk_initialize $args
    166172}
     
    421427
    422428#
    423 # ReceiveBytes --
     429# StartWaiting --
    424430#
    425431#    Read some number of bytes from the visualization server.
     
    544550#
    545551itcl::body Rappture::VisViewer::SendEcho {channel {data ""}} {
     552    if { $_logging }  {
     553        set f [open "/tmp/recording.log" "a"]
     554        puts $f $data
     555        close $f
     556    }
    546557    #puts stderr ">>($data)"
    547558    if {[string length $itk_option(-sendcommand)] > 0} {
  • branches/blt4/gui/scripts/vtkvolumeviewer.tcl

    r2791 r2966  
    258258        cutplane-zposition      50
    259259        cutplane-visible        1
     260        cutplane-lighting       1
    260261        cutplane-wireframe      0
    261262        cutplane-opacity        100
    262263        volume-lighting         1
     264        volume-material         80
    263265        volume-opacity          40
     266        volume-quality          50
    264267        volume-visible          1
    265         volume-wireframe        0
    266268        legend-visible          1
    267269    }]
     
    994996    set _first ""
    995997    InitSettings axis-xgrid axis-ygrid axis-zgrid axis-mode \
    996         axis-visible axis-labels cutplane-visible \
    997         cutplane-xposition cutplane-yposition cutplane-zposition \
    998         cutplane-xvisible cutplane-yvisible cutplane-zvisible
     998        axis-visible axis-labels
    999999
    10001000    SendCmd "imgflush"
     
    11001100    }
    11011101
    1102     InitSettings volume-palette volume-visible
     1102    InitSettings volume-palette volume-material volume-quality volume-visible \
     1103        cutplane-visible \
     1104        cutplane-xposition cutplane-yposition cutplane-zposition \
     1105        cutplane-xvisible cutplane-yvisible cutplane-zvisible
    11031106
    11041107    if { $_reset } {
     
    13631366            }
    13641367        }
     1368        "volume-material" {
     1369            set val $_settings(volume-material)
     1370            set diffuse [expr {0.01*$val}]
     1371            set specular [expr {0.01*$val}]
     1372            #set power [expr {sqrt(160*$val+1.0)}]
     1373            set power [expr {$val+1.0}]
     1374            foreach dataset [CurrentDatasets -visible] {
     1375                SendCmd "volume shading diffuse $diffuse $dataset"
     1376                SendCmd "volume shading specular $specular $power $dataset"
     1377            }
     1378        }
    13651379        "volume-lighting" {
    13661380            set bool $_settings(volume-lighting)
    13671381            foreach dataset [CurrentDatasets -visible] {
    13681382                SendCmd "volume lighting $bool $dataset"
     1383            }
     1384        }
     1385        "volume-quality" {
     1386            set val $_settings(volume-quality)
     1387            set val [expr {0.01*$val}]
     1388            foreach dataset [CurrentDatasets -visible] {
     1389                SendCmd "volume quality $val $dataset"
    13691390            }
    13701391        }
     
    14291450                    -troughcolor grey82
    14301451            }
    1431             SendCmd "cutplane axis $axis $bool"
     1452            foreach dataset [CurrentDatasets -visible] {
     1453                SendCmd "cutplane axis $axis $bool $dataset"
     1454            }
    14321455        }
    14331456        "cutplane-xposition" - "cutplane-yposition" - "cutplane-zposition" {
    14341457            set axis [string range $what 9 9]
    14351458            set pos [expr $_settings($what) * 0.01]
    1436             SendCmd "cutplane slice ${axis} ${pos}"
     1459            foreach dataset [CurrentDatasets -visible] {
     1460                SendCmd "cutplane slice ${axis} ${pos} $dataset"
     1461            }
    14371462            set _cutplanePending 0
    14381463        }
     
    15651590         $_dataset2style($tag) != $name } {
    15661591        SendCmd "volume colormap $name $tag"
    1567         SendCmd "cutplane colormap $name $tag"
     1592        SendCmd "cutplane colormap $name-opaque $tag"
    15681593        set _dataset2style($tag) $name
    15691594    }
     
    17981823    set max $_settings(volume-opacity)
    17991824
    1800     set wmap "0.0 1.0 1.0 1.0"
    1801     set wmap "0.0 0.0 0.1 0.0 0.2 0.8 0.98 0.8 0.99 0.0 1.0 0.0"
     1825    set opaqueWmap "0.0 1.0 1.0 1.0"
     1826    #set wmap "0.0 0.0 0.1 0.0 0.2 0.8 0.98 0.8 0.99 0.0 1.0 0.0"
     1827    # Approximate cubic opacity curve
     1828    set wmap "0.0 0.0 0.1 0.001 0.2 0.008 0.3 0.027 0.4 0.064 0.5 0.125 0.6 0.216 0.7 0.343 0.8 0.512 0.9 0.729 1.0 1.0"
    18021829    SendCmd "colormap add $name { $cmap } { $wmap }"
     1830    SendCmd "colormap add $name-opaque { $cmap } { $opaqueWmap }"
    18031831}
    18041832
     
    19171945        -font "Arial 9"
    19181946
     1947    label $inner.dim_l -text "Dim" -font "Arial 9"
     1948    ::scale $inner.material -from 0 -to 100 -orient horizontal \
     1949        -variable [itcl::scope _settings(volume-material)] \
     1950        -width 10 \
     1951        -showvalue off -command [itcl::code $this AdjustSetting volume-material]
     1952    label $inner.bright_l -text "Bright" -font "Arial 9"
     1953
    19191954    label $inner.opacity_l -text "Opacity" -font "Arial 9"
    19201955    ::scale $inner.opacity -from 0 -to 100 -orient horizontal \
     
    19231958        -showvalue off \
    19241959        -command [itcl::code $this AdjustSetting volume-opacity]
     1960
     1961    label $inner.quality_l -text "Quality" -font "Arial 9"
     1962    ::scale $inner.quality -from 0 -to 100 -orient horizontal \
     1963        -variable [itcl::scope _settings(volume-quality)] \
     1964        -width 10 \
     1965        -showvalue off -command [itcl::code $this AdjustSetting volume-quality]
    19251966
    19261967    label $inner.field_l -text "Field" -font "Arial 9"
     
    19581999
    19592000    blt::table $inner \
    1960         0,0 $inner.volume    -anchor w -pady 2 \
    1961         2,0 $inner.lighting  -anchor w -pady 2 \
    1962         6,0 $inner.field_l     -anchor w -pady 2  \
    1963         6,1 $inner.field       -anchor w -pady 2  \
    1964         7,0 $inner.palette_l   -anchor w -pady 2  \
    1965         7,1 $inner.palette     -anchor w -pady 2  \
     2001        0,0 $inner.volume    -anchor w -pady 2 -cspan 4 \
     2002        2,0 $inner.lighting  -anchor w -pady 2 -cspan 4 \
     2003        3,0 $inner.dim_l     -anchor e -pady 2 \
     2004        3,1 $inner.material  -fill x   -pady 2 \
     2005        3,2 $inner.bright_l  -anchor w -pady 2 \
     2006        4,0 $inner.quality_l -anchor w -pady 2 -cspan 2 \
     2007        5,0 $inner.quality   -fill x   -pady 2 -cspan 2 \
     2008        6,0 $inner.field_l   -anchor w -pady 2  \
     2009        6,1 $inner.field     -anchor w -pady 2 -cspan 2 \
     2010        7,0 $inner.palette_l -anchor w -pady 2  \
     2011        7,1 $inner.palette   -anchor w -pady 2 -cspan 2 \
    19662012
    19672013    blt::table configure $inner r* c* -resize none
    1968     blt::table configure $inner r8 c1 -resize expand
     2014    blt::table configure $inner r8 c3 -resize expand
    19692015}
    19702016
     
    23632409    #SendCmd "cutplane visible $tag"
    23642410    foreach axis { x y z } {
    2365         SendCmd "cutplane slice $axis 1.0 $tag"
     2411        SendCmd "cutplane slice $axis 0.5 $tag"
    23662412        SendCmd "cutplane axis $axis 0 $tag"
    23672413    }
  • branches/blt4/gui/scripts/xyresult.tcl

    r2746 r2966  
    115115    common _downloadPopup          ;# download options from popup
    116116    private variable _markers
     117    private variable _nextElement 0
    117118}
    118119                                                                               
     
    684685            }
    685686
    686             set elem "elem[incr count]"
     687            set elem "elem[incr _nextElement]"
    687688            set _elem2dataobj($elem) $dataobj
    688689            lappend label2elem($label) $elem
  • branches/blt4/lang/tcl/scripts/library.tcl

    r2936 r2966  
    511511    }
    512512    set string [$node text]
    513     # Expat (via tDOM) will always produce utf-8 output, regardless of the
    514     # encoding of the tool.xml.  We need to convert utf-8 to unicode for
    515     # Tcl/Tk.  This shouldn't affect ASCII tool.xml files.
    516     #puts stderr "before $path=$string"
    517     #set string [encoding convertfrom utf-8 $string]
    518     #puts stderr "after $path=$string [string length $string]"
    519     #Rappture::encoding::debug $string
    520513    if {$params(-decode) == "yes"} {
    521514        set string [Rappture::encoding::decode -- $string]
    522     }
    523     puts stderr "returning $path=$string"
    524     return [string trim $string]
     515    } else {
     516        set string [string trim $string]
     517    }
     518    return $string
    525519}
    526520
  • branches/blt4/lang/tcl/src/RpEncodeTclInterface.cc

    r2936 r2966  
    278278
    279279    string = Tcl_GetStringFromObj(objv[last], &numBytes);
    280 
     280    if ((switches.flags == 0) && (strncmp(string, "@@RP-ENC:", 9) != 0)) {
     281        /* This string doesn't have a header, so it's not encoded.
     282         * Just return the string as-is. */
     283        Tcl_SetObjResult(interp, objv[last]);
     284        return TCL_OK;
     285    }
    281286    Rappture::Buffer buf(string, numBytes);
    282 
    283287    Rappture::Outcome status;
    284288    if (!Rappture::encoding::decode(status, buf, switches.flags)) {
     
    286290        return TCL_ERROR;
    287291    }
    288     Tcl_SetStringObj(Tcl_GetObjResult(interp), buf.bytes(), buf.size());
     292    Tcl_SetByteArrayObj(Tcl_GetObjResult(interp),
     293                        (const unsigned char *)buf.bytes(), buf.size());
    289294    return TCL_OK;
    290295}
  • branches/blt4/packages/vizservers/nanovis/Axis.cpp

    r2936 r2966  
    111111
    112112Axis::Axis(const char *axisName) :
    113     _name(axisName),
     113    _name(strdup(axisName)),
    114114    _flags(AUTOSCALE),
    115115    _title(NULL),
  • branches/blt4/packages/vizservers/nanovis/Axis.h

    r2936 r2966  
    22#ifndef AXIS_H
    33#define AXIS_H
     4
     5#include <stdlib.h>
    46
    57#include <cmath>
     
    4547};
    4648
    47 /*
    48  * ----------------------------------------------------------------------
    49  *
    50  * Ticks --
    51  *
    52  *         Structure containing information where the ticks (major or
    53  *        minor) will be displayed on the graph.
    54  *
    55  * ----------------------------------------------------------------------
     49/**
     50 * Class containing information where the ticks (major or
     51 * minor) will be displayed on the graph.
    5652 */
    5753class Ticks
     
    182178
    183179/**
    184  * Structure contains options controlling how the axis will be
     180 * Class contains options controlling how the axis will be
    185181 * displayed.
    186182 */
     
    212208    }
    213209
     210    bool firstMajor(TickIter& iter)
     211    {
     212        return _major.firstTick(iter);
     213    }
     214
     215    bool firstMinor(TickIter& iter)
     216    {
     217        return _minor.firstTick(iter);
     218    }
     219
    214220    void resetRange();
    215221
     
    218224    void setScale(double min, double max);
    219225
    220     double scale()
     226    double scale() const
    221227    {
    222228        return _scale;
    223229    }
    224230
    225     double range()
     231    double range() const
    226232    {
    227233        return _range;
    228234    }
    229235
    230     bool firstMajor(TickIter& iter)
    231     {
    232         return _major.firstTick(iter);
    233     }
    234 
    235     bool firstMinor(TickIter& iter)
    236     {
    237         return _minor.firstTick(iter);
    238     }
    239 
    240236    void getDataLimits(double& min, double& max)
    241237    {
    242238        min = _valueMin, max = _valueMax;
     239    }
     240
     241    double min() const
     242    {
     243        return _min;
     244    }
     245
     246    void min(double min)
     247    {
     248        _reqMin = min;
     249    }
     250
     251    double max() const
     252    {
     253        return _max;
     254    }
     255
     256    void max(double max)
     257    {
     258        _reqMax = max;
     259    }
     260
     261    void setLimits(double min, double max)
     262    {
     263        _reqMin = min, _reqMax = max;
     264    }
     265
     266    void unsetLimits()
     267    {
     268        min(NAN), max(NAN);
    243269    }
    244270
     
    284310        }
    285311        _title = strdup(title);
    286     }
    287 
    288     double min()
    289     {
    290         return _min;
    291     }
    292 
    293     void min(double min)
    294     {
    295         _reqMin = min;
    296     }
    297 
    298     double max()
    299     {
    300         return _max;
    301     }
    302 
    303     void max(double max)
    304     {
    305         _reqMax = max;
    306     }
    307 
    308     void setLimits(double min, double max)
    309     {
    310         _reqMin = min, _reqMax = max;
    311     }
    312 
    313     void unsetLimits()
    314     {
    315         min(NAN), max(NAN);
    316312    }
    317313
  • branches/blt4/packages/vizservers/nanovis/Command.cpp

    r2936 r2966  
    7878  1.0  1 0 1\n\
    7979} {\n\
    80   0.00  1.0\n\
    81   0.05  0.0\n\
    82   0.15  0.0\n\
    83   0.20  1.0\n\
    84   0.25  0.0\n\
    85   0.35  0.0\n\
    86   0.40  1.0\n\
    87   0.45  0.0\n\
    88   0.55  0.0\n\
    89   0.60  1.0\n\
    90   0.65  0.0\n\
    91   0.75  0.0\n\
    92   0.80  1.0\n\
    93   0.85  0.0\n\
    94   0.95  0.0\n\
    95   1.00  1.0\n\
     80  0.00000  0.0\n\
     81  0.19999  0.0\n\
     82  0.20000  1.0\n\
     83  0.20001  0.0\n\
     84  0.39999  0.0\n\
     85  0.40000  1.0\n\
     86  0.40001  0.0\n\
     87  0.59999  0.0\n\
     88  0.60000  1.0\n\
     89  0.60001  0.0\n\
     90  0.79999  0.0\n\
     91  0.80000  1.0\n\
     92  0.80001  0.0\n\
     93  1.00000  0.0\n\
    9694}";
    9795
     
    651649    NanoVis::readScreen();
    652650
    653     NanoVis::ppmWrite("nv>image -bytes %d -type print");
     651    NanoVis::ppmWrite("nv>image -type print -bytes %d");
    654652    NanoVis::resizeOffscreenBuffer(w, h);
    655653
  • branches/blt4/packages/vizservers/nanovis/FlowCmd.cpp

    r2936 r2966  
    561561
    562562    Vector3 loc = _volPtr->location();
    563     /*This is wrong. Need to compute origin. */
    564     NanoVis::xOrigin = loc.x;
    565     NanoVis::yOrigin = loc.y;
    566     NanoVis::zOrigin = loc.z;
    567563
    568564    _fieldPtr->setVectorField(_volPtr, loc,
     
    657653    Volume *volPtr;
    658654
    659     volPtr = NanoVis::loadVolume(_name, _dataPtr->xNum(), _dataPtr->yNum(),
    660                                  _dataPtr->zNum(), 4, data,
     655    volPtr = NanoVis::loadVolume(_name,
     656                                 _dataPtr->xNum(),
     657                                 _dataPtr->yNum(),
     658                                 _dataPtr->zNum(),
     659                                 4, data,
    661660                                 NanoVis::magMin, NanoVis::magMax, 0);
    662661    volPtr->xAxis.setRange(_dataPtr->xMin(), _dataPtr->xMax());
     
    672671          NanoVis::magMin, NanoVis::magMax);
    673672    volPtr->setPhysicalBBox(physicalMin, physicalMax);
    674     //volPtr->numSlices(256 - _volIndex);
    675     //volPtr->numSlices(512 - _volIndex);
    676     //volPtr->numSlices(256 - n);
    677     // TBD..
    678     /* Don't set the slice number until we're are about to render the
    679        volume. */
    680673    volPtr->disableCutplane(0);
    681674    volPtr->disableCutplane(1);
     
    689682    volPtr->specular(_sv.specular);
    690683    volPtr->diffuse(_sv.diffuse);
    691     TRACE("volume is now %d %d\n", _sv.showVolume, volPtr->visible());
    692684    volPtr->visible(_sv.showVolume);
    693685    float dx0 = -0.5;
     
    10181010            continue;
    10191011        }
    1020         Rappture::Unirect3d *dataPtr;
    1021         dataPtr = flowPtr->data();
     1012        Rappture::Unirect3d *dataPtr = flowPtr->data();
    10221013        min = dataPtr->magMin();
    10231014        max = dataPtr->magMax();
     
    10651056        // FIXME: This doesn't work when there is more than one flow.
    10661057        licRenderer->setOffset(flowPtr->GetRelativePosition());
    1067         NanoVis::velocityArrowsSlice->slicePos(flowPtr->GetRelativePosition());
     1058        velocityArrowsSlice->slicePos(flowPtr->GetRelativePosition());
    10681059    }
    10691060    AdvectFlows();
  • branches/blt4/packages/vizservers/nanovis/Grid.cpp

    r2936 r2966  
    1818    _majorColor(1.0f, 1.0f, 1.0f, 1.0f),
    1919    _minorColor(0.5f, 0.5f, 0.5f, 1.0f),
    20     _font(0),
     20    _font(NULL),
    2121    _visible(false)
     22{
     23}
     24
     25Grid::~Grid()
    2226{
    2327}
  • branches/blt4/packages/vizservers/nanovis/Grid.h

    r2936 r2966  
    3333public:
    3434    Grid();
     35    virtual ~Grid();
    3536
    3637    bool isVisible() const
  • branches/blt4/packages/vizservers/nanovis/HeightMap.cpp

    r2936 r2966  
    11 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #include <memory.h>
    3 #include <stdlib.h>
    4 #include <sys/time.h>
    5 #include <sys/types.h>
    6 #include <unistd.h>
    7 #include <fcntl.h>
    8 #include <stdlib.h>
    9 
    102#include <GL/glew.h>
    11 #include <Cg/cgGL.h>
    123
    134#include "Grid.h"
     
    156#include "ContourLineFilter.h"
    167#include "Texture1D.h"
    17 #include "R2/R2FilePath.h"
    18 #include "RpField1D.h"
    198#include "RenderContext.h"
    209
     
    2716HeightMap::HeightMap() :
    2817    _vertexBufferObjectID(0),
    29     _textureBufferObjectID(0),
     18    _texcoordBufferObjectID(0),
    3019    _vertexCount(0),
    3120    _contour(0),
     
    4534    _shader = new NvShader();
    4635    _shader->loadFragmentProgram("heightcolor.cg", "main");
    47     _tfParam      = _shader->getNamedParameterFromFP("tf");
    48     _opacityParam = _shader->getNamedParameterFromFP("opacity");
    4936}
    5037
     
    5340    reset();
    5441
    55     if (_shader) {
     42    if (_shader != NULL) {
    5643        delete _shader;
    5744    }
    5845    if (_heights != NULL) {
    59         free(_heights);
     46        delete [] _heights;
    6047    }
    6148}
     
    10592            //
    10693            _shader->bind();
    107  
    108             cgGLSetTextureParameter(_tfParam, _tfPtr->id());
    109             cgGLEnableTextureParameter(_tfParam);
    110             cgGLSetParameter1f(_opacityParam, _opacity);
     94            _shader->setFPTextureParameter("tf", _tfPtr->id());
     95            _shader->setFPParameter1f("opacity", _opacity);
    11196
    11297            glEnable(GL_TEXTURE_1D);
     
    119104        glVertexPointer(3, GL_FLOAT, 12, 0);
    120105
    121         glBindBuffer(GL_ARRAY_BUFFER, _textureBufferObjectID);
     106        glBindBuffer(GL_ARRAY_BUFFER, _texcoordBufferObjectID);
    122107        glTexCoordPointer(3, GL_FLOAT, 12, 0);
    123108
     
    138123            glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    139124
     125            _shader->disableFPTextureParameter("tf");
    140126            _shader->unbind();
    141127        }
     
    247233        _vertexBufferObjectID = 0;
    248234    }
    249     if (_textureBufferObjectID) {
    250         glDeleteBuffers(1, &_textureBufferObjectID);
    251         _textureBufferObjectID = 0;
     235    if (_texcoordBufferObjectID) {
     236        glDeleteBuffers(1, &_texcoordBufferObjectID);
     237        _texcoordBufferObjectID = 0;
    252238    }
    253239    if (_contour != NULL) {
     
    260246    }
    261247}
    262 
     248#if 0
    263249void
    264250HeightMap::setHeight(int xCount, int yCount, Vector3 *heights)
     
    302288    glBufferData(GL_ARRAY_BUFFER, _vertexCount * sizeof( Vector3 ), heights,
    303289        GL_STATIC_DRAW);
    304     glGenBuffers(1, &_textureBufferObjectID);
    305     glBindBuffer(GL_ARRAY_BUFFER, _textureBufferObjectID);
     290    glGenBuffers(1, &_texcoordBufferObjectID);
     291    glBindBuffer(GL_ARRAY_BUFFER, _texcoordBufferObjectID);
    306292    glBufferData(GL_ARRAY_BUFFER, _vertexCount * sizeof(float) * 3, texcoord,
    307293        GL_STATIC_DRAW);
     
    333319    //}
    334320}
    335 
     321#endif
    336322void
    337323HeightMap::setHeight(float xMin, float yMin, float xMax, float yMax,
     
    394380    glBufferData(GL_ARRAY_BUFFER, _vertexCount * sizeof(Vector3), map,
    395381        GL_STATIC_DRAW);
    396     glGenBuffers(1, &_textureBufferObjectID);
    397     glBindBuffer(GL_ARRAY_BUFFER, _textureBufferObjectID);
     382    glGenBuffers(1, &_texcoordBufferObjectID);
     383    glBindBuffer(GL_ARRAY_BUFFER, _texcoordBufferObjectID);
    398384    glBufferData(GL_ARRAY_BUFFER, _vertexCount * sizeof(float) * 3, texcoord,
    399385        GL_STATIC_DRAW);
     
    494480    glBufferData(GL_ARRAY_BUFFER, _vertexCount * sizeof(Vector3), vertices,
    495481        GL_STATIC_DRAW);
    496     glGenBuffers(1, &_textureBufferObjectID);
    497     glBindBuffer(GL_ARRAY_BUFFER, _textureBufferObjectID);
     482    glGenBuffers(1, &_texcoordBufferObjectID);
     483    glBindBuffer(GL_ARRAY_BUFFER, _texcoordBufferObjectID);
    498484    glBufferData(GL_ARRAY_BUFFER, _vertexCount * sizeof(float) * 3, texcoord,
    499485        GL_STATIC_DRAW);
     
    578564        if (_tfPtr != NULL) {
    579565            _shader->bind();
    580            
    581             cgGLSetTextureParameter(_tfParam, _tfPtr->id());
    582             cgGLEnableTextureParameter(_tfParam);
     566
     567            _shader->setFPTextureParameter("tf", _tfPtr->id());
    583568
    584569            glEnable(GL_TEXTURE_1D);
     
    593578        glVertexPointer(3, GL_FLOAT, 12, 0);
    594579
    595         glBindBuffer(GL_ARRAY_BUFFER, _textureBufferObjectID);
     580        glBindBuffer(GL_ARRAY_BUFFER, _texcoordBufferObjectID);
    596581        glTexCoordPointer(3, GL_FLOAT, 12, 0);
    597582
     
    612597            glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    613598
     599            _shader->disableFPTextureParameter("tf");
    614600            _shader->unbind();
    615601        }
  • branches/blt4/packages/vizservers/nanovis/HeightMap.h

    r2936 r2966  
    22#ifndef HEIGHTMAP_H
    33#define HEIGHTMAP_H
    4 
    5 #include <Cg/cg.h>
    64
    75#include <R2/graphics/R2Geometry.h>
     
    3634    /**
    3735     *@brief Create a height map with heigh values
    38      *@param startX a x position of the first height value
    39      *@param startY a y position of the first height value
    40      *@param endX a x position of the last height value
    41      *@param endY a y position of the last height value
     36     *@param startX x position of the first height value
     37     *@param startY y position of the first height value
     38     *@param endX x position of the last height value
     39     *@param endY y position of the last height value
    4240     *@param xCount the number of columns of height values
    4341     *@param yCount the number of rows of height values
     
    4644    void setHeight(float startX, float startY, float endX, float endY,
    4745                   int xCount, int yCount, float *height);
    48 
     46#if 0
    4947    /**
    5048     *@brief Create a height map with a set of points
     
    5351     */
    5452    void setHeight(int xCount, int yCount, Vector3 *heights);
    55 
     53#endif
    5654    void mapToGrid(Grid *gridPtr);
    5755
     
    126124
    127125private:
    128     void createIndexBuffer(int xCount, int zCount, float* heights);
     126    void createIndexBuffer(int xCount, int zCount, float *heights);
    129127    Vector3 *createHeightVertices(float startX, float startY,
    130128                                  float endX, float endY,
    131                                   int xCount, int yCount, float  *height);
     129                                  int xCount, int yCount, float *height);
    132130    void reset();
    133131
    134132    unsigned int _vertexBufferObjectID;
    135     unsigned int _textureBufferObjectID;
     133    unsigned int _texcoordBufferObjectID;
    136134    int _vertexCount;
    137     CGparameter _tfParam;
    138     CGparameter _opacityParam;
    139135    R2Geometry *_contour;
    140136    R2Geometry *_topContour;
     
    145141    int _indexCount;
    146142    Vector3 _contourColor;
    147    
     143
    148144    bool _contourVisible;
    149145    bool _topContourVisible;
    150146    bool _visible;
    151    
     147
    152148    Vector3 _scale;
    153149    Vector3 _centerPoint;
  • branches/blt4/packages/vizservers/nanovis/Makefile.in

    r2936 r2966  
    120120                NvColorTableRenderer.o \
    121121                NvColorTableShader.o \
    122                 NvDefaultTFData.o \
    123122                NvEventLog.o \
    124                 NvFlowVisRenderer.o \
    125123                NvLIC.o \
    126124                NvParticleAdvectionShader.o \
     
    180178ifdef NOTDEF
    181179OBJS +=         DataLoader.o \
     180                NvFlowVisRenderer.o \
    182181                ParticleEmitter.o \
    183182                ParticleSystem.o \
     
    301300NvColorTableRenderer.o: NvColorTableRenderer.cpp NvColorTableRenderer.h
    302301NvColorTableShader.o: NvColorTableShader.cpp NvColorTableShader.h NvShader.h
    303 NvDefaultTFData.o: NvDefaultTFData.cpp
    304302NvEventLog.o: NvEventLog.cpp NvEventLog.h
    305303NvFlowVisRenderer.o: NvFlowVisRenderer.cpp NvFlowVisRenderer.h
  • branches/blt4/packages/vizservers/nanovis/NvColorTableRenderer.cpp

    r2936 r2966  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    22#include <stdlib.h>
     3
     4#include <GL/glew.h>
    35
    46#include <R2/R2Fonts.h>
  • branches/blt4/packages/vizservers/nanovis/NvColorTableShader.cpp

    r2936 r2966  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #include <R2/R2FilePath.h>
    3 
    4 #include <GL/glew.h>
    5 #include <Cg/cgGL.h>
    6 
    72#include "NvColorTableShader.h"
    8 #include "Trace.h"
    93
    104NvColorTableShader::NvColorTableShader()
     
    2014{
    2115    loadFragmentProgram("one_plane.cg", "main");
    22     _dataParam = getNamedParameterFromFP("data");
    23     _tfParam = getNamedParameterFromFP("tf");
    24     _renderParam = getNamedParameterFromFP("render_param");
    2516}
    2617
    2718void NvColorTableShader::bind(Texture2D *plane, TransferFunction *tf)
    2819{
    29     cgGLSetTextureParameter(_dataParam, plane->id());
    30     cgGLSetTextureParameter(_tfParam, tf->id());
    31     cgGLEnableTextureParameter(_dataParam);
    32     cgGLEnableTextureParameter(_tfParam);
    33     cgGLSetParameter4f(_renderParam, 0., 0., 0., 0.);
     20    setFPTextureParameter("data", plane->id());
     21    setFPTextureParameter("tf", tf->id());
     22
     23    setFPParameter4f("render_param", 0., 0., 0., 0.);
    3424
    3525    NvShader::bind();
     
    3828void NvColorTableShader::unbind()
    3929{
    40     cgGLDisableTextureParameter(_dataParam);
    41     cgGLDisableTextureParameter(_tfParam);
     30    disableFPTextureParameter("data");
     31    disableFPTextureParameter("tf");
    4232
    4333    NvShader::unbind();
  • branches/blt4/packages/vizservers/nanovis/NvColorTableShader.h

    r2936 r2966  
    22#ifndef NV_COLORTABLE_SHADER_H
    33#define NV_COLORTABLE_SHADER_H
    4 
    5 #include <Cg/cg.h>
    64
    75#include "NvShader.h"
     
    2220private :
    2321    void init();
    24 
    25     CGparameter _dataParam;
    26     CGparameter _tfParam;
    27     CGparameter _renderParam;
    2822};
    2923
  • branches/blt4/packages/vizservers/nanovis/NvFlowVisRenderer.cpp

    r2936 r2966  
    1515 */
    1616
    17 #include <stdio.h>
    18 #include <assert.h>
    19 #include <malloc.h>
    20 #include <string.h>
    21 
    22 #include <R2/R2FilePath.h>
    23 
    2417#include "NvFlowVisRenderer.h"
    25 #include "NvVectorField.h"
    26 #include "Trace.h"
    2718
    2819#define NV_32
  • branches/blt4/packages/vizservers/nanovis/NvFlowVisRenderer.h

    r2936 r2966  
    33#define NVFLOWVISRENDERER_H
    44
    5 #include <vector>
    65#include <map>
    76#include <string>
    87
    9 #include <GL/glew.h>
    10 #include <Cg/cgGL.h>
    11 
    12 #include "config.h"
    13 
    14 #include "Renderable.h"
    15 #include "RenderVertexArray.h"
    168#include "Vector3.h"
    17 #include "NvParticleAdvectionShader.h"
    189#include "NvVectorField.h"
    1910
  • branches/blt4/packages/vizservers/nanovis/NvLIC.cpp

    r2936 r2966  
    3030
    3131NvLIC::NvLIC(int size, int width, int height, int axis,
    32              const Vector3& offset) :
     32             float offset) :
    3333    Renderable(Vector3(0.0f, 0.0f, 0.0f)),
    3434    _width(width),
     
    265265        case 0 :
    266266            // TBD..
    267             glTexCoord3f(_offset.x, 0., 0.); glVertex2f(0.,    0.);
    268             glTexCoord3f(_offset.x, 1., 0.); glVertex2f(_size, 0.);
    269             glTexCoord3f(_offset.x, 1., 1.); glVertex2f(_size, _size);
    270             glTexCoord3f(_offset.x, 0., 1.); glVertex2f(0.,    _size);
     267            glTexCoord3f(_offset, 0., 0.); glVertex2f(0.,    0.);
     268            glTexCoord3f(_offset, 1., 0.); glVertex2f(_size, 0.);
     269            glTexCoord3f(_offset, 1., 1.); glVertex2f(_size, _size);
     270            glTexCoord3f(_offset, 0., 1.); glVertex2f(0.,    _size);
    271271                break;
    272272        case 1 :
    273273            // TBD..
    274             glTexCoord3f(0., _offset.y, 0.); glVertex2f(0.,    0.);
    275             glTexCoord3f(1., _offset.y, 0.); glVertex2f(_size, 0.);
    276             glTexCoord3f(1., _offset.y, 1.); glVertex2f(_size, _size);
    277             glTexCoord3f(0., _offset.y, 1.); glVertex2f(0.,    _size);
     274            glTexCoord3f(0., _offset, 0.); glVertex2f(0.,    0.);
     275            glTexCoord3f(1., _offset, 0.); glVertex2f(_size, 0.);
     276            glTexCoord3f(1., _offset, 1.); glVertex2f(_size, _size);
     277            glTexCoord3f(0., _offset, 1.); glVertex2f(0.,    _size);
    278278                break;
    279279        case 2 :
    280             glTexCoord3f(0., 0., _offset.z); glVertex2f(0.,    0.);
    281             glTexCoord3f(1., 0., _offset.z); glVertex2f(_size, 0.);
    282             glTexCoord3f(1., 1., _offset.z); glVertex2f(_size, _size);
    283             glTexCoord3f(0., 1., _offset.z); glVertex2f(0.,    _size);
     280            glTexCoord3f(0., 0., _offset); glVertex2f(0.,    0.);
     281            glTexCoord3f(1., 0., _offset); glVertex2f(_size, 0.);
     282            glTexCoord3f(1., 1., _offset); glVertex2f(_size, _size);
     283            glTexCoord3f(0., 1., _offset); glVertex2f(0.,    _size);
    284284            break;
    285285        }
     
    459459    case 0:
    460460        glNormal3f(1, 0, 0);
    461         glTexCoord2f(0, 0); glVertex3f(_offset.x, 0, 0);
    462         glTexCoord2f(1, 0); glVertex3f(_offset.x, 1, 0);
    463         glTexCoord2f(1, 1); glVertex3f(_offset.x, 1, 1);
    464         glTexCoord2f(0, 1); glVertex3f(_offset.x, 0, 1);
     461        glTexCoord2f(0, 0); glVertex3f(_offset, 0, 0);
     462        glTexCoord2f(1, 0); glVertex3f(_offset, 1, 0);
     463        glTexCoord2f(1, 1); glVertex3f(_offset, 1, 1);
     464        glTexCoord2f(0, 1); glVertex3f(_offset, 0, 1);
    465465        break;
    466466    case 1:
    467467        glNormal3f(0, 1, 0);
    468         glTexCoord2f(0, 0); glVertex3f(0, _offset.y, 0);
    469         glTexCoord2f(1, 0); glVertex3f(1, _offset.y, 0);
    470         glTexCoord2f(1, 1); glVertex3f(1, _offset.y, 1);
    471         glTexCoord2f(0, 1); glVertex3f(0, _offset.y, 1);
     468        glTexCoord2f(0, 0); glVertex3f(0, _offset, 0);
     469        glTexCoord2f(1, 0); glVertex3f(1, _offset, 0);
     470        glTexCoord2f(1, 1); glVertex3f(1, _offset, 1);
     471        glTexCoord2f(0, 1); glVertex3f(0, _offset, 1);
    472472        break;
    473473    case 2:
    474474        glNormal3f(0, 0, 1);
    475         glTexCoord2f(0, 0); glVertex3f(0, 0, _offset.z);
    476         glTexCoord2f(1, 0); glVertex3f(1, 0, _offset.z);
    477         glTexCoord2f(1, 1); glVertex3f(1, 1, _offset.z);
    478         glTexCoord2f(0, 1); glVertex3f(0, 1, _offset.z);
     475        glTexCoord2f(0, 0); glVertex3f(0, 0, _offset);
     476        glTexCoord2f(1, 0); glVertex3f(1, 0, _offset);
     477        glTexCoord2f(1, 1); glVertex3f(1, 1, _offset);
     478        glTexCoord2f(0, 1); glVertex3f(0, 1, _offset);
    479479        break;
    480480    }
     
    530530
    531531void
    532 NvLIC::setOffset(float v)
    533 {
    534     switch (_axis) {
    535     case 0 : _offset.x = v; break;
    536     case 1 : _offset.y = v; break;
    537     case 2 : _offset.z = v; break;
    538     }
     532NvLIC::setOffset(float offset)
     533{
     534    _offset = offset;
    539535    getSlice();
    540536}
  • branches/blt4/packages/vizservers/nanovis/NvLIC.h

    r2936 r2966  
    3131{
    3232public:
    33     NvLIC(int size, int width, int height, int axis,
    34           const Vector3& offset);
     33    NvLIC(int size, int width, int height, int axis, float offset);
    3534    ~NvLIC();
    3635
     
    4948    void getSlice();
    5049
    51     void setOffset(float v);
     50    void setOffset(float offset);
    5251
    5352    /**
     
    10099                                        // plane to fit the actual dimensions
    101100    Vector3 _origin;
    102     Vector3 _offset;                    // [0,1] offset could be x, y, or z
    103                                         // direction
     101    float _offset;                      // [0,1] offset of _axis plane
    104102    int _axis;
    105103
  • branches/blt4/packages/vizservers/nanovis/NvParticleAdvectionShader.cpp

    r2936 r2966  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #include <R2/R2FilePath.h>
    3 
    4 #include <GL/glew.h>
    5 #include <Cg/cgGL.h>
    6 
    72#include "NvParticleAdvectionShader.h"
    8 #include "Trace.h"
    93
    104NvParticleAdvectionShader::NvParticleAdvectionShader() :
     
    2519{
    2620    loadFragmentProgram("update_pos.cg", "main");
    27     _posTexParam       = getNamedParameterFromFP("pos_tex");
    28     _initPosTexParam   = getNamedParameterFromFP("init_pos_tex");
    29     _velTexParam       = getNamedParameterFromFP("vel_tex");
    30     _posTimestepParam  = getNamedParameterFromFP("timestep");
    31     _maxParam          = getNamedParameterFromFP("max");
    32     _modeParam         = getNamedParameterFromFP("mode");
    33     _scaleParam        = getNamedParameterFromFP("scale");
    3421}
    3522
     
    3724NvParticleAdvectionShader::bind(unsigned int texID, unsigned int initPosTexID)
    3825{
    39     cgGLSetTextureParameter(_posTexParam, texID);
    40     cgGLEnableTextureParameter(_posTexParam);
     26    setFPTextureParameter("pos_tex", texID);
     27    setFPTextureParameter("init_pos_tex", initPosTexID);
     28    setFPTextureParameter("vel_tex", _velocityVolumeID);
    4129
    42     cgGLSetTextureParameter(_initPosTexParam, initPosTexID);
    43     cgGLEnableTextureParameter(_initPosTexParam);
    44 
    45     cgGLSetTextureParameter(_velTexParam, _velocityVolumeID);
    46     cgGLEnableTextureParameter(_velTexParam);
    47 
    48     cgGLSetParameter1f(_posTimestepParam, _timeStep);
    49     cgGLSetParameter1f(_maxParam, _max);
    50     cgGLSetParameter1f(_modeParam, _mode);
    51     cgGLSetParameter3f(_scaleParam, _scale.x, _scale.y, _scale.z);
     30    setFPParameter1f("timestep", _timeStep);
     31    setFPParameter1f("max", _max);
     32    setFPParameter1f("mode", _mode);
     33    setFPParameter3f("scale", _scale.x, _scale.y, _scale.z);
    5234
    5335    NvShader::bind();
     
    5739NvParticleAdvectionShader::unbind()
    5840{
    59      cgGLDisableTextureParameter(_posTexParam);
    60      cgGLDisableTextureParameter(_initPosTexParam);
    61      cgGLDisableTextureParameter(_velTexParam);
     41     disableFPTextureParameter("pos_tex");
     42     disableFPTextureParameter("init_pos_tex");
     43     disableFPTextureParameter("vel_tex");
    6244
    6345     NvShader::unbind();
  • branches/blt4/packages/vizservers/nanovis/NvParticleAdvectionShader.h

    r2936 r2966  
    88class NvParticleAdvectionShader : public NvShader
    99{
    10 public: 
     10public:
    1111    NvParticleAdvectionShader();
    1212
     
    2727        _max = max;
    2828        // FIXME: Is this needed?
    29         //if (_max > 100.f)
    30         //    _max = 100.0f;
     29        if (_max > 100.f)
     30            _max = 100.0f;
    3131    }
    3232
     
    4444    void init();
    4545
    46     CGparameter _posTexParam;
    47     CGparameter _initPosTexParam;
    48     CGparameter _velTexParam;
    49     CGparameter _posTimestepParam;
    50     CGparameter _maxParam;
    51     CGparameter _modeParam;
    52     CGparameter _scaleParam;
    53 
    5446    unsigned int _velocityVolumeID;
    5547    Vector3 _scale;
  • branches/blt4/packages/vizservers/nanovis/NvParticleRenderer.cpp

    r2936 r2966  
    1515 */
    1616
    17 #include <stdio.h>
    1817#include <assert.h>
    19 #include <malloc.h>
    2018#include <string.h>
    2119#include <stdlib.h>
    2220
    23 #include <R2/R2FilePath.h>
     21#include <GL/glew.h>
    2422
    2523#include "NvParticleRenderer.h"
     
    9290                              GL_TEXTURE_RECTANGLE_ARB, _psysTex[0], 0);
    9391
     92    CHECK_FRAMEBUFFER_STATUS();
    9493
    9594    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _psysFbo[1]);
     
    108107                              GL_TEXTURE_RECTANGLE_ARB, _psysTex[1], 0);
    109108 
     109    CHECK_FRAMEBUFFER_STATUS();
     110
    110111    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboOrig);
    111112
     
    121122                 _psysWidth, _psysHeight, 0, GL_RGBA, GL_FLOAT, NULL);
    122123#endif
    123 
    124     CHECK_FRAMEBUFFER_STATUS();
    125124
    126125    if (_advectionShader == NULL) {
     
    300299    if (_psysFrame == _maxLife) {
    301300        _psysFrame = 0;
    302         //        _reborn = true;
     301        // _reborn = true;
    303302    }
    304303    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboOrig);
     
    314313    //_vertexArray->loadData(vert);     //does not work??
    315314    //assert(glGetError()==0);
    316 }
    317 
    318 void
    319 NvParticleRenderer::drawBoundingBox(float x0, float y0, float z0,
    320                                     float x1, float y1, float z1,
    321                                     float r, float g, float b,
    322                                     float line_width)
    323 {
    324     glPushAttrib(GL_ENABLE_BIT);
    325 
    326     glEnable(GL_DEPTH_TEST);
    327     glDisable(GL_TEXTURE_2D);
    328     glEnable(GL_BLEND);
    329 
    330     glColor4d(r, g, b, 1.0);
    331     glLineWidth(line_width);
    332 
    333     glBegin(GL_LINE_LOOP);
    334     {
    335         glVertex3d(x0, y0, z0);
    336         glVertex3d(x1, y0, z0);
    337         glVertex3d(x1, y1, z0);
    338         glVertex3d(x0, y1, z0);
    339     }
    340     glEnd();
    341 
    342     glBegin(GL_LINE_LOOP);
    343     {
    344         glVertex3d(x0, y0, z1);
    345         glVertex3d(x1, y0, z1);
    346         glVertex3d(x1, y1, z1);
    347         glVertex3d(x0, y1, z1);
    348     }
    349     glEnd();
    350 
    351     glBegin(GL_LINE_LOOP);
    352     {
    353         glVertex3d(x0, y0, z0);
    354         glVertex3d(x0, y0, z1);
    355         glVertex3d(x0, y1, z1);
    356         glVertex3d(x0, y1, z0);
    357     }
    358     glEnd();
    359 
    360     glBegin(GL_LINE_LOOP);
    361     {
    362         glVertex3d(x1, y0, z0);
    363         glVertex3d(x1, y0, z1);
    364         glVertex3d(x1, y1, z1);
    365         glVertex3d(x1, y1, z0);
    366     }
    367     glEnd();
    368 
    369     glPopAttrib();
    370315}
    371316
     
    386331    glScaled(_scale.x, _scale.y, _scale.z);
    387332
    388     // TBD...
    389     /*
    390       drawBoundingBox(0, 0, 0,
    391       1, 1, 1,
    392       1, 1, 1, 2);
    393 
    394       drawBoundingBox(0, 0.5f / 4.5f, 0.5f / 4.5,
    395       1, 4.0f / 4.5f, 4.0f / 4.5,
    396       1, 0, 0, 2);
    397 
    398       drawBoundingBox(1/3.0f, 1.0f / 4.5f, 0.5f / 4.5,
    399       2/3.0f, 3.5f / 4.5f, 3.5f / 4.5,
    400       1, 1, 0, 2);
    401     */
    402 
    403333    glPointSize(_particleSize);
    404334    glColor4f(_color.x, _color.y, _color.z, _color.w);
     335
    405336    glEnableClientState(GL_VERTEX_ARRAY);
    406337    _vertexArray->setPointer(0);
     
    409340
    410341    glPopMatrix();
    411 
    412342    glPopAttrib();
    413 
    414     //assert(glGetError()==0);
    415343}
    416344
  • branches/blt4/packages/vizservers/nanovis/NvParticleRenderer.h

    r2936 r2966  
    1717#define NVPARTICLERENDERER_H
    1818
    19 #include <vector>
    20 
    2119#include <GL/glew.h>
    22 #include <Cg/cgGL.h>
    23 
    24 #include "config.h"
    2520
    2621#include "Renderable.h"
     22#include "NvParticleAdvectionShader.h"
    2723#include "RenderVertexArray.h"
    2824#include "Vector3.h"
    29 #include "NvParticleAdvectionShader.h"
     25#include "Vector4.h"
    3026
    3127struct Particle {
     
    8177
    8278    void setPos(float pos);
    83 
    84     void drawBoundingBox(float x0, float y0, float z0,
    85                          float x1, float y1, float z1,
    86                          float r, float g, float b, float line_width);
    8779
    8880    void initializeDataArray();
  • branches/blt4/packages/vizservers/nanovis/NvShader.cpp

    r2936 r2966  
    9090    TRACE("In ~NvShader");
    9191    if (_cgContext == NULL) {
    92         TRACE("Lost Cg context");
     92        TRACE("Lost Cg context: vp: %s, fp: %s", _vpFile.c_str(), _fpFile.c_str());
    9393    } else {
    9494        resetPrograms();
     
    103103    _cgVP = loadCgSourceProgram(_cgContext, fileName,
    104104                                _vertexProfile, entryPoint);
     105    _vpFile = fileName;
    105106}
    106107
     
    112113    _cgFP = loadCgSourceProgram(_cgContext, fileName,
    113114                                _fragmentProfile, entryPoint);
     115    _fpFile = fileName;
    114116}
    115117
     
    117119{
    118120    if (_cgVP != NULL) {
     121        TRACE("Destroying vertex program: %s\n", _vpFile.c_str());
    119122        cgDestroyProgram(_cgVP);
    120123    }
    121124
    122125    if (_cgFP != NULL) {
     126        TRACE("Destroying fragment program: %s\n", _fpFile.c_str());
    123127        cgDestroyProgram(_cgFP);
    124128    }
  • branches/blt4/packages/vizservers/nanovis/NvShader.h

    r2936 r2966  
    33#define NV_SHADER_H
    44
     5#include <string>
     6#include <tr1/unordered_map>
     7
    58#include <GL/glew.h>
    69#include <Cg/cg.h>
     
    1619{
    1720public:
     21    enum NvGLMatrix {
     22        MODELVIEW_MATRIX = CG_GL_MODELVIEW_MATRIX,
     23        PROJECTION_MATRIX = CG_GL_PROJECTION_MATRIX,
     24        MODELVIEW_PROJECTION_MATRIX = CG_GL_MODELVIEW_PROJECTION_MATRIX
     25    };
     26    enum NvGLMatrixType {
     27        MATRIX_IDENTITY = CG_GL_MATRIX_IDENTITY,
     28        MATRIX_INVERSE = CG_GL_MATRIX_INVERSE
     29    };
     30
    1831    typedef void NvCgCallbackFunction(void);
    1932
     
    4154            return cgGetNamedParameter(_cgFP, paramName);
    4255        }
     56        ERROR("Unknown fragment program parameter: %s\n", paramName);
    4357        return 0;
    4458    }
     
    4963            return cgGetNamedParameter(_cgVP, paramName);
    5064        }
     65        ERROR("Unknown vertex program parameter: %s\n", paramName);
    5166        return 0;
    5267    }
    5368
    54     void setTextureParameter(CGparameter param, GLuint texobj)
    55     {
     69    void setVPParameter1f(const char *name, float val)
     70    {
     71        CGparameter param = getVPParam(name);
     72        if (param == NULL)
     73            return;
     74        cgSetParameter1f(param, val);
     75    }
     76
     77    void setFPParameter1f(const char *name, float val)
     78    {
     79        CGparameter param = getFPParam(name);
     80        if (param == NULL)
     81            return;
     82        cgSetParameter1f(param, val);
     83    }
     84
     85    void setVPParameter2f(const char *name, float val1, float val2)
     86    {
     87        CGparameter param = getVPParam(name);
     88        if (param == NULL)
     89            return;
     90        cgSetParameter2f(param, val1, val2);
     91    }
     92
     93    void setFPParameter2f(const char *name, float val1, float val2)
     94    {
     95        CGparameter param = getFPParam(name);
     96        if (param == NULL)
     97            return;
     98        cgSetParameter2f(param, val1, val2);
     99    }
     100
     101    void setVPParameter3f(const char *name, float val1, float val2, float val3)
     102    {
     103        CGparameter param = getVPParam(name);
     104        if (param == NULL)
     105            return;
     106        cgSetParameter3f(param, val1, val2, val3);
     107    }
     108
     109    void setFPParameter3f(const char *name, float val1, float val2, float val3)
     110    {
     111        CGparameter param = getFPParam(name);
     112        if (param == NULL)
     113            return;
     114        cgSetParameter3f(param, val1, val2, val3);
     115    }
     116
     117    void setVPParameter4f(const char *name, float val1, float val2, float val3, float val4)
     118    {
     119        CGparameter param = getVPParam(name);
     120        if (param == NULL)
     121            return;
     122        cgSetParameter4f(param, val1, val2, val3, val4);
     123    }
     124
     125    void setFPParameter4f(const char *name, float val1, float val2, float val3, float val4)
     126    {
     127        CGparameter param = getFPParam(name);
     128        if (param == NULL)
     129            return;
     130        cgSetParameter4f(param, val1, val2, val3, val4);
     131    }
     132
     133    void setVPTextureParameter(const char *name, GLuint texobj, bool enable = true)
     134    {
     135        CGparameter param = getVPParam(name);
     136        if (param == NULL)
     137            return;
    56138        cgGLSetTextureParameter(param, texobj);
    57     }
    58 
    59     CGprogram getVP() const
    60     {
    61         return _cgVP;
    62     }
    63 
    64     CGprogram getFP() const
    65     {
    66         return _cgFP;
     139        if (enable)
     140            cgGLEnableTextureParameter(param);
     141    }
     142
     143    void setFPTextureParameter(const char *name, GLuint texobj, bool enable = true)
     144    {
     145        CGparameter param = getFPParam(name);
     146        if (param == NULL)
     147            return;
     148        cgGLSetTextureParameter(param, texobj);
     149        if (enable)
     150            cgGLEnableTextureParameter(param);
     151    }
     152
     153    void enableVPTextureParameter(const char *name)
     154    {
     155        CGparameter param = getVPParam(name);
     156        if (param == NULL)
     157            return;
     158        cgGLEnableTextureParameter(param);
     159    }
     160
     161    void enaableFPTextureParameter(const char *name)
     162    {
     163        CGparameter param = getFPParam(name);
     164        if (param == NULL)
     165            return;
     166        cgGLEnableTextureParameter(param);
     167    }
     168
     169    void disableVPTextureParameter(const char *name)
     170    {
     171        CGparameter param = getVPParam(name);
     172        if (param == NULL)
     173            return;
     174        cgGLDisableTextureParameter(param);
     175    }
     176
     177    void disableFPTextureParameter(const char *name)
     178    {
     179        CGparameter param = getFPParam(name);
     180        if (param == NULL)
     181            return;
     182        cgGLDisableTextureParameter(param);
     183    }
     184
     185    void setGLStateMatrixVPParameter(const char *name, NvGLMatrix matrix, NvGLMatrixType type)
     186    {
     187        CGparameter param = getVPParam(name);
     188        if (param == NULL)
     189            return;
     190        cgGLSetStateMatrixParameter(param, (CGGLenum)matrix, (CGGLenum)type);
     191    }
     192
     193    void setGLStateMatrixFPParameter(const char *name, NvGLMatrix matrix, NvGLMatrixType type)
     194    {
     195        CGparameter param = getFPParam(name);
     196        if (param == NULL)
     197            return;
     198        cgGLSetStateMatrixParameter(param, (CGGLenum)matrix, (CGGLenum)type);
    67199    }
    68200
     
    126258
    127259protected:
     260    typedef std::tr1::unordered_map<std::string, CGparameter> ParameterHashmap;
     261
     262    CGprogram getVP()
     263    {
     264        return _cgVP;
     265    }
     266
     267    CGprogram getFP()
     268    {
     269        return _cgFP;
     270    }
     271
     272    CGparameter getVPParam(const char *name)
     273    {
     274        CGparameter param;
     275        ParameterHashmap::iterator itr = _vpParams.find(name);
     276        if (itr == _vpParams.end()) {
     277            param = getNamedParameterFromVP(name);
     278            if (param != NULL)
     279                _vpParams[name] = param;
     280            else
     281                ERROR("Unknown vertex program parameter: %s\n", name);
     282        } else {
     283            param = itr->second;
     284        }
     285        return param;
     286    }
     287
     288    CGparameter getFPParam(const char *name)
     289    {
     290        CGparameter param;
     291        ParameterHashmap::iterator itr = _fpParams.find(name);
     292        if (itr == _fpParams.end()) {
     293            param = getNamedParameterFromFP(name);
     294            if (param != NULL)
     295                _fpParams[name] = param;
     296            else
     297                ERROR("Unknown fragment program parameter: %s\n", name);
     298        } else {
     299            param = itr->second;
     300        }
     301        return param;
     302    }
     303
    128304    void resetPrograms();
    129305
    130306    CGprofile _vertexProfile;
    131307    CGprofile _fragmentProfile;
     308    std::string _vpFile;
    132309    CGprogram _cgVP;
     310    std::string _fpFile;
    133311    CGprogram _cgFP;
     312    ParameterHashmap _vpParams;
     313    ParameterHashmap _fpParams;
    134314
    135315    static CGprofile _defaultVertexProfile;
  • branches/blt4/packages/vizservers/nanovis/NvStdVertexShader.cpp

    r2936 r2966  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #include <stdio.h>
    3 
    4 #include <GL/glew.h>
    5 #include <Cg/cgGL.h>
    6 
    72#include "NvStdVertexShader.h"
    83
     
    1914{
    2015    loadVertexProgram("vertex_std.cg", "main");
    21     _mvpVertStdParam = getNamedParameterFromVP("modelViewProjMatrix");
    22     _mviVertStdParam = getNamedParameterFromVP("modelViewInv");
    2316}
    2417
    2518void NvStdVertexShader::bind()
    2619{
    27     cgGLSetStateMatrixParameter(_mvpVertStdParam, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY);
    28     cgGLSetStateMatrixParameter(_mviVertStdParam, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_INVERSE);
     20    setGLStateMatrixVPParameter("modelViewProjMatrix", MODELVIEW_PROJECTION_MATRIX, MATRIX_IDENTITY);
     21    setGLStateMatrixVPParameter("modelViewInv", MODELVIEW_MATRIX, MATRIX_INVERSE);
    2922
    3023    NvShader::bind();
  • branches/blt4/packages/vizservers/nanovis/NvStdVertexShader.h

    r2936 r2966  
    2121private:
    2222    void init();
    23 
    24     /// A parameter id for ModelViewProjection matrix of Cg program
    25     CGparameter _mvpVertStdParam;
    26 
    27     /// A parameter id for ModelViewInverse matrix of Cg program
    28     CGparameter _mviVertStdParam;
    2923};
    3024
  • branches/blt4/packages/vizservers/nanovis/NvZincBlendeVolumeShader.cpp

    r2936 r2966  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 
    3 #include <string.h>
    42
    53#include <GL/glew.h>
  • branches/blt4/packages/vizservers/nanovis/PlaneRenderer.cpp

    r2936 r2966  
    1414 * ======================================================================
    1515 */
     16
     17#include <GL/glew.h>
    1618
    1719#include "PlaneRenderer.h"
  • branches/blt4/packages/vizservers/nanovis/PlaneRenderer.h

    r2936 r2966  
    1717#define PLANE_RENDERER_H
    1818
    19 #include <math.h>
    20 #include <stdio.h>
    21 #include <assert.h>
    22 #include <float.h>
    23 
    2419#include <vector>
    25 
    26 #include <GL/glew.h>
    27 #include <Cg/cgGL.h>
    2820
    2921#include "NvColorTableShader.h"
  • branches/blt4/packages/vizservers/nanovis/PointSetRenderer.cpp

    r2936 r2966  
    4848}
    4949
     50PointSetRenderer::~PointSetRenderer()
     51{
     52}
     53
    5054void PointSetRenderer::renderPoints(PCA::Point *points, int length)
    5155{
     
    7377    glBegin(GL_POINTS);
    7478
    75     PCA::ClusterList* p;
     79    PCA::ClusterList *p;
    7680    for (int i = size - 1; i >= 0; --i) {
    7781        p = bucket[i];
  • branches/blt4/packages/vizservers/nanovis/PointSetRenderer.h

    r2936 r2966  
    1111class PointSetRenderer
    1212{
    13  public:
     13public:
    1414    PointSetRenderer();
    1515    ~PointSetRenderer();
  • branches/blt4/packages/vizservers/nanovis/PointShader.cpp

    r2936 r2966  
    11/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
    2 #include <stdio.h>
    3 #include <stdlib.h>
    4 #include <assert.h>
    5 
    6 #include <R2/R2FilePath.h>
    7 #include <R2/R2string.h>
    8 
    92#include "PointShader.h"
    103
    114PointShader::PointShader() :
    12     NvShader(),
     5    NvShader(),
     6    _scale(1.0f),
    137    _normal(NULL)
    148{
    159    loadVertexProgram("pointsvp.cg", "main");
    16     _modelviewVP  = getNamedParameterFromVP("modelview");
    17     _projectionVP = getNamedParameterFromVP("projection");
    18     _attenVP      = getNamedParameterFromVP("atten");
    19     _posoffsetVP  = getNamedParameterFromVP("posoffset");
    20     _baseposVP    = getNamedParameterFromVP("basepos");
    21     _scaleVP      = getNamedParameterFromVP("scale");
    22     _normalParam  = getNamedParameterFromVP("normal");
    2310}
    2411
     
    2714}
    2815
    29 void PointShader::setParameters()
     16void PointShader::bind()
    3017{
    31     cgGLSetStateMatrixParameter(_modelviewVP, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_IDENTITY);
    32     cgGLSetStateMatrixParameter(_projectionVP, CG_GL_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY);
     18    setGLStateMatrixVPParameter("modelview", MODELVIEW_MATRIX, MATRIX_IDENTITY);
     19    setGLStateMatrixVPParameter("projection", PROJECTION_MATRIX, MATRIX_IDENTITY);
    3320
    34     cgGLSetParameter1f(_attenVP, 1.0f);
    35     cgGLSetParameter4f(_posoffsetVP, 1.0f, 1.0f, 1.0f, 1.0f);
    36     cgGLSetParameter4f(_baseposVP, 1.0f, 1.0f, 1.0f, 1.0f);
    37     cgGLSetParameter4f(_scaleVP, 1.0f, 1.0f, 1.0f, 1.0f);
     21    setVPParameter1f("atten", 1.0f);
     22    setVPParameter4f("posoffset", 1.0f, 1.0f, 1.0f, 1.0f);
     23    setVPParameter4f("basepos", 1.0f, 1.0f, 1.0f, 1.0f);
     24    setVPParameter4f("scale", _scale, 1.0f, 1.0f, 1.0f);
     25    //setVPTextureParameter("normal", _normal->getGraphicsObjectID());
    3826
    39     //cgGLSetTextureParameter(_normalParam,_normal->getGraphicsObjectID());
    40     //cgGLEnableTextureParameter(_normalParam);
     27    NvShader::bind();
    4128}
    4229
    43 void PointShader::resetParameters()
     30void PointShader::unbind()
    4431{
    45     //cgGLDisableTextureParameter(_normalParam);
     32    //disableVPTextureParameter("normal");
     33
     34    NvShader::unbind();
    4635}
  • branches/blt4/packages/vizservers/nanovis/PointShader.h

    r2936 r2966  
    1515    void setScale(float scale)
    1616    {
    17         cgGLSetParameter4f(_scaleVP, scale, 1.0f, 1.0f, 1.0f);
     17        _scale = scale;
    1818    }
    1919
    20     void setNormalTexture(Texture3D *n)
     20    void setNormalTexture(Texture3D *normal)
    2121    {
    22         _normal = n;
     22        _normal = normal;
    2323    }
    2424
    25     virtual void bind()
    26     {
    27         setParameters();
     25    virtual void bind();
    2826
    29         NvShader::bind();
    30     }
    31 
    32     virtual  void unbind()
    33     {
    34         resetParameters();
    35 
    36         NvShader::unbind();
    37     }
    38 
    39 protected:
    40     virtual void setParameters();
    41     virtual void resetParameters();
     27    virtual void unbind();
    4228
    4329private:
    44     CGparameter _modelviewVP;
    45     CGparameter _projectionVP;
    46 
    47     CGparameter _attenVP;
    48     CGparameter _posoffsetVP;
    49     CGparameter _baseposVP;
    50     CGparameter _scaleVP;
    51     CGparameter _normalParam;
    52 
     30    float _scale;
     31    float _scale;
    5332    Texture3D *_normal;
    5433};
  • branches/blt4/packages/vizservers/nanovis/R2/src/R2Fonts.cpp

    r2936 r2966  
    7373R2Fonts::begin()
    7474{
     75    glPushAttrib(GL_TRANSFORM_BIT | GL_ENABLE_BIT);
    7576    glEnable(GL_TEXTURE_2D);
    76     glBindTexture(GL_TEXTURE_2D, _fonts[_fontIndex]. _fontTextureID);
    77 
    78     glPushAttrib(GL_TRANSFORM_BIT | GL_ENABLE_BIT);
     77    glBindTexture(GL_TEXTURE_2D, _fonts[_fontIndex]._fontTextureID);
     78
    7979    glMatrixMode(GL_PROJECTION);
    8080    glPushMatrix();
    81 
    82     glLoadIdentity( );
     81    glLoadIdentity();
     82
    8383    gluOrtho2D(0.0f, _screenWidth, _screenHeight, 0.0f);
    8484
    8585    glMatrixMode(GL_MODELVIEW);
    86     glPushMatrix( );
    87     glLoadIdentity( );
    88 
    89     glEnable(GL_TEXTURE_2D);
     86    glPushMatrix();
     87    glLoadIdentity();
     88
    9089    glEnable(GL_BLEND);
    9190    glDisable(GL_DEPTH_TEST);
     
    9897
    9998    glMatrixMode(GL_PROJECTION);
    100     glPopMatrix( );
     99    glPopMatrix();
    101100
    102101    glMatrixMode(GL_MODELVIEW);
    103     glPopMatrix( );
    104 
    105     glPopAttrib( );
     102    glPopMatrix();
     103
     104    glPopAttrib();
    106105}
    107106
     
    229228        }
    230229
    231         fsInput.close( );
     230        fsInput.close();
    232231    }
    233232    delete [] path;
  • branches/blt4/packages/vizservers/nanovis/RenderVertexArray.cpp

    r2936 r2966  
    5151    switch (_type) {
    5252    case GL_HALF_FLOAT_NV:
    53         _bytesPerComponent = 2; break;
     53        _bytesPerComponent = 2;
     54        break;
    5455    case GL_FLOAT:
    55         _bytesPerComponent = sizeof(float); break;
     56        _bytesPerComponent = sizeof(float);
     57        break;
    5658    default:
    5759        ERROR("unsupported RenderVertexArray type\n");
     
    7072    switch(_size) {
    7173    case 1:
    72         _format = GL_LUMINANCE; break;
     74        _format = GL_LUMINANCE;
     75        break;
    7376    case 3:
    74         _format = GL_RGB; break;
     77        _format = GL_RGB;
     78        break;
    7579    case 4:
    76         _format = GL_RGBA; break;
     80        _format = GL_RGBA;
     81        break;
    7782    default:
    7883        ERROR("unsupported RenderVertexArray size\n");
  • branches/blt4/packages/vizservers/nanovis/Unirect.cpp

    r2936 r2966  
    734734        }
    735735    }
    736     TRACE("GetVectorRange %g %g\n", _magMin, _magMax);
     736    TRACE("getVectorRange: %g %g\n", _magMin, _magMax);
    737737}
    738738
  • branches/blt4/packages/vizservers/nanovis/VelocityArrowsSlice.h

    r2936 r2966  
    8484
    8585private:
     86    void createRenderTarget();
     87
     88    void computeSamplingTicks();
     89
    8690    unsigned int _vectorFieldGraphicsID;
    8791    float _vfXscale;
     
    134138
    135139    RenderMode _renderMode;
    136 
    137     void createRenderTarget();
    138 
    139     void computeSamplingTicks();
    140140};
    141141
  • branches/blt4/packages/vizservers/nanovis/VolumeInterpolator.cpp

    r2936 r2966  
    1818    _numBytes(0),
    1919    _dataCount(0),
    20     _numComponents(0),
    21     _referenceOfVolume(0)
     20    _numComponents(0)
    2221{
    2322}
     
    133132        _numComponents = refPtr->numComponents();
    134133        _numBytes = _dataCount * _numComponents * sizeof(float);
    135         Vector3 loc = refPtr->location();
     134        Vector3 loc = refPtr->location();
    136135        _volume = new Volume(loc.x, loc.y, loc.z,
    137136                             refPtr->width, refPtr->height, refPtr->depth,
     
    141140                             refPtr->wAxis.min(),
    142141                             refPtr->wAxis.max(),
    143                              refPtr->nonZeroMin());
    144         /*
    145         _referenceOfVolume = refPtr->dataID();
    146         */
     142                             refPtr->nonZeroMin());
    147143        _volume->numSlices(256-1);
    148144        _volume->disableCutplane(0);
     
    156152        _volume->isosurface(0);
    157153        TRACE("VOL : location %f %f %f\n\tid : %s\n", loc.x, loc.y, loc.z,
    158                refPtr->name());
     154               refPtr->name());
    159155    }
    160156    _volumes.push_back(_volume);
  • branches/blt4/packages/vizservers/nanovis/VolumeInterpolator.h

    r2936 r2966  
    3030    double getStartTime() const;
    3131
    32     unsigned int getReferenceVolumeID() const;
    33 
    3432    Volume *getVolume();
    3533
     
    4442    unsigned int _dataCount;
    4543    unsigned int _numComponents;
    46     unsigned int _referenceOfVolume;
    4744    double _startTime;
    4845};
     
    6360}
    6461
    65 inline unsigned int VolumeInterpolator::getReferenceVolumeID() const
    66 {
    67     return _referenceOfVolume;
    68 }
    69 
    7062#endif
    7163
  • branches/blt4/packages/vizservers/nanovis/VolumeRenderer.h

    r2936 r2966  
    146146
    147147    //standard vertex shader parameters
    148     CGprogram _vertStdVprog;
    149148    CGparameter _mvpVertStdParam;
    150149    CGparameter _mviVertStdParam;
  • branches/blt4/packages/vizservers/nanovis/dxReader.cpp

    r2936 r2966  
    116116                // save corners of bounding box first, to work around meshing
    117117                // problems in voronoi utility
    118                 ftmp << xymesh.rangeMin(Rappture::xaxis) << " "
    119                      << xymesh.rangeMin(Rappture::yaxis) << std::endl;
    120                 ftmp << xymesh.rangeMax(Rappture::xaxis) << " "
    121                      << xymesh.rangeMin(Rappture::yaxis) << std::endl;
    122                 ftmp << xymesh.rangeMax(Rappture::xaxis) << " "
    123                      << xymesh.rangeMax(Rappture::yaxis) << std::endl;
    124                 ftmp << xymesh.rangeMin(Rappture::xaxis) << " "
    125                      << xymesh.rangeMax(Rappture::yaxis) << std::endl;
     118                int numBoundaryPoints = 4;
     119
     120                // Bump out the bounds by an epsilon to avoid problem when
     121                // corner points are already nodes
     122                double XEPS = (xymesh.rangeMax(Rappture::xaxis) -
     123                               xymesh.rangeMin(Rappture::xaxis)) / 10.0f;
     124
     125                double YEPS = (xymesh.rangeMax(Rappture::yaxis) -
     126                               xymesh.rangeMin(Rappture::yaxis)) / 10.0f;
     127
     128                ftmp << xymesh.rangeMin(Rappture::xaxis) - XEPS << " "
     129                     << xymesh.rangeMin(Rappture::yaxis) - YEPS << std::endl;
     130                ftmp << xymesh.rangeMax(Rappture::xaxis) + XEPS << " "
     131                     << xymesh.rangeMin(Rappture::yaxis) - YEPS << std::endl;
     132                ftmp << xymesh.rangeMax(Rappture::xaxis) + XEPS << " "
     133                     << xymesh.rangeMax(Rappture::yaxis) + YEPS << std::endl;
     134                ftmp << xymesh.rangeMin(Rappture::xaxis) - XEPS << " "
     135                     << xymesh.rangeMax(Rappture::yaxis) + YEPS << std::endl;
     136
    126137                for (int i = 0; i < nxy; i++) {
    127138                    ftmp << xymesh.atNode(i).x() << " " << xymesh.atNode(i).y() << std::endl;
     
    137148                        ftri.getline(line,sizeof(line)-1);
    138149                        if (sscanf(line, "%d %d %d", &cx, &cy, &cz) == 3) {
    139                             if (cx >= 4 && cy >= 4 && cz >= 4) {
    140                                 // skip first 4 boundary points
    141                                 xymesh.addCell(cx-4, cy-4, cz-4);
     150                            if (cx >= numBoundaryPoints &&
     151                                cy >= numBoundaryPoints &&
     152                                cz >= numBoundaryPoints) {
     153                                // skip boundary points we added
     154                                xymesh.addCell(cx - numBoundaryPoints,
     155                                               cy - numBoundaryPoints,
     156                                               cz - numBoundaryPoints);
    142157                            }
    143158                        }
     
    198213    }
    199214
    200     TRACE("found nx=%d ny=%d nz=%d\ndx=%f dy=%f dz=%f\nx0=%f y0=%f z0=%f\n",
    201           nx, ny, nz, dx, dy, dz, x0, y0, z0);
     215    TRACE("found nx=%d ny=%d nxy=%d nz=%d\ndx=%f dy=%f dz=%f\nx0=%f y0=%f z0=%f\n",
     216          nx, ny, nxy, nz, dx, dy, dz, x0, y0, z0);
     217
     218    lx = (nx - 1) * dx;
     219    ly = (ny - 1) * dy;
     220    lz = (nz - 1) * dz;
    202221
    203222    // read data points
     
    207226    }
    208227    Volume *volPtr = NULL;
    209     lx = (nx - 1) * dx;
    210     ly = (ny - 1) * dy;
    211     lz = (nz - 1) * dz;
     228    float *data = NULL;
     229    double vmin = DBL_MAX;
     230    double nzero_min = DBL_MAX;
     231    double vmax = -DBL_MAX;
    212232    if (isrect) {
    213233#if ISO_TEST
    214         float *data = new float[nx *  ny *  nz * 4];
     234        data = new float[nx *  ny *  nz * 4];
    215235        memset(data, 0, nx*ny*nz*4);
    216         double vmin = DBL_MAX;
    217         double nzero_min = DBL_MAX;
    218         double vmax = -DBL_MAX;
    219236#else // !ISO_TEST
    220237        Rappture::Mesh1D xgrid(x0, x0 + lx, nx);
     
    279296#if ISO_TEST
    280297        double dv = vmax - vmin;
    281         int count = nx*ny*nz;
    282         int ngen = 0;
    283         double v;
    284298        if (dv == 0.0) {
    285299            dv = 1.0;
    286300        }
    287301
    288         for (int i = 0; i < count; ++i) {
    289             v = data[ngen];
     302        int ngen = 0;
     303        const int step = 4;
     304        for (int i = 0; i < nx*ny*nz; ++i) {
     305            double v = data[ngen];
    290306            // scale all values [0-1], -1 => out of bounds
    291307            v = (isnan(v)) ? -1.0 : (v - vmin)/dv;
    292308
    293309            data[ngen] = v;
    294             ngen += 4;
     310            ngen += step;
    295311        }
    296312
     
    317333        dz = lz /(double)(nz - 1);
    318334
    319         double vmin = field.valueMin();
    320         double vmax = field.valueMax();
     335        vmin = field.valueMin();
     336        vmax = field.valueMax();
     337        nzero_min = DBL_MAX;
    321338        double dv = vmax - vmin;
    322339        if (dv == 0.0) {
    323340            dv = 1.0;
    324341        }
    325         double nzero_min = DBL_MAX;
     342
    326343        int ngen = 0;
    327344#if FILTER_GRADIENTS
     
    334351        // to be filled in by computeSimpleGradient()
    335352        const int step = 4;
    336         float *data = new float[nx*ny*nz * step];
     353        data = new float[nx*ny*nz * step];
    337354#endif // FILTER_GRADIENTS
    338355
     
    368385        // computeGradient returns a new array with gradients
    369386        // filled in, so data is now 4 floats per node
    370         float *data = computeGradient(cdata, nx, ny, nz,
    371                                       dx, dy, dz,
    372                                       vmin, vmax);
     387        data = computeGradient(cdata, nx, ny, nz,
     388                               dx, dy, dz,
     389                               vmin, vmax);
    373390        delete [] cdata;
    374391#else // !FILTER_GRADIENTS
     
    378395
    379396#endif // ISO_TEST
    380         TRACE("nx = %i ny = %i nz = %i\n", nx, ny, nz);
    381         TRACE("lx = %lg ly = %lg lz = %lg\n", lx, ly, lz);
    382         TRACE("dx = %lg dy = %lg dz = %lg\n", dx, dy, dz);
    383         TRACE("dataMin = %lg\tdataMax = %lg\tnzero_min = %lg\n",
    384               vmin, vmax, nzero_min);
    385 
    386         volPtr = NanoVis::loadVolume(tag, nx, ny, nz, 4, data,
    387                                      vmin, vmax, nzero_min);
    388         volPtr->xAxis.setRange(x0, x0 + lx);
    389         volPtr->yAxis.setRange(y0, y0 + ly);
    390         volPtr->zAxis.setRange(z0, z0 + lz);
    391         volPtr->wAxis.setRange(vmin, vmax);
    392         volPtr->updatePending = true;
    393         // TBD..
    394 #if 0 && defined(USE_POINTSET_RENDERER)
    395         PointSet *pset = new PointSet();
    396         pset->initialize(volPtr, (float*)data);
    397         pset->setVisible(true);
    398         NanoVis::pointSet.push_back(pset);
    399         updateColor(pset);
    400         volPtr->pointsetIndex = NanoVis::pointSet.size() - 1;
    401 #endif
    402         delete [] data;
    403397    } else {
    404398        Rappture::Mesh1D zgrid(z0, z0 + (nz-1)*dz, nz);
     
    434428        }
    435429
    436         // figure out a good mesh spacing
    437         int nsample = 30;
    438430        x0 = field.rangeMin(Rappture::xaxis);
    439431        lx = field.rangeMax(Rappture::xaxis) - field.rangeMin(Rappture::xaxis);
     
    442434        z0 = field.rangeMin(Rappture::zaxis);
    443435        lz = field.rangeMax(Rappture::zaxis) - field.rangeMin(Rappture::zaxis);
     436
     437        // figure out a good mesh spacing
     438        int nsample = 30;
    444439        double dmin = pow((lx*ly*lz)/((nsample-1)*(nsample-1)*(nsample-1)), 0.333);
    445440
     
    458453        dz = lz /(double)(nz - 1);
    459454
    460         float *data = new float[4*nx*ny*nz];
    461 
    462         double vmin = field.valueMin();
    463         double vmax = field.valueMax();
     455        vmin = field.valueMin();
     456        vmax = field.valueMax();
     457        nzero_min = DBL_MAX;
    464458        double dv = vmax - vmin;
    465459        if (dv == 0.0) {
     
    467461        }
    468462
     463        data = new float[4*nx*ny*nz];
    469464        // generate the uniformly sampled data that we need for a volume
    470465        int ngen = 0;
    471         double nzero_min = DBL_MAX;
    472466        for (int iz = 0; iz < nz; iz++) {
    473467            double zval = z0 + iz*dz;
     
    492486        computeSimpleGradient(data, nx, ny, nz,
    493487                              dx, dy, dz);
    494 
    495         volPtr = NanoVis::loadVolume(tag, nx, ny, nz, 4, data,
    496                                      vmin, vmax, nzero_min);
    497         volPtr->xAxis.setRange(field.rangeMin(Rappture::xaxis),
    498                                field.rangeMax(Rappture::xaxis));
    499         volPtr->yAxis.setRange(field.rangeMin(Rappture::yaxis),
    500                                field.rangeMax(Rappture::yaxis));
    501         volPtr->zAxis.setRange(field.rangeMin(Rappture::zaxis),
    502                                field.rangeMax(Rappture::zaxis));
    503         volPtr->wAxis.setRange(field.valueMin(), field.valueMax());
    504         volPtr->updatePending = true;
    505         // TBD..
     488    }
     489
     490    TRACE("nx = %i ny = %i nz = %i\n", nx, ny, nz);
     491    TRACE("x0 = %lg y0 = %lg z0 = %lg\n", x0, y0, z0);
     492    TRACE("lx = %lg ly = %lg lz = %lg\n", lx, ly, lz);
     493    TRACE("dx = %lg dy = %lg dz = %lg\n", dx, dy, dz);
     494    TRACE("dataMin = %lg dataMax = %lg nzero_min = %lg\n",
     495          vmin, vmax, nzero_min);
     496
     497    volPtr = NanoVis::loadVolume(tag, nx, ny, nz, 4, data,
     498                                 vmin, vmax, nzero_min);
     499    volPtr->xAxis.setRange(x0, x0 + lx);
     500    volPtr->yAxis.setRange(y0, y0 + ly);
     501    volPtr->zAxis.setRange(z0, z0 + lz);
     502    volPtr->updatePending = true;
     503
     504    // TBD..
    506505#if 0 && defined(USE_POINTSET_RENDERER)
    507         PointSet *pset = new PointSet();
    508         pset->initialize(volPtr, (float*)data);
    509         pset->setVisible(true);
    510         NanoVis::pointSet.push_back(pset);
    511         updateColor(pset);
    512         volPtr->pointsetIndex = NanoVis::pointSet.size() - 1;
     506    PointSet *pset = new PointSet();
     507    pset->initialize(volPtr, (float*)data);
     508    pset->setVisible(true);
     509    NanoVis::pointSet.push_back(pset);
     510    updateColor(pset);
     511    volPtr->pointsetIndex = NanoVis::pointSet.size() - 1;
    513512#endif
    514         delete [] data;
    515     }
     513    delete [] data;
    516514
    517515    //
  • branches/blt4/packages/vizservers/nanovis/imgLoaders/BMPImageLoaderImpl.cpp

    r2936 r2966  
    7777            }
    7878        } else if (_targetImageFormat == Image::IMG_RGBA) {
    79             char *buff = (char*)malloc(width * height * sizeof(unsigned char) * 3);
     79            unsigned char *buff = (unsigned char*)malloc(width * height * sizeof(unsigned char) * 3);
    8080            if (fread(buff, width*height*3, 1, f) != 1) {
    8181                ERROR("can't read BMP image data\n");
     
    8383            for (x = 0, y = 0; x < width*height*3; x += 3, y += 4) {       //except the format is BGR, grr
    8484                bytes[y] = buff[x+2];
     85                bytes[y+1] = buff[x+1];
    8586                bytes[y+2] = buff[x];
    8687                bytes[y+3] = 255;
     
    101102            }
    102103        } else if (_targetImageFormat == Image::IMG_RGB) {
    103             char *buff = (char*)malloc(width * height * sizeof(unsigned char) * 3);
     104            unsigned char *buff = (unsigned char*)malloc(width * height * sizeof(unsigned char) * 4);
    104105            if (fread(buff, width*height*4, 1, f) != 1) {
    105106                ERROR("can't read BMP image data\n");
     
    107108            for (x = 0, y = 0; x < width*height*4; x += 4, y += 3) {       //except the format is BGR, grr
    108109                bytes[y] = buff[x+2];
     110                bytes[y+1] = buff[x+1];
    109111                bytes[y+2] = buff[x];
    110112            }
     
    125127                for (int c = 0; c < 3; ++c) {
    126128                    //bytes[(y*width+x)*3+c] = cols[byte*4+2-c];        //and look up in the table
    127                     bytes[(y*width+x)*_targetImageFormat + c] = cols[byte*4+2-c];       //and look up in the table 
     129                    bytes[(y*width+x)*_targetImageFormat + c] = cols[byte*4+2-c];       //and look up in the table
    128130                }
    129             }
     131                if (_targetImageFormat == Image::IMG_RGBA) {
     132                    bytes[(y*width+x)*_targetImageFormat + 3] = 255;
     133                }
     134            }
    130135        }
    131136        break;
  • branches/blt4/packages/vizservers/nanovis/nanovis.cpp

    r2936 r2966  
    133133Texture2D *NanoVis::legendTexture = NULL;
    134134NvColorTableRenderer *NanoVis::colorTableRenderer = NULL;
    135 
     135#ifdef notdef
    136136NvFlowVisRenderer *NanoVis::flowVisRenderer = NULL;
     137#endif
    137138VelocityArrowsSlice *NanoVis::velocityArrowsSlice = NULL;
    138139
     
    149150
    150151Tcl_Interp *NanoVis::interp;
    151 Tcl_DString NanoVis::cmdbuffer;
    152152
    153153//frame buffer for final rendering
     
    173173float NanoVis::wMin = FLT_MAX;
    174174float NanoVis::wMax = -FLT_MAX;
    175 float NanoVis::xOrigin;
    176 float NanoVis::yOrigin;
    177 float NanoVis::zOrigin;
    178175
    179176/* FIXME: This variable is always true. */
     
    236233// Image based flow visualization slice location
    237234// FLOW
    238 float NanoVis::_licSliceX = 0.5f;
    239 float NanoVis::_licSliceY = 0.5f;
    240 float NanoVis::_licSliceZ = 0.5f;
     235float NanoVis::_licSlice = 0.5f;
    241236int NanoVis::_licAxis = 2; // z axis
    242237
    243 static void
    244 removeAllData()
     238void
     239NanoVis::removeAllData()
    245240{
    246241    //
     
    364359doExit(int code)
    365360{
    366     TRACE("in doExit\n");
    367     removeAllData();
     361    TRACE("in doExit: %d\n", code);
     362    NanoVis::removeAllData();
    368363
    369364    NvShader::exitCg();
     
    515510int
    516511NanoVis::renderLegend(TransferFunction *tf, double min, double max,
    517                       int width, int height, const char* volArg)
     512                      int width, int height, const char *volArg)
    518513{
    519514    TRACE("in renderLegend\n");
     
    546541        ssize_t nWritten;
    547542
    548         TRACE("ppm legend image");
     543        TRACE("Sending ppm legend image %s min:%g max:%g", volArg, min, max);
    549544        sprintf(prefix, "nv>legend %s %g %g", volArg, min, max);
    550545        ppmWrite(prefix);
     
    555550    resizeOffscreenBuffer(old_width, old_height);
    556551
     552    delete legendTexture;
     553    legendTexture = NULL;
    557554    TRACE("leaving renderLegend\n");
    558     delete legendTexture;
    559555    return TCL_OK;
    560556}
     
    710706#endif
    711707
    712 void NanoVis::initParticle()
    713 {
    714     flowVisRenderer->initialize();
    715     licRenderer->makePatterns();
    716 }
    717 
    718708static
    719709void cgErrorCallback(void)
     
    798788    colorTableRenderer = new NvColorTableRenderer();
    799789    colorTableRenderer->setFonts(fonts);
    800 
     790#ifdef notdef
    801791    flowVisRenderer = new NvFlowVisRenderer(NMESH, NMESH);
    802 
     792#endif
    803793    velocityArrowsSlice = new VelocityArrowsSlice;
    804794
    805     licRenderer = new NvLIC(NMESH, NPIX, NPIX, _licAxis,
    806                             Vector3(_licSliceX, _licSliceY, _licSliceZ));
     795    licRenderer = new NvLIC(NMESH, NPIX, NPIX, _licAxis, _licSlice);
    807796
    808797    grid = new Grid();
     
    13431332#endif
    13441333
    1345 static void
    1346 draw3dAxis()
     1334void
     1335NanoVis::draw3dAxis()
    13471336{
    13481337    glPushAttrib(GL_ENABLE_BIT);
     
    17611750
    17621751#ifdef notdef
     1752void NanoVis::initParticle()
     1753{
     1754    flowVisRenderer->initialize();
     1755    licRenderer->makePatterns();
     1756}
     1757
    17631758static
    17641759void addVectorField(const char* filename, const char* vf_name,
     
    21172112
    21182113    //  Read and execute as many commands as we can from stdin...
    2119 
     2114    Tcl_DString cmdbuffer;
     2115    Tcl_DStringInit(&cmdbuffer);
    21202116    int nCommands = 0;
    21212117    bool isComplete = false;
     
    23732369    NvInitEventLog();
    23742370#endif
    2375     Tcl_DStringInit(&NanoVis::cmdbuffer);
    23762371    NanoVis::interp = initTcl();
    23772372    NanoVis::resizeOffscreenBuffer(NanoVis::winWidth, NanoVis::winHeight);
  • branches/blt4/packages/vizservers/nanovis/nanovis.h

    r2936 r2966  
    7979    static void displayOffscreenBuffer();
    8080    static void display();
     81    static void draw3dAxis();
    8182    static void idle();
    8283    static void update();
     84    static void removeAllData();
    8385
    8486    static void pan(float dx, float dy);
     
    8991    static void setVolumeRanges();
    9092    static void setHeightmapRanges();
    91 
     93#ifdef notdef
    9294    static void initParticle();
    93 
     95#endif
    9496    static void ppmWrite(const char *prefix);
    9597    static void sendDataToClient(const char *command, const char *data,
     
    155157    static int renderWindow;
    156158    static unsigned char *screenBuffer;
     159    static Texture2D *legendTexture;
    157160    static Grid *grid;
    158161    static R2Fonts *fonts;
     
    161164    static graphics::RenderContext *renderContext;
    162165
     166    static Tcl_HashTable tfTable;
    163167    static Tcl_HashTable volumeTable;
    164 
    165     static std::vector<NvVectorField *> flow;
    166168    static Tcl_HashTable flowTable;
     169    static Tcl_HashTable heightmapTable;
     170
    167171    static double magMin, magMax;
    168172    static float xMin, xMax, yMin, yMax, zMin, zMax, wMin, wMax;
    169     static float xOrigin, yOrigin, zOrigin;
    170 
     173
     174    static NvColorTableRenderer *colorTableRenderer;
    171175    static VolumeRenderer *volRenderer;
     176#ifdef notdef
    172177    static NvFlowVisRenderer *flowVisRenderer;
     178#endif
    173179    static VelocityArrowsSlice *velocityArrowsSlice;
    174180    static NvLIC *licRenderer;
     
    183189#endif
    184190
    185     static Tcl_HashTable tfTable;
    186     static Texture2D *legendTexture;
    187     static NvColorTableRenderer *colorTableRenderer;
    188 
    189     static std::vector<HeightMap *> heightMap;
    190     static Tcl_HashTable heightmapTable;
    191 
    192191    static Tcl_Interp *interp;
    193     static Tcl_DString cmdbuffer;
    194192
    195193private:
    196     static float _licSliceX;
    197     static float _licSliceY;
    198     static float _licSliceZ;
    199     static int _licAxis;     /* 0:x, 1:y, 2:z */
     194    static float _licSlice;  ///< Slice position [0,1]
     195    static int _licAxis;     ///< Slice axis: 0:x, 1:y, 2:z
    200196
    201197    //frame buffer for final rendering
  • branches/blt4/packages/vizservers/nanovis/protocol-nanovis.txt

    r2936 r2966  
    186186  (followed by bytes)
    187187
     188nv>data tag <dataobj-tag> min <val> max <val> vmin <val> vmax <val>
     189   The min,max data values for the data object and the cumulative volume data
     190   min,max over all volumes
     191
    188192================================================================================
    189193Error Replies:
  • branches/blt4/packages/vizservers/nanovis/shaders/update_pos.cg

    r2936 r2966  
    4949
    5050    //reconstruct negative value
    51     float4 vel = float4(tex3D(vel_tex, pos.xyz).yzw, 0) - float4(0.5, 0.5, 0.5, 0.0f);
    52     vel = vel * (2 * max);
     51    float4 vel = float4(tex3D(vel_tex, pos.xyz).yzw, 0.0) * 2.0 - float4(1.0, 1.0, 1.0, 0.0f);
     52    vel = vel * max;
    5353    //vel *= float4(scale, 1);
    5454    ret = pos + (vel * timestep);
Note: See TracChangeset for help on using the changeset viewer.