Changeset 3567 for trunk/packages/vizservers/nanovis/Command.cpp
- Timestamp:
- Mar 24, 2013, 10:23:25 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/Command.cpp
r3562 r3567 266 266 } 267 267 } 268 HeightMap* hmPtr; 269 hmPtr = new HeightMap(); 270 hmPtr->setHeight(xMin, yMin, xMax, yMax, xNum, yNum, heights); 271 hmPtr->transferFunction(NanoVis::getTransfunc("default")); 272 hmPtr->setVisible(true); 273 hmPtr->setLineContourVisible(true); 268 HeightMap *heightMap = new HeightMap(); 269 heightMap->setHeight(xMin, yMin, xMax, yMax, xNum, yNum, heights); 270 heightMap->transferFunction(NanoVis::getTransferFunction("default")); 271 heightMap->setVisible(true); 272 heightMap->setLineContourVisible(true); 274 273 delete [] heights; 275 return h mPtr;274 return heightMap; 276 275 } 277 276 … … 279 278 GetHeightMapFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, HeightMap **hmPtrPtr) 280 279 { 281 const char *string; 282 string = Tcl_GetString(objPtr); 283 284 Tcl_HashEntry *hPtr; 285 hPtr = Tcl_FindHashEntry(&NanoVis::heightmapTable, string); 286 if (hPtr == NULL) { 287 if (interp != NULL) { 288 Tcl_AppendResult(interp, "can't find a heightmap named \"", 280 const char *string = Tcl_GetString(objPtr); 281 282 NanoVis::HeightMapHashmap::iterator itr = NanoVis::heightMapTable.find(string); 283 if (itr == NanoVis::heightMapTable.end()) { 284 if (interp != NULL) { 285 Tcl_AppendResult(interp, "can't find a heightmap named \"", 289 286 string, "\"", (char*)NULL); 290 291 return TCL_ERROR; 292 } 293 *hmPtrPtr = (HeightMap *)Tcl_GetHashValue(hPtr);287 } 288 return TCL_ERROR; 289 } 290 *hmPtrPtr = itr->second; 294 291 return TCL_OK; 295 292 } … … 308 305 GetVolumeFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, Volume **volPtrPtr) 309 306 { 310 const char *string; 311 string = Tcl_GetString(objPtr); 312 313 Tcl_HashEntry *hPtr; 314 hPtr = Tcl_FindHashEntry(&NanoVis::volumeTable, string); 315 if (hPtr == NULL) { 316 if (interp != NULL) { 317 Tcl_AppendResult(interp, "can't find a volume named \"", 307 const char *string = Tcl_GetString(objPtr); 308 309 NanoVis::VolumeHashmap::iterator itr = NanoVis::volumeTable.find(string); 310 if (itr == NanoVis::volumeTable.end()) { 311 if (interp != NULL) { 312 Tcl_AppendResult(interp, "can't find a volume named \"", 318 313 string, "\"", (char*)NULL); 319 320 return TCL_ERROR; 321 } 322 *volPtrPtr = (Volume *)Tcl_GetHashValue(hPtr);314 } 315 return TCL_ERROR; 316 } 317 *volPtrPtr = itr->second; 323 318 return TCL_OK; 324 319 } … … 338 333 { 339 334 if (objc == 0) { 340 // No arguments. Get all volumes. 341 Tcl_HashSearch iter; 342 Tcl_HashEntry *hPtr; 343 for (hPtr = Tcl_FirstHashEntry(&NanoVis::volumeTable, &iter); 344 hPtr != NULL; hPtr = Tcl_NextHashEntry(&iter)) { 345 Volume *volPtr; 346 volPtr = (Volume *)Tcl_GetHashValue(hPtr); 347 vectorPtr->push_back(volPtr); 348 } 335 // No arguments. Get all volumes. 336 NanoVis::VolumeHashmap::iterator itr; 337 for (itr = NanoVis::volumeTable.begin(); 338 itr != NanoVis::volumeTable.end(); ++itr) { 339 vectorPtr->push_back(itr->second); 340 } 349 341 } else { 350 342 // Get the volumes associated with the given index arguments. 351 343 for (int n = 0; n < objc; n++) { 352 Volume *volPtr; 353 354 if (GetVolumeFromObj(interp, objv[n], &volPtr) != TCL_OK) { 344 Volume *volume; 345 if (GetVolumeFromObj(interp, objv[n], &volume) != TCL_OK) { 355 346 return TCL_ERROR; 356 347 } 357 vectorPtr->push_back(vol Ptr);348 vectorPtr->push_back(volume); 358 349 } 359 350 } … … 375 366 { 376 367 if (objc == 0) { 377 // No arguments. Get all heightmaps. 378 Tcl_HashSearch iter; 379 Tcl_HashEntry *hPtr; 380 for (hPtr = Tcl_FirstHashEntry(&NanoVis::heightmapTable, &iter); 381 hPtr != NULL; hPtr = Tcl_NextHashEntry(&iter)) { 382 HeightMap *hmPtr; 383 hmPtr = (HeightMap *)Tcl_GetHashValue(hPtr); 384 vectorPtr->push_back(hmPtr); 385 } 368 // No arguments. Get all heightmaps. 369 NanoVis::HeightMapHashmap::iterator itr; 370 for (itr = NanoVis::heightMapTable.begin(); 371 itr != NanoVis::heightMapTable.end(); ++itr) { 372 vectorPtr->push_back(itr->second); 373 } 386 374 } else { 387 375 for (int n = 0; n < objc; n++) { 388 HeightMap *hmPtr; 389 390 if (GetHeightMapFromObj(interp, objv[n], &hmPtr) != TCL_OK) { 376 HeightMap *heightMap; 377 if (GetHeightMapFromObj(interp, objv[n], &heightMap) != TCL_OK) { 391 378 return TCL_ERROR; 392 379 } 393 vectorPtr->push_back(h mPtr);380 vectorPtr->push_back(heightMap); 394 381 } 395 382 } … … 517 504 } 518 505 if (NanoVis::recfile != NULL) { 519 506 ssize_t nWritten; 520 507 521 508 nWritten = fwrite(buf.bytes(), sizeof(char), buf.size(), 522 523 509 NanoVis::recfile); 510 assert(nWritten == (ssize_t)buf.size()); 524 511 fflush(NanoVis::recfile); 525 512 } … … 527 514 TRACE("Checking header[%.13s]", buf.bytes()); 528 515 if (strncmp (buf.bytes(), "@@RP-ENC:", 9) == 0) { 529 530 531 532 533 516 /* There's a header on the buffer, use it to decode the data. */ 517 if (!Rappture::encoding::decode(err, buf, RPENC_HDR)) { 518 Tcl_AppendResult(interp, err.remark(), (char*)NULL); 519 return TCL_ERROR; 520 } 534 521 } else if (Rappture::encoding::isBase64(buf.bytes(), buf.size())) { 535 536 537 538 539 540 522 /* No header, but it's base64 encoded. It's likely that it's both 523 * base64 encoded and compressed. */ 524 if (!Rappture::encoding::decode(err, buf, RPENC_B64 | RPENC_Z)) { 525 Tcl_AppendResult(interp, err.remark(), (char*)NULL); 526 return TCL_ERROR; 527 } 541 528 } 542 529 return TCL_OK; … … 644 631 static int 645 632 CameraCmd(ClientData clientData, Tcl_Interp *interp, int objc, 646 633 Tcl_Obj *const *objv) 647 634 { 648 635 Tcl_ObjCmdProc *proc; … … 658 645 static int 659 646 SnapshotCmd(ClientData clientData, Tcl_Interp *interp, int objc, 660 647 Tcl_Obj *const *objv) 661 648 { 662 649 int w, h; … … 787 774 * "render_start" is written into the stats file. Afterwards, it 788 775 * is "render_info". 789 * 776 * 790 777 * clientinfo list 791 778 */ … … 803 790 804 791 if (objc != 2) { 805 792 Tcl_AppendResult(interp, "wrong # of arguments: should be \"", 806 793 Tcl_GetString(objv[0]), " list\"", (char *)NULL); 807 794 return TCL_ERROR; 808 795 } 809 796 #ifdef KEEPSTATS … … 814 801 f = NanoVis::getStatsFile(objv[1]); 815 802 if (f < 0) { 816 803 Tcl_AppendResult(interp, "can't open stats file: ", 817 804 Tcl_PosixError(interp), (char *)NULL); 818 805 return TCL_ERROR; 819 806 } 820 807 #endif … … 858 845 /* Client arguments. */ 859 846 if (Tcl_ListObjGetElements(interp, objv[1], &numItems, &items) != TCL_OK) { 860 847 return TCL_ERROR; 861 848 } 862 849 for (i = 0; i < numItems; i++) { … … 891 878 static int 892 879 LegendCmd(ClientData clientData, Tcl_Interp *interp, int objc, 893 880 Tcl_Obj *const *objv) 894 881 { 895 882 if (objc != 4) { … … 901 888 const char *name; 902 889 name = Tcl_GetString(objv[1]); 903 TransferFunction *tf; 904 tf = NanoVis::getTransfunc(name); 890 TransferFunction *tf = NanoVis::getTransferFunction(name); 905 891 if (tf == NULL) { 906 892 Tcl_AppendResult(interp, "unknown transfer function \"", name, "\"", … … 1182 1168 } 1183 1169 TRACE("parsing volume data identifier"); 1184 Tcl_HashSearch iter; 1185 Tcl_HashEntry *hPtr; 1186 for (hPtr = Tcl_FirstHashEntry(&NanoVis::volumeTable, &iter); hPtr != NULL; 1187 hPtr = Tcl_NextHashEntry(&iter)) { 1188 Volume *volPtr; 1189 volPtr = (Volume *)Tcl_GetHashValue(hPtr); 1190 NanoVis::volRenderer->addAnimatedVolume(volPtr); 1170 NanoVis::VolumeHashmap::iterator itr; 1171 for (itr = NanoVis::volumeTable.begin(); 1172 itr != NanoVis::volumeTable.end(); ++itr) { 1173 NanoVis::volRenderer->addAnimatedVolume(itr->second); 1191 1174 } 1192 1175 return TCL_OK; … … 1210 1193 1211 1194 proc = Rappture::GetOpFromObj(interp, nVolumeAnimationOps, 1212 1195 volumeAnimationOps, Rappture::CMDSPEC_ARG2, objc, objv, 0); 1213 1196 if (proc == NULL) { 1214 1197 return TCL_ERROR; … … 1227 1210 return TCL_ERROR; 1228 1211 } 1229 const char *tag; 1230 tag = Tcl_GetString(objv[4]); 1212 const char *tag = Tcl_GetString(objv[4]); 1231 1213 Rappture::Buffer buf; 1232 1214 if (GetDataStream(interp, buf, nbytes) != TCL_OK) { … … 1241 1223 TRACE("Checking header[%.20s]", bytes); 1242 1224 1243 Volume *vol Ptr= NULL;1225 Volume *volume = NULL; 1244 1226 1245 1227 if ((nBytes > 5) && (strncmp(bytes, "<HDR>", 5) == 0)) { … … 1249 1231 //vol = NvZincBlendeReconstructor::getInstance()->loadFromStream(fdata); 1250 1232 1251 vol Ptr= NvZincBlendeReconstructor::getInstance()->loadFromMemory((void*) buf.bytes());1252 if (vol Ptr== NULL) {1233 volume = NvZincBlendeReconstructor::getInstance()->loadFromMemory((void*) buf.bytes()); 1234 if (volume == NULL) { 1253 1235 Tcl_AppendResult(interp, "can't get volume instance", (char *)NULL); 1254 1236 return TCL_ERROR; … … 1256 1238 TRACE("finish loading"); 1257 1239 1258 Vector3f scale = vol Ptr->getPhysicalScaling();1240 Vector3f scale = volume->getPhysicalScaling(); 1259 1241 Vector3f loc(scale); 1260 1242 loc *= -0.5; 1261 volPtr->location(loc); 1262 1263 int isNew; 1264 Tcl_HashEntry *hPtr; 1265 hPtr = Tcl_CreateHashEntry(&NanoVis::volumeTable, tag, &isNew); 1266 if (!isNew) { 1243 volume->location(loc); 1244 1245 NanoVis::VolumeHashmap::iterator itr = NanoVis::volumeTable.find(tag); 1246 if (itr != NanoVis::volumeTable.end()) { 1267 1247 Tcl_AppendResult(interp, "volume \"", tag, "\" already exists.", 1268 1248 (char *)NULL); 1269 1249 return TCL_ERROR; 1270 1271 Tcl_SetHashValue(hPtr, volPtr);1272 volPtr->name(Tcl_GetHashKey(&NanoVis::volumeTable, hPtr));1250 } 1251 NanoVis::volumeTable[tag] = volume; 1252 volume->name(tag); 1273 1253 } else if ((nBytes > 14) && (strncmp(bytes, "# vtk DataFile", 14) == 0)) { 1274 1254 TRACE("VTK loading..."); … … 1276 1256 fdata.write(bytes, nBytes); 1277 1257 if (nBytes <= 0) { 1278 1279 1258 ERROR("data buffer is empty"); 1259 abort(); 1280 1260 } 1281 1261 Rappture::Outcome context; 1282 vol Ptr= load_vtk_volume_stream(context, tag, fdata);1283 if (vol Ptr== NULL) {1262 volume = load_vtk_volume_stream(context, tag, fdata); 1263 if (volume == NULL) { 1284 1264 Tcl_AppendResult(interp, context.remark(), (char*)NULL); 1285 1265 return TCL_ERROR; … … 1299 1279 } 1300 1280 Rappture::Outcome context; 1301 vol Ptr= load_dx_volume_stream(context, tag, fdata);1302 if (vol Ptr== NULL) {1281 volume = load_dx_volume_stream(context, tag, fdata); 1282 if (volume == NULL) { 1303 1283 Tcl_AppendResult(interp, context.remark(), (char*)NULL); 1304 1284 return TCL_ERROR; … … 1306 1286 } 1307 1287 1308 if (vol Ptr!= NULL) {1309 vol Ptr->disableCutplane(0);1310 vol Ptr->disableCutplane(1);1311 vol Ptr->disableCutplane(2);1312 vol Ptr->transferFunction(NanoVis::getTransfunc("default"));1313 volPtr->visible(true);1288 if (volume != NULL) { 1289 volume->disableCutplane(0); 1290 volume->disableCutplane(1); 1291 volume->disableCutplane(2); 1292 volume->transferFunction(NanoVis::getTransferFunction("default")); 1293 volume->visible(true); 1314 1294 1315 1295 char info[1024]; 1316 1296 ssize_t nWritten; 1317 1297 1318 1298 if (Volume::updatePending) { … … 1322 1302 // FIXME: strlen(info) is the return value of sprintf 1323 1303 sprintf(info, "nv>data tag %s min %g max %g vmin %g vmax %g\n", tag, 1324 volPtr->wAxis.min(), volPtr->wAxis.max(),1304 volume->wAxis.min(), volume->wAxis.max(), 1325 1305 Volume::valueMin, Volume::valueMax); 1326 1306 nWritten = write(1, info, strlen(info)); 1327 1307 assert(nWritten == (ssize_t)strlen(info)); 1328 1308 } 1329 1309 return TCL_OK; … … 1344 1324 std::vector<Volume *>::iterator iter; 1345 1325 for (iter = ivol.begin(); iter != ivol.end(); iter++) { 1346 1326 (*iter)->dataEnabled(state); 1347 1327 } 1348 1328 return TCL_OK; … … 1371 1351 static int 1372 1352 VolumeDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc, 1373 Tcl_Obj *const *objv) 1374 { 1375 int i; 1376 1377 for (i = 2; i < objc; i++) { 1378 Volume *volPtr; 1379 1380 if (GetVolumeFromObj(interp, objv[i], &volPtr) != TCL_OK) { 1381 return TCL_ERROR; 1382 } 1383 NanoVis::removeVolume(volPtr); 1353 Tcl_Obj *const *objv) 1354 { 1355 for (int i = 2; i < objc; i++) { 1356 Volume *volume; 1357 if (GetVolumeFromObj(interp, objv[i], &volume) != TCL_OK) { 1358 return TCL_ERROR; 1359 } 1360 NanoVis::removeVolume(volume); 1384 1361 } 1385 1362 NanoVis::eventuallyRedraw(); … … 1389 1366 static int 1390 1367 VolumeExistsOp(ClientData clientData, Tcl_Interp *interp, int objc, 1391 1368 Tcl_Obj *const *objv) 1392 1369 { 1393 1370 bool value; 1394 Volume *vol Ptr;1371 Volume *volume; 1395 1372 1396 1373 value = false; 1397 if (GetVolumeFromObj(NULL, objv[2], &vol Ptr) == TCL_OK) {1398 1374 if (GetVolumeFromObj(NULL, objv[2], &volume) == TCL_OK) { 1375 value = true; 1399 1376 } 1400 1377 Tcl_SetBooleanObj(Tcl_GetObjResult(interp), (int)value); … … 1404 1381 static int 1405 1382 VolumeNamesOp(ClientData clientData, Tcl_Interp *interp, int objc, 1406 1383 Tcl_Obj *const *objv) 1407 1384 { 1408 1385 Tcl_Obj *listObjPtr; 1409 1386 listObjPtr = Tcl_NewListObj(0, (Tcl_Obj **) NULL); 1410 Tcl_HashEntry *hPtr; 1411 Tcl_HashSearch iter; 1412 for (hPtr = Tcl_FirstHashEntry(&NanoVis::volumeTable, &iter); hPtr != NULL; 1413 hPtr = Tcl_NextHashEntry(&iter)) { 1414 Volume *volPtr; 1415 volPtr = (Volume *)Tcl_GetHashValue(hPtr); 1416 Tcl_Obj *objPtr; 1417 objPtr = Tcl_NewStringObj(volPtr->name(), -1); 1418 Tcl_ListObjAppendElement(interp, listObjPtr, objPtr); 1387 NanoVis::VolumeHashmap::iterator itr; 1388 for (itr = NanoVis::volumeTable.begin(); 1389 itr != NanoVis::volumeTable.end(); ++itr) { 1390 Tcl_Obj *objPtr = Tcl_NewStringObj(itr->second->name(), -1); 1391 Tcl_ListObjAppendElement(interp, listObjPtr, objPtr); 1419 1392 } 1420 1393 Tcl_SetObjResult(interp, listObjPtr); … … 1455 1428 std::vector<Volume *>::iterator iter; 1456 1429 for (iter = ivol.begin(); iter != ivol.end(); iter++) { 1457 1430 (*iter)->outline(state); 1458 1431 } 1459 1432 return TCL_OK; … … 1633 1606 Tcl_Obj *const *objv) 1634 1607 { 1635 TransferFunction *tfPtr;1636 1608 const char *name = Tcl_GetString(objv[3]); 1637 tfPtr = NanoVis::getTransfunc(name);1638 if (tf Ptr== NULL) {1609 TransferFunction *tf = NanoVis::getTransferFunction(name); 1610 if (tf == NULL) { 1639 1611 Tcl_AppendResult(interp, "transfer function \"", name, 1640 1612 "\" is not defined", (char*)NULL); … … 1647 1619 std::vector<Volume *>::iterator iter; 1648 1620 for (iter = ivol.begin(); iter != ivol.end(); iter++) { 1649 1650 tfPtr->name());1651 (*iter)->transferFunction(tf Ptr);1621 TRACE("setting %s with transfer function %s", (*iter)->name(), 1622 tf->name()); 1623 (*iter)->transferFunction(tf); 1652 1624 #ifdef USE_POINTSET_RENDERER 1653 1625 // TBD.. 1654 1626 if ((*iter)->pointsetIndex != -1) { 1655 NanoVis::pointSet[(*iter)->pointsetIndex]->updateColor(tf Ptr->getData(), 256);1627 NanoVis::pointSet[(*iter)->pointsetIndex]->updateColor(tf->getData(), 256); 1656 1628 } 1657 1629 #endif … … 1700 1672 std::vector<Volume *>::iterator iter; 1701 1673 for (iter = ivol.begin(); iter != ivol.end(); iter++) { 1702 (*iter)->visible(state); 1703 } 1704 return TCL_OK; 1705 } 1706 1707 static int 1708 VolumeTestOp(ClientData clientData, Tcl_Interp *interp, int objc, 1709 Tcl_Obj *const *objv) 1710 { 1711 // Find the first volume in the vector. 1712 Tcl_HashEntry *hPtr; 1713 Tcl_HashSearch iter; 1714 hPtr = Tcl_FirstHashEntry(&NanoVis::volumeTable, &iter); 1715 if (hPtr != NULL) { 1716 Volume *volPtr; 1717 volPtr = (Volume *)Tcl_GetHashValue(hPtr); 1718 volPtr->dataEnabled(false); 1719 volPtr->visible(false); 1674 (*iter)->visible(state); 1720 1675 } 1721 1676 return TCL_OK; … … 1731 1686 {"shading", 2, VolumeShadingOp, 3, 0, "oper ?args?",}, 1732 1687 {"state", 2, VolumeStateOp, 3, 0, "bool ?indices?",}, 1733 {"test2", 1, VolumeTestOp, 2, 2, "",},1734 1688 }; 1735 1689 static int nVolumeOps = NumCmdSpecs(volumeOps); … … 1752 1706 static int 1753 1707 VolumeCmd(ClientData clientData, Tcl_Interp *interp, int objc, 1754 1708 Tcl_Obj *const *objv) 1755 1709 { 1756 1710 Tcl_ObjCmdProc *proc; … … 1772 1726 return TCL_ERROR; 1773 1727 } 1774 const char *tag; 1775 tag = Tcl_GetString(objv[4]); 1776 int isNew; 1777 Tcl_HashEntry *hPtr; 1728 const char *tag = Tcl_GetString(objv[4]); 1778 1729 1779 1730 Rappture::Buffer buf; … … 1783 1734 Rappture::Unirect2d data(1); 1784 1735 if (data.parseBuffer(interp, buf) != TCL_OK) { 1785 1736 return TCL_ERROR; 1786 1737 } 1787 1738 if (data.nValues() == 0) { 1788 1789 1739 Tcl_AppendResult(interp, "no data found in stream", (char *)NULL); 1740 return TCL_ERROR; 1790 1741 } 1791 1742 if (!data.isInitialized()) { 1792 return TCL_ERROR; 1793 } 1794 HeightMap* hmPtr; 1795 hPtr = Tcl_CreateHashEntry(&NanoVis::heightmapTable, tag, &isNew); 1796 if (isNew) { 1797 hmPtr = new HeightMap(); 1798 Tcl_SetHashValue(hPtr, hmPtr); 1743 return TCL_ERROR; 1744 } 1745 HeightMap *heightMap; 1746 NanoVis::HeightMapHashmap::iterator itr = NanoVis::heightMapTable.find(tag); 1747 if (itr != NanoVis::heightMapTable.end()) { 1748 heightMap = itr->second; 1799 1749 } else { 1800 hmPtr = (HeightMap *)Tcl_GetHashValue(hPtr); 1801 } 1802 TRACE("Number of heightmaps=%d", NanoVis::heightmapTable.numEntries); 1750 heightMap = new HeightMap(); 1751 NanoVis::heightMapTable[tag] = heightMap; 1752 } 1753 TRACE("Number of heightmaps=%d", NanoVis::heightMapTable.size()); 1803 1754 // Must set units before the heights. 1804 h mPtr->xAxis.units(data.xUnits());1805 h mPtr->yAxis.units(data.yUnits());1806 h mPtr->zAxis.units(data.vUnits());1807 h mPtr->wAxis.units(data.yUnits());1808 h mPtr->setHeight(data.xMin(), data.yMin(), data.xMax(), data.yMax(),1809 1810 h mPtr->transferFunction(NanoVis::getTransfunc("default"));1811 h mPtr->setVisible(true);1812 h mPtr->setLineContourVisible(true);1755 heightMap->xAxis.units(data.xUnits()); 1756 heightMap->yAxis.units(data.yUnits()); 1757 heightMap->zAxis.units(data.vUnits()); 1758 heightMap->wAxis.units(data.yUnits()); 1759 heightMap->setHeight(data.xMin(), data.yMin(), data.xMax(), data.yMax(), 1760 data.xNum(), data.yNum(), data.transferValues()); 1761 heightMap->transferFunction(NanoVis::getTransferFunction("default")); 1762 heightMap->setVisible(true); 1763 heightMap->setLineContourVisible(true); 1813 1764 NanoVis::eventuallyRedraw(); 1814 1765 return TCL_OK; … … 1878 1829 static int 1879 1830 HeightMapLineContourVisibleOp(ClientData clientData, Tcl_Interp *interp, 1880 1831 int objc, Tcl_Obj *const *objv) 1881 1832 { 1882 1833 bool visible; … … 1933 1884 Tcl_Obj *const *objv) 1934 1885 { 1935 const char *tag; 1936 tag = Tcl_GetString(objv[2]); 1937 Tcl_HashEntry *hPtr; 1938 int isNew; 1939 hPtr = Tcl_CreateHashEntry(&NanoVis::heightmapTable, tag, &isNew); 1940 if (!isNew) { 1941 Tcl_AppendResult(interp, "heightmap \"", tag, "\" already exists.", 1942 (char *)NULL); 1943 return TCL_ERROR; 1944 } 1945 HeightMap *hmPtr; 1886 const char *tag = Tcl_GetString(objv[2]); 1887 NanoVis::HeightMapHashmap::iterator itr = NanoVis::heightMapTable.find(tag); 1888 if (itr != NanoVis::heightMapTable.end()) { 1889 Tcl_AppendResult(interp, "heightmap \"", tag, "\" already exists.", 1890 (char *)NULL); 1891 return TCL_ERROR; 1892 } 1946 1893 /* heightmap create xmin ymin xmax ymax xnum ynum values */ 1947 hmPtr = CreateHeightMap(clientData, interp, objc - 3, objv + 3); 1948 if (hmPtr == NULL) { 1949 return TCL_ERROR; 1950 } 1951 Tcl_SetHashValue(hPtr, hmPtr); 1952 Tcl_SetStringObj(Tcl_GetObjResult(interp), tag, -1);; 1894 HeightMap *heightMap = CreateHeightMap(clientData, interp, objc - 3, objv + 3); 1895 if (heightMap == NULL) { 1896 return TCL_ERROR; 1897 } 1898 NanoVis::heightMapTable[tag] = heightMap; 1953 1899 NanoVis::eventuallyRedraw(); 1954 TRACE("Number of heightmaps=%d", NanoVis::height mapTable.numEntries);1900 TRACE("Number of heightmaps=%d", NanoVis::heightMapTable.size()); 1955 1901 return TCL_OK; 1956 1902 } … … 1970 1916 if (tfPtr == NULL) { 1971 1917 Tcl_AppendResult(interp, "no transfer function defined for heightmap" 1972 1918 " \"", tag, "\"", (char*)NULL); 1973 1919 return TCL_ERROR; 1974 1920 } … … 2018 1964 const char *name; 2019 1965 name = Tcl_GetString(objv[2]); 2020 TransferFunction *tfPtr; 2021 tfPtr = NanoVis::getTransfunc(name); 2022 if (tfPtr == NULL) { 1966 TransferFunction *tf = NanoVis::getTransferFunction(name); 1967 if (tf == NULL) { 2023 1968 Tcl_AppendResult(interp, "transfer function \"", name, 2024 1969 "\" is not defined", (char*)NULL); … … 2031 1976 std::vector<HeightMap *>::iterator iter; 2032 1977 for (iter = imap.begin(); iter != imap.end(); iter++) { 2033 (*iter)->transferFunction(tf Ptr);1978 (*iter)->transferFunction(tf); 2034 1979 } 2035 1980 NanoVis::eventuallyRedraw(); … … 2044 1989 float opacity; 2045 1990 if (GetFloatFromObj(interp, objv[2], &opacity) != TCL_OK) { 2046 1991 return TCL_ERROR; 2047 1992 } 2048 1993 std::vector<HeightMap *> heightmaps; … … 2073 2018 static int 2074 2019 HeightMapCmd(ClientData clientData, Tcl_Interp *interp, int objc, 2075 2020 Tcl_Obj *const *objv) 2076 2021 { 2077 2022 Tcl_ObjCmdProc *proc; … … 2150 2095 static int 2151 2096 GridVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc, 2152 2097 Tcl_Obj *const *objv) 2153 2098 { 2154 2099 bool visible; … … 2170 2115 static int 2171 2116 GridCmd(ClientData clientData, Tcl_Interp *interp, int objc, 2172 2117 Tcl_Obj *const *objv) 2173 2118 { 2174 2119 Tcl_ObjCmdProc *proc; … … 2184 2129 static int 2185 2130 AxisCmd(ClientData clientData, Tcl_Interp *interp, int objc, 2186 2131 Tcl_Obj *const *objv) 2187 2132 { 2188 2133 if (objc < 2) { … … 2211 2156 static int 2212 2157 PlaneAddOp(ClientData clientData, Tcl_Interp *interp, int objc, 2213 2158 Tcl_Obj *const *objv) 2214 2159 { 2215 2160 TRACE("load plane for 2D visualization command"); … … 2316 2261 static int 2317 2262 PlaneCmd(ClientData clientData, Tcl_Interp *interp, int objc, 2318 2263 Tcl_Obj *const *objv) 2319 2264 { 2320 2265 Tcl_ObjCmdProc *proc; … … 2364 2309 static int 2365 2310 Unirect3dCmd(ClientData clientData, Tcl_Interp *interp, int objc, 2366 2311 Tcl_Obj *const *objv) 2367 2312 { 2368 2313 Rappture::Unirect3d *dataPtr = (Rappture::Unirect3d *)clientData; … … 2391 2336 Tcl_CreateObjCommand(interp, "cutplane", CutplaneCmd, NULL, NULL); 2392 2337 if (FlowCmdInitProc(interp) != TCL_OK) { 2393 2338 return NULL; 2394 2339 } 2395 2340 Tcl_CreateObjCommand(interp, "grid", GridCmd, NULL, NULL); … … 2407 2352 Tcl_CreateObjCommand(interp, "volume", VolumeCmd, NULL, NULL); 2408 2353 2409 Tcl_InitHashTable(&NanoVis::volumeTable, TCL_STRING_KEYS);2410 Tcl_InitHashTable(&NanoVis::heightmapTable, TCL_STRING_KEYS);2411 2354 // create a default transfer function 2412 2355 if (Tcl_Eval(interp, def_transfunc) != TCL_OK) { 2413 2356 WARN("bad default transfer function:\n%s", 2414 2357 Tcl_GetStringResult(interp)); 2415 2358 } 2416 2359 return interp;
Note: See TracChangeset
for help on using the changeset viewer.