Changeset 3805
- Timestamp:
- Jul 17, 2013, 1:34:42 AM (11 years ago)
- Location:
- branches/1.3/gui/apps
- Files:
-
- 2 added
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.3/gui/apps/vtkheightmap-test
r3177 r3805 2 2 # -*- mode: Tcl -*- 3 3 # ---------------------------------------------------------------------- 4 # TEST PROGRAM for Vtk ContourViewer4 # TEST PROGRAM for VtkHeightmapViewer 5 5 # 6 6 # This program is a test harness for the VtkVis visualization … … 78 78 Rappture::Field::constructor [Rappture::library standard] "" 79 79 } { 80 set _reader [vtkDataSetReader $this-xvtkDataSetReader] 81 $_reader SetFileName [lindex $args 0] 82 $_reader Update 83 set _data [$_reader GetOutput] 84 } 85 destructor { 86 rename _data "" 87 rename _reader "" 88 } 80 set _data [lindex $args 0] 81 GetTypeAndSize $_cname 82 GetAssociation $_cname 83 ReadVtkDataSet $_cname $_data 84 set _type [lindex $args 1] 85 } 86 89 87 public method components {args} { 88 Rappture::getopts args params { 89 flag what -name default 90 flag what -dimensions 91 flag what -style 92 flag what -particles 93 flag what -flow 94 flag what -box 95 } 96 if { $params(what) == "-dimensions" } { 97 return "${_dim}D" 98 } 90 99 if {[llength $args] == 0} { 91 return "one"100 return $_cname 92 101 } 93 102 return "" 94 103 } 95 public method mesh {args} { 96 switch -- [$_data GetClassName] { 97 vtkPolyData { 98 if {[$_data GetNumberOfCells] > 0} { 99 return $_data 100 } else { 101 return [$_data GetPoints] 102 } 103 } 104 vtkStructuredPoints - 105 vtkUniformGrid - 106 vtkImageData { 107 foreach { x1 y1 z1 } [$_data GetOrigin] break 108 foreach { xN yN zN } [$_data GetDimensions] break 109 foreach { xS yS zS } [$_data GetSpacing] break 110 set x2 [expr {$x1 + $xN * $xS}] 111 set y2 [expr {$x1 + $yN * $yS}] 112 set z2 [expr {$x1 + $zN * $zS}] 113 if {$zN == 1} { 114 lappend out $x1 $x2 $xN $y1 $y2 $yN 115 } else { 116 lappend out $x1 $x2 $xN $y1 $y2 $yN $z1 $z2 $zN 117 } 118 return $out 119 } 120 default { 121 return $_data 122 } 123 } 124 } 125 public method isunirect2d {args} { 126 if {[$_data GetClassName] != "vtkImageData" && 127 [$_data GetClassName] != "vtkStructuredPoints" && 128 [$_data GetClassName] != "vtkUniformGrid"} { 129 return 0 130 } 131 foreach { xN yN zN } [$_data GetDimensions] break 132 if {$zN == 1} { 133 return 1 134 } else { 135 return 0 136 } 137 } 138 public method isunirect3d {args} { 139 if {[$_data GetClassName] != "vtkImageData" && 140 [$_data GetClassName] != "vtkStructuredPoints" && 141 [$_data GetClassName] != "vtkUniformGrid"} { 142 return 0 143 } 144 foreach { xN yN zN } [$_data GetDimensions] break 145 if {$zN > 1} { 146 return 1 147 } else { 148 return 0 149 } 104 public method isvalid {} { 105 return 1 150 106 } 151 107 public method data {args} { 152 return [values $args] 108 return $_data 109 } 110 public method vtkdata {args} { 111 return $_data 153 112 } 154 113 public method values {args} { 155 set dataAttrs [$_data GetPointData] 156 if {"" == $dataAttrs} { 157 puts stderr "No point data" 158 return "" 159 } 160 set scalarArr [$dataAttrs GetScalars] 161 if {"" == $scalarArr} { 162 for {set i 0} {$i < [$dataAttrs GetNumberOfArrays]} {incr i} { 163 if {[[$dataAttrs GetArray $i] GetNumberOfComponents] == 1} { 164 $dataAttrs SetActiveScalars [$dataAttrs GetArrayName $i] 165 puts stderr "Set scalars to '[$dataAttrs GetArrayName $i]'" 166 break 167 } 168 } 169 set scalarArr [$dataAttrs GetScalars] 170 if {"" == $scalarArr} { 171 puts stderr "No scalar point data" 172 return "" 173 } 174 } 175 if {[isunirect2d] || [isunirect3d]} { 176 for {set i 0} {$i < [$scalarArr GetNumberOfTuples]} {incr i} { 177 lappend out [$scalarArr GetComponent $i 0] 178 } 179 return $out 180 } 181 return $scalarArr 182 } 183 public method limits {which} { 184 foreach { xMin xMax yMin yMax zMin zMax} [$_data GetBounds] break 185 set min "" 186 set max "" 187 188 switch -- $which { 189 x - xlin - xlog { 190 set min $xMin 191 set max $xMax 192 set axis "xaxis" 193 } 194 y - ylin - ylog { 195 set min $yMin 196 set max $yMax 197 set axis "yaxis" 198 } 199 z - zlin - zlog { 200 set min $zMin 201 set max $zMax 202 set axis "zaxis" 203 } 204 v - vlin - vlog { 205 foreach { min max } [$_data GetScalarRange] break 206 set axis "vaxis" 207 } 208 default { 209 error "unknown axis description \"$which\"" 210 } 211 } 212 return [list $min $max] 114 return $_data 115 } 116 public method style {args} { 117 return "" 213 118 } 214 119 public method hints {args} { 215 120 return "" 216 121 } 217 122 public method type {args} { 123 return $_type 124 } 125 public method viewer {args} { 126 return "contour" 127 } 128 129 private variable _cname "one" 218 130 private variable _data "" 219 private variable _ reader""131 private variable _type "" 220 132 } 221 133 … … 229 141 global widgets 230 142 231 set file [tk_getOpenFile -title "Open VTK File"] 232 if {"" != $file} { 233 set obj [visData #auto $file] 143 set file [tk_getOpenFile -title "Open VTK File As Contour"] 144 if {"" != $file && [catch { 145 set fid [open $file r] 146 fconfigure $fid -translation binary -encoding binary 147 set info [read $fid] 148 close $fid 149 }] == 0} { 150 set obj [visData #auto $info "vtk"] 234 151 $widgets(vtkheightmapviewer) add $obj 152 $widgets(vtkheightmapviewer) scale $obj 235 153 } 236 154 } -
branches/1.3/gui/apps/vtkstreamlines-test
r3177 r3805 78 78 } { 79 79 set _data [lindex $args 0] 80 GetTypeAndSize $_cname 81 GetAssociation $_cname 82 ReadVtkDataSet $_cname $_data 80 83 set _type [lindex $args 1] 81 84 } 82 85 83 86 public method components {args} { 87 Rappture::getopts args params { 88 flag what -name default 89 flag what -dimensions 90 flag what -style 91 flag what -particles 92 flag what -flow 93 flag what -box 94 } 95 if { $params(what) == "-dimensions" } { 96 return "${_dim}D" 97 } 84 98 if {[llength $args] == 0} { 85 return "one"99 return $_cname 86 100 } 87 101 return "" 88 102 } 89 public method blob {args} {90 return $_data103 public method isvalid {} { 104 return 1 91 105 } 92 106 public method data {args} { 93 107 return $_data 94 108 } 109 public method vtkdata {args} { 110 return $_data 111 } 95 112 public method values {args} { 96 113 return $_data 97 114 } 115 public method style {args} { 116 return "" 117 } 98 118 public method hints {args} { 99 119 return "" 100 120 } 101 public method style {args} {102 return ""103 }104 121 public method type {args} { 105 122 return $_type 106 123 } 107 124 public method viewer {args} { 125 return "streamlines" 126 } 127 128 private variable _cname "one" 108 129 private variable _data "" 109 130 private variable _type "" … … 128 149 set obj [visData #auto $info "vtk"] 129 150 $widgets(vtkviewer) add $obj 130 } 131 } 132 133 # ---------------------------------------------------------------------- 134 # USAGE: send_streamlines_file 135 # 136 # Prompts the user for a text file, and then sends the text within 137 # that file along to the rendering widget. 138 # ---------------------------------------------------------------------- 139 proc send_streamlines_file {} { 140 global widgets 141 142 set file [tk_getOpenFile -title "Open VTK File as Streamlines"] 143 if {"" != $file && [catch { 144 set fid [open $file r] 145 fconfigure $fid -translation binary -encoding binary 146 set info [read $fid] 147 close $fid 148 }] == 0} { 149 set obj [visData #auto $info "vtkstreamlines"] 150 $widgets(vtkviewer) add $obj 151 $widgets(vtkviewer) scale $obj 151 152 } 152 153 } … … 348 349 menu .mbar.file 349 350 .mbar.file add command -label "Send VTK File..." -underline 0 -command send_file 350 .mbar.file add command -label "Send VTK File as Streamlines..." -underline 0 -command send_streamlines_file351 351 .mbar.file add command -label "Load script..." -underline 0 -command load_script 352 352 .mbar.file add command -label "Reset" -underline 0 -command reset -
branches/1.3/gui/apps/vtkvolume-test
r3177 r3805 78 78 } { 79 79 set _data [lindex $args 0] 80 GetTypeAndSize $_cname 81 GetAssociation $_cname 82 ReadVtkDataSet $_cname $_data 80 83 set _type [lindex $args 1] 81 84 } 82 85 83 86 public method components {args} { 87 Rappture::getopts args params { 88 flag what -name default 89 flag what -dimensions 90 flag what -style 91 flag what -particles 92 flag what -flow 93 flag what -box 94 } 95 if { $params(what) == "-dimensions" } { 96 return "${_dim}D" 97 } 84 98 if {[llength $args] == 0} { 85 99 return "one" … … 87 101 return "" 88 102 } 89 public method blob {args} {90 return $_data103 public method isvalid {} { 104 return 1 91 105 } 92 106 public method data {args} { … … 99 113 return $_data 100 114 } 115 public method style {args} { 116 return "" 117 } 101 118 public method hints {args} { 102 119 return "" … … 105 122 return $_type 106 123 } 107 124 public method viewer {args} { 125 return "vtkvolume" 126 } 127 128 private variable _cname "one" 108 129 private variable _data "" 109 130 private variable _type "" … … 126 147 close $fid 127 148 }] == 0} { 128 set obj [visData #auto $info "vtk "]149 set obj [visData #auto $info "vtkvolume"] 129 150 $widgets(vtkviewer) add $obj 151 $widgets(vtkviewer) scale $obj 130 152 } 131 153 }
Note: See TracChangeset
for help on using the changeset viewer.