Changeset 923 for trunk/vizservers/nanovis/Command.cpp
- Timestamp:
- Mar 6, 2008 10:59:02 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/vizservers/nanovis/Command.cpp
r917 r923 34 34 * an id field that's a number that gets incremented each new volume. 35 35 * x Create R2, matrix, etc. libraries. (done) 36 * 37 * 38 * 39 * 36 * o Add bookkeeping for volumes, heightmaps, flows, etc. to track 37 * 1) id # 2) simulation # 3) include/exclude. The include/exclude 38 * is to indicate whether the item should contribute to the overall 39 * limits of the axes. 40 40 */ 41 41 42 #define ISO_TEST 43 #define PLANE_CMD 44 #define __TEST_CODE__ 42 #define ISO_TEST 1 43 #define PLANE_CMD 0 44 #define __TEST_CODE__ 0 45 45 // FOR testing new functions 46 #define _LOCAL_ZINC_TEST_ 46 #define _LOCAL_ZINC_TEST_ 0 47 47 48 48 #include <tcl.h> … … 165 165 static int 166 166 GetCullMode(Tcl_Interp *interp, Tcl_Obj *objPtr, 167 167 graphics::RenderContext::CullMode *modePtr) 168 168 { 169 169 char *string = Tcl_GetString(objPtr); … … 272 272 static HeightMap * 273 273 CreateHeightMap(ClientData clientData, Tcl_Interp *interp, int objc, 274 274 Tcl_Obj *CONST *objv) 275 275 { 276 276 float xMin, yMin, xMax, yMax; … … 353 353 (NanoVis::heightMap[mapIndex] == NULL)) { 354 354 Tcl_AppendResult(interp, "invalid heightmap index \"", 355 355 Tcl_GetString(objPtr), "\"", (char *)NULL); 356 356 return TCL_ERROR; 357 357 } … … 382 382 if (index < 0) { 383 383 Tcl_AppendResult(interp, "can't have negative index \"", 384 384 Tcl_GetString(objPtr), "\"", (char*)NULL); 385 385 return TCL_ERROR; 386 386 } … … 418 418 if (vol == NULL) { 419 419 Tcl_AppendResult(interp, "no volume defined for index \"", 420 420 Tcl_GetString(objPtr), "\"", (char*)NULL); 421 421 return TCL_ERROR; 422 422 } … … 475 475 if (index < 0) { 476 476 Tcl_AppendResult(interp, "can't have negative index \"", 477 477 Tcl_GetString(objv[n]), "\"", (char *)NULL); 478 478 return TCL_ERROR; 479 479 } … … 594 594 } 595 595 if (GetAxis(interp, string, indexPtr) != TCL_OK) { 596 596 return TCL_ERROR; 597 597 } 598 598 if (dirPtr != NULL) { 599 599 *dirPtr = sign; 600 600 } 601 601 return TCL_OK; … … 617 617 if (objc < 3) { 618 618 Tcl_AppendResult(interp, "missing color values\": ", 619 619 "should list of R G B values 0.0 - 1.0", (char*)NULL); 620 620 return TCL_ERROR; 621 621 } … … 684 684 double x0, y0, z0; 685 685 if ((Tcl_GetDoubleFromObj(interp, objv[2], &x0) != TCL_OK) || 686 687 688 686 (Tcl_GetDoubleFromObj(interp, objv[3], &y0) != TCL_OK) || 687 (Tcl_GetDoubleFromObj(interp, objv[4], &z0) != TCL_OK)) { 688 return TCL_ERROR; 689 689 } 690 690 NanoVis::cam->aim(x0, y0, z0); … … 697 697 double xangle, yangle, zangle; 698 698 if ((Tcl_GetDoubleFromObj(interp, objv[2], &xangle) != TCL_OK) || 699 700 701 699 (Tcl_GetDoubleFromObj(interp, objv[3], &yangle) != TCL_OK) || 700 (Tcl_GetDoubleFromObj(interp, objv[4], &zangle) != TCL_OK)) { 701 return TCL_ERROR; 702 702 } 703 703 NanoVis::cam->rotate(xangle, yangle, zangle); … … 710 710 double zoom; 711 711 if (Tcl_GetDoubleFromObj(interp, objv[2], &zoom) != TCL_OK) { 712 712 return TCL_ERROR; 713 713 } 714 714 NanoVis::zoom(zoom); … … 718 718 static Rappture::CmdSpec cameraOps[] = 719 719 { 720 {"aim", 2, CameraAimOp,5, 5, "x y z",},721 {"angle", 722 {"zoom", 720 {"aim", 2, CameraAimOp, 5, 5, "x y z",}, 721 {"angle", 2, CameraAngleOp, 5, 5, "xAngle yAngle zAngle",}, 722 {"zoom", 1, CameraZoomOp, 3, 3, "factor",}, 723 723 }; 724 724 static int nCameraOps = NumCmdSpecs(cameraOps); … … 743 743 744 744 proc = Rappture::GetOpFromObj(interp, nCameraOps, cameraOps, 745 745 Rappture::CMDSPEC_ARG1, objc, objv, 0); 746 746 if (proc == NULL) { 747 747 return TCL_ERROR; 748 748 } 749 749 return (*proc) (cdata, interp, objc, objv); … … 787 787 static int 788 788 CutplanePositionOp(ClientData cdata, Tcl_Interp *interp, int objc, 789 789 Tcl_Obj *CONST *objv) 790 790 { 791 791 float relval; 792 792 if (GetFloatFromObj(interp, objv[2], &relval) != TCL_OK) { 793 793 return TCL_ERROR; 794 794 } 795 795 796 796 // keep this just inside the volume so it doesn't disappear 797 797 if (relval < 0.01f) { 798 798 relval = 0.01f; 799 799 } else if (relval > 0.99f) { 800 800 relval = 0.99f; 801 801 } 802 802 803 803 int axis; 804 804 if (GetAxisFromObj(interp, objv[3], &axis) != TCL_OK) { 805 805 return TCL_ERROR; 806 806 } 807 807 808 808 vector<Volume *> ivol; 809 if (GetVolumes(interp, objc -4, objv+4, &ivol) != TCL_OK) {810 809 if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) { 810 return TCL_ERROR; 811 811 } 812 812 vector<Volume *>::iterator iter; 813 813 for (iter = ivol.begin(); iter != ivol.end(); iter++) { 814 814 (*iter)->move_cutplane(axis, relval); 815 815 } 816 816 return TCL_OK; … … 819 819 static int 820 820 CutplaneStateOp(ClientData cdata, Tcl_Interp *interp, int objc, 821 821 Tcl_Obj *CONST *objv) 822 822 { 823 823 int state; 824 824 if (Tcl_GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 825 825 return TCL_ERROR; 826 826 } 827 827 828 828 int axis; 829 829 if (GetAxisFromObj(interp, objv[3], &axis) != TCL_OK) { 830 830 return TCL_ERROR; 831 831 } 832 832 833 833 vector<Volume *> ivol; 834 834 if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) { 835 835 return TCL_ERROR; 836 836 } 837 837 if (state) { 838 839 840 841 838 vector<Volume *>::iterator iter; 839 for (iter = ivol.begin(); iter != ivol.end(); iter++) { 840 (*iter)->enable_cutplane(axis); 841 } 842 842 } else { 843 844 845 846 843 vector<Volume *>::iterator iter; 844 for (iter = ivol.begin(); iter != ivol.end(); iter++) { 845 (*iter)->disable_cutplane(axis); 846 } 847 847 } 848 848 return TCL_OK; … … 851 851 static Rappture::CmdSpec cutplaneOps[] = 852 852 { 853 {"position", 1, CutplanePositionOp, 4, 4, "bool axis ?indices?",},854 {"state", 853 {"position", 1, CutplanePositionOp, 4, 0, "bool axis ?indices?",}, 854 {"state", 1, CutplaneStateOp, 4, 0, "relval axis ?indices?",}, 855 855 }; 856 856 static int nCutplaneOps = NumCmdSpecs(cutplaneOps); … … 877 877 878 878 proc = Rappture::GetOpFromObj(interp, nCutplaneOps, cutplaneOps, 879 879 Rappture::CMDSPEC_ARG1, objc, objv, 0); 880 880 if (proc == NULL) { 881 881 return TCL_ERROR; 882 882 } 883 883 return (*proc) (cdata, interp, objc, objv); … … 900 900 if (objc != 4) { 901 901 Tcl_AppendResult(interp, "wrong # args: should be \"", 902 902 Tcl_GetString(objv[0]), " volIndex width height\"", (char*)NULL); 903 903 return TCL_ERROR; 904 904 } … … 912 912 if (tf == NULL) { 913 913 Tcl_AppendResult(interp, "no transfer function defined for volume \"", 914 914 Tcl_GetString(objv[1]), "\"", (char*)NULL); 915 915 return TCL_ERROR; 916 916 } … … 945 945 if (objc != 3) { 946 946 Tcl_AppendResult(interp, "wrong # args: should be \"", 947 947 Tcl_GetString(objv[0]), " width height\"", (char*)NULL); 948 948 return TCL_ERROR; 949 949 } … … 951 951 int w, h; 952 952 if ((Tcl_GetIntFromObj(interp, objv[1], &w) != TCL_OK) || 953 953 (Tcl_GetIntFromObj(interp, objv[2], &h) != TCL_OK)) { 954 954 return TCL_ERROR; 955 955 } … … 973 973 if (objc < 2) { 974 974 Tcl_AppendResult(interp, "wrong # args: should be \"", 975 975 Tcl_GetString(objv[0]), " option arg arg...\"", (char*)NULL); 976 976 return TCL_ERROR; 977 977 } … … 982 982 if (objc != 5) { 983 983 Tcl_AppendResult(interp, "wrong # args: should be \"", 984 985 984 Tcl_GetString(objv[0]), " define name colormap alphamap\"", 985 (char*)NULL); 986 986 return TCL_ERROR; 987 987 } … … 1085 1085 if (objc != 2) { 1086 1086 Tcl_AppendResult(interp, "wrong # args: should be \"", 1087 1087 Tcl_GetString(objv[0]), " x|y|z|-x|-y|-z\"", (char*)NULL); 1088 1088 return TCL_ERROR; 1089 1089 } … … 1097 1097 return TCL_OK; 1098 1098 } 1099 1100 #ifdef notdef 1101 static Rappture::CmdSpec volumeAnimationOps[] = 1102 { 1103 {"capture", 2, VolumeAnimationCaptureOp, 4, 0, "value ?indices?",}, 1104 {"clear", 2, VolumeAnimationClearOp, 4, 0, "value ?indices?",}, 1105 {"start", 3, VolumeAnimationStartOp, 4, 0, "value ?indices?",}, 1106 {"stop", 3, VolumeAnimationStopOp, 4, 0, "bool ?indices?",}, 1107 {"volumes", 1, VolumeAnimationVolumesOp, 4, 0, "funcName ?indices?",}, 1108 }; 1109 static int nVolumeAnimationOps = NumCmdSpecs(volumeAnimationOps); 1110 1111 static int 1112 VolumeDataFollowsOp(ClientData cdata, Tcl_Interp *interp, int objc, 1113 Tcl_Obj *CONST *objv) 1114 { 1115 printf("Data Loading\n"); 1116 fflush(stdout); 1117 1118 int nbytes; 1119 if (Tcl_GetIntFromObj(interp, objv[3], &nbytes) != TCL_OK) { 1120 return TCL_ERROR; 1121 } 1122 1123 Rappture::Buffer buf; 1124 if (GetDataStream(interp, buf, nbytes) != TCL_OK) { 1125 return TCL_ERROR; 1126 } 1127 int n = NanoVis::n_volumes; 1128 char header[6]; 1129 memcpy(header, buf.bytes(), sizeof(char) * 5); 1130 header[5] = '\0'; 1131 1132 #if _LOCAL_ZINC_TEST_ 1133 //FILE* fp = fopen("/home/nanohub/vrinside/nv/data/HOON/QDWL_100_100_50_strain_8000i.nd_zatom_12_1", "rb"); 1134 FILE* fp; 1135 1136 fp = fopen("/home/nanohub/vrinside/nv/data/HOON/GaAs_AlGaAs_2QD_B4.nd_zc_1_wf", "rb"); 1137 if (fp == NULL) { 1138 printf("cannot open the file\n"); 1139 fflush(stdout); 1140 return TCL_ERROR; 1141 } 1142 unsigned char* b = (unsigned char*)malloc(buf.size()); 1143 fread(b, buf.size(), 1, fp); 1144 fclose(fp); 1145 #endif /*_LOCAL_ZINC_TEST_*/ 1146 printf("Checking header[%s]\n", header); 1147 fflush(stdout); 1148 if (strcmp(header, "<HDR>") == 0) { 1149 Volume* vol = NULL; 1150 1151 printf("ZincBlende stream is in\n"); 1152 fflush(stdout); 1153 //std::stringstream fdata(std::ios_base::out|std::ios_base::in|std::ios_base::binary); 1154 //fdata.write(buf.bytes(),buf.size()); 1155 //vol = NvZincBlendeReconstructor::getInstance()->loadFromStream(fdata); 1156 1157 #if _LOCAL_ZINC_TEST_ 1158 vol = NvZincBlendeReconstructor::getInstance()->loadFromMemory(b); 1159 #else 1160 vol = NvZincBlendeReconstructor::getInstance()->loadFromMemory((void*) buf.bytes()); 1161 #endif /*_LOCAL_ZINC_TEST_*/ 1162 if (vol == NULL) { 1163 Tcl_AppendResult(interp, "can't get volume instance", (char *)NULL); 1164 return TCL_OK; 1165 } 1166 printf("finish loading\n"); 1167 fflush(stdout); 1168 while (NanoVis::n_volumes <= n) { 1169 NanoVis::volume.push_back((Volume*) NULL); 1170 NanoVis::n_volumes++; 1171 } 1172 1173 if (NanoVis::volume[n] != NULL) { 1174 delete NanoVis::volume[n]; 1175 NanoVis::volume[n] = NULL; 1176 } 1177 1178 float dx0 = -0.5; 1179 float dy0 = -0.5*vol->height/vol->width; 1180 float dz0 = -0.5*vol->depth/vol->width; 1181 vol->move(Vector3(dx0, dy0, dz0)); 1182 1183 NanoVis::volume[n] = vol; 1184 #if __TEST_CODE__ 1185 } else if (strcmp(header, "<FET>") == 0) { 1186 printf("FET loading...\n"); 1187 fflush(stdout); 1188 std::stringstream fdata; 1189 fdata.write(buf.bytes(),buf.size()); 1190 err = load_volume_stream3(n, fdata); 1191 if (err) { 1192 Tcl_AppendResult(interp, err.remark().c_str(), (char*)NULL); 1193 return TCL_ERROR; 1194 } 1195 #endif /*__TEST_CODE__*/ 1196 } else if (strcmp(header, "<ODX>") == 0) { 1197 Rappture::Outcome err; 1198 1199 printf("Loading DX using OpenDX library...\n"); 1200 fflush(stdout); 1201 //err = load_volume_stream_odx(n, buf.bytes()+5, buf.size()-5); 1202 //err = load_volume_stream2(n, fdata); 1203 if (err) { 1204 Tcl_AppendResult(interp, err.remark().c_str(), (char*)NULL); 1205 return TCL_ERROR; 1206 } 1207 } else { 1208 Rappture::Outcome err; 1209 1210 printf("OpenDX loading...\n"); 1211 fflush(stdout); 1212 std::stringstream fdata; 1213 fdata.write(buf.bytes(),buf.size()); 1214 1215 #if ISO_TEST 1216 err = load_volume_stream2(n, fdata); 1217 #else 1218 err = load_volume_stream(n, fdata); 1219 #endif 1220 if (err) { 1221 Tcl_AppendResult(interp, err.remark().c_str(), (char*)NULL); 1222 return TCL_ERROR; 1223 } 1224 } 1225 1226 // 1227 // BE CAREFUL: Set the number of slices to something slightly different 1228 // for each volume. If we have identical volumes at exactly the same 1229 // position with exactly the same number of slices, the second volume will 1230 // overwrite the first, so the first won't appear at all. 1231 // 1232 if (NanoVis::volume[n] != NULL) { 1233 NanoVis::volume[n]->set_n_slice(256-n); 1234 NanoVis::volume[n]->disable_cutplane(0); 1235 NanoVis::volume[n]->disable_cutplane(1); 1236 NanoVis::volume[n]->disable_cutplane(2); 1237 1238 NanoVis::vol_renderer->add_volume(NanoVis::volume[n], 1239 NanoVis::get_transfunc("default")); 1240 } 1241 1242 { 1243 Volume *volPtr; 1244 char info[1024]; 1245 float vmin, vmax; 1246 1247 if (GetVolumeLimits(interp, &vmin, &vmax) != TCL_OK) { 1248 return TCL_ERROR; 1249 } 1250 volPtr = NanoVis::volume[n]; 1251 sprintf(info, "nv>data id %d min %g max %g vmin %g vmax %g\n", 1252 n, volPtr->range_min(), volPtr->range_max(),vmin, vmax); 1253 write(0, info, strlen(info)); 1254 } 1255 return TCL_OK; 1256 } 1257 1258 static int 1259 VolumeDataStateOp(ClientData cdata, Tcl_Interp *interp, int objc, 1260 Tcl_Obj *CONST *objv) 1261 { 1262 int state; 1263 if (Tcl_GetBooleanFromObj(interp, objv[3], &state) != TCL_OK) { 1264 return TCL_ERROR; 1265 } 1266 vector<Volume *> ivol; 1267 if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) { 1268 return TCL_ERROR; 1269 } 1270 if (state) { 1271 vector<Volume *>::iterator iter; 1272 for (iter = ivol.begin(); iter != ivol.end(); iter++) { 1273 (*iter)->enable_data(); 1274 } 1275 } else { 1276 vector<Volume *>::iterator iter; 1277 for (iter = ivol.begin(); iter != ivol.end(); iter++) { 1278 (*iter)->disable_data(); 1279 } 1280 } 1281 return TCL_OK; 1282 } 1283 1284 static Rappture::CmdSpec volumeDataOps[] = 1285 { 1286 {"follows", 1, VolumeDataFollowsOp, 4, 4, "size",}, 1287 {"state", 1, VolumeDataStateOp, 4, 0, "bool ?indices?",}, 1288 }; 1289 static int nVolumeDataOps = NumCmdSpecs(volumeDataOps); 1290 1291 static int 1292 VolumeOutlineStateOp(ClientData cdata, Tcl_Interp *interp, int objc, 1293 Tcl_Obj *CONST *objv) 1294 { 1295 return TCL_OK; 1296 } 1297 static Rappture::CmdSpec volumeOutlineOps[] = 1298 { 1299 {"color", 1, VolumeOutlineColorOp, 6, 0, "r g b ?indices?",}, 1300 {"state", 1, VolumeOutlineStateOp, 4, 0, "bool ?indices?",}, 1301 {"visible", 1, VolumeOutlineVisibleOp, 4, 0, "bool ?indices?",}, 1302 }; 1303 static int nVolumeOutlineOps = NumCmdSpecs(volumeOutlineOps); 1304 1305 static Rappture::CmdSpec volumeShadingOps[] = 1306 { 1307 {"diffuse", 1, VolumeShadingDiffuseOp, 4, 0, "value ?indices?",}, 1308 {"isosurface", 1, VolumeShadingIsosurfaceOp, 4, 0, "bool ?indices?",}, 1309 {"opacity", 1, VolumeShadingOpacityOp, 4, 0, "value ?indices?",}, 1310 {"specular", 1, VolumeShadingSpecularOp, 4, 0, "value ?indices?",}, 1311 {"transfunc", 1, VolumeShadingTransFuncOp, 4, 0, "funcName ?indices?",}, 1312 }; 1313 static int nVolumeShadingOps = NumCmdSpecs(volumeShadingOps); 1314 1315 static Rappture::CmdSpec volumeOps[] = 1316 { 1317 {"animation", 2, VolumeAnimationOp, 3, 3, "oper ?args?",}, 1318 {"axis", 2, VolumeAxisOp, 3, 3, "label axis value ?indices?",}, 1319 {"data", 1, VolumeDataOp, 3, 3, "oper ?args?",}, 1320 {"outline", 1, VolumeOutlineOp, 3, 0, "oper ?args?",}, 1321 {"shading", 2, VolumeShadingOp, 3, 0, "oper ?args?",}, 1322 {"state", 2, VolumeStateOp, 3, 0, "bool ?indices?",}, 1323 {"test2", 1, VolumeTestOp, 2, 2, "",}, 1324 }; 1325 static int nVolumeOps = NumCmdSpecs(volumeOps); 1326 #endif 1099 1327 1100 1328 /* … … 1119 1347 if (objc < 2) { 1120 1348 Tcl_AppendResult(interp, "wrong # args: should be \"", 1121 1349 Tcl_GetString(objv[0]), " option arg arg...\"", (char*)NULL); 1122 1350 return TCL_ERROR; 1123 1351 } … … 1128 1356 if (objc < 3) { 1129 1357 Tcl_AppendResult(interp, "wrong # args: should be \"", 1130 1131 1132 return TCL_ERROR; 1133 } 1134 1358 Tcl_GetString(objv[0]), " axis option ?arg arg...?\"", 1359 (char*)NULL); 1360 return TCL_ERROR; 1361 } 1362 char *string = Tcl_GetString(objv[2]); 1135 1363 c = string[0]; 1136 1364 if ((c == 'l') && (strcmp(string, "label") == 0)) { 1137 1365 if (objc < 5) { 1138 1366 Tcl_AppendResult(interp, "wrong # args: should be \"", 1139 1140 1367 Tcl_GetString(objv[0]), 1368 " axis label x|y|z string ?volume ...?\"", (char*)NULL); 1141 1369 return TCL_ERROR; 1142 1370 } … … 1150 1378 } 1151 1379 vector<Volume *>::iterator iter; 1152 1153 1380 char *label; 1381 label = Tcl_GetString(objv[4]); 1154 1382 for (iter = ivol.begin(); iter != ivol.end(); iter++) { 1155 1383 (*iter)->set_label(axis, label); … … 1157 1385 } else { 1158 1386 Tcl_AppendResult(interp, "bad option \"", string, 1159 1387 "\": should be label", (char*)NULL); 1160 1388 return TCL_ERROR; 1161 1389 } … … 1163 1391 if (objc < 3) { 1164 1392 Tcl_AppendResult(interp, "wrong # args: should be \"", 1165 1166 1167 return TCL_ERROR; 1168 } 1169 1393 Tcl_GetString(objv[0]), " data option ?arg arg...?\"", 1394 (char*)NULL); 1395 return TCL_ERROR; 1396 } 1397 char *string = Tcl_GetString(objv[2]); 1170 1398 c = string[0]; 1171 1399 if ((c == 's') && (strcmp(string, "state") == 0)) { 1172 1400 if (objc < 4) { 1173 1401 Tcl_AppendResult(interp, "wrong # args: should be \"", 1174 1175 1402 Tcl_GetString(objv[0])," data state on|off ?volume...?\"", 1403 (char*)NULL); 1176 1404 return TCL_ERROR; 1177 1405 } … … 1198 1426 if (objc < 4) { 1199 1427 Tcl_AppendResult(interp, "wrong # args: should be \"", 1200 1428 Tcl_GetString(objv[0]), " data follows size", (char*)NULL); 1201 1429 return TCL_ERROR; 1202 1430 } … … 1300 1528 std::stringstream fdata; 1301 1529 fdata.write(buf.bytes(),buf.size()); 1302 1530 1303 1531 #if ISO_TEST 1304 1532 err = load_volume_stream2(n, fdata); … … 1350 1578 if (objc < 3) { 1351 1579 Tcl_AppendResult(interp, "wrong # args: should be \"", 1352 1353 1354 return TCL_ERROR; 1355 } 1356 1580 Tcl_GetString(objv[0]), " outline option ?arg arg...?\"", 1581 (char*)NULL); 1582 return TCL_ERROR; 1583 } 1584 char *string = Tcl_GetString(objv[2]); 1357 1585 c = string[0]; 1358 1586 if ((c == 's') && (strcmp(string, "state") == 0)) { 1359 1587 if (objc < 3) { 1360 1588 Tcl_AppendResult(interp, "wrong # args: should be \"", 1361 1362 1589 Tcl_GetString(objv[0]), 1590 " outline state on|off ?volume ...? \"", (char*)NULL); 1363 1591 return TCL_ERROR; 1364 1592 } … … 1405 1633 if (objc < 6) { 1406 1634 Tcl_AppendResult(interp, "wrong # args: should be \"", 1407 1408 1635 Tcl_GetString(objv[0]), 1636 " outline color R G B ?volume ...? \"", (char*)NULL); 1409 1637 return TCL_ERROR; 1410 1638 } … … 1430 1658 if (objc < 3) { 1431 1659 Tcl_AppendResult(interp, "wrong # args: should be \"", 1432 1433 1434 return TCL_ERROR; 1435 } 1436 1660 Tcl_GetString(objv[0]), " shading option ?arg arg...?\"", 1661 (char*)NULL); 1662 return TCL_ERROR; 1663 } 1664 char *string = Tcl_GetString(objv[2]); 1437 1665 c = string[0]; 1438 1666 if ((c == 't') && (strcmp(string, "transfunc") == 0)) { 1439 1667 if (objc < 4) { 1440 1668 Tcl_AppendResult(interp, "wrong # args: should be \"", 1441 1442 1669 Tcl_GetString(objv[0]), 1670 " shading transfunc name ?volume ...?\"", (char*)NULL); 1443 1671 return TCL_ERROR; 1444 1672 } 1445 1673 TransferFunction *tf; 1446 1674 char *name = Tcl_GetString(objv[3]); 1447 1675 tf = NanoVis::get_transfunc(name); 1448 1676 if (tf == NULL) { … … 1470 1698 if (objc < 4) { 1471 1699 Tcl_AppendResult(interp, "wrong # args: should be \"", 1472 1473 1700 Tcl_GetString(objv[0]), 1701 " shading diffuse value ?volume ...?\"", (char*)NULL); 1474 1702 return TCL_ERROR; 1475 1703 } … … 1490 1718 if (objc < 4) { 1491 1719 Tcl_AppendResult(interp, "wrong # args: should be \"", 1492 1493 1720 Tcl_GetString(objv[0]), 1721 " shading opacity value ?volume ...?\"", (char*)NULL); 1494 1722 return TCL_ERROR; 1495 1723 } … … 1509 1737 if (objc < 4) { 1510 1738 Tcl_AppendResult(interp, "wrong # args: should be \"", 1511 1512 1739 Tcl_GetString(objv[0]), 1740 " shading specular value ?volume ...?\"", (char*)NULL); 1513 1741 return TCL_ERROR; 1514 1742 } … … 1528 1756 if (objc < 4) { 1529 1757 Tcl_AppendResult(interp, "wrong # args: should be \"", 1530 1531 1758 Tcl_GetString(objv[0]), 1759 " shading isosurface on|off ?volume ...?\"", (char*)NULL); 1532 1760 return TCL_ERROR; 1533 1761 } … … 1553 1781 if (objc < 3) { 1554 1782 Tcl_AppendResult(interp, "wrong # args: should be \"", 1555 1556 1783 Tcl_GetString(objv[0]), " state on|off ?volume...?\"", 1784 (char*)NULL); 1557 1785 return TCL_ERROR; 1558 1786 } … … 1579 1807 if (objc < 3) { 1580 1808 Tcl_AppendResult(interp, "wrong # args: should be \"", 1581 1582 1583 return TCL_ERROR; 1584 } 1585 1586 1809 Tcl_GetString(objv[0]), " animation option ?args...?\"", 1810 (char*)NULL); 1811 return TCL_ERROR; 1812 } 1813 char *string = Tcl_GetString(objv[2]); 1814 char c = string[0]; 1587 1815 if ((c == 'v') && (strcmp(string,"volumes") == 0)) { 1588 1816 vector<unsigned int> ivol; … … 1595 1823 Trace("index: %d\n", *iter); 1596 1824 NanoVis::vol_renderer->addAnimatedVolume(NanoVis::volume[*iter], 1597 1825 *iter); 1598 1826 } 1599 1827 } else if ((c == 'c') && (strcmp(string,"capture") == 0)) { … … 1604 1832 } 1605 1833 VolumeInterpolator* interpolator; 1606 1834 interpolator = NanoVis::vol_renderer->getVolumeInterpolator(); 1607 1835 interpolator->start(); 1608 1836 if (interpolator->is_started()) { 1609 1837 char *fileName = (objc < 5) ? NULL : Tcl_GetString(objv[4]); 1610 1838 for (int frame_num = 0; frame_num < total; ++frame_num) { 1611 1839 float fraction; 1612 1840 1613 1841 fraction = ((float)frame_num) / (total - 1); … … 1623 1851 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 1624 1852 1625 1853 NanoVis::bmp_write_to_file(frame_num, fileName); 1626 1854 } 1627 1855 } 1628 1856 } else if ((c == 's') && (strcmp(string, "start") == 0)) { 1629 1857 NanoVis::vol_renderer->startVolumeAnimation(); 1630 1858 } else if ((c == 's') && (strcmp(string, "stop") == 0)) { 1631 1859 NanoVis::vol_renderer->stopVolumeAnimation(); 1632 1860 } else if ((c == 'c') && (strcmp(string, "clear") == 0)) { 1633 1861 NanoVis::vol_renderer->clearAnimatedVolumeInfo(); 1634 1862 } else { 1635 1863 Tcl_AppendResult(interp, "bad animation option \"", string, 1636 1864 "\": should be volumes, start, stop, or clear", (char*)NULL); 1637 1865 return TCL_ERROR; 1638 1866 } 1639 1867 } else if ((c == 't') && (strcmp(string, "test2") == 0)) { 1640 1868 NanoVis::volume[1]->disable_data(); … … 1655 1883 if (objc < 2) { 1656 1884 Tcl_AppendResult(interp, "wrong # args: should be \"", 1657 1885 Tcl_GetString(objv[0]), " option ?arg arg?", (char *)NULL); 1658 1886 return TCL_ERROR; 1659 1887 } … … 1663 1891 if (objc != 3) { 1664 1892 Tcl_AppendResult(interp, "wrong # args: should be \"", 1665 1893 Tcl_GetString(objv[0]), " vectorid volume", (char *)NULL); 1666 1894 return TCL_ERROR; 1667 1895 } … … 1689 1917 if (objc != 3) { 1690 1918 Tcl_AppendResult(interp, "wrong # args: should be \"", 1691 1919 Tcl_GetString(objv[0]), " lic on|off\"", (char*)NULL); 1692 1920 return TCL_ERROR; 1693 1921 } … … 1700 1928 if (objc < 3) { 1701 1929 Tcl_AppendResult(interp, "wrong # args: should be \"", 1702 1703 1704 return TCL_ERROR; 1705 } 1706 1930 Tcl_GetString(objv[0]), " particle visible|slice|slicepos arg \"", 1931 (char*)NULL); 1932 return TCL_ERROR; 1933 } 1934 char *string = Tcl_GetString(objv[2]); 1707 1935 c = string[0]; 1708 1936 if ((c == 'v') && (strcmp(string, "visible") == 0)) { 1709 1937 if (objc != 4) { 1710 1938 Tcl_AppendResult(interp, "wrong # args: should be \"", 1711 1712 1939 Tcl_GetString(objv[0]), " particle visible on|off\"", 1940 (char*)NULL); 1713 1941 return TCL_ERROR; 1714 1942 } … … 1721 1949 if (objc != 4) { 1722 1950 Tcl_AppendResult(interp, "wrong # args: should be \"", 1723 1951 Tcl_GetString(objv[0]), 1724 1952 " particle slice volume\"", (char*)NULL); 1725 1953 return TCL_ERROR; … … 1733 1961 if (objc != 4) { 1734 1962 Tcl_AppendResult(interp, "wrong # args: should be \"", 1735 1736 1963 Tcl_GetString(objv[0]), " particle slicepos value\"", 1964 (char*)NULL); 1737 1965 return TCL_ERROR; 1738 1966 } … … 1759 1987 } else { 1760 1988 Tcl_AppendResult(interp, "unknown option \"",string,"\": should be \"", 1761 1989 Tcl_GetString(objv[0]), " visible, slice, or slicepos\"", 1762 1990 (char *)NULL); 1763 1991 return TCL_ERROR; … … 1768 1996 if (objc > 4 || objc < 3) { 1769 1997 Tcl_AppendResult(interp, "wrong # args: should be \"", 1770 1771 1998 Tcl_GetString(objv[0]), " capture numframes [directory]\"", 1999 (char*)NULL); 1772 2000 return TCL_ERROR; 1773 2001 } … … 1784 2012 } 1785 2013 // Karl 1786 1787 1788 1789 2014 // 2015 Trace("FLOW started\n"); 2016 char *fileName; 2017 fileName = (objc < 4) ? NULL : Tcl_GetString(objv[3]); 1790 2018 for (int frame_count = 0; frame_count < total_frame_count; 1791 2019 frame_count++) { … … 1808 2036 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 1809 2037 1810 1811 } 1812 2038 NanoVis::bmp_write_to_file(frame_count, fileName); 2039 } 2040 Trace("FLOW end\n"); 1813 2041 // put your code... 1814 2042 if (NanoVis::licRenderer) { … … 1822 2050 if (objc < 3) { 1823 2051 Tcl_AppendResult(interp, "wrong # args: should be \"", 1824 1825 return TCL_ERROR; 1826 } 1827 2052 Tcl_GetString(objv[0]), " data follows ?args?", (char *)NULL); 2053 return TCL_ERROR; 2054 } 2055 char *string = Tcl_GetString(objv[2]);; 1828 2056 c = string[0]; 1829 2057 if ((c == 'f') && (strcmp(string,"follows") == 0)) { 1830 2058 if (objc != 4) { 1831 2059 Tcl_AppendResult(interp, "wrong # args: should be \"", 1832 1833 2060 Tcl_GetString(objv[0]), " data follows length", 2061 (char *)NULL); 1834 2062 return TCL_ERROR; 1835 2063 } … … 1875 2103 static int 1876 2104 HeightMapDataFollowsOp(ClientData cdata, Tcl_Interp *interp, int objc, 1877 2105 Tcl_Obj *CONST *objv) 1878 2106 { 1879 2107 Rappture::Buffer buf; … … 1881 2109 1882 2110 if (Tcl_GetIntFromObj(interp, objv[3], &nBytes) != TCL_OK) { 1883 2111 return TCL_ERROR; 1884 2112 } 1885 2113 if (GetDataStream(interp, buf, nBytes) != TCL_OK) { 1886 2114 return TCL_ERROR; 1887 2115 } 1888 2116 buf.append("\0", 1); … … 1890 2118 result = Tcl_Eval(interp, buf.bytes()); 1891 2119 if (result != TCL_OK) { 1892 1893 1894 2120 fprintf(stderr, "error in command: %s\n", 2121 Tcl_GetStringResult(interp)); 2122 fflush(stderr); 1895 2123 } 1896 2124 return result; … … 1899 2127 static int 1900 2128 HeightMapDataVisibleOp(ClientData cdata, Tcl_Interp *interp, int objc, 1901 2129 Tcl_Obj *CONST *objv) 1902 2130 { 1903 2131 int ivisible; 1904 2132 if (Tcl_GetBooleanFromObj(interp, objv[3], &ivisible) != TCL_OK) { 1905 2133 return TCL_ERROR; 1906 2134 } 1907 2135 vector<unsigned int> indices; 1908 2136 if (GetIndices(interp, objc - 4, objv + 4, &indices) != TCL_OK) { 1909 2137 return TCL_ERROR; 1910 2138 } 1911 2139 bool visible; 1912 2140 visible = (bool)ivisible; 1913 2141 for (unsigned int i = 0; i < indices.size(); ++i) { 1914 1915 1916 1917 2142 if ((indices[i] < NanoVis::heightMap.size()) && 2143 (NanoVis::heightMap[indices[i]] != NULL)) { 2144 NanoVis::heightMap[indices[i]]->setVisible(visible); 2145 } 1918 2146 } 1919 2147 return TCL_OK; … … 1929 2157 static int 1930 2158 HeightMapDataOp(ClientData cdata, Tcl_Interp *interp, int objc, 1931 2159 Tcl_Obj *CONST *objv) 1932 2160 { 1933 2161 Tcl_ObjCmdProc *proc; 1934 2162 1935 2163 proc = Rappture::GetOpFromObj(interp, nHeightMapDataOps, heightMapDataOps, 1936 2164 Rappture::CMDSPEC_ARG2, objc, objv, 0); 1937 2165 if (proc == NULL) { 1938 2166 return TCL_ERROR; 1939 2167 } 1940 2168 return (*proc) (cdata, interp, objc, objv); … … 1944 2172 static int 1945 2173 HeightMapLineContourColorOp(ClientData cdata, Tcl_Interp *interp, int objc, 1946 2174 Tcl_Obj *CONST *objv) 1947 2175 { 1948 2176 float rgb[3]; 1949 2177 if (GetColor(interp, objc - 3, objv + 3, rgb) != TCL_OK) { 1950 2178 return TCL_ERROR; 1951 2179 } 1952 2180 vector<unsigned int> indices; 1953 2181 if (GetIndices(interp, objc-6, objv + 6, &indices) != TCL_OK) { 1954 2182 return TCL_ERROR; 1955 2183 } 1956 2184 for (unsigned int i = 0; i < indices.size(); ++i) { 1957 1958 1959 1960 2185 if ((indices[i] < NanoVis::heightMap.size()) && 2186 (NanoVis::heightMap[indices[i]] != NULL)) { 2187 NanoVis::heightMap[indices[i]]->setLineContourColor(rgb); 2188 } 1961 2189 } 1962 2190 return TCL_OK; … … 1965 2193 static int 1966 2194 HeightMapLineContourVisibleOp(ClientData cdata, Tcl_Interp *interp, int objc, 1967 2195 Tcl_Obj *CONST *objv) 1968 2196 { 1969 2197 int ivisible; 1970 2198 bool visible; 1971 2199 if (Tcl_GetBooleanFromObj(interp, objv[3], &ivisible) != TCL_OK) { 1972 2200 return TCL_ERROR; 1973 2201 } 1974 2202 visible = (bool)ivisible; 1975 2203 vector<unsigned int> indices; 1976 2204 if (GetIndices(interp, objc-4, objv+4, &indices) != TCL_OK) { 1977 2205 return TCL_ERROR; 1978 2206 } 1979 2207 for (unsigned int i = 0; i < indices.size(); ++i) { 1980 1981 1982 1983 2208 if ((indices[i] < NanoVis::heightMap.size()) && 2209 (NanoVis::heightMap[indices[i]] != NULL)) { 2210 NanoVis::heightMap[indices[i]]->setLineContourVisible(visible); 2211 } 1984 2212 } 1985 2213 return TCL_OK; … … 1995 2223 static int 1996 2224 HeightMapLineContourOp(ClientData cdata, Tcl_Interp *interp, int objc, 1997 2225 Tcl_Obj *CONST *objv) 1998 2226 { 1999 2227 Tcl_ObjCmdProc *proc; 2000 2228 2001 2229 proc = Rappture::GetOpFromObj(interp, nHeightMapLineContourOps, 2002 2230 heightMapLineContourOps, Rappture::CMDSPEC_ARG2, objc, objv, 0); 2003 2231 if (proc == NULL) { 2004 2232 return TCL_ERROR; 2005 2233 } 2006 2234 return (*proc) (cdata, interp, objc, objv); … … 2009 2237 static int 2010 2238 HeightMapCullOp(ClientData cdata, Tcl_Interp *interp, int objc, 2011 2239 Tcl_Obj *CONST *objv) 2012 2240 { 2013 2241 graphics::RenderContext::CullMode mode; 2014 2242 if (GetCullMode(interp, objv[2], &mode) != TCL_OK) { 2015 2243 return TCL_ERROR; 2016 2244 } 2017 2245 NanoVis::renderContext->setCullMode(mode); … … 2021 2249 static int 2022 2250 HeightMapCreateOp(ClientData cdata, Tcl_Interp *interp, int objc, 2023 2251 Tcl_Obj *CONST *objv) 2024 2252 { 2025 2253 HeightMap *hMap; … … 2028 2256 hMap = CreateHeightMap(cdata, interp, objc - 2, objv + 2); 2029 2257 if (hMap == NULL) { 2030 2258 return TCL_ERROR; 2031 2259 } 2032 2260 NanoVis::heightMap.push_back(hMap); … … 2037 2265 static int 2038 2266 HeightMapLegendOp(ClientData cdata, Tcl_Interp *interp, int objc, 2039 2267 Tcl_Obj *CONST *objv) 2040 2268 { 2041 2269 HeightMap *hMap; 2042 2270 if (GetHeightMap(interp, objv[2], &hMap) != TCL_OK) { 2043 2271 return TCL_ERROR; 2044 2272 } 2045 2273 TransferFunction *tf; 2046 2274 tf = hMap->getColorMap(); 2047 2275 if (tf == NULL) { 2048 2049 2050 2276 Tcl_AppendResult(interp, "no transfer function defined for heightmap \"", 2277 Tcl_GetString(objv[2]), "\"", (char*)NULL); 2278 return TCL_ERROR; 2051 2279 } 2052 2280 int w, h; 2053 2281 if ((Tcl_GetIntFromObj(interp, objv[3], &w) != TCL_OK) || 2054 2055 2282 (Tcl_GetIntFromObj(interp, objv[4], &h) != TCL_OK)) { 2283 return TCL_ERROR; 2056 2284 } 2057 2285 NanoVis::render_legend(tf, hMap->range_min(), hMap->range_max(), 2058 2286 w, h, "label"); 2059 2287 return TCL_OK; 2060 2288 } … … 2062 2290 static int 2063 2291 HeightMapPolygonOp(ClientData cdata, Tcl_Interp *interp, int objc, 2064 2292 Tcl_Obj *CONST *objv) 2065 2293 { 2066 2294 graphics::RenderContext::PolygonMode mode; 2067 2295 if (GetPolygonMode(interp, objv[2], &mode) != TCL_OK) { 2068 2296 return TCL_ERROR; 2069 2297 } 2070 2298 NanoVis::renderContext->setPolygonMode(mode); … … 2074 2302 static int 2075 2303 HeightMapShadeOp(ClientData cdata, Tcl_Interp *interp, int objc, 2076 2304 Tcl_Obj *CONST *objv) 2077 2305 { 2078 2306 graphics::RenderContext::ShadingModel model; 2079 2307 if (GetShadingModel(interp, objv[2], &model) != TCL_OK) { 2080 2308 return TCL_ERROR; 2081 2309 } 2082 2310 NanoVis::renderContext->setShadingModel(model); … … 2086 2314 static int 2087 2315 HeightMapTestOp(ClientData cdata, Tcl_Interp *interp, int objc, 2088 2316 Tcl_Obj *CONST *objv) 2089 2317 { 2090 2318 srand((unsigned)time(NULL)); … … 2097 2325 float x; 2098 2326 for (int i = 0; i < size; ++i) { 2099 2100 2101 2327 x = - 10 + i%20; 2328 data[i] = exp(- (x * x)/(2 * sigma * sigma)) / 2329 (sigma * sqrt(2.0)) / mean * 2 + 1000; 2102 2330 } 2103 2331 … … 2125 2353 static int 2126 2354 HeightMapTransFuncOp(ClientData cdata, Tcl_Interp *interp, int objc, 2127 2355 Tcl_Obj *CONST *objv) 2128 2356 { 2129 2357 char *name; … … 2132 2360 tf = NanoVis::get_transfunc(name); 2133 2361 if (tf == NULL) { 2134 2135 2136 2362 Tcl_AppendResult(interp, "transfer function \"", name, 2363 "\" is not defined", (char*)NULL); 2364 return TCL_ERROR; 2137 2365 } 2138 2366 vector<unsigned int> indices; 2139 2367 if (GetIndices(interp, objc - 3, objv + 3, &indices) != TCL_OK) { 2140 2368 return TCL_ERROR; 2141 2369 } 2142 2370 for (unsigned int i = 0; i < indices.size(); ++i) { 2143 2144 2145 2146 2371 if ((indices[i] < NanoVis::heightMap.size()) && 2372 (NanoVis::heightMap[indices[i]] != NULL)) { 2373 NanoVis::heightMap[indices[i]]->setColorMap(tf); 2374 } 2147 2375 } 2148 2376 return TCL_OK; … … 2152 2380 { 2153 2381 {"create", 2, HeightMapCreateOp, 9, 9, 2154 2382 "xmin ymin xmax ymax xnum ynum values",}, 2155 2383 {"cull", 2, HeightMapCullOp, 3, 3, "mode",}, 2156 2384 {"data", 1, HeightMapDataOp, 3, 0, "oper ?args?",}, … … 2170 2398 2171 2399 proc = Rappture::GetOpFromObj(interp, nHeightMapOps, heightMapOps, 2172 2400 Rappture::CMDSPEC_ARG1, objc, objv, 0); 2173 2401 if (proc == NULL) { 2174 2402 return TCL_ERROR; 2175 2403 } 2176 2404 return (*proc) (cdata, interp, objc, objv); … … 2179 2407 static int 2180 2408 GridAxisColorOp(ClientData cdata, Tcl_Interp *interp, int objc, 2181 2409 Tcl_Obj *CONST *objv) 2182 2410 { 2183 2411 float r, g, b, a; 2184 2412 if ((GetFloatFromObj(interp, objv[2], &r) != TCL_OK) || 2185 2186 2187 2413 (GetFloatFromObj(interp, objv[3], &g) != TCL_OK) || 2414 (GetFloatFromObj(interp, objv[4], &b) != TCL_OK)) { 2415 return TCL_ERROR; 2188 2416 } 2189 2417 a = 1.0f; 2190 2418 if ((objc == 6) && (GetFloatFromObj(interp, objv[5], &a) != TCL_OK)) { 2191 2419 return TCL_ERROR; 2192 2420 } 2193 2421 if (NanoVis::grid) { 2194 2422 NanoVis::grid->setAxisColor(r, g, b, a); 2195 2423 } 2196 2424 return TCL_OK; … … 2199 2427 static int 2200 2428 GridAxisNameOp(ClientData cdata, Tcl_Interp *interp, int objc, 2201 2429 Tcl_Obj *CONST *objv) 2202 2430 { 2203 2431 int axisId; 2204 2432 if (GetAxisFromObj(interp, objv[2], &axisId) != TCL_OK) { 2205 2433 return TCL_ERROR; 2206 2434 } 2207 2435 if (NanoVis::grid) { 2208 2436 NanoVis::grid->setAxisName(axisId, Tcl_GetString(objv[3])); 2209 2437 } 2210 2438 return TCL_OK; … … 2213 2441 static int 2214 2442 GridLineColorOp(ClientData cdata, Tcl_Interp *interp, int objc, 2215 2443 Tcl_Obj *CONST *objv) 2216 2444 { 2217 2445 float r, g, b, a; 2218 2446 if ((GetFloatFromObj(interp, objv[2], &r) != TCL_OK) || 2219 2220 2221 2447 (GetFloatFromObj(interp, objv[3], &g) != TCL_OK) || 2448 (GetFloatFromObj(interp, objv[4], &b) != TCL_OK)) { 2449 return TCL_ERROR; 2222 2450 } 2223 2451 a = 1.0f; 2224 2452 if ((objc == 6) && (GetFloatFromObj(interp, objv[5], &a) != TCL_OK)) { 2225 2453 return TCL_ERROR; 2226 2454 } 2227 2455 if (NanoVis::grid) { 2228 2456 NanoVis::grid->setGridLineColor(r, g, b, a); 2229 2457 } 2230 2458 return TCL_OK; … … 2233 2461 static int 2234 2462 GridLineCountOp(ClientData cdata, Tcl_Interp *interp, int objc, 2235 2463 Tcl_Obj *CONST *objv) 2236 2464 { 2237 2465 int x, y, z; 2238 2466 2239 2467 if ((Tcl_GetIntFromObj(interp, objv[2], &x) != TCL_OK) || 2240 2241 2242 2468 (Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK) || 2469 (Tcl_GetIntFromObj(interp, objv[4], &z) != TCL_OK)) { 2470 return TCL_ERROR; 2243 2471 } 2244 2472 if (NanoVis::grid) { 2245 2473 NanoVis::grid->setGridLineCount(x, y, z); 2246 2474 } 2247 2475 return TCL_OK; … … 2250 2478 static int 2251 2479 GridMinMaxOp(ClientData cdata, Tcl_Interp *interp, int objc, 2252 2480 Tcl_Obj *CONST *objv) 2253 2481 { 2254 2482 double x1, y1, z1, x2, y2, z2; 2255 2483 if ((Tcl_GetDoubleFromObj(interp, objv[2], &x1) != TCL_OK) || 2256 2257 2258 2259 2260 2261 2484 (Tcl_GetDoubleFromObj(interp, objv[3], &y1) != TCL_OK) || 2485 (Tcl_GetDoubleFromObj(interp, objv[4], &z1) != TCL_OK) || 2486 (Tcl_GetDoubleFromObj(interp, objv[5], &x2) != TCL_OK) || 2487 (Tcl_GetDoubleFromObj(interp, objv[6], &y2) != TCL_OK) || 2488 (Tcl_GetDoubleFromObj(interp, objv[7], &z2) != TCL_OK)) { 2489 return TCL_ERROR; 2262 2490 } 2263 2491 if (NanoVis::grid) { 2264 2492 NanoVis::grid->setMinMax(Vector3(x1, y1, z1), Vector3(x2, y2, z2)); 2265 2493 } 2266 2494 return TCL_OK; … … 2269 2497 static int 2270 2498 GridVisibleOp(ClientData cdata, Tcl_Interp *interp, int objc, 2271 2499 Tcl_Obj *CONST *objv) 2272 2500 { 2273 2501 int ivisible; 2274 2502 2275 2503 if (Tcl_GetBooleanFromObj(interp, objv[2], &ivisible) != TCL_OK) { 2276 2504 return TCL_ERROR; 2277 2505 } 2278 2506 NanoVis::grid->setVisible((bool)ivisible); … … 2282 2510 static Rappture::CmdSpec gridOps[] = 2283 2511 { 2284 {"axiscolor", 5, GridAxisColorOp, 2285 {"axisname", 5, GridAxisNameOp, 2286 {"linecolor", 7, GridLineColorOp, 2287 {"linecount", 7, GridLineCountOp, 2288 {"minmax", 1, GridMinMaxOp, 2289 {"visible", 1, GridVisibleOp, 2512 {"axiscolor", 5, GridAxisColorOp, 5, 6, "r g b ?a?",}, 2513 {"axisname", 5, GridAxisNameOp, 5, 5, "index width height",}, 2514 {"linecolor", 7, GridLineColorOp, 5, 6, "r g b ?a?",}, 2515 {"linecount", 7, GridLineCountOp, 5, 5, "xCount yCount zCount",}, 2516 {"minmax", 1, GridMinMaxOp, 8, 8, "xMin yMin zMin xMax yMax zMax",}, 2517 {"visible", 1, GridVisibleOp, 3, 3, "bool",}, 2290 2518 }; 2291 2519 static int nGridOps = NumCmdSpecs(gridOps); … … 2297 2525 2298 2526 proc = Rappture::GetOpFromObj(interp, nGridOps, gridOps, 2299 2527 Rappture::CMDSPEC_ARG1, objc, objv, 0); 2300 2528 if (proc == NULL) { 2301 2529 return TCL_ERROR; 2302 2530 } 2303 2531 return (*proc) (cdata, interp, objc, objv); … … 2309 2537 if (objc < 2) { 2310 2538 Tcl_AppendResult(interp, "wrong # args: should be \"", 2311 2539 Tcl_GetString(objv[0]), " option arg arg...\"", (char*)NULL); 2312 2540 return TCL_ERROR; 2313 2541 } … … 2338 2566 if (objc != 4) { 2339 2567 Tcl_AppendResult(interp, "wrong # args: should be \"", 2340 2568 Tcl_GetString(objv[0]), " plane_index w h \"", (char*)NULL); 2341 2569 return TCL_ERROR; 2342 2570 } … … 2379 2607 if (objc != 3) { 2380 2608 Tcl_AppendResult(interp, "wrong # args: should be \"", 2381 2609 Tcl_GetString(objv[0]), " plane_index tf_index \"", (char*)NULL); 2382 2610 return TCL_ERROR; 2383 2611 } … … 2396 2624 static int 2397 2625 PlaneEnableOp(ClientData cdata, Tcl_Interp *interp, int objc, 2398 2626 Tcl_Obj *CONST *objv) 2399 2627 { 2400 2628 fprintf(stderr,"enable a plane so the 2D renderer can render it command\n"); … … 2402 2630 if (objc != 3) { 2403 2631 Tcl_AppendResult(interp, "wrong # args: should be \"", 2404 2632 Tcl_GetString(objv[0]), " plane_index mode \"", (char*)NULL); 2405 2633 return TCL_ERROR; 2406 2634 } … … 2422 2650 static Rappture::CmdSpec planeOps[] = 2423 2651 { 2424 {"enable", 1, PlaneEnableOp, 2425 {"link", 1, PlaneLinkOp,4, 4, "planeIdx transfuncIdx",},2426 {"new", 1, PlaneNewOp,5, 5, "planeIdx width height",},2652 {"enable", 1, PlaneEnableOp, 4, 4, "planeIdx mode",}, 2653 {"link", 1, PlaneLinkOp, 4, 4, "planeIdx transfuncIdx",}, 2654 {"new", 1, PlaneNewOp, 5, 5, "planeIdx width height",}, 2427 2655 }; 2428 2656 static int nPlaneOps = NumCmdSpecs(planeOps); … … 2434 2662 2435 2663 proc = Rappture::GetOpFromObj(interp, nPlaneOps, planeOps, 2436 2664 Rappture::CMDSPEC_ARG1, objc, objv, 0); 2437 2665 if (proc == NULL) { 2438 2666 return TCL_ERROR; 2439 2667 } 2440 2668 return (*proc) (cdata, interp, objc, objv); 2441 2669 } 2442 2670 2443 #endif 2671 #endif /*PLANE_CMD*/ 2444 2672 2445 2673 /* … … 2472 2700 int i; 2473 2701 for (i = 1; i < objc; i += 2) { 2474 2475 2476 2702 char *string; 2703 2704 string = Tcl_GetString(objv[i]); 2477 2705 if (strcmp(string, "xmin") == 0) { 2478 2706 if (GetFloatFromObj(interp, objv[i+1], &xMin) != TCL_OK) { … … 2510 2738 } 2511 2739 } else if (strcmp(string, "zvalues") == 0) { 2512 2740 Tcl_Obj **zObj; 2513 2741 2514 2742 if (Tcl_ListObjGetElements(interp, objv[i+1], &zNum, &zObj)!= TCL_OK) { … … 2565 2793 Tcl_DStringInit(&cmdbuffer); 2566 2794 2567 Tcl_CreateObjCommand(interp, "axis", AxisCmd,NULL, NULL);2568 Tcl_CreateObjCommand(interp, "camera", CameraCmd,NULL, NULL);2569 Tcl_CreateObjCommand(interp, "cutplane", CutplaneCmd,NULL, NULL);2570 Tcl_CreateObjCommand(interp, "flow", FlowCmd,NULL, NULL);2571 Tcl_CreateObjCommand(interp, "grid", GridCmd,NULL, NULL);2572 Tcl_CreateObjCommand(interp, "heightmap", HeightMapCmd,NULL, NULL);2573 Tcl_CreateObjCommand(interp, "legend", LegendCmd,NULL, NULL);2574 Tcl_CreateObjCommand(interp, "screen", ScreenCmd,NULL, NULL);2575 Tcl_CreateObjCommand(interp, "screenshot", ScreenShotCmd,NULL, NULL);2576 Tcl_CreateObjCommand(interp, "transfunc", TransfuncCmd,NULL, NULL);2577 Tcl_CreateObjCommand(interp, "unirect2d", UniRect2dCmd,NULL, NULL);2578 Tcl_CreateObjCommand(interp, "up", UpCmd,NULL, NULL);2579 Tcl_CreateObjCommand(interp, "volume", VolumeCmd,NULL, NULL);2795 Tcl_CreateObjCommand(interp, "axis", AxisCmd, NULL, NULL); 2796 Tcl_CreateObjCommand(interp, "camera", CameraCmd, NULL, NULL); 2797 Tcl_CreateObjCommand(interp, "cutplane", CutplaneCmd, NULL, NULL); 2798 Tcl_CreateObjCommand(interp, "flow", FlowCmd, NULL, NULL); 2799 Tcl_CreateObjCommand(interp, "grid", GridCmd, NULL, NULL); 2800 Tcl_CreateObjCommand(interp, "heightmap", HeightMapCmd, NULL, NULL); 2801 Tcl_CreateObjCommand(interp, "legend", LegendCmd, NULL, NULL); 2802 Tcl_CreateObjCommand(interp, "screen", ScreenCmd, NULL, NULL); 2803 Tcl_CreateObjCommand(interp, "screenshot", ScreenShotCmd, NULL, NULL); 2804 Tcl_CreateObjCommand(interp, "transfunc", TransfuncCmd, NULL, NULL); 2805 Tcl_CreateObjCommand(interp, "unirect2d", UniRect2dCmd, NULL, NULL); 2806 Tcl_CreateObjCommand(interp, "up", UpCmd, NULL, NULL); 2807 Tcl_CreateObjCommand(interp, "volume", VolumeCmd, NULL, NULL); 2580 2808 #if __TEST_CODE__ 2581 2809 Tcl_CreateObjCommand(interp, "test", TestCmd, NULL, NULL);
Note: See TracChangeset
for help on using the changeset viewer.