- Timestamp:
- May 30, 2006, 7:29:30 PM (18 years ago)
- Location:
- trunk/gui/vizservers/nanovis
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gui/vizservers/nanovis/Volume.cpp
r448 r449 54 54 55 55 //initialize the labels 56 strcpy(label[0], "X Label");57 strcpy(label[1], "Y Label");58 strcpy(label[2], "Z Label");56 label[0] = "X Label"; 57 label[1] = "Y Label"; 58 label[2] = "Z Label"; 59 59 } 60 60 … … 136 136 137 137 void Volume::set_label(int axis, char* txt){ 138 strcpy(label[axis], txt);139 } 138 label[axis] = txt; 139 } -
trunk/gui/vizservers/nanovis/Volume.h
r448 r449 17 17 #define _VOLUME_H_ 18 18 19 #include <string> 19 20 #include <vector> 20 21 … … 121 122 122 123 void set_label(int axis, char* txt); //change the label displayed on an axis 123 char label[3][50]; // the labels along each axis 0:x , 1:y, 2:z124 std::string label[3]; // the labels along each axis 0:x , 1:y, 2:z 124 125 }; 125 126 -
trunk/gui/vizservers/nanovis/VolumeRenderer.cpp
r448 r449 83 83 84 84 void VolumeRenderer::render_all(){ 85 int total_enabled_volumes = 0;86 85 int total_rendered_slices = 0; 87 86 88 //compute total enabled volumes 87 ConvexPolygon*** polys = new ConvexPolygon**[n_volumes]; //two dimension pointer array 88 //storing the slices 89 int* actual_slices = new int[n_volumes]; //number of actual slices for each volume 90 89 91 for(int i=0; i<n_volumes; i++){ 90 if(volume[i]->is_enabled()) 91 total_enabled_volumes ++; 92 } 93 //fprintf(stderr, "total volumes rendered: %d\n", total_enabled_volumes); 94 95 ConvexPolygon*** polys = new ConvexPolygon**[total_enabled_volumes]; //two dimension pointer array 96 //storing the slices 97 int* actual_slices = new int[total_enabled_volumes]; //number of actual slices for each volume 98 99 int cur_vol = -1; 100 for(int i=0; i<n_volumes; i++){ 92 polys[i] = NULL; 93 actual_slices[i] = 0; 94 101 95 if(!volume[i]->is_enabled()) 102 96 continue; //skip this volume 103 104 cur_vol++;105 97 106 98 int volume_index = i; … … 158 150 159 151 //draw volume bounding box with translation (the correct location in space) 160 if (volume[ i]->outline_is_enabled()) {152 if (volume[volume_index]->outline_is_enabled()) { 161 153 float olcolor[3]; 162 volume[ i]->get_outline_color(olcolor);154 volume[volume_index]->get_outline_color(olcolor); 163 155 draw_bounding_box(x0, y0, z0, x0+1, y0+1, z0+1, 164 156 (double)olcolor[0], (double)olcolor[1], (double)olcolor[2], … … 178 170 int n_actual_slices; 179 171 180 if (volume[ i]->data_is_enabled()) {172 if (volume[volume_index]->data_is_enabled()) { 181 173 n_actual_slices = (int)(fabs(zNear-zFar)/z_step + 1); 182 polys[ cur_vol] = new ConvexPolygon*[n_actual_slices];174 polys[volume_index] = new ConvexPolygon*[n_actual_slices]; 183 175 } else { 184 176 n_actual_slices = 0; 185 polys[ cur_vol] = NULL;186 } 187 actual_slices[ cur_vol] = n_actual_slices;177 polys[volume_index] = NULL; 178 } 179 actual_slices[volume_index] = n_actual_slices; 188 180 189 181 Vector4 vert1 = (Vector4(-10, -10, -0.5, 1)); … … 280 272 281 273 ConvexPolygon *poly = new ConvexPolygon(); 282 polys[ cur_vol][counter] = poly;274 polys[volume_index][counter] = poly; 283 275 counter++; 284 276 … … 317 309 318 310 int counter = 0; 319 for(int i=0; i< total_enabled_volumes; i++){311 for(int i=0; i<n_volumes; i++){ 320 312 for(int j=0; j<actual_slices[i]; j++){ 321 313 if(polys[i][j]->vertices.size() >= 3){ … … 364 356 365 357 //Deallocate all the memory used 366 for(int i=0; i< total_enabled_volumes; i++){358 for(int i=0; i<n_volumes; i++){ 367 359 for(int j=0; j<actual_slices[i]; j++){ 368 360 delete polys[i][j]; 369 361 } 370 delete[] polys[i]; 362 if (polys[i]) { 363 delete[] polys[i]; 364 } 371 365 } 372 366 delete[] polys; … … 865 859 1./volume[volume_index]->aspect_ratio_height, 866 860 1./volume[volume_index]->aspect_ratio_depth); 867 glPrint( vol->label[0], 0);861 glPrint((char*)vol->label[0].c_str(), 0); 868 862 glPopMatrix(); 869 863 glPopMatrix(); … … 871 865 //y 872 866 glPushMatrix(); 873 glTranslatef( -0.02, 0., 1.);867 glTranslatef(1., 0.5, 0.); 874 868 875 869 glPushMatrix(); … … 877 871 1./volume[volume_index]->aspect_ratio_height, 878 872 1./volume[volume_index]->aspect_ratio_depth); 879 glRotatef( 90., 0., 0., 1.);873 glRotatef(45., 0., 1., 0.); 880 874 glColor3f(1.f, 1.0f, 1.0f); 881 glPrint( vol->label[1], 0);875 glPrint((char*)vol->label[1].c_str(), 0); 882 876 glPopMatrix(); 883 877 glPopMatrix(); … … 893 887 glRotatef(90., 0., 1., 0.); 894 888 glColor3f(1.f, 1.0f, 1.0f); 895 glPrint( vol->label[2], 0);889 glPrint((char*)vol->label[2].c_str(), 0); 896 890 glPopMatrix(); 897 891 glPopMatrix(); -
trunk/gui/vizservers/nanovis/nanovis.cpp
r448 r449 421 421 char **xferv; 422 422 423 if (Tcl_SplitList(interp, argv[3], &xferc, (const char***)&xferv) != TCL_OK) {423 if (Tcl_SplitList(interp, argv[3], &xferc, &xferv) != TCL_OK) { 424 424 return TCL_ERROR; 425 425 } … … 487 487 * ---------------------------------------------------------------------- 488 488 * CLIENT COMMAND: 489 * volume axis label x|y|z <value> ?<volumeId> ...? 489 490 * volume data state on|off ?<volumeId> ...? 490 491 * volume outline state on|off ?<volumeId> ...? … … 502 503 VolumeCmd(ClientData cdata, Tcl_Interp *interp, int argc, CONST84 char *argv[]) 503 504 { 504 505 506 507 505 if (argc < 2) { 506 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 507 " option arg arg...\"", (char*)NULL); 508 return TCL_ERROR; 508 509 } 509 510 510 511 char c = *argv[1]; 511 if (c == 'd' && strcmp(argv[1],"data") == 0) {512 if (c == 'a' && strcmp(argv[1],"axis") == 0) { 512 513 if (argc < 3) { 513 514 515 514 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 515 argv[1], " option ?arg arg...?\"", (char*)NULL); 516 return TCL_ERROR; 516 517 } 517 518 c = *argv[2]; 518 if (c == 's' && strcmp(argv[2],"state") == 0) {519 if (c == 'l' && strcmp(argv[2],"label") == 0) { 519 520 if (argc < 4) { 520 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 521 argv[1], " state on|off ?volume ...?\"", (char*)NULL); 522 return TCL_ERROR; 521 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 522 argv[1], " label x|y|z string ?volume ...?\"", (char*)NULL); 523 return TCL_ERROR; 524 } 525 526 int axis; 527 if (GetAxis(interp, argv[3], &axis) != TCL_OK) { 528 return TCL_ERROR; 529 } 530 531 int ivol; 532 if (argc < 6) { 533 for (ivol=0; ivol < n_volumes; ivol++) { 534 volume[ivol]->set_label(axis, argv[4]); 535 } 536 } else { 537 for (int n=5; n < argc; n++) { 538 if (Tcl_GetInt(interp, argv[n], &ivol) != TCL_OK) { 539 return TCL_ERROR; 540 } 541 volume[ivol]->set_label(axis, argv[4]); 542 } 543 } 544 return TCL_OK; 545 } 546 Tcl_AppendResult(interp, "bad option \"", argv[2], 547 "\": should be label", (char*)NULL); 548 return TCL_ERROR; 549 } 550 else if (c == 'd' && strcmp(argv[1],"data") == 0) { 551 if (argc < 3) { 552 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 553 argv[1], " option ?arg arg...?\"", (char*)NULL); 554 return TCL_ERROR; 555 } 556 c = *argv[2]; 557 if (c == 's' && strcmp(argv[2],"state") == 0) { 558 if (argc < 4) { 559 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 560 argv[1], " state on|off ?volume ...?\"", (char*)NULL); 561 return TCL_ERROR; 523 562 } 524 563 525 564 int state; 526 527 528 565 if (Tcl_GetBoolean(interp, argv[3], &state) != TCL_OK) { 566 return TCL_ERROR; 567 } 529 568 530 569 int ivol; … … 539 578 } else { 540 579 for (int n=4; n < argc; n++) { 541 542 543 580 if (Tcl_GetInt(interp, argv[n], &ivol) != TCL_OK) { 581 return TCL_ERROR; 582 } 544 583 if (state) { 545 584 volume[ivol]->enable_data(); … … 551 590 return TCL_OK; 552 591 } 553 592 else if (c == 'f' && strcmp(argv[2],"follows") == 0) { 554 593 int nbytes; 555 556 557 594 if (Tcl_GetInt(interp, argv[3], &nbytes) != TCL_OK) { 595 return TCL_ERROR; 596 } 558 597 559 598 char fname[64]; … … 609 648 return TCL_ERROR; 610 649 } 611 650 else if (c == 'o' && strcmp(argv[1],"outline") == 0) { 612 651 if (argc < 3) { 613 614 615 652 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 653 argv[1], " option ?arg arg...?\"", (char*)NULL); 654 return TCL_ERROR; 616 655 } 617 656 c = *argv[2]; … … 693 732 return TCL_ERROR; 694 733 } 695 734 else if (c == 's' && strcmp(argv[1],"shading") == 0) { 696 735 if (argc < 3) { 697 698 699 736 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 737 argv[1], " option ?arg arg...?\"", (char*)NULL); 738 return TCL_ERROR; 700 739 } 701 740 c = *argv[2]; 702 741 if (c == 'c' && strcmp(argv[2],"color") == 0) { 703 742 if (argc < 4) { 704 705 706 743 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 744 argv[1], " color value ?volume ...?\"", (char*)NULL); 745 return TCL_ERROR; 707 746 } 708 747 709 748 float cval[3]; 710 711 712 749 if (GetColor(interp, (char*) argv[3], cval) != TCL_OK) { 750 return TCL_ERROR; 751 } 713 752 714 753 int ivol; … … 719 758 } else { 720 759 for (int n=4; n < argc; n++) { 721 722 723 760 if (Tcl_GetInt(interp, argv[n], &ivol) != TCL_OK) { 761 return TCL_ERROR; 762 } 724 763 //volume[ivol]->set_diffuse((float)dval); 725 764 } … … 727 766 return TCL_OK; 728 767 } 729 768 else if (c == 'd' && strcmp(argv[2],"diffuse") == 0) { 730 769 if (argc < 4) { 731 732 733 770 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 771 argv[1], " diffuse value ?volume ...?\"", (char*)NULL); 772 return TCL_ERROR; 734 773 } 735 774 736 775 double dval; 737 738 739 776 if (Tcl_GetDouble(interp, argv[3], &dval) != TCL_OK) { 777 return TCL_ERROR; 778 } 740 779 741 780 int ivol; … … 746 785 } else { 747 786 for (int n=4; n < argc; n++) { 748 749 750 787 if (Tcl_GetInt(interp, argv[n], &ivol) != TCL_OK) { 788 return TCL_ERROR; 789 } 751 790 volume[ivol]->set_diffuse((float)dval); 752 791 } … … 754 793 return TCL_OK; 755 794 } 756 795 else if (c == 'o' && strcmp(argv[2],"opacity") == 0) { 757 796 if (argc < 4) { 758 759 760 797 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 798 argv[1], " opacity value ?volume ...?\"", (char*)NULL); 799 return TCL_ERROR; 761 800 } 762 801 763 802 double dval; 764 765 766 803 if (Tcl_GetDouble(interp, argv[3], &dval) != TCL_OK) { 804 return TCL_ERROR; 805 } 767 806 768 807 int ivol; … … 773 812 } else { 774 813 for (int n=4; n < argc; n++) { 775 776 777 814 if (Tcl_GetInt(interp, argv[n], &ivol) != TCL_OK) { 815 return TCL_ERROR; 816 } 778 817 volume[ivol]->set_opacity_scale((float)dval); 779 818 } … … 781 820 return TCL_OK; 782 821 } 783 822 else if (c == 's' && strcmp(argv[2],"specular") == 0) { 784 823 if (argc < 4) { 785 786 787 824 Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], 825 argv[1], " specular value ?volume ...?\"", (char*)NULL); 826 return TCL_ERROR; 788 827 } 789 828 790 829 double dval; 791 792 793 830 if (Tcl_GetDouble(interp, argv[3], &dval) != TCL_OK) { 831 return TCL_ERROR; 832 } 794 833 795 834 int ivol; … … 800 839 } else { 801 840 for (int n=4; n < argc; n++) { 802 803 804 841 if (Tcl_GetInt(interp, argv[n], &ivol) != TCL_OK) { 842 return TCL_ERROR; 843 } 805 844 volume[ivol]->set_specular((float)dval); 806 845 } … … 976 1015 int rgbc; 977 1016 char **rgbv; 978 if (Tcl_SplitList(interp, str, &rgbc, (const char***)&rgbv) != TCL_OK) {1017 if (Tcl_SplitList(interp, str, &rgbc, &rgbv) != TCL_OK) { 979 1018 return TCL_ERROR; 980 1019 }
Note: See TracChangeset
for help on using the changeset viewer.