Changeset 4818 for nanovis/branches/1.1/Command.cpp
- Timestamp:
- Dec 6, 2014 5:16:37 PM (8 years ago)
- Location:
- nanovis/branches/1.1
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
nanovis/branches/1.1
- Property svn:mergeinfo changed
/trunk/packages/vizservers/nanovis merged: 3883-3884,4098
- Property svn:mergeinfo changed
-
nanovis/branches/1.1/Command.cpp
r4816 r4818 48 48 #include "CmdProc.h" 49 49 #include "FlowCmd.h" 50 #include "Trace.h"51 50 #ifdef USE_POINTSET_RENDERER 52 51 #include "PointSet.h" … … 61 60 #include "Volume.h" 62 61 #include "VolumeRenderer.h" 62 #include "Trace.h" 63 63 64 64 using namespace nv::graphics; … … 266 266 } 267 267 268 269 268 /** 270 269 * Used internally to decode a series of volume index values and … … 672 671 } 673 672 674 /*675 * cutplane state $bool $axis vol,,,676 */677 673 static int 678 674 CutplaneStateOp(ClientData clientData, Tcl_Interp *interp, int objc, … … 707 703 } 708 704 705 static int 706 CutplaneVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc, 707 Tcl_Obj *const *objv) 708 { 709 bool state; 710 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 711 return TCL_ERROR; 712 } 713 714 std::vector<Volume *> ivol; 715 if (GetVolumes(interp, objc - 3, objv + 3, &ivol) != TCL_OK) { 716 return TCL_ERROR; 717 } 718 std::vector<Volume *>::iterator iter; 719 for (iter = ivol.begin(); iter != ivol.end(); iter++) { 720 (*iter)->cutplanesVisible(state); 721 } 722 return TCL_OK; 723 } 724 709 725 static Rappture::CmdSpec cutplaneOps[] = { 710 726 {"position", 1, CutplanePositionOp, 4, 0, "relval axis ?indices?",}, 711 727 {"state", 1, CutplaneStateOp, 4, 0, "bool axis ?indices?",}, 728 {"visible", 1, CutplaneVisibleOp, 3, 0, "bool ?indices?",}, 712 729 }; 713 730 static int nCutplaneOps = NumCmdSpecs(cutplaneOps); … … 858 875 } 859 876 860 const char *name; 861 name = Tcl_GetString(objv[1]); 862 TransferFunction *tf = NanoVis::getTransferFunction(name); 877 const char *tfName = Tcl_GetString(objv[1]); 878 TransferFunction *tf = NanoVis::getTransferFunction(tfName); 863 879 if (tf == NULL) { 864 Tcl_AppendResult(interp, "unknown transfer function \"", name, "\"",880 Tcl_AppendResult(interp, "unknown transfer function \"", tfName, "\"", 865 881 (char*)NULL); 866 882 return TCL_ERROR; … … 874 890 NanoVis::setVolumeRanges(); 875 891 } 876 NanoVis::renderLegend(tf, Volume::valueMin, Volume::valueMax, w, h, name);892 NanoVis::renderLegend(tf, Volume::valueMin, Volume::valueMax, w, h, tfName); 877 893 return TCL_OK; 878 894 } … … 965 981 966 982 // decode the data and store in a series of fields 967 Rappture::Field1D rFunc, gFunc, bFunc, wFunc;968 int cmapc, wmapc, i;983 Rappture::Field1D rFunc, gFunc, bFunc, aFunc; 984 int cmapc, amapc, i; 969 985 Tcl_Obj **cmapv; 970 Tcl_Obj ** wmapv;971 972 wmapv = cmapv = NULL;986 Tcl_Obj **amapv; 987 988 amapv = cmapv = NULL; 973 989 if (Tcl_ListObjGetElements(interp, objv[3], &cmapc, &cmapv) != TCL_OK) { 974 990 return TCL_ERROR; … … 979 995 return TCL_ERROR; 980 996 } 981 if (Tcl_ListObjGetElements(interp, objv[4], & wmapc, &wmapv) != TCL_OK) {997 if (Tcl_ListObjGetElements(interp, objv[4], &amapc, &amapv) != TCL_OK) { 982 998 return TCL_ERROR; 983 999 } 984 if (( wmapc % 2) != 0) {1000 if ((amapc % 2) != 0) { 985 1001 Tcl_AppendResult(interp, "wrong # elements in alphamap: should be ", 986 1002 " { v w ... }", (char*)NULL); … … 1006 1022 bFunc.define(q[0], q[3]); 1007 1023 } 1008 for (i=0; i < wmapc; i += 2) {1024 for (i=0; i < amapc; i += 2) { 1009 1025 double q[2]; 1010 1026 int j; 1011 1027 1012 1028 for (j=0; j < 2; j++) { 1013 if (Tcl_GetDoubleFromObj(interp, wmapv[i+j], &q[j]) != TCL_OK) {1029 if (Tcl_GetDoubleFromObj(interp, amapv[i+j], &q[j]) != TCL_OK) { 1014 1030 return TCL_ERROR; 1015 1031 } 1016 1032 if ((q[j] < 0.0) || (q[j] > 1.0)) { 1017 1033 Tcl_AppendResult(interp, "bad alphamap value \"", 1018 Tcl_GetString( wmapv[i+j]),1034 Tcl_GetString(amapv[i+j]), 1019 1035 "\": should be in the range 0-1", (char*)NULL); 1020 1036 return TCL_ERROR; 1021 1037 } 1022 1038 } 1023 wFunc.define(q[0], q[1]);1039 aFunc.define(q[0], q[1]); 1024 1040 } 1025 1041 // sample the given function into discrete slots … … 1031 1047 data[4*i+1] = gFunc.value(x); 1032 1048 data[4*i+2] = bFunc.value(x); 1033 data[4*i+3] = wFunc.value(x);1049 data[4*i+3] = aFunc.value(x); 1034 1050 } 1035 1051 // find or create this transfer function … … 1078 1094 return TCL_ERROR; 1079 1095 } 1080 VolumeInterpolator * interpolator;1081 interpolator =NanoVis::volRenderer->getVolumeInterpolator();1096 VolumeInterpolator *interpolator = 1097 NanoVis::volRenderer->getVolumeInterpolator(); 1082 1098 interpolator->start(); 1083 1099 if (interpolator->isStarted()) { 1084 const char * fileName = (objc < 5) ? NULL : Tcl_GetString(objv[4]);1085 for (int frame _num = 0; frame_num < total; ++frame_num) {1100 const char *dirName = (objc < 5) ? NULL : Tcl_GetString(objv[4]); 1101 for (int frameNum = 0; frameNum < total; ++frameNum) { 1086 1102 float fraction; 1087 1103 1088 fraction = ((float)frame _num) / (total - 1);1104 fraction = ((float)frameNum) / (total - 1); 1089 1105 TRACE("fraction : %f", fraction); 1090 //interpolator->update(((float)frame_num) / (total - 1));1091 1106 interpolator->update(fraction); 1092 1107 … … 1101 1116 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboOrig); 1102 1117 1103 NanoVis::bmpWriteToFile(frame _num, fileName);1118 NanoVis::bmpWriteToFile(frameNum, dirName); 1104 1119 } 1105 1120 } … … 1242 1257 bytes += 5; 1243 1258 nBytes -= 5; 1259 } else if ((nBytes > 4) && (strncmp(bytes, "<DX>", 4) == 0)) { 1260 bytes += 4; 1261 nBytes -= 4; 1244 1262 } 1245 1263 TRACE("DX loading..."); … … 1302 1320 1303 1321 static Rappture::CmdSpec volumeDataOps[] = { 1304 {"follows", 1, VolumeDataFollowsOp, 5, 5, " sizetag",},1322 {"follows", 1, VolumeDataFollowsOp, 5, 5, "nbytes tag",}, 1305 1323 {"state", 1, VolumeDataStateOp, 4, 0, "bool ?indices?",}, 1306 1324 }; … … 1404 1422 return TCL_OK; 1405 1423 } 1406 1407 1424 1408 1425 static Rappture::CmdSpec volumeOutlineOps[] = { … … 1654 1671 {"delete", 2, VolumeDeleteOp, 3, 0, "?name...?",}, 1655 1672 {"exists", 1, VolumeExistsOp, 3, 3, "name",}, 1656 {"names", 1, VolumeNamesOp, 2, 3, "?pattern?",},1673 {"names", 1, VolumeNamesOp, 2, 2, "",}, 1657 1674 {"outline", 1, VolumeOutlineOp, 3, 0, "oper ?args?",}, 1658 1675 {"shading", 2, VolumeShadingOp, 3, 0, "oper ?args?",}, … … 1661 1678 static int nVolumeOps = NumCmdSpecs(volumeOps); 1662 1679 1663 /*1664 * ----------------------------------------------------------------------1665 * CLIENT COMMAND:1666 * volume data state on|off ?<volumeId> ...?1667 * volume outline state on|off ?<volumeId> ...?1668 * volume outline color on|off ?<volumeId> ...?1669 * volume shading transfunc <name> ?<volumeId> ...?1670 * volume shading diffuse <value> ?<volumeId> ...?1671 * volume shading specular <value> ?<volumeId> ...?1672 * volume shading opacity <value> ?<volumeId> ...?1673 * volume state on|off ?<volumeId> ...?1674 *1675 * Clients send these commands to manipulate the volumes.1676 * ----------------------------------------------------------------------1677 */1678 1680 static int 1679 1681 VolumeCmd(ClientData clientData, Tcl_Interp *interp, int objc, … … 1759 1761 1760 1762 static Rappture::CmdSpec heightMapDataOps[] = { 1761 {"follows", 1, HeightMapDataFollowsOp, 5, 5, "size tag",},1762 {"visible", 1, HeightMapDataVisibleOp, 4, 0, "bool ? indices?",},1763 {"follows", 1, HeightMapDataFollowsOp, 5, 5, "size heightmapName",}, 1764 {"visible", 1, HeightMapDataVisibleOp, 4, 0, "bool ?heightmapNames...?",}, 1763 1765 }; 1764 1766 static int nHeightMapDataOps = NumCmdSpecs(heightMapDataOps); … … 1778 1780 } 1779 1781 1780 1781 1782 static int 1782 1783 HeightMapLineContourColorOp(ClientData clientData, Tcl_Interp *interp, int objc, … … 1820 1821 1821 1822 static Rappture::CmdSpec heightMapLineContourOps[] = { 1822 {"color", 1, HeightMapLineContourColorOp, 4, 4, "length",},1823 {"visible", 1, HeightMapLineContourVisibleOp, 4, 0, "bool ? indices?",},1823 {"color", 1, HeightMapLineContourColorOp, 6, 0, "r g b ?heightmapNames...?",}, 1824 {"visible", 1, HeightMapLineContourVisibleOp, 4, 0, "bool ?heightmapNames...?",}, 1824 1825 }; 1825 1826 static int nHeightMapLineContourOps = NumCmdSpecs(heightMapLineContourOps); … … 1954 1955 } 1955 1956 1956 1957 1957 static int 1958 1958 HeightMapOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc, … … 1976 1976 1977 1977 static Rappture::CmdSpec heightMapOps[] = { 1978 {"create", 2, HeightMapCreateOp, 10, 10, " tagxmin ymin xmax ymax xnum ynum values",},1978 {"create", 2, HeightMapCreateOp, 10, 10, "heightmapName xmin ymin xmax ymax xnum ynum values",}, 1979 1979 {"cull", 2, HeightMapCullOp, 3, 3, "mode",}, 1980 1980 {"data", 1, HeightMapDataOp, 3, 0, "oper ?args?",}, 1981 {"legend", 2, HeightMapLegendOp, 5, 5, " indexwidth height",},1981 {"legend", 2, HeightMapLegendOp, 5, 5, "heightmapName width height",}, 1982 1982 {"linecontour", 2, HeightMapLineContourOp, 2, 0, "oper ?args?",}, 1983 {"opacity", 1, HeightMapOpacityOp, 3, 0, "value ?heightmap ...? ",},1983 {"opacity", 1, HeightMapOpacityOp, 3, 0, "value ?heightmapNames...? ",}, 1984 1984 {"polygon", 1, HeightMapPolygonOp, 3, 3, "mode",}, 1985 1985 {"shading", 1, HeightMapShadingOp, 3, 3, "model",}, 1986 {"transfunc", 2, HeightMapTransFuncOp, 3, 0, "name ?heightmap ...?",},1986 {"transfunc", 2, HeightMapTransFuncOp, 3, 0, "name ?heightmapNames...?",}, 1987 1987 }; 1988 1988 static int nHeightMapOps = NumCmdSpecs(heightMapOps);
Note: See TracChangeset
for help on using the changeset viewer.