Ignore:
Timestamp:
Dec 6, 2014, 8:16:37 PM (5 years ago)
Author:
ldelgass
Message:

Merge in 'cutplane visible' command

Location:
nanovis/branches/1.1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • nanovis/branches/1.1

  • nanovis/branches/1.1/Command.cpp

    r4816 r4818  
    4848#include "CmdProc.h"
    4949#include "FlowCmd.h"
    50 #include "Trace.h"
    5150#ifdef USE_POINTSET_RENDERER
    5251#include "PointSet.h"
     
    6160#include "Volume.h"
    6261#include "VolumeRenderer.h"
     62#include "Trace.h"
    6363
    6464using namespace nv::graphics;
     
    266266}
    267267
    268 
    269268/**
    270269 * Used internally to decode a series of volume index values and
     
    672671}
    673672
    674 /*
    675  * cutplane state $bool $axis vol,,,
    676  */
    677673static int
    678674CutplaneStateOp(ClientData clientData, Tcl_Interp *interp, int objc,
     
    707703}
    708704
     705static int
     706CutplaneVisibleOp(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
    709725static Rappture::CmdSpec cutplaneOps[] = {
    710726    {"position", 1, CutplanePositionOp, 4, 0, "relval axis ?indices?",},
    711727    {"state",    1, CutplaneStateOp,    4, 0, "bool axis ?indices?",},
     728    {"visible",  1, CutplaneVisibleOp,  3, 0, "bool ?indices?",},
    712729};
    713730static int nCutplaneOps = NumCmdSpecs(cutplaneOps);
     
    858875    }
    859876
    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);
    863879    if (tf == NULL) {
    864         Tcl_AppendResult(interp, "unknown transfer function \"", name, "\"",
     880        Tcl_AppendResult(interp, "unknown transfer function \"", tfName, "\"",
    865881                             (char*)NULL);
    866882        return TCL_ERROR;
     
    874890        NanoVis::setVolumeRanges();
    875891    }
    876     NanoVis::renderLegend(tf, Volume::valueMin, Volume::valueMax, w, h, name);
     892    NanoVis::renderLegend(tf, Volume::valueMin, Volume::valueMax, w, h, tfName);
    877893    return TCL_OK;
    878894}
     
    965981
    966982        // 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;
    969985        Tcl_Obj **cmapv;
    970         Tcl_Obj **wmapv;
    971 
    972         wmapv = cmapv = NULL;
     986        Tcl_Obj **amapv;
     987
     988        amapv = cmapv = NULL;
    973989        if (Tcl_ListObjGetElements(interp, objv[3], &cmapc, &cmapv) != TCL_OK) {
    974990            return TCL_ERROR;
     
    979995            return TCL_ERROR;
    980996        }
    981         if (Tcl_ListObjGetElements(interp, objv[4], &wmapc, &wmapv) != TCL_OK) {
     997        if (Tcl_ListObjGetElements(interp, objv[4], &amapc, &amapv) != TCL_OK) {
    982998            return TCL_ERROR;
    983999        }
    984         if ((wmapc % 2) != 0) {
     1000        if ((amapc % 2) != 0) {
    9851001            Tcl_AppendResult(interp, "wrong # elements in alphamap: should be ",
    9861002                " { v w ... }", (char*)NULL);
     
    10061022            bFunc.define(q[0], q[3]);
    10071023        }
    1008         for (i=0; i < wmapc; i += 2) {
     1024        for (i=0; i < amapc; i += 2) {
    10091025            double q[2];
    10101026            int j;
    10111027
    10121028            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) {
    10141030                    return TCL_ERROR;
    10151031                }
    10161032                if ((q[j] < 0.0) || (q[j] > 1.0)) {
    10171033                    Tcl_AppendResult(interp, "bad alphamap value \"",
    1018                         Tcl_GetString(wmapv[i+j]),
     1034                        Tcl_GetString(amapv[i+j]),
    10191035                        "\": should be in the range 0-1", (char*)NULL);
    10201036                    return TCL_ERROR;
    10211037                }
    10221038            }
    1023             wFunc.define(q[0], q[1]);
     1039            aFunc.define(q[0], q[1]);
    10241040        }
    10251041        // sample the given function into discrete slots
     
    10311047            data[4*i+1] = gFunc.value(x);
    10321048            data[4*i+2] = bFunc.value(x);
    1033             data[4*i+3] = wFunc.value(x);
     1049            data[4*i+3] = aFunc.value(x);
    10341050        }
    10351051        // find or create this transfer function
     
    10781094        return TCL_ERROR;
    10791095    }
    1080     VolumeInterpolator* interpolator;
    1081     interpolator = NanoVis::volRenderer->getVolumeInterpolator();
     1096    VolumeInterpolator *interpolator =
     1097        NanoVis::volRenderer->getVolumeInterpolator();
    10821098    interpolator->start();
    10831099    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) {
    10861102            float fraction;
    10871103
    1088             fraction = ((float)frame_num) / (total - 1);
     1104            fraction = ((float)frameNum) / (total - 1);
    10891105            TRACE("fraction : %f", fraction);
    1090             //interpolator->update(((float)frame_num) / (total - 1));
    10911106            interpolator->update(fraction);
    10921107
     
    11011116            glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboOrig);
    11021117
    1103             NanoVis::bmpWriteToFile(frame_num, fileName);
     1118            NanoVis::bmpWriteToFile(frameNum, dirName);
    11041119        }
    11051120    }
     
    12421257            bytes += 5;
    12431258            nBytes -= 5;
     1259        } else if ((nBytes > 4) && (strncmp(bytes, "<DX>", 4) == 0)) {
     1260            bytes += 4;
     1261            nBytes -= 4;
    12441262        }
    12451263        TRACE("DX loading...");
     
    13021320
    13031321static Rappture::CmdSpec volumeDataOps[] = {
    1304     {"follows",   1, VolumeDataFollowsOp, 5, 5, "size tag",},
     1322    {"follows",   1, VolumeDataFollowsOp, 5, 5, "nbytes tag",},
    13051323    {"state",     1, VolumeDataStateOp,   4, 0, "bool ?indices?",},
    13061324};
     
    14041422    return TCL_OK;
    14051423}
    1406 
    14071424
    14081425static Rappture::CmdSpec volumeOutlineOps[] = {
     
    16541671    {"delete",    2, VolumeDeleteOp,      3, 0, "?name...?",},
    16551672    {"exists",    1, VolumeExistsOp,      3, 3, "name",},
    1656     {"names",     1, VolumeNamesOp,       2, 3, "?pattern?",},
     1673    {"names",     1, VolumeNamesOp,       2, 2, "",},
    16571674    {"outline",   1, VolumeOutlineOp,     3, 0, "oper ?args?",},
    16581675    {"shading",   2, VolumeShadingOp,     3, 0, "oper ?args?",},
     
    16611678static int nVolumeOps = NumCmdSpecs(volumeOps);
    16621679
    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  */
    16781680static int
    16791681VolumeCmd(ClientData clientData, Tcl_Interp *interp, int objc,
     
    17591761
    17601762static 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...?",},
    17631765};
    17641766static int nHeightMapDataOps = NumCmdSpecs(heightMapDataOps);
     
    17781780}
    17791781
    1780 
    17811782static int
    17821783HeightMapLineContourColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     
    18201821
    18211822static 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...?",},
    18241825};
    18251826static int nHeightMapLineContourOps = NumCmdSpecs(heightMapLineContourOps);
     
    19541955}
    19551956
    1956 
    19571957static int
    19581958HeightMapOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     
    19761976
    19771977static Rappture::CmdSpec heightMapOps[] = {
    1978     {"create",       2, HeightMapCreateOp,      10, 10, "tag xmin ymin xmax ymax xnum ynum values",},
     1978    {"create",       2, HeightMapCreateOp,      10, 10, "heightmapName xmin ymin xmax ymax xnum ynum values",},
    19791979    {"cull",         2, HeightMapCullOp,        3, 3, "mode",},
    19801980    {"data",         1, HeightMapDataOp,        3, 0, "oper ?args?",},
    1981     {"legend",       2, HeightMapLegendOp,      5, 5, "index width height",},
     1981    {"legend",       2, HeightMapLegendOp,      5, 5, "heightmapName width height",},
    19821982    {"linecontour",  2, HeightMapLineContourOp, 2, 0, "oper ?args?",},
    1983     {"opacity",      1, HeightMapOpacityOp,     3, 0, "value ?heightmap...? ",},
     1983    {"opacity",      1, HeightMapOpacityOp,     3, 0, "value ?heightmapNames...? ",},
    19841984    {"polygon",      1, HeightMapPolygonOp,     3, 3, "mode",},
    19851985    {"shading",      1, HeightMapShadingOp,     3, 3, "model",},
    1986     {"transfunc",    2, HeightMapTransFuncOp,   3, 0, "name ?heightmap...?",},
     1986    {"transfunc",    2, HeightMapTransFuncOp,   3, 0, "name ?heightmapNames...?",},
    19871987};
    19881988static int nHeightMapOps = NumCmdSpecs(heightMapOps);
Note: See TracChangeset for help on using the changeset viewer.