Changeset 913
- Timestamp:
- Mar 4, 2008, 2:14:33 PM (17 years ago)
- Location:
- trunk/vizservers/nanovis
- Files:
-
- 4 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/vizservers/nanovis/Command.cpp
r911 r913 24 24 /* 25 25 * TODO: In no particular order... 26 * o Convert to Tcl_CmdObj interface. 26 * o Convert to Tcl_CmdObj interface. (done) 27 27 * o Use Tcl command option parser to reduce size of procedures, remove 28 28 * lots of extra error checking code. … … 36 36 */ 37 37 38 #define ISO_TEST 038 #define ISO_TEST 1 39 39 #define PLANE_CMDS 0 40 40 #define __TEST_CODE__ 0 … … 42 42 #define _LOCAL_ZINC_TEST_ 0 43 43 44 #include <tcl.h> 45 #include "Trace.h" 44 46 #include "Command.h" 45 #include "Trace.h"46 47 47 #include "nanovis.h" 48 #include "CmdProc.h" 48 49 49 50 #include "RpField1D.h" … … 129 130 }"; 130 131 131 static Tcl_ CmdProc AxisCmd;132 static Tcl_ CmdProc CameraCmd;133 static Tcl_ CmdProc CutplaneCmd;134 static Tcl_ CmdProc GridCmd;135 static Tcl_ CmdProc LegendCmd;132 static Tcl_ObjCmdProc AxisCmd; 133 static Tcl_ObjCmdProc CameraCmd; 134 static Tcl_ObjCmdProc CutplaneCmd; 135 static Tcl_ObjCmdProc GridCmd; 136 static Tcl_ObjCmdProc LegendCmd; 136 137 #if PLANE_CMDS 137 static Tcl_ CmdProc PlaneEnableCmd;138 static Tcl_ CmdProc PlaneLinkCmd;139 static Tcl_ CmdProc PlaneNewCmd;138 static Tcl_ObjCmdProc PlaneEnableCmd; 139 static Tcl_ObjCmdProc PlaneLinkCmd; 140 static Tcl_ObjCmdProc PlaneNewCmd; 140 141 #endif 141 static Tcl_ CmdProc ScreenCmd;142 static Tcl_ CmdProc ScreenShotCmd;143 static Tcl_ CmdProc TransfuncCmd;144 static Tcl_ CmdProc UniRect2dCmd;145 static Tcl_ CmdProc UpCmd;146 static Tcl_ CmdProc VolumeCmd;147 static Tcl_ CmdProc FlowCmd;148 149 static int GetVolumeIndices(Tcl_Interp *interp, int argc, const char *argv[],142 static Tcl_ObjCmdProc ScreenCmd; 143 static Tcl_ObjCmdProc ScreenShotCmd; 144 static Tcl_ObjCmdProc TransfuncCmd; 145 static Tcl_ObjCmdProc UniRect2dCmd; 146 static Tcl_ObjCmdProc UpCmd; 147 static Tcl_ObjCmdProc VolumeCmd; 148 static Tcl_ObjCmdProc FlowCmd; 149 150 static int GetVolumeIndices(Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv, 150 151 vector<unsigned int>* vectorPtr); 151 static int GetVolumes(Tcl_Interp *interp, int argc, const char *argv[],152 static int GetVolumes(Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv, 152 153 vector<Volume *>* vectorPtr); 153 static int GetVolume(Tcl_Interp *interp, const char *string, 154 Volume **volPtrPtr); 155 static int GetVolumeIndex(Tcl_Interp *interp, const char *string, 156 unsigned int *indexPtr); 157 static int GetHeightMap(Tcl_Interp *interp, const char *string, 158 HeightMap **hmPtrPtr); 159 static int GetIndices(Tcl_Interp *interp, int argc, const char *argv[], 154 static int GetVolumeFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, 155 Volume **volPtrPtr); 156 static int GetVolumeIndex(Tcl_Interp *interp, Tcl_Obj *objPtr, 157 unsigned int *indexPtr); 158 static int GetHeightMap(Tcl_Interp *interp, Tcl_Obj *objPtr, HeightMap **hmPtrPtr); 159 static int GetIndices(Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv, 160 160 vector<unsigned int>* vectorPtr); 161 static int GetAxis(Tcl_Interp *interp, const char *string, int *valPtr); 162 static int GetColor(Tcl_Interp *interp, int argc, const char *argv[], 161 static int GetAxisFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, int *indexPtr); 162 static int GetAxisDirFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, int *indexPtr, 163 int *dirPtr); 164 static int GetColor(Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv, 163 165 float *rgbPtr); 164 166 static int GetDataStream(Tcl_Interp *interp, Rappture::Buffer &buf, 165 167 int nBytes); 166 168 static HeightMap *CreateHeightMap(ClientData clientData, Tcl_Interp *interp, 167 int argc, const char *argv[]);168 169 static int 170 GetFloat (Tcl_Interp *interp, const char *string, float *valuePtr)169 int objc, Tcl_Obj *CONST *objv); 170 171 static int 172 GetFloatFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, float *valuePtr) 171 173 { 172 174 double value; 173 175 174 if (Tcl_GetDouble (interp, string, &value) != TCL_OK) {176 if (Tcl_GetDoubleFromObj(interp, objPtr, &value) != TCL_OK) { 175 177 return TCL_ERROR; 176 178 } … … 180 182 181 183 static int 182 GetCullMode(Tcl_Interp *interp, const char *string, 183 graphics::RenderContext::CullMode *modePtr) 184 { 184 GetCullMode(Tcl_Interp *interp, Tcl_Obj *objPtr, 185 graphics::RenderContext::CullMode *modePtr) 186 { 187 char *string = Tcl_GetString(objPtr); 185 188 if (strcmp(string, "none") == 0) { 186 189 *modePtr = graphics::RenderContext::NO_CULL; … … 198 201 199 202 static int 200 GetShadingModel(Tcl_Interp *interp, const char *string,203 GetShadingModel(Tcl_Interp *interp, Tcl_Obj *objPtr, 201 204 graphics::RenderContext::ShadingModel *modelPtr) 202 205 { 206 char *string = Tcl_GetString(objPtr); 203 207 if (strcmp(string,"flat") == 0) { 204 208 *modelPtr = graphics::RenderContext::FLAT; … … 214 218 215 219 static int 216 GetPolygonMode(Tcl_Interp *interp, const char *string,220 GetPolygonMode(Tcl_Interp *interp, Tcl_Obj *objPtr, 217 221 graphics::RenderContext::PolygonMode *modePtr) 218 222 { 223 char *string = Tcl_GetString(objPtr); 219 224 if (strcmp(string,"wireframe") == 0) { 220 225 *modePtr = graphics::RenderContext::LINE; … … 281 286 */ 282 287 static int 283 CameraCmd(ClientData cdata, Tcl_Interp *interp, int argc, const char *argv[]) 284 { 285 if (argc < 2) { 286 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 287 " option arg arg...\"", (char*)NULL); 288 return TCL_ERROR; 289 } 290 291 char c = argv[1][0]; 292 if ((c == 'a') && (strcmp(argv[1],"angle") == 0)) { 293 if (argc != 5) { 294 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 295 " angle xangle yangle zangle\"", (char*)NULL); 288 CameraCmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv) 289 { 290 if (objc < 2) { 291 Tcl_AppendResult(interp, "wrong # args: should be \"", 292 Tcl_GetString(objv[0]), " option arg arg...\"", (char*)NULL); 293 return TCL_ERROR; 294 } 295 296 char *string = Tcl_GetString(objv[1]); 297 char c = string[0]; 298 if ((c == 'a') && (strcmp(string, "angle") == 0)) { 299 if (objc != 5) { 300 Tcl_AppendResult(interp, "wrong # args: should be \"", 301 Tcl_GetString(objv[0]), " angle xangle yangle zangle\"", 302 (char*)NULL); 296 303 return TCL_ERROR; 297 304 } 298 305 double xangle, yangle, zangle; 299 if ((Tcl_GetDouble (interp, argv[2], &xangle) != TCL_OK) ||300 (Tcl_GetDouble (interp, argv[3], &yangle) != TCL_OK) ||301 (Tcl_GetDouble (interp, argv[4], &zangle) != TCL_OK)) {306 if ((Tcl_GetDoubleFromObj(interp, objv[2], &xangle) != TCL_OK) || 307 (Tcl_GetDoubleFromObj(interp, objv[3], &yangle) != TCL_OK) || 308 (Tcl_GetDoubleFromObj(interp, objv[4], &zangle) != TCL_OK)) { 302 309 return TCL_ERROR; 303 310 } 304 311 NanoVis::cam->rotate(xangle, yangle, zangle); 305 } else if ((c == 'a') && (strcmp(argv[1], "aim") == 0)) { 306 if (argc != 5) { 307 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 308 " aim x y z\"", (char*)NULL); 309 return TCL_ERROR; 310 } 311 312 } else if ((c == 'a') && (strcmp(string, "aim") == 0)) { 313 if (objc != 5) { 314 Tcl_AppendResult(interp, "wrong # args: should be \"", 315 Tcl_GetString(objv[0]), " aim x y z\"", (char*)NULL); 316 return TCL_ERROR; 317 } 312 318 double x0, y0, z0; 313 if ((Tcl_GetDouble (interp, argv[2], &x0) != TCL_OK) ||314 (Tcl_GetDouble (interp, argv[3], &y0) != TCL_OK) ||315 (Tcl_GetDouble (interp, argv[4], &z0) != TCL_OK)) {319 if ((Tcl_GetDoubleFromObj(interp, objv[2], &x0) != TCL_OK) || 320 (Tcl_GetDoubleFromObj(interp, objv[3], &y0) != TCL_OK) || 321 (Tcl_GetDoubleFromObj(interp, objv[4], &z0) != TCL_OK)) { 316 322 return TCL_ERROR; 317 323 } 318 324 NanoVis::cam->aim(x0, y0, z0); 319 } else if ((c == 'z') && (strcmp( argv[1],"zoom") == 0)) {320 if ( argc != 3) {321 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],322 325 } else if ((c == 'z') && (strcmp(string, "zoom") == 0)) { 326 if (objc != 3) { 327 Tcl_AppendResult(interp, "wrong # args: should be \"", 328 Tcl_GetString(objv[0]), " zoom factor\"", (char*)NULL); 323 329 return TCL_ERROR; 324 330 } 325 331 326 332 double zoom; 327 if (Tcl_GetDouble (interp, argv[2], &zoom) != TCL_OK) {333 if (Tcl_GetDoubleFromObj(interp, objv[2], &zoom) != TCL_OK) { 328 334 return TCL_ERROR; 329 335 } 330 336 NanoVis::zoom(zoom); 331 337 } else { 332 Tcl_AppendResult(interp, "bad camera option \"", argv[1],338 Tcl_AppendResult(interp, "bad camera option \"", string, 333 339 "\": should be aim, angle, or zoom", (char*)NULL); 334 340 return TCL_ERROR; … … 350 356 351 357 static int 352 ScreenShotCmd(ClientData cdata, Tcl_Interp *interp, int argc,353 const char *argv[])358 ScreenShotCmd(ClientData cdata, Tcl_Interp *interp, int objc, 359 Tcl_Obj *CONST *objv) 354 360 { 355 361 #ifdef XINETD … … 400 406 */ 401 407 static int 402 CutplaneCmd(ClientData cdata, Tcl_Interp *interp, int argc, 403 const char *argv[]) 404 { 405 if (argc < 2) { 406 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 407 " option ?arg arg...?\"", (char*)NULL); 408 return TCL_ERROR; 409 } 410 411 char c = argv[1][0]; 412 if ((c == 's') && (strcmp(argv[1],"state") == 0)) { 413 if (argc < 4) { 414 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 415 " state on|off axis ?volume ...? \"", (char*)NULL); 408 CutplaneCmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv) 409 { 410 if (objc < 2) { 411 Tcl_AppendResult(interp, "wrong # args: should be \"", 412 Tcl_GetString(objv[0]), " option ?arg arg...?\"", (char*)NULL); 413 return TCL_ERROR; 414 } 415 416 char *string = Tcl_GetString(objv[1]); 417 char c = string[0]; 418 if ((c == 's') && (strcmp(string, "state") == 0)) { 419 if (objc < 4) { 420 Tcl_AppendResult(interp, "wrong # args: should be \"", 421 Tcl_GetString(objv[0]), " state on|off axis ?volume ...? \"", 422 (char*)NULL); 416 423 return TCL_ERROR; 417 424 } 418 425 419 426 int state; 420 if (Tcl_GetBoolean (interp, argv[2], &state) != TCL_OK) {427 if (Tcl_GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 421 428 return TCL_ERROR; 422 429 } 423 430 424 431 int axis; 425 if (GetAxis (interp, (char*) argv[3], &axis) != TCL_OK) {432 if (GetAxisFromObj(interp, objv[3], &axis) != TCL_OK) { 426 433 return TCL_ERROR; 427 434 } 428 435 429 436 vector<Volume *> ivol; 430 if (GetVolumes(interp, argc-4, argv+4, &ivol) != TCL_OK) {437 if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) { 431 438 return TCL_ERROR; 432 439 } … … 442 449 } 443 450 } 444 } else if ((c == 'p') && (strcmp(argv[1],"position") == 0)) { 445 if (argc < 4) { 446 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 447 " position relval axis ?volume ...? \"", (char*)NULL); 451 } else if ((c == 'p') && (strcmp(string, "position") == 0)) { 452 if (objc < 4) { 453 Tcl_AppendResult(interp, "wrong # args: should be \"", 454 Tcl_GetString(objv[0]), " position relval axis ?volume ...? \"", 455 (char*)NULL); 448 456 return TCL_ERROR; 449 457 } 450 458 451 459 float relval; 452 if (GetFloat (interp, argv[2], &relval) != TCL_OK) {460 if (GetFloatFromObj(interp, objv[2], &relval) != TCL_OK) { 453 461 return TCL_ERROR; 454 462 } … … 462 470 463 471 int axis; 464 if (GetAxis (interp, argv[3], &axis) != TCL_OK) {472 if (GetAxisFromObj(interp, objv[3], &axis) != TCL_OK) { 465 473 return TCL_ERROR; 466 474 } 467 475 468 476 vector<Volume *> ivol; 469 if (GetVolumes(interp, argc-4, argv+4, &ivol) != TCL_OK) {477 if (GetVolumes(interp, objc-4, objv+4, &ivol) != TCL_OK) { 470 478 return TCL_ERROR; 471 479 } … … 475 483 } 476 484 } else { 477 Tcl_AppendResult(interp, "bad option \"", argv[1],485 Tcl_AppendResult(interp, "bad option \"", string, 478 486 "\": should be position or state", (char*)NULL); 479 487 return TCL_ERROR; … … 494 502 */ 495 503 static int 496 LegendCmd(ClientData cdata, Tcl_Interp *interp, int argc, const char *argv[])497 { 498 if ( argc != 4) {499 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],500 504 LegendCmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv) 505 { 506 if (objc != 4) { 507 Tcl_AppendResult(interp, "wrong # args: should be \"", 508 Tcl_GetString(objv[0]), " transfunc width height\"", (char*)NULL); 501 509 return TCL_ERROR; 502 510 } 503 511 504 512 Volume *volPtr; 505 if (GetVolume (interp, argv[1], &volPtr) != TCL_OK) {513 if (GetVolumeFromObj(interp, objv[1], &volPtr) != TCL_OK) { 506 514 return TCL_ERROR; 507 515 } … … 510 518 if (tf == NULL) { 511 519 Tcl_AppendResult(interp, "no transfer function defined for volume \"", 512 argv[1], "\"", (char*)NULL); 513 return TCL_ERROR; 514 } 515 516 int width, height; 517 if ((Tcl_GetInt(interp, argv[2], &width) != TCL_OK) || 518 (Tcl_GetInt(interp, argv[3], &height) != TCL_OK)) { 520 Tcl_GetString(objv[1]), "\"", (char*)NULL); 521 return TCL_ERROR; 522 } 523 char *label; 524 label = Tcl_GetString(objv[1]); 525 526 int w, h; 527 if ((Tcl_GetIntFromObj(interp, objv[2], &w) != TCL_OK) || 528 (Tcl_GetIntFromObj(interp, objv[3], &h) != TCL_OK)) { 519 529 return TCL_ERROR; 520 530 } … … 523 533 return TCL_ERROR; 524 534 } 525 NanoVis::render_legend(tf, vmin, vmax, w idth, height, argv[1]);535 NanoVis::render_legend(tf, vmin, vmax, w, h, label); 526 536 return TCL_OK; 527 537 } … … 537 547 */ 538 548 static int 539 ScreenCmd(ClientData cdata, Tcl_Interp *interp, int argc, const char *argv[]) 540 { 549 ScreenCmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv) 550 { 551 if (objc != 3) { 552 Tcl_AppendResult(interp, "wrong # args: should be \"", 553 Tcl_GetString(objv[0]), " width height\"", (char*)NULL); 554 return TCL_ERROR; 555 } 556 541 557 int w, h; 542 543 if (argc != 3) { 544 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 545 " width height\"", (char*)NULL); 546 return TCL_ERROR; 547 } 548 if (Tcl_GetInt(interp, argv[1], &w) != TCL_OK) { 549 return TCL_ERROR; 550 } 551 if (Tcl_GetInt(interp, argv[2], &h) != TCL_OK) { 558 if ((Tcl_GetIntFromObj(interp, objv[1], &w) != TCL_OK) || 559 (Tcl_GetIntFromObj(interp, objv[2], &h) != TCL_OK)) { 552 560 return TCL_ERROR; 553 561 } … … 567 575 */ 568 576 static int 569 TransfuncCmd(ClientData cdata, Tcl_Interp *interp, int argc, 570 const char *argv[]) 571 { 572 if (argc < 2) { 573 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 574 " option arg arg...\"", (char*)NULL); 575 return TCL_ERROR; 576 } 577 578 char c = argv[1][0]; 579 if ((c == 'd') && (strcmp(argv[1],"define") == 0)) { 580 if (argc != 5) { 581 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 582 " define name colormap alphamap\"", (char*)NULL); 577 TransfuncCmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv) 578 { 579 if (objc < 2) { 580 Tcl_AppendResult(interp, "wrong # args: should be \"", 581 Tcl_GetString(objv[0]), " option arg arg...\"", (char*)NULL); 582 return TCL_ERROR; 583 } 584 585 char *string = Tcl_GetString(objv[1]); 586 char c = string[0]; 587 if ((c == 'd') && (strcmp(string, "define") == 0)) { 588 if (objc != 5) { 589 Tcl_AppendResult(interp, "wrong # args: should be \"", 590 Tcl_GetString(objv[0]), " define name colormap alphamap\"", 591 (char*)NULL); 583 592 return TCL_ERROR; 584 593 } … … 587 596 Rappture::Field1D rFunc, gFunc, bFunc, wFunc; 588 597 int cmapc, wmapc, i; 589 const char**cmapv;590 const char**wmapv;598 Tcl_Obj **cmapv; 599 Tcl_Obj **wmapv; 591 600 592 601 wmapv = cmapv = NULL; 593 if (Tcl_ SplitList(interp, argv[3], &cmapc, &cmapv) != TCL_OK) {602 if (Tcl_ListObjGetElements(interp, objv[3], &cmapc, &cmapv) != TCL_OK) { 594 603 return TCL_ERROR; 595 604 } … … 597 606 Tcl_AppendResult(interp, "bad colormap in transfunc: should be ", 598 607 "{ v r g b ... }", (char*)NULL); 599 Tcl_Free((char*)cmapv); 600 return TCL_ERROR; 601 } 602 603 if (Tcl_SplitList(interp, argv[4], &wmapc, &wmapv) != TCL_OK) { 604 Tcl_Free((char*)cmapv); 608 return TCL_ERROR; 609 } 610 if (Tcl_ListObjGetElements(interp, objv[4], &wmapc, &wmapv) != TCL_OK) { 605 611 return TCL_ERROR; 606 612 } … … 608 614 Tcl_AppendResult(interp, "wrong # elements in alphamap: should be ", 609 615 " { v w ... }", (char*)NULL); 610 Tcl_Free((char*)cmapv); 611 Tcl_Free((char*)wmapv); 612 return TCL_ERROR; 613 } 614 for (i=0; i < cmapc; i += 4) { 616 return TCL_ERROR; 617 } 618 for (i = 0; i < cmapc; i += 4) { 615 619 int j; 616 620 double vals[4]; 617 621 618 622 for (j=0; j < 4; j++) { 619 if (Tcl_GetDouble(interp, cmapv[i+j], &vals[j]) != TCL_OK) { 620 Tcl_Free((char*)cmapv); 621 Tcl_Free((char*)wmapv); 623 if (Tcl_GetDoubleFromObj(interp, cmapv[i+j], &vals[j]) != TCL_OK) { 622 624 return TCL_ERROR; 623 625 } … … 625 627 Tcl_AppendResult(interp, "bad value \"", cmapv[i+j], 626 628 "\": should be in the range 0-1", (char*)NULL); 627 Tcl_Free((char*)cmapv);628 Tcl_Free((char*)wmapv);629 629 return TCL_ERROR; 630 630 } … … 639 639 640 640 for (j=0; j < 2; j++) { 641 if (Tcl_GetDouble(interp, wmapv[i+j], &vals[j]) != TCL_OK) { 642 Tcl_Free((char*)cmapv); 643 Tcl_Free((char*)wmapv); 641 if (Tcl_GetDoubleFromObj(interp, wmapv[i+j], &vals[j]) != TCL_OK) { 644 642 return TCL_ERROR; 645 643 } … … 647 645 Tcl_AppendResult(interp, "bad value \"", wmapv[i+j], 648 646 "\": should be in the range 0-1", (char*)NULL); 649 Tcl_Free((char*)cmapv);650 Tcl_Free((char*)wmapv);651 647 return TCL_ERROR; 652 648 } … … 654 650 wFunc.define(vals[0], vals[1]); 655 651 } 656 Tcl_Free((char*)cmapv);657 Tcl_Free((char*)wmapv);658 659 652 // sample the given function into discrete slots 660 653 const int nslots = 256; … … 668 661 } 669 662 670 #if ISO_TEST671 /*672 for (i=0; i < nslots; i++) {673 if (i == 0) data[4*i + 3] = 0.0f;674 else if (i == (nslots - 1)) data[4*i + 3] = 0.0f;675 //else if (i >= 245 && i < (nslots - 1))676 else if (i >= 50 && i < (nslots - 1))677 {678 //data[4*i + 3] = 1.0;679 data[4*i + 3] = 0.5;680 }681 else682 {683 data[4*i + 3] = 0.0f;684 }685 }686 */687 #endif688 689 663 // find or create this transfer function 690 664 TransferFunction *tf; 691 tf = NanoVis::get_transfunc( argv[2]);665 tf = NanoVis::get_transfunc(Tcl_GetString(objv[2])); 692 666 if (tf != NULL) { 693 667 tf->update(data); 694 668 } else { 695 tf = NanoVis::set_transfunc( argv[2], nslots, data);669 tf = NanoVis::set_transfunc(Tcl_GetString(objv[2]), nslots, data); 696 670 } 697 671 } else { 698 Tcl_AppendResult(interp, "bad option \"", argv[1],672 Tcl_AppendResult(interp, "bad option \"", string, 699 673 "\": should be define", (char*)NULL); 700 674 return TCL_ERROR; … … 713 687 */ 714 688 static int 715 UpCmd(ClientData cdata, Tcl_Interp *interp, int argc, const char *argv[]) 716 { 717 if (argc != 2) { 718 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 719 " x|y|z|-x|-y|-z\"", (char*)NULL); 720 return TCL_ERROR; 721 } 722 723 int sign = 1; 724 725 char *axisName = (char*)argv[1]; 726 if (*axisName == '-') { 727 sign = -1; 728 axisName++; 729 } 730 689 UpCmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv) 690 { 691 if (objc != 2) { 692 Tcl_AppendResult(interp, "wrong # args: should be \"", 693 Tcl_GetString(objv[0]), " x|y|z|-x|-y|-z\"", (char*)NULL); 694 return TCL_ERROR; 695 } 696 697 int sign; 731 698 int axis; 732 if (GetAxis (interp, axisName, &axis) != TCL_OK) {699 if (GetAxisDirFromObj(interp, objv[1], &axis, &sign) != TCL_OK) { 733 700 return TCL_ERROR; 734 701 } … … 754 721 */ 755 722 static int 756 VolumeCmd(ClientData cdata, Tcl_Interp *interp, int argc, const char *argv[]) 757 { 758 if (argc < 2) { 759 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 760 " option arg arg...\"", (char*)NULL); 761 return TCL_ERROR; 762 } 763 764 char c = argv[1][0]; 765 if ((c == 'a') && (strcmp(argv[1],"axis") == 0)) { 766 if (argc < 3) { 767 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 768 " axis option ?arg arg...?\"", (char*)NULL); 769 return TCL_ERROR; 770 } 771 c = argv[2][0]; 772 if ((c == 'l') && (strcmp(argv[2],"label") == 0)) { 773 if (argc < 5) { 774 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 775 " axis label x|y|z string ?volume ...?\"", (char*)NULL); 723 VolumeCmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv) 724 { 725 if (objc < 2) { 726 Tcl_AppendResult(interp, "wrong # args: should be \"", 727 Tcl_GetString(objv[0]), " option arg arg...\"", (char*)NULL); 728 return TCL_ERROR; 729 } 730 731 char *string = Tcl_GetString(objv[1]); 732 char c = string[0]; 733 if ((c == 'a') && (strcmp(string, "axis") == 0)) { 734 if (objc < 3) { 735 Tcl_AppendResult(interp, "wrong # args: should be \"", 736 Tcl_GetString(objv[0]), " axis option ?arg arg...?\"", 737 (char*)NULL); 738 return TCL_ERROR; 739 } 740 char *string = Tcl_GetString(objv[2]); 741 c = string[0]; 742 if ((c == 'l') && (strcmp(string, "label") == 0)) { 743 if (objc < 5) { 744 Tcl_AppendResult(interp, "wrong # args: should be \"", 745 Tcl_GetString(objv[0]), 746 " axis label x|y|z string ?volume ...?\"", (char*)NULL); 776 747 return TCL_ERROR; 777 748 } 778 749 int axis; 779 if (GetAxis (interp, (char*)argv[3], &axis) != TCL_OK) {750 if (GetAxisFromObj(interp, objv[3], &axis) != TCL_OK) { 780 751 return TCL_ERROR; 781 752 } 782 753 vector<Volume *> ivol; 783 if (GetVolumes(interp, argc-5, argv+5, &ivol) != TCL_OK) {754 if (GetVolumes(interp, objc - 5, objv + 5, &ivol) != TCL_OK) { 784 755 return TCL_ERROR; 785 756 } 786 757 vector<Volume *>::iterator iter; 758 char *label; 759 label = Tcl_GetString(objv[4]); 787 760 for (iter = ivol.begin(); iter != ivol.end(); iter++) { 788 (*iter)->set_label(axis, argv[4]);761 (*iter)->set_label(axis, label); 789 762 } 790 763 } else { 791 Tcl_AppendResult(interp, "bad option \"", argv[2], 792 "\": should be label", (char*)NULL); 793 return TCL_ERROR; 794 } 795 } else if ((c == 'd') && (strcmp(argv[1],"data") == 0)) { 796 if (argc < 3) { 797 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 798 " data option ?arg arg...?\"", (char*)NULL); 799 return TCL_ERROR; 800 } 801 c = argv[2][0]; 802 if ((c == 's') && (strcmp(argv[2],"state") == 0)) { 803 if (argc < 4) { 804 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 805 " data state on|off ?volume ...?\"", (char*)NULL); 764 Tcl_AppendResult(interp, "bad option \"", string, 765 "\": should be label", (char*)NULL); 766 return TCL_ERROR; 767 } 768 } else if ((c == 'd') && (strcmp(string, "data") == 0)) { 769 if (objc < 3) { 770 Tcl_AppendResult(interp, "wrong # args: should be \"", 771 Tcl_GetString(objv[0]), " data option ?arg arg...?\"", 772 (char*)NULL); 773 return TCL_ERROR; 774 } 775 char *string = Tcl_GetString(objv[2]); 776 c = string[0]; 777 if ((c == 's') && (strcmp(string, "state") == 0)) { 778 if (objc < 4) { 779 Tcl_AppendResult(interp, "wrong # args: should be \"", 780 Tcl_GetString(objv[0])," data state on|off ?volume...?\"", 781 (char*)NULL); 806 782 return TCL_ERROR; 807 783 } 808 784 int state; 809 if (Tcl_GetBoolean (interp, argv[3], &state) != TCL_OK) {785 if (Tcl_GetBooleanFromObj(interp, objv[3], &state) != TCL_OK) { 810 786 return TCL_ERROR; 811 787 } 812 788 vector<Volume *> ivol; 813 if (GetVolumes(interp, argc-4, argv+4, &ivol) != TCL_OK) {789 if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) { 814 790 return TCL_ERROR; 815 791 } … … 825 801 } 826 802 } 827 } else if (c == 'f' && strcmp( argv[2], "follows") == 0) {828 if ( argc < 4) {829 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],830 803 } else if (c == 'f' && strcmp(string, "follows") == 0) { 804 if (objc < 4) { 805 Tcl_AppendResult(interp, "wrong # args: should be \"", 806 Tcl_GetString(objv[0]), " data follows size", (char*)NULL); 831 807 return TCL_ERROR; 832 808 } … … 835 811 836 812 int nbytes; 837 if (Tcl_GetInt (interp, argv[3], &nbytes) != TCL_OK) {813 if (Tcl_GetIntFromObj(interp, objv[3], &nbytes) != TCL_OK) { 838 814 return TCL_ERROR; 839 815 } … … 930 906 std::stringstream fdata; 931 907 fdata.write(buf.bytes(),buf.size()); 908 932 909 #if ISO_TEST 933 910 err = load_volume_stream2(n, fdata); … … 972 949 } 973 950 } else { 974 Tcl_AppendResult(interp, "bad data option \"", argv[2],951 Tcl_AppendResult(interp, "bad data option \"", string, 975 952 "\": should be follows or state", (char*)NULL); 976 953 return TCL_ERROR; 977 954 } 978 } else if (c == 'o' && strcmp(argv[1],"outline") == 0) { 979 if (argc < 3) { 980 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 981 " outline option ?arg arg...?\"", (char*)NULL); 982 return TCL_ERROR; 983 } 984 c = argv[2][0]; 985 if ((c == 's') && (strcmp(argv[2],"state") == 0)) { 986 if (argc < 3) { 987 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 988 " outline state on|off ?volume ...? \"", (char*)NULL); 955 } else if (c == 'o' && strcmp(string, "outline") == 0) { 956 if (objc < 3) { 957 Tcl_AppendResult(interp, "wrong # args: should be \"", 958 Tcl_GetString(objv[0]), " outline option ?arg arg...?\"", 959 (char*)NULL); 960 return TCL_ERROR; 961 } 962 char *string = Tcl_GetString(objv[2]); 963 c = string[0]; 964 if ((c == 's') && (strcmp(string, "state") == 0)) { 965 if (objc < 3) { 966 Tcl_AppendResult(interp, "wrong # args: should be \"", 967 Tcl_GetString(objv[0]), 968 " outline state on|off ?volume ...? \"", (char*)NULL); 989 969 return TCL_ERROR; 990 970 } 991 971 992 972 int state; 993 if (Tcl_GetBoolean (interp, argv[3], &state) != TCL_OK) {973 if (Tcl_GetBooleanFromObj(interp, objv[3], &state) != TCL_OK) { 994 974 return TCL_ERROR; 995 975 } 996 976 vector<Volume *> ivol; 997 if (GetVolumes(interp, argc-4, argv+4, &ivol) != TCL_OK) {977 if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) { 998 978 return TCL_ERROR; 999 979 } … … 1009 989 } 1010 990 } 1011 } else if ( c == 'v' && strcmp(argv[2],"visible") == 0) {991 } else if ((c == 'v') && (strcmp(string, "visible") == 0)) { 1012 992 int ivisible; 1013 993 1014 if (Tcl_GetBoolean (interp, argv[3], &ivisible) != TCL_OK) {994 if (Tcl_GetBooleanFromObj(interp, objv[3], &ivisible) != TCL_OK) { 1015 995 return TCL_ERROR; 1016 996 } … … 1028 1008 } 1029 1009 } 1030 } else if ((c == 'c') && (strcmp(argv[2],"color") == 0)) { 1031 if (argc < 6) { 1032 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1033 " outline color R G B ?volume ...? \"", (char*)NULL); 1010 } else if ((c == 'c') && (strcmp(string, "color") == 0)) { 1011 if (objc < 6) { 1012 Tcl_AppendResult(interp, "wrong # args: should be \"", 1013 Tcl_GetString(objv[0]), 1014 " outline color R G B ?volume ...? \"", (char*)NULL); 1034 1015 return TCL_ERROR; 1035 1016 } 1036 1017 float rgb[3]; 1037 if (GetColor(interp, argc - 3, argv + 3, rgb) != TCL_OK) {1018 if (GetColor(interp, objc - 3, objv + 3, rgb) != TCL_OK) { 1038 1019 return TCL_ERROR; 1039 1020 } 1040 1021 vector<Volume *> ivol; 1041 if (GetVolumes(interp, argc - 6, argv + 6, &ivol) != TCL_OK) {1022 if (GetVolumes(interp, objc - 6, objv + 6, &ivol) != TCL_OK) { 1042 1023 return TCL_ERROR; 1043 1024 } … … 1048 1029 } 1049 1030 else { 1050 Tcl_AppendResult(interp, "bad outline option \"", argv[2],1031 Tcl_AppendResult(interp, "bad outline option \"", string, 1051 1032 "\": should be color, visible, or state", (char*)NULL); 1052 1033 return TCL_ERROR; 1053 1034 } 1054 } else if ((c == 's') && (strcmp(argv[1],"shading") == 0)) { 1055 if (argc < 3) { 1056 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1057 " shading option ?arg arg...?\"", (char*)NULL); 1058 return TCL_ERROR; 1059 } 1060 c = argv[2][0]; 1061 if ((c == 't') && (strcmp(argv[2],"transfunc") == 0)) { 1062 if (argc < 4) { 1063 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1064 " shading transfunc name ?volume ...?\"", (char*)NULL); 1035 } else if ((c == 's') && (strcmp(string, "shading") == 0)) { 1036 if (objc < 3) { 1037 Tcl_AppendResult(interp, "wrong # args: should be \"", 1038 Tcl_GetString(objv[0]), " shading option ?arg arg...?\"", 1039 (char*)NULL); 1040 return TCL_ERROR; 1041 } 1042 char *string = Tcl_GetString(objv[2]); 1043 c = string[0]; 1044 if ((c == 't') && (strcmp(string, "transfunc") == 0)) { 1045 if (objc < 4) { 1046 Tcl_AppendResult(interp, "wrong # args: should be \"", 1047 Tcl_GetString(objv[0]), 1048 " shading transfunc name ?volume ...?\"", (char*)NULL); 1065 1049 return TCL_ERROR; 1066 1050 } 1067 1051 TransferFunction *tf; 1068 tf = NanoVis::get_transfunc(argv[3]); 1052 char *name = Tcl_GetString(objv[3]); 1053 tf = NanoVis::get_transfunc(name); 1069 1054 if (tf == NULL) { 1070 Tcl_AppendResult(interp, "transfer function \"", argv[3],1055 Tcl_AppendResult(interp, "transfer function \"", name, 1071 1056 "\" is not defined", (char*)NULL); 1072 1057 return TCL_ERROR; 1073 1058 } 1074 1059 vector<Volume *> ivol; 1075 if (GetVolumes(interp, argc-4, argv+4, &ivol) != TCL_OK) {1060 if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) { 1076 1061 return TCL_ERROR; 1077 1062 } … … 1088 1073 */ 1089 1074 } 1090 } else if ((c == 'd') && (strcmp(argv[2], "diffuse") == 0)) { 1091 if (argc < 4) { 1092 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1093 " shading diffuse value ?volume ...?\"", (char*)NULL); 1075 } else if ((c == 'd') && (strcmp(string, "diffuse") == 0)) { 1076 if (objc < 4) { 1077 Tcl_AppendResult(interp, "wrong # args: should be \"", 1078 Tcl_GetString(objv[0]), 1079 " shading diffuse value ?volume ...?\"", (char*)NULL); 1094 1080 return TCL_ERROR; 1095 1081 } 1096 1082 1097 1083 float diffuse; 1098 if (GetFloat (interp, argv[3], &diffuse) != TCL_OK) {1084 if (GetFloatFromObj(interp, objv[3], &diffuse) != TCL_OK) { 1099 1085 return TCL_ERROR; 1100 1086 } 1101 1087 vector<Volume *> ivol; 1102 if (GetVolumes(interp, argc-4, argv+4, &ivol) != TCL_OK) {1088 if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) { 1103 1089 return TCL_ERROR; 1104 1090 } … … 1107 1093 (*iter)->set_diffuse(diffuse); 1108 1094 } 1109 } else if ((c == 'o') && (strcmp(argv[2], "opacity") == 0)) { 1110 if (argc < 4) { 1111 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1112 " shading opacity value ?volume ...?\"", (char*)NULL); 1095 } else if ((c == 'o') && (strcmp(string, "opacity") == 0)) { 1096 if (objc < 4) { 1097 Tcl_AppendResult(interp, "wrong # args: should be \"", 1098 Tcl_GetString(objv[0]), 1099 " shading opacity value ?volume ...?\"", (char*)NULL); 1113 1100 return TCL_ERROR; 1114 1101 } 1115 1102 float opacity; 1116 if (GetFloat (interp, argv[3], &opacity) != TCL_OK) {1103 if (GetFloatFromObj(interp, objv[3], &opacity) != TCL_OK) { 1117 1104 return TCL_ERROR; 1118 1105 } 1119 1106 vector<Volume *> ivol; 1120 if (GetVolumes(interp, argc-4, argv+4, &ivol) != TCL_OK) {1107 if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) { 1121 1108 return TCL_ERROR; 1122 1109 } … … 1125 1112 (*iter)->set_opacity_scale(opacity); 1126 1113 } 1127 } else if ((c == 's') && (strcmp(argv[2], "specular") == 0)) { 1128 if (argc < 4) { 1129 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1130 " shading specular value ?volume ...?\"", (char*)NULL); 1114 } else if ((c == 's') && (strcmp(string, "specular") == 0)) { 1115 if (objc < 4) { 1116 Tcl_AppendResult(interp, "wrong # args: should be \"", 1117 Tcl_GetString(objv[0]), 1118 " shading specular value ?volume ...?\"", (char*)NULL); 1131 1119 return TCL_ERROR; 1132 1120 } 1133 1121 float specular; 1134 if (GetFloat (interp, argv[3], &specular) != TCL_OK) {1122 if (GetFloatFromObj(interp, objv[3], &specular) != TCL_OK) { 1135 1123 return TCL_ERROR; 1136 1124 } 1137 1125 vector<Volume *> ivol; 1138 if (GetVolumes(interp, argc-4, argv+4, &ivol) != TCL_OK) {1126 if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) { 1139 1127 return TCL_ERROR; 1140 1128 } … … 1143 1131 (*iter)->set_specular(specular); 1144 1132 } 1145 } else if ((c == 'i') && (strcmp(argv[2], "isosurface") == 0)) { 1146 if (argc < 4) { 1147 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1148 " shading isosurface on|off ?volume ...?\"", (char*)NULL); 1133 } else if ((c == 'i') && (strcmp(string, "isosurface") == 0)) { 1134 if (objc < 4) { 1135 Tcl_AppendResult(interp, "wrong # args: should be \"", 1136 Tcl_GetString(objv[0]), 1137 " shading isosurface on|off ?volume ...?\"", (char*)NULL); 1149 1138 return TCL_ERROR; 1150 1139 } 1151 1140 int iso_surface; 1152 if (Tcl_GetBoolean (interp, argv[3], &iso_surface) != TCL_OK) {1141 if (Tcl_GetBooleanFromObj(interp, objv[3], &iso_surface) != TCL_OK) { 1153 1142 return TCL_ERROR; 1154 1143 } 1155 1144 vector<Volume *> ivol; 1156 if (GetVolumes(interp, argc-4, argv+4, &ivol) != TCL_OK) {1145 if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) { 1157 1146 return TCL_ERROR; 1158 1147 } … … 1162 1151 } 1163 1152 } else { 1164 Tcl_AppendResult(interp, "bad shading option \"", argv[2],1153 Tcl_AppendResult(interp, "bad shading option \"", string, 1165 1154 "\": should be diffuse, opacity, specular, transfunc, or ", 1166 1155 "isosurface", (char*)NULL); 1167 1156 return TCL_ERROR; 1168 1157 } 1169 } else if ((c == 's') && (strcmp(argv[1], "state") == 0)) { 1170 if (argc < 3) { 1171 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1172 " state on|off ?volume...?\"", (char*)NULL); 1158 } else if ((c == 's') && (strcmp(string, "state") == 0)) { 1159 if (objc < 3) { 1160 Tcl_AppendResult(interp, "wrong # args: should be \"", 1161 Tcl_GetString(objv[0]), " state on|off ?volume...?\"", 1162 (char*)NULL); 1173 1163 return TCL_ERROR; 1174 1164 } 1175 1165 int state; 1176 if (Tcl_GetBoolean (interp, argv[2], &state) != TCL_OK) {1166 if (Tcl_GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 1177 1167 return TCL_ERROR; 1178 1168 } 1179 1169 vector<Volume *> ivol; 1180 if (GetVolumes(interp, argc-3, argv+3, &ivol) != TCL_OK) {1170 if (GetVolumes(interp, objc - 3, objv + 3, &ivol) != TCL_OK) { 1181 1171 return TCL_ERROR; 1182 1172 } … … 1192 1182 } 1193 1183 } 1194 } else if (strcmp(argv[1],"animation") == 0) { 1195 if (argc < 3) { 1196 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1197 " animation option ?args...?\"", (char*)NULL); 1198 return TCL_ERROR; 1199 } 1200 if (strcmp(argv[2],"volumes") == 0) { 1184 } else if (strcmp(string, "animation") == 0) { 1185 if (objc < 3) { 1186 Tcl_AppendResult(interp, "wrong # args: should be \"", 1187 Tcl_GetString(objv[0]), " animation option ?args...?\"", 1188 (char*)NULL); 1189 return TCL_ERROR; 1190 } 1191 char *string = Tcl_GetString(objv[2]); 1192 char c = string[0]; 1193 if ((c == 'v') && (strcmp(string,"volumes") == 0)) { 1201 1194 vector<unsigned int> ivol; 1202 if (GetVolumeIndices(interp, argc-3, argv+3, &ivol) != TCL_OK) {1195 if (GetVolumeIndices(interp, objc - 3, objv + 3, &ivol) != TCL_OK) { 1203 1196 return TCL_ERROR; 1204 1197 } … … 1210 1203 *iter); 1211 1204 } 1212 } else if (strcmp(argv[2],"capture") == 0) { 1213 1214 int total_frame_count; 1215 1216 if (Tcl_GetInt(interp, argv[3], &total_frame_count) != TCL_OK) 1217 { 1218 return TCL_ERROR; 1219 } 1220 1221 VolumeInterpolator* interpolator = NanoVis::vol_renderer->getVolumeInterpolator(); 1205 } else if ((c == 'c') && (strcmp(string,"capture") == 0)) { 1206 int total; 1207 1208 if (Tcl_GetIntFromObj(interp, objv[3], &total) != TCL_OK) { 1209 return TCL_ERROR; 1210 } 1211 VolumeInterpolator* interpolator; 1212 interpolator = NanoVis::vol_renderer->getVolumeInterpolator(); 1222 1213 interpolator->start(); 1223 if (interpolator->is_started()) 1224 { 1225 f loat fraction;1226 for (int frame_num = 0; frame_num < total_frame_count; ++frame_num) 1227 { 1228 fraction = ((float)frame_num) / (total _frame_count- 1);1214 if (interpolator->is_started()) { 1215 char *fileName = (objc < 5) ? NULL : Tcl_GetString(objv[4]); 1216 for (int frame_num = 0; frame_num < total; ++frame_num) { 1217 float fraction; 1218 1219 fraction = ((float)frame_num) / (total - 1); 1229 1220 Trace("fraction : %f\n", fraction); 1230 //interpolator->update(((float)frame_num) / (total _frame_count- 1));1221 //interpolator->update(((float)frame_num) / (total - 1)); 1231 1222 interpolator->update(fraction); 1232 1223 … … 1238 1229 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 1239 1230 1240 if (argc < 5) 1241 NanoVis::bmp_write_to_file(frame_num, NULL); 1242 else 1243 NanoVis::bmp_write_to_file(frame_num, (char*) argv[4]); 1231 NanoVis::bmp_write_to_file(frame_num, fileName); 1244 1232 } 1245 1233 } 1246 1247 } else if (strcmp(argv[2],"start") == 0) { 1234 } else if ((c == 's') && (strcmp(string, "start") == 0)) { 1248 1235 NanoVis::vol_renderer->startVolumeAnimation(); 1249 } else if ( strcmp(argv[2],"stop") == 0) {1250 1251 } else if ( strcmp(argv[2],"clear") == 0) {1252 1236 } else if ((c == 's') && (strcmp(string, "stop") == 0)) { 1237 NanoVis::vol_renderer->stopVolumeAnimation(); 1238 } else if ((c == 'c') && (strcmp(string, "clear") == 0)) { 1239 NanoVis::vol_renderer->clearAnimatedVolumeInfo(); 1253 1240 } else { 1254 Tcl_AppendResult(interp, "bad animation option \"", argv[2],1241 Tcl_AppendResult(interp, "bad animation option \"", string, 1255 1242 "\": should be volumes, start, stop, or clear", (char*)NULL); 1256 1243 return TCL_ERROR; 1257 1244 } 1258 } else if ((c == 't') && (strcmp( argv[1],"test2") == 0)) {1245 } else if ((c == 't') && (strcmp(string, "test2") == 0)) { 1259 1246 NanoVis::volume[1]->disable_data(); 1260 1247 NanoVis::volume[1]->disable(); 1261 1248 } else { 1262 Tcl_AppendResult(interp, "bad option \"", argv[1], "\": should be ",1249 Tcl_AppendResult(interp, "bad option \"", string, "\": should be ", 1263 1250 "data, outline, shading, or state", (char*)NULL); 1264 1251 return TCL_ERROR; … … 1268 1255 1269 1256 static int 1270 FlowCmd(ClientData cdata, Tcl_Interp *interp, int argc, const char *argv[])1257 FlowCmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv) 1271 1258 { 1272 1259 Rappture::Outcome err; 1273 1260 1274 if (argc < 2) { 1275 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1276 " option ?arg arg?", (char *)NULL); 1277 return TCL_ERROR; 1278 } 1279 char c = argv[1][0]; 1280 if ((c == 'v') && (strcmp(argv[1], "vectorid") == 0)) { 1281 if (argc != 3) { 1282 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1283 " vectorid volume", (char *)NULL); 1261 if (objc < 2) { 1262 Tcl_AppendResult(interp, "wrong # args: should be \"", 1263 Tcl_GetString(objv[0]), " option ?arg arg?", (char *)NULL); 1264 return TCL_ERROR; 1265 } 1266 char *string = Tcl_GetString(objv[1]); 1267 char c = string[0]; 1268 if ((c == 'v') && (strcmp(string, "vectorid") == 0)) { 1269 if (objc != 3) { 1270 Tcl_AppendResult(interp, "wrong # args: should be \"", 1271 Tcl_GetString(objv[0]), " vectorid volume", (char *)NULL); 1284 1272 return TCL_ERROR; 1285 1273 } 1286 1274 Volume *volPtr; 1287 1275 1288 if (GetVolume (interp, argv[2], &volPtr) != TCL_OK) {1276 if (GetVolumeFromObj(interp, objv[2], &volPtr) != TCL_OK) { 1289 1277 return TCL_ERROR; 1290 1278 } … … 1304 1292 NanoVis::licRenderer->set_offset(NanoVis::lic_slice_z); 1305 1293 } 1306 } else if (c == 'l' && strcmp( argv[1], "lic") == 0) {1307 if ( argc != 3) {1308 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],1309 1294 } else if (c == 'l' && strcmp(string, "lic") == 0) { 1295 if (objc != 3) { 1296 Tcl_AppendResult(interp, "wrong # args: should be \"", 1297 Tcl_GetString(objv[0]), " lic on|off\"", (char*)NULL); 1310 1298 return TCL_ERROR; 1311 1299 } 1312 1300 int ibool; 1313 if (Tcl_GetBoolean (interp, argv[2], &ibool) != TCL_OK) {1301 if (Tcl_GetBooleanFromObj(interp, objv[2], &ibool) != TCL_OK) { 1314 1302 return TCL_ERROR; 1315 1303 } 1316 1304 NanoVis::lic_on = (bool)ibool; 1317 } else if ((c == 'p') && (strcmp(argv[1], "particle") == 0)) { 1318 if (argc < 3) { 1319 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1320 " particle visible|slice|slicepos arg \"", (char*)NULL); 1321 return TCL_ERROR; 1322 } 1323 c = argv[2][0]; 1324 if ((c == 'v') && (strcmp(argv[2], "visible") == 0)) { 1325 if (argc != 4) { 1326 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1327 " particle visible on|off\"", (char*)NULL); 1305 } else if ((c == 'p') && (strcmp(string, "particle") == 0)) { 1306 if (objc < 3) { 1307 Tcl_AppendResult(interp, "wrong # args: should be \"", 1308 Tcl_GetString(objv[0]), " particle visible|slice|slicepos arg \"", 1309 (char*)NULL); 1310 return TCL_ERROR; 1311 } 1312 char *string = Tcl_GetString(objv[2]); 1313 c = string[0]; 1314 if ((c == 'v') && (strcmp(string, "visible") == 0)) { 1315 if (objc != 4) { 1316 Tcl_AppendResult(interp, "wrong # args: should be \"", 1317 Tcl_GetString(objv[0]), " particle visible on|off\"", 1318 (char*)NULL); 1328 1319 return TCL_ERROR; 1329 1320 } 1330 1321 int state; 1331 if (Tcl_GetBoolean (interp, argv[3], &state) != TCL_OK) {1322 if (Tcl_GetBooleanFromObj(interp, objv[3], &state) != TCL_OK) { 1332 1323 return TCL_ERROR; 1333 1324 } 1334 1325 NanoVis::particle_on = state; 1335 } else if ((c == 's') && (strcmp(argv[2], "slice") == 0)) { 1336 if (argc != 4) { 1337 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1326 } else if ((c == 's') && (strcmp(string, "slice") == 0)) { 1327 if (objc != 4) { 1328 Tcl_AppendResult(interp, "wrong # args: should be \"", 1329 Tcl_GetString(objv[0]), 1338 1330 " particle slice volume\"", (char*)NULL); 1339 1331 return TCL_ERROR; 1340 1332 } 1341 1333 int axis; 1342 if (GetAxis (interp, argv[3], &axis) != TCL_OK) {1334 if (GetAxisFromObj(interp, objv[3], &axis) != TCL_OK) { 1343 1335 return TCL_ERROR; 1344 1336 } 1345 1337 NanoVis::lic_axis = axis; 1346 } else if ((c == 's') && (strcmp(argv[2], "slicepos") == 0)) { 1347 if (argc != 4) { 1348 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1349 " particle slicepos value\"", (char*)NULL); 1338 } else if ((c == 's') && (strcmp(string, "slicepos") == 0)) { 1339 if (objc != 4) { 1340 Tcl_AppendResult(interp, "wrong # args: should be \"", 1341 Tcl_GetString(objv[0]), " particle slicepos value\"", 1342 (char*)NULL); 1350 1343 return TCL_ERROR; 1351 1344 } 1352 1345 float pos; 1353 if (GetFloat (interp, argv[2], &pos) != TCL_OK) {1346 if (GetFloatFromObj(interp, objv[2], &pos) != TCL_OK) { 1354 1347 return TCL_ERROR; 1355 1348 } … … 1371 1364 } 1372 1365 } else { 1373 Tcl_AppendResult(interp, "unknown option \"", argv[2],1374 "\": should be \"", argv[0], " visible, slice, or slicepos\"",1366 Tcl_AppendResult(interp, "unknown option \"",string,"\": should be \"", 1367 Tcl_GetString(objv[0]), " visible, slice, or slicepos\"", 1375 1368 (char *)NULL); 1376 1369 return TCL_ERROR; 1377 1370 } 1378 } else if ((c == 'r') && (strcmp( argv[1],"reset") == 0)) {1371 } else if ((c == 'r') && (strcmp(string, "reset") == 0)) { 1379 1372 NanoVis::initParticle(); 1380 } else if ((c == 'c') && (strcmp(argv[1],"capture") == 0)) { 1381 if (argc > 4 || argc < 3) { 1382 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1383 " capture numframes [directory]\"", (char*)NULL); 1373 } else if ((c == 'c') && (strcmp(string, "capture") == 0)) { 1374 if (objc > 4 || objc < 3) { 1375 Tcl_AppendResult(interp, "wrong # args: should be \"", 1376 Tcl_GetString(objv[0]), " capture numframes [directory]\"", 1377 (char*)NULL); 1384 1378 return TCL_ERROR; 1385 1379 } 1386 1380 int total_frame_count; 1387 1381 1388 if (Tcl_GetInt (interp, argv[2], &total_frame_count) != TCL_OK) {1382 if (Tcl_GetIntFromObj(interp, objv[2], &total_frame_count) != TCL_OK) { 1389 1383 return TCL_ERROR; 1390 1384 } … … 1398 1392 // 1399 1393 Trace("FLOW started\n"); 1394 char *fileName; 1395 fileName = (objc < 4) ? NULL : Tcl_GetString(objv[3]); 1400 1396 for (int frame_count = 0; frame_count < total_frame_count; 1401 1397 frame_count++) { … … 1418 1414 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 1419 1415 1420 if (argc < 4) 1421 NanoVis::bmp_write_to_file(frame_count, NULL); 1422 else 1423 NanoVis::bmp_write_to_file(frame_count, (char*) argv[3]); 1424 1416 NanoVis::bmp_write_to_file(frame_count, fileName); 1425 1417 } 1426 1418 Trace("FLOW end\n"); … … 1433 1425 } 1434 1426 NanoVis::initParticle(); 1435 } else if (c == 'd' && strcmp(argv[1],"data") == 0) { 1436 if (argc < 3) { 1437 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1438 " data follows ?args?", (char *)NULL); 1439 return TCL_ERROR; 1440 } 1441 c = argv[2][0]; 1442 if ((c == 'f') && (strcmp(argv[2],"follows") == 0)) { 1443 if (argc != 4) { 1444 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1445 " data follows length", (char *)NULL); 1427 } else if ((c == 'd') && (strcmp(string, "data") == 0)) { 1428 if (objc < 3) { 1429 Tcl_AppendResult(interp, "wrong # args: should be \"", 1430 Tcl_GetString(objv[0]), " data follows ?args?", (char *)NULL); 1431 return TCL_ERROR; 1432 } 1433 char *string = Tcl_GetString(objv[2]);; 1434 c = string[0]; 1435 if ((c == 'f') && (strcmp(string,"follows") == 0)) { 1436 if (objc != 4) { 1437 Tcl_AppendResult(interp, "wrong # args: should be \"", 1438 Tcl_GetString(objv[0]), " data follows length", 1439 (char *)NULL); 1446 1440 return TCL_ERROR; 1447 1441 } 1448 1442 int nbytes; 1449 if (Tcl_GetInt (interp, argv[3], &nbytes) != TCL_OK) {1443 if (Tcl_GetIntFromObj(interp, objv[3], &nbytes) != TCL_OK) { 1450 1444 return TCL_ERROR; 1451 1445 } … … 1484 1478 } 1485 1479 1480 1481 static int 1482 HeightMapDataFollowsOp(ClientData cdata, Tcl_Interp *interp, int objc, 1483 Tcl_Obj *CONST *objv) 1484 { 1485 Rappture::Buffer buf; 1486 int nBytes; 1487 1488 if (Tcl_GetIntFromObj(interp, objv[3], &nBytes) != TCL_OK) { 1489 return TCL_ERROR; 1490 } 1491 if (GetDataStream(interp, buf, nBytes) != TCL_OK) { 1492 return TCL_ERROR; 1493 } 1494 buf.append("\0", 1); 1495 int result; 1496 result = Tcl_Eval(interp, buf.bytes()); 1497 if (result != TCL_OK) { 1498 fprintf(stderr, "error in command: %s\n", 1499 Tcl_GetStringResult(interp)); 1500 fflush(stderr); 1501 } 1502 return result; 1503 } 1504 1505 static int 1506 HeightMapDataVisibleOp(ClientData cdata, Tcl_Interp *interp, int objc, 1507 Tcl_Obj *CONST *objv) 1508 { 1509 int ivisible; 1510 if (Tcl_GetBooleanFromObj(interp, objv[3], &ivisible) != TCL_OK) { 1511 return TCL_ERROR; 1512 } 1513 vector<unsigned int> indices; 1514 if (GetIndices(interp, objc - 4, objv + 4, &indices) != TCL_OK) { 1515 return TCL_ERROR; 1516 } 1517 bool visible; 1518 visible = (bool)ivisible; 1519 for (unsigned int i = 0; i < indices.size(); ++i) { 1520 if ((indices[i] < NanoVis::heightMap.size()) && 1521 (NanoVis::heightMap[indices[i]] != NULL)) { 1522 NanoVis::heightMap[indices[i]]->setVisible(visible); 1523 } 1524 } 1525 return TCL_OK; 1526 } 1527 1528 static Rappture::CmdSpec heightMapDataOps[] = 1529 { 1530 {"follows", 1, HeightMapDataFollowsOp, 4, 4, "length",}, 1531 {"visible", 1, HeightMapDataVisibleOp, 4, 0, "bool ?indices?",}, 1532 }; 1533 static int nHeightMapDataOps = NumCmdSpecs(heightMapDataOps); 1534 1486 1535 static int 1487 HeightMapCmd(ClientData cdata, Tcl_Interp *interp, int argc, 1488 const char *argv[]) 1489 { 1490 if (argc < 2) { 1491 srand((unsigned)time(NULL)); 1492 int size = 20 * 200; 1493 double sigma = 5.0; 1494 double mean = exp(0.0) / (sigma * sqrt(2.0)); 1495 float* data = (float*) malloc(sizeof(float) * size); 1496 1497 float x; 1498 for (int i = 0; i < size; ++i) { 1499 x = - 10 + i%20; 1500 data[i] = exp(- (x * x)/(2 * sigma * sigma)) / 1501 (sigma * sqrt(2.0)) / mean * 2 + 1000; 1502 } 1503 1504 HeightMap* heightMap = new HeightMap(); 1505 float minx = 0.0f; 1506 float maxx = 1.0f; 1507 float miny = 0.5f; 1508 float maxy = 3.5f; 1509 heightMap->setHeight(minx, miny, maxx, maxy, 20, 200, data); 1510 heightMap->setColorMap(NanoVis::get_transfunc("default")); 1511 heightMap->setVisible(true); 1512 heightMap->setLineContourVisible(true); 1513 NanoVis::heightMap.push_back(heightMap); 1514 1515 1516 Vector3 min(minx, (float) heightMap->range_min(), miny); 1517 Vector3 max(maxx, (float) heightMap->range_max(), maxy); 1518 1519 NanoVis::grid->setMinMax(min, max); 1520 NanoVis::grid->setVisible(true); 1521 1522 return TCL_OK; 1523 } 1536 HeightMapDataOp(ClientData cdata, Tcl_Interp *interp, int objc, 1537 Tcl_Obj *CONST *objv) 1538 { 1539 Tcl_ObjCmdProc *proc; 1540 1541 proc = Rappture::GetOpFromObj(interp, nHeightMapDataOps, heightMapDataOps, 1542 Rappture::CMDSPEC_ARG2, objc, objv, 0); 1543 if (proc == NULL) { 1544 return TCL_ERROR; 1545 } 1546 return (*proc) (cdata, interp, objc, objv); 1547 } 1548 1549 1550 static int 1551 HeightMapLineContourColorOp(ClientData cdata, Tcl_Interp *interp, int objc, 1552 Tcl_Obj *CONST *objv) 1553 { 1554 float rgb[3]; 1555 if (GetColor(interp, objc - 3, objv + 3, rgb) != TCL_OK) { 1556 return TCL_ERROR; 1557 } 1558 vector<unsigned int> indices; 1559 if (GetIndices(interp, objc-6, objv + 6, &indices) != TCL_OK) { 1560 return TCL_ERROR; 1561 } 1562 for (unsigned int i = 0; i < indices.size(); ++i) { 1563 if ((indices[i] < NanoVis::heightMap.size()) && 1564 (NanoVis::heightMap[indices[i]] != NULL)) { 1565 NanoVis::heightMap[indices[i]]->setLineContourColor(rgb); 1566 } 1567 } 1568 return TCL_OK; 1569 } 1570 1571 static int 1572 HeightMapLineContourVisibleOp(ClientData cdata, Tcl_Interp *interp, int objc, 1573 Tcl_Obj *CONST *objv) 1574 { 1575 int ivisible; 1576 bool visible; 1577 if (Tcl_GetBooleanFromObj(interp, objv[3], &ivisible) != TCL_OK) { 1578 return TCL_ERROR; 1579 } 1580 visible = (bool)ivisible; 1581 vector<unsigned int> indices; 1582 if (GetIndices(interp, objc-4, objv+4, &indices) != TCL_OK) { 1583 return TCL_ERROR; 1584 } 1585 for (unsigned int i = 0; i < indices.size(); ++i) { 1586 if ((indices[i] < NanoVis::heightMap.size()) && 1587 (NanoVis::heightMap[indices[i]] != NULL)) { 1588 NanoVis::heightMap[indices[i]]->setLineContourVisible(visible); 1589 } 1590 } 1591 return TCL_OK; 1592 } 1593 1594 static Rappture::CmdSpec heightMapLineContourOps[] = 1595 { 1596 {"color", 1, HeightMapLineContourColorOp, 4, 4, "length",}, 1597 {"visible", 1, HeightMapLineContourVisibleOp, 4, 0, "bool ?indices?",}, 1598 }; 1599 static int nHeightMapLineContourOps = NumCmdSpecs(heightMapLineContourOps); 1600 1601 static int 1602 HeightMapLineContourOp(ClientData cdata, Tcl_Interp *interp, int objc, 1603 Tcl_Obj *CONST *objv) 1604 { 1605 Tcl_ObjCmdProc *proc; 1606 1607 proc = Rappture::GetOpFromObj(interp, nHeightMapLineContourOps, 1608 heightMapLineContourOps, Rappture::CMDSPEC_ARG2, objc, objv, 0); 1609 if (proc == NULL) { 1610 return TCL_ERROR; 1611 } 1612 return (*proc) (cdata, interp, objc, objv); 1613 } 1614 1615 static int 1616 HeightMapCullOp(ClientData cdata, Tcl_Interp *interp, int objc, 1617 Tcl_Obj *CONST *objv) 1618 { 1619 graphics::RenderContext::CullMode mode; 1620 if (GetCullMode(interp, objv[2], &mode) != TCL_OK) { 1621 return TCL_ERROR; 1622 } 1623 NanoVis::renderContext->setCullMode(mode); 1624 return TCL_OK; 1625 } 1626 1627 static int 1628 HeightMapCreateOp(ClientData cdata, Tcl_Interp *interp, int objc, 1629 Tcl_Obj *CONST *objv) 1630 { 1631 HeightMap *hMap; 1524 1632 1525 char c = argv[1][0]; 1526 if ((c == 'c') && (strcmp(argv[1], "create") == 0)) { 1527 HeightMap *hMap; 1528 1529 /* heightmap create xmin ymin xmax ymax xnum ynum values */ 1530 hMap = CreateHeightMap(cdata, interp, argc - 2, argv + 2); 1531 if (hMap == NULL) { 1532 return TCL_ERROR; 1533 } 1534 NanoVis::heightMap.push_back(hMap); 1535 /* FIXME: Convert this file to use Tcl_CmdObjProc */ 1536 sprintf(interp->result, "%d", NanoVis::heightMap.size() - 1); 1537 return TCL_OK; 1538 } else if ((c == 'd') && (strcmp(argv[1],"data") == 0)) { 1539 if (argc < 3) { 1540 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1541 " data follows|visible ?args?", (char *)NULL); 1542 return TCL_ERROR; 1543 } 1544 //bytes 1545 char c; 1546 c = argv[2][0]; 1547 if ((c == 'v') && (strcmp(argv[2],"visible") == 0)) { 1548 if (argc < 4) { 1549 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1550 " data visible bool ?indices?", (char *)NULL); 1551 return TCL_ERROR; 1552 } 1553 int ivisible; 1554 vector<unsigned int> indices; 1555 1556 if (Tcl_GetBoolean(interp, argv[3], &ivisible) != TCL_OK) { 1557 return TCL_ERROR; 1558 } 1559 if (GetIndices(interp, argc-4, argv+4, &indices) != TCL_OK) { 1560 return TCL_ERROR; 1561 } 1562 bool visible; 1563 visible = (bool)ivisible; 1564 for (unsigned int i = 0; i < indices.size(); ++i) { 1565 if ((indices[i] < NanoVis::heightMap.size()) && 1566 (NanoVis::heightMap[indices[i]] != NULL)) { 1567 NanoVis::heightMap[indices[i]]->setVisible(visible); 1568 } 1569 } 1570 } else if ((c == 'f') && (strcmp(argv[2],"follows") == 0)) { 1571 if (argc != 4) { 1572 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1573 " data follow length", (char *)NULL); 1574 return TCL_ERROR; 1575 } 1576 Rappture::Buffer buf; 1577 int nBytes; 1578 1579 if (Tcl_GetInt(interp, argv[3], &nBytes) != TCL_OK) { 1580 return TCL_ERROR; 1581 } 1582 if (GetDataStream(interp, buf, nBytes) != TCL_OK) { 1583 return TCL_ERROR; 1584 } 1585 buf.append("\0", 1); 1586 if (Tcl_Eval(interp, buf.bytes()) != TCL_OK) { 1587 fprintf(stderr, "error in command: %s\n", 1588 Tcl_GetStringResult(interp)); 1589 fflush(stderr); 1590 return TCL_ERROR; 1591 } 1592 } else { 1593 Tcl_AppendResult(interp, "unknown option \"", argv[2], "\": ", 1594 "should be visible or follows", (char *)NULL); 1595 return TCL_ERROR; 1596 } 1597 } else if ((c == 'l') && (strcmp(argv[1], "linecontour") == 0)) { 1598 if (argc < 3) { 1599 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1600 " linecontour visible|color ?args?", (char *)NULL); 1601 return TCL_ERROR; 1602 } 1603 vector<unsigned int> indices; 1604 char c; 1605 c = argv[2][0]; 1606 if ((c == 'v') && (strcmp(argv[2],"visible") == 0)) { 1607 if (argc < 4) { 1608 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1609 " linecontour visible boolean ?indices?", (char *)NULL); 1610 return TCL_ERROR; 1611 } 1612 int ivisible; 1613 bool visible; 1614 if (Tcl_GetBoolean(interp, argv[3], &ivisible) != TCL_OK) { 1615 return TCL_ERROR; 1616 } 1617 visible = (bool)ivisible; 1618 if (GetIndices(interp, argc-4, argv+4, &indices) != TCL_OK) { 1619 return TCL_ERROR; 1620 } 1621 for (unsigned int i = 0; i < indices.size(); ++i) { 1622 if ((indices[i] < NanoVis::heightMap.size()) && 1623 (NanoVis::heightMap[indices[i]] != NULL)) { 1624 NanoVis::heightMap[indices[i]]->setLineContourVisible(visible); 1625 } 1626 } 1627 } else if ((c == 'c') && (strcmp(argv[2],"color") == 0)) { 1628 if (argc < 6) { 1629 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1630 " linecontour color r g b ?indices?", (char *)NULL); 1631 return TCL_ERROR; 1632 } 1633 float r, g, b; 1634 if ((GetFloat(interp, argv[3], &r) != TCL_OK) || 1635 (GetFloat(interp, argv[4], &g) != TCL_OK) || 1636 (GetFloat(interp, argv[5], &b) != TCL_OK)) { 1637 return TCL_ERROR; 1638 } 1639 vector<unsigned int> indices; 1640 if (GetIndices(interp, argc-6, argv+6, &indices) != TCL_OK) { 1641 return TCL_ERROR; 1642 } 1643 for (unsigned int i = 0; i < indices.size(); ++i) { 1644 if ((indices[i] < NanoVis::heightMap.size()) && 1645 (NanoVis::heightMap[indices[i]] != NULL)) { 1646 NanoVis::heightMap[indices[i]]->setLineContourColor(r, g, b); 1647 } 1648 } 1649 } else { 1650 Tcl_AppendResult(interp, "unknown option \"", argv[2], "\": ", 1651 "should be visible or color", (char *)NULL); 1652 return TCL_ERROR; 1653 } 1654 } else if ((c == 't') && (strcmp(argv[1], "transfunc") == 0)) { 1655 if (argc < 3) { 1656 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1657 " transfunc name ?indices?", (char *)NULL); 1658 return TCL_ERROR; 1659 } 1660 TransferFunction *tf; 1661 1662 tf = NanoVis::get_transfunc(argv[2]); 1663 if (tf == NULL) { 1664 Tcl_AppendResult(interp, "transfer function \"", argv[2], 1665 "\" is not defined", (char*)NULL); 1666 return TCL_ERROR; 1667 } 1668 vector<unsigned int> indices; 1669 if (GetIndices(interp, argc - 3, argv + 3, &indices) != TCL_OK) { 1670 return TCL_ERROR; 1671 } 1672 for (unsigned int i = 0; i < indices.size(); ++i) { 1673 if ((indices[i] < NanoVis::heightMap.size()) && 1674 (NanoVis::heightMap[indices[i]] != NULL)) { 1675 NanoVis::heightMap[indices[i]]->setColorMap(tf); 1676 } 1677 } 1678 } else if ((c == 'l') && (strcmp(argv[1], "legend") == 0)) { 1679 if (argc != 5) { 1680 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1681 " legend index width height\"", (char*)NULL); 1682 return TCL_ERROR; 1683 } 1684 HeightMap *hMap; 1685 if (GetHeightMap(interp, argv[2], &hMap) != TCL_OK) { 1686 return TCL_ERROR; 1687 } 1688 TransferFunction *tf; 1689 tf = hMap->getColorMap(); 1690 if (tf == NULL) { 1691 Tcl_AppendResult(interp, 1692 "no transfer function defined for heightmap \"", argv[1], "\"", 1693 (char*)NULL); 1694 return TCL_ERROR; 1695 } 1696 int width, height; 1697 if ((Tcl_GetInt(interp, argv[3], &width) != TCL_OK) || 1698 (Tcl_GetInt(interp, argv[4], &height) != TCL_OK)) { 1699 return TCL_ERROR; 1700 } 1701 NanoVis::render_legend(tf, hMap->range_min(), hMap->range_max(), 1702 width, height, argv[1]); 1703 } else if ((c == 'p') && (strcmp(argv[1], "polygon") == 0)) { 1704 if (argc != 3) { 1705 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1706 " polygon mode", (char *)NULL); 1707 return TCL_ERROR; 1708 } 1709 graphics::RenderContext::PolygonMode mode; 1710 if (GetPolygonMode(interp, argv[2], &mode) != TCL_OK) { 1711 return TCL_ERROR; 1712 } 1713 NanoVis::renderContext->setPolygonMode(mode); 1714 } else if ((c == 'c') && (strcmp(argv[1], "cull") == 0)) { 1715 if (argc != 3) { 1716 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1717 " cull mode", (char *)NULL); 1718 return TCL_ERROR; 1719 } 1720 graphics::RenderContext::CullMode mode; 1721 if (GetCullMode(interp, argv[2], &mode) != TCL_OK) { 1722 return TCL_ERROR; 1723 } 1724 NanoVis::renderContext->setCullMode(mode); 1725 } else if ((c == 's') && (strcmp(argv[1], "shade") == 0)) { 1726 if (argc != 3) { 1727 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1728 " shade model", (char *)NULL); 1729 return TCL_ERROR; 1730 } 1731 graphics::RenderContext::ShadingModel model; 1732 if (GetShadingModel(interp, argv[2], &model) != TCL_OK) { 1733 return TCL_ERROR; 1734 } 1735 NanoVis::renderContext->setShadingModel(model); 1736 } else { 1737 Tcl_AppendResult(interp, "bad option \"", argv[1], 1738 "\": should be data, linecontour, legend, or transfunc", 1739 (char*)NULL); 1740 return TCL_ERROR; 1741 } 1742 return TCL_OK; 1743 } 1633 /* heightmap create xmin ymin xmax ymax xnum ynum values */ 1634 hMap = CreateHeightMap(cdata, interp, objc - 2, objv + 2); 1635 if (hMap == NULL) { 1636 return TCL_ERROR; 1637 } 1638 NanoVis::heightMap.push_back(hMap); 1639 Tcl_SetIntObj(Tcl_GetObjResult(interp), NanoVis::heightMap.size() - 1);; 1640 return TCL_OK; 1641 } 1642 1643 static int 1644 HeightMapLegendOp(ClientData cdata, Tcl_Interp *interp, int objc, 1645 Tcl_Obj *CONST *objv) 1646 { 1647 HeightMap *hMap; 1648 if (GetHeightMap(interp, objv[2], &hMap) != TCL_OK) { 1649 return TCL_ERROR; 1650 } 1651 TransferFunction *tf; 1652 tf = hMap->getColorMap(); 1653 if (tf == NULL) { 1654 Tcl_AppendResult(interp, "no transfer function defined for heightmap \"", 1655 Tcl_GetString(objv[2]), "\"", (char*)NULL); 1656 return TCL_ERROR; 1657 } 1658 int w, h; 1659 if ((Tcl_GetIntFromObj(interp, objv[3], &w) != TCL_OK) || 1660 (Tcl_GetIntFromObj(interp, objv[4], &h) != TCL_OK)) { 1661 return TCL_ERROR; 1662 } 1663 NanoVis::render_legend(tf, hMap->range_min(), hMap->range_max(), 1664 w, h, "label"); 1665 return TCL_OK; 1666 } 1667 1668 static int 1669 HeightMapPolygonOp(ClientData cdata, Tcl_Interp *interp, int objc, 1670 Tcl_Obj *CONST *objv) 1671 { 1672 graphics::RenderContext::PolygonMode mode; 1673 if (GetPolygonMode(interp, objv[2], &mode) != TCL_OK) { 1674 return TCL_ERROR; 1675 } 1676 NanoVis::renderContext->setPolygonMode(mode); 1677 return TCL_OK; 1678 } 1679 1680 static int 1681 HeightMapShadeOp(ClientData cdata, Tcl_Interp *interp, int objc, 1682 Tcl_Obj *CONST *objv) 1683 { 1684 graphics::RenderContext::ShadingModel model; 1685 if (GetShadingModel(interp, objv[2], &model) != TCL_OK) { 1686 return TCL_ERROR; 1687 } 1688 NanoVis::renderContext->setShadingModel(model); 1689 return TCL_OK; 1690 } 1691 1692 static int 1693 HeightMapTestOp(ClientData cdata, Tcl_Interp *interp, int objc, 1694 Tcl_Obj *CONST *objv) 1695 { 1696 srand((unsigned)time(NULL)); 1697 1698 int size = 20 * 200; 1699 double sigma = 5.0; 1700 double mean = exp(0.0) / (sigma * sqrt(2.0)); 1701 float* data = (float*) malloc(sizeof(float) * size); 1702 1703 float x; 1704 for (int i = 0; i < size; ++i) { 1705 x = - 10 + i%20; 1706 data[i] = exp(- (x * x)/(2 * sigma * sigma)) / 1707 (sigma * sqrt(2.0)) / mean * 2 + 1000; 1708 } 1709 1710 HeightMap* heightMap = new HeightMap(); 1711 float minx = 0.0f; 1712 float maxx = 1.0f; 1713 float miny = 0.5f; 1714 float maxy = 3.5f; 1715 heightMap->setHeight(minx, miny, maxx, maxy, 20, 200, data); 1716 heightMap->setColorMap(NanoVis::get_transfunc("default")); 1717 heightMap->setVisible(true); 1718 heightMap->setLineContourVisible(true); 1719 NanoVis::heightMap.push_back(heightMap); 1720 1721 1722 Vector3 min(minx, (float) heightMap->range_min(), miny); 1723 Vector3 max(maxx, (float) heightMap->range_max(), maxy); 1724 1725 NanoVis::grid->setMinMax(min, max); 1726 NanoVis::grid->setVisible(true); 1727 1728 return TCL_OK; 1729 } 1730 1731 static int 1732 HeightMapTransFuncOp(ClientData cdata, Tcl_Interp *interp, int objc, 1733 Tcl_Obj *CONST *objv) 1734 { 1735 char *name; 1736 name = Tcl_GetString(objv[2]); 1737 TransferFunction *tf; 1738 tf = NanoVis::get_transfunc(name); 1739 if (tf == NULL) { 1740 Tcl_AppendResult(interp, "transfer function \"", name, 1741 "\" is not defined", (char*)NULL); 1742 return TCL_ERROR; 1743 } 1744 vector<unsigned int> indices; 1745 if (GetIndices(interp, objc - 3, objv + 3, &indices) != TCL_OK) { 1746 return TCL_ERROR; 1747 } 1748 for (unsigned int i = 0; i < indices.size(); ++i) { 1749 if ((indices[i] < NanoVis::heightMap.size()) && 1750 (NanoVis::heightMap[indices[i]] != NULL)) { 1751 NanoVis::heightMap[indices[i]]->setColorMap(tf); 1752 } 1753 } 1754 return TCL_OK; 1755 } 1756 1757 static Rappture::CmdSpec heightMapOps[] = 1758 { 1759 {"create", 2, HeightMapCreateOp, 9, 9, 1760 "xmin ymin xmax ymax xnum ynum values",}, 1761 {"cull", 2, HeightMapCullOp, 3, 3, "mode",}, 1762 {"data", 1, HeightMapDataOp, 3, 0, "oper ?args?",}, 1763 {"legend", 2, HeightMapLegendOp, 5, 5, "index width height",}, 1764 {"linecontour", 2, HeightMapLineContourOp, 2, 0, "oper ?args?",}, 1765 {"polygon", 1, HeightMapPolygonOp, 3, 3, "mode",}, 1766 {"shade", 1, HeightMapShadeOp, 3, 3, "model",}, 1767 {"test", 2, HeightMapTestOp, 2, 2, "",}, 1768 {"transfunc", 2, HeightMapTransFuncOp, 3, 0, "name ?indices?",}, 1769 }; 1770 static int nHeightMapOps = NumCmdSpecs(heightMapOps); 1744 1771 1745 1772 static int 1746 GridCmd(ClientData cdata, Tcl_Interp *interp, int argc, const char *argv[]) 1747 { 1748 if (argc < 2) { 1749 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1750 " option ?args?", (char *)NULL); 1751 return TCL_ERROR; 1752 } 1753 char c = argv[1][0]; 1754 if ((c == 'v') && (strcmp(argv[1],"visible") == 0)) { 1773 HeightMapCmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv) 1774 { 1775 Tcl_ObjCmdProc *proc; 1776 1777 proc = Rappture::GetOpFromObj(interp, nHeightMapOps, heightMapOps, 1778 Rappture::CMDSPEC_ARG1, objc, objv, 0); 1779 if (proc == NULL) { 1780 return TCL_ERROR; 1781 } 1782 return (*proc) (cdata, interp, objc, objv); 1783 } 1784 1785 static int 1786 GridCmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv) 1787 { 1788 if (objc < 2) { 1789 Tcl_AppendResult(interp, "wrong # args: should be \"", 1790 Tcl_GetString(objv[0]), " option ?args?", (char *)NULL); 1791 return TCL_ERROR; 1792 } 1793 char *string = Tcl_GetString(objv[1]); 1794 char c = string[0]; 1795 if ((c == 'v') && (strcmp(string,"visible") == 0)) { 1755 1796 int ivisible; 1756 1797 1757 if (Tcl_GetBoolean (interp, argv[2], &ivisible) != TCL_OK) {1798 if (Tcl_GetBooleanFromObj(interp, objv[2], &ivisible) != TCL_OK) { 1758 1799 return TCL_ERROR; 1759 1800 } 1760 1801 NanoVis::grid->setVisible((bool)ivisible); 1761 } else if ((c == 'l') && (strcmp( argv[1],"linecount") == 0)) {1802 } else if ((c == 'l') && (strcmp(string, "linecount") == 0)) { 1762 1803 int x, y, z; 1763 1804 1764 if ((Tcl_GetInt (interp, argv[2], &x) != TCL_OK) ||1765 (Tcl_GetInt (interp, argv[3], &y) != TCL_OK) ||1766 (Tcl_GetInt (interp, argv[4], &z) != TCL_OK)) {1805 if ((Tcl_GetIntFromObj(interp, objv[2], &x) != TCL_OK) || 1806 (Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK) || 1807 (Tcl_GetIntFromObj(interp, objv[4], &z) != TCL_OK)) { 1767 1808 return TCL_ERROR; 1768 1809 } … … 1770 1811 NanoVis::grid->setGridLineCount(x, y, z); 1771 1812 } 1772 } else if ((c == 'a') && (strcmp( argv[1],"axiscolor") == 0)) {1813 } else if ((c == 'a') && (strcmp(string, "axiscolor") == 0)) { 1773 1814 float r, g, b, a; 1774 if ((GetFloat (interp, argv[2], &r) != TCL_OK) ||1775 (GetFloat (interp, argv[3], &g) != TCL_OK) ||1776 (GetFloat (interp, argv[4], &b) != TCL_OK)) {1815 if ((GetFloatFromObj(interp, objv[2], &r) != TCL_OK) || 1816 (GetFloatFromObj(interp, objv[3], &g) != TCL_OK) || 1817 (GetFloatFromObj(interp, objv[4], &b) != TCL_OK)) { 1777 1818 return TCL_ERROR; 1778 1819 } 1779 1820 a = 1.0f; 1780 if (( argc == 6) && (GetFloat(interp, argv[5], &a) != TCL_OK)) {1821 if ((objc == 6) && (GetFloatFromObj(interp, objv[5], &a) != TCL_OK)) { 1781 1822 return TCL_ERROR; 1782 1823 } … … 1784 1825 NanoVis::grid->setAxisColor(r, g, b, a); 1785 1826 } 1786 } else if ((c == 'l') && (strcmp( argv[1],"linecolor") == 0)) {1827 } else if ((c == 'l') && (strcmp(string, "linecolor") == 0)) { 1787 1828 float r, g, b, a; 1788 if ((GetFloat (interp, argv[2], &r) != TCL_OK) ||1789 (GetFloat (interp, argv[3], &g) != TCL_OK) ||1790 (GetFloat (interp, argv[4], &b) != TCL_OK)) {1829 if ((GetFloatFromObj(interp, objv[2], &r) != TCL_OK) || 1830 (GetFloatFromObj(interp, objv[3], &g) != TCL_OK) || 1831 (GetFloatFromObj(interp, objv[4], &b) != TCL_OK)) { 1791 1832 return TCL_ERROR; 1792 1833 } 1793 1834 a = 1.0f; 1794 if (( argc == 6) && (GetFloat(interp, argv[5], &a) != TCL_OK)) {1835 if ((objc == 6) && (GetFloatFromObj(interp, objv[5], &a) != TCL_OK)) { 1795 1836 return TCL_ERROR; 1796 1837 } … … 1798 1839 NanoVis::grid->setGridLineColor(r, g, b, a); 1799 1840 } 1800 } else if ((c == 'm') && (strcmp( argv[1],"minmax") == 0)) {1841 } else if ((c == 'm') && (strcmp(string, "minmax") == 0)) { 1801 1842 double x1, y1, z1, x2, y2, z2; 1802 if ((Tcl_GetDouble (interp, argv[2], &x1) != TCL_OK) ||1803 (Tcl_GetDouble (interp, argv[3], &y1) != TCL_OK) ||1804 (Tcl_GetDouble (interp, argv[4], &z1) != TCL_OK) ||1805 (Tcl_GetDouble (interp, argv[5], &x2) != TCL_OK) ||1806 (Tcl_GetDouble (interp, argv[6], &y2) != TCL_OK) ||1807 (Tcl_GetDouble (interp, argv[7], &z2) != TCL_OK)) {1843 if ((Tcl_GetDoubleFromObj(interp, objv[2], &x1) != TCL_OK) || 1844 (Tcl_GetDoubleFromObj(interp, objv[3], &y1) != TCL_OK) || 1845 (Tcl_GetDoubleFromObj(interp, objv[4], &z1) != TCL_OK) || 1846 (Tcl_GetDoubleFromObj(interp, objv[5], &x2) != TCL_OK) || 1847 (Tcl_GetDoubleFromObj(interp, objv[6], &y2) != TCL_OK) || 1848 (Tcl_GetDoubleFromObj(interp, objv[7], &z2) != TCL_OK)) { 1808 1849 return TCL_ERROR; 1809 1850 } … … 1811 1852 NanoVis::grid->setMinMax(Vector3(x1, y1, z1), Vector3(x2, y2, z2)); 1812 1853 } 1813 } else if ((c == 'a') && (strcmp( argv[1],"axisname") == 0)) {1854 } else if ((c == 'a') && (strcmp(string, "axisname") == 0)) { 1814 1855 int axisId; 1815 if (GetAxis (interp, argv[2], &axisId) != TCL_OK) {1856 if (GetAxisFromObj(interp, objv[2], &axisId) != TCL_OK) { 1816 1857 return TCL_ERROR; 1817 1858 } 1818 1859 if (NanoVis::grid) { 1819 NanoVis::grid->setAxisName(axisId, argv[3]);1860 NanoVis::grid->setAxisName(axisId, Tcl_GetString(objv[3])); 1820 1861 } 1821 1862 } else { 1822 Tcl_AppendResult(interp, "bad option \"", argv[1],1863 Tcl_AppendResult(interp, "bad option \"", Tcl_GetString(objv[1]), 1823 1864 "\": should be data, outline, shading, or state", 1824 1865 (char*)NULL); … … 1829 1870 1830 1871 static int 1831 AxisCmd(ClientData cdata, Tcl_Interp *interp, int argc, const char *argv[]) 1832 { 1833 if (argc < 2) { 1834 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 1835 " option arg arg...\"", (char*)NULL); 1836 return TCL_ERROR; 1837 } 1838 char c = argv[1][0]; 1839 if ((c == 'v') && (strcmp(argv[1], "visible") == 0)) { 1872 AxisCmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv) 1873 { 1874 if (objc < 2) { 1875 Tcl_AppendResult(interp, "wrong # args: should be \"", 1876 Tcl_GetString(objv[0]), " option arg arg...\"", (char*)NULL); 1877 return TCL_ERROR; 1878 } 1879 char *string = Tcl_GetString(objv[1]); 1880 char c = string[0]; 1881 if ((c == 'v') && (strcmp(string, "visible") == 0)) { 1840 1882 int ivisible; 1841 1883 1842 if (Tcl_GetBoolean (interp, argv[2], &ivisible) != TCL_OK) {1884 if (Tcl_GetBooleanFromObj(interp, objv[2], &ivisible) != TCL_OK) { 1843 1885 return TCL_ERROR; 1844 1886 } 1845 1887 NanoVis::axis_on = (bool)ivisible; 1846 1888 } else { 1847 Tcl_AppendResult(interp, "bad axis option \"", argv[1],1889 Tcl_AppendResult(interp, "bad axis option \"", string, 1848 1890 "\": should be visible", (char*)NULL); 1849 1891 return TCL_ERROR; … … 1866 1908 */ 1867 1909 static int 1868 GetHeightMap(Tcl_Interp *interp, const char *string, HeightMap **hmPtrPtr)1910 GetHeightMap(Tcl_Interp *interp, Tcl_Obj *objPtr, HeightMap **hmPtrPtr) 1869 1911 { 1870 1912 int mapIndex; 1871 if (Tcl_GetInt (interp, string, &mapIndex) != TCL_OK) {1913 if (Tcl_GetIntFromObj(interp, objPtr, &mapIndex) != TCL_OK) { 1872 1914 return TCL_ERROR; 1873 1915 } 1874 1916 if ((mapIndex < 0) || (mapIndex >= (int)NanoVis::heightMap.size()) || 1875 1917 (NanoVis::heightMap[mapIndex] == NULL)) { 1876 Tcl_AppendResult(interp, "invalid heightmap index \"", string, "\"",1877 1918 Tcl_AppendResult(interp, "invalid heightmap index \"", 1919 Tcl_GetString(objPtr), "\"", (char *)NULL); 1878 1920 return TCL_ERROR; 1879 1921 } … … 1896 1938 */ 1897 1939 static int 1898 GetVolumeIndex(Tcl_Interp *interp, const char *string, unsigned int *indexPtr)1940 GetVolumeIndex(Tcl_Interp *interp, Tcl_Obj *objPtr, unsigned int *indexPtr) 1899 1941 { 1900 1942 int index; 1901 if (Tcl_GetInt (interp, string, &index) != TCL_OK) {1943 if (Tcl_GetIntFromObj(interp, objPtr, &index) != TCL_OK) { 1902 1944 return TCL_ERROR; 1903 1945 } 1904 1946 if (index < 0) { 1905 Tcl_AppendResult(interp, "can't have negative index \"", string,1906 1947 Tcl_AppendResult(interp, "can't have negative index \"", 1948 Tcl_GetString(objPtr), "\"", (char*)NULL); 1907 1949 return TCL_ERROR; 1908 1950 } 1909 1951 if (index >= (int)NanoVis::volume.size()) { 1910 Tcl_AppendResult(interp, "index \"", string,1952 Tcl_AppendResult(interp, "index \"", Tcl_GetString(objPtr), 1911 1953 "\" is out of range", (char*)NULL); 1912 1954 return TCL_ERROR; … … 1918 1960 /* 1919 1961 * ---------------------------------------------------------------------- 1920 * FUNCTION: GetVolume 1962 * FUNCTION: GetVolumeFromObj 1921 1963 * 1922 1964 * Used internally to decode a series of volume index values and … … 1930 1972 */ 1931 1973 static int 1932 GetVolume (Tcl_Interp *interp, const char *string, Volume **volPtrPtr)1974 GetVolumeFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, Volume **volPtrPtr) 1933 1975 { 1934 1976 unsigned int index; 1935 if (GetVolumeIndex(interp, string, &index) != TCL_OK) {1977 if (GetVolumeIndex(interp, objPtr, &index) != TCL_OK) { 1936 1978 return TCL_ERROR; 1937 1979 } … … 1939 1981 vol = NanoVis::volume[index]; 1940 1982 if (vol == NULL) { 1941 Tcl_AppendResult(interp, "no volume defined for index \"", string,1942 1983 Tcl_AppendResult(interp, "no volume defined for index \"", 1984 Tcl_GetString(objPtr), "\"", (char*)NULL); 1943 1985 return TCL_ERROR; 1944 1986 } … … 1961 2003 */ 1962 2004 static int 1963 GetVolumeIndices(Tcl_Interp *interp, int argc, const char *argv[],2005 GetVolumeIndices(Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv, 1964 2006 vector<unsigned int>* vectorPtr) 1965 2007 { 1966 if ( argc == 0) {2008 if (objc == 0) { 1967 2009 for (unsigned int n = 0; n < NanoVis::volume.size(); n++) { 1968 2010 if (NanoVis::volume[n] != NULL) { … … 1971 2013 } 1972 2014 } else { 1973 for (int n = 0; n < argc; n++) {2015 for (int n = 0; n < objc; n++) { 1974 2016 unsigned int index; 1975 2017 1976 if (GetVolumeIndex(interp, argv[n], &index) != TCL_OK) {2018 if (GetVolumeIndex(interp, objv[n], &index) != TCL_OK) { 1977 2019 return TCL_ERROR; 1978 2020 } … … 1986 2028 1987 2029 static int 1988 GetIndices(Tcl_Interp *interp, int argc, const char *argv[],2030 GetIndices(Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv, 1989 2031 vector<unsigned int>* vectorPtr) 1990 2032 { 1991 for (int n = 0; n < argc; n++) {2033 for (int n = 0; n < objc; n++) { 1992 2034 int index; 1993 2035 1994 if (Tcl_GetInt (interp, argv[n], &index) != TCL_OK) {2036 if (Tcl_GetIntFromObj(interp, objv[n], &index) != TCL_OK) { 1995 2037 return TCL_ERROR; 1996 2038 } 1997 2039 if (index < 0) { 1998 Tcl_AppendResult(interp, "can't have negative index \"", argv[n],1999 2040 Tcl_AppendResult(interp, "can't have negative index \"", 2041 Tcl_GetString(objv[n]), "\"", (char *)NULL); 2000 2042 return TCL_ERROR; 2001 2043 } … … 2020 2062 */ 2021 2063 static int 2022 GetVolumes(Tcl_Interp *interp, int argc, const char *argv[],2064 GetVolumes(Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv, 2023 2065 vector<Volume *>* vectorPtr) 2024 2066 { 2025 if ( argc == 0) {2067 if (objc == 0) { 2026 2068 for (unsigned int n = 0; n < NanoVis::volume.size(); n++) { 2027 2069 if (NanoVis::volume[n] != NULL) { … … 2030 2072 } 2031 2073 } else { 2032 for (int n = 0; n < argc; n++) {2074 for (int n = 0; n < objc; n++) { 2033 2075 Volume *volPtr; 2034 2076 2035 if (GetVolume (interp, argv[n], &volPtr) != TCL_OK) {2077 if (GetVolumeFromObj(interp, objv[n], &volPtr) != TCL_OK) { 2036 2078 return TCL_ERROR; 2037 2079 } … … 2043 2085 return TCL_OK; 2044 2086 } 2087 2045 2088 2046 2089 /* … … 2055 2098 */ 2056 2099 static int 2057 GetAxis(Tcl_Interp *interp, const char *string, int * valPtr)2100 GetAxis(Tcl_Interp *interp, const char *string, int *indexPtr) 2058 2101 { 2059 2102 if (string[1] == '\0') { … … 2062 2105 c = tolower((unsigned char)string[0]); 2063 2106 if (c == 'x') { 2064 * valPtr = 0;2107 *indexPtr = 0; 2065 2108 return TCL_OK; 2066 2109 } else if (c == 'y') { 2067 * valPtr = 1;2110 *indexPtr = 1; 2068 2111 return TCL_OK; 2069 2112 } else if (c == 'z') { 2070 * valPtr = 2;2113 *indexPtr = 2; 2071 2114 return TCL_OK; 2072 2115 } … … 2078 2121 } 2079 2122 2123 2124 /* 2125 * ---------------------------------------------------------------------- 2126 * FUNCTION: GetAxisFromObj() 2127 * 2128 * Used internally to decode an axis value from a string ("x", "y", 2129 * or "z") to its index (0, 1, or 2). Returns TCL_OK if successful, 2130 * along with a value in indexPtr. Otherwise, it returns TCL_ERROR 2131 * and an error message in the interpreter. 2132 * ---------------------------------------------------------------------- 2133 */ 2134 static int 2135 GetAxisFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, int *indexPtr) 2136 { 2137 return GetAxis(interp, Tcl_GetString(objPtr), indexPtr); 2138 } 2139 2140 /* 2141 * ---------------------------------------------------------------------- 2142 * FUNCTION: GetAxisDirFromObj() 2143 * 2144 * Used internally to decode an axis value from a string ("x", "y", 2145 * or "z") to its index (0, 1, or 2). Returns TCL_OK if successful, 2146 * along with a value in indexPtr. Otherwise, it returns TCL_ERROR 2147 * and an error message in the interpreter. 2148 * ---------------------------------------------------------------------- 2149 */ 2150 static int 2151 GetAxisDirFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, int *indexPtr, int *dirPtr) 2152 { 2153 char *string = Tcl_GetString(objPtr); 2154 2155 int sign = 1; 2156 if (*string == '-') { 2157 sign = -1; 2158 string++; 2159 } 2160 if (GetAxis(interp, string, indexPtr) != TCL_OK) { 2161 return TCL_ERROR; 2162 } 2163 if (dirPtr != NULL) { 2164 *dirPtr = sign; 2165 } 2166 return TCL_OK; 2167 } 2168 2080 2169 /* 2081 2170 * ---------------------------------------------------------------------- … … 2084 2173 * Used internally to decode a color value from a string ("R G B") 2085 2174 * as a list of three numbers 0-1. Returns TCL_OK if successful, 2086 * along with RGB values in valPtr. Otherwise, it returns TCL_ERROR2175 * along with RGB values in rgbPtr. Otherwise, it returns TCL_ERROR 2087 2176 * and an error message in the interpreter. 2088 2177 * ---------------------------------------------------------------------- 2089 2178 */ 2090 2179 static int 2091 GetColor(Tcl_Interp *interp, int argc, const char *argv[], float *rgbPtr)2092 { 2093 if ( argc < 3) {2180 GetColor(Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv, float *rgbPtr) 2181 { 2182 if (objc < 3) { 2094 2183 Tcl_AppendResult(interp, "missing color values\": ", 2095 2184 "should list of R G B values 0.0 - 1.0", (char*)NULL); 2096 2185 return TCL_ERROR; 2097 2186 } 2098 if ((GetFloat (interp, argv[0], rgbPtr + 0) != TCL_OK) ||2099 (GetFloat (interp, argv[1], rgbPtr + 1) != TCL_OK) ||2100 (GetFloat (interp, argv[2], rgbPtr + 2) != TCL_OK)) {2187 if ((GetFloatFromObj(interp, objv[0], rgbPtr + 0) != TCL_OK) || 2188 (GetFloatFromObj(interp, objv[1], rgbPtr + 1) != TCL_OK) || 2189 (GetFloatFromObj(interp, objv[2], rgbPtr + 2) != TCL_OK)) { 2101 2190 return TCL_ERROR; 2102 2191 } … … 2107 2196 #if PLANE_CMDS 2108 2197 static int 2109 PlaneNewCmd(ClientData cdata, Tcl_Interp *interp, int argc,2110 const char *argv[])2198 PlaneNewCmd(ClientData cdata, Tcl_Interp *interp, int objc, 2199 Tcl_Obj *CONST *objv) 2111 2200 { 2112 2201 fprintf(stderr, "load plane for 2D visualization command\n"); 2113 2114 2202 int index, w, h; 2115 2116 if (argc != 4) { 2117 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 2118 " plane_index w h \"", (char*)NULL); 2119 return TCL_ERROR; 2120 } 2121 if (Tcl_GetInt(interp, argv[1], &index) != TCL_OK) { 2122 return TCL_ERROR; 2123 } 2124 if (Tcl_GetInt(interp, argv[2], &w) != TCL_OK) { 2125 return TCL_ERROR; 2126 } 2127 if (Tcl_GetInt(interp, argv[3], &h) != TCL_OK) { 2203 if (objc != 4) { 2204 Tcl_AppendResult(interp, "wrong # args: should be \"", 2205 Tcl_GetString(objv[0]), " plane_index w h \"", (char*)NULL); 2206 return TCL_ERROR; 2207 } 2208 if (Tcl_GetIntFromObj(interp, objv[1], &index) != TCL_OK) { 2209 return TCL_ERROR; 2210 } 2211 if (Tcl_GetIntFromObj(interp, objv[2], &w) != TCL_OK) { 2212 return TCL_ERROR; 2213 } 2214 if (Tcl_GetIntFromObj(interp, objv[3], &h) != TCL_OK) { 2128 2215 return TCL_ERROR; 2129 2216 } … … 2148 2235 2149 2236 static int 2150 PlaneLinkCmd(ClientData cdata, Tcl_Interp *interp, int argc,2151 const char *argv[])2237 PlaneLinkCmd(ClientData cdata, Tcl_Interp *interp, int objc, 2238 Tcl_Obj *CONST *objv) 2152 2239 { 2153 2240 fprintf(stderr, "link the plane to the 2D renderer command\n"); … … 2155 2242 int plane_index, tf_index; 2156 2243 2157 if ( argc != 3) {2158 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],2159 2160 return TCL_ERROR; 2161 } 2162 if (Tcl_GetInt (interp, argv[1], &plane_index) != TCL_OK) {2163 return TCL_ERROR; 2164 } 2165 if (Tcl_GetInt (interp, argv[2], &tf_index) != TCL_OK) {2244 if (objc != 3) { 2245 Tcl_AppendResult(interp, "wrong # args: should be \"", 2246 Tcl_GetString(objv[0]), " plane_index tf_index \"", (char*)NULL); 2247 return TCL_ERROR; 2248 } 2249 if (Tcl_GetIntFromObj(interp, objv[1], &plane_index) != TCL_OK) { 2250 return TCL_ERROR; 2251 } 2252 if (Tcl_GetIntFromObj(interp, objv[2], &tf_index) != TCL_OK) { 2166 2253 return TCL_ERROR; 2167 2254 } … … 2173 2260 //The plane_index is the index mantained in the 2D plane renderer 2174 2261 static int 2175 PlaneEnableCmd(ClientData cdata, Tcl_Interp *interp, int argc,2176 const char *argv[])2262 PlaneEnableCmd(ClientData cdata, Tcl_Interp *interp, int objc, 2263 Tcl_Obj *CONST *objv) 2177 2264 { 2178 2265 fprintf(stderr,"enable a plane so the 2D renderer can render it command\n"); 2179 2266 2180 if ( argc != 3) {2181 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],2182 2267 if (objc != 3) { 2268 Tcl_AppendResult(interp, "wrong # args: should be \"", 2269 Tcl_GetString(objv[0]), " plane_index mode \"", (char*)NULL); 2183 2270 return TCL_ERROR; 2184 2271 } 2185 2272 int plane_index; 2186 if (Tcl_GetInt (interp, argv[1], &plane_index) != TCL_OK) {2273 if (Tcl_GetIntFromObj(interp, objv[1], &plane_index) != TCL_OK) { 2187 2274 return TCL_ERROR; 2188 2275 } 2189 2276 int mode; 2190 if (Tcl_GetInt (interp, argv[2], &mode) != TCL_OK) {2277 if (Tcl_GetIntFromObj(interp, objv[2], &mode) != TCL_OK) { 2191 2278 return TCL_ERROR; 2192 2279 } … … 2208 2295 2209 2296 // manipulate the viewpoint 2210 Tcl_Create Command(interp, "camera", CameraCmd,2211 (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);2297 Tcl_CreateObjCommand(interp, "camera", CameraCmd, 2298 NULL, (Tcl_CmdDeleteProc*)NULL); 2212 2299 2213 2300 // turn on/off cut planes in x/y/z directions 2214 Tcl_Create Command(interp, "cutplane", CutplaneCmd,2215 (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);2301 Tcl_CreateObjCommand(interp, "cutplane", CutplaneCmd, 2302 NULL, (Tcl_CmdDeleteProc*)NULL); 2216 2303 2217 2304 // request the legend for a plot (transfer function) 2218 Tcl_Create Command(interp, "legend", LegendCmd,2219 (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);2305 Tcl_CreateObjCommand(interp, "legend", LegendCmd, 2306 NULL, (Tcl_CmdDeleteProc*)NULL); 2220 2307 2221 2308 // change the size of the screen (size of picture generated) 2222 Tcl_Create Command(interp, "screen", ScreenCmd,2223 (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);2309 Tcl_CreateObjCommand(interp, "screen", ScreenCmd, 2310 NULL, (Tcl_CmdDeleteProc*)NULL); 2224 2311 2225 2312 // manipulate transfer functions 2226 Tcl_Create Command(interp, "transfunc", TransfuncCmd,2227 (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);2313 Tcl_CreateObjCommand(interp, "transfunc", TransfuncCmd, 2314 NULL, (Tcl_CmdDeleteProc*)NULL); 2228 2315 2229 2316 // set the "up" direction for volumes 2230 Tcl_Create Command(interp, "up", UpCmd,2231 (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);2317 Tcl_CreateObjCommand(interp, "up", UpCmd, 2318 NULL, (Tcl_CmdDeleteProc*)NULL); 2232 2319 2233 2320 // manipulate volume data 2234 Tcl_Create Command(interp, "volume", VolumeCmd,2235 (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);2236 2237 Tcl_Create Command(interp, "flow", FlowCmd,2238 (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);2239 2240 Tcl_Create Command(interp, "axis", AxisCmd,2241 (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);2242 2243 Tcl_Create Command(interp, "grid", GridCmd,2244 (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);2245 2246 Tcl_Create Command(interp, "heightmap", HeightMapCmd,2247 (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);2321 Tcl_CreateObjCommand(interp, "volume", VolumeCmd, 2322 NULL, (Tcl_CmdDeleteProc*)NULL); 2323 2324 Tcl_CreateObjCommand(interp, "flow", FlowCmd, 2325 NULL, (Tcl_CmdDeleteProc*)NULL); 2326 2327 Tcl_CreateObjCommand(interp, "axis", AxisCmd, 2328 NULL, (Tcl_CmdDeleteProc*)NULL); 2329 2330 Tcl_CreateObjCommand(interp, "grid", GridCmd, 2331 NULL, (Tcl_CmdDeleteProc*)NULL); 2332 2333 Tcl_CreateObjCommand(interp, "heightmap", HeightMapCmd, 2334 NULL, (Tcl_CmdDeleteProc*)NULL); 2248 2335 2249 2336 // get screenshot 2250 Tcl_Create Command(interp, "screenshot", ScreenShotCmd,2251 (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);2252 2253 Tcl_Create Command(interp, "unirect2d", UniRect2dCmd,2254 (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);2255 2256 Tcl_Create Command(interp, "axis", AxisCmd,2257 (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);2258 2259 Tcl_Create Command(interp, "grid", GridCmd,2260 (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);2261 2262 Tcl_Create Command(interp, "heightmap", HeightMapCmd,2263 (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);2337 Tcl_CreateObjCommand(interp, "screenshot", ScreenShotCmd, 2338 NULL, (Tcl_CmdDeleteProc*)NULL); 2339 2340 Tcl_CreateObjCommand(interp, "unirect2d", UniRect2dCmd, 2341 NULL, (Tcl_CmdDeleteProc*)NULL); 2342 2343 Tcl_CreateObjCommand(interp, "axis", AxisCmd, 2344 NULL, (Tcl_CmdDeleteProc*)NULL); 2345 2346 Tcl_CreateObjCommand(interp, "grid", GridCmd, 2347 NULL, (Tcl_CmdDeleteProc*)NULL); 2348 2349 Tcl_CreateObjCommand(interp, "heightmap", HeightMapCmd, 2350 NULL, (Tcl_CmdDeleteProc*)NULL); 2264 2351 2265 2352 // get screenshot 2266 Tcl_Create Command(interp, "screenshot", ScreenShotCmd,2267 (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);2268 2269 Tcl_Create Command(interp, "unirect2d", UniRect2dCmd,2270 (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);2353 Tcl_CreateObjCommand(interp, "screenshot", ScreenShotCmd, 2354 NULL, (Tcl_CmdDeleteProc*)NULL); 2355 2356 Tcl_CreateObjCommand(interp, "unirect2d", UniRect2dCmd, 2357 NULL, (Tcl_CmdDeleteProc*)NULL); 2271 2358 2272 2359 #if __TEST_CODE__ 2273 Tcl_Create Command(interp, "test", TestCmd,2274 (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);2275 2276 2277 // Tcl_Create Command(interp, "flow", FlowCmd,2278 // (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);2360 Tcl_CreateObjCommand(interp, "test", TestCmd, 2361 NULL, (Tcl_CmdDeleteProc*)NULL); 2362 2363 2364 // Tcl_CreateObjCommand(interp, "flow", FlowCmd, 2365 // NULL, (Tcl_CmdDeleteProc*)NULL); 2279 2366 #endif 2280 2367 … … 2459 2546 */ 2460 2547 static HeightMap * 2461 CreateHeightMap(ClientData clientData, Tcl_Interp *interp, int argc,2462 const char *argv[])2548 CreateHeightMap(ClientData clientData, Tcl_Interp *interp, int objc, 2549 Tcl_Obj *CONST *objv) 2463 2550 { 2464 2551 float xMin, yMin, xMax, yMax; 2465 2552 int xNum, yNum; 2466 2553 2467 if ( argc != 7) {2554 if (objc != 7) { 2468 2555 Tcl_AppendResult(interp, 2469 2556 "wrong # of values: should be xMin yMin xMax yMax xNum yNum heights", … … 2471 2558 return NULL; 2472 2559 } 2473 if ((GetFloat (interp, argv[0], &xMin) != TCL_OK) ||2474 (GetFloat (interp, argv[1], &yMin) != TCL_OK) ||2475 (GetFloat (interp, argv[2], &xMax) != TCL_OK) ||2476 (GetFloat (interp, argv[3], &yMax) != TCL_OK) ||2477 (Tcl_GetInt (interp, argv[4], &xNum) != TCL_OK) ||2478 (Tcl_GetInt (interp, argv[5], &yNum) != TCL_OK)) {2560 if ((GetFloatFromObj(interp, objv[0], &xMin) != TCL_OK) || 2561 (GetFloatFromObj(interp, objv[1], &yMin) != TCL_OK) || 2562 (GetFloatFromObj(interp, objv[2], &xMax) != TCL_OK) || 2563 (GetFloatFromObj(interp, objv[3], &yMax) != TCL_OK) || 2564 (Tcl_GetIntFromObj(interp, objv[4], &xNum) != TCL_OK) || 2565 (Tcl_GetIntFromObj(interp, objv[5], &yNum) != TCL_OK)) { 2479 2566 return NULL; 2480 2567 } 2481 2568 int nValues; 2482 const char**elem;2483 if (Tcl_ SplitList(interp, argv[6], &nValues, &elem) != TCL_OK) {2569 Tcl_Obj **elem; 2570 if (Tcl_ListObjGetElements(interp, objv[6], &nValues, &elem) != TCL_OK) { 2484 2571 return NULL; 2485 2572 } 2486 2573 if ((xNum <= 0) || (yNum <= 0)) { 2487 2574 Tcl_AppendResult(interp, "bad number of x or y values", (char *)NULL); 2488 goto error;2575 return NULL; 2489 2576 } 2490 2577 if (nValues != (xNum * yNum)) { 2491 2578 Tcl_AppendResult(interp, "wrong # of heights", (char *)NULL); 2492 goto error;2579 return NULL; 2493 2580 } 2494 2581 … … 2498 2585 Tcl_AppendResult(interp, "can't allocate array of heights", 2499 2586 (char *)NULL); 2500 goto error;2587 return NULL; 2501 2588 } 2502 2589 2503 2590 int i; 2504 2591 for (i = 0; i < nValues; i++) { 2505 if (GetFloat (interp, elem[i], heights + i) != TCL_OK) {2592 if (GetFloatFromObj(interp, elem[i], heights + i) != TCL_OK) { 2506 2593 delete [] heights; 2507 goto error;2594 return NULL; 2508 2595 } 2509 2596 } … … 2514 2601 hMap->setVisible(true); 2515 2602 hMap->setLineContourVisible(true); 2516 2517 Tcl_Free((char *)elem);2518 2603 delete [] heights; 2519 2604 return hMap; 2520 error:2521 Tcl_Free((char *)elem);2522 return NULL;2523 2605 } 2524 2606 … … 2535 2617 */ 2536 2618 static int 2537 UniRect2dCmd(ClientData, Tcl_Interp *interp, int argc, const char *argv[])2619 UniRect2dCmd(ClientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv) 2538 2620 { 2539 2621 int xNum, yNum, zNum; … … 2541 2623 float *zValues; 2542 2624 2543 if (( argc & 0x01) == 0) {2544 Tcl_AppendResult(interp, 2625 if ((objc & 0x01) == 0) { 2626 Tcl_AppendResult(interp, Tcl_GetString(objv[0]), ": ", 2545 2627 "wrong number of arguments: should be key-value pairs", 2546 2628 (char *)NULL); … … 2551 2633 xMin = yMin = xMax = yMax = 0.0f; 2552 2634 int i; 2553 for (i = 1; i < argc; i += 2) { 2554 if (strcmp(argv[i], "xmin") == 0) { 2555 if (GetFloat(interp, argv[i+1], &xMin) != TCL_OK) { 2556 return TCL_ERROR; 2557 } 2558 } else if (strcmp(argv[i], "xmax") == 0) { 2559 if (GetFloat(interp, argv[i+1], &xMax) != TCL_OK) { 2560 return TCL_ERROR; 2561 } 2562 } else if (strcmp(argv[i], "xnum") == 0) { 2563 if (Tcl_GetInt(interp, argv[i+1], &xNum) != TCL_OK) { 2635 for (i = 1; i < objc; i += 2) { 2636 char *string; 2637 2638 string = Tcl_GetString(objv[i]); 2639 if (strcmp(string, "xmin") == 0) { 2640 if (GetFloatFromObj(interp, objv[i+1], &xMin) != TCL_OK) { 2641 return TCL_ERROR; 2642 } 2643 } else if (strcmp(string, "xmax") == 0) { 2644 if (GetFloatFromObj(interp, objv[i+1], &xMax) != TCL_OK) { 2645 return TCL_ERROR; 2646 } 2647 } else if (strcmp(string, "xnum") == 0) { 2648 if (Tcl_GetIntFromObj(interp, objv[i+1], &xNum) != TCL_OK) { 2564 2649 return TCL_ERROR; 2565 2650 } … … 2569 2654 return TCL_ERROR; 2570 2655 } 2571 } else if (strcmp( argv[i], "ymin") == 0) {2572 if (GetFloat (interp, argv[i+1], &yMin) != TCL_OK) {2573 return TCL_ERROR; 2574 } 2575 } else if (strcmp( argv[i], "ymax") == 0) {2576 if (GetFloat (interp, argv[i+1], &yMax) != TCL_OK) {2577 return TCL_ERROR; 2578 } 2579 } else if (strcmp( argv[i], "ynum") == 0) {2580 if (Tcl_GetInt (interp, argv[i+1], &yNum) != TCL_OK) {2656 } else if (strcmp(string, "ymin") == 0) { 2657 if (GetFloatFromObj(interp, objv[i+1], &yMin) != TCL_OK) { 2658 return TCL_ERROR; 2659 } 2660 } else if (strcmp(string, "ymax") == 0) { 2661 if (GetFloatFromObj(interp, objv[i+1], &yMax) != TCL_OK) { 2662 return TCL_ERROR; 2663 } 2664 } else if (strcmp(string, "ynum") == 0) { 2665 if (Tcl_GetIntFromObj(interp, objv[i+1], &yNum) != TCL_OK) { 2581 2666 return TCL_ERROR; 2582 2667 } … … 2586 2671 return TCL_ERROR; 2587 2672 } 2588 } else if (strcmp( argv[i], "zvalues") == 0) {2589 const char **zlist;2590 2591 if (Tcl_ SplitList(interp, argv[i+1], &zNum, &zlist)!= TCL_OK) {2673 } else if (strcmp(string, "zvalues") == 0) { 2674 Tcl_Obj **zObj; 2675 2676 if (Tcl_ListObjGetElements(interp, objv[i+1], &zNum, &zObj)!= TCL_OK) { 2592 2677 return TCL_ERROR; 2593 2678 } … … 2595 2680 zValues = new float[zNum]; 2596 2681 for (j = 0; j < zNum; j++) { 2597 if (GetFloat(interp, zlist[j], zValues + j) != TCL_OK) { 2598 Tcl_Free((char *)zlist); 2682 if (GetFloatFromObj(interp, zObj[j], zValues + j) != TCL_OK) { 2599 2683 return TCL_ERROR; 2600 2684 } 2601 2685 } 2602 Tcl_Free((char *)zlist);2603 2686 } else { 2604 Tcl_AppendResult(interp, "unknown key \"", argv[i],2687 Tcl_AppendResult(interp, "unknown key \"", string, 2605 2688 "\": should be xmin, xmax, xnum, ymin, ymax, ynum, or zvalues", 2606 2689 (char *)NULL); -
trunk/vizservers/nanovis/HeightMap.h
r838 r913 104 104 *@brief Defind the color of the line contour 105 105 */ 106 void setLineContourColor(float r, float g, floatb);106 void setLineContourColor(float *rgb); 107 107 108 108 double range_min(void); … … 125 125 } 126 126 127 inline void HeightMap::setLineContourColor(float r , float g, float b)127 inline void HeightMap::setLineContourColor(float rgb[]) 128 128 { 129 _contourColor.x = r ;130 _contourColor.y = g;131 _contourColor.z = b;129 _contourColor.x = rgb[0]; 130 _contourColor.y = rgb[1]; 131 _contourColor.z = rgb[2]; 132 132 } 133 133 -
trunk/vizservers/nanovis/Makefile.in
r888 r913 2 2 # 3 3 # FIXME: I can see at least 3 possible candidates for separate libraries. 4 # R2, mat, and Image. 4 # R2, mat, and Image. (First 2 are done.) 5 5 # 6 6 SHELL = /bin/sh … … 28 28 AUXSRC = config.h define.h global.h 29 29 30 RP_DIR = @RP_DIR@ 31 R2INC = ./R2/include 32 MATINC = ./newmat11 33 34 DX_DIR = /usr/lib/dx 35 DX_INC_SPEC = -I$(DX_DIR)/include 36 DX_LIB_SPEC = -L$(DX_DIR)/lib_linux -lDXcallm -lm 37 GL_INC_SPEC = -I/usr/include/GL 38 GL_LIB_SPEC = -lGL -lglut -lglui -lGLEW -lCg -lCgGL -lpthread 39 MAT_INC_SPEC = -I$(MATINC) 40 R2_INC_SPEC = -I$(R2INC) 41 RP_INC_SPEC = -I$(RP_DIR)/include -I$(RP_DIR)/include/rappture2 42 RP_LIB_SPEC = -L$(RP_DIR)/lib -lrappture2 -lb64 -lz 30 DX_DIR = /usr/lib/dx 31 DX_INC_SPEC = -I$(DX_DIR)/include 32 DX_LIB_SPEC = -L$(DX_DIR)/lib_linux -lDXcallm -lm 33 GL_INC_SPEC = -I/usr/include/GL 34 GL_LIB_SPEC = -lGL -lglut -lglui -lGLEW -lCg -lCgGL -lpthread 35 MAT_DIR = ./newmat11 36 MAT_INC_SPEC = -I$(srcdir)/$(MAT_DIR) 37 MAT_LIB = $(MAT_DIR)/libnewmat11.a 38 MAT_LIB_SPEC = $(MAT_LIB) 39 R2_DIR = ./R2 40 R2_INC_SPEC = -I$(srcdir)/$(R2_DIR)/include 41 R2_LIB = $(R2_DIR)/src/libR2.a 42 R2_LIB_SPEC = $(R2_LIB) 43 RP_DIR = @RP_DIR@ 44 RP_INC_SPEC = -I$(RP_DIR)/include -I$(RP_DIR)/include/rappture2 45 RP_LIB_SPEC = -L$(RP_DIR)/lib -lrappture2 -lb64 -lz 43 46 44 47 LIBS = \ … … 46 49 -ltcl8.4 \ 47 50 $(GL_LIB_SPEC) \ 48 $(DX_LIB_SPEC) 51 $(DX_LIB_SPEC) \ 52 $(R2_LIB_SPEC) \ 53 $(MAT_LIB_SPEC) 49 54 50 55 INCLUDES = \ … … 64 69 BucketSort.o \ 65 70 NvCamera.o \ 71 CmdProc.o \ 66 72 Color.o \ 67 73 ColorGradient.o \ … … 104 110 PointSetRenderer.o \ 105 111 PointShader.o \ 106 R2FilePath.o \107 R2Fonts.o \108 R2Geometry.o \109 R2IndexBuffer.o \110 R2Object.o \111 R2VertexBuffer.o \112 R2string.o \113 112 RenderContext.o \ 114 113 RenderVertexArray.o \ … … 130 129 VolumeRenderer.o \ 131 130 ZincBlendeVolume.o \ 132 bandmat.o \133 cholesky.o \134 131 dxReader.o \ 135 132 dxReader2.o \ 136 evalue.o \ 137 fft.o \ 138 hholder.o \ 139 jacobi.o \ 140 myexcept.o \ 141 nanovis.o \ 142 newfft.o \ 143 newmat1.o \ 144 newmat2.o \ 145 newmat3.o \ 146 newmat4.o \ 147 newmat5.o \ 148 newmat6.o \ 149 newmat7.o \ 150 newmat8.o \ 151 newmat9.o \ 152 newmatex.o \ 153 newmatnl.o \ 154 newmatrm.o \ 155 nm_misc.o \ 156 solution.o \ 157 sort.o \ 158 submat.o \ 159 svd.o 133 nanovis.o 134 160 135 161 136 all: nanovis … … 172 147 173 148 clean: 149 make -C $(MAT_DIR) clean 174 150 rm -f nanovis client $(OBJS) 175 151 … … 177 153 rm -f Makefile *~ 178 154 179 nanovis: $(OBJS) 155 $(MAT_LIB): 156 make -C $(MAT_DIR) all 157 158 $(R2_LIB): 159 make -C $(R2_DIR)/src all 160 161 nanovis: $(MAT_LIB) $(R2_LIB) $(OBJS) 180 162 $(CC) $(CC_SWITCHES) -o $@ $^ $(LIBS) 181 163 … … 208 190 $(CC) $(CC_SWITCHES) -o $@ -c $< 209 191 RenderClient.o: socket/RenderClient.cpp socket/RenderClient.h 210 $(CC) $(CC_SWITCHES) -o $@ -c $<211 R2string.o: R2/src/R2string.cpp $(R2INC)/R2/R2string.h212 $(CC) $(CC_SWITCHES) -o $@ -c $<213 R2FilePath.o: R2/src/R2FilePath.cpp $(R2INC)/R2/R2FilePath.h214 $(CC) $(CC_SWITCHES) -o $@ -c $<215 R2Fonts.o: R2/src/R2Fonts.cpp $(R2INC)/R2/R2Fonts.h216 $(CC) $(CC_SWITCHES) -o $@ -c $<217 R2Object.o: R2/src/R2Object.cpp $(R2INC)/R2/R2Object.h218 $(CC) $(CC_SWITCHES) -o $@ -c $<219 R2Geometry.o: R2/src/R2Geometry.cpp $(R2INC)/R2/graphics/R2Geometry.h220 $(CC) $(CC_SWITCHES) -o $@ -c $<221 R2VertexBuffer.o: R2/src/R2VertexBuffer.cpp $(R2INC)/R2/graphics/R2VertexBuffer.h222 $(CC) $(CC_SWITCHES) -o $@ -c $<223 R2IndexBuffer.o: R2/src/R2IndexBuffer.cpp $(R2INC)/R2/graphics/R2IndexBuffer.h224 192 $(CC) $(CC_SWITCHES) -o $@ -c $< 225 193 … … 266 234 PointSetRenderer.o: PointSetRenderer.cpp PointSetRenderer.h 267 235 PointSet.o: PointSet.cpp PointSet.h 268 bandmat.o: newmat11/bandmat.cpp269 $(CC) $(CC_SWITCHES) -o $@ -c $<270 cholesky.o: newmat11/cholesky.cpp271 $(CC) $(CC_SWITCHES) -o $@ -c $<272 evalue.o: newmat11/evalue.cpp273 $(CC) $(CC_SWITCHES) -o $@ -c $<274 fft.o: newmat11/fft.cpp275 $(CC) $(CC_SWITCHES) -o $@ -c $<276 hholder.o: newmat11/hholder.cpp277 $(CC) $(CC_SWITCHES) -o $@ -c $<278 jacobi.o: newmat11/jacobi.cpp279 $(CC) $(CC_SWITCHES) -o $@ -c $<280 myexcept.o: newmat11/myexcept.cpp281 $(CC) $(CC_SWITCHES) -o $@ -c $<282 newfft.o: newmat11/newfft.cpp283 $(CC) $(CC_SWITCHES) -o $@ -c $<284 newmat1.o: newmat11/newmat1.cpp285 $(CC) $(CC_SWITCHES) -o $@ -c $<286 newmat2.o: newmat11/newmat2.cpp287 $(CC) $(CC_SWITCHES) -o $@ -c $<288 newmat3.o: newmat11/newmat3.cpp289 $(CC) $(CC_SWITCHES) -o $@ -c $<290 newmat4.o: newmat11/newmat4.cpp291 $(CC) $(CC_SWITCHES) -o $@ -c $<292 newmat5.o: newmat11/newmat5.cpp293 $(CC) $(CC_SWITCHES) -o $@ -c $<294 newmat6.o: newmat11/newmat6.cpp295 $(CC) $(CC_SWITCHES) -o $@ -c $<296 newmat7.o: newmat11/newmat7.cpp297 $(CC) $(CC_SWITCHES) -o $@ -c $<298 newmat8.o: newmat11/newmat8.cpp299 $(CC) $(CC_SWITCHES) -o $@ -c $<300 newmat9.o: newmat11/newmat9.cpp301 $(CC) $(CC_SWITCHES) -o $@ -c $<302 newmatex.o: newmat11/newmatex.cpp303 $(CC) $(CC_SWITCHES) -o $@ -c $<304 newmatnl.o: newmat11/newmatnl.cpp305 $(CC) $(CC_SWITCHES) -o $@ -c $<306 newmatrm.o: newmat11/newmatrm.cpp307 $(CC) $(CC_SWITCHES) -o $@ -c $<308 nm_misc.o: newmat11/nm_misc.cpp309 $(CC) $(CC_SWITCHES) -o $@ -c $<310 solution.o: newmat11/solution.cpp311 $(CC) $(CC_SWITCHES) -o $@ -c $<312 sort.o: newmat11/sort.cpp313 $(CC) $(CC_SWITCHES) -o $@ -c $<314 svd.o: newmat11/svd.cpp315 $(CC) $(CC_SWITCHES) -o $@ -c $<316 submat.o: newmat11/submat.cpp317 $(CC) $(CC_SWITCHES) -o $@ -c $<318 319 236 Image.o: imgLoaders/Image.cpp 320 237 $(CC) $(CC_SWITCHES) -o $@ -c $<
Note: See TracChangeset
for help on using the changeset viewer.