Changeset 1850
- Timestamp:
- Jul 30, 2010, 8:34:57 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/configure
r1844 r1850 9490 9490 9491 9491 9492 ac_config_files="$ac_config_files Makefile packages/Makefile src/Makefile src/core/Makefile src/core2/Makefile src/objects/Makefile src/objects/RpHash.h gui/Makefile gui/apps/Makefile gui/apps/about gui/apps/encodedata gui/apps/rappture gui/apps/rappture-csh.env gui/apps/rappture.env gui/apps/rappture.use gui/apps/rerun gui/apps/simsim gui/apps/xmldiff gui/pkgIndex.tcl gui/scripts/Makefile instant/Makefile instant/irappture lang/Makefile lang/java/Makefile lang/java/rappture/Makefile lang/perl/Makefile lang/perl/Makefile.PL lang/python/Makefile lang/python/setup.py lang/matlab/Makefile lang/octave/Makefile lang/octave/octave2/Makefile lang/octave/octave3/Makefile lang/ruby/Makefile lang/ruby/build.rb lang/tcl/Makefile lang/tcl/pkgIndex.tcl lang/tcl/src/Makefile lang/tcl/scripts/Makefile lang/tcl/tests/Makefile lib/Makefile examples/3D/Makefile examples/Makefile examples/app-fermi/2.0/Makefile examples/app-fermi/Makefile examples/app-fermi/cee/Makefile examples/app-fermi/fortran/Makefile examples/app-fermi/java/Makefile examples/app-fermi/matlab/Makefile examples/app-fermi/matlab/compiled/Makefile examples/app-fermi/matlab/uncompiled/Makefile examples/app-fermi/octave/Makefile examples/app-fermi/octave/2/Makefile examples/app-fermi/octave/3/Makefile examples/app-fermi/perl/Makefile examples/app-fermi/python/Makefile examples/app-fermi/ruby/Makefile examples/app-fermi/tcl/Makefile examples/app-fermi/wrapper/Makefile examples/app-fermi/wrapper/cee/Makefile examples/app-fermi/wrapper/p ython/Makefile examples/app-fermi/wrapper/tcl/Makefile examples/c-example/Makefile examples/canvas/Makefile examples/demo.bash examples/flow/Makefile examples/flow/demo1/Makefile examples/flow/demo2/Makefile examples/flow/demo3/Makefile examples/graph/Makefile examples/objects/Makefile examples/objects/axis/Makefile examples/objects/contour/Makefile examples/objects/curve/Makefile examples/objects/dxWriter/Makefile examples/objects/floatBuffer/Makefile examples/objects/histogram/Makefile examples/objects/library/Makefile examples/objects/number/Makefile examples/objects/path/Makefile examples/objects/plot/Makefile examples/objects/scatter/Makefile examples/objects/string/Makefile examples/objects/tree/Makefile examples/objects/xmlparser/Makefile examples/zoo/Makefile examples/zoo/binary/Makefile examples/zoo/boolean/Makefile examples/zoo/choice/Makefile examples/zoo/cloud/Makefile examples/zoo/cloud/matlab/Makefile examples/zoo/curve/Makefile examples/zoo/enable/Makefile examples/zoo/field/Makefile examples/zoo/group/Makefile examples/zoo/image/Makefile examples/zoo/image/docs/Makefile examples/zoo/image/examples/Makefile examples/zoo/integer/Makefile examples/zoo/integer2/Makefile examples/zoo/loader/Makefile examples/zoo/loader/examples/Makefile examples/zoo/loadrun/Makefile examples/zoo/log/Makefile examples/zoo/note/Makefile examples/zoo/note/docs/Makefile examples/zoo/number/Makefile examples/zoo/number2/Makefile examples/zoo/periodicelement/Makefile examples/zoo/phase/Makefile examples/zoo/sequence/Makefile examples/zoo/sequence/examples/Makefile examples/zoo/string/Makefile examples/zoo/structure/Makefile examples/zoo/structure/examples/Makefile examples/zoo/table/Makefile examples/zoo/unirect2d/Makefile test/Makefile test/src/Makefile"9492 ac_config_files="$ac_config_files Makefile packages/Makefile src/Makefile src/core/Makefile src/core2/Makefile src/objects/Makefile src/objects/RpHash.h gui/Makefile gui/apps/Makefile gui/apps/about gui/apps/encodedata gui/apps/rappture gui/apps/rappture-csh.env gui/apps/rappture.env gui/apps/rappture.use gui/apps/rerun gui/apps/simsim gui/apps/xmldiff gui/pkgIndex.tcl gui/scripts/Makefile instant/Makefile instant/irappture lang/Makefile lang/java/Makefile lang/java/rappture/Makefile lang/perl/Makefile lang/perl/Makefile.PL lang/python/Makefile lang/python/setup.py lang/matlab/Makefile lang/octave/Makefile lang/octave/octave2/Makefile lang/octave/octave3/Makefile lang/ruby/Makefile lang/ruby/build.rb lang/tcl/Makefile lang/tcl/pkgIndex.tcl lang/tcl/src/Makefile lang/tcl/scripts/Makefile lang/tcl/tests/Makefile lib/Makefile examples/3D/Makefile examples/Makefile examples/app-fermi/2.0/Makefile examples/app-fermi/Makefile examples/app-fermi/cee/Makefile examples/app-fermi/fortran/Makefile examples/app-fermi/java/Makefile examples/app-fermi/matlab/Makefile examples/app-fermi/matlab/compiled/Makefile examples/app-fermi/matlab/uncompiled/Makefile examples/app-fermi/octave/Makefile examples/app-fermi/octave/2/Makefile examples/app-fermi/octave/3/Makefile examples/app-fermi/perl/Makefile examples/app-fermi/python/Makefile examples/app-fermi/ruby/Makefile examples/app-fermi/tcl/Makefile examples/app-fermi/wrapper/Makefile examples/app-fermi/wrapper/cee/Makefile examples/app-fermi/wrapper/perl/Makefile examples/app-fermi/wrapper/python/Makefile examples/app-fermi/wrapper/tcl/Makefile examples/c-example/Makefile examples/canvas/Makefile examples/demo.bash examples/flow/Makefile examples/flow/demo1/Makefile examples/flow/demo2/Makefile examples/flow/demo3/Makefile examples/graph/Makefile examples/objects/Makefile examples/objects/axis/Makefile examples/objects/contour/Makefile examples/objects/curve/Makefile examples/objects/dxWriter/Makefile examples/objects/floatBuffer/Makefile examples/objects/histogram/Makefile examples/objects/library/Makefile examples/objects/number/Makefile examples/objects/path/Makefile examples/objects/plot/Makefile examples/objects/scatter/Makefile examples/objects/string/Makefile examples/objects/tree/Makefile examples/objects/xmlparser/Makefile examples/zoo/Makefile examples/zoo/binary/Makefile examples/zoo/boolean/Makefile examples/zoo/choice/Makefile examples/zoo/cloud/Makefile examples/zoo/cloud/matlab/Makefile examples/zoo/curve/Makefile examples/zoo/enable/Makefile examples/zoo/field/Makefile examples/zoo/group/Makefile examples/zoo/image/Makefile examples/zoo/image/docs/Makefile examples/zoo/image/examples/Makefile examples/zoo/integer/Makefile examples/zoo/integer2/Makefile examples/zoo/loader/Makefile examples/zoo/loader/examples/Makefile examples/zoo/loadrun/Makefile examples/zoo/log/Makefile examples/zoo/note/Makefile examples/zoo/note/docs/Makefile examples/zoo/number/Makefile examples/zoo/number2/Makefile examples/zoo/periodicelement/Makefile examples/zoo/phase/Makefile examples/zoo/sequence/Makefile examples/zoo/sequence/examples/Makefile examples/zoo/string/Makefile examples/zoo/structure/Makefile examples/zoo/structure/examples/Makefile examples/zoo/table/Makefile examples/zoo/unirect2d/Makefile test/Makefile test/src/Makefile" 9493 9493 9494 9494 cat >confcache <<\_ACEOF … … 10239 10239 "examples/app-fermi/wrapper/Makefile") CONFIG_FILES="$CONFIG_FILES examples/app-fermi/wrapper/Makefile" ;; 10240 10240 "examples/app-fermi/wrapper/cee/Makefile") CONFIG_FILES="$CONFIG_FILES examples/app-fermi/wrapper/cee/Makefile" ;; 10241 "examples/app-fermi/wrapper/perl/Makefile") CONFIG_FILES="$CONFIG_FILES examples/app-fermi/wrapper/perl/Makefile" ;; 10241 10242 "examples/app-fermi/wrapper/python/Makefile") CONFIG_FILES="$CONFIG_FILES examples/app-fermi/wrapper/python/Makefile" ;; 10242 10243 "examples/app-fermi/wrapper/tcl/Makefile") CONFIG_FILES="$CONFIG_FILES examples/app-fermi/wrapper/tcl/Makefile" ;; -
trunk/configure.in
r1844 r1850 722 722 examples/app-fermi/wrapper/Makefile 723 723 examples/app-fermi/wrapper/cee/Makefile 724 examples/app-fermi/wrapper/perl/Makefile 724 725 examples/app-fermi/wrapper/python/Makefile 725 726 examples/app-fermi/wrapper/tcl/Makefile -
trunk/examples/app-fermi/wrapper/Makefile.in
r1018 r1850 1 1 2 2 bindir = @bindir@ 3 datadir 4 datarootdir 3 datadir = @datadir@ 4 datarootdir = @datarootdir@ 5 5 exec_prefix = @exec_prefix@ 6 6 includedir = @includedir@ … … 8 8 mandir = @mandir@ 9 9 prefix = @prefix@ 10 srcdir 10 srcdir = @srcdir@ 11 11 12 INSTALL 13 VPATH 14 SHELL 15 RM 12 INSTALL = @INSTALL@ 13 VPATH = $(srcdir) 14 SHELL = @SHELL@ 15 RM = rm -f 16 16 17 .PHONY: cee python tcl 17 .PHONY: cee python tcl perl 18 18 19 all: python tcl cee 19 all: python tcl cee perl 20 20 21 21 cee: 22 22 $(MAKE) -C cee all 23 python: 23 perl: 24 $(MAKE) -C perl all 25 python: 24 26 $(MAKE) -C python all 25 tcl: 27 tcl: 26 28 $(MAKE) -C tcl all 29 27 30 28 31 install: 29 32 $(MAKE) -C cee install 33 $(MAKE) -C perl install 30 34 $(MAKE) -C python install 31 35 $(MAKE) -C tcl install … … 33 37 clean: 34 38 $(MAKE) -C cee clean 39 $(MAKE) -C perl clean 35 40 $(MAKE) -C python clean 36 41 $(MAKE) -C tcl clean 37 42 38 distclean: 43 distclean: 39 44 $(MAKE) -C cee distclean 45 $(MAKE) -C perl distclean 40 46 $(MAKE) -C python distclean 41 47 $(MAKE) -C tcl distclean -
trunk/gui/scripts/editor.tcl
r1342 r1850 58 58 protected variable _loc ;# array of editor location parameters 59 59 } 60 60 61 61 itk::usual Editor { 62 62 keep -cursor -font … … 74 74 75 75 itk_component add editor { 76 76 entry $itk_interior.editor -highlightthickness 0 77 77 } { 78 79 80 81 82 78 usual 79 keep -relief 80 ignore -highlightthickness 81 ignore -highlightcolor 82 ignore -highlightbackground 83 83 } 84 84 pack $itk_component(editor) -expand yes -fill both 85 85 86 86 bind $itk_component(editor) <KeyPress> \ 87 87 [itcl::code $this _resize] 88 88 bind $itk_component(editor) <KeyPress-Return> \ 89 89 [itcl::code $this deactivate] 90 90 bind $itk_component(editor) <KeyPress-Escape> \ 91 91 [itcl::code $this deactivate -abort] 92 92 bind $itk_component(editor) <ButtonPress> \ 93 93 [itcl::code $this _click %X %Y] 94 94 95 95 itk_component add emenu { 96 96 menu $itk_component(editor).menu -tearoff 0 97 97 } { 98 99 100 98 usual 99 ignore -tearoff 100 ignore -background -foreground 101 101 } 102 102 $itk_component(emenu) add command -label "Cut" -accelerator "^X" \ 103 103 -command [list event generate $itk_component(editor) <<Cut>>] 104 104 $itk_component(emenu) add command -label "Copy" -accelerator "^C" \ 105 105 -command [list event generate $itk_component(editor) <<Copy>>] 106 106 $itk_component(emenu) add command -label "Paste" -accelerator "^V" \ 107 107 -command [list event generate $itk_component(editor) <<Paste>>] 108 108 bind $itk_component(editor) <<PopupMenu>> { 109 109 tk_popup %W.menu %X %Y 110 110 } 111 111 … … 124 124 set e $itk_component(editor) 125 125 if {[winfo ismapped $e]} { 126 126 return ;# already mapped -- nothing to do 127 127 } 128 128 129 129 set info "" 130 130 if {[string length $itk_option(-activatecommand)] > 0} { 131 132 133 134 135 131 set status [catch {uplevel #0 $itk_option(-activatecommand)} info] 132 if {$status != 0} { 133 bgerror $info 134 return 135 } 136 136 } 137 137 … … 145 145 array set vals $info 146 146 if {![info exists vals(x)] || ![info exists vals(y)]} { 147 147 return 148 148 } 149 149 set _loc(x) $vals(x) … … 154 154 $itk_component(editor) delete 0 end 155 155 if {[info exists vals(text)]} { 156 156 $itk_component(editor) insert end $vals(text) 157 157 } 158 158 $itk_component(editor) select from 0 … … 167 167 update 168 168 while {[catch {grab set -global $itk_component(editor)}]} { 169 169 after 100 170 170 } 171 171 } … … 188 188 189 189 if {$args == "-abort"} { 190 191 192 190 grab release $itk_component(editor) 191 wm withdraw $itk_component(hull) 192 return 193 193 } 194 194 … … 200 200 # 201 201 if {[string length $itk_option(-validatecommand)] > 0} { 202 203 204 205 206 207 208 209 210 211 212 213 214 202 set cmd "uplevel #0 [list $itk_option(-validatecommand) [list $str]]" 203 if {[catch $cmd result]} { 204 bgerror $result 205 set result 1 206 } 207 if {$result == 0} { 208 bell 209 $itk_component(editor) select from 0 210 $itk_component(editor) select to end 211 $itk_component(editor) icursor end 212 focus $itk_component(editor) 213 return 214 } 215 215 } 216 216 … … 223 223 # 224 224 if {[string length $itk_option(-applycommand)] > 0} { 225 226 227 228 229 225 set cmd "uplevel #0 [list $itk_option(-applycommand) [list $str]]" 226 if {[catch $cmd result]} { 227 bgerror $result 228 return 229 } 230 230 } 231 231 } … … 255 255 itcl::body Rappture::Editor::_click {x y} { 256 256 if {[winfo containing $x $y] != $itk_component(editor)} { 257 257 deactivate 258 258 } else { 259 260 261 259 # make sure the editor has keyboard focus! 260 # it loses focus sometimes during cut/copy/paste operations 261 focus -force $itk_component(editor) 262 262 } 263 263 } … … 278 278 set w [expr {($w < $_loc(w)) ? $_loc(w) : $w}] 279 279 if {$w+$_loc(x) >= [winfo screenwidth $e]} { 280 280 set w [expr {[winfo screenwidth $e]-$_loc(x)}] 281 281 } 282 282 … … 284 284 set h [expr {($h < $_loc(h)) ? $_loc(h) : $h}] 285 285 if {$h+$_loc(y) >= [winfo screenheight $e]} { 286 287 } 286 set h [expr {[winfo screenheight $e]-$_loc(y)}] 287 } 288 288 # Temporary fix to prevent Opps. Don't deal with negative dimensions. 289 289 if { $w <= 0 || $h <= 0 } { 290 290 wm geometry $itk_component(hull) "+$_loc(x)+$_loc(y)" 291 291 } else { 292 292 wm geometry $itk_component(hull) "${w}x${h}+$_loc(x)+$_loc(y)" 293 293 } 294 294 } -
trunk/gui/scripts/gauge.tcl
r1483 r1850 55 55 56 56 blt::bitmap define GaugeArrow-up { 57 58 59 60 57 #define up_width 8 58 #define up_height 4 59 static unsigned char up_bits[] = { 60 0x10, 0x38, 0x7c, 0xfe}; 61 61 } 62 62 blt::bitmap define GaugeArrow-down { 63 64 65 66 63 #define arrow_width 8 64 #define arrow_height 4 65 static unsigned char arrow_bits[] = { 66 0xfe, 0x7c, 0x38, 0x10}; 67 67 } 68 68 69 69 blt::bitmap define GaugeArrow { 70 71 72 73 74 } 75 } 76 70 #define arrow_width 9 71 #define arrow_height 4 72 static unsigned char arrow_bits[] = { 73 0x7f, 0x00, 0x3e, 0x00, 0x1c, 0x00, 0x08, 0x00}; 74 } 75 } 76 77 77 itk::usual Gauge { 78 78 keep -cursor -font -foreground -background … … 85 85 itcl::body Rappture::Gauge::constructor {args} { 86 86 itk_component add icon { 87 88 87 canvas $itk_interior.icon -width 1 -height 1 \ 88 -borderwidth 0 -highlightthickness 0 89 89 } { 90 91 90 usual 91 ignore -highlightthickness -highlightbackground -highlightcolor 92 92 } 93 93 pack $itk_component(icon) -side left … … 95 95 96 96 itk_component add -protected vframe { 97 97 frame $itk_interior.vframe 98 98 } 99 99 100 100 itk_component add value { 101 102 101 label $itk_component(vframe).value -borderwidth 1 -width 7 \ 102 -textvariable [itcl::scope _value] 103 103 } { 104 104 rename -background -textbackground textBackground Background 105 105 } 106 106 pack $itk_component(value) -side left -expand yes -fill both … … 114 114 115 115 itk_component add emenu { 116 116 menu $itk_component(value).menu -tearoff 0 117 117 } { 118 119 118 usual 119 ignore -tearoff 120 120 } 121 121 $itk_component(emenu) add command -label "Cut" -accelerator "^X" \ 122 122 -command [list event generate $itk_component(value) <<Cut>>] 123 123 $itk_component(emenu) add command -label "Copy" -accelerator "^C" \ 124 124 -command [list event generate $itk_component(value) <<Copy>>] 125 125 $itk_component(emenu) add command -label "Paste" -accelerator "^V" \ 126 126 -command [list event generate $itk_component(value) <<Paste>>] 127 127 bind $itk_component(value) <<PopupMenu>> \ 128 128 [itcl::code $this _editor menu %X %Y] 129 129 130 130 itk_component add editor { 131 132 133 134 131 Rappture::Editor $itk_interior.editor \ 132 -activatecommand [itcl::code $this _editor activate] \ 133 -validatecommand [itcl::code $this _editor validate] \ 134 -applycommand [itcl::code $this _editor apply] 135 135 } 136 136 bind $itk_component(value) <ButtonPress> \ 137 137 [itcl::code $this _editor popup] 138 138 139 139 140 140 itk_component add spinner { 141 141 frame $itk_component(vframe).spinner 142 142 } 143 143 144 144 itk_component add spinup { 145 146 147 145 button $itk_component(spinner).up -bitmap GaugeArrow-up \ 146 -borderwidth 1 -relief raised -highlightthickness 0 \ 147 -command [itcl::code $this bump 1] 148 148 } { 149 150 149 usual 150 ignore -borderwidth -highlightthickness 151 151 } 152 152 pack $itk_component(spinup) -side top -expand yes -fill both 153 153 154 154 itk_component add spindn { 155 156 157 155 button $itk_component(spinner).down -bitmap GaugeArrow-down \ 156 -borderwidth 1 -relief raised -highlightthickness 0 \ 157 -command [itcl::code $this bump -1] 158 158 } { 159 160 159 usual 160 ignore -borderwidth -highlightthickness 161 161 } 162 162 pack $itk_component(spindn) -side bottom -expand yes -fill both … … 164 164 165 165 itk_component add presets { 166 167 166 button $itk_component(vframe).psbtn -bitmap GaugeArrow \ 167 -borderwidth 1 -highlightthickness 0 -relief flat 168 168 } { 169 170 171 169 usual 170 ignore -borderwidth -relief -highlightthickness 171 rename -background -textbackground textBackground Background 172 172 } 173 173 … … 176 176 177 177 itk_component add presetlist { 178 179 180 178 Rappture::Dropdownlist $itk_component(presets).plist \ 179 -postcommand [itcl::code $this _presets post] \ 180 -unpostcommand [itcl::code $this _presets unpost] \ 181 181 } 182 182 183 183 bind $itk_component(presetlist) <<DropdownlistSelect>> \ 184 184 [itcl::code $this _presets select] 185 185 186 186 $itk_component(presets) configure -command \ 187 187 [list $itk_component(presetlist) post $itk_component(vframe) left] 188 188 189 189 eval itk_initialize $args … … 203 203 set i [lsearch -exact $args -check] 204 204 if {$i >= 0} { 205 206 205 set onlycheck 1 206 set args [lreplace $args $i $i] 207 207 } 208 208 209 209 if {[llength $args] == 1} { 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 210 # 211 # If this gauge has -units, try to convert the incoming 212 # value to that system of units. Also, make sure that 213 # the value is bound by any min/max value constraints. 214 # 215 # Keep track of the inputted units so we can give a 216 # response about min and max values in familiar units. 217 # 218 set newval [set nv [lindex $args 0]] 219 set units $itk_option(-units) 220 if {"" != $units} { 221 set newval [Rappture::Units::convert $newval -context $units] 222 set nvUnits [Rappture::Units::Search::for $newval] 223 if { "" == $nvUnits} { 224 set msg [Rappture::Units::description $units] 225 error "Unrecognized units: $newval\nEnter value with units of $msg" 226 } 227 set nv [Rappture::Units::convert $nv \ 228 -context $units -to $units -units off] 229 230 # Normalize the units name 231 set newval [Rappture::Units::convert $newval -units off]$nvUnits 232 } 233 234 switch -- $itk_option(-type) { 235 integer { 236 if { [scan $nv "%g" value] != 1 || int($nv) != $value } { 237 error "bad value \"$nv\": should be an integer value" 238 } 239 } 240 real { 241 if {[string length $nv] <= 0 242 || ![string is double $nv] 243 || [regexp -nocase {^(inf|nan)$} $nv]} { 244 error "bad value \"$nv\": should be a real number" 245 } 246 } 247 } 248 249 if {"" != $itk_option(-minvalue)} { 250 set convMinVal [set minv $itk_option(-minvalue)] 251 if {"" != $units} { 252 set minv [Rappture::Units::convert $minv \ 253 -context $units -to $units -units off] 254 set convMinVal [Rappture::Units::convert \ 255 $itk_option(-minvalue) -context $units -to $nvUnits] 256 } else { 257 set newval [format "%g" $newval] 258 } 259 260 # fix for the case when the user tries to 261 # compare values like minv=-500 nv=-0600 262 set nv [format "%g" $nv] 263 set minv [format "%g" $minv] 264 265 if {$nv < $minv} { 266 error "minimum value allowed here is $convMinVal" 267 } 268 } 269 270 if {"" != $itk_option(-maxvalue)} { 271 set convMaxVal [set maxv $itk_option(-maxvalue)] 272 if {"" != $units} { 273 set maxv [Rappture::Units::convert $maxv \ 274 -context $units -to $units -units off] 275 set convMaxVal [Rappture::Units::convert \ 276 $itk_option(-maxvalue) -context $units -to $nvUnits] 277 } else { 278 set newval [format "%g" $newval] 279 } 280 281 # fix for the case when the user tries to 282 # compare values like maxv=500 nv=0600 283 set nv [format "%g" $nv] 284 set maxv [format "%g" $maxv] 285 286 if {$nv > $maxv} { 287 error "maximum value allowed here is $convMaxVal" 288 } 289 } 290 291 if {$onlycheck} { 292 return 293 } 294 295 set _value $newval 296 297 _redraw 298 event generate $itk_component(hull) <<Value>> 299 299 300 300 } elseif {[llength $args] != 0} { 301 301 error "wrong # args: should be \"value ?-check? ?newval?\"" 302 302 } 303 303 return $_value … … 315 315 itcl::body Rappture::Gauge::edit {option} { 316 316 if {$itk_option(-state) == "disabled"} { 317 317 return ;# disabled? then bail out here! 318 318 } 319 319 switch -- $option { 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 320 cut { 321 edit copy 322 _editor popup 323 $itk_component(editor) value "" 324 $itk_component(editor) deactivate 325 } 326 copy { 327 clipboard clear 328 clipboard append $_value 329 } 330 paste { 331 _editor popup 332 $itk_component(editor) value [clipboard get] 333 $itk_component(editor) deactivate 334 } 335 default { 336 error "bad option \"$option\": should be cut, copy, paste" 337 } 338 338 } 339 339 } … … 349 349 set val $_value 350 350 if {$val == ""} { 351 351 set val 0 352 352 } 353 353 if {[catch {value [expr {$val+$delta}]} result]} { 354 355 356 357 358 359 360 361 362 363 364 354 if {[regexp {allowed here is (.+)} $result match newval]} { 355 set _value $newval 356 $itk_component(value) configure -text $newval 357 } 358 if {[regexp {^bad.*: +(.)(.+)} $result match first tail] 359 || [regexp {(.)(.+)} $result match first tail]} { 360 set result "[string toupper $first]$tail" 361 } 362 bell 363 Rappture::Tooltip::cue $itk_component(value) $result 364 return 0 365 365 } 366 366 } … … 380 380 381 381 if {"" == [$c find all]} { 382 383 384 385 382 # first time around, create the items 383 $c create rectangle 0 0 1 1 -outline black -tags block 384 $c create image 0 0 -anchor center -image "" -tags bimage 385 $c create rectangle 0 0 1 1 -outline "" -fill "" -stipple gray50 -tags screen 386 386 } 387 387 388 388 if {"" != $itk_option(-spectrum)} { 389 389 set color [$itk_option(-spectrum) get $_value] 390 390 } else { 391 391 set color "" 392 392 } 393 393 … … 400 400 401 401 if {$itk_option(-state) == "disabled"} { 402 402 $c itemconfigure screen -fill white 403 403 } else { 404 404 $c itemconfigure screen -fill "" 405 405 } 406 406 } … … 417 417 418 418 if {"" != $itk_option(-image) || "" != $itk_option(-spectrum)} { 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 419 if {$itk_option(-samplewidth) > 0} { 420 set w $itk_option(-samplewidth) 421 } else { 422 if {$itk_option(-image) != ""} { 423 set w [expr {[image width $itk_option(-image)]+4}] 424 } else { 425 set w [winfo reqheight $itk_component(value)] 426 } 427 } 428 429 if {$itk_option(-sampleheight) > 0} { 430 set h $itk_option(-sampleheight) 431 } else { 432 if {$itk_option(-image) != ""} { 433 set h [expr {[image height $itk_option(-image)]+4}] 434 } else { 435 set h [winfo reqheight $itk_component(value)] 436 } 437 } 438 438 } 439 439 440 440 if {$w > 0 && $h > 0} { 441 441 $itk_component(icon) configure -width $w -height $h 442 442 } 443 443 } … … 451 451 itcl::body Rappture::Gauge::_hilite {comp state} { 452 452 if {$itk_option(-state) == "disabled"} { 453 453 set state 0 ;# disabled? then don't hilite 454 454 } 455 455 if {$comp == "value" && !$itk_option(-editable)} { 456 457 456 $itk_component(value) configure -relief flat 457 return 458 458 } 459 459 460 460 if {$state} { 461 461 $itk_component($comp) configure -relief solid 462 462 } else { 463 463 $itk_component($comp) configure -relief flat 464 464 } 465 465 } … … 477 477 itcl::body Rappture::Gauge::_editor {option args} { 478 478 if {$itk_option(-state) == "disabled"} { 479 479 return ;# disabled? then bail out here! 480 480 } 481 481 switch -- $option { 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 482 popup { 483 if {$itk_option(-editable)} { 484 $itk_component(editor) activate 485 } 486 } 487 activate { 488 return [list text $_value \ 489 x [winfo rootx $itk_component(value)] \ 490 y [winfo rooty $itk_component(value)] \ 491 w [winfo width $itk_component(value)] \ 492 h [winfo height $itk_component(value)]] 493 } 494 validate { 495 if {[llength $args] != 1} { 496 error "wrong # args: should be \"_editor validate val\"" 497 } 498 set val [lindex $args 0] 499 500 if {[catch {value -check $val} result]} { 501 if {[regexp {allowed here is (.+)} $result match newval]} { 502 $itk_component(editor) value $newval 503 } 504 if {[regexp {^bad.*: +(.)(.+)} $result match first tail] 505 || [regexp {(.)(.+)} $result match first tail]} { 506 set result "[string toupper $first]$tail" 507 } 508 bell 509 Rappture::Tooltip::cue $itk_component(editor) $result 510 return 0 511 } 512 } 513 apply { 514 if {[llength $args] != 1} { 515 error "wrong # args: should be \"_editor apply val\"" 516 } 517 value [lindex $args 0] 518 } 519 menu { 520 eval tk_popup $itk_component(emenu) $args 521 } 522 default { 523 error "bad option \"$option\": should be popup, activate, validate, apply, and menu" 524 } 525 525 } 526 526 } … … 539 539 itcl::body Rappture::Gauge::_presets {option} { 540 540 switch -- $option { 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 541 post { 542 set i [$itk_component(presetlist) index $_value] 543 if {$i >= 0} { 544 $itk_component(presetlist) select clear 0 end 545 $itk_component(presetlist) select set $i 546 } 547 after 10 [list $itk_component(presets) configure -relief sunken] 548 } 549 unpost { 550 $itk_component(presets) configure -relief flat 551 } 552 select { 553 set val [$itk_component(presetlist) current] 554 if {"" != $val} { 555 value $val 556 } 557 } 558 default { 559 error "bad option \"$option\": should be post, unpost, select" 560 } 561 561 } 562 562 } … … 572 572 itcl::body Rappture::Gauge::_layout {} { 573 573 foreach w [pack slaves $itk_component(hull)] { 574 574 pack forget $w 575 575 } 576 576 577 577 array set side2anchor { 578 579 580 581 578 left e 579 right w 580 top s 581 bottom n 582 582 } 583 583 set pos $itk_option(-valueposition) 584 584 pack $itk_component(vframe) -side $pos \ 585 585 -expand yes -fill both -ipadx 2 586 586 $itk_component(value) configure -anchor $side2anchor($pos) 587 587 588 588 if {"" != $itk_option(-image) || "" != $itk_option(-spectrum)} { 589 589 pack $itk_component(icon) -side $pos 590 590 } 591 591 } … … 596 596 itcl::configbody Rappture::Gauge::editable { 597 597 if {![string is boolean -strict $itk_option(-editable)]} { 598 598 error "bad value \"$itk_option(-editable)\": should be boolean" 599 599 } 600 600 if {!$itk_option(-editable) && [winfo ismapped $itk_component(editor)]} { 601 601 $itk_component(editor) deactivate -abort 602 602 } 603 603 } … … 609 609 set valid {normal disabled} 610 610 if {[lsearch -exact $valid $itk_option(-state)] < 0} { 611 611 error "bad value \"$itk_option(-state)\": should be [join $valid {, }]" 612 612 } 613 613 $itk_component(value) configure -state $itk_option(-state) … … 623 623 itcl::configbody Rappture::Gauge::spectrum { 624 624 if {$itk_option(-spectrum) != "" 625 626 627 625 && ([catch {$itk_option(-spectrum) isa ::Rappture::Spectrum} valid] 626 || !$valid)} { 627 error "bad option \"$itk_option(-spectrum)\": should be Rappture::Spectrum object" 628 628 } 629 629 _resize … … 637 637 itcl::configbody Rappture::Gauge::image { 638 638 if {$itk_option(-image) != "" 639 640 639 && [catch {image width $itk_option(-image)}]} { 640 error "bad value \"$itk_option(-image)\": should be Tk image" 641 641 } 642 642 _resize … … 650 650 itcl::configbody Rappture::Gauge::units { 651 651 if {$itk_option(-units) != "" 652 653 652 && [::Rappture::Units::System::for $itk_option(-units)] == ""} { 653 error "unrecognized system of units \"$itk_option(-units)\"" 654 654 } 655 655 } … … 662 662 set opts {left right top bottom} 663 663 if {[lsearch -exact $opts $pos] < 0} { 664 664 error "bad value \"$pos\": should be [join $opts {, }]" 665 665 } 666 666 _layout … … 672 672 itcl::configbody Rappture::Gauge::presets { 673 673 if {"" == $itk_option(-presets)} { 674 674 pack forget $itk_component(presets) 675 675 } else { 676 677 678 679 680 681 682 683 684 685 676 if {$itk_option(-valueposition) == "left"} { 677 set s "left" 678 } else { 679 set s "right" 680 } 681 set first [lindex [pack slaves $itk_component(vframe)] 0] 682 pack $itk_component(presets) -before $first -side $s -fill y 683 684 $itk_component(presetlist) delete 0 end 685 $itk_component(presetlist) insert end $itk_option(-presets) 686 686 } 687 687 } … … 692 692 itcl::configbody Rappture::Gauge::type { 693 693 switch -- $itk_option(-type) { 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 } 709 } 694 integer { 695 set first [lindex [pack slaves $itk_component(vframe)] 0] 696 if {$first == $itk_component(presets)} { 697 pack $itk_component(spinner) -after $first -side left -fill y 698 } else { 699 pack $itk_component(spinner) -before $first -side right -fill y 700 } 701 } 702 real { 703 pack forget $itk_component(spinner) 704 } 705 default { 706 error "bad number type \"$itk_option(-type)\": should be integer or real" 707 } 708 } 709 } -
trunk/lang/tcl/src/RpEncodeTclInterface.cc
r1409 r1850 81 81 string = (Rappture::encoding::isBinary(buf, bufLen)) ? "yes" : "no"; 82 82 } else if (('e' == *type) && (strcmp(type,"encoded") == 0)) { 83 83 bool isEncoded; 84 84 85 85 isEncoded = (Rappture::encoding::headerFlags(buf, bufLen) != 0); 86 86 string = (isEncoded) ? "yes" : "no" ; 87 87 } else { 88 89 90 88 Tcl_AppendResult(interp, "bad option \"", type, 89 "\": should be binary or encoded", (char*)NULL); 90 return TCL_ERROR; 91 91 } 92 92 Tcl_SetResult(interp, (char *)string, TCL_STATIC); … … 114 114 * AsSwitch -- 115 115 * 116 * 117 * 116 * Convert a string represent a node number into its integer 117 * value. 118 118 * 119 119 * Results: 120 * 120 * The return value is a standard Tcl result. 121 121 * 122 122 *--------------------------------------------------------------------------- … … 125 125 static int 126 126 AsSwitch( 127 ClientData clientData, 128 Tcl_Interp *interp, 129 const char *switchName, 130 Tcl_Obj *objPtr, 131 char *record, 132 int offset, 133 int flags) 127 ClientData clientData, /* Not used. */ 128 Tcl_Interp *interp, /* Interpreter to send results back to */ 129 const char *switchName, /* Not used. */ 130 Tcl_Obj *objPtr, /* String representation */ 131 char *record, /* Structure record */ 132 int offset, /* Offset to field in structure */ 133 int flags) /* Not used. */ 134 134 { 135 135 int *flagsPtr = (int *)(record + offset); … … 140 140 c = string[0]; 141 141 if ((c == 'b') && (strcmp(string, "b64") == 0)) { 142 142 *flagsPtr = RPENC_B64; 143 143 } else if ((c == 'z') && (strcmp(string, "zb64") == 0)) { 144 144 *flagsPtr = RPENC_Z | RPENC_B64; 145 145 } else if ((c == 'z') && (strcmp(string, "z") == 0)) { 146 146 *flagsPtr = RPENC_Z; 147 147 } else { 148 149 150 148 Tcl_AppendResult(interp, "bad value \"", string, 149 "\": should be b64, zb64, or z", (char *)NULL); 150 return TCL_ERROR; 151 151 } 152 152 return TCL_OK; … … 165 165 { 166 166 {SWITCH_CUSTOM, "-as", "z|b64|zb64", 167 167 offsetof(EncodeSwitches, flags), 0, 0, &asSwitch}, 168 168 {SWITCH_BITMASK, "-noheader", "", 169 169 offsetof(EncodeSwitches, flags), 0, RPENC_RAW}, 170 170 {SWITCH_END} 171 171 }; … … 173 173 static int 174 174 EncodeCmd(ClientData clientData, Tcl_Interp *interp, int objc, 175 175 Tcl_Obj *const *objv) 176 176 { 177 177 if (objc < 1) { 178 178 Tcl_AppendResult(interp, "wrong # args: should be \"", 179 180 179 Tcl_GetString(objv[0]), 180 " ?-as z|b64|zb64? ?-noheader? ?--? string\"", (char*)NULL); 181 181 return TCL_ERROR; 182 182 } … … 185 185 int n; 186 186 n = Rp_ParseSwitches(interp, encodeSwitches, objc - 1, objv + 1, &switches, 187 187 SWITCH_OBJV_PARTIAL); 188 188 if (n < 0) { 189 189 return TCL_ERROR; 190 190 } 191 191 int last; … … 193 193 if ((objc - last) != 1) { 194 194 Tcl_AppendResult(interp, "wrong # args: should be \"", 195 196 195 Tcl_GetString(objv[0]), 196 " ?-as z|b64|zb64? ?-noheader? ?--? string\"", (char*)NULL); 197 197 return TCL_ERROR; 198 198 } … … 201 201 string = (const char*)Tcl_GetByteArrayFromObj(objv[last], &nBytes); 202 202 if (nBytes <= 0) { 203 return TCL_OK;// Nothing to encode.203 return TCL_OK; // Nothing to encode. 204 204 } 205 205 Rappture::Buffer buf(string, nBytes); … … 207 207 if (!Rappture::encoding::encode(status, buf, switches.flags)) { 208 208 Tcl_AppendResult(interp, status.remark(), "\n", status.context(), NULL); 209 209 return TCL_ERROR; 210 210 } 211 211 Tcl_SetByteArrayObj(Tcl_GetObjResult(interp), 212 212 (const unsigned char*)buf.bytes(), buf.size()); 213 213 return TCL_OK; 214 214 } … … 225 225 * ::Rappture::encoding::decode ?-as z|b64|zb64? <string> 226 226 * 227 * 228 * 229 * 227 * I'd rather the interface be 228 * 229 * decode -b64 -z string 230 230 */ 231 231 … … 237 237 { 238 238 {SWITCH_CUSTOM, "-as", "z|b64|zb64", 239 239 offsetof(DecodeSwitches, flags), 0, 0, &asSwitch}, 240 240 {SWITCH_BITMASK, "-noheader", "", 241 241 offsetof(DecodeSwitches, flags), 0, RPENC_RAW}, 242 242 {SWITCH_END} 243 243 }; … … 245 245 static int 246 246 DecodeCmd(ClientData clientData, Tcl_Interp *interp, int objc, 247 247 Tcl_Obj *const *objv) 248 248 { 249 249 if (objc < 1) { 250 250 Tcl_AppendResult(interp, "wrong # args: should be \"", 251 251 Tcl_GetString(objv[0]), 252 252 " ?-as z|b64|zb64? ?--? <string>\"", (char*)NULL); 253 253 return TCL_ERROR; … … 258 258 int n; 259 259 n = Rp_ParseSwitches(interp, decodeSwitches, objc - 1, objv + 1, &switches, 260 260 SWITCH_OBJV_PARTIAL); 261 261 if (n < 0) { 262 262 return TCL_ERROR; 263 263 } 264 264 int last; … … 266 266 if ((objc - last) != 1) { 267 267 Tcl_AppendResult(interp, "wrong # args: should be \"", 268 269 268 Tcl_GetString(objv[0]), 269 " ?-as z|b64|zb64? ?--? string\"", (char*)NULL); 270 270 return TCL_ERROR; 271 271 } … … 274 274 string = (const char*)Tcl_GetByteArrayFromObj(objv[last], &nBytes); 275 275 if (nBytes <= 0) { 276 return TCL_OK;// Nothing to decode.276 return TCL_OK; // Nothing to decode. 277 277 } 278 278 Rappture::Buffer buf(string, nBytes); … … 280 280 if (!Rappture::encoding::decode(status, buf, switches.flags)) { 281 281 Tcl_AppendResult(interp, status.remark(), "\n", status.context(), NULL); 282 282 return TCL_ERROR; 283 283 } 284 284 Tcl_SetByteArrayObj(Tcl_GetObjResult(interp), 285 286 return TCL_OK; 287 } 285 (const unsigned char*)buf.bytes(), buf.size()); 286 return TCL_OK; 287 } -
trunk/packages/vizservers/nanovis/FlowCmd.cpp
r1571 r1850 55 55 Rappture::SwitchSpec FlowCmd::_switches[] = { 56 56 {Rappture::SWITCH_BOOLEAN, "-arrows", "boolean", 57 57 offsetof(FlowValues, showArrows), 0}, 58 58 {Rappture::SWITCH_CUSTOM, "-axis", "axis", 59 59 offsetof(FlowValues, slicePos.axis), 0, 0, &axisSwitch}, 60 60 {Rappture::SWITCH_FLOAT, "-diffuse", "value", 61 61 offsetof(FlowValues, diffuse), 0}, 62 62 {Rappture::SWITCH_BOOLEAN, "-hide", "boolean", 63 63 offsetof(FlowValues, isHidden), 0}, 64 64 {Rappture::SWITCH_FLOAT, "-opacity", "value", 65 65 offsetof(FlowValues, opacity), 0}, 66 66 {Rappture::SWITCH_BOOLEAN, "-outline", "boolean", 67 67 offsetof(FlowValues, showOutline), 0}, 68 68 {Rappture::SWITCH_CUSTOM, "-position", "number", 69 69 offsetof(FlowValues, slicePos), 0, 0, &positionSwitch}, 70 70 {Rappture::SWITCH_BOOLEAN, "-slice", "boolean", 71 71 offsetof(FlowValues, sliceVisible), 0}, 72 72 {Rappture::SWITCH_FLOAT, "-specular", "value", 73 73 offsetof(FlowValues, specular), 0}, 74 74 {Rappture::SWITCH_CUSTOM, "-transferfunction", "name", 75 75 offsetof(FlowValues, tfPtr), 0, 0, &transferFunctionSwitch}, 76 76 {Rappture::SWITCH_BOOLEAN, "-volume", "boolean", 77 77 offsetof(FlowValues, showVolume), 0}, 78 78 {Rappture::SWITCH_END} 79 79 }; … … 87 87 offsetof(FlowParticlesValues, isHidden), 0}, 88 88 {Rappture::SWITCH_CUSTOM, "-position", "number", 89 89 offsetof(FlowParticlesValues, position), 0, 0, &positionSwitch}, 90 90 {Rappture::SWITCH_FLOAT, "-size", "float", 91 91 offsetof(FlowParticlesValues, particleSize), 0}, … … 118 118 _hashPtr = hPtr; 119 119 _sv.isHidden = false; 120 _sv.position.axis = 0; 121 _sv.position.value = 0.0f; 120 _sv.position.axis = 0; /* X_AXIS */ 121 _sv.position.value = 0.0f; 122 122 _sv.position.flags = RELPOS; 123 123 _sv.color.r = _sv.color.b = _sv.color.g = _sv.color.a = 1.0f; 124 124 _rendererPtr = new NvParticleRenderer(NMESH, NMESH, 125 125 /* Global nVidia Cg context */g_context); 126 126 } 127 127 … … 129 129 { 130 130 if (_rendererPtr != NULL) { 131 131 delete _rendererPtr; 132 132 } 133 133 if (_hashPtr != NULL) { 134 134 Tcl_DeleteHashEntry(_hashPtr); 135 135 } 136 136 Rappture::FreeSwitches(_switches, &_sv, 0); … … 144 144 Trace("rendering particles %s position=%g\n", _name, _sv.position.value); 145 145 Trace("rendering particles %s position=%g\n", _name, 146 146 FlowCmd::GetRelativePosition(&_sv.position)); 147 147 148 148 _rendererPtr->setPos(FlowCmd::GetRelativePosition(&_sv.position)); … … 157 157 _rendererPtr->setPos(FlowCmd::GetRelativePosition(&_sv.position)); 158 158 _rendererPtr->setColor(Vector4(_sv.color.r, _sv.color.g, _sv.color.b, 159 159 _sv.color.a)); 160 160 _rendererPtr->particleSize(_sv.particleSize); 161 161 _rendererPtr->setAxis(_sv.position.axis); … … 168 168 _hashPtr = hPtr; 169 169 _sv.isHidden = false; 170 _sv.corner1.x = 0.0f; 171 _sv.corner1.y = 0.0f; 172 _sv.corner1.z = 0.0f; 173 _sv.corner2.x = 1.0f; 174 _sv.corner2.y = 1.0f; 175 _sv.corner2.z = 1.0f; 170 _sv.corner1.x = 0.0f; 171 _sv.corner1.y = 0.0f; 172 _sv.corner1.z = 0.0f; 173 _sv.corner2.x = 1.0f; 174 _sv.corner2.y = 1.0f; 175 _sv.corner2.z = 1.0f; 176 176 _sv.lineWidth = 1.2f; 177 177 _sv.color.r = _sv.color.b = _sv.color.g = _sv.color.a = 1.0f; … … 199 199 sy = volPtr->height / (double)volPtr->width; 200 200 if (volPtr->depth > 0.0) { 201 201 sz = volPtr->depth / (double)volPtr->width; 202 202 } 203 203 glScaled(sx, sy, sz); … … 209 209 210 210 Trace("box is %g,%g %g,%g %g,%g\n", 211 212 213 211 _sv.corner1.x, _sv.corner2.x, 212 _sv.corner1.y, _sv.corner2.y, 213 _sv.corner1.z, _sv.corner2.z); 214 214 Trace("world is %g,%g %g,%g %g,%g\n", 215 215 min.x, max.x, min.y, max.y, min.z, max.z); 216 216 217 217 float x0, y0, z0, x1, y1, z1; … … 219 219 x1 = y1 = z1 = 0.0f; 220 220 if (max.y > min.y) { 221 222 221 y0 = (_sv.corner1.y - min.y) / (max.y - min.y); 222 y1 = (_sv.corner2.y - min.y) / (max.y - min.y); 223 223 } 224 224 if (max.z > min.z) { 225 226 225 z0 = (_sv.corner1.z - min.z) / (max.z - min.z); 226 z1 = (_sv.corner2.z - min.z) / (max.z - min.z); 227 227 } 228 228 if (max.x > min.x) { 229 230 229 x0 = (_sv.corner1.x - min.x) / (max.x - min.x); 230 x1 = (_sv.corner2.x - min.x) / (max.x - min.x); 231 231 } 232 232 Trace("rendering box %g,%g %g,%g %g,%g\n", x0, x1, y0, y1, z0, z1); … … 235 235 glBegin(GL_LINE_LOOP); 236 236 { 237 238 239 240 237 glVertex3d(x0, y0, z0); 238 glVertex3d(x1, y0, z0); 239 glVertex3d(x1, y1, z0); 240 glVertex3d(x0, y1, z0); 241 241 } 242 242 glEnd(); 243 243 glBegin(GL_LINE_LOOP); 244 244 { 245 246 247 248 245 glVertex3d(x0, y0, z1); 246 glVertex3d(x1, y0, z1); 247 glVertex3d(x1, y1, z1); 248 glVertex3d(x0, y1, z1); 249 249 } 250 250 glEnd(); … … 252 252 glBegin(GL_LINE_LOOP); 253 253 { 254 255 256 257 254 glVertex3d(x0, y0, z0); 255 glVertex3d(x0, y0, z1); 256 glVertex3d(x0, y1, z1); 257 glVertex3d(x0, y1, z0); 258 258 } 259 259 glEnd(); … … 261 261 glBegin(GL_LINE_LOOP); 262 262 { 263 264 265 266 263 glVertex3d(x1, y0, z0); 264 glVertex3d(x1, y0, z1); 265 glVertex3d(x1, y1, z1); 266 glVertex3d(x1, y1, z0); 267 267 } 268 268 glEnd(); … … 290 290 _volPtr = NULL; 291 291 _cmdToken = Tcl_CreateObjCommand(interp, (char *)_name, 292 292 (Tcl_ObjCmdProc *)FlowInstObjCmd, this, FlowInstDeleteProc); 293 293 Tcl_InitHashTable(&_particlesTable, TCL_STRING_KEYS); 294 294 Tcl_InitHashTable(&_boxTable, TCL_STRING_KEYS); … … 299 299 Rappture::FreeSwitches(_switches, &_sv, 0); 300 300 if (_hashPtr != NULL) { 301 301 Tcl_DeleteHashEntry(_hashPtr); 302 302 } 303 303 if (_fieldPtr != NULL) { 304 304 delete _fieldPtr; 305 305 } 306 306 if (_dataPtr != NULL) { 307 307 delete _dataPtr; 308 308 } 309 309 if (_volPtr != NULL) { 310 311 310 NanoVis::remove_volume(_volPtr); 311 _volPtr = NULL; 312 312 } 313 313 … … 315 315 FlowBoxIterator boxIter; 316 316 for (boxPtr = FirstBox(&boxIter); boxPtr != NULL; 317 318 319 320 } 317 boxPtr = NextBox(&boxIter)) { 318 boxPtr->disconnect(); 319 delete boxPtr; 320 } 321 321 FlowParticles *particlesPtr; 322 322 FlowParticlesIterator partIter; 323 323 for (particlesPtr = FirstParticles(&partIter); particlesPtr != NULL; 324 325 326 327 } 324 particlesPtr = NextParticles(&partIter)) { 325 particlesPtr->disconnect(); 326 delete particlesPtr; 327 } 328 328 Tcl_DeleteHashTable(&_particlesTable); 329 329 Tcl_DeleteHashTable(&_boxTable); … … 336 336 FlowParticles *particlesPtr; 337 337 for (particlesPtr = FirstParticles(&iter); particlesPtr != NULL; 338 339 338 particlesPtr = NextParticles(&iter)) { 339 particlesPtr->Reset(); 340 340 } 341 341 } … … 350 350 FlowParticles *particlesPtr; 351 351 for (particlesPtr = FirstParticles(&iter); particlesPtr != NULL; 352 353 354 355 352 particlesPtr = NextParticles(&iter)) { 353 if (particlesPtr->visible()) { 354 particlesPtr->Advect(); 355 } 356 356 } 357 357 } … … 365 365 FlowParticles *particlesPtr; 366 366 for (particlesPtr = FirstParticles(&iter); particlesPtr != NULL; 367 368 369 370 367 particlesPtr = NextParticles(&iter)) { 368 if (particlesPtr->visible()) { 369 particlesPtr->Render(); 370 } 371 371 } 372 372 Trace("in Render before boxes %s\n", _name); … … 382 382 hPtr = Tcl_CreateHashEntry(&_particlesTable, particlesName, &isNew); 383 383 if (!isNew) { 384 385 386 384 Tcl_AppendResult(interp, "particle injection plane \"", 385 particlesName, "\" already exists.", (char *)NULL); 386 return TCL_ERROR; 387 387 } 388 388 particlesName = Tcl_GetHashKey(&_particlesTable, hPtr); … … 390 390 particlesPtr = new FlowParticles(particlesName, hPtr); 391 391 if (particlesPtr == NULL) { 392 393 394 395 392 Tcl_AppendResult(interp, "can't allocate particle injection plane", 393 (char *)NULL); 394 Tcl_DeleteHashEntry(hPtr); 395 return TCL_ERROR; 396 396 } 397 397 Tcl_SetHashValue(hPtr, particlesPtr); … … 401 401 int 402 402 FlowCmd::GetParticles(Tcl_Interp *interp, Tcl_Obj *objPtr, 403 403 FlowParticles **particlesPtrPtr) 404 404 { 405 405 Tcl_HashEntry *hPtr; 406 406 hPtr = Tcl_FindHashEntry(&_particlesTable, Tcl_GetString(objPtr)); 407 407 if (hPtr == NULL) { 408 409 410 411 412 408 if (interp != NULL) { 409 Tcl_AppendResult(interp, "can't find a particle injection plane \"", 410 Tcl_GetString(objPtr), "\"", (char *)NULL); 411 } 412 return TCL_ERROR; 413 413 } 414 414 *particlesPtrPtr = (FlowParticles *)Tcl_GetHashValue(hPtr); … … 420 420 { 421 421 iterPtr->hashPtr = Tcl_FirstHashEntry(&_particlesTable, 422 422 &iterPtr->hashSearch); 423 423 if (iterPtr->hashPtr == NULL) { 424 424 return NULL; 425 425 } 426 426 return (FlowParticles *)Tcl_GetHashValue(iterPtr->hashPtr); … … 431 431 { 432 432 if (iterPtr->hashPtr == NULL) { 433 433 return NULL; 434 434 } 435 435 iterPtr->hashPtr = Tcl_NextHashEntry(&iterPtr->hashSearch); 436 436 if (iterPtr->hashPtr == NULL) { 437 437 return NULL; 438 438 } 439 439 return (FlowParticles *)Tcl_GetHashValue(iterPtr->hashPtr); … … 447 447 hPtr = Tcl_CreateHashEntry(&_boxTable, Tcl_GetString(objPtr), &isNew); 448 448 if (!isNew) { 449 450 451 449 Tcl_AppendResult(interp, "box \"", Tcl_GetString(objPtr), 450 "\" already exists in flow \"", name(), "\"", (char *)NULL); 451 return TCL_ERROR; 452 452 } 453 453 const char *boxName; … … 456 456 boxPtr = new FlowBox(boxName, hPtr); 457 457 if (boxPtr == NULL) { 458 459 460 461 458 Tcl_AppendResult(interp, "can't allocate box \"", boxName, "\"", 459 (char *)NULL); 460 Tcl_DeleteHashEntry(hPtr); 461 return TCL_ERROR; 462 462 } 463 463 Tcl_SetHashValue(hPtr, boxPtr); … … 471 471 hPtr = Tcl_FindHashEntry(&_boxTable, Tcl_GetString(objPtr)); 472 472 if (hPtr == NULL) { 473 474 475 476 477 478 473 if (interp != NULL) { 474 Tcl_AppendResult(interp, "can't find a box \"", 475 Tcl_GetString(objPtr), "\" in flow \"", name(), "\"", 476 (char *)NULL); 477 } 478 return TCL_ERROR; 479 479 } 480 480 *boxPtrPtr = (FlowBox *)Tcl_GetHashValue(hPtr); … … 487 487 iterPtr->hashPtr = Tcl_FirstHashEntry(&_boxTable, &iterPtr->hashSearch); 488 488 if (iterPtr->hashPtr == NULL) { 489 489 return NULL; 490 490 } 491 491 return (FlowBox *)Tcl_GetHashValue(iterPtr->hashPtr); … … 496 496 { 497 497 if (iterPtr->hashPtr == NULL) { 498 498 return NULL; 499 499 } 500 500 iterPtr->hashPtr = Tcl_NextHashEntry(&iterPtr->hashSearch); 501 501 if (iterPtr->hashPtr == NULL) { 502 502 return NULL; 503 503 } 504 504 return (FlowBox *)Tcl_GetHashValue(iterPtr->hashPtr); … … 512 512 FlowParticlesIterator iter; 513 513 for (particlesPtr = FirstParticles(&iter); particlesPtr != NULL; 514 515 516 } 514 particlesPtr = NextParticles(&iter)) { 515 particlesPtr->Initialize(); 516 } 517 517 } 518 518 … … 521 521 { 522 522 if (_volPtr != NULL) { 523 524 525 523 fprintf(stderr, "from ScaleVectorField volId=%s\n", _volPtr->name()); 524 NanoVis::remove_volume(_volPtr); 525 _volPtr = NULL; 526 526 } 527 527 float *vdata; 528 528 vdata = GetScaledVector(); 529 529 if (vdata == NULL) { 530 530 return false; 531 531 } 532 532 Volume *volPtr; … … 534 534 delete [] vdata; 535 535 if (volPtr == NULL) { 536 536 return false; 537 537 } 538 538 _volPtr = volPtr; … … 540 540 // Remove the associated vector field. 541 541 if (_fieldPtr != NULL) { 542 542 delete _fieldPtr; 543 543 } 544 544 _fieldPtr = new NvVectorField(); 545 545 if (_fieldPtr == NULL) { 546 546 return false; 547 547 } 548 548 … … 559 559 560 560 _fieldPtr->setVectorField(_volPtr, loc, 561 561 1.0f, height / width, depth / width, NanoVis::magMax); 562 562 563 563 if (NanoVis::licRenderer != NULL) { 564 564 NanoVis::licRenderer->setVectorField(_volPtr->id, loc, 565 566 567 568 569 570 571 565 1.0f / _volPtr->aspect_ratio_width, 566 1.0f / _volPtr->aspect_ratio_height, 567 1.0f / _volPtr->aspect_ratio_depth, 568 _volPtr->wAxis.max()); 569 SetCurrentPosition(); 570 SetAxis(); 571 SetActive(); 572 572 } 573 573 … … 576 576 //*(volPtr->get_location()), 577 577 1.0f, 578 579 578 _volPtr->aspect_ratio_height / _volPtr->aspect_ratio_width, 579 _volPtr->aspect_ratio_depth / _volPtr->aspect_ratio_width 580 580 //,volPtr->wAxis.max() 581 581 ); 582 583 584 585 582 Trace("Arrows enabled set to %d\n", _sv.showArrows); 583 NanoVis::velocityArrowsSlice->axis(_sv.slicePos.axis); 584 NanoVis::velocityArrowsSlice->slicePos(_sv.slicePos.value); 585 NanoVis::velocityArrowsSlice->enabled(_sv.showArrows); 586 586 } 587 587 FlowParticles *particlesPtr; 588 588 FlowParticlesIterator partIter; 589 589 for (particlesPtr = FirstParticles(&partIter); particlesPtr != NULL; 590 591 592 } 590 particlesPtr = NextParticles(&partIter)) { 591 particlesPtr->SetVectorField(_volPtr); 592 } 593 593 return true; 594 594 } … … 600 600 FlowBox *boxPtr; 601 601 for (boxPtr = FirstBox(&iter); boxPtr != NULL; boxPtr = NextBox(&iter)) { 602 603 604 605 602 Trace("found box %s\n", boxPtr->name()); 603 if (boxPtr->visible()) { 604 boxPtr->Render(_volPtr); 605 } 606 606 } 607 607 } … … 614 614 float *data = new float[n]; 615 615 if (data == NULL) { 616 616 return NULL; 617 617 } 618 618 memset(data, 0, sizeof(float) * n); … … 620 620 const float *values = _dataPtr->values(); 621 621 for (size_t iz=0; iz < _dataPtr->zNum(); iz++) { 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 622 for (size_t iy=0; iy < _dataPtr->yNum(); iy++) { 623 for (size_t ix=0; ix < _dataPtr->xNum(); ix++) { 624 double vx, vy, vz, vm; 625 vx = values[0]; 626 vy = values[1]; 627 vz = values[2]; 628 vm = sqrt(vx*vx + vy*vy + vz*vz); 629 destPtr[0] = vm / NanoVis::magMax; 630 destPtr[1] = vx /(2.0*NanoVis::magMax) + 0.5; 631 destPtr[2] = vy /(2.0*NanoVis::magMax) + 0.5; 632 destPtr[3] = vz /(2.0*NanoVis::magMax) + 0.5; 633 values += 3; 634 destPtr += 4; 635 } 636 } 637 637 } 638 638 return data; … … 645 645 646 646 volPtr = NanoVis::load_volume(_name, _dataPtr->xNum(), _dataPtr->yNum(), 647 648 647 _dataPtr->zNum(), 4, data, 648 NanoVis::magMin, NanoVis::magMax, 0); 649 649 volPtr->xAxis.SetRange(_dataPtr->xMin(), _dataPtr->xMax()); 650 650 volPtr->yAxis.SetRange(_dataPtr->yMin(), _dataPtr->yMax()); … … 655 655 Vector3 physicalMax(NanoVis::xMax, NanoVis::yMax, NanoVis::zMax); 656 656 Trace("min=%g %g %g max=%g %g %g mag=%g %g\n", 657 658 659 657 NanoVis::xMin, NanoVis::yMin, NanoVis::zMin, 658 NanoVis::xMax, NanoVis::yMax, NanoVis::zMax, 659 NanoVis::magMin, NanoVis::magMax); 660 660 volPtr->setPhysicalBBox(physicalMin, physicalMax); 661 661 //volPtr->set_n_slice(256 - _volIndex); … … 689 689 static int 690 690 FlowDataFileOp(ClientData clientData, Tcl_Interp *interp, int objc, 691 691 Tcl_Obj *const *objv) 692 692 { 693 693 Rappture::Outcome result; … … 702 702 } 703 703 if ((nComponents < 1) || (nComponents > 4)) { 704 705 706 704 Tcl_AppendResult(interp, "bad # of components \"", 705 Tcl_GetString(objv[4]), "\"", (char *)NULL); 706 return TCL_ERROR; 707 707 } 708 708 Rappture::Buffer buf; 709 709 if (!buf.load(result, fileName)) { 710 711 712 710 Tcl_AppendResult(interp, "can't load data from \"", fileName, "\": ", 711 result.remark(), (char *)NULL); 712 return TCL_ERROR; 713 713 } 714 714 … … 719 719 char *bytes = (char *)buf.bytes(); 720 720 if ((length > 4) && (strncmp(bytes, "<DX>", 4) == 0)) { 721 722 723 724 725 721 if (!dataPtr->ImportDx(result, nComponents, length-4, bytes+4)) { 722 Tcl_AppendResult(interp, result.remark(), (char *)NULL); 723 delete dataPtr; 724 return TCL_ERROR; 725 } 726 726 } else if ((length > 10) && (strncmp(bytes, "unirect3d ", 10) == 0)) { 727 728 729 730 727 if (dataPtr->ParseBuffer(interp, buf) != TCL_OK) { 728 delete dataPtr; 729 return TCL_ERROR; 730 } 731 731 } else if ((length > 10) && (strncmp(bytes, "unirect2d ", 10) == 0)) { 732 733 734 735 736 737 738 739 732 Rappture::Unirect2d *u2dPtr; 733 u2dPtr = new Rappture::Unirect2d(nComponents); 734 if (u2dPtr->ParseBuffer(interp, buf) != TCL_OK) { 735 delete u2dPtr; 736 return TCL_ERROR; 737 } 738 dataPtr->Convert(u2dPtr); 739 delete u2dPtr; 740 740 } else { 741 742 743 744 745 746 741 fprintf(stderr, "header is %.14s\n", buf.bytes()); 742 if (!dataPtr->ImportDx(result, nComponents, length, bytes)) { 743 Tcl_AppendResult(interp, result.remark(), (char *)NULL); 744 delete dataPtr; 745 return TCL_ERROR; 746 } 747 747 } 748 748 if (dataPtr->nValues() == 0) { 749 750 751 752 749 delete dataPtr; 750 Tcl_AppendResult(interp, "no data found in \"", fileName, "\"", 751 (char *)NULL); 752 return TCL_ERROR; 753 753 } 754 754 flowPtr->data(dataPtr); … … 770 770 int nBytes; 771 771 if (Tcl_GetIntFromObj(interp, objv[3], &nBytes) != TCL_OK) { 772 772 Trace("Bad nBytes \"%s\"\n", Tcl_GetString(objv[3])); 773 773 return TCL_ERROR; 774 774 } 775 775 if (nBytes <= 0) { 776 777 778 779 776 Tcl_AppendResult(interp, "bad # bytes request \"", 777 Tcl_GetString(objv[3]), "\" for \"data follows\"", (char *)NULL); 778 Trace("Bad nbytes %d\n", nBytes); 779 return TCL_ERROR; 780 780 } 781 781 int nComponents; 782 782 if (Tcl_GetIntFromObj(interp, objv[4], &nComponents) != TCL_OK) { 783 783 Trace("Bad # of components \"%s\"\n", Tcl_GetString(objv[4])); 784 784 return TCL_ERROR; 785 785 } 786 786 if (nComponents <= 0) { 787 788 789 790 787 Tcl_AppendResult(interp, "bad # of components request \"", 788 Tcl_GetString(objv[4]), "\" for \"data follows\"", (char *)NULL); 789 Trace("Bad # of components %d\n", nComponents); 790 return TCL_ERROR; 791 791 } 792 792 Rappture::Buffer buf; … … 802 802 char *bytes = (char *)buf.bytes(); 803 803 if ((length > 4) && (strncmp(bytes, "<DX>", 4) == 0)) { 804 805 806 807 808 804 if (!dataPtr->ImportDx(result, nComponents, length - 4, bytes + 4)) { 805 Tcl_AppendResult(interp, result.remark(), (char *)NULL); 806 delete dataPtr; 807 return TCL_ERROR; 808 } 809 809 } else if ((length > 10) && (strncmp(bytes, "unirect3d ", 10) == 0)) { 810 811 812 813 810 if (dataPtr->ParseBuffer(interp, buf) != TCL_OK) { 811 delete dataPtr; 812 return TCL_ERROR; 813 } 814 814 } else if ((length > 10) && (strncmp(bytes, "unirect2d ", 10) == 0)) { 815 816 817 818 819 820 821 822 815 Rappture::Unirect2d *u2dPtr; 816 u2dPtr = new Rappture::Unirect2d(nComponents); 817 if (u2dPtr->ParseBuffer(interp, buf) != TCL_OK) { 818 delete u2dPtr; 819 return TCL_ERROR; 820 } 821 dataPtr->Convert(u2dPtr); 822 delete u2dPtr; 823 823 } else { 824 825 826 827 828 829 824 fprintf(stderr, "header is %.14s\n", buf.bytes()); 825 if (!dataPtr->ImportDx(result, nComponents, length, bytes)) { 826 Tcl_AppendResult(interp, result.remark(), (char *)NULL); 827 delete dataPtr; 828 return TCL_ERROR; 829 } 830 830 } 831 831 if (dataPtr->nValues() == 0) { 832 833 834 832 delete dataPtr; 833 Tcl_AppendResult(interp, "no data found in stream", (char *)NULL); 834 return TCL_ERROR; 835 835 } 836 836 flowPtr->data(dataPtr); 837 837 { 838 838 char info[1024]; 839 840 839 ssize_t nWritten; 840 size_t length; 841 841 842 842 length = sprintf(info, "nv>data tag %s min %g max %g\n", 843 843 flowPtr->name(), dataPtr->magMin(), dataPtr->magMax()); 844 844 nWritten = write(0, info, length); 845 845 assert(nWritten == (ssize_t)strlen(info)); 846 846 } 847 847 NanoVis::EventuallyRedraw(NanoVis::MAP_FLOWS); … … 857 857 static int 858 858 FlowDataOp(ClientData clientData, Tcl_Interp *interp, int objc, 859 859 Tcl_Obj *const *objv) 860 860 { 861 861 Tcl_ObjCmdProc *proc; … … 873 873 { 874 874 if (posPtr->flags == RELPOS) { 875 875 return posPtr->value; 876 876 } 877 877 switch (posPtr->axis) { 878 878 case AXIS_X: 879 880 879 return (posPtr->value - NanoVis::xMin) / 880 (NanoVis::xMax - NanoVis::xMin); 881 881 case AXIS_Y: 882 883 882 return (posPtr->value - NanoVis::yMin) / 883 (NanoVis::yMax - NanoVis::yMin); 884 884 case AXIS_Z: 885 886 885 return (posPtr->value - NanoVis::zMin) / 886 (NanoVis::zMax - NanoVis::zMin); 887 887 } 888 888 return 0.0; … … 908 908 iterPtr->hashPtr = Tcl_FirstHashEntry(&flowTable, &iterPtr->hashSearch); 909 909 if (iterPtr->hashPtr == NULL) { 910 910 return NULL; 911 911 } 912 912 return (FlowCmd *)Tcl_GetHashValue(iterPtr->hashPtr); … … 917 917 { 918 918 if (iterPtr->hashPtr == NULL) { 919 919 return NULL; 920 920 } 921 921 iterPtr->hashPtr = Tcl_NextHashEntry(&iterPtr->hashSearch); 922 922 if (iterPtr->hashPtr == NULL) { 923 923 return NULL; 924 924 } 925 925 return (FlowCmd *)Tcl_GetHashValue(iterPtr->hashPtr); … … 932 932 hPtr = Tcl_FindHashEntry(&flowTable, Tcl_GetString(objPtr)); 933 933 if (hPtr == NULL) { 934 935 936 937 938 934 if (interp != NULL) { 935 Tcl_AppendResult(interp, "can't find a flow \"", 936 Tcl_GetString(objPtr), "\"", (char *)NULL); 937 } 938 return TCL_ERROR; 939 939 } 940 940 *flowPtrPtr = (FlowCmd *)Tcl_GetHashValue(hPtr); … … 951 951 hPtr = Tcl_CreateHashEntry(&flowTable, name, &isNew); 952 952 if (!isNew) { 953 954 955 953 Tcl_AppendResult(interp, "flow \"", name, "\" already exists.", 954 (char *)NULL); 955 return TCL_ERROR; 956 956 } 957 957 Tcl_CmdInfo cmdInfo; 958 958 if (Tcl_GetCommandInfo(interp, name, &cmdInfo)) { 959 960 961 962 } 959 Tcl_AppendResult(interp, "an another command \"", name, 960 "\" already exists.", (char *)NULL); 961 return TCL_ERROR; 962 } 963 963 FlowCmd *flowPtr; 964 964 name = Tcl_GetHashKey(&flowTable, hPtr); 965 965 flowPtr = new FlowCmd(interp, name, hPtr); 966 966 if (flowPtr == NULL) { 967 968 969 967 Tcl_AppendResult(interp, "can't allocate a flow object \"", name, 968 "\"", (char *)NULL); 969 return TCL_ERROR; 970 970 } 971 971 Tcl_SetHashValue(hPtr, flowPtr); … … 979 979 FlowIterator iter; 980 980 for (flowPtr = FirstFlow(&iter); flowPtr != NULL; 981 982 flowPtr->disconnect();/* Don't disrupt the hash walk */983 981 flowPtr = NextFlow(&iter)) { 982 flowPtr->disconnect(); /* Don't disrupt the hash walk */ 983 Tcl_DeleteCommand(interp, flowPtr->name()); 984 984 } 985 985 Tcl_DeleteHashTable(&flowTable); … … 994 994 /* 995 995 * Step 1. Get the overall min and max magnitudes of all the 996 * 996 * flow vectors. 997 997 */ 998 998 magMin = DBL_MAX, magMax = -DBL_MAX; … … 1001 1001 FlowIterator iter; 1002 1002 for (flowPtr = FirstFlow(&iter); flowPtr != NULL; 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1003 flowPtr = NextFlow(&iter)) { 1004 double min, max; 1005 if (!flowPtr->isDataLoaded()) { 1006 continue; 1007 } 1008 Rappture::Unirect3d *dataPtr; 1009 dataPtr = flowPtr->data(); 1010 min = dataPtr->magMin(); 1011 max = dataPtr->magMax(); 1012 if (min < magMin) { 1013 magMin = min; 1014 } 1015 if (max > magMax) { 1016 magMax = max; 1017 } 1018 if (dataPtr->xMin() < xMin) { 1019 xMin = dataPtr->xMin(); 1020 } 1021 if (dataPtr->yMin() < yMin) { 1022 yMin = dataPtr->yMin(); 1023 } 1024 if (dataPtr->zMin() < zMin) { 1025 zMin = dataPtr->zMin(); 1026 } 1027 if (dataPtr->xMax() > xMax) { 1028 xMax = dataPtr->xMax(); 1029 } 1030 if (dataPtr->yMax() > yMax) { 1031 yMax = dataPtr->yMax(); 1032 } 1033 if (dataPtr->zMax() > zMax) { 1034 zMax = dataPtr->zMax(); 1035 } 1036 1036 } 1037 1037 Trace("MapFlows magMin=%g magMax=%g\n", NanoVis::magMin, NanoVis::magMax); … … 1041 1041 */ 1042 1042 for (flowPtr = FirstFlow(&iter); flowPtr != NULL; 1043 1044 1045 continue;// Flow exists, but no data has1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1043 flowPtr = NextFlow(&iter)) { 1044 if (!flowPtr->isDataLoaded()) { 1045 continue; // Flow exists, but no data has 1046 // been loaded yet. 1047 } 1048 if (flowPtr->visible()) { 1049 flowPtr->InitializeParticles(); 1050 } 1051 if (!flowPtr->ScaleVectorField()) { 1052 return false; 1053 } 1054 // FIXME: This doesn't work when there is more than one flow. 1055 licRenderer->set_offset(flowPtr->GetRelativePosition()); 1056 1056 NanoVis::velocityArrowsSlice->slicePos(flowPtr->GetRelativePosition()); 1057 1057 … … 1067 1067 FlowIterator iter; 1068 1068 for (flowPtr = FirstFlow(&iter); flowPtr != NULL; 1069 1070 1071 1072 1069 flowPtr = NextFlow(&iter)) { 1070 if ((flowPtr->isDataLoaded()) && (flowPtr->visible())) { 1071 flowPtr->Render(); 1072 } 1073 1073 } 1074 1074 flags &= ~REDRAW_PENDING; … … 1082 1082 1083 1083 if (licRenderer->active()) { 1084 1084 NanoVis::licRenderer->reset(); 1085 1085 } 1086 1086 for (flowPtr = FirstFlow(&iter); flowPtr != NULL; 1087 1088 1089 1090 1087 flowPtr = NextFlow(&iter)) { 1088 if ((flowPtr->isDataLoaded()) && (flowPtr->visible())) { 1089 flowPtr->ResetParticles(); 1090 } 1091 1091 } 1092 1092 } … … 1098 1098 FlowIterator iter; 1099 1099 for (flowPtr = FirstFlow(&iter); flowPtr != NULL; 1100 1101 1102 1103 1100 flowPtr = NextFlow(&iter)) { 1101 if ((flowPtr->isDataLoaded()) && (flowPtr->visible())) { 1102 flowPtr->Advect(); 1103 } 1104 1104 } 1105 1105 } … … 1110 1110 * AxisSwitchProc -- 1111 1111 * 1112 * 1113 * 1112 * Convert a Tcl_Obj representing the label of a child node into its 1113 * integer node id. 1114 1114 * 1115 1115 * Results: 1116 * 1116 * The return value is a standard Tcl result. 1117 1117 * 1118 1118 *--------------------------------------------------------------------------- … … 1121 1121 static int 1122 1122 AxisSwitchProc( 1123 ClientData clientData, 1124 1125 Tcl_Interp *interp, 1126 const char *switchName, 1127 Tcl_Obj *objPtr, 1128 char *record, 1129 int offset, 1130 int flags) 1123 ClientData clientData, /* Flag indicating if the node is considered 1124 * before or after the insertion position. */ 1125 Tcl_Interp *interp, /* Interpreter to send results back to */ 1126 const char *switchName, /* Not used. */ 1127 Tcl_Obj *objPtr, /* String representation */ 1128 char *record, /* Structure record */ 1129 int offset, /* Not used. */ 1130 int flags) /* Not used. */ 1131 1131 { 1132 1132 const char *string = Tcl_GetString(objPtr); 1133 1133 if (string[1] == '\0') { 1134 1134 FlowCmd::SliceAxis *axisPtr = (FlowCmd::SliceAxis *)(record + offset); 1135 1135 char c; 1136 1136 c = tolower((unsigned char)string[0]); … … 1157 1157 * ColorSwitchProc -- 1158 1158 * 1159 * 1160 * 1159 * Convert a Tcl_Obj representing the label of a list of four color 1160 * components in to a RGBA color value. 1161 1161 * 1162 1162 * Results: 1163 * 1163 * The return value is a standard Tcl result. 1164 1164 * 1165 1165 *--------------------------------------------------------------------------- … … 1168 1168 static int 1169 1169 ColorSwitchProc( 1170 ClientData clientData, 1171 1172 Tcl_Interp *interp, 1173 const char *switchName, 1174 Tcl_Obj *objPtr, 1175 char *record, 1176 int offset, 1177 int flags) 1170 ClientData clientData, /* Flag indicating if the node is considered 1171 * before or after the insertion position. */ 1172 Tcl_Interp *interp, /* Interpreter to send results back to */ 1173 const char *switchName, /* Not used. */ 1174 Tcl_Obj *objPtr, /* String representation */ 1175 char *record, /* Structure record */ 1176 int offset, /* Not used. */ 1177 int flags) /* Not used. */ 1178 1178 { 1179 1179 Tcl_Obj **objv; … … 1182 1182 1183 1183 if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) != TCL_OK) { 1184 1184 return TCL_ERROR; 1185 1185 } 1186 1186 if ((objc < 3) || (objc > 4)) { 1187 1188 1189 1187 Tcl_AppendResult(interp, "wrong # of elements in color definition", 1188 (char *)NULL); 1189 return TCL_ERROR; 1190 1190 } 1191 1191 float values[4]; … … 1193 1193 values[3] = 1.0f; 1194 1194 for (i = 0; i < objc; i++) { 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 } 1195 float value; 1196 1197 if (GetFloatFromObj(interp, objv[i], &value) != TCL_OK) { 1198 return TCL_ERROR; 1199 } 1200 if ((value < 0.0) || (value > 1.0)) { 1201 Tcl_AppendResult(interp, "bad component value in \"", 1202 Tcl_GetString(objPtr), "\": color values must be [0..1]", 1203 (char *)NULL); 1204 return TCL_ERROR; 1205 } 1206 values[i] = value; 1207 } 1208 1208 colorPtr->r = values[0]; 1209 1209 colorPtr->g = values[1]; … … 1218 1218 * PointSwitchProc -- 1219 1219 * 1220 * 1221 * 1220 * Convert a Tcl_Obj representing the a 3-D coordinate into 1221 * a point. 1222 1222 * 1223 1223 * Results: 1224 * 1224 * The return value is a standard Tcl result. 1225 1225 * 1226 1226 *--------------------------------------------------------------------------- … … 1229 1229 static int 1230 1230 PointSwitchProc( 1231 ClientData clientData, 1232 1233 Tcl_Interp *interp, 1234 const char *switchName, 1235 Tcl_Obj *objPtr, 1236 char *record, 1237 int offset, 1238 int flags) 1231 ClientData clientData, /* Flag indicating if the node is considered 1232 * before or after the insertion position. */ 1233 Tcl_Interp *interp, /* Interpreter to send results back to */ 1234 const char *switchName, /* Not used. */ 1235 Tcl_Obj *objPtr, /* String representation */ 1236 char *record, /* Structure record */ 1237 int offset, /* Not used. */ 1238 int flags) /* Not used. */ 1239 1239 { 1240 1240 FlowPoint *pointPtr = (FlowPoint *)(record + offset); … … 1243 1243 1244 1244 if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) != TCL_OK) { 1245 1245 return TCL_ERROR; 1246 1246 } 1247 1247 if (objc != 3) { 1248 1249 1250 1248 Tcl_AppendResult(interp, "wrong # of elements for box coordinates: " 1249 " should be \"x y z\"", (char *)NULL); 1250 return TCL_ERROR; 1251 1251 } 1252 1252 float values[3]; 1253 1253 int i; 1254 1254 for (i = 0; i < objc; i++) { 1255 1256 1257 1258 1259 1260 1261 } 1255 float value; 1256 1257 if (GetFloatFromObj(interp, objv[i], &value) != TCL_OK) { 1258 return TCL_ERROR; 1259 } 1260 values[i] = value; 1261 } 1262 1262 pointPtr->x = values[0]; 1263 1263 pointPtr->y = values[1]; … … 1271 1271 * PositionSwitchProc -- 1272 1272 * 1273 * 1274 * 1273 * Convert a Tcl_Obj representing the a 3-D coordinate into 1274 * a point. 1275 1275 * 1276 1276 * Results: 1277 * 1277 * The return value is a standard Tcl result. 1278 1278 * 1279 1279 *--------------------------------------------------------------------------- … … 1282 1282 static int 1283 1283 PositionSwitchProc( 1284 ClientData clientData, 1285 1286 Tcl_Interp *interp, 1287 const char *switchName, 1288 Tcl_Obj *objPtr, 1289 char *record, 1290 int offset, 1291 int flags) 1284 ClientData clientData, /* Flag indicating if the node is considered 1285 * before or after the insertion position. */ 1286 Tcl_Interp *interp, /* Interpreter to send results back to */ 1287 const char *switchName, /* Not used. */ 1288 Tcl_Obj *objPtr, /* String representation */ 1289 char *record, /* Structure record */ 1290 int offset, /* Not used. */ 1291 int flags) /* Not used. */ 1292 1292 { 1293 1293 FlowPosition *posPtr = (FlowPosition *)(record + offset); … … 1298 1298 p = strrchr((char *)string, '%'); 1299 1299 if (p == NULL) { 1300 1301 1302 1303 1304 1305 1306 1300 float value; 1301 1302 if (GetFloatFromObj(interp, objPtr, &value) != TCL_OK) { 1303 return TCL_ERROR; 1304 } 1305 posPtr->value = value; 1306 posPtr->flags = ABSPOS; 1307 1307 } else { 1308 1309 1310 1311 1312 1313 1314 1315 1308 double value; 1309 1310 *p = '\0'; 1311 if (Tcl_GetDouble(interp, string, &value) != TCL_OK) { 1312 return TCL_ERROR; 1313 } 1314 posPtr->value = (float)value * 0.01; 1315 posPtr->flags = RELPOS; 1316 1316 } 1317 1317 return TCL_OK; … … 1323 1323 * TransferFunctionSwitchProc -- 1324 1324 * 1325 * 1326 * 1327 * 1325 * Convert a Tcl_Obj representing the transfer function into a 1326 * TransferFunction pointer. The transfer function must have been 1327 * previously defined. 1328 1328 * 1329 1329 * Results: 1330 * 1330 * The return value is a standard Tcl result. 1331 1331 * 1332 1332 *--------------------------------------------------------------------------- … … 1335 1335 static int 1336 1336 TransferFunctionSwitchProc( 1337 ClientData clientData, 1338 1339 Tcl_Interp *interp, 1340 const char *switchName, 1341 Tcl_Obj *objPtr, 1342 char *record, 1343 int offset, 1344 int flags) 1337 ClientData clientData, /* Flag indicating if the node is considered 1338 * before or after the insertion position. */ 1339 Tcl_Interp *interp, /* Interpreter to send results back to */ 1340 const char *switchName, /* Not used. */ 1341 Tcl_Obj *objPtr, /* String representation */ 1342 char *record, /* Structure record */ 1343 int offset, /* Not used. */ 1344 int flags) /* Not used. */ 1345 1345 { 1346 1346 TransferFunction **funcPtrPtr = (TransferFunction **)(record + offset); … … 1361 1361 * VideoFormatSwitchProc -- 1362 1362 * 1363 * 1364 * 1363 * Convert a Tcl_Obj representing the video format into its 1364 * integer id. 1365 1365 * 1366 1366 * Results: 1367 * 1367 * The return value is a standard Tcl result. 1368 1368 * 1369 1369 *--------------------------------------------------------------------------- … … 1372 1372 static int 1373 1373 VideoFormatSwitchProc( 1374 ClientData clientData, 1375 Tcl_Interp *interp, 1376 const char *switchName, 1377 Tcl_Obj *objPtr, 1378 char *record, 1379 int offset, 1380 int flags) 1374 ClientData clientData, /* Not used. */ 1375 Tcl_Interp *interp, /* Interpreter to send results back to */ 1376 const char *switchName, /* Not used. */ 1377 Tcl_Obj *objPtr, /* String representation */ 1378 char *record, /* Structure record */ 1379 int offset, /* Not used. */ 1380 int flags) /* Not used. */ 1381 1381 { 1382 1382 Rappture::AVTranslate::VideoFormats *formatPtr = 1383 1383 (Rappture::AVTranslate::VideoFormats *)(record + offset); 1384 1384 const char *string; 1385 1385 char c; … … 1388 1388 c = string[0]; 1389 1389 if ((c == 'm') && (strcmp(string, "mpeg") == 0)) { 1390 1390 *formatPtr = Rappture::AVTranslate::MPEG1; 1391 1391 } else if ((c == 't') && (strcmp(string, "theora") == 0)) { 1392 1392 *formatPtr = Rappture::AVTranslate::THEORA; 1393 1393 } else if ((c == 'm') && (strcmp(string, "mov") == 0)) { 1394 1394 *formatPtr = Rappture::AVTranslate::QUICKTIME; 1395 1395 } else { 1396 1396 Tcl_AppendResult(interp, "bad video format \"", string, 1397 1397 "\": should be mpeg, theora, or mov", (char*)NULL); 1398 1398 } … … 1402 1402 static int 1403 1403 FlowConfigureOp(ClientData clientData, Tcl_Interp *interp, int objc, 1404 1404 Tcl_Obj *const *objv) 1405 1405 { 1406 1406 FlowCmd *flowPtr = (FlowCmd *)clientData; 1407 1407 1408 1408 if (flowPtr->ParseSwitches(interp, objc - 2, objv + 2) != TCL_OK) { 1409 1409 return TCL_ERROR; 1410 1410 } 1411 1411 NanoVis::EventuallyRedraw(NanoVis::MAP_FLOWS); … … 1415 1415 static int 1416 1416 FlowParticlesAddOp(ClientData clientData, Tcl_Interp *interp, int objc, 1417 1417 Tcl_Obj *const *objv) 1418 1418 { 1419 1419 FlowCmd *flowPtr = (FlowCmd *)clientData; 1420 1420 1421 1421 if (flowPtr->CreateParticles(interp, objv[3]) != TCL_OK) { 1422 1422 return TCL_ERROR; 1423 1423 } 1424 1424 FlowParticles *particlesPtr; 1425 1425 if (flowPtr->GetParticles(interp, objv[3], &particlesPtr) != TCL_OK) { 1426 1426 return TCL_ERROR; 1427 1427 } 1428 1428 if (particlesPtr->ParseSwitches(interp, objc - 4, objv + 4) != TCL_OK) { 1429 1430 1429 delete particlesPtr; 1430 return TCL_ERROR; 1431 1431 } 1432 1432 particlesPtr->Configure(); … … 1438 1438 static int 1439 1439 FlowParticlesConfigureOp(ClientData clientData, Tcl_Interp *interp, int objc, 1440 1440 Tcl_Obj *const *objv) 1441 1441 { 1442 1442 FlowCmd *flowPtr = (FlowCmd *)clientData; … … 1444 1444 FlowParticles *particlesPtr; 1445 1445 if (flowPtr->GetParticles(interp, objv[3], &particlesPtr) != TCL_OK) { 1446 1446 return TCL_ERROR; 1447 1447 } 1448 1448 if (particlesPtr->ParseSwitches(interp, objc - 4, objv + 4) != TCL_OK) { 1449 1449 return TCL_ERROR; 1450 1450 } 1451 1451 particlesPtr->Configure(); … … 1456 1456 static int 1457 1457 FlowParticlesDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc, 1458 1458 Tcl_Obj *const *objv) 1459 1459 { 1460 1460 FlowCmd *flowPtr = (FlowCmd *)clientData; 1461 1461 int i; 1462 1462 for (i = 3; i < objc; i++) { 1463 1464 1465 1466 1467 1463 FlowParticles *particlesPtr; 1464 1465 if (flowPtr->GetParticles(NULL, objv[i], &particlesPtr) == TCL_OK) { 1466 delete particlesPtr; 1467 } 1468 1468 } 1469 1469 NanoVis::EventuallyRedraw(); … … 1473 1473 static int 1474 1474 FlowParticlesNamesOp(ClientData clientData, Tcl_Interp *interp, int objc, 1475 1475 Tcl_Obj *const *objv) 1476 1476 { 1477 1477 FlowCmd *flowPtr = (FlowCmd *)clientData; … … 1481 1481 FlowParticles *particlesPtr; 1482 1482 for (particlesPtr = flowPtr->FirstParticles(&iter); particlesPtr != NULL; 1483 1484 1485 1486 1487 1483 particlesPtr = flowPtr->NextParticles(&iter)) { 1484 Tcl_Obj *objPtr; 1485 1486 objPtr = Tcl_NewStringObj(particlesPtr->name(), -1); 1487 Tcl_ListObjAppendElement(interp, listObjPtr, objPtr); 1488 1488 } 1489 1489 Tcl_SetObjResult(interp, listObjPtr); … … 1496 1496 * FlowParticlesObjCmd -- 1497 1497 * 1498 * 1499 * 1498 * This procedure is invoked to process commands on behalf of the flow 1499 * object. 1500 1500 * 1501 1501 * Results: 1502 * 1502 * A standard Tcl result. 1503 1503 * 1504 1504 * Side effects: 1505 * 1505 * See the user documentation. 1506 1506 * 1507 1507 * $flow particles oper $name … … 1511 1511 {"add", 1, FlowParticlesAddOp, 4, 0, "name ?switches?",}, 1512 1512 {"configure", 1, FlowParticlesConfigureOp, 4, 0, "name ?switches?",}, 1513 {"delete", 1513 {"delete", 1, FlowParticlesDeleteOp, 4, 0, "?name...?"}, 1514 1514 {"names", 1, FlowParticlesNamesOp, 3, 4, "?pattern?"}, 1515 1515 }; … … 1519 1519 static int 1520 1520 FlowParticlesOp(ClientData clientData, Tcl_Interp *interp, int objc, 1521 1521 Tcl_Obj *const *objv) 1522 1522 { 1523 1523 Tcl_ObjCmdProc *proc; 1524 1524 proc = Rappture::GetOpFromObj(interp, nFlowParticlesOps, flowParticlesOps, 1525 1525 Rappture::CMDSPEC_ARG2, objc, objv, 0); 1526 1526 if (proc == NULL) { 1527 1527 return TCL_ERROR; 1528 1528 } 1529 1529 FlowCmd *flowPtr = (FlowCmd *)clientData; … … 1537 1537 static int 1538 1538 FlowBoxAddOp(ClientData clientData, Tcl_Interp *interp, int objc, 1539 1539 Tcl_Obj *const *objv) 1540 1540 { 1541 1541 FlowCmd *flowPtr = (FlowCmd *)clientData; 1542 1542 1543 1543 if (flowPtr->CreateBox(interp, objv[3]) != TCL_OK) { 1544 1544 return TCL_ERROR; 1545 1545 } 1546 1546 FlowBox *boxPtr; 1547 1547 if (flowPtr->GetBox(interp, objv[3], &boxPtr) != TCL_OK) { 1548 1548 return TCL_ERROR; 1549 1549 } 1550 1550 if (boxPtr->ParseSwitches(interp, objc - 4, objv + 4) != TCL_OK) { 1551 1552 1551 delete boxPtr; 1552 return TCL_ERROR; 1553 1553 } 1554 1554 NanoVis::EventuallyRedraw(); … … 1559 1559 static int 1560 1560 FlowBoxDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc, 1561 1561 Tcl_Obj *const *objv) 1562 1562 { 1563 1563 FlowCmd *flowPtr = (FlowCmd *)clientData; 1564 1564 int i; 1565 1565 for (i = 3; i < objc; i++) { 1566 1567 1568 1569 1570 1566 FlowBox *boxPtr; 1567 1568 if (flowPtr->GetBox(NULL, objv[i], &boxPtr) == TCL_OK) { 1569 delete boxPtr; 1570 } 1571 1571 } 1572 1572 NanoVis::EventuallyRedraw(); … … 1584 1584 FlowBox *boxPtr; 1585 1585 for (boxPtr = flowPtr->FirstBox(&iter); boxPtr != NULL; 1586 1587 1588 1589 1590 1586 boxPtr = flowPtr->NextBox(&iter)) { 1587 Tcl_Obj *objPtr; 1588 1589 objPtr = Tcl_NewStringObj(boxPtr->name(), -1); 1590 Tcl_ListObjAppendElement(interp, listObjPtr, objPtr); 1591 1591 } 1592 1592 Tcl_SetObjResult(interp, listObjPtr); … … 1596 1596 static int 1597 1597 FlowBoxConfigureOp(ClientData clientData, Tcl_Interp *interp, int objc, 1598 1598 Tcl_Obj *const *objv) 1599 1599 { 1600 1600 FlowCmd *flowPtr = (FlowCmd *)clientData; … … 1602 1602 FlowBox *boxPtr; 1603 1603 if (flowPtr->GetBox(interp, objv[3], &boxPtr) != TCL_OK) { 1604 1604 return TCL_ERROR; 1605 1605 } 1606 1606 if (boxPtr->ParseSwitches(interp, objc - 4, objv + 4) != TCL_OK) { 1607 1607 return TCL_ERROR; 1608 1608 } 1609 1609 NanoVis::EventuallyRedraw(); … … 1616 1616 * FlowBoxOp-- 1617 1617 * 1618 * 1619 * 1618 * This procedure is invoked to process commands on behalf of the flow 1619 * object. 1620 1620 * 1621 1621 * Results: 1622 * 1622 * A standard Tcl result. 1623 1623 * 1624 1624 * Side effects: 1625 * 1625 * See the user documentation. 1626 1626 * 1627 1627 *--------------------------------------------------------------------------- … … 1630 1630 {"add", 1, FlowBoxAddOp, 4, 0, "name ?switches?",}, 1631 1631 {"configure", 1, FlowBoxConfigureOp, 4, 0, "name ?switches?",}, 1632 {"delete", 1632 {"delete", 1, FlowBoxDeleteOp, 3, 0, "?name...?"}, 1633 1633 {"names", 1, FlowBoxNamesOp, 3, 0, "?pattern?"}, 1634 1634 }; … … 1638 1638 static int 1639 1639 FlowBoxOp(ClientData clientData, Tcl_Interp *interp, int objc, 1640 1640 Tcl_Obj *const *objv) 1641 1641 { 1642 1642 Tcl_ObjCmdProc *proc; 1643 1643 proc = Rappture::GetOpFromObj(interp, nFlowBoxOps, flowBoxOps, 1644 1644 Rappture::CMDSPEC_ARG2, objc, objv, 0); 1645 1645 if (proc == NULL) { 1646 1646 return TCL_ERROR; 1647 1647 } 1648 1648 FlowCmd *flowPtr = (FlowCmd *)clientData; … … 1667 1667 static int 1668 1668 FlowLegendOp(ClientData clientData, Tcl_Interp *interp, int objc, 1669 1669 Tcl_Obj *const *objv) 1670 1670 { 1671 1671 FlowCmd *flowPtr = (FlowCmd *)clientData; … … 1698 1698 * FlowInstObjCmd -- 1699 1699 * 1700 * 1701 * 1700 * This procedure is invoked to process commands on behalf of the flow 1701 * object. 1702 1702 * 1703 1703 * Results: 1704 * 1704 * A standard Tcl result. 1705 1705 * 1706 1706 * Side effects: 1707 * 1707 * See the user documentation. 1708 1708 * 1709 1709 *--------------------------------------------------------------------------- … … 1712 1712 {"box", 1, FlowBoxOp, 2, 0, "oper ?args?"}, 1713 1713 {"configure", 1, FlowConfigureOp, 2, 0, "?switches?"}, 1714 {"data", 1714 {"data", 1, FlowDataOp, 2, 0, "oper ?args?"}, 1715 1715 {"legend", 1, FlowLegendOp, 4, 4, "w h"}, 1716 1716 {"particles", 1, FlowParticlesOp, 2, 0, "oper ?args?"} … … 1720 1720 static int 1721 1721 FlowInstObjCmd(ClientData clientData, Tcl_Interp *interp, int objc, 1722 1722 Tcl_Obj *const *objv) 1723 1723 { 1724 1724 Tcl_ObjCmdProc *proc; 1725 1725 proc = Rappture::GetOpFromObj(interp, nFlowInstOps, flowInstOps, 1726 1726 Rappture::CMDSPEC_ARG1, objc, objv, 0); 1727 1727 if (proc == NULL) { 1728 1728 return TCL_ERROR; 1729 1729 } 1730 1730 assert(CheckGL(AT)); … … 1742 1742 * FlowInstDeleteProc -- 1743 1743 * 1744 * 1745 * 1744 * Deletes the command associated with the tree. This is called only 1745 * when the command associated with the tree is destroyed. 1746 1746 * 1747 1747 * Results: 1748 * 1748 * None. 1749 1749 * 1750 1750 *--------------------------------------------------------------------------- … … 1767 1767 static int 1768 1768 FlowAddOp(ClientData clientData, Tcl_Interp *interp, int objc, 1769 1769 Tcl_Obj *const *objv) 1770 1770 { 1771 1771 if (NanoVis::CreateFlow(interp, objv[2]) != TCL_OK) { 1772 1772 return TCL_ERROR; 1773 1773 } 1774 1774 FlowCmd *flowPtr; 1775 1775 if (NanoVis::GetFlow(interp, objv[2], &flowPtr) != TCL_OK) { 1776 1776 return TCL_ERROR; 1777 1777 } 1778 1778 if (flowPtr->ParseSwitches(interp, objc - 3, objv + 3) != TCL_OK) { 1779 1780 1779 Tcl_DeleteCommand(interp, flowPtr->name()); 1780 return TCL_ERROR; 1781 1781 } 1782 1782 Tcl_SetObjResult(interp, objv[2]); … … 1795 1795 static int 1796 1796 FlowDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc, 1797 1797 Tcl_Obj *const *objv) 1798 1798 { 1799 1799 int i; 1800 1800 1801 1801 for (i = 2; i < objc; i++) { 1802 1803 1804 1805 1806 1807 1802 FlowCmd *flowPtr; 1803 1804 if (NanoVis::GetFlow(interp, objv[i], &flowPtr) != TCL_OK) { 1805 return TCL_ERROR; 1806 } 1807 Tcl_DeleteCommand(interp, flowPtr->name()); 1808 1808 } 1809 1809 NanoVis::EventuallyRedraw(NanoVis::MAP_FLOWS); … … 1821 1821 static int 1822 1822 FlowExistsOp(ClientData clientData, Tcl_Interp *interp, int objc, 1823 1823 Tcl_Obj *const *objv) 1824 1824 { 1825 1825 bool value; … … 1828 1828 value = false; 1829 1829 if (NanoVis::GetFlow(NULL, objv[2], &flowPtr) == TCL_OK) { 1830 1830 value = true; 1831 1831 } 1832 1832 Tcl_SetBooleanObj(Tcl_GetObjResult(interp), (int)value); … … 1839 1839 * FlowGotoOp -- 1840 1840 * 1841 * 1841 * flow goto number 1842 1842 * 1843 1843 *--------------------------------------------------------------------------- … … 1852 1852 } 1853 1853 if ((nSteps < 0) || (nSteps > SHRT_MAX)) { 1854 1855 1856 1854 Tcl_AppendResult(interp, "flow goto: bad # of steps \"", 1855 Tcl_GetString(objv[2]), "\"", (char *)NULL); 1856 return TCL_ERROR; 1857 1857 } 1858 1858 NanoVis::ResetFlows(); 1859 1859 if (NanoVis::flags & NanoVis::MAP_FLOWS) { 1860 1860 NanoVis::MapFlows(); 1861 1861 } 1862 1862 int i; 1863 1863 NanoVis::AdvectFlows(); 1864 1864 for (i = 0; i < nSteps; i++) { 1865 1866 1867 1868 1865 if (NanoVis::licRenderer->active()) { 1866 NanoVis::licRenderer->convolve(); 1867 } 1868 NanoVis::AdvectFlows(); 1869 1869 } 1870 1870 NanoVis::EventuallyRedraw(); … … 1882 1882 static int 1883 1883 FlowNamesOp(ClientData clientData, Tcl_Interp *interp, int objc, 1884 1884 Tcl_Obj *const *objv) 1885 1885 { 1886 1886 Tcl_Obj *listObjPtr; … … 1889 1889 FlowIterator iter; 1890 1890 for (flowPtr = NanoVis::FirstFlow(&iter); flowPtr != NULL; 1891 1892 1893 1894 1895 1891 flowPtr = NanoVis::NextFlow(&iter)) { 1892 Tcl_Obj *objPtr; 1893 1894 objPtr = Tcl_NewStringObj(flowPtr->name(), -1); 1895 Tcl_ListObjAppendElement(interp, listObjPtr, objPtr); 1896 1896 } 1897 1897 Tcl_SetObjResult(interp, listObjPtr); … … 1905 1905 assert(NanoVis::licRenderer != NULL); 1906 1906 if (NanoVis::flags & NanoVis::MAP_FLOWS) { 1907 1907 NanoVis::MapFlows(); 1908 1908 } 1909 1909 NanoVis::EventuallyRedraw(); … … 1922 1922 1923 1923 struct FlowVideoValues { 1924 float frameRate; 1925 int bitRate; 1926 int width, height; 1924 float frameRate; /* Frame rate */ 1925 int bitRate; /* Video bitrate */ 1926 int width, height; /* Dimensions of video frame. */ 1927 1927 int nFrames; 1928 1928 Rappture::AVTranslate::VideoFormats format; … … 1936 1936 Rappture::SwitchSpec FlowCmd::videoSwitches[] = { 1937 1937 {Rappture::SWITCH_FLOAT, "-bitrate", "value", 1938 1938 offsetof(FlowVideoValues, bitRate), 0}, 1939 1939 {Rappture::SWITCH_CUSTOM, "-format", "string", 1940 1940 offsetof(FlowVideoValues, format), 0, 0, &videoFormatSwitch}, 1941 1941 {Rappture::SWITCH_FLOAT, "-framerate", "value", 1942 1942 offsetof(FlowVideoValues, frameRate), 0}, 1943 1943 {Rappture::SWITCH_INT, "-height", "integer", 1944 1944 offsetof(FlowVideoValues, height), 0}, 1945 1945 {Rappture::SWITCH_INT, "-numframes", "count", 1946 1946 offsetof(FlowVideoValues, nFrames), 0}, 1947 1947 {Rappture::SWITCH_INT, "-width", "integer", 1948 1948 offsetof(FlowVideoValues, width), 0}, 1949 1949 {Rappture::SWITCH_END} 1950 1950 }; … … 1952 1952 static int 1953 1953 FlowVideoOp(ClientData clientData, Tcl_Interp *interp, int objc, 1954 1954 Tcl_Obj *const *objv) 1955 1955 { 1956 1956 struct pollfd pollResults; … … 1960 1960 pollResults.events = POLLIN; 1961 1961 1962 #define PENDING_TIMEOUT 1962 #define PENDING_TIMEOUT 10 /* milliseconds. */ 1963 1963 timeout = PENDING_TIMEOUT; 1964 1964 … … 1967 1967 1968 1968 token = Tcl_GetString(objv[2]); 1969 values.frameRate = 25.0f; 1970 values.bitRate = 6.0e+6f; 1969 values.frameRate = 25.0f; // Default frame rate 25 fps 1970 values.bitRate = 6.0e+6f; // Default video bit rate. 1971 1971 values.width = NanoVis::win_width; 1972 1972 values.height = NanoVis::win_height; … … 1974 1974 values.format = Rappture::AVTranslate::MPEG1; 1975 1975 if (Rappture::ParseSwitches(interp, FlowCmd::videoSwitches, 1976 1977 1976 objc - 3, objv + 3, &values, SWITCH_DEFAULTS) < 0) { 1977 return TCL_ERROR; 1978 1978 } 1979 1979 if ((values.width < 0) || (values.width > SHRT_MAX) || 1980 1981 1982 1980 (values.height < 0) || (values.height > SHRT_MAX)) { 1981 Tcl_AppendResult(interp, "bad dimensions for video", (char *)NULL); 1982 return TCL_ERROR; 1983 1983 } 1984 1984 if ((values.frameRate < 0.0f) || (values.frameRate > 30.0f)) { 1985 1986 1985 Tcl_AppendResult(interp, "bad frame rate.", (char *)NULL); 1986 return TCL_ERROR; 1987 1987 } 1988 1988 if (values.bitRate < 0.0f) { 1989 1990 1989 Tcl_AppendResult(interp, "bad bit rate.", (char *)NULL); 1990 return TCL_ERROR; 1991 1991 } 1992 1992 if (NanoVis::licRenderer == NULL) { 1993 1994 1993 Tcl_AppendResult(interp, "no lic renderer.", (char *)NULL); 1994 return TCL_ERROR; 1995 1995 } 1996 1996 // Save the old dimensions of the offscreen buffer. … … 2004 2004 2005 2005 Rappture::AVTranslate movie(values.width, values.height, values.bitRate, 2006 2006 values.frameRate); 2007 2007 char tmpFileName[200]; 2008 2008 sprintf(tmpFileName,"/tmp/flow%d.mpeg", getpid()); 2009 2009 if (!movie.init(context, tmpFileName)) { 2010 2010 Tcl_AppendResult(interp, "can't initialized movie \"", tmpFileName, 2011 2012 2011 "\": ", context.remark(), (char *)NULL); 2012 return TCL_ERROR; 2013 2013 } 2014 2014 if ((values.width != oldWidth) || (values.height != oldHeight)) { 2015 2016 2015 // Resize to the requested size. 2016 NanoVis::resize_offscreen_buffer(values.width, values.height); 2017 2017 } 2018 2018 // Now compute the line padding for the offscreen buffer. … … 2024 2024 bool canceled = false; 2025 2025 for (int i = 1; i <= values.nFrames; i++) { 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2026 if (((i & 0xF) == 0) && (poll(&pollResults, 1, 0) > 0)) { 2027 /* If there's another command on stdin, that means the client is 2028 * trying to cancel this operation. */ 2029 canceled = true; 2030 break; 2031 } 2032 if (NanoVis::licRenderer->active()) { 2033 NanoVis::licRenderer->convolve(); 2034 } 2035 NanoVis::AdvectFlows(); 2036 NanoVis::offscreen_buffer_capture(); 2037 2037 NanoVis::display(); 2038 2038 NanoVis::read_screen(); … … 2043 2043 Trace("FLOW end\n"); 2044 2044 if (!canceled) { 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2045 Rappture::Buffer data; 2046 2047 /* FIXME: find a way to get the data from the movie object as a 2048 * void* */ 2049 if (!data.load(context, tmpFileName)) { 2050 Tcl_AppendResult(interp, "can't load data from temporary file \"", 2051 tmpFileName, "\": ", context.remark(), (char *)NULL); 2052 return TCL_ERROR; 2053 } 2054 2055 char command[200]; 2056 sprintf(command,"nv>image -bytes %lu -type movie -token \"%s\"\n", 2057 (unsigned long)data.size(), token); 2058 NanoVis::sendDataToClient(command, data.bytes(), data.size()); 2059 2059 } 2060 2060 if ((values.width != oldWidth) || (values.height != oldHeight)) { 2061 2061 NanoVis::resize_offscreen_buffer(oldWidth, oldHeight); 2062 2062 } 2063 2063 NanoVis::ResetFlows(); 2064 2064 if (unlink(tmpFileName) != 0) { 2065 2065 Tcl_AppendResult(interp, "can't unlink temporary movie file \"", 2066 2067 2066 tmpFileName, "\": ", Tcl_PosixError(interp), (char *)NULL); 2067 return TCL_ERROR; 2068 2068 } 2069 2069 return TCL_OK; … … 2093 2093 static int 2094 2094 FlowCmdProc(ClientData clientData, Tcl_Interp *interp, int objc, 2095 2095 Tcl_Obj *const *objv) 2096 2096 { 2097 2097 Tcl_ObjCmdProc *proc; 2098 2098 2099 2099 proc = Rappture::GetOpFromObj(interp, nFlowCmdOps, flowCmdOps, 2100 2100 Rappture::CMDSPEC_ARG1, objc, objv, 0); 2101 2101 if (proc == NULL) { 2102 2102 return TCL_ERROR; 2103 2103 } 2104 2104 return (*proc) (clientData, interp, objc, objv); … … 2110 2110 * FlowCmdInitProc -- 2111 2111 * 2112 * 2112 * This procedure is invoked to initialize the "tree" command. 2113 2113 * 2114 2114 * Results: 2115 * 2115 * None. 2116 2116 * 2117 2117 * Side effects: 2118 * 2119 * 2118 * Creates the new command and adds a new entry into a global Tcl 2119 * associative array. 2120 2120 * 2121 2121 *--------------------------------------------------------------------------- … … 2141 2141 if (line == endPtr) { 2142 2142 vtkErrorMacro(<<"Premature EOF reading first line! " << " for file: " 2143 2143 << (this->FileName?this->FileName:"(Null FileName)")); 2144 2144 return false; 2145 2145 } 2146 2146 if (sscanf(line, "# vtk DataFile Version %s", version) != 1) { 2147 2147 vtkErrorMacro(<< "Unrecognized file type: "<< line << " for file: " 2148 2148 << (this->FileName?this->FileName:"(Null FileName)")); 2149 2149 return false; 2150 2150 } … … 2153 2153 if (line == endPtr) { 2154 2154 vtkErrorMacro(<<"Premature EOF reading title! " << " for file: " 2155 2155 << (this->FileName?this->FileName:"(Null FileName)")); 2156 2156 return false; 2157 2157 } … … 2166 2166 if (line == endPtr) { 2167 2167 vtkErrorMacro(<<"Premature EOF reading file type!" << " for file: " 2168 2168 << (this->FileName?this->FileName:"(Null FileName)")); 2169 2169 return false; 2170 2170 } … … 2176 2176 } else { 2177 2177 vtkErrorMacro(<< "Unrecognized file type: "<< line << " for file: " 2178 2178 << (this->FileName?this->FileName:"(Null FileName)")); 2179 2179 _fileType = 0; 2180 2180 return false; … … 2185 2185 if (line == endPtr) { 2186 2186 vtkErrorMacro(<<"Premature EOF reading file type!" << " for file: " 2187 2187 << (this->FileName?this->FileName:"(Null FileName)")); 2188 2188 return false; 2189 2189 } … … 2193 2193 line = getline(&p, endPtr); 2194 2194 if (line == endPtr) { 2195 2195 // EOF 2196 2196 } 2197 2197 type = GetWord(line, &endPtr); 2198 2198 if (strncasecmp(word, "structured_grid", 15) == 0) { 2199 2200 2199 vtkErrorMacro(<< "Cannot read dataset type: " << line); 2200 return 1; 2201 2201 } 2202 2202 // Read keyword and dimensions -
trunk/packages/vizservers/nanovis/RpAVTranslate.h
r1825 r1850 53 53 size_t _height; 54 54 size_t _bitRate; 55 float _frameRate; 55 float _frameRate; // frames/seconds 56 56 size_t _videoOutbufSize; 57 57 uint8_t *_videoOutbuf; 58 58 59 59 size_t width(void) { 60 60 return _width; 61 61 } 62 62 void width(size_t width) { 63 63 _width = width; 64 64 } 65 65 size_t height(void) { 66 66 return _width; 67 67 } 68 68 void height(size_t width) { 69 69 _width = width; 70 70 } 71 71 size_t bitRate(void) { 72 72 return _bitRate; 73 73 } 74 74 void bitRate(size_t bitRate) { 75 75 _bitRate = bitRate; 76 76 } 77 77 float frameRate(void) { 78 78 return _frameRate; 79 79 } 80 80 void frameRate(size_t frameRate) { 81 81 _frameRate = frameRate; 82 82 } 83 83 AVOutputFormat *_fmtPtr; -
trunk/src/core/RpSimpleBuffer.h
r1560 r1850 749 749 750 750 /** 751 * Read data from the buffer into a memory location provided by caller751 * Move the internal position tracker to the beginning of the buffer. 752 752 */ 753 753 template<class T> -
trunk/src/objects/RpMediaPlayer.cc
r1848 r1850 218 218 219 219 // Save the frame to the SimpleBuffer object 220 __frame2ppm(b[frameCount]); 220 // FIXME: 221 // should be b[frameCount] but operator[] was 222 // overloaded in Rappture::SimpleBuffer, and I 223 // think it is causing problems 224 __frame2ppm(*b+frameCount); 221 225 frameCount++; 222 226 }
Note: See TracChangeset
for help on using the changeset viewer.