Changeset 3168


Ignore:
Timestamp:
Sep 12, 2012, 12:53:57 PM (12 years ago)
Author:
ldelgass
Message:

Protocol for arrow, cone and cylinder

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

Legend:

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

    r3167 r3168  
    397397    void setArcResolution(const DataSetId& id, int res);
    398398
     399    // Arrows
     400
     401    bool addArrow(const DataSetId& id, double tipRadius, double shaftRadius, double tipLength);
     402
     403    void setArrowResolution(const DataSetId& id, int resTip, int resShaft);
     404
     405    // Cones
     406
     407    bool addCone(const DataSetId& id, double radius, double height, bool cap);
     408
     409    void setConeResolution(const DataSetId& id, int res);
     410
    399411    // 2D Contour plots
    400412
     
    441453                              const char *name, double range[2] = NULL);
    442454
     455    // Cylinders
     456
     457    bool addCylinder(const DataSetId& id, double radius, double height, bool cap);
     458
     459    void setCylinderResolution(const DataSetId& id, int res);
     460
    443461    // Disks
    444462
    445     bool addDisk(const DataSetId& id, double innerRadisu, double outerRadius);
     463    bool addDisk(const DataSetId& id, double innerRadius, double outerRadius);
    446464
    447465    void setDiskResolution(const DataSetId& id, int resRadial, int resCircum);
  • trunk/packages/vizservers/vtkvis/RpVtkRendererCmd.cpp

    r3167 r3168  
    322322
    323323    proc = Rappture::GetOpFromObj(interp, nArcOps, arcOps,
     324                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
     325    if (proc == NULL) {
     326        return TCL_ERROR;
     327    }
     328    return (*proc) (clientData, interp, objc, objv);
     329}
     330
     331static int
     332ArrowAddOp(ClientData clientData, Tcl_Interp *interp, int objc,
     333           Tcl_Obj *const *objv)
     334{
     335    double tipRadius, shaftRadius, tipLength;
     336    if (Tcl_GetDoubleFromObj(interp, objv[2], &tipRadius) != TCL_OK ||
     337        Tcl_GetDoubleFromObj(interp, objv[3], &shaftRadius) != TCL_OK ||
     338        Tcl_GetDoubleFromObj(interp, objv[4], &tipLength) != TCL_OK) {
     339        return TCL_ERROR;
     340    }
     341    const char *name = Tcl_GetString(objv[5]);
     342    if (!g_renderer->addArrow(name, tipRadius, shaftRadius, tipLength)) {
     343        Tcl_AppendResult(interp, "Failed to create arrow", (char*)NULL);
     344        return TCL_ERROR;
     345    }
     346    return TCL_OK;
     347}
     348
     349static int
     350ArrowDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc,
     351              Tcl_Obj *const *objv)
     352{
     353    if (objc == 3) {
     354        const char *name = Tcl_GetString(objv[2]);
     355        g_renderer->deleteGraphicsObject<Arrow>(name);
     356    } else {
     357        g_renderer->deleteGraphicsObject<Arrow>("all");
     358    }
     359    return TCL_OK;
     360}
     361
     362static int
     363ArrowColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     364             Tcl_Obj *const *objv)
     365{
     366    float color[3];
     367    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     368        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     369        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     370        return TCL_ERROR;
     371    }
     372    if (objc == 6) {
     373        const char *name = Tcl_GetString(objv[5]);
     374        g_renderer->setGraphicsObjectColor<Arrow>(name, color);
     375    } else {
     376        g_renderer->setGraphicsObjectColor<Arrow>("all", color);
     377    }
     378    return TCL_OK;
     379}
     380
     381static int
     382ArrowEdgeVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     383                      Tcl_Obj *const *objv)
     384{
     385    bool state;
     386    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     387        return TCL_ERROR;
     388    }
     389    if (objc == 4) {
     390        const char *name = Tcl_GetString(objv[3]);
     391        g_renderer->setGraphicsObjectEdgeVisibility<Arrow>(name, state);
     392    } else {
     393        g_renderer->setGraphicsObjectEdgeVisibility<Arrow>("all", state);
     394    }
     395    return TCL_OK;
     396}
     397
     398static int
     399ArrowLightingOp(ClientData clientData, Tcl_Interp *interp, int objc,
     400                Tcl_Obj *const *objv)
     401{
     402    bool state;
     403    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     404        return TCL_ERROR;
     405    }
     406    if (objc == 4) {
     407        const char *name = Tcl_GetString(objv[3]);
     408        g_renderer->setGraphicsObjectLighting<Arrow>(name, state);
     409    } else {
     410        g_renderer->setGraphicsObjectLighting<Arrow>("all", state);
     411    }
     412    return TCL_OK;
     413}
     414
     415static int
     416ArrowLineColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     417                 Tcl_Obj *const *objv)
     418{
     419    float color[3];
     420    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     421        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     422        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     423        return TCL_ERROR;
     424    }
     425    if (objc == 6) {
     426        const char *name = Tcl_GetString(objv[5]);
     427        g_renderer->setGraphicsObjectEdgeColor<Arrow>(name, color);
     428    } else {
     429        g_renderer->setGraphicsObjectEdgeColor<Arrow>("all", color);
     430    }
     431    return TCL_OK;
     432}
     433
     434static int
     435ArrowLineWidthOp(ClientData clientData, Tcl_Interp *interp, int objc,
     436                 Tcl_Obj *const *objv)
     437{
     438    float width;
     439    if (GetFloatFromObj(interp, objv[2], &width) != TCL_OK) {
     440        return TCL_ERROR;
     441    }
     442    if (objc == 4) {
     443        const char *name = Tcl_GetString(objv[3]);
     444        g_renderer->setGraphicsObjectEdgeWidth<Arrow>(name, width);
     445    } else {
     446        g_renderer->setGraphicsObjectEdgeWidth<Arrow>("all", width);
     447    }
     448    return TCL_OK;
     449}
     450
     451static int
     452ArrowMaterialOp(ClientData clientData, Tcl_Interp *interp, int objc,
     453                Tcl_Obj *const *objv)
     454{
     455    double ambient, diffuse, specCoeff, specPower;
     456    if (Tcl_GetDoubleFromObj(interp, objv[2], &ambient) != TCL_OK ||
     457        Tcl_GetDoubleFromObj(interp, objv[3], &diffuse) != TCL_OK ||
     458        Tcl_GetDoubleFromObj(interp, objv[4], &specCoeff) != TCL_OK ||
     459        Tcl_GetDoubleFromObj(interp, objv[5], &specPower) != TCL_OK) {
     460        return TCL_ERROR;
     461    }
     462
     463    if (objc == 7) {
     464        const char *name = Tcl_GetString(objv[6]);
     465        g_renderer->setGraphicsObjectAmbient<Arrow>(name, ambient);
     466        g_renderer->setGraphicsObjectDiffuse<Arrow>(name, diffuse);
     467        g_renderer->setGraphicsObjectSpecular<Arrow>(name, specCoeff, specPower);
     468    } else {
     469        g_renderer->setGraphicsObjectAmbient<Arrow>("all", ambient);
     470        g_renderer->setGraphicsObjectDiffuse<Arrow>("all", diffuse);
     471        g_renderer->setGraphicsObjectSpecular<Arrow>("all", specCoeff, specPower);
     472    }
     473    return TCL_OK;
     474}
     475
     476static int
     477ArrowOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     478               Tcl_Obj *const *objv)
     479{
     480    double opacity;
     481    if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) {
     482        return TCL_ERROR;
     483    }
     484    if (objc == 4) {
     485        const char *name = Tcl_GetString(objv[3]);
     486        g_renderer->setGraphicsObjectOpacity<Arrow>(name, opacity);
     487    } else {
     488        g_renderer->setGraphicsObjectOpacity<Arrow>("all", opacity);
     489    }
     490    return TCL_OK;
     491}
     492
     493static int
     494ArrowOrientOp(ClientData clientData, Tcl_Interp *interp, int objc,
     495              Tcl_Obj *const *objv)
     496{
     497    double quat[4];
     498    if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK ||
     499        Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK ||
     500        Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK ||
     501        Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) {
     502        return TCL_ERROR;
     503    }
     504    if (objc == 7) {
     505        const char *name = Tcl_GetString(objv[6]);
     506        g_renderer->setGraphicsObjectOrientation<Arrow>(name, quat);
     507    } else {
     508        g_renderer->setGraphicsObjectOrientation<Arrow>("all", quat);
     509    }
     510    return TCL_OK;
     511}
     512
     513static int
     514ArrowPositionOp(ClientData clientData, Tcl_Interp *interp, int objc,
     515                Tcl_Obj *const *objv)
     516{
     517    double pos[3];
     518    if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK ||
     519        Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK ||
     520        Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) {
     521        return TCL_ERROR;
     522    }
     523    if (objc == 6) {
     524        const char *name = Tcl_GetString(objv[5]);
     525        g_renderer->setGraphicsObjectPosition<Arrow>(name, pos);
     526    } else {
     527        g_renderer->setGraphicsObjectPosition<Arrow>("all", pos);
     528    }
     529    return TCL_OK;
     530}
     531
     532static int
     533ArrowResolutionOp(ClientData clientData, Tcl_Interp *interp, int objc,
     534                  Tcl_Obj *const *objv)
     535{
     536    int tipRes, shaftRes;
     537    if (Tcl_GetIntFromObj(interp, objv[2], &tipRes) != TCL_OK ||
     538        Tcl_GetIntFromObj(interp, objv[3], &shaftRes) != TCL_OK) {
     539        return TCL_ERROR;
     540    }
     541    if (objc == 4) {
     542        const char *name = Tcl_GetString(objv[4]);
     543        g_renderer->setArrowResolution(name, tipRes, shaftRes);
     544    } else {
     545        g_renderer->setArrowResolution("all", tipRes, shaftRes);
     546    }
     547    return TCL_OK;
     548}
     549
     550static int
     551ArrowScaleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     552             Tcl_Obj *const *objv)
     553{
     554    double scale[3];
     555    if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK ||
     556        Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK ||
     557        Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) {
     558        return TCL_ERROR;
     559    }
     560    if (objc == 6) {
     561        const char *name = Tcl_GetString(objv[5]);
     562        g_renderer->setGraphicsObjectScale<Arrow>(name, scale);
     563    } else {
     564        g_renderer->setGraphicsObjectScale<Arrow>("all", scale);
     565    }
     566    return TCL_OK;
     567}
     568
     569static int
     570ArrowVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     571               Tcl_Obj *const *objv)
     572{
     573    bool state;
     574    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     575        return TCL_ERROR;
     576    }
     577    if (objc == 4) {
     578        const char *name = Tcl_GetString(objv[3]);
     579        g_renderer->setGraphicsObjectVisibility<Arrow>(name, state);
     580    } else {
     581        g_renderer->setGraphicsObjectVisibility<Arrow>("all", state);
     582    }
     583    return TCL_OK;
     584}
     585
     586static int
     587ArrowWireframeOp(ClientData clientData, Tcl_Interp *interp, int objc,
     588                 Tcl_Obj *const *objv)
     589{
     590    bool state;
     591    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     592        return TCL_ERROR;
     593    }
     594    if (objc == 4) {
     595        const char *name = Tcl_GetString(objv[3]);
     596        g_renderer->setGraphicsObjectWireframe<Arrow>(name, state);
     597    } else {
     598        g_renderer->setGraphicsObjectWireframe<Arrow>("all", state);
     599    }
     600    return TCL_OK;
     601}
     602
     603static Rappture::CmdSpec arrowOps[] = {
     604    {"add",       1, ArrowAddOp, 6, 6, "tipRadius shaftRadius tipLength name"},
     605    {"color",     1, ArrowColorOp, 5, 6, "r g b ?name?"},
     606    {"delete",    1, ArrowDeleteOp, 2, 3, "?name?"},
     607    {"edges",     1, ArrowEdgeVisibilityOp, 3, 4, "bool ?name?"},
     608    {"lighting",  3, ArrowLightingOp, 3, 4, "bool ?name?"},
     609    {"linecolor", 5, ArrowLineColorOp, 5, 6, "r g b ?name?"},
     610    {"linewidth", 5, ArrowLineWidthOp, 3, 4, "width ?name?"},
     611    {"material",  1, ArrowMaterialOp, 6, 7, "ambientCoeff diffuseCoeff specularCoeff specularPower ?name?"},
     612    {"opacity",   2, ArrowOpacityOp, 3, 4, "value ?name?"},
     613    {"orient",    2, ArrowOrientOp, 6, 7, "qw qx qy qz ?name?"},
     614    {"pos",       2, ArrowPositionOp, 5, 6, "x y z ?name?"},
     615    {"resolution",1, ArrowResolutionOp, 4, 5, "tipRes shaftRes ?name?"},
     616    {"scale",     1, ArrowScaleOp, 5, 6, "sx sy sz ?name?"},
     617    {"visible",   1, ArrowVisibleOp, 3, 4, "bool ?name?"},
     618    {"wireframe", 1, ArrowWireframeOp, 3, 4, "bool ?name?"}
     619};
     620static int nArrowOps = NumCmdSpecs(arrowOps);
     621
     622static int
     623ArrowCmd(ClientData clientData, Tcl_Interp *interp, int objc,
     624       Tcl_Obj *const *objv)
     625{
     626    Tcl_ObjCmdProc *proc;
     627
     628    proc = Rappture::GetOpFromObj(interp, nArrowOps, arrowOps,
    324629                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
    325630    if (proc == NULL) {
     
    11811486
    11821487static int
     1488ConeAddOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1489          Tcl_Obj *const *objv)
     1490{
     1491    double radius, height;
     1492    bool cap;
     1493    if (Tcl_GetDoubleFromObj(interp, objv[2], &radius) != TCL_OK ||
     1494        Tcl_GetDoubleFromObj(interp, objv[3], &height) != TCL_OK ||
     1495        GetBooleanFromObj(interp, objv[4], &cap) != TCL_OK) {
     1496        return TCL_ERROR;
     1497    }
     1498    const char *name = Tcl_GetString(objv[5]);
     1499    if (!g_renderer->addCone(name, radius, height, cap)) {
     1500        Tcl_AppendResult(interp, "Failed to create cone", (char*)NULL);
     1501        return TCL_ERROR;
     1502    }
     1503    return TCL_OK;
     1504}
     1505
     1506static int
     1507ConeDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1508             Tcl_Obj *const *objv)
     1509{
     1510    if (objc == 3) {
     1511        const char *name = Tcl_GetString(objv[2]);
     1512        g_renderer->deleteGraphicsObject<Cone>(name);
     1513    } else {
     1514        g_renderer->deleteGraphicsObject<Cone>("all");
     1515    }
     1516    return TCL_OK;
     1517}
     1518
     1519static int
     1520ConeColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1521            Tcl_Obj *const *objv)
     1522{
     1523    float color[3];
     1524    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     1525        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     1526        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     1527        return TCL_ERROR;
     1528    }
     1529    if (objc == 6) {
     1530        const char *name = Tcl_GetString(objv[5]);
     1531        g_renderer->setGraphicsObjectColor<Cone>(name, color);
     1532    } else {
     1533        g_renderer->setGraphicsObjectColor<Cone>("all", color);
     1534    }
     1535    return TCL_OK;
     1536}
     1537
     1538static int
     1539ConeEdgeVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1540                     Tcl_Obj *const *objv)
     1541{
     1542    bool state;
     1543    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     1544        return TCL_ERROR;
     1545    }
     1546    if (objc == 4) {
     1547        const char *name = Tcl_GetString(objv[3]);
     1548        g_renderer->setGraphicsObjectEdgeVisibility<Cone>(name, state);
     1549    } else {
     1550        g_renderer->setGraphicsObjectEdgeVisibility<Cone>("all", state);
     1551    }
     1552    return TCL_OK;
     1553}
     1554
     1555static int
     1556ConeLightingOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1557               Tcl_Obj *const *objv)
     1558{
     1559    bool state;
     1560    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     1561        return TCL_ERROR;
     1562    }
     1563    if (objc == 4) {
     1564        const char *name = Tcl_GetString(objv[3]);
     1565        g_renderer->setGraphicsObjectLighting<Cone>(name, state);
     1566    } else {
     1567        g_renderer->setGraphicsObjectLighting<Cone>("all", state);
     1568    }
     1569    return TCL_OK;
     1570}
     1571
     1572static int
     1573ConeLineColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1574                Tcl_Obj *const *objv)
     1575{
     1576    float color[3];
     1577    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     1578        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     1579        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     1580        return TCL_ERROR;
     1581    }
     1582    if (objc == 6) {
     1583        const char *name = Tcl_GetString(objv[5]);
     1584        g_renderer->setGraphicsObjectEdgeColor<Cone>(name, color);
     1585    } else {
     1586        g_renderer->setGraphicsObjectEdgeColor<Cone>("all", color);
     1587    }
     1588    return TCL_OK;
     1589}
     1590
     1591static int
     1592ConeLineWidthOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1593                Tcl_Obj *const *objv)
     1594{
     1595    float width;
     1596    if (GetFloatFromObj(interp, objv[2], &width) != TCL_OK) {
     1597        return TCL_ERROR;
     1598    }
     1599    if (objc == 4) {
     1600        const char *name = Tcl_GetString(objv[3]);
     1601        g_renderer->setGraphicsObjectEdgeWidth<Cone>(name, width);
     1602    } else {
     1603        g_renderer->setGraphicsObjectEdgeWidth<Cone>("all", width);
     1604    }
     1605    return TCL_OK;
     1606}
     1607
     1608static int
     1609ConeMaterialOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1610               Tcl_Obj *const *objv)
     1611{
     1612    double ambient, diffuse, specCoeff, specPower;
     1613    if (Tcl_GetDoubleFromObj(interp, objv[2], &ambient) != TCL_OK ||
     1614        Tcl_GetDoubleFromObj(interp, objv[3], &diffuse) != TCL_OK ||
     1615        Tcl_GetDoubleFromObj(interp, objv[4], &specCoeff) != TCL_OK ||
     1616        Tcl_GetDoubleFromObj(interp, objv[5], &specPower) != TCL_OK) {
     1617        return TCL_ERROR;
     1618    }
     1619
     1620    if (objc == 7) {
     1621        const char *name = Tcl_GetString(objv[6]);
     1622        g_renderer->setGraphicsObjectAmbient<Cone>(name, ambient);
     1623        g_renderer->setGraphicsObjectDiffuse<Cone>(name, diffuse);
     1624        g_renderer->setGraphicsObjectSpecular<Cone>(name, specCoeff, specPower);
     1625    } else {
     1626        g_renderer->setGraphicsObjectAmbient<Cone>("all", ambient);
     1627        g_renderer->setGraphicsObjectDiffuse<Cone>("all", diffuse);
     1628        g_renderer->setGraphicsObjectSpecular<Cone>("all", specCoeff, specPower);
     1629    }
     1630    return TCL_OK;
     1631}
     1632
     1633static int
     1634ConeOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1635              Tcl_Obj *const *objv)
     1636{
     1637    double opacity;
     1638    if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) {
     1639        return TCL_ERROR;
     1640    }
     1641    if (objc == 4) {
     1642        const char *name = Tcl_GetString(objv[3]);
     1643        g_renderer->setGraphicsObjectOpacity<Cone>(name, opacity);
     1644    } else {
     1645        g_renderer->setGraphicsObjectOpacity<Cone>("all", opacity);
     1646    }
     1647    return TCL_OK;
     1648}
     1649
     1650static int
     1651ConeOrientOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1652             Tcl_Obj *const *objv)
     1653{
     1654    double quat[4];
     1655    if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK ||
     1656        Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK ||
     1657        Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK ||
     1658        Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) {
     1659        return TCL_ERROR;
     1660    }
     1661    if (objc == 7) {
     1662        const char *name = Tcl_GetString(objv[6]);
     1663        g_renderer->setGraphicsObjectOrientation<Cone>(name, quat);
     1664    } else {
     1665        g_renderer->setGraphicsObjectOrientation<Cone>("all", quat);
     1666    }
     1667    return TCL_OK;
     1668}
     1669
     1670static int
     1671ConePositionOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1672               Tcl_Obj *const *objv)
     1673{
     1674    double pos[3];
     1675    if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK ||
     1676        Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK ||
     1677        Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) {
     1678        return TCL_ERROR;
     1679    }
     1680    if (objc == 6) {
     1681        const char *name = Tcl_GetString(objv[5]);
     1682        g_renderer->setGraphicsObjectPosition<Cone>(name, pos);
     1683    } else {
     1684        g_renderer->setGraphicsObjectPosition<Cone>("all", pos);
     1685    }
     1686    return TCL_OK;
     1687}
     1688
     1689static int
     1690ConeResolutionOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1691                 Tcl_Obj *const *objv)
     1692{
     1693    int res;
     1694    if (Tcl_GetIntFromObj(interp, objv[2], &res) != TCL_OK) {
     1695        return TCL_ERROR;
     1696    }
     1697    if (objc == 4) {
     1698        const char *name = Tcl_GetString(objv[3]);
     1699        g_renderer->setConeResolution(name, res);
     1700    } else {
     1701        g_renderer->setConeResolution("all", res);
     1702    }
     1703    return TCL_OK;
     1704}
     1705
     1706static int
     1707ConeScaleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1708            Tcl_Obj *const *objv)
     1709{
     1710    double scale[3];
     1711    if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK ||
     1712        Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK ||
     1713        Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) {
     1714        return TCL_ERROR;
     1715    }
     1716    if (objc == 6) {
     1717        const char *name = Tcl_GetString(objv[5]);
     1718        g_renderer->setGraphicsObjectScale<Cone>(name, scale);
     1719    } else {
     1720        g_renderer->setGraphicsObjectScale<Cone>("all", scale);
     1721    }
     1722    return TCL_OK;
     1723}
     1724
     1725static int
     1726ConeVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1727              Tcl_Obj *const *objv)
     1728{
     1729    bool state;
     1730    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     1731        return TCL_ERROR;
     1732    }
     1733    if (objc == 4) {
     1734        const char *name = Tcl_GetString(objv[3]);
     1735        g_renderer->setGraphicsObjectVisibility<Cone>(name, state);
     1736    } else {
     1737        g_renderer->setGraphicsObjectVisibility<Cone>("all", state);
     1738    }
     1739    return TCL_OK;
     1740}
     1741
     1742static int
     1743ConeWireframeOp(ClientData clientData, Tcl_Interp *interp, int objc,
     1744                Tcl_Obj *const *objv)
     1745{
     1746    bool state;
     1747    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     1748        return TCL_ERROR;
     1749    }
     1750    if (objc == 4) {
     1751        const char *name = Tcl_GetString(objv[3]);
     1752        g_renderer->setGraphicsObjectWireframe<Cone>(name, state);
     1753    } else {
     1754        g_renderer->setGraphicsObjectWireframe<Cone>("all", state);
     1755    }
     1756    return TCL_OK;
     1757}
     1758
     1759static Rappture::CmdSpec coneOps[] = {
     1760    {"add",       1, ConeAddOp, 6, 6, "radius height cap name"},
     1761    {"color",     1, ConeColorOp, 5, 6, "r g b ?name?"},
     1762    {"delete",    1, ConeDeleteOp, 2, 3, "?name?"},
     1763    {"edges",     1, ConeEdgeVisibilityOp, 3, 4, "bool ?name?"},
     1764    {"lighting",  3, ConeLightingOp, 3, 4, "bool ?name?"},
     1765    {"linecolor", 5, ConeLineColorOp, 5, 6, "r g b ?name?"},
     1766    {"linewidth", 5, ConeLineWidthOp, 3, 4, "width ?name?"},
     1767    {"material",  1, ConeMaterialOp, 6, 7, "ambientCoeff diffuseCoeff specularCoeff specularPower ?name?"},
     1768    {"opacity",   2, ConeOpacityOp, 3, 4, "value ?name?"},
     1769    {"orient",    2, ConeOrientOp, 6, 7, "qw qx qy qz ?name?"},
     1770    {"pos",       2, ConePositionOp, 5, 6, "x y z ?name?"},
     1771    {"resolution",1, ConeResolutionOp, 3, 4, "res ?name?"},
     1772    {"scale",     1, ConeScaleOp, 5, 6, "sx sy sz ?name?"},
     1773    {"visible",   1, ConeVisibleOp, 3, 4, "bool ?name?"},
     1774    {"wireframe", 1, ConeWireframeOp, 3, 4, "bool ?name?"}
     1775};
     1776static int nConeOps = NumCmdSpecs(coneOps);
     1777
     1778static int
     1779ConeCmd(ClientData clientData, Tcl_Interp *interp, int objc,
     1780       Tcl_Obj *const *objv)
     1781{
     1782    Tcl_ObjCmdProc *proc;
     1783
     1784    proc = Rappture::GetOpFromObj(interp, nConeOps, coneOps,
     1785                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
     1786    if (proc == NULL) {
     1787        return TCL_ERROR;
     1788    }
     1789    return (*proc) (clientData, interp, objc, objv);
     1790}
     1791
     1792static int
    11831793Contour2DAddContourListOp(ClientData clientData, Tcl_Interp *interp, int objc,
    11841794                          Tcl_Obj *const *objv)
     
    22172827
    22182828    proc = Rappture::GetOpFromObj(interp, nCutplaneOps, cutplaneOps,
     2829                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
     2830    if (proc == NULL) {
     2831        return TCL_ERROR;
     2832    }
     2833    return (*proc) (clientData, interp, objc, objv);
     2834}
     2835
     2836static int
     2837CylinderAddOp(ClientData clientData, Tcl_Interp *interp, int objc,
     2838              Tcl_Obj *const *objv)
     2839{
     2840    double radius, height;
     2841    bool cap = true;
     2842    if (Tcl_GetDoubleFromObj(interp, objv[2], &radius) != TCL_OK ||
     2843        Tcl_GetDoubleFromObj(interp, objv[3], &height) != TCL_OK ||
     2844        GetBooleanFromObj(interp, objv[4], &cap) != TCL_OK) {
     2845        return TCL_ERROR;
     2846    }
     2847    const char *name = Tcl_GetString(objv[5]);
     2848    if (!g_renderer->addCylinder(name, radius, height, cap)) {
     2849        Tcl_AppendResult(interp, "Failed to create cylinder", (char*)NULL);
     2850        return TCL_ERROR;
     2851    }
     2852    return TCL_OK;
     2853}
     2854
     2855static int
     2856CylinderDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc,
     2857                 Tcl_Obj *const *objv)
     2858{
     2859    if (objc == 3) {
     2860        const char *name = Tcl_GetString(objv[2]);
     2861        g_renderer->deleteGraphicsObject<Cylinder>(name);
     2862    } else {
     2863        g_renderer->deleteGraphicsObject<Cylinder>("all");
     2864    }
     2865    return TCL_OK;
     2866}
     2867
     2868static int
     2869CylinderColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     2870                Tcl_Obj *const *objv)
     2871{
     2872    float color[3];
     2873    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     2874        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     2875        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     2876        return TCL_ERROR;
     2877    }
     2878    if (objc == 6) {
     2879        const char *name = Tcl_GetString(objv[5]);
     2880        g_renderer->setGraphicsObjectColor<Cylinder>(name, color);
     2881    } else {
     2882        g_renderer->setGraphicsObjectColor<Cylinder>("all", color);
     2883    }
     2884    return TCL_OK;
     2885}
     2886
     2887static int
     2888CylinderEdgeVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     2889                         Tcl_Obj *const *objv)
     2890{
     2891    bool state;
     2892    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     2893        return TCL_ERROR;
     2894    }
     2895    if (objc == 4) {
     2896        const char *name = Tcl_GetString(objv[3]);
     2897        g_renderer->setGraphicsObjectEdgeVisibility<Cylinder>(name, state);
     2898    } else {
     2899        g_renderer->setGraphicsObjectEdgeVisibility<Cylinder>("all", state);
     2900    }
     2901    return TCL_OK;
     2902}
     2903
     2904static int
     2905CylinderLightingOp(ClientData clientData, Tcl_Interp *interp, int objc,
     2906                   Tcl_Obj *const *objv)
     2907{
     2908    bool state;
     2909    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     2910        return TCL_ERROR;
     2911    }
     2912    if (objc == 4) {
     2913        const char *name = Tcl_GetString(objv[3]);
     2914        g_renderer->setGraphicsObjectLighting<Cylinder>(name, state);
     2915    } else {
     2916        g_renderer->setGraphicsObjectLighting<Cylinder>("all", state);
     2917    }
     2918    return TCL_OK;
     2919}
     2920
     2921static int
     2922CylinderLineColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     2923                    Tcl_Obj *const *objv)
     2924{
     2925    float color[3];
     2926    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     2927        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     2928        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     2929        return TCL_ERROR;
     2930    }
     2931    if (objc == 6) {
     2932        const char *name = Tcl_GetString(objv[5]);
     2933        g_renderer->setGraphicsObjectEdgeColor<Cylinder>(name, color);
     2934    } else {
     2935        g_renderer->setGraphicsObjectEdgeColor<Cylinder>("all", color);
     2936    }
     2937    return TCL_OK;
     2938}
     2939
     2940static int
     2941CylinderLineWidthOp(ClientData clientData, Tcl_Interp *interp, int objc,
     2942                    Tcl_Obj *const *objv)
     2943{
     2944    float width;
     2945    if (GetFloatFromObj(interp, objv[2], &width) != TCL_OK) {
     2946        return TCL_ERROR;
     2947    }
     2948    if (objc == 4) {
     2949        const char *name = Tcl_GetString(objv[3]);
     2950        g_renderer->setGraphicsObjectEdgeWidth<Cylinder>(name, width);
     2951    } else {
     2952        g_renderer->setGraphicsObjectEdgeWidth<Cylinder>("all", width);
     2953    }
     2954    return TCL_OK;
     2955}
     2956
     2957static int
     2958CylinderMaterialOp(ClientData clientData, Tcl_Interp *interp, int objc,
     2959                   Tcl_Obj *const *objv)
     2960{
     2961    double ambient, diffuse, specCoeff, specPower;
     2962    if (Tcl_GetDoubleFromObj(interp, objv[2], &ambient) != TCL_OK ||
     2963        Tcl_GetDoubleFromObj(interp, objv[3], &diffuse) != TCL_OK ||
     2964        Tcl_GetDoubleFromObj(interp, objv[4], &specCoeff) != TCL_OK ||
     2965        Tcl_GetDoubleFromObj(interp, objv[5], &specPower) != TCL_OK) {
     2966        return TCL_ERROR;
     2967    }
     2968
     2969    if (objc == 7) {
     2970        const char *name = Tcl_GetString(objv[6]);
     2971        g_renderer->setGraphicsObjectAmbient<Cylinder>(name, ambient);
     2972        g_renderer->setGraphicsObjectDiffuse<Cylinder>(name, diffuse);
     2973        g_renderer->setGraphicsObjectSpecular<Cylinder>(name, specCoeff, specPower);
     2974    } else {
     2975        g_renderer->setGraphicsObjectAmbient<Cylinder>("all", ambient);
     2976        g_renderer->setGraphicsObjectDiffuse<Cylinder>("all", diffuse);
     2977        g_renderer->setGraphicsObjectSpecular<Cylinder>("all", specCoeff, specPower);
     2978    }
     2979    return TCL_OK;
     2980}
     2981
     2982static int
     2983CylinderOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc,
     2984                  Tcl_Obj *const *objv)
     2985{
     2986    double opacity;
     2987    if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) {
     2988        return TCL_ERROR;
     2989    }
     2990    if (objc == 4) {
     2991        const char *name = Tcl_GetString(objv[3]);
     2992        g_renderer->setGraphicsObjectOpacity<Cylinder>(name, opacity);
     2993    } else {
     2994        g_renderer->setGraphicsObjectOpacity<Cylinder>("all", opacity);
     2995    }
     2996    return TCL_OK;
     2997}
     2998
     2999static int
     3000CylinderOrientOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3001                 Tcl_Obj *const *objv)
     3002{
     3003    double quat[4];
     3004    if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK ||
     3005        Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK ||
     3006        Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK ||
     3007        Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) {
     3008        return TCL_ERROR;
     3009    }
     3010    if (objc == 7) {
     3011        const char *name = Tcl_GetString(objv[6]);
     3012        g_renderer->setGraphicsObjectOrientation<Cylinder>(name, quat);
     3013    } else {
     3014        g_renderer->setGraphicsObjectOrientation<Cylinder>("all", quat);
     3015    }
     3016    return TCL_OK;
     3017}
     3018
     3019static int
     3020CylinderPositionOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3021                   Tcl_Obj *const *objv)
     3022{
     3023    double pos[3];
     3024    if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK ||
     3025        Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK ||
     3026        Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) {
     3027        return TCL_ERROR;
     3028    }
     3029    if (objc == 6) {
     3030        const char *name = Tcl_GetString(objv[5]);
     3031        g_renderer->setGraphicsObjectPosition<Cylinder>(name, pos);
     3032    } else {
     3033        g_renderer->setGraphicsObjectPosition<Cylinder>("all", pos);
     3034    }
     3035    return TCL_OK;
     3036}
     3037
     3038static int
     3039CylinderResolutionOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3040                     Tcl_Obj *const *objv)
     3041{
     3042    int res;
     3043    if (Tcl_GetIntFromObj(interp, objv[2], &res) != TCL_OK) {
     3044        return TCL_ERROR;
     3045    }
     3046    if (objc == 4) {
     3047        const char *name = Tcl_GetString(objv[3]);
     3048        g_renderer->setCylinderResolution(name, res);
     3049    } else {
     3050        g_renderer->setCylinderResolution("all", res);
     3051    }
     3052    return TCL_OK;
     3053}
     3054
     3055static int
     3056CylinderScaleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3057                Tcl_Obj *const *objv)
     3058{
     3059    double scale[3];
     3060    if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK ||
     3061        Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK ||
     3062        Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) {
     3063        return TCL_ERROR;
     3064    }
     3065    if (objc == 6) {
     3066        const char *name = Tcl_GetString(objv[5]);
     3067        g_renderer->setGraphicsObjectScale<Cylinder>(name, scale);
     3068    } else {
     3069        g_renderer->setGraphicsObjectScale<Cylinder>("all", scale);
     3070    }
     3071    return TCL_OK;
     3072}
     3073
     3074static int
     3075CylinderVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3076                  Tcl_Obj *const *objv)
     3077{
     3078    bool state;
     3079    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     3080        return TCL_ERROR;
     3081    }
     3082    if (objc == 4) {
     3083        const char *name = Tcl_GetString(objv[3]);
     3084        g_renderer->setGraphicsObjectVisibility<Cylinder>(name, state);
     3085    } else {
     3086        g_renderer->setGraphicsObjectVisibility<Cylinder>("all", state);
     3087    }
     3088    return TCL_OK;
     3089}
     3090
     3091static int
     3092CylinderWireframeOp(ClientData clientData, Tcl_Interp *interp, int objc,
     3093                    Tcl_Obj *const *objv)
     3094{
     3095    bool state;
     3096    if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) {
     3097        return TCL_ERROR;
     3098    }
     3099    if (objc == 4) {
     3100        const char *name = Tcl_GetString(objv[3]);
     3101        g_renderer->setGraphicsObjectWireframe<Cylinder>(name, state);
     3102    } else {
     3103        g_renderer->setGraphicsObjectWireframe<Cylinder>("all", state);
     3104    }
     3105    return TCL_OK;
     3106}
     3107
     3108static Rappture::CmdSpec cylinderOps[] = {
     3109    {"add",       1, CylinderAddOp, 6, 6, " radius height cap name"},
     3110    {"color",     1, CylinderColorOp, 5, 6, "r g b ?name?"},
     3111    {"delete",    1, CylinderDeleteOp, 2, 3, "?name?"},
     3112    {"edges",     1, CylinderEdgeVisibilityOp, 3, 4, "bool ?name?"},
     3113    {"lighting",  3, CylinderLightingOp, 3, 4, "bool ?name?"},
     3114    {"linecolor", 5, CylinderLineColorOp, 5, 6, "r g b ?name?"},
     3115    {"linewidth", 5, CylinderLineWidthOp, 3, 4, "width ?name?"},
     3116    {"material",  1, CylinderMaterialOp, 6, 7, "ambientCoeff diffuseCoeff specularCoeff specularPower ?name?"},
     3117    {"opacity",   2, CylinderOpacityOp, 3, 4, "value ?name?"},
     3118    {"orient",    2, CylinderOrientOp, 6, 7, "qw qx qy qz ?name?"},
     3119    {"pos",       2, CylinderPositionOp, 5, 6, "x y z ?name?"},
     3120    {"resolution",1, CylinderResolutionOp, 3, 4, "res ?name?"},
     3121    {"scale",     1, CylinderScaleOp, 5, 6, "sx sy sz ?name?"},
     3122    {"visible",   1, CylinderVisibleOp, 3, 4, "bool ?name?"},
     3123    {"wireframe", 1, CylinderWireframeOp, 3, 4, "bool ?name?"}
     3124};
     3125static int nCylinderOps = NumCmdSpecs(cylinderOps);
     3126
     3127static int
     3128CylinderCmd(ClientData clientData, Tcl_Interp *interp, int objc,
     3129       Tcl_Obj *const *objv)
     3130{
     3131    Tcl_ObjCmdProc *proc;
     3132
     3133    proc = Rappture::GetOpFromObj(interp, nCylinderOps, cylinderOps,
    22193134                                  Rappture::CMDSPEC_ARG1, objc, objv, 0);
    22203135    if (proc == NULL) {
     
    77328647    Tcl_MakeSafe(interp);
    77338648    Tcl_CreateObjCommand(interp, "arc",         ArcCmd,         clientData, NULL);
     8649    Tcl_CreateObjCommand(interp, "arrow",       ArrowCmd,       clientData, NULL);
    77348650    Tcl_CreateObjCommand(interp, "axis",        AxisCmd,        clientData, NULL);
    77358651    Tcl_CreateObjCommand(interp, "box",         BoxCmd,         clientData, NULL);
    77368652    Tcl_CreateObjCommand(interp, "camera",      CameraCmd,      clientData, NULL);
    77378653    Tcl_CreateObjCommand(interp, "colormap",    ColorMapCmd,    clientData, NULL);
     8654    Tcl_CreateObjCommand(interp, "cone",        ConeCmd,        clientData, NULL);
    77388655    Tcl_CreateObjCommand(interp, "contour2d",   Contour2DCmd,   clientData, NULL);
    77398656    Tcl_CreateObjCommand(interp, "contour3d",   Contour3DCmd,   clientData, NULL);
    77408657    Tcl_CreateObjCommand(interp, "cutplane",    CutplaneCmd,    clientData, NULL);
     8658    Tcl_CreateObjCommand(interp, "cylinder",    CylinderCmd,    clientData, NULL);
    77418659    Tcl_CreateObjCommand(interp, "dataset",     DataSetCmd,     clientData, NULL);
    77428660    Tcl_CreateObjCommand(interp, "disk",        DiskCmd,        clientData, NULL);
     
    77658683{
    77668684    Tcl_DeleteCommand(interp, "arc");
     8685    Tcl_DeleteCommand(interp, "arrow");
    77678686    Tcl_DeleteCommand(interp, "axis");
    77688687    Tcl_DeleteCommand(interp, "box");
    77698688    Tcl_DeleteCommand(interp, "camera");
    77708689    Tcl_DeleteCommand(interp, "colormap");
     8690    Tcl_DeleteCommand(interp, "cone");
    77718691    Tcl_DeleteCommand(interp, "contour2d");
    77728692    Tcl_DeleteCommand(interp, "contour3d");
    77738693    Tcl_DeleteCommand(interp, "cutplane");
     8694    Tcl_DeleteCommand(interp, "cylinder");
    77748695    Tcl_DeleteCommand(interp, "dataset");
    77758696    Tcl_DeleteCommand(interp, "disk");
  • trunk/packages/vizservers/vtkvis/RpVtkRendererGraphicsObjs.cpp

    r3167 r3168  
    325325
    326326/**
     327 * \brief Create a new Arrow and associate it with an ID
     328 */
     329bool Renderer::addArrow(const DataSetId& id, double tipRadius, double shaftRadius, double tipLength)
     330{
     331    Arrow *gobj;
     332    if ((gobj = getGraphicsObject<Arrow>(id)) != NULL) {
     333        WARN("Replacing existing %s %s", gobj->getClassName(), id.c_str());
     334        deleteGraphicsObject<Arrow>(id);
     335    }
     336
     337    gobj = new Arrow();
     338 
     339    gobj->setDataSet(NULL, this);
     340
     341    if (gobj->getProp() == NULL &&
     342        gobj->getOverlayProp() == NULL) {
     343        delete gobj;
     344        return false;
     345    } else {
     346        if (gobj->getProp())
     347            _renderer->AddViewProp(gobj->getProp());
     348        if (gobj->getOverlayProp())
     349            _renderer->AddViewProp(gobj->getOverlayProp());
     350    }
     351
     352    gobj->setRadii(tipRadius, shaftRadius);
     353    gobj->setTipLength(tipLength);
     354
     355    getGraphicsObjectHashmap<Arrow>()[id] = gobj;
     356
     357    initCamera();
     358    _needsRedraw = true;
     359    return true;
     360}
     361
     362/**
     363 * \brief Set Arrow resolution
     364 */
     365void Renderer::setArrowResolution(const DataSetId& id, int tipRes, int shaftRes)
     366{
     367    ArrowHashmap::iterator itr;
     368
     369    bool doAll = false;
     370
     371    if (id.compare("all") == 0) {
     372        itr = _arrows.begin();
     373        doAll = true;
     374    } else {
     375        itr = _arrows.find(id);
     376    }
     377    if (itr == _arrows.end()) {
     378        ERROR("Arrow not found: %s", id.c_str());
     379        return;
     380    }
     381
     382    do {
     383        itr->second->setResolution(tipRes, shaftRes);
     384    } while (doAll && ++itr != _arrows.end());
     385
     386    _needsRedraw = true;
     387}
     388
     389/**
     390 * \brief Create a new Cone and associate it with an ID
     391 */
     392bool Renderer::addCone(const DataSetId& id, double radius, double height, bool cap)
     393{
     394    Cone *gobj;
     395    if ((gobj = getGraphicsObject<Cone>(id)) != NULL) {
     396        WARN("Replacing existing %s %s", gobj->getClassName(), id.c_str());
     397        deleteGraphicsObject<Cone>(id);
     398    }
     399
     400    gobj = new Cone();
     401 
     402    gobj->setDataSet(NULL, this);
     403
     404    if (gobj->getProp() == NULL &&
     405        gobj->getOverlayProp() == NULL) {
     406        delete gobj;
     407        return false;
     408    } else {
     409        if (gobj->getProp())
     410            _renderer->AddViewProp(gobj->getProp());
     411        if (gobj->getOverlayProp())
     412            _renderer->AddViewProp(gobj->getOverlayProp());
     413    }
     414
     415    gobj->setRadius(radius);
     416    gobj->setHeight(height);
     417    gobj->setCapping(cap);
     418
     419    getGraphicsObjectHashmap<Cone>()[id] = gobj;
     420
     421    initCamera();
     422    _needsRedraw = true;
     423    return true;
     424}
     425
     426/**
     427 * \brief Set Cone resolution
     428 */
     429void Renderer::setConeResolution(const DataSetId& id, int res)
     430{
     431    ConeHashmap::iterator itr;
     432
     433    bool doAll = false;
     434
     435    if (id.compare("all") == 0) {
     436        itr = _cones.begin();
     437        doAll = true;
     438    } else {
     439        itr = _cones.find(id);
     440    }
     441    if (itr == _cones.end()) {
     442        ERROR("Cone not found: %s", id.c_str());
     443        return;
     444    }
     445
     446    do {
     447        itr->second->setResolution(res);
     448    } while (doAll && ++itr != _cones.end());
     449
     450    _needsRedraw = true;
     451}
     452
     453/**
    327454 * \brief Create a new Contour2D and associate it with the named DataSet
    328455 */
     
    797924        itr->second->setColorMode(mode, name, range);
    798925    } while (doAll && ++itr != _cutplanes.end());
     926
     927    _needsRedraw = true;
     928}
     929
     930/**
     931 * \brief Create a new Cylinder and associate it with an ID
     932 */
     933bool Renderer::addCylinder(const DataSetId& id, double radius, double height, bool cap)
     934{
     935    Cylinder *gobj;
     936    if ((gobj = getGraphicsObject<Cylinder>(id)) != NULL) {
     937        WARN("Replacing existing %s %s", gobj->getClassName(), id.c_str());
     938        deleteGraphicsObject<Cylinder>(id);
     939    }
     940
     941    gobj = new Cylinder();
     942 
     943    gobj->setDataSet(NULL, this);
     944
     945    if (gobj->getProp() == NULL &&
     946        gobj->getOverlayProp() == NULL) {
     947        delete gobj;
     948        return false;
     949    } else {
     950        if (gobj->getProp())
     951            _renderer->AddViewProp(gobj->getProp());
     952        if (gobj->getOverlayProp())
     953            _renderer->AddViewProp(gobj->getOverlayProp());
     954    }
     955
     956    gobj->setRadius(radius);
     957    gobj->setHeight(height);
     958    gobj->setCapping(cap);
     959
     960    getGraphicsObjectHashmap<Cylinder>()[id] = gobj;
     961
     962    initCamera();
     963    _needsRedraw = true;
     964    return true;
     965}
     966
     967/**
     968 * \brief Set Cylinder resolution
     969 */
     970void Renderer::setCylinderResolution(const DataSetId& id, int res)
     971{
     972    CylinderHashmap::iterator itr;
     973
     974    bool doAll = false;
     975
     976    if (id.compare("all") == 0) {
     977        itr = _cylinders.begin();
     978        doAll = true;
     979    } else {
     980        itr = _cylinders.find(id);
     981    }
     982    if (itr == _cylinders.end()) {
     983        ERROR("Cylinder not found: %s", id.c_str());
     984        return;
     985    }
     986
     987    do {
     988        itr->second->setResolution(res);
     989    } while (doAll && ++itr != _cylinders.end());
    799990
    800991    _needsRedraw = true;
     
    13981589}
    13991590
     1591/**
     1592 * \brief Create a new Line and associate it with an ID
     1593 */
    14001594bool Renderer::addLine(const DataSetId& id, double pt1[3], double pt2[3])
    14011595{
     
    17301924}
    17311925
     1926/**
     1927 * \brief Create a new n-sided regular Polygon and associate it with an ID
     1928 */
    17321929bool Renderer::addPolygon(const DataSetId& id, int numSides)
    17331930{
  • trunk/packages/vizservers/vtkvis/protocol.txt

    r3167 r3168  
    141141arc visible <bool> <?name?>
    142142
     143arrow add <tipRadius> <shaftRadius> <tipLength> <name>
     144      Arrow will have base at 0,0,0 and tip at 1, 0, 0
     145arrow color <r> <g> <b> <?name?>
     146arrow delete <?name?>
     147arrow edges <bool> <?name?>
     148arrow lighting <bool> <?name?>
     149arrow linecolor <r> <g> <b> <?name?>
     150arrow linewidth <val> <?name?>
     151arrow material <ambientCoeff> <diffuseCoeff> <specularCoeff> <specularExp> <?name?>
     152arrow opacity <val> <?name?>
     153arrow orient <qw> <qx> <qy> <qz> <?name?>
     154arrow pos <x> <y> <z> <?name?>
     155arrow resolution <tipRes> <shaftRes> <?name?>
     156arrow scale <sx> <sy> <sz> <?name?>
     157arrow visible <bool> <?name?>
     158arrow wireframe <bool> <?name?>
     159
    143160box add <name>
    144161box color <r> <g> <b> <?name?>
     
    155172box visible <bool> <?name?>
    156173box wireframe <bool> <?name?>
     174
     175cone add <radius> <height> <cap> <name>
     176     <cap> = boolean flag for cap disks
     177cone color <r> <g> <b> <?name?>
     178cone delete <?name?>
     179cone edges <bool> <?name?>
     180cone lighting <bool> <?name?>
     181cone linecolor <r> <g> <b> <?name?>
     182cone linewidth <val> <?name?>
     183cone material <ambientCoeff> <diffuseCoeff> <specularCoeff> <specularExp> <?name?>
     184cone opacity <val> <?name?>
     185cone orient <qw> <qx> <qy> <qz> <?name?>
     186cone pos <x> <y> <z> <?name?>
     187cone resolution <res> <?name?>
     188cone scale <sx> <sy> <sz> <?name?>
     189cone visible <bool> <?name?>
     190cone wireframe <bool> <?name?>
    157191
    158192contour2d add numcontours <n> <?datasetName?>
     
    227261cutplane visible <bool> <?dataSetName?>
    228262cutplane wireframe <bool> <?datasetName?>
     263
     264cylinder add <radius> <height> <cap> <name>
     265         <cap> = boolean flag for cap disks
     266cylinder color <r> <g> <b> <?name?>
     267cylinder delete <?name?>
     268cylinder edges <bool> <?name?>
     269cylinder lighting <bool> <?name?>
     270cylinder linecolor <r> <g> <b> <?name?>
     271cylinder linewidth <val> <?name?>
     272cylinder material <ambientCoeff> <diffuseCoeff> <specularCoeff> <specularExp> <?name?>
     273cylinder opacity <val> <?name?>
     274cylinder orient <qw> <qx> <qy> <qz> <?name?>
     275cylinder pos <x> <y> <z> <?name?>
     276cylinder resolution <res> <?name?>
     277cylinder scale <sx> <sy> <sz> <?name?>
     278cylinder visible <bool> <?name?>
     279cylinder wireframe <bool> <?name?>
    229280
    230281disk add <innerRadius> <outerRadius> <name>
Note: See TracChangeset for help on using the changeset viewer.