Ignore:
Timestamp:
Jul 23, 2012 11:51:04 AM (12 years ago)
Author:
ldelgass
Message:

Add protocol to change atom/bond radius scale factor for VTK molecules

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

Legend:

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

    r3095 r3110  
    431431
    432432    // Molecules
     433
     434    void setMoleculeAtomRadiusScale(const DataSetId& id, double scale);
     435
     436    void setMoleculeBondRadiusScale(const DataSetId& id, double scale);
    433437
    434438    void setMoleculeAtomScaling(const DataSetId& id, Molecule::AtomScaling scaling);
  • trunk/packages/vizservers/vtkvis/RpVtkRendererCmd.cpp

    r3095 r3110  
    552552
    553553static Rappture::CmdSpec cameraOps[] = {
    554     {"get", 1, CameraGetOp, 2, 2, ""},
    555     {"mode", 1, CameraModeOp, 3, 3, "mode"},
     554    {"get",    1, CameraGetOp, 2, 2, ""},
     555    {"mode",   1, CameraModeOp, 3, 3, "mode"},
    556556    {"orient", 3, CameraOrientOp, 6, 6, "qw qx qy qz"},
    557     {"ortho", 1, CameraOrthoOp, 7, 7, "coordMode x y width height"},
    558     {"pan", 1, CameraPanOp, 4, 4, "panX panY"},
    559     {"reset", 2, CameraResetOp, 2, 3, "?all?"},
     557    {"ortho",  1, CameraOrthoOp, 7, 7, "coordMode x y width height"},
     558    {"pan",    1, CameraPanOp, 4, 4, "panX panY"},
     559    {"reset",  2, CameraResetOp, 2, 3, "?all?"},
    560560    {"rotate", 2, CameraRotateOp, 5, 5, "angle angle angle"},
    561     {"set", 1, CameraSetOp, 11, 11, "posX posY posZ focalPtX focalPtY focalPtZ viewUpX viewUpY viewUpZ"},
    562     {"zoom", 1, CameraZoomOp, 3, 3, "zoomAmount"}
     561    {"set",    1, CameraSetOp, 11, 11, "posX posY posZ focalPtX focalPtY focalPtZ viewUpX viewUpY viewUpZ"},
     562    {"zoom",   1, CameraZoomOp, 3, 3, "zoomAmount"}
    563563};
    564564static int nCameraOps = NumCmdSpecs(cameraOps);
     
    34883488
    34893489static int
     3490MoleculeAtomScaleFactorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3491                          Tcl_Obj *const *objv)
     3492{
     3493    double scale;
     3494    if (Tcl_GetDoubleFromObj(interp, objv[2], &scale) != TCL_OK) {
     3495        return TCL_ERROR;
     3496    }
     3497    if (objc == 4) {
     3498        const char *name = Tcl_GetString(objv[3]);
     3499        g_renderer->setMoleculeAtomRadiusScale(name, scale);
     3500    } else {
     3501        g_renderer->setMoleculeAtomRadiusScale("all", scale);
     3502    }
     3503    return TCL_OK;
     3504}
     3505
     3506static int
    34903507MoleculeAtomScalingOp(ClientData clientData, Tcl_Interp *interp, int objc,
    34913508                      Tcl_Obj *const *objv)
     
    35163533
    35173534static int
     3535MoleculeBondScaleFactorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3536                          Tcl_Obj *const *objv)
     3537{
     3538    double scale;
     3539    if (Tcl_GetDoubleFromObj(interp, objv[2], &scale) != TCL_OK) {
     3540        return TCL_ERROR;
     3541    }
     3542    if (objc == 4) {
     3543        const char *name = Tcl_GetString(objv[3]);
     3544        g_renderer->setMoleculeBondRadiusScale(name, scale);
     3545    } else {
     3546        g_renderer->setMoleculeBondRadiusScale("all", scale);
     3547    }
     3548    return TCL_OK;
     3549}
     3550
     3551static int
    35183552MoleculeBondVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc,
    35193553                         Tcl_Obj *const *objv)
     
    37403774static Rappture::CmdSpec moleculeOps[] = {
    37413775    {"add",        2, MoleculeAddOp, 2, 3, "?dataSetName?"},
     3776    {"ascale",     2, MoleculeAtomScaleFactorOp, 3, 4, "value ?dataSetName?"},
    37423777    {"atoms",      2, MoleculeAtomVisibilityOp, 3, 4, "bool ?dataSetName?"},
    37433778    {"bonds",      2, MoleculeBondVisibilityOp, 3, 4, "bool ?dataSetName?"},
     3779    {"bscale",     2, MoleculeBondScaleFactorOp, 3, 4, "value ?dataSetName?"},
    37443780    {"colormap",   1, MoleculeColorMapOp, 3, 4, "colorMapName ?dataSetName?"},
    37453781    {"delete",     1, MoleculeDeleteOp, 2, 3, "?dataSetName?"},
  • trunk/packages/vizservers/vtkvis/RpVtkRendererGraphicsObjs.cpp

    r3095 r3110  
    10831083
    10841084/**
    1085  * \brief Set radius standard for scaling atoms
    1086  */
    1087 void Renderer::setMoleculeAtomScaling(const DataSetId& id, Molecule::AtomScaling scaling)
     1085 * \brief Set radius scale factor for atoms
     1086 */
     1087void Renderer::setMoleculeAtomRadiusScale(const DataSetId& id, double scale)
    10881088{
    10891089    MoleculeHashmap::iterator itr;
     
    11031103
    11041104    do {
     1105        itr->second->setAtomRadiusScale(scale);
     1106    } while (doAll && ++itr != _molecules.end());
     1107
     1108    _needsRedraw = true;
     1109}
     1110
     1111/**
     1112 * \brief Set radius standard for scaling atoms
     1113 */
     1114void Renderer::setMoleculeAtomScaling(const DataSetId& id, Molecule::AtomScaling scaling)
     1115{
     1116    MoleculeHashmap::iterator itr;
     1117
     1118    bool doAll = false;
     1119
     1120    if (id.compare("all") == 0) {
     1121        itr = _molecules.begin();
     1122        doAll = true;
     1123    } else {
     1124        itr = _molecules.find(id);
     1125    }
     1126    if (itr == _molecules.end()) {
     1127        ERROR("Molecule not found: %s", id.c_str());
     1128        return;
     1129    }
     1130
     1131    do {
    11051132        itr->second->setAtomScaling(scaling);
    11061133    } while (doAll && ++itr != _molecules.end());
     
    11311158    do {
    11321159        itr->second->setAtomVisibility(state);
     1160    } while (doAll && ++itr != _molecules.end());
     1161
     1162    _needsRedraw = true;
     1163}
     1164
     1165/**
     1166 * \brief Set radius scale factor for atoms
     1167 */
     1168void Renderer::setMoleculeBondRadiusScale(const DataSetId& id, double scale)
     1169{
     1170    MoleculeHashmap::iterator itr;
     1171
     1172    bool doAll = false;
     1173
     1174    if (id.compare("all") == 0) {
     1175        itr = _molecules.begin();
     1176        doAll = true;
     1177    } else {
     1178        itr = _molecules.find(id);
     1179    }
     1180    if (itr == _molecules.end()) {
     1181        ERROR("Molecule not found: %s", id.c_str());
     1182        return;
     1183    }
     1184
     1185    do {
     1186        itr->second->setBondRadiusScale(scale);
    11331187    } while (doAll && ++itr != _molecules.end());
    11341188
  • trunk/packages/vizservers/vtkvis/protocol.txt

    r3097 r3110  
    274274molecule atoms <bool> <?datasetName?>
    275275         Toggle rendering of atoms
     276molecule ascale <val> <?datasetName?>
     277         Set atom scale factor
    276278molecule bonds <bool> <?datasetName?>
    277279         Toggle rendering of bonds
     280molecule bscale <val> <?datasetName?>
     281         Set bond scale factor
    278282molecule colormap <colormapName> <?datasetName?>
    279283molecule delete <?datasetName?>
Note: See TracChangeset for help on using the changeset viewer.