Changeset 3771


Ignore:
Timestamp:
Jul 10, 2013 5:14:25 PM (8 years ago)
Author:
ldelgass
Message:

Add protocol for setting max. number of glyphs

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

Legend:

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

    r3621 r3771  
    1313
    1414void GraphicsObject::setDataSet(DataSet *dataSet,
    15                                    Renderer *renderer)
     15                                Renderer *renderer)
    1616{
    1717    if (_dataSet != dataSet) {
  • trunk/packages/vizservers/vtkvis/Renderer.h

    r3696 r3771  
    699699    void setGlyphsScaleFactor(const DataSetId& id, double scale);
    700700
     701    void setGlyphsMaximumNumberOfGlyphs(const DataSetId& id, int max,
     702                                        bool random = true,
     703                                        int offset = 0, int ratio = 1);
     704
    701705    // Groups
    702706
  • trunk/packages/vizservers/vtkvis/RendererCmd.cpp

    r3696 r3771  
    20492049    {"orient",    4, BoxOrientOp, 6, 7, "qw qx qy qz ?name?"},
    20502050    {"origin",    4, BoxOriginOp, 5, 6, "x y z ?name?"},
    2051     {"pos",       2, BoxPositionOp, 5, 6, "x y z ?name?"},
     2051    {"pos",       1, BoxPositionOp, 5, 6, "x y z ?name?"},
    20522052    {"scale",     2, BoxScaleOp, 5, 6, "sx sy sz ?name?"},
    20532053    {"shading",   2, BoxShadingOp, 3, 4, "val ?name?"},
     
    28912891    {"orient",    4, ConeOrientOp, 6, 7, "qw qx qy qz ?name?"},
    28922892    {"origin",    4, ConeOriginOp, 5, 6, "x y z ?name?"},
    2893     {"pos",       2, ConePositionOp, 5, 6, "x y z ?name?"},
     2893    {"pos",       1, ConePositionOp, 5, 6, "x y z ?name?"},
    28942894    {"resolution",1, ConeResolutionOp, 3, 4, "res ?name?"},
    28952895    {"scale",     2, ConeScaleOp, 5, 6, "sx sy sz ?name?"},
     
    45184518    {"orient",    4, CylinderOrientOp, 6, 7, "qw qx qy qz ?name?"},
    45194519    {"origin",    4, CylinderOriginOp, 5, 6, "x y z ?name?"},
    4520     {"pos",       2, CylinderPositionOp, 5, 6, "x y z ?name?"},
     4520    {"pos",       1, CylinderPositionOp, 5, 6, "x y z ?name?"},
    45214521    {"resolution",1, CylinderResolutionOp, 3, 4, "res ?name?"},
    45224522    {"scale",     2, CylinderScaleOp, 5, 6, "sx sy sz ?name?"},
     
    53345334    {"orient",    4, DiskOrientOp, 6, 7, "qw qx qy qz ?name?"},
    53355335    {"origin",    4, DiskOriginOp, 5, 6, "x y z ?name?"},
    5336     {"pos",       2, DiskPositionOp, 5, 6, "x y z ?name?"},
     5336    {"pos",       1, DiskPositionOp, 5, 6, "x y z ?name?"},
    53375337    {"resolution",1, DiskResolutionOp, 4, 5, "resRadial resCircum ?name?"},
    53385338    {"scale",     2, DiskScaleOp, 5, 6, "sx sy sz ?name?"},
     
    55605560
    55615561static int
     5562GlyphsMaxNumberOfGlyphsOp(ClientData clientData, Tcl_Interp *interp, int objc,
     5563                          Tcl_Obj *const *objv)
     5564{
     5565    int max;
     5566    bool random = true;
     5567    int offset = 0;
     5568    int ratio = 1;
     5569    if (Tcl_GetIntFromObj(interp, objv[2], &max) != TCL_OK) {
     5570        return TCL_ERROR;
     5571    }
     5572    if (objc > 3) {
     5573        if (GetBooleanFromObj(interp, objv[3], &random) != TCL_OK) {
     5574            return TCL_ERROR;
     5575        }
     5576        if (Tcl_GetIntFromObj(interp, objv[4], &offset) != TCL_OK) {
     5577            return TCL_ERROR;
     5578        }
     5579        if (Tcl_GetIntFromObj(interp, objv[5], &ratio) != TCL_OK) {
     5580            return TCL_ERROR;
     5581        }
     5582    }
     5583    if (objc == 7) {
     5584        const char *name = Tcl_GetString(objv[6]);
     5585        g_renderer->setGlyphsMaximumNumberOfGlyphs(name, max, random, offset, ratio);
     5586    } else {
     5587        g_renderer->setGlyphsMaximumNumberOfGlyphs("all", max, random, offset, ratio);
     5588    }
     5589    return TCL_OK;
     5590}
     5591
     5592static int
    55625593GlyphsNormalizeScaleOp(ClientData clientData, Tcl_Interp *interp, int objc,
    55635594                       Tcl_Obj *const *objv)
     
    58395870    {"linecolor",    5, GlyphsLineColorOp, 5, 6, "r g b ?dataSetName?"},
    58405871    {"linewidth",    5, GlyphsLineWidthOp, 3, 4, "width ?dataSetName?"},
    5841     {"normscale",    1, GlyphsNormalizeScaleOp, 3, 4, "bool ?dataSetName?"},
     5872    {"normscale",    2, GlyphsNormalizeScaleOp, 3, 4, "bool ?dataSetName?"},
     5873    {"numglyphs",    2, GlyphsMaxNumberOfGlyphsOp, 3, 7, "max ?random? ?offset? ?ratio? ?dataSetName?"},
    58425874    {"opacity",      2, GlyphsOpacityOp, 3, 4, "value ?dataSetName?"},
    58435875    {"orient",       2, GlyphsOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"},
     
    60246056    {"pos",       1, GroupPositionOp, 5, 6, "x y z ?name?"},
    60256057    {"remove",    1, GroupRemoveChildOp, 3, 4, "nodeList ?name?"},
    6026     {"scale",     2, GroupScaleOp, 5, 6, "sx sy sz ?name?"},
     6058    {"scale",     1, GroupScaleOp, 5, 6, "sx sy sz ?name?"},
    60276059    {"visible",   1, GroupVisibleOp, 3, 4, "bool ?name?"},
    60286060};
     
    72717303    {"orient",    4, LineOrientOp, 6, 7, "qw qx qy qz ?name?"},
    72727304    {"origin",    4, LineOriginOp, 5, 6, "x y z ?name?"},
    7273     {"pos",       2, LinePositionOp, 5, 6, "x y z ?name?"},
    7274     {"scale",     2, LineScaleOp, 5, 6, "sx sy sz ?name?"},
     7305    {"pos",       1, LinePositionOp, 5, 6, "x y z ?name?"},
     7306    {"scale",     1, LineScaleOp, 5, 6, "sx sy sz ?name?"},
    72757307    {"visible",   1, LineVisibleOp, 3, 4, "bool ?name?"}
    72767308};
     
    80198051    {"opacity",   2, OutlineOpacityOp, 3, 4, "value ?dataSetName?"},
    80208052    {"orient",    2, OutlineOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"},
    8021     {"pos",       2, OutlinePositionOp, 5, 6, "x y z ?dataSetName?"},
    8022     {"scale",     2, OutlineScaleOp, 5, 6, "sx sy sz ?dataSetName?"},
     8053    {"pos",       1, OutlinePositionOp, 5, 6, "x y z ?dataSetName?"},
     8054    {"scale",     1, OutlineScaleOp, 5, 6, "sx sy sz ?dataSetName?"},
    80238055    {"visible",   1, OutlineVisibleOp, 3, 4, "bool ?dataSetName?"}
    80248056};
     
    1115811190    {"preinterp",    2, WarpPreInterpOp, 3, 4, "bool ?dataSetName?"},
    1115911191    {"ptsize",       2, WarpPointSizeOp, 3, 4, "size ?dataSetName?"},
    11160     {"scale",        2, WarpScaleOp, 5, 6, "sx sy sz ?dataSetName?"},
     11192    {"scale",        1, WarpScaleOp, 5, 6, "sx sy sz ?dataSetName?"},
    1116111193    {"visible",      1, WarpVisibleOp, 3, 4, "bool ?dataSetName?"},
    1116211194    {"warpscale",    2, WarpWarpScaleOp, 3, 4, "value ?dataSetName?"},
  • trunk/packages/vizservers/vtkvis/RendererGraphicsObjs.cpp

    r3696 r3771  
    15611561
    15621562/**
     1563 * \brief Limit the number of glyphs displayed
     1564 *
     1565 * The choice of glyphs to display can be based on sampling every
     1566 * n-th point (ratio) or by random sample
     1567 *
     1568 * \param max Maximum number of glyphs to display, negative means display all
     1569 * \param random Flag to enable/disable random sampling
     1570 * \param offset If random is false, this controls the first sample point
     1571 * \param ratio If random is false, this ratio controls every n-th point sampling
     1572 */
     1573void Renderer::setGlyphsMaximumNumberOfGlyphs(const DataSetId& id, int max,
     1574                                              bool random, int offset, int ratio)
     1575{
     1576    GlyphsHashmap::iterator itr;
     1577
     1578    bool doAll = false;
     1579
     1580    if (id.compare("all") == 0) {
     1581        itr = _glyphs.begin();
     1582        if (itr == _glyphs.end())
     1583            return;
     1584        doAll = true;
     1585    } else {
     1586        itr = _glyphs.find(id);
     1587    }
     1588    if (itr == _glyphs.end()) {
     1589        ERROR("Glyphs not found: %s", id.c_str());
     1590        return;
     1591    }
     1592
     1593    do {
     1594        itr->second->setMaximumNumberOfGlyphs(max, random, offset, ratio);
     1595    } while (doAll && ++itr != _glyphs.end());
     1596
     1597    sceneBoundsChanged();
     1598    _needsRedraw = true;
     1599}
     1600
     1601/**
    15631602 * \brief Controls if field data range is normalized to [0,1] before
    15641603 * applying scale factor for the given DataSet
Note: See TracChangeset for help on using the changeset viewer.