Changeset 3153


Ignore:
Timestamp:
Aug 24, 2012, 2:14:24 PM (12 years ago)
Author:
ldelgass
Message:

Protocol support for colormapping contour2ds.

Location:
trunk/packages/vizservers/vtkvis
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/vtkvis/RpVtkRenderer.cpp

    r3148 r3153  
    897897void Renderer::updateColorMap(ColorMap *cmap)
    898898{
     899    for (Contour2DHashmap::iterator itr = _contour2Ds.begin();
     900         itr != _contour2Ds.end(); ++itr) {
     901        if (itr->second->getColorMap() == cmap) {
     902            itr->second->updateColorMap();
     903            _needsRedraw = true;
     904        }
     905    }
    899906    for (Contour3DHashmap::iterator itr = _contour3Ds.begin();
    900907         itr != _contour3Ds.end(); ++itr) {
     
    974981bool Renderer::colorMapUsed(ColorMap *cmap)
    975982{
     983    for (Contour2DHashmap::iterator itr = _contour2Ds.begin();
     984         itr != _contour2Ds.end(); ++itr) {
     985        if (itr->second->getColorMap() == cmap)
     986            return true;
     987    }
    976988    for (Contour3DHashmap::iterator itr = _contour3Ds.begin();
    977989         itr != _contour3Ds.end(); ++itr) {
  • trunk/packages/vizservers/vtkvis/RpVtkRenderer.h

    r3149 r3153  
    369369    void setContour2DContourList(const DataSetId& id, const std::vector<double>& contours);
    370370
     371    void setContour2DColorMode(const DataSetId& id,
     372                               Contour2D::ColorMode mode,
     373                               const char *name, double range[2] = NULL);
     374
     375    void setContour2DColorMode(const DataSetId& id,
     376                               Contour2D::ColorMode mode,
     377                               DataSet::DataAttributeType type,
     378                               const char *name, double range[2] = NULL);
     379
    371380    // 3D Contour (isosurface) plots
    372381
  • trunk/packages/vizservers/vtkvis/RpVtkRendererCmd.cpp

    r3149 r3153  
    10641064
    10651065static int
     1066Contour2DColorMapOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1067                    Tcl_Obj *const *objv)
     1068{
     1069    const char *colorMapName = Tcl_GetString(objv[2]);
     1070    if (objc == 4) {
     1071        const char *dataSetName = Tcl_GetString(objv[3]);
     1072        g_renderer->setGraphicsObjectColorMap<Contour2D>(dataSetName, colorMapName);
     1073    } else {
     1074        g_renderer->setGraphicsObjectColorMap<Contour2D>("all", colorMapName);
     1075    }
     1076    return TCL_OK;
     1077}
     1078
     1079static int
     1080Contour2DColorModeOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1081                     Tcl_Obj *const *objv)
     1082{
     1083    Contour2D::ColorMode mode;
     1084    const char *str = Tcl_GetString(objv[2]);
     1085    if (str[0] == 'c' && strcmp(str, "ccolor") == 0) {
     1086        mode = Contour2D::COLOR_CONSTANT;
     1087    } else if (str[0] == 's' && strcmp(str, "scalar") == 0) {
     1088        mode = Contour2D::COLOR_BY_SCALAR;
     1089    } else if (str[0] == 'v' && strcmp(str, "vmag") == 0) {
     1090        mode = Contour2D::COLOR_BY_VECTOR_MAGNITUDE;
     1091    } else if (str[0] == 'v' && strcmp(str, "vx") == 0) {
     1092        mode = Contour2D::COLOR_BY_VECTOR_X;
     1093    } else if (str[0] == 'v' && strcmp(str, "vy") == 0) {
     1094        mode = Contour2D::COLOR_BY_VECTOR_Y;
     1095    } else if (str[0] == 'v' && strcmp(str, "vz") == 0) {
     1096        mode = Contour2D::COLOR_BY_VECTOR_Z;
     1097    } else {
     1098        Tcl_AppendResult(interp, "bad color mode option \"", str,
     1099                         "\": should be one of: 'scalar', 'vmag', 'vx', 'vy', 'vz', 'ccolor'", (char*)NULL);
     1100        return TCL_ERROR;
     1101    }
     1102    const char *fieldName = Tcl_GetString(objv[3]);
     1103    if (mode == Contour2D::COLOR_CONSTANT) {
     1104        fieldName = NULL;
     1105    }
     1106    if (objc == 5) {
     1107        const char *name = Tcl_GetString(objv[4]);
     1108        g_renderer->setContour2DColorMode(name, mode, fieldName);
     1109    } else {
     1110        g_renderer->setContour2DColorMode("all", mode, fieldName);
     1111    }
     1112    return TCL_OK;
     1113}
     1114
     1115static int
    10661116Contour2DLightingOp(ClientData clientData, Tcl_Interp *interp, int objc,
    10671117                    Tcl_Obj *const *objv)
     
    12101260static Rappture::CmdSpec contour2dOps[] = {
    12111261    {"add",       1, Contour2DAddOp, 4, 5, "oper value ?dataSetName?"},
    1212     {"color",     1, Contour2DLineColorOp, 5, 6, "r g b ?dataSetName?"},
     1262    {"ccolor",    2, Contour2DLineColorOp, 5, 6, "r g b ?dataSetName?"},
     1263    {"colormap",  7, Contour2DColorMapOp, 3, 4, "colorMapName ?dataSetName?"},
     1264    {"colormode", 7, Contour2DColorModeOp, 4, 5, "mode fieldName ?dataSetName?"},
    12131265    {"delete",    1, Contour2DDeleteOp, 2, 3, "?dataSetName?"},
    12141266    {"lighting",  3, Contour2DLightingOp, 3, 4, "bool ?dataSetName?"},
  • trunk/packages/vizservers/vtkvis/RpVtkRendererGraphicsObjs.cpp

    r3150 r3153  
    361361}
    362362
     363
     364/**
     365 * \brief Set the color mode for the specified DataSet
     366 */
     367void Renderer::setContour2DColorMode(const DataSetId& id,
     368                                     Contour2D::ColorMode mode,
     369                                     DataSet::DataAttributeType type,
     370                                     const char *name, double range[2])
     371{
     372    Contour2DHashmap::iterator itr;
     373
     374    bool doAll = false;
     375
     376    if (id.compare("all") == 0) {
     377        itr = _contour2Ds.begin();
     378        doAll = true;
     379    } else {
     380        itr = _contour2Ds.find(id);
     381    }
     382    if (itr == _contour2Ds.end()) {
     383        ERROR("Contour2D not found: %s", id.c_str());
     384        return;
     385    }
     386
     387    do {
     388        itr->second->setColorMode(mode, type, name, range);
     389    } while (doAll && ++itr != _contour2Ds.end());
     390
     391    _needsRedraw = true;
     392}
     393
     394/**
     395 * \brief Set the color mode for the specified DataSet
     396 */
     397void Renderer::setContour2DColorMode(const DataSetId& id,
     398                                     Contour2D::ColorMode mode,
     399                                     const char *name, double range[2])
     400{
     401    Contour2DHashmap::iterator itr;
     402
     403    bool doAll = false;
     404
     405    if (id.compare("all") == 0) {
     406        itr = _contour2Ds.begin();
     407        doAll = true;
     408    } else {
     409        itr = _contour2Ds.find(id);
     410    }
     411    if (itr == _contour2Ds.end()) {
     412        ERROR("Contour2D not found: %s", id.c_str());
     413        return;
     414    }
     415
     416    do {
     417        itr->second->setColorMode(mode, name, range);
     418    } while (doAll && ++itr != _contour2Ds.end());
     419
     420    _needsRedraw = true;
     421}
     422
    363423/**
    364424 * \brief Create a new Contour3D and associate it with the named DataSet
     
    14651525}
    14661526
    1467 
    14681527/**
    14691528 * \brief Set the color mode for the specified DataSet
  • trunk/packages/vizservers/vtkvis/protocol.txt

    r3149 r3153  
    149149contour2d add contourlist <list> <?datasetName?>
    150150          list = {isoval1 isoval2 isoval3...}
    151 contour2d color <r> <g> <b> <?datasetName?>
     151contour2d ccolor <r> <g> <b> <?datasetName?>
    152152          synonym for linecolor
     153contour2d colormap <colormapName> <?datasetName?>
     154contour2d colormode <scalar|vmag|vx|vy|vz|ccolor> <fieldName> <?datasetName?>
     155          Set the field used to color the object.  'ccolor' means to use
     156          the constant color defined by the ccolor subcommand.  'scalar' uses
     157          the active scalar field.  'vmag' uses the magnitude of the current
     158          vector field, and 'vx','vy','vz' use the corresponding component of
     159          the active vector field.
    153160contour2d delete <?datasetName?>
    154161contour2d lighting <bool> <?datasetName?>
     
    342349
    343350pseudocolor add <?datasetName?>
    344 pseudocolor ccolor r g b <?datasetName?>
     351pseudocolor ccolor <r> <g> <b> <?datasetName?>
    345352pseudocolor colormap <colormapName> <?datasetName?>
    346353pseudocolor colormode <scalar|vmag|vx|vy|vz|ccolor> <fieldName> <?datasetName?>
Note: See TracChangeset for help on using the changeset viewer.