Changeset 2722
- Timestamp:
- Dec 8, 2011, 2:34:01 PM (13 years ago)
- Location:
- trunk/gui
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/scripts/field.tcl
r2721 r2722 51 51 private variable _comp2vtk ;# maps component name => vtkFloatArray 52 52 private variable _comp2vtkstreamlines ;# maps component name => vtkFloatArray 53 private variable _comp2vtkvolume ;# maps component name => vtkFloatArray 53 54 private variable _comp2volume ;# maps component name => vtkFloatArray 54 55 private variable _comp2dx ;# maps component name => OpenDX data … … 605 606 } 606 607 } elseif {[$_field element $cname.opendx] != ""} { 607 set type "dx" 608 global env 609 if { [info exists env(VTKVOLUME)] } { 610 set type "vtkvolume" 611 } else { 612 set type "dx" 613 } 608 614 } elseif {[$_field element $cname.dx] != ""} { 609 set type "dx" 615 global env 616 if { [info exists env(VTKVOLUME)] } { 617 set type "vtkvolume" 618 } else { 619 set type "dx" 620 } 610 621 } 611 622 set _comp2style($cname) "" … … 798 809 set _comp2style($cname) [$_field get $cname.style] 799 810 incr _counter 811 } elseif {$type == "vtkvolume"} { 812 set _comp2dims($cname) "3D" 813 # Allow redirects to another element. 814 set data [$_field get -decode no $cname.dx] 815 set data [Rappture::encoding::decode -as zb64 $data] 816 if 1 { 817 set file "/tmp/junk.dx" 818 set f [open $file "w"] 819 puts $f $data 820 close $f 821 } 822 set data [Rappture::ConvertDxToVtk $data] 823 set _comp2vtkvolume($cname) $data 824 set _comp2style($cname) [$_field get $cname.style] 825 incr _counter 800 826 } elseif {$type == "vtkstreamlines2"} { 801 827 set _comp2dims($cname) "3D" … … 803 829 set _comp2style($cname) [$_field get $cname.style] 804 830 incr _counter 805 } elseif {$type == "dx" } {831 } elseif {$type == "dx" } { 806 832 # 807 833 # HACK ALERT! Extract gzipped, base64-encoded OpenDX … … 994 1020 } 995 1021 if {[info exists _comp2dx($what)]} { 996 set data $_comp2dx($what) 997 if { $data == "" } { 998 return "" 999 } 1000 set data [$_field get -decode yes $data] 1001 set data [Rappture::ConvertDxToVtk $data] 1002 return $data 1022 return $_comp2dx($what) 1003 1023 } 1004 1024 if {[info exists _comp2unirect2d($what)]} { -
trunk/gui/scripts/field3dresult.tcl
r2504 r2722 59 59 set servers [Rappture::VisViewer::GetServerList "nanovis"] 60 60 } 61 "vtkcontour" - "vtkstreamlines" {61 "vtkcontour" - "vtkstreamlines" - "vtkvolume" - "vtkviewer" { 62 62 set servers [Rappture::VisViewer::GetServerList "vtkvis"] 63 63 } … … 80 80 itk_component add renderer { 81 81 Rappture::FlowvisViewer $itk_interior.ren $servers 82 } 83 } 84 "vtkvolume" { 85 itk_component add renderer { 86 Rappture::VtkVolumeViewer $itk_interior.ren $servers 82 87 } 83 88 } -
trunk/gui/scripts/resultviewer.tcl
r2565 r2722 206 206 # ---------------------------------------------------------------------- 207 207 itcl::body Rappture::ResultViewer::_plotAdd {dataobj {settings ""}} { 208 puts stderr "ResultViewer _plotAdd info class [$dataobj info class]" 208 209 switch -- [$dataobj info class] { 209 210 ::Rappture::DataTable { … … 252 253 ::Rappture::Field { 253 254 set dims [lindex [lsort [$dataobj components -dimensions]] end] 255 puts stderr "ResultViewer in Field dims=$dims" 254 256 switch -- $dims { 255 257 1D { … … 287 289 set mode "field3D" 288 290 if {![info exists _mode2widget($mode)]} { 291 puts stderr "type=$type" 289 292 switch -- [$dataobj type] { 290 293 "vtk" { … … 298 301 } 299 302 } 303 "vtkvolume" { 304 set fmt "vtkvolume" 305 } 300 306 "vtkstreamlines" { 301 307 set fmt "vtkstreamlines" -
trunk/gui/scripts/sequenceresult.tcl
r2268 r2722 482 482 } 483 483 3D { 484 Rappture::Field3DResult $viewer 484 set fmt [$dataobj type] 485 switch -- $fmt { 486 "opendx" - "dx" - "points-on-mesh" { 487 set fmt "nanovis" 488 set extents [$dataobj extents] 489 if { $extents > 1 } { 490 set fmt "flowvis" 491 } 492 } 493 } 494 Rappture::Field3DResult $viewer -mode $fmt 485 495 } 486 496 default { -
trunk/gui/scripts/vtkvolumeviewer.tcl
r2718 r2722 260 260 cutplane-wireframe 0 261 261 cutplane-opacity 100 262 volume-edges 0263 262 volume-lighting 1 264 263 volume-opacity 40 … … 1090 1089 1091 1090 if { $_reset } { 1092 InitSettings volume-edges volume-lighting volume-opacity \ 1093 volume-wireframe 1091 InitSettings volume-lighting 1094 1092 Zoom reset 1095 1093 set _reset 0 … … 1338 1336 } 1339 1337 switch -- $what { 1340 "volume-opacity" {1341 set val $_settings(volume-opacity)1342 set sval [expr { 0.01 * double($val) }]1343 foreach dataset [CurrentDatasets -visible] {1344 SendCmd "polydata opacity $sval $dataset"1345 }1346 }1347 "volume-wireframe" {1348 set bool $_settings(volume-wireframe)1349 foreach dataset [CurrentDatasets -visible] {1350 SendCmd "polydata wireframe $bool $dataset"1351 }1352 }1353 1338 "volume-visible" { 1354 1339 set bool $_settings(volume-visible) 1355 1340 foreach dataset [CurrentDatasets -visible] { 1356 SendCmd " polydatavisible $bool $dataset"1341 SendCmd "volume visible $bool $dataset" 1357 1342 } 1358 1343 if { $bool } { … … 1367 1352 set bool $_settings(volume-lighting) 1368 1353 foreach dataset [CurrentDatasets -visible] { 1369 SendCmd "polydata lighting $bool $dataset" 1370 } 1371 } 1372 "volume-edges" { 1373 set bool $_settings(volume-edges) 1374 foreach dataset [CurrentDatasets -visible] { 1375 SendCmd "polydata edges $bool $dataset" 1354 SendCmd "volume lighting $bool $dataset" 1376 1355 } 1377 1356 } … … 1578 1557 1579 1558 itcl::body Rappture::VtkVolumeViewer::ColorsToColormap { colors } { 1559 puts stderr colors=$colors 1580 1560 switch -- $colors { 1581 1561 "grey-to-blue" { … … 1910 1890 -font "Arial 9" 1911 1891 1912 checkbutton $inner.wireframe \1913 -text "Show Wireframe" \1914 -variable [itcl::scope _settings(volume-wireframe)] \1915 -command [itcl::code $this AdjustSetting volume-wireframe] \1916 -font "Arial 9"1917 1918 1892 checkbutton $inner.lighting \ 1919 1893 -text "Enable Lighting" \ 1920 1894 -variable [itcl::scope _settings(volume-lighting)] \ 1921 1895 -command [itcl::code $this AdjustSetting volume-lighting] \ 1922 -font "Arial 9"1923 1924 checkbutton $inner.edges \1925 -text "Show Edges" \1926 -variable [itcl::scope _settings(volume-edges)] \1927 -command [itcl::code $this AdjustSetting volume-edges] \1928 1896 -font "Arial 9" 1929 1897 … … 1970 1938 blt::table $inner \ 1971 1939 0,0 $inner.volume -anchor w -pady 2 \ 1972 1,0 $inner.wireframe -anchor w -pady 2 \1973 1940 2,0 $inner.lighting -anchor w -pady 2 \ 1974 3,0 $inner.edges -anchor w -pady 2 \1975 4,0 $inner.opacity_l -anchor w -pady 2 \1976 5,0 $inner.opacity -fill x -pady 2 \1977 1941 6,0 $inner.field_l -anchor w -pady 2 \ 1978 1942 6,1 $inner.field -anchor w -pady 2 \ … … 2382 2346 } 2383 2347 2384 SendCmd "polydata add $tag" 2385 SendCmd "polydata edges $settings(-edges) $tag" 2386 set _settings(volume-edges) $settings(-edges) 2387 SendCmd "polydata color [Color2RGB $settings(-color)] $tag" 2388 SendCmd "polydata lighting $settings(-lighting) $tag" 2348 SendCmd "volume lighting $settings(-lighting) $tag" 2389 2349 set _settings(volume-lighting) $settings(-lighting) 2390 SendCmd "polydata linecolor [Color2RGB $settings(-edgecolor)] $tag"2391 SendCmd "polydata linewidth $settings(-linewidth) $tag"2392 SendCmd "polydata opacity $settings(-opacity) $tag"2393 set _settings(volume-opacity) $settings(-opacity)2394 SendCmd "polydata wireframe $settings(-wireframe) $tag"2395 set _settings(volume-wireframe) $settings(-wireframe)2396 set _settings(volume-opacity) [expr $settings(-opacity) * 100.0]2397 2350 SetColormap $dataobj $comp 2398 2351 } -
trunk/gui/src/RpConvertDxToVtk.c
r2721 r2722 45 45 } 46 46 47 static int 48 GetPoints(Tcl_Interp *interp, int nPoints, char **stringPtr, 49 const char *endPtr, Tcl_Obj *objPtr) 50 { 51 int nValues; 52 int i; 53 const char *p; 54 char mesg[2000]; 55 56 nValues = 0; 57 p = *stringPtr; 58 for (i = 0; i < nPoints; i++) { 59 double value; 60 char *nextPtr; 61 62 if (p >= endPtr) { 63 Tcl_AppendResult(interp, "unexpected EOF in reading points", 64 (char *)NULL); 65 return TCL_ERROR; 66 } 67 value = strtod(p, &nextPtr); 68 if (nextPtr == p) { 69 Tcl_AppendResult(interp, "bad value found in reading points", 70 (char *)NULL); 71 return TCL_ERROR; 72 } 73 p = nextPtr; 74 sprintf(mesg, "%.15g\n", value); 75 Tcl_AppendToObj(objPtr, mesg, -1); 76 } 77 *stringPtr = p; 78 return TCL_OK; 79 } 80 47 81 /* 48 82 * ConvertDxToVtk string … … 53 87 Tcl_Obj *const *objv) 54 88 { 55 Tcl_Obj *objPtr ;89 Tcl_Obj *objPtr, *pointsObjPtr; 56 90 char *p, *pend; 57 91 char *string; … … 59 93 double delta[3]; 60 94 double origin[3]; 61 double xMax, yMax, zMax, xMin, yMin, zMin;62 double maxValue[3], minValue[3];63 95 int count[3]; 64 96 int length, nComponents, nValues, nPoints; 65 int xNum, yNum, zNum;66 size_t ix;67 97 68 98 nComponents = nPoints = 0; … … 77 107 } 78 108 string = Tcl_GetStringFromObj(objv[1], &length); 109 pointsObjPtr = Tcl_NewStringObj("", -1); 79 110 for (p = string, pend = p + length; p < pend; /*empty*/) { 80 111 char *line; … … 82 113 83 114 line = GetLine(&p, pend); 84 if (line == pend) {115 if (line >= pend) { 85 116 break; /* EOF */ 86 117 } … … 96 127 return TCL_ERROR; 97 128 } 129 #ifdef notdef 130 fprintf(stderr, "found gridpositions counts %d %d %d\n", 131 count[0], count[1], count[2]); 132 #endif 98 133 } else if (sscanf(line, "origin %lg %lg %lg", origin, origin + 1, 99 134 origin + 2) == 3) { 100 135 /* Found origin. */ 136 #ifdef notdef 137 fprintf(stderr, "found origin %g %g %g\n", 138 origin[0], origin[1], origin[2]); 139 #endif 101 140 } else if (sscanf(line, "delta %lg %lg %lg", &ddx, &ddy, &ddz) == 3) { 102 141 if (nComponents == 3) { … … 107 146 delta[nComponents] = sqrt((ddx * ddx) + (ddy * ddy) + (ddz * ddz)); 108 147 nComponents++; 148 #ifdef notdef 149 fprintf(stderr, "found delta %g %g %g\n", ddx, ddy, ddx); 150 #endif 109 151 } else if (sscanf(line, "object %*d class array type %*s shape 3" 110 152 " rank 1 items %d data follows", &nPoints) == 1) { 153 fprintf(stderr, "found class array type shape 3 nPoints=%d\n", 154 nPoints); 111 155 if (nPoints < 0) { 112 156 sprintf(mesg, "bad # points %d", nPoints); … … 114 158 return TCL_ERROR; 115 159 } 116 printf("#points=%d\n", nPoints);117 160 if (nPoints != count[0]*count[1]*count[2]) { 118 161 sprintf(mesg, "inconsistent data: expected %d points" … … 122 165 return TCL_ERROR; 123 166 } 124 break; 167 if (GetPoints(interp, nPoints, &p, pend, pointsObjPtr) != TCL_OK) { 168 return TCL_ERROR; 169 } 125 170 } else if (sscanf(line, "object %*d class array type %*s rank 0" 126 " times %d data follows", &nPoints) == 1) { 171 " items %d data follows", &nPoints) == 1) { 172 #ifdef notdef 173 fprintf(stderr, "found class array type rank 0 nPoints=%d\n", 174 nPoints); 175 #endif 127 176 if (nPoints != count[0]*count[1]*count[2]) { 128 177 sprintf(mesg, "inconsistent data: expected %d points" … … 132 181 return TCL_ERROR; 133 182 } 134 break; 183 if (GetPoints(interp, nPoints, &p, pend, pointsObjPtr) != TCL_OK) { 184 return TCL_ERROR; 185 } 186 #ifdef notdef 187 } else { 188 fprintf(stderr, "unknown line (%.80s)\n", line); 189 #endif 135 190 } 136 191 } … … 155 210 sprintf(mesg, "POINT_DATA %d\n", nPoints); 156 211 Tcl_AppendToObj(objPtr, mesg, -1); 157 158 minValue[0] = minValue[1] = minValue[2] = DBL_MAX; 159 maxValue[0] = maxValue[1] = maxValue[2] = -DBL_MAX; 160 xMin = origin[0], yMin = origin[1], zMin = origin[2]; 161 xNum = count[0], yNum = count[1], zNum = count[2]; 162 xMax = origin[0] + delta[0] * count[0]; 163 yMax = origin[1] + delta[1] * count[1]; 164 zMax = origin[2] + delta[2] * count[2]; 165 nValues = 0; 166 for (ix = 0; ix < xNum; ix++) { 167 size_t iy; 168 169 for (iy = 0; iy < yNum; iy++) { 170 size_t iz; 171 172 for (iz = 0; iz < zNum; iz++) { 173 const char *line; 174 double vx, vy, vz; 175 176 if ((p == pend) || (nValues > (size_t)nPoints)) { 177 break; 178 } 179 line = GetLine(&p, pend); 180 if ((line[0] == '#') || (line[0] == '\n')) { 181 continue; /* Skip blank or comment lines. */ 182 } 183 if (sscanf(line, "%lg %lg %lg", &vx, &vy, &vz) == 3) { 184 if (vx < minValue[0]) { 185 minValue[0] = vx; 186 } else if (vx > maxValue[0]) { 187 maxValue[0] = vx; 188 } 189 if (vy < minValue[1]) { 190 minValue[1] = vy; 191 } else if (vy > maxValue[1]) { 192 maxValue[1] = vy; 193 } 194 if (vz < minValue[2]) { 195 minValue[2] = vz; 196 } else if (vz > maxValue[2]) { 197 maxValue[2] = vz; 198 } 199 sprintf(mesg, "%g %g %g\n", vx, vy, vz); 200 Tcl_AppendToObj(objPtr, mesg, -1); 201 nValues++; 202 } 203 } 204 } 205 } 206 /* Make sure that we read all of the expected points. */ 207 if (nValues != (size_t)nPoints) { 208 sprintf(mesg, "inconsistent data: expected %d points" 209 " but found %d points", nPoints, nValues); 210 Tcl_AppendResult(interp, mesg, (char *)NULL); 211 Tcl_DecrRefCount(objPtr); 212 return TCL_ERROR; 213 } 212 Tcl_AppendObjToObj(objPtr, pointsObjPtr); 213 Tcl_DecrRefCount(pointsObjPtr); 214 214 Tcl_SetObjResult(interp, objPtr); 215 215 return TCL_OK;
Note: See TracChangeset
for help on using the changeset viewer.