Changeset 2966
- Timestamp:
- Apr 13, 2012 12:04:37 PM (12 years ago)
- Location:
- branches/blt4
- Files:
-
- 5 added
- 1 deleted
- 59 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/blt4/Makefile.in
r2692 r2966 31 31 32 32 ENABLE_GUI = @ENABLE_GUI@ 33 33 HAVE_FFMPEG = @HAVE_FFMPEG_LIBS@ 34 34 TARGETS = src lang lib 35 35 36 36 ifneq ($(ENABLE_GUI),) 37 37 TARGETS += gui builder tester examples 38 endif 39 ifeq ($(HAVE_FFMEG),) 40 TARGETS += video 38 41 endif 39 42 … … 44 47 $(MAKE) -C $$i all || exit 1 ;\ 45 48 done 46 test: 49 test: 47 50 $(MAKE) -C test all 48 51 -
branches/blt4/gui/scripts/balloon.tcl
r1923 r2966 30 30 inherit itk::Toplevel 31 31 32 itk_option define -background background Background "" 32 33 itk_option define -deactivatecommand deactivateCommand DeactivateCommand "" 33 34 itk_option define -dismissbutton dismissButton DismissButton "on" … … 324 325 set dark [Rappture::color::brightness $bg -0.4] 325 326 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]] 327 346 328 347 $_fills($dir) put $bg -to 0 0 $sw $sh … … 485 504 486 505 # ---------------------------------------------------------------------- 506 # CONFIGURATION OPTION: -background 507 # ---------------------------------------------------------------------- 508 itcl::configbody Rappture::Balloon::background { 509 _createStems 510 } 511 512 # ---------------------------------------------------------------------- 487 513 # CONFIGURATION OPTION: -stemlength 488 514 # -
branches/blt4/gui/scripts/controlOwner.tcl
r1923 r2966 59 59 # in coordination with loaders inside the load function 60 60 array set _type2curpath { 61 drawing components 61 62 choice current 62 63 boolean current … … 66 67 note contents 67 68 number current 69 periodicelement current 68 70 string current 69 71 } -
branches/blt4/gui/scripts/drawingentry.tcl
r1923 r2966 15 15 itcl::class Rappture::DrawingEntry { 16 16 inherit itk::Widget 17 18 17 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 19 26 20 27 constructor {owner path args} { # defined below } … … 24 31 public method label {} 25 32 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 } 26 47 } 27 48 … … 41 62 } 42 63 set _path $path 43 64 set _owner $owner 44 65 # 45 66 # Display the current drawing. 46 67 # 47 68 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 49 72 } 50 73 pack $itk_component(drawing) -expand yes -fill both 51 74 ParseDescription 52 75 eval itk_initialize $args 53 76 } … … 128 151 } 129 152 } 153 154 itcl::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 # 195 itcl::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 280 itcl::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 320 itcl::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 389 itcl::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 396 itcl::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 404 itcl::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 410 itcl::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 418 itcl::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 426 itcl::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 434 itcl::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 469 itcl::body Rappture::DrawingEntry::Highlight { tag } { 470 $itk_component(drawing) itemconfigure $tag-bg -outline black \ 471 -fill lightblue 472 } 473 474 itcl::body Rappture::DrawingEntry::Unhighlight { tag } { 475 $itk_component(drawing) itemconfigure $tag-bg -outline "" \ 476 -fill "" 477 } -
branches/blt4/gui/scripts/icons.tcl
r2745 r2966 18 18 variable iconpath [list [file join $RapptureGUI::library scripts images]] 19 19 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 # ---------------------------------------------------------------------- 30 proc 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 } 20 39 } 21 40 -
branches/blt4/gui/scripts/page.tcl
r2327 r2966 79 79 continue 80 80 } 81 82 81 if {$type == "loader"} { 83 82 # … … 139 138 # 140 139 set w "$frame.drawing[incr num]" 141 Rappture::DrawingEntry ::$w $_owner $path.$cname .current140 Rappture::DrawingEntry ::$w $_owner $path.$cname 142 141 pack $w -expand yes -fill both 143 142 $_owner widgetfor $path.$cname $w -
branches/blt4/gui/scripts/periodictable.tcl
r2745 r2966 461 461 set elem [FindElement $name] 462 462 if { $elem == "" || $_state($elem) == "disabled" } { 463 if { $elem != "" } { 464 puts stderr "element $elem is disabled" 465 } 463 466 return "" 464 467 } … … 608 611 609 612 # ---------------------------------------------------------------------- 610 # USAGE: select <name>613 # USAGE: FindElement 611 614 # 612 615 # Used to manipulate the selection in the table. … … 615 618 itcl::body Rappture::PeriodicTable::FindElement { what } { 616 619 foreach name [array names _table] { 620 array unset info 617 621 array set info $_table($name) 618 622 if { $what == $info(name) || $what == $info(number) || 619 623 $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 } 626 626 } 627 627 return "" -
branches/blt4/gui/scripts/resultset.tcl
r2791 r2966 41 41 itk_option define -boldfont boldFont Font "" 42 42 itk_option define -foreground foreground Foreground "" 43 itk_option define -missingdata missingData MissingData ""44 43 itk_option define -clearcommand clearCommand ClearCommand "" 45 44 itk_option define -settingscommand settingsCommand SettingsCommand "" … … 50 49 51 50 public method add {xmlobj} 52 public method clear { }51 public method clear {{xmlobj ""}} 53 52 public method activate {column} 54 53 public method contains {xmlobj} 55 54 public method size {{what -results}} 56 55 57 protected method _doClear { }56 protected method _doClear {what} 58 57 protected method _doSettings {{cmd ""}} 59 protected method _doPrompt {state}60 58 protected method _control {option args} 61 59 protected method _fixControls {args} 62 60 protected method _fixLayout {args} 61 protected method _fixNumResults {} 63 62 protected method _fixSettings {args} 64 protected method _fixExplore {}65 63 protected method _fixValue {column why} 66 64 protected method _drawValue {column widget wmax} … … 69 67 protected method _getTooltip {role column} 70 68 protected method _getParamDesc {which {index "current"}} 69 protected method _addOneResult {tuples xmlobj {simnum ""}} 71 70 72 71 private variable _dispatcher "" ;# dispatchers for !events 73 72 private variable _results "" ;# tuple of known results 73 private variable _resultnum 0 ;# counter for result #1, #2, etc. 74 74 private variable _recent "" ;# most recent result in _results 75 75 private variable _active "" ;# column with active control … … 78 78 private variable _counter 0 ;# counter for unique control names 79 79 private variable _settings 0 ;# non-zero => _fixSettings in progress 80 private variable _explore 0 ;# non-zero => explore all parameters81 80 82 81 private common _cntlInfo ;# maps column name => control info … … 85 84 itk::usual ResultSet { 86 85 keep -background -foreground -cursor -font 87 }88 itk::usual Scrollset {89 86 } 90 87 … … 118 115 set _results [Rappture::Tuples ::#auto] 119 116 $_results column insert end -name xmlobj -label "top-level XML object" 117 $_results column insert end -name simnum -label "simulation number" 120 118 121 119 … … 129 127 pack $itk_component(cntls) -fill x -pady {0 2} 130 128 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 \ 133 131 -padx 1 -pady 1 \ 134 132 -relief flat -overrelief raised \ 135 -command [itcl::code $this _doClear ]133 -command [itcl::code $this _doClear all] 136 134 } { 137 135 usual … … 140 138 rename -highlightbackground -controlbarbackground controlbarBackground Background 141 139 } 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 } 142 155 pack $itk_component(clear) -side right -padx 2 -pady 1 143 156 Rappture::Tooltip::for $itk_component(clear) \ 144 "Clears all results collected so far."157 "Clears the result that is currently selected." 145 158 146 159 itk_component add status { … … 155 168 pack $itk_component(status) -side left -padx 2 -pady {2 0} 156 169 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 usual164 rename -background -controlbarbackground controlbarBackground Background165 rename -foreground -controlbarforeground controlbarForeground Foreground166 rename -highlightbackground -controlbarbackground controlbarBackground Background167 }168 pack $itk_component(parameters) -side left -padx 8 -pady 1169 Rappture::Tooltip::for $itk_component(parameters) \170 "Click to access all parameters."171 172 170 itk_component add dials { 173 171 frame $itk_interior.dials … … 194 192 label $dials.labelmore.arrow -bitmap [Rappture::icon empty] -borderwidth 0 195 193 pack $dials.labelmore.arrow -side left -fill y 196 _control bind $dials.labelmore.arrow @more197 194 label $dials.labelmore.name -text "more parameters..." -font $fn \ 198 195 -borderwidth 0 -padx 0 -pady 1 … … 200 197 label $dials.labelmore.value 201 198 pack $dials.labelmore.value -side left 202 _control bind $dials.labelmore.name @more203 Rappture::Tooltip::for $dials.labelmore \204 "@[itcl::code $this _getTooltip more more]"205 206 # use this pop-up for access to all controls207 Rappture::Balloon $itk_component(hull).popup \208 -title "Change Parameters" -padx 0 -pady 0209 set inner [$itk_component(hull).popup component inner]210 211 frame $inner.cntls212 pack $inner.cntls -side bottom -fill x213 frame $inner.cntls.sep -height 2 -borderwidth 1 -relief sunken214 pack $inner.cntls.sep -side top -fill x -padx 4 -pady 4215 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 w220 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.frame228 }229 pack $itk_component(options) -expand yes -fill both230 blt::tk::scrollbar $inner.scrl.xs231 blt::tk::scrollbar $inner.scrl.ys232 itk_component add popup {233 frame $inner.scrl.frame234 }235 frame $itk_component(popup).bg236 199 237 200 eval itk_initialize $args … … 250 213 # Adds a new result to this result set. Scans through all existing 251 214 # results to look for a difference compared to previous results. 252 # Returns the index of this new result to the caller. The various253 # data objects for this result set should be added to their result254 # 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. 255 218 # ---------------------------------------------------------------------- 256 219 itcl::body Rappture::ResultSet::add {xmlobj} { … … 265 228 if {"" == $xmlobj0} { 266 229 # first element -- always add 267 $_results insert end [list $xmlobj] 230 set simnum "#[incr _resultnum]" 231 $_results insert end [list $xmlobj $simnum] 232 _fixNumResults 268 233 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 # ---------------------------------------------------------------------- 254 itcl::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 # ---------------------------------------------------------------------- 415 itcl::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 # ---------------------------------------------------------------------- 442 itcl::body Rappture::ResultSet::contains {xmlobj} { 443 # no results? then this must be new 444 if {[$_results size] == 0} { 276 445 return 0 277 446 } … … 282 451 # is a column to represent the quantity with the difference. 283 452 # 453 set xmlobj0 [$_results get -format xmlobj end] 284 454 foreach {op vpath oldval newval} [$xmlobj0 diff $xmlobj] { 285 455 if {[$xmlobj get $vpath.about.diffs] == "ignore"} { … … 291 461 continue 292 462 } 293 294 # make sure that these values really are different295 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 yet300 $_results column insert end -name $vpath -default $oldval301 }302 }303 304 # build a tuple for this new object305 set cols ""306 set tuple ""307 foreach col [lrange [$_results column names] 1 end] {308 lappend cols $col309 set raw [lindex [Rappture::LibraryObj::value $xmlobj $col] 0]310 lappend tuple $raw ;# use the "raw" (user-readable) label311 }312 313 # find a matching tuple? then replace it -- only need one314 if {[llength $cols] > 0} {315 set ilist [$_results find -format $cols -- $tuple]316 } else {317 set ilist 0 ;# no diffs -- must match first entry318 }319 320 # add all remaining columns for this new entry321 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 entry329 set index [lindex $ilist 0]330 $_results put $index $tuple331 set _recent $xmlobj332 } else {333 set index [$_results size]334 $_results insert end $tuple335 set _recent $xmlobj336 }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 normal343 }344 $itk_component(clear) configure -state normal345 346 return $index347 }348 349 # ----------------------------------------------------------------------350 # USAGE: clear351 #352 # Clears all results in this result set.353 # ----------------------------------------------------------------------354 itcl::body Rappture::ResultSet::clear {} {355 _doSettings356 357 # delete all adjuster controls358 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$id363 destroy $shortlist.label$id364 }365 366 array unset _cntlInfo $this-*367 # clean up control info368 foreach key [array names _cntlInfo $this-*] {369 catch {unset _cntlInfo($key)}370 }371 set _cntlInfo($this-all) ""372 set _counter 0373 374 # clear out all results375 $_results delete 0 end376 eval $_results column delete [lrange [$_results column names] 1 end]377 set _recent ""378 set _active ""379 380 set _plotall 0381 $itk_component(dials).all configure -relief raised \382 -background $itk_option(-background) \383 -foreground $itk_option(-foreground)384 385 # update status and Clear button386 $itk_component(status) configure -text "No results"387 $itk_component(parameters) configure -state disabled388 $itk_component(clear) configure -state disabled389 $_dispatcher event -idle !fixcntls390 391 # let clients know that the number of controls has changed392 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 of399 # controls. When a column is active, its label is bold and its400 # 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 above406 return407 }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 active415 set _active $column416 417 # keep track of usage, so we know which controls are popular418 incr _cntlInfo($this-$column-usage)419 420 # fix controls at next idle point421 $_dispatcher event -idle !layout why data422 $_dispatcher event -idle !settings column $_active423 }424 425 # ----------------------------------------------------------------------426 # USAGE: contains <xmlobj>427 #428 # Checks to see if the given <xmlobj> is already represented by429 # some result in this result set. This comes in handy when checking430 # to see if an input case is already covered.431 #432 # Returns 1 if the result set already contains this result, and433 # 0 otherwise.434 # ----------------------------------------------------------------------435 itcl::body Rappture::ResultSet::contains {xmlobj} {436 # no results? then this must be new437 if {[$_results size] == 0} {438 return 0439 }440 441 #442 # Compare this new object against the last XML object in the443 # results set. If it has a difference, make sure that there444 # 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 continue450 }451 if {$op == "+" || $op == "-"} {452 # ignore differences where parameters come and go453 # such differences make it hard to work controls454 continue455 }456 463 if {[$_results column names $vpath] == ""} { 457 464 # no column for this quantity yet … … 466 473 set format "" 467 474 set tuple "" 468 foreach col [lrange [$_results column names] 1end] {475 foreach col [lrange [$_results column names] 2 end] { 469 476 lappend format $col 470 477 set raw [lindex [Rappture::LibraryObj::value $xmlobj $col] 0] … … 543 550 544 551 # ---------------------------------------------------------------------- 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 # ---------------------------------------------------------------------- 558 itcl::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" } 554 574 } 555 575 } … … 565 585 if {[string length $itk_option(-settingscommand)] > 0} { 566 586 uplevel #0 $itk_option(-settingscommand) $cmd 567 }568 }569 570 # ----------------------------------------------------------------------571 # USAGE: _doPrompt <state>572 #573 # Used internally whenever the current settings represent a point574 # with no data. Invokes the -promptcommand with an explanation of575 # 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 $val585 }586 uplevel #0 $itk_option(-promptcommand) [list on $message $settings]587 } else {588 uplevel #0 $itk_option(-promptcommand) off589 }590 587 } 591 588 } … … 689 686 } 690 687 691 set popup $itk_component(popup)692 grid columnconfigure $popup 0 -minsize 16693 grid columnconfigure $popup 1 -weight 1694 695 688 set shortlist $itk_component(dials) 696 689 grid columnconfigure $shortlist 1 -weight 1 … … 711 704 # 712 705 if {![info exists _cntlInfo($this-$col-id)]} { 713 set row [lindex [grid size $popup] 1]714 set row2 [expr {$row+1}]715 716 706 set tip "" 717 if {$col == "xmlobj"} { 707 if {$col eq "xmlobj"} { 708 continue 709 } elseif {$col eq "simnum"} { 718 710 set quantity "Simulation" 719 711 set tip "List of all simulations that you have performed so far." … … 732 724 } 733 725 734 # 735 # Build the main control in the pop-up panel. 736 # 726 # Create the controls for the "short list" area. 737 727 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] 739 730 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 741 732 label $w.arrow -bitmap [Rappture::icon empty] -borderwidth 0 742 733 pack $w.arrow -side left -fill y … … 757 748 Rappture::Tooltip::for $w \ 758 749 "@[itcl::code $this _getTooltip label $col]" 759 760 set w $popup.dial$_counter761 Rappture::Radiodial $w -valuewidth 0762 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$_counter768 label $w -text "All" -padx 8 \769 -borderwidth 1 -relief raised -font $fn770 grid $w -row $row -rowspan 2 -column 1 -sticky nsew -padx 2 -pady 4771 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$_counter777 frame $w778 grid $w -row $row -column 1 -sticky ew779 label $w.arrow -bitmap [Rappture::icon empty] -borderwidth 0780 pack $w.arrow -side left -fill y781 _control bind $w.arrow $col782 783 label $w.name -text $quantity -anchor w \784 -borderwidth 0 -padx 0 -pady 1 -font $fn785 pack $w.name -side left786 bind $w.name <Configure> [itcl::code $this _fixValue $col resize]787 _control bind $w.name $col788 789 label $w.value -anchor w \790 -borderwidth 0 -padx 0 -pady 1 -font $fn791 pack $w.value -side left792 bind $w.value <Configure> [itcl::code $this _fixValue $col resize]793 _control bind $w.value $col794 795 Rappture::Tooltip::for $w \796 "@[itcl::code $this _getTooltip label $col]"797 798 # if this is the "Simulation #" control, add a separator799 if {$col == "xmlobj"} {800 grid $popup.all$_counter -column 0801 grid $popup.label$_counter -column 1 -columnspan 2802 grid $popup.dial$_counter -column 1 -columnspan 2803 804 if {![winfo exists $popup.sep]} {805 frame $popup.sep -height 1 -borderwidth 0 -background black806 }807 grid $popup.sep -row [expr {$row+2}] -column 0 \808 -columnspan 3 -sticky ew -pady 4809 810 if {![winfo exists $popup.paraml]} {811 label $popup.paraml -text "Parameters:" -font $fn812 }813 grid $popup.paraml -row [expr {$row+3}] -column 0 \814 -columnspan 3 -sticky w -padx 4 -pady {0 4}815 }816 750 817 751 # create a record for this control … … 844 778 # 845 779 set id $_cntlInfo($this-$col-id) 846 set popup $itk_component(popup)847 set dial $popup.dial$id848 849 _control load $popup.dial$id $col850 780 851 781 if {$col == $_layout(active)} { … … 862 792 # 863 793 if {$nadded > 0} { 864 if {[$_results column names] == 2|| $nadded == 1} {794 if {[$_results column names] == 3 || $nadded == 1} { 865 795 activate [lindex $_cntlInfo($this-all) end] 866 796 } else { 867 activate xmlobj797 activate simnum 868 798 } 869 799 } … … 874 804 # will then fix all other controls to match the one that changed. 875 805 # 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) $raw806 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 880 810 } 881 811 } … … 888 818 # so that the active control is displayed, and other recent controls 889 819 # 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. 891 821 # ---------------------------------------------------------------------- 892 822 itcl::body Rappture::ResultSet::_fixLayout {args} { 893 823 array set eventdata $args 894 824 895 set popup $itk_component(popup)896 825 set shortlist $itk_component(dials) 897 826 … … 907 836 foreach col $_cntlInfo($this-all) { 908 837 set id $_cntlInfo($this-$col-id) 909 $popup.label$id configure -background $bg910 $popup.label$id.arrow configure -background $bg \911 -bitmap [Rappture::icon empty]912 $popup.label$id.name configure -font $fn -background $bg913 $popup.label$id.value configure -background $bg914 $popup.all$id configure -background $bg -foreground $fg \915 -relief raised916 $popup.dial$id configure -background $bg917 838 $shortlist.label$id configure -background $bg 918 839 $shortlist.label$id.arrow configure -background $bg \ … … 995 916 996 917 if {$col == $_active} { 997 # put the background behind the active control in the popup998 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 nsew1002 lower $popup.bg1003 1004 918 if {$_layout(mode) == "usual"} { 1005 919 # put the background behind the active control in the shortlist … … 1033 947 set fg $itk_option(-activecontrolforeground) 1034 948 set bg $itk_option(-activecontrolbackground) 1035 1036 $popup.label$id configure -background $bg1037 $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 $bf1041 $popup.label$id.value configure -foreground $fg -background $bg1042 $popup.dial$id configure -background $bg1043 $popup.bg configure -background $bg1044 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 }1054 949 1055 950 if {$_layout(mode) == "usual"} { … … 1072 967 1073 968 # ---------------------------------------------------------------------- 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 # ---------------------------------------------------------------------- 976 itcl::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 # ---------------------------------------------------------------------- 1074 999 # USAGE: _fixSettings ?<eventArgs...>? 1075 1000 # … … 1088 1013 set changed "" 1089 1014 } 1090 _doPrompt off1091 1015 1092 1016 if {[info exists _cntlInfo($this-$_active-label)]} { … … 1107 1031 1 { 1108 1032 # only one data set? then plot it 1033 set simnum [$_results get -format simnum 0] 1109 1034 _doSettings [list \ 1110 0[list -width 2 \1035 $simnum [list -width 2 \ 1111 1036 -param [_getValues $_active current] \ 1112 1037 -description [_getParamDesc all] \ … … 1123 1048 # for a tuple that matches the current settings. 1124 1049 # 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)] 1129 1052 } else { 1130 1053 set format "" 1131 1054 set tuple "" 1132 foreach col [lrange [$_results column names] 1end] {1055 foreach col [lrange [$_results column names] 2 end] { 1133 1056 lappend format $col 1134 1057 lappend tuple $_cntlInfo($this-$col-value) … … 1136 1059 set irun [lindex [$_results find -format $format -- $tuple] 0] 1137 1060 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 } 1173 1095 } 1174 1096 … … 1181 1103 set _settings 1 1182 1104 1183 set format [lrange [$_results column names] 1end]1105 set format [lrange [$_results column names] 2 end] 1184 1106 if {[llength $format] == 1} { 1185 1107 set data [$_results get -format $format $irun] … … 1191 1113 set _cntlInfo($this-$col-value) $val 1192 1114 } 1193 set _cntlInfo($this-xmlobj-value) "#[expr {$irun+1}]" 1115 set simnum [$_results get -format simnum $irun] 1116 set _cntlInfo($this-simnum-value) $simnum 1194 1117 1195 1118 # okay, react to value changes again … … 1201 1124 # plot them. 1202 1125 # 1203 if {$_plotall && $_active == " xmlobj"} {1126 if {$_plotall && $_active == "simnum"} { 1204 1127 set format "" 1205 1128 } else { 1206 1129 set format "" 1207 1130 set tuple "" 1208 foreach col [lrange [$_results column names] 1end] {1131 foreach col [lrange [$_results column names] 2 end] { 1209 1132 if {!$_plotall || $col != $_active} { 1210 1133 lappend format $col … … 1224 1147 set format "" 1225 1148 set tuple "" 1226 foreach col [lrange [$_results column names] 1end] {1149 foreach col [lrange [$_results column names] 2 end] { 1227 1150 lappend format $col 1228 1151 lappend tuple $_cntlInfo($this-$col-value) 1229 1152 } 1230 1153 set icurr [$_results find -format $format -- $tuple] 1231 1232 # no data for these settings? prompt the user to simulate1233 if {"" == $icurr} {1234 _doPrompt on1235 }1236 1154 1237 1155 if {[llength $ilist] == 1} { 1238 1156 # single result -- always use active color 1239 1157 set i [lindex $ilist 0] 1158 set simnum [$_results get -format simnum $i] 1240 1159 set plist [list \ 1241 $ i[list -width 2 \1160 $simnum [list -width 2 \ 1242 1161 -param [_getValues $_active $i] \ 1243 1162 -description [_getParamDesc all $i] \ … … 1252 1171 set plist [list params $params] 1253 1172 foreach i $ilist { 1173 set simnum [$_results get -format simnum $i] 1254 1174 if {$i == $icurr} { 1255 lappend plist $ i[list -width 3 -raise 1 \1175 lappend plist $simnum [list -width 3 -raise 1 \ 1256 1176 -param [_getValues $_active $i] \ 1257 1177 -description [_getParamDesc all $i]] 1258 1178 } else { 1259 lappend plist $ i[list -brightness 0.7 -width 1 \1179 lappend plist $simnum [list -brightness 0.7 -width 1 \ 1260 1180 -param [_getValues $_active $i] \ 1261 1181 -description [_getParamDesc all $i]] … … 1268 1188 # 1269 1189 _doSettings $plist 1270 1271 } elseif {$itk_option(-missingdata) == "prompt"} {1272 # prompt the user to simulate these settings1273 _doPrompt on1274 _doSettings ;# clear plotting area1275 1276 # clear the current run selection -- there is no run for this1277 set _settings 11278 set _cntlInfo($this-xmlobj-value) ""1279 set _settings 01280 }1281 }1282 1283 # ----------------------------------------------------------------------1284 # USAGE: _fixExplore1285 #1286 # Called automatically whenever the user toggles the "Explore" button1287 # on the parameter popup. Changes the -missingdata option back and1288 # forth, to allow for missing data or skip it.1289 # ----------------------------------------------------------------------1290 itcl::body Rappture::ResultSet::_fixExplore {} {1291 if {$_explore} {1292 configure -missingdata prompt1293 } else {1294 configure -missingdata skip1295 1190 } 1296 1191 } … … 1307 1202 if {[info exists _cntlInfo($this-$col-id)]} { 1308 1203 set id $_cntlInfo($this-$col-id) 1309 1310 set popup $itk_component(popup)1311 set widget $popup.label$id1312 set wmax [winfo width $popup.dial$id]1313 _drawValue $col $widget $wmax1314 1204 1315 1205 set widget $itk_component(dials).label$id … … 1432 1322 } 1433 1323 set id $_cntlInfo($this-$col-id) 1434 set popup $itk_component(popup)1435 set pbutton $popup.all$id1436 set current [$pbutton cget -relief]1437 1324 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] 1445 1326 1446 1327 if {$current == "sunken"} { 1447 $pbutton configure -relief raised \1448 -background $itk_option(-activecontrolbackground) \1449 -foreground $itk_option(-activecontrolforeground)1450 1328 $sbutton configure -relief raised \ 1451 1329 -background $itk_option(-activecontrolbackground) \ … … 1453 1331 set _plotall 0 1454 1332 } else { 1455 $pbutton configure -relief sunken \1456 -background $itk_option(-togglebackground) \1457 -foreground $itk_option(-toggleforeground)1458 1333 $sbutton configure -relief sunken \ 1459 1334 -background $itk_option(-togglebackground) \ … … 1476 1351 # ---------------------------------------------------------------------- 1477 1352 itcl::body Rappture::ResultSet::_getValues {col {which ""}} { 1478 if {$col == " xmlobj"} {1353 if {$col == "simnum"} { 1479 1354 # load the Simulation # control 1480 1355 set nruns [$_results size] 1481 1356 for {set n 0} {$n < $nruns} {incr n} { 1482 set v "#[expr {$n+1}]"1357 set v [$_results get -format simnum $n] 1483 1358 set label2val($v) $n 1484 1359 } … … 1526 1401 default { 1527 1402 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] 1530 1405 } else { 1531 1406 # Be careful giving singleton elements as the "columns" … … 1584 1459 append tip "\n\nCurrently, plotting $what. Click to toggle." 1585 1460 } 1586 more {1587 set tip "Click to access all parameters."1588 }1589 1461 } 1590 1462 return [string trim $tip] … … 1603 1475 set format "" 1604 1476 set tuple "" 1605 foreach col [lrange [$_results column names] 1end] {1477 foreach col [lrange [$_results column names] 2 end] { 1606 1478 lappend format $col 1607 1479 lappend tuple $_cntlInfo($this-$col-value) … … 1626 1498 # argument to "Tuples::get". It is expecting a list. 1627 1499 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] 1631 1503 } 1632 1504 append desc "$quantity = $val\n" … … 1641 1513 1642 1514 # ---------------------------------------------------------------------- 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 # ---------------------------------------------------------------------- 1524 itcl::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 1651 1587 } 1652 1588 -
branches/blt4/gui/scripts/resultviewer.tcl
r2745 r2966 36 36 protected method _plotAdd {xmlobj {settings ""}} 37 37 protected method _fixScale {args} 38 protected proc _xml2data {xmlobj path} 38 protected method _xml2data {xmlobj path} 39 protected method _cleanIndex {index} 39 40 40 41 private variable _dispatcher "" ;# dispatchers for !events … … 42 43 private variable _mode2widget ;# maps plotting mode => widget 43 44 private variable _dataslots "" ;# list of all data objects in this widget 45 private variable _xml2data ;# maps xmlobj => data obj in _dataslots 44 46 } 45 47 … … 79 81 # ---------------------------------------------------------------------- 80 82 itcl::body Rappture::ResultViewer::add {index xmlobj path} { 83 set index [_cleanIndex $index] 81 84 set dobj [_xml2data $xmlobj $path] 82 85 … … 96 99 97 100 # ---------------------------------------------------------------------- 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. 101 108 # ---------------------------------------------------------------------- 102 109 itcl::body Rappture::ResultViewer::clear {{index ""}} { 103 if { "" != $index} {110 if {$index ne ""} { 104 111 # 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 108 137 itcl::delete object $dobj 109 }110 set _dataslots [lreplace $_dataslots $index $index ""]138 unset _xml2data($key) 139 } 111 140 } 112 141 } else { … … 119 148 } 120 149 set _dataslots "" 150 catch {unset _xml2data} 121 151 } 122 152 } … … 139 169 140 170 # ---------------------------------------------------------------------- 141 # USAGE: plot add ?< index> <settings> <index> <settings> ...?171 # USAGE: plot add ?<simnum> <settings> <simnum> <settings> ...? 142 172 # USAGE: plot clear 143 173 # … … 145 175 # command clears the current viewer. Data is still stored in the 146 176 # 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 148 179 # the optional <settings> are specified, then they are applied 149 180 # to the plot; otherwise, default settings are used. … … 158 189 continue 159 190 } 191 192 set index [_cleanIndex $index] 160 193 set reset "-color autoreset" 161 194 set slot [lindex $_dataslots $index] … … 263 296 set mode "contour" 264 297 if {![info exists _mode2widget($mode)]} { 298 global env 265 299 if { [$dataobj isunirect2d] } { 266 300 if { [$dataobj hints type] == "contour" } { … … 271 305 set resultMode "heightmap" 272 306 } 307 } elseif { [info exists env(VTKCONTOUR)] } { 308 set resultMode "vtkcontour" 273 309 } else { 274 310 set resultMode "vtk" … … 292 328 set fmt "vtk" 293 329 } 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" { 295 339 set fmt "nanovis" 296 340 set extents [$dataobj extents] … … 464 508 # ---------------------------------------------------------------------- 465 509 itcl::body Rappture::ResultViewer::_xml2data {xmlobj path} { 510 if {[info exists _xml2data($xmlobj-$path)]} { 511 return $_xml2data($xmlobj-$path) 512 } 513 466 514 set type [$xmlobj element -as type $path] 467 515 switch -- $type { 468 516 curve { 469 return[Rappture::Curve ::#auto $xmlobj $path]517 set dobj [Rappture::Curve ::#auto $xmlobj $path] 470 518 } 471 519 datatable { 472 return[Rappture::DataTable ::#auto $xmlobj $path]520 set dobj [Rappture::DataTable ::#auto $xmlobj $path] 473 521 } 474 522 histogram { 475 return[Rappture::Histogram ::#auto $xmlobj $path]523 set dobj [Rappture::Histogram ::#auto $xmlobj $path] 476 524 } 477 525 field { 478 return[Rappture::Field ::#auto $xmlobj $path]526 set dobj [Rappture::Field ::#auto $xmlobj $path] 479 527 } 480 528 mesh { 481 return[Rappture::Mesh ::#auto $xmlobj $path]529 set dobj [Rappture::Mesh ::#auto $xmlobj $path] 482 530 } 483 531 table { 484 return[Rappture::Table ::#auto $xmlobj $path]532 set dobj [Rappture::Table ::#auto $xmlobj $path] 485 533 } 486 534 image { 487 return[Rappture::Image ::#auto $xmlobj $path]535 set dobj [Rappture::Image ::#auto $xmlobj $path] 488 536 } 489 537 sequence { 490 return[Rappture::Sequence ::#auto $xmlobj $path]538 set dobj [Rappture::Sequence ::#auto $xmlobj $path] 491 539 } 492 540 string - log { 493 return[$xmlobj element -as object $path]541 set dobj [$xmlobj element -as object $path] 494 542 } 495 543 structure { 496 return[$xmlobj element -as object $path]544 set dobj [$xmlobj element -as object $path] 497 545 } 498 546 number - integer - boolean - choice { 499 return[$xmlobj element -as object $path]547 set dobj [$xmlobj element -as object $path] 500 548 } 501 549 drawing3d - drawing { 502 return[Rappture::Drawing ::#auto $xmlobj $path]550 set dobj [Rappture::Drawing ::#auto $xmlobj $path] 503 551 } 504 552 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 # ---------------------------------------------------------------------- 573 itcl::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,..." 509 580 } 510 581 -
branches/blt4/gui/scripts/unirect3d.tcl
r2745 r2966 68 68 GetSize $m "zaxis.numpoints" _zNum 69 69 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 } 70 101 itcl::delete object $m 71 102 … … 193 224 # ---------------------------------------------------------------------- 194 225 itcl::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) 238 242 } 239 243 if {$keyword != ""} { -
branches/blt4/gui/scripts/visviewer.tcl
r2745 r2966 40 40 #private variable _idleTimeout 5000; # 5 seconds 41 41 #private variable _idleTimeout 0; # No timeout 42 private variable _logging 0 42 43 43 44 protected variable _dispatcher ""; # dispatcher for !events … … 163 164 pack $itk_component(plotarea) -fill both -expand yes 164 165 set _image(plot) [image create picture] 166 167 global env 168 if { [info exists env(VISRECORDER)] } { 169 set _logging 1 170 } 165 171 eval itk_initialize $args 166 172 } … … 421 427 422 428 # 423 # ReceiveBytes--429 # StartWaiting -- 424 430 # 425 431 # Read some number of bytes from the visualization server. … … 544 550 # 545 551 itcl::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 } 546 557 #puts stderr ">>($data)" 547 558 if {[string length $itk_option(-sendcommand)] > 0} { -
branches/blt4/gui/scripts/vtkvolumeviewer.tcl
r2791 r2966 258 258 cutplane-zposition 50 259 259 cutplane-visible 1 260 cutplane-lighting 1 260 261 cutplane-wireframe 0 261 262 cutplane-opacity 100 262 263 volume-lighting 1 264 volume-material 80 263 265 volume-opacity 40 266 volume-quality 50 264 267 volume-visible 1 265 volume-wireframe 0266 268 legend-visible 1 267 269 }] … … 994 996 set _first "" 995 997 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 999 999 1000 1000 SendCmd "imgflush" … … 1100 1100 } 1101 1101 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 1103 1106 1104 1107 if { $_reset } { … … 1363 1366 } 1364 1367 } 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 } 1365 1379 "volume-lighting" { 1366 1380 set bool $_settings(volume-lighting) 1367 1381 foreach dataset [CurrentDatasets -visible] { 1368 1382 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" 1369 1390 } 1370 1391 } … … 1429 1450 -troughcolor grey82 1430 1451 } 1431 SendCmd "cutplane axis $axis $bool" 1452 foreach dataset [CurrentDatasets -visible] { 1453 SendCmd "cutplane axis $axis $bool $dataset" 1454 } 1432 1455 } 1433 1456 "cutplane-xposition" - "cutplane-yposition" - "cutplane-zposition" { 1434 1457 set axis [string range $what 9 9] 1435 1458 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 } 1437 1462 set _cutplanePending 0 1438 1463 } … … 1565 1590 $_dataset2style($tag) != $name } { 1566 1591 SendCmd "volume colormap $name $tag" 1567 SendCmd "cutplane colormap $name $tag"1592 SendCmd "cutplane colormap $name-opaque $tag" 1568 1593 set _dataset2style($tag) $name 1569 1594 } … … 1798 1823 set max $_settings(volume-opacity) 1799 1824 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" 1802 1829 SendCmd "colormap add $name { $cmap } { $wmap }" 1830 SendCmd "colormap add $name-opaque { $cmap } { $opaqueWmap }" 1803 1831 } 1804 1832 … … 1917 1945 -font "Arial 9" 1918 1946 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 1919 1954 label $inner.opacity_l -text "Opacity" -font "Arial 9" 1920 1955 ::scale $inner.opacity -from 0 -to 100 -orient horizontal \ … … 1923 1958 -showvalue off \ 1924 1959 -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] 1925 1966 1926 1967 label $inner.field_l -text "Field" -font "Arial 9" … … 1958 1999 1959 2000 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 \ 1966 2012 1967 2013 blt::table configure $inner r* c* -resize none 1968 blt::table configure $inner r8 c 1-resize expand2014 blt::table configure $inner r8 c3 -resize expand 1969 2015 } 1970 2016 … … 2363 2409 #SendCmd "cutplane visible $tag" 2364 2410 foreach axis { x y z } { 2365 SendCmd "cutplane slice $axis 1.0$tag"2411 SendCmd "cutplane slice $axis 0.5 $tag" 2366 2412 SendCmd "cutplane axis $axis 0 $tag" 2367 2413 } -
branches/blt4/gui/scripts/xyresult.tcl
r2746 r2966 115 115 common _downloadPopup ;# download options from popup 116 116 private variable _markers 117 private variable _nextElement 0 117 118 } 118 119 … … 684 685 } 685 686 686 set elem "elem[incr count]"687 set elem "elem[incr _nextElement]" 687 688 set _elem2dataobj($elem) $dataobj 688 689 lappend label2elem($label) $elem -
branches/blt4/lang/tcl/scripts/library.tcl
r2936 r2966 511 511 } 512 512 set string [$node text] 513 # Expat (via tDOM) will always produce utf-8 output, regardless of the514 # encoding of the tool.xml. We need to convert utf-8 to unicode for515 # 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 $string520 513 if {$params(-decode) == "yes"} { 521 514 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 525 519 } 526 520 -
branches/blt4/lang/tcl/src/RpEncodeTclInterface.cc
r2936 r2966 278 278 279 279 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 } 281 286 Rappture::Buffer buf(string, numBytes); 282 283 287 Rappture::Outcome status; 284 288 if (!Rappture::encoding::decode(status, buf, switches.flags)) { … … 286 290 return TCL_ERROR; 287 291 } 288 Tcl_SetStringObj(Tcl_GetObjResult(interp), buf.bytes(), buf.size()); 292 Tcl_SetByteArrayObj(Tcl_GetObjResult(interp), 293 (const unsigned char *)buf.bytes(), buf.size()); 289 294 return TCL_OK; 290 295 } -
branches/blt4/packages/vizservers/nanovis/Axis.cpp
r2936 r2966 111 111 112 112 Axis::Axis(const char *axisName) : 113 _name( axisName),113 _name(strdup(axisName)), 114 114 _flags(AUTOSCALE), 115 115 _title(NULL), -
branches/blt4/packages/vizservers/nanovis/Axis.h
r2936 r2966 2 2 #ifndef AXIS_H 3 3 #define AXIS_H 4 5 #include <stdlib.h> 4 6 5 7 #include <cmath> … … 45 47 }; 46 48 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. 56 52 */ 57 53 class Ticks … … 182 178 183 179 /** 184 * Structurecontains options controlling how the axis will be180 * Class contains options controlling how the axis will be 185 181 * displayed. 186 182 */ … … 212 208 } 213 209 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 214 220 void resetRange(); 215 221 … … 218 224 void setScale(double min, double max); 219 225 220 double scale() 226 double scale() const 221 227 { 222 228 return _scale; 223 229 } 224 230 225 double range() 231 double range() const 226 232 { 227 233 return _range; 228 234 } 229 235 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 240 236 void getDataLimits(double& min, double& max) 241 237 { 242 238 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); 243 269 } 244 270 … … 284 310 } 285 311 _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);316 312 } 317 313 -
branches/blt4/packages/vizservers/nanovis/Command.cpp
r2936 r2966 78 78 1.0 1 0 1\n\ 79 79 } {\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\ 96 94 }"; 97 95 … … 651 649 NanoVis::readScreen(); 652 650 653 NanoVis::ppmWrite("nv>image - bytes %d -type print");651 NanoVis::ppmWrite("nv>image -type print -bytes %d"); 654 652 NanoVis::resizeOffscreenBuffer(w, h); 655 653 -
branches/blt4/packages/vizservers/nanovis/FlowCmd.cpp
r2936 r2966 561 561 562 562 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;567 563 568 564 _fieldPtr->setVectorField(_volPtr, loc, … … 657 653 Volume *volPtr; 658 654 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, 661 660 NanoVis::magMin, NanoVis::magMax, 0); 662 661 volPtr->xAxis.setRange(_dataPtr->xMin(), _dataPtr->xMax()); … … 672 671 NanoVis::magMin, NanoVis::magMax); 673 672 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 the679 volume. */680 673 volPtr->disableCutplane(0); 681 674 volPtr->disableCutplane(1); … … 689 682 volPtr->specular(_sv.specular); 690 683 volPtr->diffuse(_sv.diffuse); 691 TRACE("volume is now %d %d\n", _sv.showVolume, volPtr->visible());692 684 volPtr->visible(_sv.showVolume); 693 685 float dx0 = -0.5; … … 1018 1010 continue; 1019 1011 } 1020 Rappture::Unirect3d *dataPtr; 1021 dataPtr = flowPtr->data(); 1012 Rappture::Unirect3d *dataPtr = flowPtr->data(); 1022 1013 min = dataPtr->magMin(); 1023 1014 max = dataPtr->magMax(); … … 1065 1056 // FIXME: This doesn't work when there is more than one flow. 1066 1057 licRenderer->setOffset(flowPtr->GetRelativePosition()); 1067 NanoVis::velocityArrowsSlice->slicePos(flowPtr->GetRelativePosition());1058 velocityArrowsSlice->slicePos(flowPtr->GetRelativePosition()); 1068 1059 } 1069 1060 AdvectFlows(); -
branches/blt4/packages/vizservers/nanovis/Grid.cpp
r2936 r2966 18 18 _majorColor(1.0f, 1.0f, 1.0f, 1.0f), 19 19 _minorColor(0.5f, 0.5f, 0.5f, 1.0f), 20 _font( 0),20 _font(NULL), 21 21 _visible(false) 22 { 23 } 24 25 Grid::~Grid() 22 26 { 23 27 } -
branches/blt4/packages/vizservers/nanovis/Grid.h
r2936 r2966 33 33 public: 34 34 Grid(); 35 virtual ~Grid(); 35 36 36 37 bool isVisible() const -
branches/blt4/packages/vizservers/nanovis/HeightMap.cpp
r2936 r2966 1 1 /* -*- 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 10 2 #include <GL/glew.h> 11 #include <Cg/cgGL.h>12 3 13 4 #include "Grid.h" … … 15 6 #include "ContourLineFilter.h" 16 7 #include "Texture1D.h" 17 #include "R2/R2FilePath.h"18 #include "RpField1D.h"19 8 #include "RenderContext.h" 20 9 … … 27 16 HeightMap::HeightMap() : 28 17 _vertexBufferObjectID(0), 29 _tex tureBufferObjectID(0),18 _texcoordBufferObjectID(0), 30 19 _vertexCount(0), 31 20 _contour(0), … … 45 34 _shader = new NvShader(); 46 35 _shader->loadFragmentProgram("heightcolor.cg", "main"); 47 _tfParam = _shader->getNamedParameterFromFP("tf");48 _opacityParam = _shader->getNamedParameterFromFP("opacity");49 36 } 50 37 … … 53 40 reset(); 54 41 55 if (_shader ) {42 if (_shader != NULL) { 56 43 delete _shader; 57 44 } 58 45 if (_heights != NULL) { 59 free(_heights);46 delete [] _heights; 60 47 } 61 48 } … … 105 92 // 106 93 _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); 111 96 112 97 glEnable(GL_TEXTURE_1D); … … 119 104 glVertexPointer(3, GL_FLOAT, 12, 0); 120 105 121 glBindBuffer(GL_ARRAY_BUFFER, _tex tureBufferObjectID);106 glBindBuffer(GL_ARRAY_BUFFER, _texcoordBufferObjectID); 122 107 glTexCoordPointer(3, GL_FLOAT, 12, 0); 123 108 … … 138 123 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 139 124 125 _shader->disableFPTextureParameter("tf"); 140 126 _shader->unbind(); 141 127 } … … 247 233 _vertexBufferObjectID = 0; 248 234 } 249 if (_tex tureBufferObjectID) {250 glDeleteBuffers(1, &_tex tureBufferObjectID);251 _tex tureBufferObjectID = 0;235 if (_texcoordBufferObjectID) { 236 glDeleteBuffers(1, &_texcoordBufferObjectID); 237 _texcoordBufferObjectID = 0; 252 238 } 253 239 if (_contour != NULL) { … … 260 246 } 261 247 } 262 248 #if 0 263 249 void 264 250 HeightMap::setHeight(int xCount, int yCount, Vector3 *heights) … … 302 288 glBufferData(GL_ARRAY_BUFFER, _vertexCount * sizeof( Vector3 ), heights, 303 289 GL_STATIC_DRAW); 304 glGenBuffers(1, &_tex tureBufferObjectID);305 glBindBuffer(GL_ARRAY_BUFFER, _tex tureBufferObjectID);290 glGenBuffers(1, &_texcoordBufferObjectID); 291 glBindBuffer(GL_ARRAY_BUFFER, _texcoordBufferObjectID); 306 292 glBufferData(GL_ARRAY_BUFFER, _vertexCount * sizeof(float) * 3, texcoord, 307 293 GL_STATIC_DRAW); … … 333 319 //} 334 320 } 335 321 #endif 336 322 void 337 323 HeightMap::setHeight(float xMin, float yMin, float xMax, float yMax, … … 394 380 glBufferData(GL_ARRAY_BUFFER, _vertexCount * sizeof(Vector3), map, 395 381 GL_STATIC_DRAW); 396 glGenBuffers(1, &_tex tureBufferObjectID);397 glBindBuffer(GL_ARRAY_BUFFER, _tex tureBufferObjectID);382 glGenBuffers(1, &_texcoordBufferObjectID); 383 glBindBuffer(GL_ARRAY_BUFFER, _texcoordBufferObjectID); 398 384 glBufferData(GL_ARRAY_BUFFER, _vertexCount * sizeof(float) * 3, texcoord, 399 385 GL_STATIC_DRAW); … … 494 480 glBufferData(GL_ARRAY_BUFFER, _vertexCount * sizeof(Vector3), vertices, 495 481 GL_STATIC_DRAW); 496 glGenBuffers(1, &_tex tureBufferObjectID);497 glBindBuffer(GL_ARRAY_BUFFER, _tex tureBufferObjectID);482 glGenBuffers(1, &_texcoordBufferObjectID); 483 glBindBuffer(GL_ARRAY_BUFFER, _texcoordBufferObjectID); 498 484 glBufferData(GL_ARRAY_BUFFER, _vertexCount * sizeof(float) * 3, texcoord, 499 485 GL_STATIC_DRAW); … … 578 564 if (_tfPtr != NULL) { 579 565 _shader->bind(); 580 581 cgGLSetTextureParameter(_tfParam, _tfPtr->id()); 582 cgGLEnableTextureParameter(_tfParam); 566 567 _shader->setFPTextureParameter("tf", _tfPtr->id()); 583 568 584 569 glEnable(GL_TEXTURE_1D); … … 593 578 glVertexPointer(3, GL_FLOAT, 12, 0); 594 579 595 glBindBuffer(GL_ARRAY_BUFFER, _tex tureBufferObjectID);580 glBindBuffer(GL_ARRAY_BUFFER, _texcoordBufferObjectID); 596 581 glTexCoordPointer(3, GL_FLOAT, 12, 0); 597 582 … … 612 597 glDisableClientState(GL_TEXTURE_COORD_ARRAY); 613 598 599 _shader->disableFPTextureParameter("tf"); 614 600 _shader->unbind(); 615 601 } -
branches/blt4/packages/vizservers/nanovis/HeightMap.h
r2936 r2966 2 2 #ifndef HEIGHTMAP_H 3 3 #define HEIGHTMAP_H 4 5 #include <Cg/cg.h>6 4 7 5 #include <R2/graphics/R2Geometry.h> … … 36 34 /** 37 35 *@brief Create a height map with heigh values 38 *@param startX ax position of the first height value39 *@param startY ay position of the first height value40 *@param endX ax position of the last height value41 *@param endY ay position of the last height value36 *@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 42 40 *@param xCount the number of columns of height values 43 41 *@param yCount the number of rows of height values … … 46 44 void setHeight(float startX, float startY, float endX, float endY, 47 45 int xCount, int yCount, float *height); 48 46 #if 0 49 47 /** 50 48 *@brief Create a height map with a set of points … … 53 51 */ 54 52 void setHeight(int xCount, int yCount, Vector3 *heights); 55 53 #endif 56 54 void mapToGrid(Grid *gridPtr); 57 55 … … 126 124 127 125 private: 128 void createIndexBuffer(int xCount, int zCount, float *heights);126 void createIndexBuffer(int xCount, int zCount, float *heights); 129 127 Vector3 *createHeightVertices(float startX, float startY, 130 128 float endX, float endY, 131 int xCount, int yCount, float 129 int xCount, int yCount, float *height); 132 130 void reset(); 133 131 134 132 unsigned int _vertexBufferObjectID; 135 unsigned int _tex tureBufferObjectID;133 unsigned int _texcoordBufferObjectID; 136 134 int _vertexCount; 137 CGparameter _tfParam;138 CGparameter _opacityParam;139 135 R2Geometry *_contour; 140 136 R2Geometry *_topContour; … … 145 141 int _indexCount; 146 142 Vector3 _contourColor; 147 143 148 144 bool _contourVisible; 149 145 bool _topContourVisible; 150 146 bool _visible; 151 147 152 148 Vector3 _scale; 153 149 Vector3 _centerPoint; -
branches/blt4/packages/vizservers/nanovis/Makefile.in
r2936 r2966 120 120 NvColorTableRenderer.o \ 121 121 NvColorTableShader.o \ 122 NvDefaultTFData.o \123 122 NvEventLog.o \ 124 NvFlowVisRenderer.o \125 123 NvLIC.o \ 126 124 NvParticleAdvectionShader.o \ … … 180 178 ifdef NOTDEF 181 179 OBJS += DataLoader.o \ 180 NvFlowVisRenderer.o \ 182 181 ParticleEmitter.o \ 183 182 ParticleSystem.o \ … … 301 300 NvColorTableRenderer.o: NvColorTableRenderer.cpp NvColorTableRenderer.h 302 301 NvColorTableShader.o: NvColorTableShader.cpp NvColorTableShader.h NvShader.h 303 NvDefaultTFData.o: NvDefaultTFData.cpp304 302 NvEventLog.o: NvEventLog.cpp NvEventLog.h 305 303 NvFlowVisRenderer.o: NvFlowVisRenderer.cpp NvFlowVisRenderer.h -
branches/blt4/packages/vizservers/nanovis/NvColorTableRenderer.cpp
r2936 r2966 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 2 #include <stdlib.h> 3 4 #include <GL/glew.h> 3 5 4 6 #include <R2/R2Fonts.h> -
branches/blt4/packages/vizservers/nanovis/NvColorTableShader.cpp
r2936 r2966 1 1 /* -*- 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 7 2 #include "NvColorTableShader.h" 8 #include "Trace.h"9 3 10 4 NvColorTableShader::NvColorTableShader() … … 20 14 { 21 15 loadFragmentProgram("one_plane.cg", "main"); 22 _dataParam = getNamedParameterFromFP("data");23 _tfParam = getNamedParameterFromFP("tf");24 _renderParam = getNamedParameterFromFP("render_param");25 16 } 26 17 27 18 void NvColorTableShader::bind(Texture2D *plane, TransferFunction *tf) 28 19 { 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.); 34 24 35 25 NvShader::bind(); … … 38 28 void NvColorTableShader::unbind() 39 29 { 40 cgGLDisableTextureParameter(_dataParam);41 cgGLDisableTextureParameter(_tfParam);30 disableFPTextureParameter("data"); 31 disableFPTextureParameter("tf"); 42 32 43 33 NvShader::unbind(); -
branches/blt4/packages/vizservers/nanovis/NvColorTableShader.h
r2936 r2966 2 2 #ifndef NV_COLORTABLE_SHADER_H 3 3 #define NV_COLORTABLE_SHADER_H 4 5 #include <Cg/cg.h>6 4 7 5 #include "NvShader.h" … … 22 20 private : 23 21 void init(); 24 25 CGparameter _dataParam;26 CGparameter _tfParam;27 CGparameter _renderParam;28 22 }; 29 23 -
branches/blt4/packages/vizservers/nanovis/NvFlowVisRenderer.cpp
r2936 r2966 15 15 */ 16 16 17 #include <stdio.h>18 #include <assert.h>19 #include <malloc.h>20 #include <string.h>21 22 #include <R2/R2FilePath.h>23 24 17 #include "NvFlowVisRenderer.h" 25 #include "NvVectorField.h"26 #include "Trace.h"27 18 28 19 #define NV_32 -
branches/blt4/packages/vizservers/nanovis/NvFlowVisRenderer.h
r2936 r2966 3 3 #define NVFLOWVISRENDERER_H 4 4 5 #include <vector>6 5 #include <map> 7 6 #include <string> 8 7 9 #include <GL/glew.h>10 #include <Cg/cgGL.h>11 12 #include "config.h"13 14 #include "Renderable.h"15 #include "RenderVertexArray.h"16 8 #include "Vector3.h" 17 #include "NvParticleAdvectionShader.h"18 9 #include "NvVectorField.h" 19 10 -
branches/blt4/packages/vizservers/nanovis/NvLIC.cpp
r2936 r2966 30 30 31 31 NvLIC::NvLIC(int size, int width, int height, int axis, 32 const Vector3&offset) :32 float offset) : 33 33 Renderable(Vector3(0.0f, 0.0f, 0.0f)), 34 34 _width(width), … … 265 265 case 0 : 266 266 // 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); 271 271 break; 272 272 case 1 : 273 273 // 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); 278 278 break; 279 279 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); 284 284 break; 285 285 } … … 459 459 case 0: 460 460 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); 465 465 break; 466 466 case 1: 467 467 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); 472 472 break; 473 473 case 2: 474 474 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); 479 479 break; 480 480 } … … 530 530 531 531 void 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 } 532 NvLIC::setOffset(float offset) 533 { 534 _offset = offset; 539 535 getSlice(); 540 536 } -
branches/blt4/packages/vizservers/nanovis/NvLIC.h
r2936 r2966 31 31 { 32 32 public: 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); 35 34 ~NvLIC(); 36 35 … … 49 48 void getSlice(); 50 49 51 void setOffset(float v);50 void setOffset(float offset); 52 51 53 52 /** … … 100 99 // plane to fit the actual dimensions 101 100 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 104 102 int _axis; 105 103 -
branches/blt4/packages/vizservers/nanovis/NvParticleAdvectionShader.cpp
r2936 r2966 1 1 /* -*- 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 7 2 #include "NvParticleAdvectionShader.h" 8 #include "Trace.h"9 3 10 4 NvParticleAdvectionShader::NvParticleAdvectionShader() : … … 25 19 { 26 20 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");34 21 } 35 22 … … 37 24 NvParticleAdvectionShader::bind(unsigned int texID, unsigned int initPosTexID) 38 25 { 39 cgGLSetTextureParameter(_posTexParam, texID); 40 cgGLEnableTextureParameter(_posTexParam); 26 setFPTextureParameter("pos_tex", texID); 27 setFPTextureParameter("init_pos_tex", initPosTexID); 28 setFPTextureParameter("vel_tex", _velocityVolumeID); 41 29 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); 52 34 53 35 NvShader::bind(); … … 57 39 NvParticleAdvectionShader::unbind() 58 40 { 59 cgGLDisableTextureParameter(_posTexParam);60 cgGLDisableTextureParameter(_initPosTexParam);61 cgGLDisableTextureParameter(_velTexParam);41 disableFPTextureParameter("pos_tex"); 42 disableFPTextureParameter("init_pos_tex"); 43 disableFPTextureParameter("vel_tex"); 62 44 63 45 NvShader::unbind(); -
branches/blt4/packages/vizservers/nanovis/NvParticleAdvectionShader.h
r2936 r2966 8 8 class NvParticleAdvectionShader : public NvShader 9 9 { 10 public: 10 public: 11 11 NvParticleAdvectionShader(); 12 12 … … 27 27 _max = max; 28 28 // FIXME: Is this needed? 29 //if (_max > 100.f)30 //_max = 100.0f;29 if (_max > 100.f) 30 _max = 100.0f; 31 31 } 32 32 … … 44 44 void init(); 45 45 46 CGparameter _posTexParam;47 CGparameter _initPosTexParam;48 CGparameter _velTexParam;49 CGparameter _posTimestepParam;50 CGparameter _maxParam;51 CGparameter _modeParam;52 CGparameter _scaleParam;53 54 46 unsigned int _velocityVolumeID; 55 47 Vector3 _scale; -
branches/blt4/packages/vizservers/nanovis/NvParticleRenderer.cpp
r2936 r2966 15 15 */ 16 16 17 #include <stdio.h>18 17 #include <assert.h> 19 #include <malloc.h>20 18 #include <string.h> 21 19 #include <stdlib.h> 22 20 23 #include < R2/R2FilePath.h>21 #include <GL/glew.h> 24 22 25 23 #include "NvParticleRenderer.h" … … 92 90 GL_TEXTURE_RECTANGLE_ARB, _psysTex[0], 0); 93 91 92 CHECK_FRAMEBUFFER_STATUS(); 94 93 95 94 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, _psysFbo[1]); … … 108 107 GL_TEXTURE_RECTANGLE_ARB, _psysTex[1], 0); 109 108 109 CHECK_FRAMEBUFFER_STATUS(); 110 110 111 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboOrig); 111 112 … … 121 122 _psysWidth, _psysHeight, 0, GL_RGBA, GL_FLOAT, NULL); 122 123 #endif 123 124 CHECK_FRAMEBUFFER_STATUS();125 124 126 125 if (_advectionShader == NULL) { … … 300 299 if (_psysFrame == _maxLife) { 301 300 _psysFrame = 0; 302 // 301 // _reborn = true; 303 302 } 304 303 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboOrig); … … 314 313 //_vertexArray->loadData(vert); //does not work?? 315 314 //assert(glGetError()==0); 316 }317 318 void319 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();370 315 } 371 316 … … 386 331 glScaled(_scale.x, _scale.y, _scale.z); 387 332 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 403 333 glPointSize(_particleSize); 404 334 glColor4f(_color.x, _color.y, _color.z, _color.w); 335 405 336 glEnableClientState(GL_VERTEX_ARRAY); 406 337 _vertexArray->setPointer(0); … … 409 340 410 341 glPopMatrix(); 411 412 342 glPopAttrib(); 413 414 //assert(glGetError()==0);415 343 } 416 344 -
branches/blt4/packages/vizservers/nanovis/NvParticleRenderer.h
r2936 r2966 17 17 #define NVPARTICLERENDERER_H 18 18 19 #include <vector>20 21 19 #include <GL/glew.h> 22 #include <Cg/cgGL.h>23 24 #include "config.h"25 20 26 21 #include "Renderable.h" 22 #include "NvParticleAdvectionShader.h" 27 23 #include "RenderVertexArray.h" 28 24 #include "Vector3.h" 29 #include " NvParticleAdvectionShader.h"25 #include "Vector4.h" 30 26 31 27 struct Particle { … … 81 77 82 78 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);87 79 88 80 void initializeDataArray(); -
branches/blt4/packages/vizservers/nanovis/NvShader.cpp
r2936 r2966 90 90 TRACE("In ~NvShader"); 91 91 if (_cgContext == NULL) { 92 TRACE("Lost Cg context ");92 TRACE("Lost Cg context: vp: %s, fp: %s", _vpFile.c_str(), _fpFile.c_str()); 93 93 } else { 94 94 resetPrograms(); … … 103 103 _cgVP = loadCgSourceProgram(_cgContext, fileName, 104 104 _vertexProfile, entryPoint); 105 _vpFile = fileName; 105 106 } 106 107 … … 112 113 _cgFP = loadCgSourceProgram(_cgContext, fileName, 113 114 _fragmentProfile, entryPoint); 115 _fpFile = fileName; 114 116 } 115 117 … … 117 119 { 118 120 if (_cgVP != NULL) { 121 TRACE("Destroying vertex program: %s\n", _vpFile.c_str()); 119 122 cgDestroyProgram(_cgVP); 120 123 } 121 124 122 125 if (_cgFP != NULL) { 126 TRACE("Destroying fragment program: %s\n", _fpFile.c_str()); 123 127 cgDestroyProgram(_cgFP); 124 128 } -
branches/blt4/packages/vizservers/nanovis/NvShader.h
r2936 r2966 3 3 #define NV_SHADER_H 4 4 5 #include <string> 6 #include <tr1/unordered_map> 7 5 8 #include <GL/glew.h> 6 9 #include <Cg/cg.h> … … 16 19 { 17 20 public: 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 18 31 typedef void NvCgCallbackFunction(void); 19 32 … … 41 54 return cgGetNamedParameter(_cgFP, paramName); 42 55 } 56 ERROR("Unknown fragment program parameter: %s\n", paramName); 43 57 return 0; 44 58 } … … 49 63 return cgGetNamedParameter(_cgVP, paramName); 50 64 } 65 ERROR("Unknown vertex program parameter: %s\n", paramName); 51 66 return 0; 52 67 } 53 68 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; 56 138 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); 67 199 } 68 200 … … 126 258 127 259 protected: 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 128 304 void resetPrograms(); 129 305 130 306 CGprofile _vertexProfile; 131 307 CGprofile _fragmentProfile; 308 std::string _vpFile; 132 309 CGprogram _cgVP; 310 std::string _fpFile; 133 311 CGprogram _cgFP; 312 ParameterHashmap _vpParams; 313 ParameterHashmap _fpParams; 134 314 135 315 static CGprofile _defaultVertexProfile; -
branches/blt4/packages/vizservers/nanovis/NvStdVertexShader.cpp
r2936 r2966 1 1 /* -*- 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 7 2 #include "NvStdVertexShader.h" 8 3 … … 19 14 { 20 15 loadVertexProgram("vertex_std.cg", "main"); 21 _mvpVertStdParam = getNamedParameterFromVP("modelViewProjMatrix");22 _mviVertStdParam = getNamedParameterFromVP("modelViewInv");23 16 } 24 17 25 18 void NvStdVertexShader::bind() 26 19 { 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); 29 22 30 23 NvShader::bind(); -
branches/blt4/packages/vizservers/nanovis/NvStdVertexShader.h
r2936 r2966 21 21 private: 22 22 void init(); 23 24 /// A parameter id for ModelViewProjection matrix of Cg program25 CGparameter _mvpVertStdParam;26 27 /// A parameter id for ModelViewInverse matrix of Cg program28 CGparameter _mviVertStdParam;29 23 }; 30 24 -
branches/blt4/packages/vizservers/nanovis/NvZincBlendeVolumeShader.cpp
r2936 r2966 1 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 3 #include <string.h>4 2 5 3 #include <GL/glew.h> -
branches/blt4/packages/vizservers/nanovis/PlaneRenderer.cpp
r2936 r2966 14 14 * ====================================================================== 15 15 */ 16 17 #include <GL/glew.h> 16 18 17 19 #include "PlaneRenderer.h" -
branches/blt4/packages/vizservers/nanovis/PlaneRenderer.h
r2936 r2966 17 17 #define PLANE_RENDERER_H 18 18 19 #include <math.h>20 #include <stdio.h>21 #include <assert.h>22 #include <float.h>23 24 19 #include <vector> 25 26 #include <GL/glew.h>27 #include <Cg/cgGL.h>28 20 29 21 #include "NvColorTableShader.h" -
branches/blt4/packages/vizservers/nanovis/PointSetRenderer.cpp
r2936 r2966 48 48 } 49 49 50 PointSetRenderer::~PointSetRenderer() 51 { 52 } 53 50 54 void PointSetRenderer::renderPoints(PCA::Point *points, int length) 51 55 { … … 73 77 glBegin(GL_POINTS); 74 78 75 PCA::ClusterList *p;79 PCA::ClusterList *p; 76 80 for (int i = size - 1; i >= 0; --i) { 77 81 p = bucket[i]; -
branches/blt4/packages/vizservers/nanovis/PointSetRenderer.h
r2936 r2966 11 11 class PointSetRenderer 12 12 { 13 public: 13 public: 14 14 PointSetRenderer(); 15 15 ~PointSetRenderer(); -
branches/blt4/packages/vizservers/nanovis/PointShader.cpp
r2936 r2966 1 1 /* -*- 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 9 2 #include "PointShader.h" 10 3 11 4 PointShader::PointShader() : 12 NvShader(), 5 NvShader(), 6 _scale(1.0f), 13 7 _normal(NULL) 14 8 { 15 9 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");23 10 } 24 11 … … 27 14 } 28 15 29 void PointShader:: setParameters()16 void PointShader::bind() 30 17 { 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); 33 20 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()); 38 26 39 //cgGLSetTextureParameter(_normalParam,_normal->getGraphicsObjectID()); 40 //cgGLEnableTextureParameter(_normalParam); 27 NvShader::bind(); 41 28 } 42 29 43 void PointShader:: resetParameters()30 void PointShader::unbind() 44 31 { 45 //cgGLDisableTextureParameter(_normalParam); 32 //disableVPTextureParameter("normal"); 33 34 NvShader::unbind(); 46 35 } -
branches/blt4/packages/vizservers/nanovis/PointShader.h
r2936 r2966 15 15 void setScale(float scale) 16 16 { 17 cgGLSetParameter4f(_scaleVP, scale, 1.0f, 1.0f, 1.0f);17 _scale = scale; 18 18 } 19 19 20 void setNormalTexture(Texture3D *n )20 void setNormalTexture(Texture3D *normal) 21 21 { 22 _normal = n ;22 _normal = normal; 23 23 } 24 24 25 virtual void bind() 26 { 27 setParameters(); 25 virtual void bind(); 28 26 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(); 42 28 43 29 private: 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; 53 32 Texture3D *_normal; 54 33 }; -
branches/blt4/packages/vizservers/nanovis/R2/src/R2Fonts.cpp
r2936 r2966 73 73 R2Fonts::begin() 74 74 { 75 glPushAttrib(GL_TRANSFORM_BIT | GL_ENABLE_BIT); 75 76 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 79 79 glMatrixMode(GL_PROJECTION); 80 80 glPushMatrix(); 81 82 glLoadIdentity( ); 81 glLoadIdentity(); 82 83 83 gluOrtho2D(0.0f, _screenWidth, _screenHeight, 0.0f); 84 84 85 85 glMatrixMode(GL_MODELVIEW); 86 glPushMatrix( ); 87 glLoadIdentity( ); 88 89 glEnable(GL_TEXTURE_2D); 86 glPushMatrix(); 87 glLoadIdentity(); 88 90 89 glEnable(GL_BLEND); 91 90 glDisable(GL_DEPTH_TEST); … … 98 97 99 98 glMatrixMode(GL_PROJECTION); 100 glPopMatrix( 99 glPopMatrix(); 101 100 102 101 glMatrixMode(GL_MODELVIEW); 103 glPopMatrix( 104 105 glPopAttrib( 102 glPopMatrix(); 103 104 glPopAttrib(); 106 105 } 107 106 … … 229 228 } 230 229 231 fsInput.close( 230 fsInput.close(); 232 231 } 233 232 delete [] path; -
branches/blt4/packages/vizservers/nanovis/RenderVertexArray.cpp
r2936 r2966 51 51 switch (_type) { 52 52 case GL_HALF_FLOAT_NV: 53 _bytesPerComponent = 2; break; 53 _bytesPerComponent = 2; 54 break; 54 55 case GL_FLOAT: 55 _bytesPerComponent = sizeof(float); break; 56 _bytesPerComponent = sizeof(float); 57 break; 56 58 default: 57 59 ERROR("unsupported RenderVertexArray type\n"); … … 70 72 switch(_size) { 71 73 case 1: 72 _format = GL_LUMINANCE; break; 74 _format = GL_LUMINANCE; 75 break; 73 76 case 3: 74 _format = GL_RGB; break; 77 _format = GL_RGB; 78 break; 75 79 case 4: 76 _format = GL_RGBA; break; 80 _format = GL_RGBA; 81 break; 77 82 default: 78 83 ERROR("unsupported RenderVertexArray size\n"); -
branches/blt4/packages/vizservers/nanovis/Unirect.cpp
r2936 r2966 734 734 } 735 735 } 736 TRACE(" GetVectorRange%g %g\n", _magMin, _magMax);736 TRACE("getVectorRange: %g %g\n", _magMin, _magMax); 737 737 } 738 738 -
branches/blt4/packages/vizservers/nanovis/VelocityArrowsSlice.h
r2936 r2966 84 84 85 85 private: 86 void createRenderTarget(); 87 88 void computeSamplingTicks(); 89 86 90 unsigned int _vectorFieldGraphicsID; 87 91 float _vfXscale; … … 134 138 135 139 RenderMode _renderMode; 136 137 void createRenderTarget();138 139 void computeSamplingTicks();140 140 }; 141 141 -
branches/blt4/packages/vizservers/nanovis/VolumeInterpolator.cpp
r2936 r2966 18 18 _numBytes(0), 19 19 _dataCount(0), 20 _numComponents(0), 21 _referenceOfVolume(0) 20 _numComponents(0) 22 21 { 23 22 } … … 133 132 _numComponents = refPtr->numComponents(); 134 133 _numBytes = _dataCount * _numComponents * sizeof(float); 135 134 Vector3 loc = refPtr->location(); 136 135 _volume = new Volume(loc.x, loc.y, loc.z, 137 136 refPtr->width, refPtr->height, refPtr->depth, … … 141 140 refPtr->wAxis.min(), 142 141 refPtr->wAxis.max(), 143 refPtr->nonZeroMin()); 144 /* 145 _referenceOfVolume = refPtr->dataID(); 146 */ 142 refPtr->nonZeroMin()); 147 143 _volume->numSlices(256-1); 148 144 _volume->disableCutplane(0); … … 156 152 _volume->isosurface(0); 157 153 TRACE("VOL : location %f %f %f\n\tid : %s\n", loc.x, loc.y, loc.z, 158 154 refPtr->name()); 159 155 } 160 156 _volumes.push_back(_volume); -
branches/blt4/packages/vizservers/nanovis/VolumeInterpolator.h
r2936 r2966 30 30 double getStartTime() const; 31 31 32 unsigned int getReferenceVolumeID() const;33 34 32 Volume *getVolume(); 35 33 … … 44 42 unsigned int _dataCount; 45 43 unsigned int _numComponents; 46 unsigned int _referenceOfVolume;47 44 double _startTime; 48 45 }; … … 63 60 } 64 61 65 inline unsigned int VolumeInterpolator::getReferenceVolumeID() const66 {67 return _referenceOfVolume;68 }69 70 62 #endif 71 63 -
branches/blt4/packages/vizservers/nanovis/VolumeRenderer.h
r2936 r2966 146 146 147 147 //standard vertex shader parameters 148 CGprogram _vertStdVprog;149 148 CGparameter _mvpVertStdParam; 150 149 CGparameter _mviVertStdParam; -
branches/blt4/packages/vizservers/nanovis/dxReader.cpp
r2936 r2966 116 116 // save corners of bounding box first, to work around meshing 117 117 // 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 126 137 for (int i = 0; i < nxy; i++) { 127 138 ftmp << xymesh.atNode(i).x() << " " << xymesh.atNode(i).y() << std::endl; … … 137 148 ftri.getline(line,sizeof(line)-1); 138 149 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); 142 157 } 143 158 } … … 198 213 } 199 214 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; 202 221 203 222 // read data points … … 207 226 } 208 227 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; 212 232 if (isrect) { 213 233 #if ISO_TEST 214 float *data = new float[nx * ny * nz * 4];234 data = new float[nx * ny * nz * 4]; 215 235 memset(data, 0, nx*ny*nz*4); 216 double vmin = DBL_MAX;217 double nzero_min = DBL_MAX;218 double vmax = -DBL_MAX;219 236 #else // !ISO_TEST 220 237 Rappture::Mesh1D xgrid(x0, x0 + lx, nx); … … 279 296 #if ISO_TEST 280 297 double dv = vmax - vmin; 281 int count = nx*ny*nz;282 int ngen = 0;283 double v;284 298 if (dv == 0.0) { 285 299 dv = 1.0; 286 300 } 287 301 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]; 290 306 // scale all values [0-1], -1 => out of bounds 291 307 v = (isnan(v)) ? -1.0 : (v - vmin)/dv; 292 308 293 309 data[ngen] = v; 294 ngen += 4;310 ngen += step; 295 311 } 296 312 … … 317 333 dz = lz /(double)(nz - 1); 318 334 319 double vmin = field.valueMin(); 320 double vmax = field.valueMax(); 335 vmin = field.valueMin(); 336 vmax = field.valueMax(); 337 nzero_min = DBL_MAX; 321 338 double dv = vmax - vmin; 322 339 if (dv == 0.0) { 323 340 dv = 1.0; 324 341 } 325 double nzero_min = DBL_MAX; 342 326 343 int ngen = 0; 327 344 #if FILTER_GRADIENTS … … 334 351 // to be filled in by computeSimpleGradient() 335 352 const int step = 4; 336 float *data = new float[nx*ny*nz * step];353 data = new float[nx*ny*nz * step]; 337 354 #endif // FILTER_GRADIENTS 338 355 … … 368 385 // computeGradient returns a new array with gradients 369 386 // filled in, so data is now 4 floats per node 370 float *data = computeGradient(cdata, nx, ny, nz,371 372 387 data = computeGradient(cdata, nx, ny, nz, 388 dx, dy, dz, 389 vmin, vmax); 373 390 delete [] cdata; 374 391 #else // !FILTER_GRADIENTS … … 378 395 379 396 #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 #endif402 delete [] data;403 397 } else { 404 398 Rappture::Mesh1D zgrid(z0, z0 + (nz-1)*dz, nz); … … 434 428 } 435 429 436 // figure out a good mesh spacing437 int nsample = 30;438 430 x0 = field.rangeMin(Rappture::xaxis); 439 431 lx = field.rangeMax(Rappture::xaxis) - field.rangeMin(Rappture::xaxis); … … 442 434 z0 = field.rangeMin(Rappture::zaxis); 443 435 lz = field.rangeMax(Rappture::zaxis) - field.rangeMin(Rappture::zaxis); 436 437 // figure out a good mesh spacing 438 int nsample = 30; 444 439 double dmin = pow((lx*ly*lz)/((nsample-1)*(nsample-1)*(nsample-1)), 0.333); 445 440 … … 458 453 dz = lz /(double)(nz - 1); 459 454 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; 464 458 double dv = vmax - vmin; 465 459 if (dv == 0.0) { … … 467 461 } 468 462 463 data = new float[4*nx*ny*nz]; 469 464 // generate the uniformly sampled data that we need for a volume 470 465 int ngen = 0; 471 double nzero_min = DBL_MAX;472 466 for (int iz = 0; iz < nz; iz++) { 473 467 double zval = z0 + iz*dz; … … 492 486 computeSimpleGradient(data, nx, ny, nz, 493 487 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.. 506 505 #if 0 && defined(USE_POINTSET_RENDERER) 507 508 509 510 511 512 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; 513 512 #endif 514 delete [] data; 515 } 513 delete [] data; 516 514 517 515 // -
branches/blt4/packages/vizservers/nanovis/imgLoaders/BMPImageLoaderImpl.cpp
r2936 r2966 77 77 } 78 78 } 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); 80 80 if (fread(buff, width*height*3, 1, f) != 1) { 81 81 ERROR("can't read BMP image data\n"); … … 83 83 for (x = 0, y = 0; x < width*height*3; x += 3, y += 4) { //except the format is BGR, grr 84 84 bytes[y] = buff[x+2]; 85 bytes[y+1] = buff[x+1]; 85 86 bytes[y+2] = buff[x]; 86 87 bytes[y+3] = 255; … … 101 102 } 102 103 } 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); 104 105 if (fread(buff, width*height*4, 1, f) != 1) { 105 106 ERROR("can't read BMP image data\n"); … … 107 108 for (x = 0, y = 0; x < width*height*4; x += 4, y += 3) { //except the format is BGR, grr 108 109 bytes[y] = buff[x+2]; 110 bytes[y+1] = buff[x+1]; 109 111 bytes[y+2] = buff[x]; 110 112 } … … 125 127 for (int c = 0; c < 3; ++c) { 126 128 //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 128 130 } 129 } 131 if (_targetImageFormat == Image::IMG_RGBA) { 132 bytes[(y*width+x)*_targetImageFormat + 3] = 255; 133 } 134 } 130 135 } 131 136 break; -
branches/blt4/packages/vizservers/nanovis/nanovis.cpp
r2936 r2966 133 133 Texture2D *NanoVis::legendTexture = NULL; 134 134 NvColorTableRenderer *NanoVis::colorTableRenderer = NULL; 135 135 #ifdef notdef 136 136 NvFlowVisRenderer *NanoVis::flowVisRenderer = NULL; 137 #endif 137 138 VelocityArrowsSlice *NanoVis::velocityArrowsSlice = NULL; 138 139 … … 149 150 150 151 Tcl_Interp *NanoVis::interp; 151 Tcl_DString NanoVis::cmdbuffer;152 152 153 153 //frame buffer for final rendering … … 173 173 float NanoVis::wMin = FLT_MAX; 174 174 float NanoVis::wMax = -FLT_MAX; 175 float NanoVis::xOrigin;176 float NanoVis::yOrigin;177 float NanoVis::zOrigin;178 175 179 176 /* FIXME: This variable is always true. */ … … 236 233 // Image based flow visualization slice location 237 234 // FLOW 238 float NanoVis::_licSliceX = 0.5f; 239 float NanoVis::_licSliceY = 0.5f; 240 float NanoVis::_licSliceZ = 0.5f; 235 float NanoVis::_licSlice = 0.5f; 241 236 int NanoVis::_licAxis = 2; // z axis 242 237 243 staticvoid244 removeAllData()238 void 239 NanoVis::removeAllData() 245 240 { 246 241 // … … 364 359 doExit(int code) 365 360 { 366 TRACE("in doExit \n");367 removeAllData();361 TRACE("in doExit: %d\n", code); 362 NanoVis::removeAllData(); 368 363 369 364 NvShader::exitCg(); … … 515 510 int 516 511 NanoVis::renderLegend(TransferFunction *tf, double min, double max, 517 int width, int height, const char *volArg)512 int width, int height, const char *volArg) 518 513 { 519 514 TRACE("in renderLegend\n"); … … 546 541 ssize_t nWritten; 547 542 548 TRACE(" ppm legend image");543 TRACE("Sending ppm legend image %s min:%g max:%g", volArg, min, max); 549 544 sprintf(prefix, "nv>legend %s %g %g", volArg, min, max); 550 545 ppmWrite(prefix); … … 555 550 resizeOffscreenBuffer(old_width, old_height); 556 551 552 delete legendTexture; 553 legendTexture = NULL; 557 554 TRACE("leaving renderLegend\n"); 558 delete legendTexture;559 555 return TCL_OK; 560 556 } … … 710 706 #endif 711 707 712 void NanoVis::initParticle()713 {714 flowVisRenderer->initialize();715 licRenderer->makePatterns();716 }717 718 708 static 719 709 void cgErrorCallback(void) … … 798 788 colorTableRenderer = new NvColorTableRenderer(); 799 789 colorTableRenderer->setFonts(fonts); 800 790 #ifdef notdef 801 791 flowVisRenderer = new NvFlowVisRenderer(NMESH, NMESH); 802 792 #endif 803 793 velocityArrowsSlice = new VelocityArrowsSlice; 804 794 805 licRenderer = new NvLIC(NMESH, NPIX, NPIX, _licAxis, 806 Vector3(_licSliceX, _licSliceY, _licSliceZ)); 795 licRenderer = new NvLIC(NMESH, NPIX, NPIX, _licAxis, _licSlice); 807 796 808 797 grid = new Grid(); … … 1343 1332 #endif 1344 1333 1345 staticvoid1346 draw3dAxis()1334 void 1335 NanoVis::draw3dAxis() 1347 1336 { 1348 1337 glPushAttrib(GL_ENABLE_BIT); … … 1761 1750 1762 1751 #ifdef notdef 1752 void NanoVis::initParticle() 1753 { 1754 flowVisRenderer->initialize(); 1755 licRenderer->makePatterns(); 1756 } 1757 1763 1758 static 1764 1759 void addVectorField(const char* filename, const char* vf_name, … … 2117 2112 2118 2113 // Read and execute as many commands as we can from stdin... 2119 2114 Tcl_DString cmdbuffer; 2115 Tcl_DStringInit(&cmdbuffer); 2120 2116 int nCommands = 0; 2121 2117 bool isComplete = false; … … 2373 2369 NvInitEventLog(); 2374 2370 #endif 2375 Tcl_DStringInit(&NanoVis::cmdbuffer);2376 2371 NanoVis::interp = initTcl(); 2377 2372 NanoVis::resizeOffscreenBuffer(NanoVis::winWidth, NanoVis::winHeight); -
branches/blt4/packages/vizservers/nanovis/nanovis.h
r2936 r2966 79 79 static void displayOffscreenBuffer(); 80 80 static void display(); 81 static void draw3dAxis(); 81 82 static void idle(); 82 83 static void update(); 84 static void removeAllData(); 83 85 84 86 static void pan(float dx, float dy); … … 89 91 static void setVolumeRanges(); 90 92 static void setHeightmapRanges(); 91 93 #ifdef notdef 92 94 static void initParticle(); 93 95 #endif 94 96 static void ppmWrite(const char *prefix); 95 97 static void sendDataToClient(const char *command, const char *data, … … 155 157 static int renderWindow; 156 158 static unsigned char *screenBuffer; 159 static Texture2D *legendTexture; 157 160 static Grid *grid; 158 161 static R2Fonts *fonts; … … 161 164 static graphics::RenderContext *renderContext; 162 165 166 static Tcl_HashTable tfTable; 163 167 static Tcl_HashTable volumeTable; 164 165 static std::vector<NvVectorField *> flow;166 168 static Tcl_HashTable flowTable; 169 static Tcl_HashTable heightmapTable; 170 167 171 static double magMin, magMax; 168 172 static float xMin, xMax, yMin, yMax, zMin, zMax, wMin, wMax; 169 static float xOrigin, yOrigin, zOrigin; 170 173 174 static NvColorTableRenderer *colorTableRenderer; 171 175 static VolumeRenderer *volRenderer; 176 #ifdef notdef 172 177 static NvFlowVisRenderer *flowVisRenderer; 178 #endif 173 179 static VelocityArrowsSlice *velocityArrowsSlice; 174 180 static NvLIC *licRenderer; … … 183 189 #endif 184 190 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 192 191 static Tcl_Interp *interp; 193 static Tcl_DString cmdbuffer;194 192 195 193 private: 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 200 196 201 197 //frame buffer for final rendering -
branches/blt4/packages/vizservers/nanovis/protocol-nanovis.txt
r2936 r2966 186 186 (followed by bytes) 187 187 188 nv>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 188 192 ================================================================================ 189 193 Error Replies: -
branches/blt4/packages/vizservers/nanovis/shaders/update_pos.cg
r2936 r2966 49 49 50 50 //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; 53 53 //vel *= float4(scale, 1); 54 54 ret = pos + (vel * timestep);
Note: See TracChangeset
for help on using the changeset viewer.