- Timestamp:
- Mar 7, 2008, 9:56:26 AM (17 years ago)
- Location:
- trunk/vizservers/nanovis
- Files:
-
- 1 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/vizservers/nanovis/Command.cpp
r928 r929 230 230 231 231 static int 232 GetVolumeLimits(Tcl_Interp *interp, float *minPtr, float *maxPtr) 233 { 234 int i; 232 GetVolumeLimits(Tcl_Interp *interp, AxisRange *range) 233 { 235 234 236 235 /* Find the first volume. */ 237 for (i = 0; i < NanoVis::n_volumes; i++) { 238 if (NanoVis::volume[i] != NULL) { 236 int start; 237 for (start = 0; start < NanoVis::n_volumes; start++) { 238 if (NanoVis::volume[start] != NULL) { 239 239 break; 240 240 } 241 241 } 242 if ( i== NanoVis::n_volumes) {242 if (start == NanoVis::n_volumes) { 243 243 Tcl_AppendResult(interp, "no volumes found", (char *)NULL); 244 244 return TCL_ERROR; 245 245 } 246 Volume *volPtr; 247 volPtr = NanoVis::volume[i]; 248 float min, max; 249 min = volPtr->range_min(); 250 max = volPtr->range_max(); 251 for (i++; i < NanoVis::n_volumes; i++) { 252 if (NanoVis::volume[i] == NULL) { 253 continue; 254 } 255 volPtr = NanoVis::volume[i]; 256 if (min > volPtr->range_min()) { 257 min = volPtr->range_min(); 258 } 259 if (max < volPtr->range_max()) { 260 max = volPtr->range_max(); 261 } 262 } 263 *minPtr = min; 264 *maxPtr = max; 246 int axis; 247 for (axis = AxisRange::X; axis <= AxisRange::VALUES; axis++) { 248 Volume *volPtr; 249 int i; 250 251 i = start; 252 volPtr = NanoVis::volume[i]; 253 range[axis] = *volPtr->GetRange(axis); 254 for (i++; i < NanoVis::n_volumes; i++) { 255 const AxisRange *rangePtr; 256 257 volPtr = NanoVis::volume[i]; 258 rangePtr = volPtr->GetRange(axis); 259 if (range[axis].max < rangePtr->max) { 260 range[axis].max = rangePtr->max; 261 } 262 if (range[axis].min > rangePtr->min) { 263 range[axis].min = rangePtr->min; 264 } 265 } 266 } 265 267 return TCL_OK; 266 268 } … … 553 555 c = tolower((unsigned char)string[0]); 554 556 if (c == 'x') { 555 *indexPtr = NanoVis::X;557 *indexPtr = AxisRange::X; 556 558 return TCL_OK; 557 559 } else if (c == 'y') { 558 *indexPtr = NanoVis::Y;560 *indexPtr = AxisRange::Y; 559 561 return TCL_OK; 560 562 } else if (c == 'z') { 561 *indexPtr = NanoVis::Z;563 *indexPtr = AxisRange::Z; 562 564 return TCL_OK; 563 565 } … … 728 730 } 729 731 730 static Rappture::CmdSpec cameraOps[] = 731 { 732 {"aim", 2, CameraAimOp, 5, 5, "x y z",}, 733 {"angle", 2, CameraAngleOp, 5, 5, "xAngle yAngle zAngle",}, 734 {"zoom", 1, CameraZoomOp, 3, 3, "factor",}, 735 }; 732 static Rappture::CmdSpec cameraOps[] = { 733 {"aim", 2, CameraAimOp, 5, 5, "x y z",}, 734 {"angle", 2, CameraAngleOp, 5, 5, "xAngle yAngle zAngle",}, 735 {"zoom", 1, CameraZoomOp, 3, 3, "factor",}, 736 }; 736 737 static int nCameraOps = NumCmdSpecs(cameraOps); 737 738 … … 786 787 } 787 788 Texture2D* plane = new Texture2D(256, 2, GL_FLOAT, GL_LINEAR, 1, data); 788 NanoVis::color_table_renderer->render(1024, 1024, plane, tf, vol->range_min(), 789 vol->range_max()); 789 AxisRange *rangePtr; 790 rangePtr = vol->GetRange(AxisRange::VALUES); 791 NanoVis::color_table_renderer->render(1024, 1024, plane, tf, rangePtr->min, 792 rangePtr->max); 790 793 delete plane; 791 794 … … 861 864 } 862 865 863 static Rappture::CmdSpec cutplaneOps[] = 864 { 865 {"position", 1, CutplanePositionOp, 4, 0, "bool axis ?indices?",}, 866 {"state", 1, CutplaneStateOp, 4, 0, "relval axis ?indices?",}, 867 }; 866 static Rappture::CmdSpec cutplaneOps[] = { 867 {"position", 1, CutplanePositionOp, 4, 0, "bool axis ?indices?",}, 868 {"state", 1, CutplaneStateOp, 4, 0, "relval axis ?indices?",}, 869 }; 868 870 static int nCutplaneOps = NumCmdSpecs(cutplaneOps); 869 871 … … 935 937 return TCL_ERROR; 936 938 } 937 float vmin, vmax; 938 if (GetVolumeLimits(interp, &vmin, &vmax) != TCL_OK) { 939 return TCL_ERROR; 940 } 941 NanoVis::render_legend(tf, vmin, vmax, w, h, label); 939 AxisRange range[4]; 940 if (GetVolumeLimits(interp, range) != TCL_OK) { 941 return TCL_ERROR; 942 } 943 NanoVis::render_legend(tf, 944 range[AxisRange::VALUES].min, 945 range[AxisRange::VALUES].max, 946 w, h, label); 942 947 return TCL_OK; 943 948 } … … 1110 1115 } 1111 1116 1112 #ifndef notdef1113 1117 1114 1118 static int … … 1187 1191 } 1188 1192 1189 static Rappture::CmdSpec volumeAnimationOps[] = 1190 { 1191 {"capture", 2, VolumeAnimationCaptureOp, 4, 5, "numframes ?filename?",}, 1192 {"clear", 2, VolumeAnimationClearOp, 3, 3, "",}, 1193 {"start", 3, VolumeAnimationStartOp, 3, 3, "",}, 1194 {"stop", 3, VolumeAnimationStopOp, 3, 3, "",}, 1195 {"volumes", 1, VolumeAnimationVolumesOp, 3, 0, "?indices?",}, 1196 }; 1193 static Rappture::CmdSpec volumeAnimationOps[] = { 1194 {"capture", 2, VolumeAnimationCaptureOp, 4, 5, "numframes ?filename?",}, 1195 {"clear", 2, VolumeAnimationClearOp, 3, 3, "",}, 1196 {"start", 3, VolumeAnimationStartOp, 3, 3, "",}, 1197 {"stop", 3, VolumeAnimationStopOp, 3, 3, "",}, 1198 {"volumes", 1, VolumeAnimationVolumesOp, 3, 0, "?indices?",}, 1199 }; 1197 1200 1198 1201 static int nVolumeAnimationOps = NumCmdSpecs(volumeAnimationOps); … … 1347 1350 Volume *volPtr; 1348 1351 char info[1024]; 1349 float vmin, vmax;1352 AxisRange overall[4]; 1350 1353 1351 if (GetVolumeLimits(interp, &vmin, &vmax) != TCL_OK) {1354 if (GetVolumeLimits(interp, overall) != TCL_OK) { 1352 1355 return TCL_ERROR; 1353 1356 } 1354 1357 volPtr = NanoVis::volume[n]; 1358 const AxisRange *rangePtr; 1359 rangePtr = volPtr->GetRange(AxisRange::VALUES); 1355 1360 sprintf(info, "nv>data id %d min %g max %g vmin %g vmax %g\n", 1356 n, volPtr->range_min(), volPtr->range_max(),vmin, vmax); 1361 n, rangePtr->min, rangePtr->max, 1362 overall[AxisRange::VALUES].min, 1363 overall[AxisRange::VALUES].max); 1357 1364 write(0, info, strlen(info)); 1358 1365 } … … 1386 1393 } 1387 1394 1388 static Rappture::CmdSpec volumeDataOps[] = 1389 { 1390 {"follows", 1, VolumeDataFollowsOp, 4, 4, "size",}, 1391 {"state", 1, VolumeDataStateOp, 4, 0, "bool ?indices?",}, 1392 }; 1395 static Rappture::CmdSpec volumeDataOps[] = { 1396 {"follows", 1, VolumeDataFollowsOp, 4, 4, "size",}, 1397 {"state", 1, VolumeDataStateOp, 4, 0, "bool ?indices?",}, 1398 }; 1393 1399 static int nVolumeDataOps = NumCmdSpecs(volumeDataOps); 1394 1400 … … 1452 1458 } 1453 1459 1454 static int 1455 VolumeOutlineVisibleOp(ClientData cdata, Tcl_Interp *interp, int objc, 1456 Tcl_Obj *CONST *objv) 1457 { 1458 bool visible; 1459 if (GetBooleanFromObj(interp, objv[3], &visible) != TCL_OK) { 1460 return TCL_ERROR; 1461 } 1462 if (!visible) { 1463 for (int i = 0; i < NanoVis::n_volumes; ++i) { 1464 if (NanoVis::volume[i]) { 1465 NanoVis::volume[i]->disable_outline(); 1466 } 1467 } 1468 } else { 1469 for (int i = 0; i < NanoVis::n_volumes; ++i) { 1470 if (NanoVis::volume[i]) { 1471 NanoVis::volume[i]->enable_outline(); 1472 } 1473 } 1474 } 1475 return TCL_OK; 1476 } 1477 1478 static Rappture::CmdSpec volumeOutlineOps[] = 1479 { 1480 {"color", 1, VolumeOutlineColorOp, 6, 0, "r g b ?indices?",}, 1481 {"state", 1, VolumeOutlineStateOp, 4, 0, "bool ?indices?",}, 1482 {"visible", 1, VolumeOutlineVisibleOp, 4, 0, "bool ?indices?",}, 1483 }; 1460 1461 static Rappture::CmdSpec volumeOutlineOps[] = { 1462 {"color", 1, VolumeOutlineColorOp, 6, 0, "r g b ?indices?",}, 1463 {"state", 1, VolumeOutlineStateOp, 4, 0, "bool ?indices?",}, 1464 {"visible", 1, VolumeOutlineStateOp, 4, 0, "bool ?indices?",}, 1465 }; 1484 1466 static int nVolumeOutlineOps = NumCmdSpecs(volumeOutlineOps); 1485 1467 … … 1604 1586 } 1605 1587 1606 static Rappture::CmdSpec volumeShadingOps[] = 1607 { 1608 {"diffuse", 1, VolumeShadingDiffuseOp, 4, 0, "value ?indices?",}, 1609 {"isosurface", 1, VolumeShadingIsosurfaceOp, 4, 0, "bool ?indices?",}, 1610 {"opacity", 1, VolumeShadingOpacityOp, 4, 0, "value ?indices?",}, 1611 {"specular", 1, VolumeShadingSpecularOp, 4, 0, "value ?indices?",}, 1612 {"transfunc", 1, VolumeShadingTransFuncOp, 4, 0, "funcName ?indices?",}, 1613 }; 1588 static Rappture::CmdSpec volumeShadingOps[] = { 1589 {"diffuse", 1, VolumeShadingDiffuseOp, 4, 0, "value ?indices?",}, 1590 {"isosurface", 1, VolumeShadingIsosurfaceOp, 4, 0, "bool ?indices?",}, 1591 {"opacity", 1, VolumeShadingOpacityOp, 4, 0, "value ?indices?",}, 1592 {"specular", 1, VolumeShadingSpecularOp, 4, 0, "value ?indices?",}, 1593 {"transfunc", 1, VolumeShadingTransFuncOp, 4, 0, "funcName ?indices?",}, 1594 }; 1614 1595 static int nVolumeShadingOps = NumCmdSpecs(volumeShadingOps); 1615 1596 … … 1693 1674 } 1694 1675 1695 static Rappture::CmdSpec volumeOps[] = 1696 { 1697 {"animation", 2, VolumeAnimationOp, 3, 3, "oper ?args?",}, 1698 {"axis", 2, VolumeAxisOp, 3, 3, "label axis value ?indices?",}, 1699 {"data", 1, VolumeDataOp, 3, 3, "oper ?args?",}, 1700 {"outline", 1, VolumeOutlineOp, 3, 0, "oper ?args?",}, 1701 {"shading", 2, VolumeShadingOp, 3, 0, "oper ?args?",}, 1702 {"state", 2, VolumeStateOp, 3, 0, "bool ?indices?",}, 1703 {"test2", 1, VolumeTestOp, 2, 2, "",}, 1704 }; 1676 static Rappture::CmdSpec volumeOps[] = { 1677 {"animation", 2, VolumeAnimationOp, 3, 3, "oper ?args?",}, 1678 {"axis", 2, VolumeAxisOp, 3, 3, "label axis value ?indices?",}, 1679 {"data", 1, VolumeDataOp, 3, 3, "oper ?args?",}, 1680 {"outline", 1, VolumeOutlineOp, 3, 0, "oper ?args?",}, 1681 {"shading", 2, VolumeShadingOp, 3, 0, "oper ?args?",}, 1682 {"state", 2, VolumeStateOp, 3, 0, "bool ?indices?",}, 1683 {"test2", 1, VolumeTestOp, 2, 2, "",}, 1684 }; 1705 1685 static int nVolumeOps = NumCmdSpecs(volumeOps); 1706 1686 … … 1734 1714 } 1735 1715 1736 #else1737 1738 static int1739 VolumeCmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv)1740 {1741 if (objc < 2) {1742 Tcl_AppendResult(interp, "wrong # args: should be \"",1743 Tcl_GetString(objv[0]), " option arg arg...\"", (char*)NULL);1744 return TCL_ERROR;1745 }1746 1747 char *string = Tcl_GetString(objv[1]);1748 char c = string[0];1749 if ((c == 'a') && (strcmp(string, "axis") == 0)) {1750 if (objc < 3) {1751 Tcl_AppendResult(interp, "wrong # args: should be \"",1752 Tcl_GetString(objv[0]), " axis option ?arg arg...?\"",1753 (char*)NULL);1754 return TCL_ERROR;1755 }1756 char *string = Tcl_GetString(objv[2]);1757 c = string[0];1758 if ((c == 'l') && (strcmp(string, "label") == 0)) {1759 if (objc < 5) {1760 Tcl_AppendResult(interp, "wrong # args: should be \"",1761 Tcl_GetString(objv[0]),1762 " axis label x|y|z string ?volume ...?\"", (char*)NULL);1763 return TCL_ERROR;1764 }1765 int axis;1766 if (GetAxisFromObj(interp, objv[3], &axis) != TCL_OK) {1767 return TCL_ERROR;1768 }1769 vector<Volume *> ivol;1770 if (GetVolumes(interp, objc - 5, objv + 5, &ivol) != TCL_OK) {1771 return TCL_ERROR;1772 }1773 vector<Volume *>::iterator iter;1774 char *label;1775 label = Tcl_GetString(objv[4]);1776 for (iter = ivol.begin(); iter != ivol.end(); iter++) {1777 (*iter)->set_label(axis, label);1778 }1779 } else {1780 Tcl_AppendResult(interp, "bad option \"", string,1781 "\": should be label", (char*)NULL);1782 return TCL_ERROR;1783 }1784 } else if ((c == 'd') && (strcmp(string, "data") == 0)) {1785 if (objc < 3) {1786 Tcl_AppendResult(interp, "wrong # args: should be \"",1787 Tcl_GetString(objv[0]), " data option ?arg arg...?\"",1788 (char*)NULL);1789 return TCL_ERROR;1790 }1791 char *string = Tcl_GetString(objv[2]);1792 c = string[0];1793 if ((c == 's') && (strcmp(string, "state") == 0)) {1794 if (objc < 4) {1795 Tcl_AppendResult(interp, "wrong # args: should be \"",1796 Tcl_GetString(objv[0])," data state on|off ?volume...?\"",1797 (char*)NULL);1798 return TCL_ERROR;1799 }1800 bool state;1801 if (GetBooleanFromObj(interp, objv[3], &state) != TCL_OK) {1802 return TCL_ERROR;1803 }1804 vector<Volume *> ivol;1805 if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) {1806 return TCL_ERROR;1807 }1808 if (state) {1809 vector<Volume *>::iterator iter;1810 for (iter = ivol.begin(); iter != ivol.end(); iter++) {1811 (*iter)->enable_data();1812 }1813 } else {1814 vector<Volume *>::iterator iter;1815 for (iter = ivol.begin(); iter != ivol.end(); iter++) {1816 (*iter)->disable_data();1817 }1818 }1819 } else if (c == 'f' && strcmp(string, "follows") == 0) {1820 if (objc < 4) {1821 Tcl_AppendResult(interp, "wrong # args: should be \"",1822 Tcl_GetString(objv[0]), " data follows size", (char*)NULL);1823 return TCL_ERROR;1824 }1825 printf("Data Loading\n");1826 fflush(stdout);1827 1828 int nbytes;1829 if (Tcl_GetIntFromObj(interp, objv[3], &nbytes) != TCL_OK) {1830 return TCL_ERROR;1831 }1832 1833 Rappture::Buffer buf;1834 if (GetDataStream(interp, buf, nbytes) != TCL_OK) {1835 return TCL_ERROR;1836 }1837 int n = NanoVis::n_volumes;1838 char header[6];1839 memcpy(header, buf.bytes(), sizeof(char) * 5);1840 header[5] = '\0';1841 1842 #if _LOCAL_ZINC_TEST_1843 //FILE* fp = fopen("/home/nanohub/vrinside/nv/data/HOON/QDWL_100_100_50_strain_8000i.nd_zatom_12_1", "rb");1844 FILE* fp;1845 1846 fp = fopen("/home/nanohub/vrinside/nv/data/HOON/GaAs_AlGaAs_2QD_B4.nd_zc_1_wf", "rb");1847 if (fp == NULL) {1848 printf("cannot open the file\n");1849 fflush(stdout);1850 return TCL_ERROR;1851 }1852 unsigned char* b = (unsigned char*)malloc(buf.size());1853 fread(b, buf.size(), 1, fp);1854 fclose(fp);1855 #endif /*_LOCAL_ZINC_TEST_*/1856 printf("Checking header[%s]\n", header);1857 fflush(stdout);1858 if (strcmp(header, "<HDR>") == 0) {1859 Volume* vol = NULL;1860 1861 printf("ZincBlende stream is in\n");1862 fflush(stdout);1863 //std::stringstream fdata(std::ios_base::out|std::ios_base::in|std::ios_base::binary);1864 //fdata.write(buf.bytes(),buf.size());1865 //vol = NvZincBlendeReconstructor::getInstance()->loadFromStream(fdata);1866 1867 #if _LOCAL_ZINC_TEST_1868 vol = NvZincBlendeReconstructor::getInstance()->loadFromMemory(b);1869 #else1870 vol = NvZincBlendeReconstructor::getInstance()->loadFromMemory((void*) buf.bytes());1871 #endif /*_LOCAL_ZINC_TEST_*/1872 1873 printf("finish loading\n");1874 fflush(stdout);1875 if (vol) {1876 while (NanoVis::n_volumes <= n) {1877 NanoVis::volume.push_back((Volume*) NULL);1878 NanoVis::n_volumes++;1879 }1880 1881 if (NanoVis::volume[n] != NULL) {1882 delete NanoVis::volume[n];1883 NanoVis::volume[n] = NULL;1884 }1885 1886 float dx0 = -0.5;1887 float dy0 = -0.5*vol->height/vol->width;1888 float dz0 = -0.5*vol->depth/vol->width;1889 vol->move(Vector3(dx0, dy0, dz0));1890 1891 NanoVis::volume[n] = vol;1892 }1893 #if __TEST_CODE__1894 } else if (strcmp(header, "<FET>") == 0) {1895 printf("FET loading...\n");1896 fflush(stdout);1897 std::stringstream fdata;1898 fdata.write(buf.bytes(),buf.size());1899 err = load_volume_stream3(n, fdata);1900 1901 if (err) {1902 Tcl_AppendResult(interp, err.remark().c_str(), (char*)NULL);1903 return TCL_ERROR;1904 }1905 #endif /*__TEST_CODE__*/1906 } else if (strcmp(header, "<ODX>") == 0) {1907 Rappture::Outcome err;1908 1909 printf("Loading DX using OpenDX library...\n");1910 fflush(stdout);1911 //err = load_volume_stream_odx(n, buf.bytes()+5, buf.size()-5);1912 //err = load_volume_stream2(n, fdata);1913 if (err) {1914 Tcl_AppendResult(interp, err.remark().c_str(), (char*)NULL);1915 return TCL_ERROR;1916 }1917 } else {1918 Rappture::Outcome err;1919 1920 printf("OpenDX loading...\n");1921 fflush(stdout);1922 std::stringstream fdata;1923 fdata.write(buf.bytes(),buf.size());1924 1925 #if ISO_TEST1926 err = load_volume_stream2(n, fdata);1927 #else1928 err = load_volume_stream(n, fdata);1929 #endif1930 if (err) {1931 Tcl_AppendResult(interp, err.remark().c_str(), (char*)NULL);1932 return TCL_ERROR;1933 }1934 }1935 1936 //1937 // BE CAREFUL: Set the number of slices to something1938 // slightly different for each volume. If we have1939 // identical volumes at exactly the same position1940 // with exactly the same number of slices, the second1941 // volume will overwrite the first, so the first won't1942 // appear at all.1943 //1944 if (NanoVis::volume[n] != NULL) {1945 NanoVis::volume[n]->set_n_slice(256-n);1946 NanoVis::volume[n]->disable_cutplane(0);1947 NanoVis::volume[n]->disable_cutplane(1);1948 NanoVis::volume[n]->disable_cutplane(2);1949 1950 NanoVis::vol_renderer->add_volume(NanoVis::volume[n],NanoVis::get_transfunc("default"));1951 }1952 1953 {1954 Volume *volPtr;1955 char info[1024];1956 float vmin, vmax;1957 1958 if (GetVolumeLimits(interp, &vmin, &vmax) != TCL_OK) {1959 return TCL_ERROR;1960 }1961 volPtr = NanoVis::volume[n];1962 sprintf(info, "nv>data id %d min %g max %g vmin %g vmax %g\n",1963 n, volPtr->range_min(), volPtr->range_max(),vmin, vmax);1964 write(0, info, strlen(info));1965 }1966 } else {1967 Tcl_AppendResult(interp, "bad data option \"", string,1968 "\": should be follows or state", (char*)NULL);1969 return TCL_ERROR;1970 }1971 } else if (c == 'o' && strcmp(string, "outline") == 0) {1972 if (objc < 3) {1973 Tcl_AppendResult(interp, "wrong # args: should be \"",1974 Tcl_GetString(objv[0]), " outline option ?arg arg...?\"",1975 (char*)NULL);1976 return TCL_ERROR;1977 }1978 char *string = Tcl_GetString(objv[2]);1979 c = string[0];1980 if ((c == 's') && (strcmp(string, "state") == 0)) {1981 if (objc < 3) {1982 Tcl_AppendResult(interp, "wrong # args: should be \"",1983 Tcl_GetString(objv[0]),1984 " outline state on|off ?volume ...? \"", (char*)NULL);1985 return TCL_ERROR;1986 }1987 1988 bool state;1989 if (GetBooleanFromObj(interp, objv[3], &state) != TCL_OK) {1990 return TCL_ERROR;1991 }1992 vector<Volume *> ivol;1993 if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) {1994 return TCL_ERROR;1995 }1996 if (state) {1997 vector<Volume *>::iterator iter;1998 for (iter = ivol.begin(); iter != ivol.end(); iter++) {1999 (*iter)->enable_outline();2000 }2001 } else {2002 vector<Volume *>::iterator iter;2003 for (iter = ivol.begin(); iter != ivol.end(); iter++) {2004 (*iter)->disable_outline();2005 }2006 }2007 } else if ((c == 'v') && (strcmp(string, "visible") == 0)) {2008 bool visible;2009 2010 if (GetBooleanFromObj(interp, objv[3], &visible) != TCL_OK) {2011 return TCL_ERROR;2012 }2013 if (!visible) {2014 for (int i = 0; i < NanoVis::n_volumes; ++i) {2015 if (NanoVis::volume[i]) {2016 NanoVis::volume[i]->disable_outline();2017 }2018 }2019 } else {2020 for (int i = 0; i < NanoVis::n_volumes; ++i) {2021 if (NanoVis::volume[i]) {2022 NanoVis::volume[i]->enable_outline();2023 }2024 }2025 }2026 } else if ((c == 'c') && (strcmp(string, "color") == 0)) {2027 if (objc < 6) {2028 Tcl_AppendResult(interp, "wrong # args: should be \"",2029 Tcl_GetString(objv[0]),2030 " outline color R G B ?volume ...? \"", (char*)NULL);2031 return TCL_ERROR;2032 }2033 float rgb[3];2034 if (GetColor(interp, objc - 3, objv + 3, rgb) != TCL_OK) {2035 return TCL_ERROR;2036 }2037 vector<Volume *> ivol;2038 if (GetVolumes(interp, objc - 6, objv + 6, &ivol) != TCL_OK) {2039 return TCL_ERROR;2040 }2041 vector<Volume *>::iterator iter;2042 for (iter = ivol.begin(); iter != ivol.end(); iter++) {2043 (*iter)->set_outline_color(rgb);2044 }2045 }2046 else {2047 Tcl_AppendResult(interp, "bad outline option \"", string,2048 "\": should be color, visible, or state", (char*)NULL);2049 return TCL_ERROR;2050 }2051 } else if ((c == 's') && (strcmp(string, "shading") == 0)) {2052 if (objc < 3) {2053 Tcl_AppendResult(interp, "wrong # args: should be \"",2054 Tcl_GetString(objv[0]), " shading option ?arg arg...?\"",2055 (char*)NULL);2056 return TCL_ERROR;2057 }2058 char *string = Tcl_GetString(objv[2]);2059 c = string[0];2060 if ((c == 't') && (strcmp(string, "transfunc") == 0)) {2061 if (objc < 4) {2062 Tcl_AppendResult(interp, "wrong # args: should be \"",2063 Tcl_GetString(objv[0]),2064 " shading transfunc name ?volume ...?\"", (char*)NULL);2065 return TCL_ERROR;2066 }2067 TransferFunction *tf;2068 char *name = Tcl_GetString(objv[3]);2069 tf = NanoVis::get_transfunc(name);2070 if (tf == NULL) {2071 Tcl_AppendResult(interp, "transfer function \"", name,2072 "\" is not defined", (char*)NULL);2073 return TCL_ERROR;2074 }2075 vector<Volume *> ivol;2076 if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) {2077 return TCL_ERROR;2078 }2079 vector<Volume *>::iterator iter;2080 for (iter = ivol.begin(); iter != ivol.end(); iter++) {2081 NanoVis::vol_renderer->shade_volume(*iter, tf);2082 2083 // TBD..2084 // POINTSET2085 /*2086 if ((*iter)->pointsetIndex != -1) {2087 g_pointSet[(*iter)->pointsetIndex]->updateColor(tf->getData(), 256);2088 }2089 */2090 }2091 } else if ((c == 'd') && (strcmp(string, "diffuse") == 0)) {2092 if (objc < 4) {2093 Tcl_AppendResult(interp, "wrong # args: should be \"",2094 Tcl_GetString(objv[0]),2095 " shading diffuse value ?volume ...?\"", (char*)NULL);2096 return TCL_ERROR;2097 }2098 2099 float diffuse;2100 if (GetFloatFromObj(interp, objv[3], &diffuse) != TCL_OK) {2101 return TCL_ERROR;2102 }2103 vector<Volume *> ivol;2104 if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) {2105 return TCL_ERROR;2106 }2107 vector<Volume *>::iterator iter;2108 for (iter = ivol.begin(); iter != ivol.end(); iter++) {2109 (*iter)->set_diffuse(diffuse);2110 }2111 } else if ((c == 'o') && (strcmp(string, "opacity") == 0)) {2112 if (objc < 4) {2113 Tcl_AppendResult(interp, "wrong # args: should be \"",2114 Tcl_GetString(objv[0]),2115 " shading opacity value ?volume ...?\"", (char*)NULL);2116 return TCL_ERROR;2117 }2118 float opacity;2119 if (GetFloatFromObj(interp, objv[3], &opacity) != TCL_OK) {2120 return TCL_ERROR;2121 }2122 vector<Volume *> ivol;2123 if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) {2124 return TCL_ERROR;2125 }2126 vector<Volume *>::iterator iter;2127 for (iter = ivol.begin(); iter != ivol.end(); iter++) {2128 (*iter)->set_opacity_scale(opacity);2129 }2130 } else if ((c == 's') && (strcmp(string, "specular") == 0)) {2131 if (objc < 4) {2132 Tcl_AppendResult(interp, "wrong # args: should be \"",2133 Tcl_GetString(objv[0]),2134 " shading specular value ?volume ...?\"", (char*)NULL);2135 return TCL_ERROR;2136 }2137 float specular;2138 if (GetFloatFromObj(interp, objv[3], &specular) != TCL_OK) {2139 return TCL_ERROR;2140 }2141 vector<Volume *> ivol;2142 if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) {2143 return TCL_ERROR;2144 }2145 vector<Volume *>::iterator iter;2146 for (iter = ivol.begin(); iter != ivol.end(); iter++) {2147 (*iter)->set_specular(specular);2148 }2149 } else if ((c == 'i') && (strcmp(string, "isosurface") == 0)) {2150 if (objc < 4) {2151 Tcl_AppendResult(interp, "wrong # args: should be \"",2152 Tcl_GetString(objv[0]),2153 " shading isosurface on|off ?volume ...?\"", (char*)NULL);2154 return TCL_ERROR;2155 }2156 bool iso_surface;2157 if (GetBooleanFromObj(interp, objv[3], &iso_surface) != TCL_OK) {2158 return TCL_ERROR;2159 }2160 vector<Volume *> ivol;2161 if (GetVolumes(interp, objc - 4, objv + 4, &ivol) != TCL_OK) {2162 return TCL_ERROR;2163 }2164 vector<Volume *>::iterator iter;2165 for (iter = ivol.begin(); iter != ivol.end(); iter++) {2166 (*iter)->set_isosurface(iso_surface);2167 }2168 } else {2169 Tcl_AppendResult(interp, "bad shading option \"", string,2170 "\": should be diffuse, opacity, specular, transfunc, or ",2171 "isosurface", (char*)NULL);2172 return TCL_ERROR;2173 }2174 } else if ((c == 's') && (strcmp(string, "state") == 0)) {2175 if (objc < 3) {2176 Tcl_AppendResult(interp, "wrong # args: should be \"",2177 Tcl_GetString(objv[0]), " state on|off ?volume...?\"",2178 (char*)NULL);2179 return TCL_ERROR;2180 }2181 bool state;2182 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {2183 return TCL_ERROR;2184 }2185 vector<Volume *> ivol;2186 if (GetVolumes(interp, objc - 3, objv + 3, &ivol) != TCL_OK) {2187 return TCL_ERROR;2188 }2189 if (state) {2190 vector<Volume *>::iterator iter;2191 for (iter = ivol.begin(); iter != ivol.end(); iter++) {2192 (*iter)->enable();2193 }2194 } else {2195 vector<Volume *>::iterator iter;2196 for (iter = ivol.begin(); iter != ivol.end(); iter++) {2197 (*iter)->disable();2198 }2199 }2200 } else if (strcmp(string, "animation") == 0) {2201 if (objc < 3) {2202 Tcl_AppendResult(interp, "wrong # args: should be \"",2203 Tcl_GetString(objv[0]), " animation option ?args...?\"",2204 (char*)NULL);2205 return TCL_ERROR;2206 }2207 char *string = Tcl_GetString(objv[2]);2208 char c = string[0];2209 if ((c == 'v') && (strcmp(string,"volumes") == 0)) {2210 vector<unsigned int> ivol;2211 if (GetVolumeIndices(interp, objc - 3, objv + 3, &ivol) != TCL_OK) {2212 return TCL_ERROR;2213 }2214 Trace("parsing volume index\n");2215 vector<unsigned int>::iterator iter;2216 for (iter = ivol.begin(); iter != ivol.end(); iter++) {2217 Trace("index: %d\n", *iter);2218 NanoVis::vol_renderer->addAnimatedVolume(NanoVis::volume[*iter],2219 *iter);2220 }2221 } else if ((c == 'c') && (strcmp(string,"capture") == 0)) {2222 int total;2223 2224 if (Tcl_GetIntFromObj(interp, objv[3], &total) != TCL_OK) {2225 return TCL_ERROR;2226 }2227 VolumeInterpolator* interpolator;2228 interpolator = NanoVis::vol_renderer->getVolumeInterpolator();2229 interpolator->start();2230 if (interpolator->is_started()) {2231 char *fileName = (objc < 5) ? NULL : Tcl_GetString(objv[4]);2232 for (int frame_num = 0; frame_num < total; ++frame_num) {2233 float fraction;2234 2235 fraction = ((float)frame_num) / (total - 1);2236 Trace("fraction : %f\n", fraction);2237 //interpolator->update(((float)frame_num) / (total - 1));2238 interpolator->update(fraction);2239 2240 NanoVis::offscreen_buffer_capture(); //enable offscreen render2241 2242 NanoVis::display();2243 NanoVis::read_screen();2244 2245 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);2246 2247 NanoVis::bmp_write_to_file(frame_num, fileName);2248 }2249 }2250 } else if ((c == 's') && (strcmp(string, "start") == 0)) {2251 NanoVis::vol_renderer->startVolumeAnimation();2252 } else if ((c == 's') && (strcmp(string, "stop") == 0)) {2253 NanoVis::vol_renderer->stopVolumeAnimation();2254 } else if ((c == 'c') && (strcmp(string, "clear") == 0)) {2255 NanoVis::vol_renderer->clearAnimatedVolumeInfo();2256 } else {2257 Tcl_AppendResult(interp, "bad animation option \"", string,2258 "\": should be volumes, start, stop, or clear", (char*)NULL);2259 return TCL_ERROR;2260 }2261 } else if ((c == 't') && (strcmp(string, "test2") == 0)) {2262 NanoVis::volume[1]->disable_data();2263 NanoVis::volume[1]->disable();2264 } else {2265 Tcl_AppendResult(interp, "bad option \"", string, "\": should be ",2266 "data, outline, shading, or state", (char*)NULL);2267 return TCL_ERROR;2268 }2269 return TCL_OK;2270 }2271 #endif2272 2273 1716 static int 2274 1717 FlowCmd(ClientData cdata, Tcl_Interp *interp, int objc, Tcl_Obj *CONST *objv) … … 2290 1733 } 2291 1734 Volume *volPtr; 1735 const AxisRange *rangePtr; 2292 1736 2293 1737 if (GetVolumeFromObj(interp, objv[2], &volPtr) != TCL_OK) { 2294 1738 return TCL_ERROR; 2295 1739 } 1740 rangePtr = volPtr->GetRange(AxisRange::VALUES); 2296 1741 if (NanoVis::particleRenderer != NULL) { 2297 1742 NanoVis::particleRenderer->setVectorField(volPtr->id, 1.0f, 2298 2299 2300 volPtr->range_max());1743 volPtr->height / (float)volPtr->width, 1744 volPtr->depth / (float)volPtr->width, 1745 rangePtr->max); 2301 1746 NanoVis::initParticle(); 2302 1747 } 2303 1748 if (NanoVis::licRenderer != NULL) { 2304 1749 NanoVis::licRenderer->setVectorField(volPtr->id, 2305 2306 2307 2308 volPtr->range_max());1750 1.0f / volPtr->aspect_ratio_width, 1751 1.0f / volPtr->aspect_ratio_height, 1752 1.0f / volPtr->aspect_ratio_depth, 1753 rangePtr->max); 2309 1754 NanoVis::licRenderer->set_offset(NanoVis::lic_slice_z); 2310 1755 } … … 2541 1986 } 2542 1987 2543 static Rappture::CmdSpec heightMapDataOps[] = 2544 { 2545 {"follows", 1, HeightMapDataFollowsOp, 4, 4, "length",}, 2546 {"visible", 1, HeightMapDataVisibleOp, 4, 0, "bool ?indices?",}, 2547 }; 1988 static Rappture::CmdSpec heightMapDataOps[] = { 1989 {"follows", 1, HeightMapDataFollowsOp, 4, 4, "length",}, 1990 {"visible", 1, HeightMapDataVisibleOp, 4, 0, "bool ?indices?",}, 1991 }; 2548 1992 static int nHeightMapDataOps = NumCmdSpecs(heightMapDataOps); 2549 1993 … … 2605 2049 } 2606 2050 2607 static Rappture::CmdSpec heightMapLineContourOps[] = 2608 { 2609 {"color", 1, HeightMapLineContourColorOp, 4, 4, "length",}, 2610 {"visible", 1, HeightMapLineContourVisibleOp, 4, 0, "bool ?indices?",}, 2611 }; 2051 static Rappture::CmdSpec heightMapLineContourOps[] = { 2052 {"color", 1, HeightMapLineContourColorOp, 4, 4, "length",}, 2053 {"visible", 1, HeightMapLineContourVisibleOp, 4, 0, "bool ?indices?",}, 2054 }; 2612 2055 static int nHeightMapLineContourOps = NumCmdSpecs(heightMapLineContourOps); 2613 2056 … … 2674 2117 return TCL_ERROR; 2675 2118 } 2676 NanoVis::render_legend(tf, hMap->range_min(), hMap->range_max(), 2677 w, h, "label"); 2119 const AxisRange *rangePtr; 2120 rangePtr = hMap->GetRange(AxisRange::VALUES); 2121 NanoVis::render_legend(tf, rangePtr->min, rangePtr->max, w, h, "label"); 2678 2122 return TCL_OK; 2679 2123 } … … 2733 2177 2734 2178 2735 Vector3 min(minx, (float) heightMap->range_min(), miny); 2736 Vector3 max(maxx, (float) heightMap->range_max(), maxy); 2179 const AxisRange *rangePtr; 2180 rangePtr = heightMap->GetRange(AxisRange::VALUES); 2181 Vector3 min(minx, (float)rangePtr->min, miny); 2182 Vector3 max(maxx, (float)rangePtr->max, maxy); 2737 2183 2738 2184 NanoVis::grid->setMinMax(min, max); … … 2768 2214 } 2769 2215 2770 static Rappture::CmdSpec heightMapOps[] = 2771 { 2772 {"create", 2, HeightMapCreateOp, 9, 9, 2773 "xmin ymin xmax ymax xnum ynum values",}, 2774 {"cull", 2, HeightMapCullOp, 3, 3, "mode",}, 2775 {"data", 1, HeightMapDataOp, 3, 0, "oper ?args?",}, 2776 {"legend", 2, HeightMapLegendOp, 5, 5, "index width height",}, 2777 {"linecontour", 2, HeightMapLineContourOp, 2, 0, "oper ?args?",}, 2778 {"polygon", 1, HeightMapPolygonOp, 3, 3, "mode",}, 2779 {"shade", 1, HeightMapShadeOp, 3, 3, "model",}, 2780 {"test", 2, HeightMapTestOp, 2, 2, "",}, 2781 {"transfunc", 2, HeightMapTransFuncOp, 3, 0, "name ?indices?",}, 2782 }; 2216 static Rappture::CmdSpec heightMapOps[] = { 2217 {"create", 2, HeightMapCreateOp, 9, 9, 2218 "xmin ymin xmax ymax xnum ynum values",}, 2219 {"cull", 2, HeightMapCullOp, 3, 3, "mode",}, 2220 {"data", 1, HeightMapDataOp, 3, 0, "oper ?args?",}, 2221 {"legend", 2, HeightMapLegendOp, 5, 5, "index width height",}, 2222 {"linecontour", 2, HeightMapLineContourOp, 2, 0, "oper ?args?",}, 2223 {"polygon", 1, HeightMapPolygonOp, 3, 3, "mode",}, 2224 {"shade", 1, HeightMapShadeOp, 3, 3, "model",}, 2225 {"test", 2, HeightMapTestOp, 2, 2, "",}, 2226 {"transfunc", 2, HeightMapTransFuncOp, 3, 0, "name ?indices?",}, 2227 }; 2783 2228 static int nHeightMapOps = NumCmdSpecs(heightMapOps); 2784 2229 … … 2896 2341 } 2897 2342 2898 static Rappture::CmdSpec gridOps[] = 2899 { 2900 {"axiscolor", 5, GridAxisColorOp, 5, 6, "r g b ?a?",}, 2901 {"axisname", 5, GridAxisNameOp, 5, 5, "index width height",}, 2902 {"linecolor", 7, GridLineColorOp, 5, 6, "r g b ?a?",}, 2903 {"linecount", 7, GridLineCountOp, 5, 5, "xCount yCount zCount",}, 2904 {"minmax", 1, GridMinMaxOp, 8, 8, "xMin yMin zMin xMax yMax zMax",}, 2905 {"visible", 1, GridVisibleOp, 3, 3, "bool",}, 2906 }; 2343 static Rappture::CmdSpec gridOps[] = { 2344 {"axiscolor", 5, GridAxisColorOp, 5, 6, "r g b ?a?",}, 2345 {"axisname", 5, GridAxisNameOp, 5, 5, "index width height",}, 2346 {"linecolor", 7, GridLineColorOp, 5, 6, "r g b ?a?",}, 2347 {"linecount", 7, GridLineCountOp, 5, 5, "xCount yCount zCount",}, 2348 {"minmax", 1, GridMinMaxOp, 8, 8, "xMin yMin zMin xMax yMax zMax",}, 2349 {"visible", 1, GridVisibleOp, 3, 3, "bool",}, 2350 }; 2907 2351 static int nGridOps = NumCmdSpecs(gridOps); 2908 2352 … … 3035 2479 } 3036 2480 3037 static Rappture::CmdSpec planeOps[] = 3038 { 3039 {"enable", 1, PlaneEnableOp, 4, 4, "planeIdx mode",}, 3040 {"link", 1, PlaneLinkOp, 4, 4, "planeIdx transfuncIdx",}, 3041 {"new", 1, PlaneNewOp, 5, 5, "planeIdx width height",}, 3042 }; 2481 static Rappture::CmdSpec planeOps[] = { 2482 {"enable", 1, PlaneEnableOp, 4, 4, "planeIdx mode",}, 2483 {"link", 1, PlaneLinkOp, 4, 4, "planeIdx transfuncIdx",}, 2484 {"new", 1, PlaneNewOp, 5, 5, "planeIdx width height",}, 2485 }; 3043 2486 static int nPlaneOps = NumCmdSpecs(planeOps); 3044 2487 -
trunk/vizservers/nanovis/Grid.cpp
r922 r929 3 3 #include "Grid.h" 4 4 5 Grid::Grid() 6 : _axisColor(1.0f, 1.0f, 1.0f, 1.0f), _font(0), _axisGridLineCount(5.0f, 5.0f, 5.0f), 7 _axisMin(0.0f, 0.0f, 0.0f), _axisMax(1.0f, 1.0f, 1.0f), _gridLineColor(1.0f, 1.0f, 1.0f, 1.0f), _visible(false) 5 Grid::Grid() : 6 _axisColor(1.0f, 1.0f, 1.0f, 1.0f), 7 _gridLineColor(1.0f, 1.0f, 1.0f, 1.0f), 8 _axisMin(0.0f, 0.0f, 0.0f), 9 _axisMax(1.0f, 1.0f, 1.0f), 10 _axisGridLineCount(5.0f, 5.0f, 5.0f), 11 _font(0), 12 _visible(false) 8 13 { 9 14 __axisScale = _axisMax - _axisMin; … … 42 47 glBegin(GL_LINES); 43 48 44 float linecount = 2.0f;45 float linecountY = 4.0f;46 49 // +y 47 50 for (int i = 1; i <= (int) _axisGridLineCount.y; ++i) { … … 77 80 78 81 if (_font) { 79 double x = 1.0f, y = 0.0f, z = 0.0f;80 82 double mv[16], prjm[16]; 81 83 int viewport[4]; -
trunk/vizservers/nanovis/Grid.h
r862 r929 11 11 Vector4 _axisColor; 12 12 Vector4 _gridLineColor; 13 Vector3 _axisMin; 13 14 Vector3 _axisMax; 14 Vector3 _axisMin;15 15 Vector3 _axisGridLineCount; 16 16 R2Fonts* _font; 17 bool _showGrid;18 17 bool _visible; 19 18 -
trunk/vizservers/nanovis/HeightMap.cpp
r927 r929 28 28 _visible(false), 29 29 _scale(1.0f, 1.0f, 1.0f), 30 _centerPoint(0.0f, 0.0f, 0.0f), 31 _vmin(0.0f), 32 _vmax(0.0f) 30 _centerPoint(0.0f, 0.0f, 0.0f) 33 31 { 34 32 _shader = new NvShader(); … … 214 212 reset(); 215 213 216 _vmin = heights[0].y, _vmax = heights[0].y; 214 float min, max; 215 min = heights[0].y, max = heights[0].y; 216 217 217 int count = xCount * yCount; 218 218 for (int i = 0; i < count; ++i) { 219 if ( _vmin > heights[i].y) {220 _vmin = heights[i].y;219 if (min > heights[i].y) { 220 min = heights[i].y; 221 221 } 222 if ( _vmax < heights[i].y) {223 _vmax = heights[i].y;222 if (max < heights[i].y) { 223 max = heights[i].y; 224 224 } 225 225 } 226 226 227 227 _scale.x = 1.0f; 228 _scale.z = _vmax - _vmin;228 _scale.z = max - min; 229 229 _scale.y = 1.0f; 230 set_limits(0, 0.0, 1.0); 231 set_limits(1, 0.0, 1.0); 232 set_limits(2, _vmin, _vmax); 233 234 _centerPoint.set(_scale.x * 0.5, _scale.z * 0.5 + _vmin, _scale.y * 0.5); 230 231 SetRange(AxisRange::VALUES, min, max); 232 SetRange(AxisRange::X, 0.0, 1.0); 233 SetRange(AxisRange::Y, 0.0, 1.0); 234 SetRange(AxisRange::Z, min, max); 235 236 _centerPoint.set(_scale.x * 0.5, _scale.z * 0.5 + min, _scale.y * 0.5); 235 237 236 238 Vector3* texcoord = new Vector3[count]; … … 278 280 reset(); 279 281 280 _vmin = heights[0], _vmax = heights[0]; 282 float min, max; 283 min = heights[0], max = heights[0]; 281 284 int count = xCount * yCount; 282 285 for (int i = 0; i < count; ++i) { 283 if ( _vmin > heights[i]) {284 _vmin = heights[i];285 } else if ( _vmax < heights[i]) {286 _vmax = heights[i];286 if (min > heights[i]) { 287 min = heights[i]; 288 } else if (max < heights[i]) { 289 max = heights[i]; 287 290 } 288 291 } 289 292 _scale.x = endX - startX; 290 _scale.y = _vmax - _vmin;293 _scale.y = max - min; 291 294 _scale.z = endY - startY; 292 set_limits(0, startX, endX); 293 set_limits(1, startY, endY); 294 set_limits(2, _vmin, _vmax); 295 296 _centerPoint.set(_scale.x * 0.5 + startX, _scale.y * 0.5 + _vmin, _scale.z * 0.5 + startY); 295 296 SetRange(AxisRange::VALUES, min, max); 297 SetRange(AxisRange::X, startX, endX); 298 SetRange(AxisRange::Y, min, max); 299 SetRange(AxisRange::Z, startY, endY); 300 301 _centerPoint.set(_scale.x * 0.5 + startX, _scale.y * 0.5 + min, 302 _scale.z * 0.5 + startY); 297 303 298 304 Vector3* texcoord = new Vector3[count]; -
trunk/vizservers/nanovis/HeightMap.h
r927 r929 9 9 #include "Vector3.h" 10 10 #include <RenderContext.h> 11 #include "AxisRange.h" 11 12 12 13 namespace graphics { … … 37 38 Vector3 _centerPoint; 38 39 39 double _limits[3][2]; 40 double _vmin, _vmax; 40 AxisRange _ranges[4]; 41 41 public : 42 42 /** … … 77 77 *@brief Define a color map for color shading of heightmap 78 78 */ 79 79 void setColorMap(TransferFunction* colorMap); 80 80 81 81 /** 82 82 *@brief Get the color map defined for shading of this heightmap 83 83 */ 84 TransferFunction *getColorMap(void); 85 84 TransferFunction *getColorMap(void) { 85 return _colorMap; 86 } 86 87 /** 87 88 *@brief Set the visibility of the height map 88 89 */ 89 void setVisible(bool visible); 90 void setVisible(bool visible) { 91 _visible = visible; 92 } 90 93 91 94 /** 92 95 *@brief Return the status of the visibility 93 96 */ 94 bool isVisible() const; 95 97 bool isVisible() const { 98 return _visible; 99 } 96 100 /** 97 101 *@brief Set the visibility of the line contour 98 102 */ 99 void setLineContourVisible(bool visible); 103 void setLineContourVisible(bool visible) { 104 _contourVisible = visible; 105 } 100 106 101 107 /** 102 108 *@brief Defind the color of the line contour 103 109 */ 104 void setLineContourColor(float *rgb); 110 void setLineContourColor(float *rgb) { 111 _contourColor.x = rgb[0]; 112 _contourColor.y = rgb[1]; 113 _contourColor.z = rgb[2]; 114 } 105 115 106 double range_min(void); 107 double range_max(void); 108 void set_limits(int axis, double min, double max); 109 void get_limits(int axis, double *minPtr, double *maxPtr); 116 void SetRange(int axis, double min, double max) { 117 _ranges[axis].min = min; 118 _ranges[axis].max = max; 119 } 120 const AxisRange *GetRange(int axis) { 121 return _ranges + axis; 122 } 110 123 }; 111 124 112 inline void HeightMap::setVisible(bool visible)113 {114 _visible = visible;115 }116 117 inline bool HeightMap::isVisible() const118 {119 return _visible;120 }121 122 inline void HeightMap::setLineContourVisible(bool visible)123 {124 _contourVisible = visible;125 }126 127 inline void HeightMap::setLineContourColor(float rgb[])128 {129 _contourColor.x = rgb[0];130 _contourColor.y = rgb[1];131 _contourColor.z = rgb[2];132 }133 134 inline TransferFunction *135 HeightMap::getColorMap()136 {137 return _colorMap;138 }139 140 inline void141 HeightMap::set_limits(int axis, double min, double max)142 {143 _limits[axis][0] = min;144 _limits[axis][1] = max;145 }146 147 inline void148 HeightMap::get_limits(int axis, double *minPtr, double *maxPtr)149 {150 *minPtr = _limits[axis][0];151 *maxPtr = _limits[axis][1];152 }153 154 inline double155 HeightMap::range_min()156 {157 return _vmin;158 }159 160 inline double161 HeightMap::range_max()162 {163 return _vmax;164 }165 125 #endif -
trunk/vizservers/nanovis/R2/include/R2/graphics/R2Geometry.h
r776 r929 1 1 2 #ifndef _R2_GEOMETRY_H_ 2 3 #define _R2_GEOMETRY_H_ … … 8 9 class R2Geometry { 9 10 public : 10 11 12 13 14 15 16 11 enum { 12 LINES = GL_LINES, 13 LINE_STRIP = GL_LINE_STRIP, 14 TRIANGLES = GL_TRIANGLES, 15 TRIANGLE_STRIP = GL_TRIANGLE_STRIP, 16 QUADS = GL_QUADS, 17 }; 17 18 18 19 private : 19 20 21 22 20 R2VertexBuffer* _vertexBuffer; 21 R2VertexBuffer* _colorBuffer; 22 R2IndexBuffer* _indexBuffer; 23 int _primitiveType; 23 24 24 25 public : 25 R2Geometry(int primitive, R2VertexBuffer* vertexBuffer, R2IndexBuffer* indexBuffer); 26 R2Geometry(int primitive, R2VertexBuffer* pointBuffer, R2VertexBuffer* colorBuffer, R2IndexBuffer* indexBuffer); 27 ~R2Geometry(); 28 26 R2Geometry(int primitive, R2VertexBuffer* vertexBuffer, 27 R2IndexBuffer* indexBuffer); 28 R2Geometry(int primitive, R2VertexBuffer* pointBuffer, 29 R2VertexBuffer* colorBuffer, R2IndexBuffer* indexBuffer); 30 ~R2Geometry(); 31 29 32 public : 30 33 void render(); 31 34 }; 32 35 33 #endif / /36 #endif /*_R2_GEOMETRY_H_*/ -
trunk/vizservers/nanovis/R2/src/R2Fonts.cpp
r835 r929 13 13 R2Fonts::~R2Fonts() 14 14 { 15 for ( R2int32index = 0; index < _fonts.size(); ++index) {15 for (unsigned index = 0; index < _fonts.size(); ++index) { 16 16 glDeleteLists(_fonts[index]._displayLists, 256); 17 17 glDeleteTextures(1, &(_fonts[_fontIndex]. _fontTextureID)); … … 22 22 R2Fonts::setFont(const char* fontName) 23 23 { 24 for ( R2int32index = 0; index < _fonts.size(); ++index) {24 for (unsigned index = 0; index < _fonts.size(); ++index) { 25 25 if (_fonts[index]._fontName == fontName) { 26 26 _fontIndex = index; … … 138 138 unsigned int uiFileId = 0; 139 139 fsInput.read(reinterpret_cast<char*>(&uiFileId), sizeof(unsigned int)); 140 if (uiFileId == c_nFileMagicHeader) {140 if (uiFileId == (unsigned int)c_nFileMagicHeader) { 141 141 // read general font/texture dimensions 142 142 unsigned int uiTextureWidth, uiTextureHeight, uiFontHeight; -
trunk/vizservers/nanovis/R2/src/R2Geometry.cpp
r780 r929 1 1 2 #include <GL/glew.h> 2 3 #include <GL/gl.h> 3 4 #include <R2/graphics/R2Geometry.h> 4 5 5 R2Geometry::R2Geometry(int primitive, R2VertexBuffer* vertexBuffer, R2IndexBuffer* indexBuffer) 6 : _primitiveType(primitive), _vertexBuffer(vertexBuffer), _indexBuffer(indexBuffer), _colorBuffer(0) 6 R2Geometry::R2Geometry(int primitive, R2VertexBuffer* vertexBuffer, 7 R2IndexBuffer* indexBuffer) : 8 _vertexBuffer(vertexBuffer), 9 _colorBuffer(0), 10 _indexBuffer(indexBuffer), 11 _primitiveType(primitive) 7 12 { 8 13 } 9 14 10 R2Geometry::R2Geometry(int primitive, R2VertexBuffer* vertexBuffer, R2VertexBuffer* colorBuffer, R2IndexBuffer* indexBuffer) 11 : _primitiveType(primitive), _vertexBuffer(vertexBuffer), _indexBuffer(indexBuffer), _colorBuffer(colorBuffer) 15 R2Geometry::R2Geometry(int primitive, R2VertexBuffer* vertexBuffer, 16 R2VertexBuffer* colorBuffer, R2IndexBuffer* indexBuffer) : 17 _vertexBuffer(vertexBuffer), 18 _colorBuffer(colorBuffer), 19 _indexBuffer(indexBuffer), 20 _primitiveType(primitive) 12 21 { 13 22 } … … 18 27 } 19 28 20 void R2Geometry::render() 29 void 30 R2Geometry::render() 21 31 { 22 //glDisableClientState(GL_NORMAL_ARRAY); 23 //glDisableClientState(GL_TEXTURE_COORD_ARRAY); 24 glEnableClientState(GL_VERTEX_ARRAY); 25 glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer->getGraphicObjectID()); 26 glVertexPointer(3, GL_FLOAT, 0, 0); 27 28 if (_colorBuffer) 29 { 30 glEnableClientState(GL_COLOR_ARRAY); 31 glBindBuffer(GL_ARRAY_BUFFER, _colorBuffer->getGraphicObjectID()); 32 glColorPointer(3, GL_FLOAT, 0, 0); 33 } 34 else 35 { 36 glDisableClientState(GL_COLOR_ARRAY); 32 //glDisableClientState(GL_NORMAL_ARRAY); 33 //glDisableClientState(GL_TEXTURE_COORD_ARRAY); 34 glEnableClientState(GL_VERTEX_ARRAY); 35 glBindBuffer(GL_ARRAY_BUFFER, _vertexBuffer->getGraphicObjectID()); 36 glVertexPointer(3, GL_FLOAT, 0, 0); 37 38 if (_colorBuffer) { 39 glEnableClientState(GL_COLOR_ARRAY); 40 glBindBuffer(GL_ARRAY_BUFFER, _colorBuffer->getGraphicObjectID()); 41 glColorPointer(3, GL_FLOAT, 0, 0); 42 } else { 43 glDisableClientState(GL_COLOR_ARRAY); 37 44 } 38 39 40 if (_indexBuffer) 41 { 42 glDrawElements(GL_QUADS, _indexBuffer->getIndexCount(), GL_UNSIGNED_INT,_indexBuffer->getData());43 } 44 else 45 { 46 glBindBuffer(GL_ARRAY_BUFFER, 0); 47 glDrawArrays(_primitiveType, 0, _vertexBuffer->getVertexCount()); 48 } 49 50 glDisableClientState(GL_VERTEX_ARRAY);51 if (_colorBuffer) glDisableClientState(GL_COLOR_ARRAY); 45 glBindBuffer(GL_ARRAY_BUFFER, 0); 46 47 if (_indexBuffer) { 48 glDrawElements(GL_QUADS, _indexBuffer->getIndexCount(), GL_UNSIGNED_INT, 49 _indexBuffer->getData()); 50 } else { 51 glBindBuffer(GL_ARRAY_BUFFER, 0); 52 glDrawArrays(_primitiveType, 0, _vertexBuffer->getVertexCount()); 53 } 54 55 glDisableClientState(GL_VERTEX_ARRAY); 56 if (_colorBuffer) { 57 glDisableClientState(GL_COLOR_ARRAY); 58 } 52 59 } -
trunk/vizservers/nanovis/Volume.cpp
r900 r929 27 27 size(s), 28 28 n_components(n), 29 vmin(v0),30 vmax(v1),31 29 nonzero_min(nz_min), 32 30 pointsetIndex(-1), … … 63 61 id = tex->id; 64 62 63 SetRange(AxisRange::VALUES, v0, v1); 64 65 65 aspect_ratio_width = s*tex->aspect_ratio_width; 66 66 aspect_ratio_height = s*tex->aspect_ratio_height; -
trunk/vizservers/nanovis/Volume.h
r927 r929 24 24 #include "Texture3D.h" 25 25 #include "Vector3.h" 26 #include "AxisRange.h" 26 27 27 28 struct CutPlane{ … … 57 58 int n_components; 58 59 59 double _limits[3][2]; // min/max for each axis 60 61 double vmin; // minimum (unscaled) value in data 62 double vmax; // maximum (unscaled) value in data 60 AxisRange _ranges[4]; // min/max for each axis 61 63 62 double nonzero_min; 64 63 … … 118 117 int get_isosurface() const; 119 118 120 double range_min() { return vmin; }121 double range_max() { return vmax; }122 119 double range_nzero_min() { return nonzero_min; } 123 120 … … 155 152 void get_outline_color(float* rgb); 156 153 157 void set_limits(int axis, double min, double max);158 void get_limits(int axis, double *minPtr, double *maxPtr);154 void SetRange(int axis, double min, double max); 155 const AxisRange *GetRange(int axis); 159 156 void set_label(int axis, const char* txt); // change the label displayed 160 157 // on an axis … … 335 332 336 333 inline void 337 Volume::set_limits(int axis, double min, double max) 338 { 339 _limits[axis][0] = min; 340 _limits[axis][1] = max; 341 } 342 343 inline void 344 Volume::get_limits(int axis, double *minPtr, double *maxPtr) 345 { 346 *minPtr = _limits[axis][0]; 347 *maxPtr = _limits[axis][1]; 334 Volume::SetRange(int axis, double min, double max) 335 { 336 _ranges[axis].min = min; 337 _ranges[axis].max = max; 338 } 339 340 inline const AxisRange * 341 Volume::GetRange(int axis) 342 { 343 return _ranges + axis; 348 344 } 349 345 -
trunk/vizservers/nanovis/VolumeInterpolator.cpp
r927 r929 146 146 volume->n_components, 147 147 volume->_data, 148 volume->vmin, 149 volume->vmax, volume->nonzero_min); 148 volume->_ranges[AxisRange::VALUES].min, 149 volume->_ranges[AxisRange::VALUES].max, 150 volume->nonzero_min); 150 151 _referenceOfVolume = volumeId; 151 152 _volume->set_n_slice(256-1); -
trunk/vizservers/nanovis/dxReader.cpp
r928 r929 237 237 volPtr = NanoVis::load_volume(index, nx, ny, nz, 3, data, vmin, vmax, 238 238 nzero_min); 239 volPtr-> set_limits(NanoVis::X, x0, x0 + (nx * ddx));240 volPtr-> set_limits(NanoVis::Y, y0, y0 + (ny * ddy));241 volPtr-> set_limits(NanoVis::Z, z0, z0 + (nz * ddz));239 volPtr->SetRange(AxisRange::X, x0, x0 + (nx * ddx)); 240 volPtr->SetRange(AxisRange::Y, y0, y0 + (ny * ddy)); 241 volPtr->SetRange(AxisRange::Z, z0, z0 + (nz * ddz)); 242 242 delete [] data; 243 243 } else { … … 488 488 volPtr = NanoVis::load_volume(index, nx, ny, nz, 4, data, 489 489 vmin, vmax, nzero_min); 490 volPtr-> set_limits(NanoVis::X, x0, x0 + (nx * ddx));491 volPtr-> set_limits(NanoVis::Y, y0, y0 + (ny * ddy));492 volPtr-> set_limits(NanoVis::Z, z0, z0 + (nz * ddz));490 volPtr->SetRange(AxisRange::X, x0, x0 + (nx * ddx)); 491 volPtr->SetRange(AxisRange::Y, y0, y0 + (ny * ddy)); 492 volPtr->SetRange(AxisRange::Z, z0, z0 + (nz * ddz)); 493 493 delete [] data; 494 494 … … 621 621 volPtr = NanoVis::load_volume(index, nx, ny, nz, 4, data, 622 622 field.valueMin(), field.valueMax(), nzero_min); 623 volPtr-> set_limits(NanoVis::X, field.rangeMin(Rappture::xaxis),623 volPtr->SetRange(AxisRange::X, field.rangeMin(Rappture::xaxis), 624 624 field.rangeMax(Rappture::xaxis)); 625 volPtr-> set_limits(NanoVis::Y, field.rangeMin(Rappture::yaxis),625 volPtr->SetRange(AxisRange::Y, field.rangeMin(Rappture::yaxis), 626 626 field.rangeMax(Rappture::yaxis)); 627 volPtr-> set_limits(NanoVis::Z, field.rangeMin(Rappture::zaxis),627 volPtr->SetRange(AxisRange::Z, field.rangeMin(Rappture::zaxis), 628 628 field.rangeMax(Rappture::zaxis)); 629 629 delete [] data; … … 917 917 volPtr = NanoVis::load_volume(index, nx, ny, nz, 4, data, 918 918 field.valueMin(), field.valueMax(), nzero_min); 919 volPtr-> set_limits(NanoVis::X, field.rangeMin(Rappture::xaxis),919 volPtr->SetRange(AxisRange::X, field.rangeMin(Rappture::xaxis), 920 920 field.rangeMax(Rappture::xaxis)); 921 volPtr-> set_limits(NanoVis::Y, field.rangeMin(Rappture::yaxis),921 volPtr->SetRange(AxisRange::Y, field.rangeMin(Rappture::yaxis), 922 922 field.rangeMax(Rappture::yaxis)); 923 volPtr-> set_limits(NanoVis::Z, field.rangeMin(Rappture::zaxis),923 volPtr->SetRange(AxisRange::Z, field.rangeMin(Rappture::zaxis), 924 924 field.rangeMax(Rappture::zaxis)); 925 925 // TBD.. … … 1063 1063 volPtr = NanoVis::load_volume(index, nx, ny, nz, 4, data, 1064 1064 field.valueMin(), field.valueMax(), nzero_min); 1065 volPtr-> set_limits(NanoVis::X, field.rangeMin(Rappture::xaxis),1065 volPtr->SetRange(AxisRange::X, field.rangeMin(Rappture::xaxis), 1066 1066 field.rangeMax(Rappture::xaxis)); 1067 volPtr-> set_limits(NanoVis::Y, field.rangeMin(Rappture::yaxis),1067 volPtr->SetRange(AxisRange::Y, field.rangeMin(Rappture::yaxis), 1068 1068 field.rangeMax(Rappture::yaxis)); 1069 volPtr-> set_limits(NanoVis::Z, field.rangeMin(Rappture::zaxis),1069 volPtr->SetRange(AxisRange::Z, field.rangeMin(Rappture::zaxis), 1070 1070 field.rangeMax(Rappture::zaxis)); 1071 1071 -
trunk/vizservers/nanovis/imgLoaders/BMPImageLoaderImpl.cpp
r823 r929 13 13 } 14 14 15 // I referred to cjbackhouse@hotmail.com 15 // I referred to cjbackhouse@hotmail.com www.backhouse.tk 16 16 Image* BMPImageLoaderImpl::load(const char* fileName) 17 17 { … … 30 30 fread(&header, 54, 1, f); 31 31 32 if (header[0] != 'B' || header[1] != 'M') 33 { 34 printf("File is not BMP format\n"); 35 return 0; 32 if (header[0] != 'B' || header[1] != 'M') { 33 printf("File is not BMP format\n"); 34 return 0; 36 35 } 37 36 38 //it seems gimp sometimes makes its headers small, so we have to do this. hence all the fseeks 39 int offset=*(unsigned int*)(header+10); 40 41 const unsigned int width =*(int*) (header+18); 42 const unsigned int height =*(int*) (header+22); 37 //it seems gimp sometimes makes its headers small, so we have to do 38 //this. hence all the fseeks 39 int offset=*(unsigned int*)(header+10); 40 41 const unsigned int width =*(int*) (header+18); 42 const unsigned int height =*(int*) (header+22); 43 43 44 int bits=int(header[28]);//colourdepth44 int bits=int(header[28]); //colourdepth 45 45 46 46 printf("image width = %d height = %d bits=%d\n", width, height, bits); 47 47 fflush(stdout); 48 48 49 image = new Image(width, height, _targetImageFormat, Image::IMG_UNSIGNED_BYTE, 0); 49 image = new Image(width, height, _targetImageFormat, 50 Image::IMG_UNSIGNED_BYTE, 0); 50 51 51 52 printf("image created\n"); … … 58 59 fflush(stdout); 59 60 60 int x,y,c; 61 unsigned char cols[256*4]; //colourtable 62 switch(bits) 63 { 64 case(24): 65 fseek(f,offset,SEEK_SET); 66 if (_targetImageFormat == Image::IMG_RGB) 67 { 68 fread(bytes,width*height*3,1,f); //24bit is easy 69 for(x=0;x<width*height*3;x+=3) //except the format is BGR, grr 70 { 71 unsigned char temp = bytes[x]; 72 bytes[x] = bytes[x+2]; 73 bytes[x+2] = temp; 74 } 75 } 76 else if (_targetImageFormat == Image::IMG_RGBA) 77 { 78 char* buff = (char*) malloc(width * height * sizeof(unsigned char) * 3); 79 fread(buff,width*height*3,1,f); //24bit is easy 80 for(x=0, y = 0;x<width*height*3;x+=3, y+=4) //except the format is BGR, grr 81 { 82 bytes[y] = buff[x+2]; 83 bytes[y+2] = buff[x]; 84 bytes[y+3] = 255; 85 } 86 free(buff); 87 } 88 break; 89 case(8): 90 fread(cols,256 * 4,1,f); //read colortable 91 fseek(f,offset,SEEK_SET); 92 for(y=0;y<height;++y) //(Notice 4bytes/col for some reason) 93 { 94 for(x=0;x<width;++x) 95 { 96 unsigned char byte; 97 fread(&byte,1,1,f); //just read byte 98 for(int c=0; c< 3; ++c) 99 { 100 //bytes[(y*width+x)*3+c] = cols[byte*4+2-c]; //and look up in the table 101 bytes[(y*width+x)*_targetImageFormat + c] = cols[byte*4+2-c]; //and look up in the table 102 } 103 } 104 } 105 break; 106 /* 107 case(4): 108 fread(cols,16*4,1,f); 109 fseek(f,offset,SEEK_SET); 110 for(y=0;y<256;++y) 111 for(x=0;x<256;x+=2) 112 { 113 BYTE byte; 114 fread(&byte,1,1,f); //as above, but need to exract two 61 unsigned int x,y; 62 unsigned char cols[256*4]; //colourtable 63 switch(bits) { 64 case 24: 65 fseek(f,offset,SEEK_SET); 66 if (_targetImageFormat == Image::IMG_RGB) { 67 fread(bytes,width*height*3,1,f); //24bit is easy 68 for(x=0;x<width*height*3;x+=3) { //except the format is BGR, grr 69 unsigned char temp = bytes[x]; 70 bytes[x] = bytes[x+2]; 71 bytes[x+2] = temp; 72 } 73 } else if (_targetImageFormat == Image::IMG_RGBA) { 74 char* buff = (char*) malloc(width * height * sizeof(unsigned char) * 3); 75 fread(buff,width*height*3,1,f); //24bit is easy 76 for(x=0, y = 0;x<width*height*3;x+=3, y+=4) { //except the format is BGR, grr 77 bytes[y] = buff[x+2]; 78 bytes[y+2] = buff[x]; 79 bytes[y+3] = 255; 80 } 81 free(buff); 82 } 83 break; 84 case 8: 85 fread(cols,256 * 4,1,f); //read colortable 86 fseek(f,offset,SEEK_SET); 87 for(y=0;y<height;++y) { //(Notice 4bytes/col for some reason) 88 for(x=0;x<width;++x) { 89 unsigned char byte; 90 fread(&byte,1,1,f); //just read byte 91 for(int c=0; c< 3; ++c) { 92 //bytes[(y*width+x)*3+c] = cols[byte*4+2-c]; //and look up in the table 93 bytes[(y*width+x)*_targetImageFormat + c] = cols[byte*4+2-c]; //and look up in the table 94 } 95 } 96 } 97 break; 98 /* 99 case(4): 100 fread(cols,16*4,1,f); 101 fseek(f,offset,SEEK_SET); 102 for(y=0;y<256;++y) 103 for(x=0;x<256;x+=2) 104 { 105 BYTE byte; 106 fread(&byte,1,1,f); //as above, but need to exract two 107 108 for(c=0;c<_targetImageFormat;++c) //pixels from each byte 109 bmp.pixel(x,y,c)=cols[byte/16*4+2-c]; 115 110 116 for(c=0;c<_targetImageFormat;++c) //pixels from each byte 117 bmp.pixel(x,y,c)=cols[byte/16*4+2-c]; 118 119 for(c=0;c<_targetImageFormat;++c) 120 bmp.pixel(x+1,y,c)=cols[byte%16*4+2-c]; 121 */ 111 for(c=0;c<_targetImageFormat;++c) 112 bmp.pixel(x+1,y,c)=cols[byte%16*4+2-c]; 113 */ 122 114 } 123 115 124 116 printf("image initialized\n"); 125 117 fflush(stdout); -
trunk/vizservers/nanovis/imgLoaders/Image.cpp
r823 r929 3 3 #include <stdlib.h> 4 4 5 Image::Image(const unsigned int width, const unsigned int height, const ImageFormat format, const Image::DataType type, void* data ) 6 : _width(width), _height(height), _dataType(type), _format(format) 5 Image::Image(const unsigned int width, const unsigned int height, 6 const ImageFormat format, const Image::DataType type, void* data ) : 7 _width(width), 8 _height(height), 9 _format(format), 10 _dataType(type) 7 11 { 8 12 switch (type) -
trunk/vizservers/nanovis/nanovis.h
r927 r929 102 102 class NanoVis { 103 103 public: 104 enum Axis { X, Y, Z };105 104 static VolumeRenderer* vol_renderer; 106 105 static PointSetRenderer* pointset_renderer;
Note: See TracChangeset
for help on using the changeset viewer.