Changeset 4818 for nanovis


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

Merge in 'cutplane visible' command

Location:
nanovis/branches/1.1
Files:
6 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);
  • nanovis/branches/1.1/Volume.cpp

    r4612 r4818  
    4848    _numComponents(n),
    4949    _nonZeroMin(nonZeroMin),
     50    _cutplanesVisible(true),
    5051    _tex(NULL),
    5152    _location(x, y, z),
  • nanovis/branches/1.1/Volume.h

    r4612 r4818  
    167167    void disableCutplane(int index);
    168168
     169    void cutplanesVisible(bool state)
     170    {
     171        _cutplanesVisible = state;
     172    }
     173
     174    bool cutplanesVisible() const
     175    {
     176        return _cutplanesVisible;
     177    }
     178
    169179    void moveCutplane(int index, float location);
    170180
     
    389399    double _nonZeroMin;
    390400
     401    bool _cutplanesVisible;
    391402    std::vector<CutPlane> _plane; ///< cut planes
    392403
  • nanovis/branches/1.1/VolumeRenderer.cpp

    r4612 r4818  
    245245
    246246        for (int j = 0; j < volume->getCutplaneCount(); j++) {
    247             if (!volume->isCutplaneEnabled(j)) {
     247            if (!volume->cutplanesVisible() || !volume->isCutplaneEnabled(j)) {
    248248                continue;
    249249            }
  • nanovis/branches/1.1/protocol-nanovis.txt

    r3568 r4818  
    66Protocol for nanovis render server. 
    77
    8 Commands take the general form of command and arguments using Tcl syntax and are 
     8Commands take the general form of command and arguments using Tcl syntax and are
    99terminated by a newline.  Some command arguments expect a Tcl list which can be
    1010sent by enclosing the list in curly braces to prevent the interpreter from
     
    3838Requests:
    3939================================================================================
    40 axis visible <false|true>
    41 
    42 grid axiscolor <red> <green> <blue> <?alpha?>
    43 grid axisname <x|y|z> <name>
    44 grid linecolor <red> <green> <blue> <?alpha?>
    45 grid visible <false|true>
     40axis visible <bool>
    4641
    4742camera angle <xAngle> <yAngle> <zAngle>
     
    5348camera zoom <factor>
    5449
    55 screen bgcolor <r> <g> <b>
    56        Set screen background color
    57 screen size <width> <height>
    58        Set size of rendered images
    59 
    60 snapshot
    61          Render a 2k x 2k image (offscreen buffer)
    62 
    63 transfunc define <name> {colors} {alpha}
    64           colors => 1 line each of "value r g b"
    65           alpha => 1 line each of "value alpha"
    66           value => [0,1]
    67 
    68 legend <transferfunc name> <width> <height>
    69        Request render of transfer function
    70 
    71 heightmap data visible <true|false> <volume IDs>
    72 heightmap data follows <nbytes> <data>
    73 heightmap linecontour visible <true|false> <volume IDs>
    74 heightmap linecontour color <red> <green> <blue> <volume IDs>
    75 heightmap tranfunc <transfer function name> <volume IDs>
    76 heightmap cull <no/back/front>
    77 heightmap polygon <wireframe/fill>
     50clientinfo <list>
     51
     52cutplane position <relval> <x|y|z> <?names?>
     53         Set the position of a volume cutplane.  Names is
     54         an optional list of volume names.
     55         relval = [0,1]
     56cutplane state <bool> <x|y|z> <?names?>
     57         Set the axis (normal) of a volume cutplane.  Names is
     58         an optional list of volume names.
     59cutplane visible <bool> <?names?>
     60         Set visibility of all (x,y, and z) cutplanes for
     61         named volume(s)
    7862
    7963flow add <name> <?option value...?>
     
    8468flow delete <names>
    8569flow exists <name>
     70     This doesn't currently produce a response, it only returns a boolean
     71     within the server's interpreter
    8672flow goto <nSteps>
    8773flow names
     74     This doesn't currently produce a response, it only returns a Tcl list
     75     within the server's interpreter
    8876flow next
    8977flow reset
     
    10694<flowObj> box delete <names>
    10795<flowObj> box names
     96          This doesn't currently produce a response, it only returns a Tcl list
     97          within the server's interpreter
    10898
    10999<flowObj> configure <?option value...?>
     
    113103          -diffuse <val>
    114104          -hide <bool>
     105          -light2side <bool>
    115106          -opacity <val>
    116107          -outline <bool>
    117           -position <val|%val>
    118            val = [0,100], or %val = [0,1]
     108          -position <val|val%>
     109           val = [0,1], or val% = [0,100]
    119110          -slice <bool>
    120111          -specularExp <val>
     
    134125          -color <{r g b a}>
    135126          -hide <bool>
    136           -position <val|%val>
    137            val = [0,100], or %val = [0,1]
     127          -position <val|val%>
     128           val = [0,1], or val% = [0,100]
    138129          -size <val>
    139130<flowObj> particles delete <names>
    140131<flowObj> particles names
    141 
    142 volume data state <on|off> <?names?>
    143 volume data follows <size> <tag>
    144 volume delete <?names?>
     132          This doesn't currently produce a response, it only returns a Tcl list
     133          within the server's interpreter
     134
     135grid axiscolor <red> <green> <blue> <?alpha?>
     136grid axisname <x|y|z> <name> <units>
     137grid linecolor <red> <green> <blue> <?alpha?>
     138grid visible <bool>
     139
     140heightmap create <heightmapName> <xMin> <yMin> <xMax> <yMax> <xNum> <yNum> <valueList>
     141heightmap cull <none|back|front>
     142heightmap data follows <nBytes> <heightmapName>
     143          After newline following command, nBytes of data are sent
     144heightmap data visible <bool> <?heightmapNames?>
     145heightmap legend <heightmapName> <width> <height>
     146heightmap linecontour color <red> <green> <blue> <?heightmapNames?>
     147heightmap linecontour visible <bool> <?heightmapNames?>
     148heightmap opacity <value> <?heightmapNames?>
     149heightmap polygon <wireframe|fill>
     150          **Warning: This is a global setting**
     151heightmap shading <flat|smooth>
     152          **Warning: This is a global setting**
     153heightmap transfunc <transferFunctionName> <?heightmapNames?>
     154
     155legend <transferfunc name> <width> <height>
     156       Request render of transfer function
     157
     158screen bgcolor <r> <g> <b>
     159       Set screen background color
     160screen size <width> <height>
     161       Set size of rendered images
     162
     163snapshot
     164         Render a 2k x 2k image (offscreen buffer).  Response image data is
     165         tagged as '-type print'
     166
     167transfunc define <name> {colors} {alpha}
     168          colors => 1 line each of "value r g b"
     169          alpha => 1 line each of "value alpha"
     170          value => [0,1]
     171
     172up <x|y|z|-x|-y|-z>
     173   Set orientation of volumes
     174
     175volume animation capture <numframes> <?filename?>
     176       This is not fully implemented.  Rendered frames are not returned
     177       to the client.
     178volume animation clear
     179volume animation start
     180volume animation stop
     181volume animation volumes <?names?>
     182
     183volume data follows <nbytes> <name>
     184volume data state <bool> <?names?>
     185volume delete <names>
    145186volume exists <name>
    146 volume names <?pattern?>
     187       This doesn't currently produce a response, it only returns a boolean
     188       within the server's interpreter
     189volume names
     190       This doesn't currently produce a response, it only returns a Tcl list
     191       within the server's interpreter
    147192volume outline color <r> <g> <b> <?names?>
    148 volume outline state|visible <bool> <?names?>
     193volume outline state <bool> <?names?>
     194volume outline visible <bool> <?names?>
    149195volume shading ambient <value> <?names?>
    150196volume shading diffuse <value> <?names?>
    151197volume shading isosurface <bool> <?names?>
     198volume shading light2side <bool> <?names?>
    152199volume shading opacity <value> <?names?>
    153200volume shading specularExp <value> <?names?>
     
    156203volume state <bool> <?names?>
    157204
    158 volume animation volumes <volume IDs>
    159 volume animation start
    160 volume animation stop
    161 volume animation clear
    162 volume animation capture numframes <filename>
    163 
    164 cutplane position <relval> <x|y|z> <?names?>
    165          Set the position of a volume cutplane.  Names is
    166          an optional list of volume names.
    167          relval = [0,1]
    168 cutplane state <bool> <x|y|z> <?names?>
    169          Set the axis (normal) of a volume cutplane.  Names is
    170          an optional list of volume names.
    171 
    172 up <x|y|z|-x|-y|-z>
    173    Set orientation of volumes
    174 
    175205================================================================================
    176206Replies:
     
    192222   min,max over all volumes
    193223
     224nv>data tag <flow-tag> min <val> max <val>
     225   Sent after a "<flowObj> data follows...".  Min,max values are for the
     226   magnitude of the vector field.
     227
    194228================================================================================
    195229Error Replies:
Note: See TracChangeset for help on using the changeset viewer.