Changeset 3221 for branches


Ignore:
Timestamp:
Dec 21, 2012, 1:09:54 PM (12 years ago)
Author:
ldelgass
Message:

Add protocol to control axis title/label fonts and format (some require fixes
in VTK to function)

Location:
branches/Rappture 1.2/packages/vizservers/vtkvis
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/Rappture 1.2/packages/vizservers/vtkvis/RpTypes.h

    r3177 r3221  
    1313
    1414    enum Axis {
    15         X_AXIS,
     15        X_AXIS = 0,
    1616        Y_AXIS,
    1717        Z_AXIS
     
    1919
    2020    enum PrincipalPlane {
    21         PLANE_XY,
     21        PLANE_XY = 0,
    2222        PLANE_ZY,
    2323        PLANE_XZ
  • branches/Rappture 1.2/packages/vizservers/vtkvis/RpVtkRenderer.cpp

    r3220 r3221  
    102102        _activeClipPlanes->AddItem(_cameraClipPlanes[3]);
    103103    _renderer = vtkSmartPointer<vtkRenderer>::New();
     104
     105    // Global ambient (defaults to 1,1,1)
     106    //_renderer->SetAmbient(.2, .2, .2);
     107
    104108    vtkSmartPointer<vtkLight> headlight = vtkSmartPointer<vtkLight>::New();
    105109    headlight->SetLightTypeToHeadlight();
    106110    headlight->PositionalOff();
     111    // Light ambient color defaults to 0,0,0
    107112    //headlight->SetAmbientColor(1, 1, 1);
    108     //_renderer->SetAmbient(.2, .2, .2);
    109113    _renderer->AddLight(headlight);
    110114    vtkSmartPointer<vtkLight> skylight = vtkSmartPointer<vtkLight>::New();
     
    113117    skylight->SetFocalPoint(0, 0, 0);
    114118    skylight->PositionalOff();
     119    // Light ambient color defaults to 0,0,0
    115120    //skylight->SetAmbientColor(1, 1, 1);
    116121    _renderer->AddLight(skylight);
     
    457462    }
    458463
     464    double unscaledBounds[6];
     465    collectUnscaledBounds(unscaledBounds, false);
     466
    459467    if (bounds == NULL) {
    460468        double newBounds[6];
    461469        collectBounds(newBounds, false);
    462         double unscaledBounds[6];
    463         collectUnscaledBounds(unscaledBounds, false);
    464         _cubeAxesActor->SetXAxisRange(unscaledBounds[0], unscaledBounds[1]);
    465         _cubeAxesActor->SetYAxisRange(unscaledBounds[2], unscaledBounds[3]);
    466         _cubeAxesActor->SetZAxisRange(unscaledBounds[4], unscaledBounds[5]);
    467         TRACE("Axis ranges: %g %g %g %g %g %g",
    468               unscaledBounds[0],
    469               unscaledBounds[1],
    470               unscaledBounds[2],
    471               unscaledBounds[3],
    472               unscaledBounds[4],
    473               unscaledBounds[5]);
    474         _cubeAxesActor->SetBounds(newBounds);
    475         TRACE("Bounds (computed): %g %g %g %g %g %g",
    476               newBounds[0],
    477               newBounds[1],
    478               newBounds[2],
    479               newBounds[3],
    480               newBounds[4],
    481               newBounds[5]);
     470
     471        double sx = (newBounds[1] == newBounds[0]) ? 1.0 : (unscaledBounds[1] - unscaledBounds[0]) / (newBounds[1] - newBounds[0]);
     472        double sy = (newBounds[3] == newBounds[2]) ? 1.0 : (unscaledBounds[3] - unscaledBounds[2]) / (newBounds[3] - newBounds[2]);
     473        double sz = (newBounds[5] == newBounds[4]) ? 1.0 : (unscaledBounds[5] - unscaledBounds[4]) / (newBounds[5] - newBounds[4]);
     474
     475        setAxisBounds(newBounds);
     476        setAxisScale(sx, sy, sz);
    482477    } else {
    483         double unscaledBounds[6];
    484         collectUnscaledBounds(unscaledBounds, false);
    485         _cubeAxesActor->SetXAxisRange(unscaledBounds[0], unscaledBounds[1]);
    486         _cubeAxesActor->SetYAxisRange(unscaledBounds[2], unscaledBounds[3]);
    487         _cubeAxesActor->SetZAxisRange(unscaledBounds[4], unscaledBounds[5]);
    488         TRACE("Axis ranges: %g %g %g %g %g %g",
    489               unscaledBounds[0],
    490               unscaledBounds[1],
    491               unscaledBounds[2],
    492               unscaledBounds[3],
    493               unscaledBounds[4],
    494               unscaledBounds[5]);
    495         _cubeAxesActor->SetBounds(bounds);
    496         TRACE("Bounds (supplied): %g %g %g %g %g %g",
     478        double sx = (bounds[1] == bounds[0]) ? 1.0 : (unscaledBounds[1] - unscaledBounds[0]) / (bounds[1] - bounds[0]);
     479        double sy = (bounds[3] == bounds[2]) ? 1.0 : (unscaledBounds[3] - unscaledBounds[2]) / (bounds[3] - bounds[2]);
     480        double sz = (bounds[5] == bounds[4]) ? 1.0 : (unscaledBounds[5] - unscaledBounds[4]) / (bounds[5] - bounds[4]);
     481
     482        setAxisBounds(bounds);
     483        setAxisScale(sx, sy, sz);
     484    }
     485}
     486
     487/**
     488 * \brief Explicitly set world coordinate bounds of axes
     489 *
     490 * This determines the region in world coordinates around which
     491 * the axes are drawn
     492 */
     493void Renderer::setAxisBounds(double bounds[6])
     494{
     495    _cubeAxesActor->SetBounds(bounds);
     496    TRACE("Axis bounds: %g %g %g %g %g %g",
    497497              bounds[0],
    498498              bounds[1],
     
    501501              bounds[4],
    502502              bounds[5]);
    503     }
     503}
     504
     505/**
     506 * \brief Set scaling factors to convert world coordinates to axis
     507 * label values in X, Y, Z
     508 */
     509void Renderer::setAxisScale(double sx, double sy, double sz)
     510{
     511    double bounds[6];
     512    _cubeAxesActor->GetBounds(bounds);
     513    double ranges[6];
     514    ranges[0] = bounds[0] * sx;
     515    ranges[1] = bounds[1] * sx;
     516    ranges[2] = bounds[2] * sy;
     517    ranges[3] = bounds[3] * sy;
     518    ranges[4] = bounds[4] * sz;
     519    ranges[5] = bounds[5] * sz;
     520    _cubeAxesActor->SetXAxisRange(&bounds[0]);
     521    _cubeAxesActor->SetYAxisRange(&bounds[2]);
     522    _cubeAxesActor->SetZAxisRange(&bounds[4]);
     523    TRACE("Setting axis scale to: %g, %g, %g", sx, sy, sz);
     524    TRACE("Axis ranges: %g %g %g %g %g %g",
     525          ranges[0],
     526          ranges[1],
     527          ranges[2],
     528          ranges[3],
     529          ranges[4],
     530          ranges[5]);
    504531}
    505532
     
    782809
    783810/**
     811 * \brief Controls label scaling by power of 10
     812 */
     813void Renderer::setAxesLabelScaling(bool autoScale, int xpow, int ypow, int zpow)
     814{
     815    if (_cubeAxesActor != NULL) {
     816        _cubeAxesActor->SetLabelScaling(autoScale, xpow, ypow, zpow);
     817        _needsRedraw = true;
     818    }
     819}
     820
     821/**
     822 * \brief Set axes title/label font size in pixels
     823 */
     824void Renderer::setAxesPixelFontSize(double screenSize)
     825{
     826    if (_cubeAxesActor != NULL) {
     827        TRACE("Setting axes font size to: %g px", screenSize);
     828        _cubeAxesActor->SetScreenSize(screenSize);
     829        _needsRedraw = true;
     830    }
     831}
     832
     833/**
     834 * \brief Set axis title font family
     835 */
     836void Renderer::setAxesTitleFont(const char *fontName)
     837{
     838    setAxisTitleFont(X_AXIS, fontName);
     839    setAxisTitleFont(Y_AXIS, fontName);
     840    setAxisTitleFont(Z_AXIS, fontName);
     841}
     842
     843/**
     844 * \brief Set axis title font size
     845 */
     846void Renderer::setAxesTitleFontSize(int sz)
     847{
     848    setAxisTitleFontSize(X_AXIS, sz);
     849    setAxisTitleFontSize(Y_AXIS, sz);
     850    setAxisTitleFontSize(Z_AXIS, sz);
     851}
     852
     853/**
     854 * \brief Set orientation (as rotation in degrees) of axis title
     855 */
     856void Renderer::setAxesTitleOrientation(double orientation)
     857{
     858    setAxisTitleOrientation(X_AXIS, orientation);
     859    setAxisTitleOrientation(Y_AXIS, orientation);
     860    setAxisTitleOrientation(Z_AXIS, orientation);
     861}
     862
     863/**
     864 * \brief Set axis label font family
     865 */
     866void Renderer::setAxesLabelFont(const char *fontName)
     867{
     868    setAxisLabelFont(X_AXIS, fontName);
     869    setAxisLabelFont(Y_AXIS, fontName);
     870    setAxisLabelFont(Z_AXIS, fontName);
     871}
     872
     873/**
     874 * \brief Set axis label font size
     875 */
     876void Renderer::setAxesLabelFontSize(int sz)
     877{
     878    setAxisLabelFontSize(X_AXIS, sz);
     879    setAxisLabelFontSize(Y_AXIS, sz);
     880    setAxisLabelFontSize(Z_AXIS, sz);
     881}
     882
     883/**
     884 * \brief Set orientation (as rotation in degrees) of axis labels
     885 */
     886void Renderer::setAxesLabelOrientation(double orientation)
     887{
     888    setAxisLabelOrientation(X_AXIS, orientation);
     889    setAxisLabelOrientation(Y_AXIS, orientation);
     890    setAxisLabelOrientation(Z_AXIS, orientation);
     891}
     892
     893/**
     894 * \brief Set printf style label format string
     895 */
     896void Renderer::setAxesLabelFormat(const char *format)
     897{
     898    setAxisLabelFormat(X_AXIS, format);
     899    setAxisLabelFormat(Y_AXIS, format);
     900    setAxisLabelFormat(Z_AXIS, format);
     901}
     902
     903/**
    784904 * \brief Turn on/off rendering of the specified axis
    785905 */
     
    9291049        _needsRedraw = true;
    9301050    }
    931 #ifdef notdef
    932     if (_cubeAxesActor2D != NULL) {
     1051}
     1052
     1053/**
     1054 * \brief Set axis title font family
     1055 */
     1056void Renderer::setAxisTitleFont(Axis axis, const char *fontName)
     1057{
     1058    if (_cubeAxesActor != NULL) {
     1059        TRACE("Setting %d axis title font to: '%s'", axis, fontName);
     1060        _cubeAxesActor->GetTitleTextProperty(axis)->SetFontFamilyAsString(fontName);
     1061        _needsRedraw = true;
     1062    }
     1063}
     1064
     1065/**
     1066 * \brief Set axis title font size (and optionally pixel size)
     1067 */
     1068void Renderer::setAxisTitleFontSize(Axis axis, int sz)
     1069{
     1070    if (_cubeAxesActor != NULL) {
     1071        TRACE("Setting %d axis title font size to: %d", axis, sz);
     1072        _cubeAxesActor->GetTitleTextProperty(axis)->SetFontSize(sz);
     1073        _needsRedraw = true;
     1074    }
     1075}
     1076
     1077/**
     1078 * \brief Set orientation (as rotation in degrees) of axis titles
     1079 */
     1080void Renderer::setAxisTitleOrientation(Axis axis, double orientation)
     1081{
     1082    if (_cubeAxesActor != NULL) {
     1083        TRACE("Setting %d axis title orientation to: %g", axis, orientation);
     1084        _cubeAxesActor->GetTitleTextProperty(axis)->SetOrientation(orientation);
     1085        _needsRedraw = true;
     1086    }
     1087}
     1088
     1089/**
     1090 * \brief Set axis label font family
     1091 */
     1092void Renderer::setAxisLabelFont(Axis axis, const char *fontName)
     1093{
     1094    if (_cubeAxesActor != NULL) {
     1095        TRACE("Setting %d axis label font to: '%s'", axis, fontName);
     1096        _cubeAxesActor->GetLabelTextProperty(axis)->SetFontFamilyAsString(fontName);
     1097        _needsRedraw = true;
     1098    }
     1099}
     1100
     1101/**
     1102 * \brief Set axis label font size (and optionally pixel size)
     1103 */
     1104void Renderer::setAxisLabelFontSize(Axis axis, int sz)
     1105{
     1106    if (_cubeAxesActor != NULL) {
     1107        TRACE("Setting %d axis label font size to: %d", axis, sz);
     1108        _cubeAxesActor->GetLabelTextProperty(axis)->SetFontSize(sz);
     1109        _needsRedraw = true;
     1110    }
     1111}
     1112
     1113/**
     1114 * \brief Set orientation (as rotation in degrees) of axis labels
     1115 */
     1116void Renderer::setAxisLabelOrientation(Axis axis, double orientation)
     1117{
     1118    if (_cubeAxesActor != NULL) {
     1119        TRACE("Setting %d axis label orientation to: %g", axis, orientation);
     1120        _cubeAxesActor->GetLabelTextProperty(axis)->SetOrientation(orientation);
     1121        _needsRedraw = true;
     1122    }
     1123}
     1124
     1125/**
     1126 * \brief Set printf style label format string
     1127 */
     1128void Renderer::setAxisLabelFormat(Axis axis, const char *format)
     1129{
     1130    if (_cubeAxesActor != NULL) {
     1131        TRACE("Setting %d axis label format to: '%s'", axis, format);
    9331132        if (axis == X_AXIS) {
    934             _cubeAxesActor2D->SetXUnits(units);
     1133            _cubeAxesActor->SetXLabelFormat(format);
    9351134        } else if (axis == Y_AXIS) {
    936             _cubeAxesActor2D->SetYUnits(units);
     1135            _cubeAxesActor->SetYLabelFormat(format);
    9371136        } else if (axis == Z_AXIS) {
    938             _cubeAxesActor2D->SetZUnits(units);
     1137            _cubeAxesActor->SetZLabelFormat(format);
    9391138        }
    9401139        _needsRedraw = true;
    9411140    }
    942 #endif
    9431141}
    9441142
  • branches/Rappture 1.2/packages/vizservers/vtkvis/RpVtkRenderer.h

    r3211 r3221  
    239239    void setAxesColor(double color[3]);
    240240
     241    void setAxesLabelScaling(bool autoScale, int xpow, int ypow, int zpow);
     242
     243    void setAxesPixelFontSize(double screenSize);
     244
     245    void setAxesTitleFont(const char *fontName);
     246
     247    void setAxesTitleFontSize(int sz);
     248
     249    void setAxesTitleOrientation(double orientation);
     250
     251    void setAxesLabelFont(const char *fontName);
     252
     253    void setAxesLabelFontSize(int sz);
     254
     255    void setAxesLabelOrientation(double orientation);
     256
     257    void setAxesLabelFormat(const char *format);
     258
    241259    void setAxisVisibility(Axis axis, bool state);
    242260
     
    250268
    251269    void setAxisUnits(Axis axis, const char *units);
     270
     271    void setAxisTitleFont(Axis axis, const char *fontName);
     272
     273    void setAxisTitleFontSize(Axis axis, int sz);
     274
     275    void setAxisTitleOrientation(Axis axis, double orientation);
     276
     277    void setAxisLabelFont(Axis axis, const char *fontName);
     278
     279    void setAxisLabelFontSize(Axis axis, int sz);
     280
     281    void setAxisLabelOrientation(Axis axis, double orientation);
     282
     283    void setAxisLabelFormat(Axis axis, const char *format);
     284
     285    void setAxisBounds(double bounds[6]);
     286
     287    void setAxisScale(double sx, double sy, double sz);
    252288
    253289    // Colormaps
  • branches/Rappture 1.2/packages/vizservers/vtkvis/RpVtkRendererCmd.cpp

    r3211 r3221  
    675675
    676676static int
     677AxisFontSizeOp(ClientData clientData, Tcl_Interp *interp, int objc,
     678               Tcl_Obj *const *objv)
     679{
     680    double screenSize;
     681    if (Tcl_GetDoubleFromObj(interp, objv[2], &screenSize)) {
     682        return TCL_ERROR;
     683    }
     684
     685    g_renderer->setAxesPixelFontSize(screenSize);
     686    return TCL_OK;
     687}
     688
     689static int
    677690AxisGridOp(ClientData clientData, Tcl_Interp *interp, int objc,
    678691           Tcl_Obj *const *objv)
     
    694707    } else {
    695708        Tcl_AppendResult(interp, "bad axis option \"", string,
    696                          "\": should be axisName visible", (char*)NULL);
    697         return TCL_ERROR;
    698     }
     709                         "\": should be axisName", (char*)NULL);
     710        return TCL_ERROR;
     711    }
     712    return TCL_OK;
     713}
     714
     715static int
     716AxisLabelFontOp(ClientData clientData, Tcl_Interp *interp, int objc,
     717                Tcl_Obj *const *objv)
     718{
     719    const char *fontName = Tcl_GetString(objv[3]);
     720
     721    const char *string = Tcl_GetString(objv[2]);
     722    char c = string[0];
     723    if ((c == 'x') && (strcmp(string, "x") == 0)) {
     724        g_renderer->setAxisLabelFont(X_AXIS, fontName);
     725    } else if ((c == 'y') && (strcmp(string, "y") == 0)) {
     726        g_renderer->setAxisLabelFont(Y_AXIS, fontName);
     727    } else if ((c == 'z') && (strcmp(string, "z") == 0)) {
     728        g_renderer->setAxisLabelFont(Z_AXIS, fontName);
     729    } else if ((c == 'a') && (strcmp(string, "all") == 0)) {
     730        g_renderer->setAxesLabelFont(fontName);
     731    } else {
     732        Tcl_AppendResult(interp, "bad axis option \"", string,
     733                         "\": should be axisName", (char*)NULL);
     734        return TCL_ERROR;
     735    }
     736    return TCL_OK;
     737}
     738
     739static int
     740AxisLabelFormatOp(ClientData clientData, Tcl_Interp *interp, int objc,
     741                  Tcl_Obj *const *objv)
     742{
     743    const char *format = Tcl_GetString(objv[3]);
     744
     745    const char *string = Tcl_GetString(objv[2]);
     746    char c = string[0];
     747    if ((c == 'x') && (strcmp(string, "x") == 0)) {
     748        g_renderer->setAxisLabelFormat(X_AXIS, format);
     749    } else if ((c == 'y') && (strcmp(string, "y") == 0)) {
     750        g_renderer->setAxisLabelFormat(Y_AXIS, format);
     751    } else if ((c == 'z') && (strcmp(string, "z") == 0)) {
     752        g_renderer->setAxisLabelFormat(Z_AXIS, format);
     753    } else if ((c == 'a') && (strcmp(string, "all") == 0)) {
     754        g_renderer->setAxesLabelFormat(format);
     755    } else {
     756        Tcl_AppendResult(interp, "bad axis option \"", string,
     757                         "\": should be axisName", (char*)NULL);
     758        return TCL_ERROR;
     759    }
     760    return TCL_OK;
     761}
     762
     763static int
     764AxisLabelFontSizeOp(ClientData clientData, Tcl_Interp *interp, int objc,
     765                    Tcl_Obj *const *objv)
     766{
     767    int fontSize;
     768    if (Tcl_GetIntFromObj(interp, objv[3], &fontSize) != TCL_OK) {
     769        return TCL_ERROR;
     770    }
     771
     772    const char *string = Tcl_GetString(objv[2]);
     773    char c = string[0];
     774    if ((c == 'x') && (strcmp(string, "x") == 0)) {
     775        g_renderer->setAxisLabelFontSize(X_AXIS, fontSize);
     776    } else if ((c == 'y') && (strcmp(string, "y") == 0)) {
     777        g_renderer->setAxisLabelFontSize(Y_AXIS, fontSize);
     778    } else if ((c == 'z') && (strcmp(string, "z") == 0)) {
     779        g_renderer->setAxisLabelFontSize(Z_AXIS, fontSize);
     780    } else if ((c == 'a') && (strcmp(string, "all") == 0)) {
     781        g_renderer->setAxesLabelFontSize(fontSize);
     782    } else {
     783        Tcl_AppendResult(interp, "bad axis option \"", string,
     784                         "\": should be axisName", (char*)NULL);
     785        return TCL_ERROR;
     786    }
     787    return TCL_OK;
     788}
     789
     790static int
     791AxisLabelOrientationOp(ClientData clientData, Tcl_Interp *interp, int objc,
     792                       Tcl_Obj *const *objv)
     793{
     794    double rot;
     795    if (Tcl_GetDoubleFromObj(interp, objv[3], &rot) != TCL_OK) {
     796        return TCL_ERROR;
     797    }
     798    const char *string = Tcl_GetString(objv[2]);
     799    char c = string[0];
     800    if ((c == 'x') && (strcmp(string, "x") == 0)) {
     801        g_renderer->setAxisLabelOrientation(X_AXIS, rot);
     802    } else if ((c == 'y') && (strcmp(string, "y") == 0)) {
     803        g_renderer->setAxisLabelOrientation(Y_AXIS, rot);
     804    } else if ((c == 'z') && (strcmp(string, "z") == 0)) {
     805        g_renderer->setAxisLabelOrientation(Z_AXIS, rot);
     806    } else if ((c == 'a') && (strcmp(string, "all") == 0)) {
     807        g_renderer->setAxesLabelOrientation(rot);
     808    } else {
     809        Tcl_AppendResult(interp, "bad axis option \"", string,
     810                         "\": should be axisName", (char*)NULL);
     811        return TCL_ERROR;
     812    }
     813    return TCL_OK;
     814}
     815
     816static int
     817AxisLabelScaleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     818                 Tcl_Obj *const *objv)
     819{
     820    bool autoScale;
     821    int xpow, ypow, zpow;
     822    if (GetBooleanFromObj(interp, objv[3], &autoScale) != TCL_OK ||
     823        Tcl_GetIntFromObj(interp, objv[4], &xpow) != TCL_OK ||
     824        Tcl_GetIntFromObj(interp, objv[5], &ypow) != TCL_OK ||
     825        Tcl_GetIntFromObj(interp, objv[6], &zpow) != TCL_OK) {
     826        return TCL_ERROR;
     827    }
     828
     829    g_renderer->setAxesLabelScaling(autoScale, xpow, ypow, zpow);
    699830    return TCL_OK;
    700831}
     
    720851    } else {
    721852        Tcl_AppendResult(interp, "bad axis option \"", string,
    722                          "\": should be axisName visible", (char*)NULL);
     853                         "\": should be axisName", (char*)NULL);
    723854        return TCL_ERROR;
    724855    }
     
    793924        Tcl_AppendResult(interp, "bad axis option \"", string,
    794925                         "\": should be inside, outside or both", (char*)NULL);
     926        return TCL_ERROR;
     927    }
     928    return TCL_OK;
     929}
     930
     931static int
     932AxisTitleFontOp(ClientData clientData, Tcl_Interp *interp, int objc,
     933                Tcl_Obj *const *objv)
     934{
     935    const char *fontName = Tcl_GetString(objv[3]);
     936
     937    const char *string = Tcl_GetString(objv[2]);
     938    char c = string[0];
     939    if ((c == 'x') && (strcmp(string, "x") == 0)) {
     940        g_renderer->setAxisTitleFont(X_AXIS, fontName);
     941    } else if ((c == 'y') && (strcmp(string, "y") == 0)) {
     942        g_renderer->setAxisTitleFont(Y_AXIS, fontName);
     943    } else if ((c == 'z') && (strcmp(string, "z") == 0)) {
     944        g_renderer->setAxisTitleFont(Z_AXIS, fontName);
     945    } else if ((c == 'a') && (strcmp(string, "all") == 0)) {
     946        g_renderer->setAxesTitleFont(fontName);
     947    } else {
     948        Tcl_AppendResult(interp, "bad axis option \"", string,
     949                         "\": should be axisName", (char*)NULL);
     950        return TCL_ERROR;
     951    }
     952    return TCL_OK;
     953}
     954
     955static int
     956AxisTitleFontSizeOp(ClientData clientData, Tcl_Interp *interp, int objc,
     957                    Tcl_Obj *const *objv)
     958{
     959    int fontSize;
     960    if (Tcl_GetIntFromObj(interp, objv[3], &fontSize) != TCL_OK) {
     961        return TCL_ERROR;
     962    }
     963
     964    const char *string = Tcl_GetString(objv[2]);
     965    char c = string[0];
     966    if ((c == 'x') && (strcmp(string, "x") == 0)) {
     967        g_renderer->setAxisTitleFontSize(X_AXIS, fontSize);
     968    } else if ((c == 'y') && (strcmp(string, "y") == 0)) {
     969        g_renderer->setAxisTitleFontSize(Y_AXIS, fontSize);
     970    } else if ((c == 'z') && (strcmp(string, "z") == 0)) {
     971        g_renderer->setAxisTitleFontSize(Z_AXIS, fontSize);
     972    } else if ((c == 'a') && (strcmp(string, "all") == 0)) {
     973        g_renderer->setAxesTitleFontSize(fontSize);
     974    } else {
     975        Tcl_AppendResult(interp, "bad axis option \"", string,
     976                         "\": should be axisName", (char*)NULL);
     977        return TCL_ERROR;
     978    }
     979    return TCL_OK;
     980}
     981
     982static int
     983AxisTitleOrientationOp(ClientData clientData, Tcl_Interp *interp, int objc,
     984                       Tcl_Obj *const *objv)
     985{
     986    double rot;
     987    if (Tcl_GetDoubleFromObj(interp, objv[3], &rot) != TCL_OK) {
     988        return TCL_ERROR;
     989    }
     990    const char *string = Tcl_GetString(objv[2]);
     991    char c = string[0];
     992    if ((c == 'x') && (strcmp(string, "x") == 0)) {
     993        g_renderer->setAxisTitleOrientation(X_AXIS, rot);
     994    } else if ((c == 'y') && (strcmp(string, "y") == 0)) {
     995        g_renderer->setAxisTitleOrientation(Y_AXIS, rot);
     996    } else if ((c == 'z') && (strcmp(string, "z") == 0)) {
     997        g_renderer->setAxisTitleOrientation(Z_AXIS, rot);
     998    } else if ((c == 'a') && (strcmp(string, "all") == 0)) {
     999        g_renderer->setAxesTitleOrientation(rot);
     1000    } else {
     1001        Tcl_AppendResult(interp, "bad axis option \"", string,
     1002                         "\": should be axisName", (char*)NULL);
    7951003        return TCL_ERROR;
    7961004    }
     
    8221030    } else {
    8231031        Tcl_AppendResult(interp, "bad axis option \"", string,
    824                          "\": should be axisName units", (char*)NULL);
     1032                         "\": should be axisName", (char*)NULL);
    8251033        return TCL_ERROR;
    8261034    }
     
    8481056    } else {
    8491057        Tcl_AppendResult(interp, "bad axis option \"", string,
    850                          "\": should be axisName visible", (char*)NULL);
     1058                         "\": should be axisName", (char*)NULL);
    8511059        return TCL_ERROR;
    8521060    }
     
    8561064static Rappture::CmdSpec axisOps[] = {
    8571065    {"color",   1, AxisColorOp, 5, 5, "r g b"},
    858     {"flymode", 1, AxisFlyModeOp, 3, 3, "mode"},
     1066    {"flymode", 2, AxisFlyModeOp, 3, 3, "mode"},
     1067    {"fontsz",  2, AxisFontSizeOp, 3, 3, "fontPixelSize"},
    8591068    {"grid",    1, AxisGridOp, 4, 4, "axis bool"},
    860     {"labels",  1, AxisLabelsVisibleOp, 4, 4, "axis bool"},
     1069    {"labels",  2, AxisLabelsVisibleOp, 4, 4, "axis bool"},
     1070    {"lfont",   4, AxisLabelFontOp, 4, 4, "axis font"},
     1071    {"lformat", 4, AxisLabelFormatOp, 4, 4, "axis format"},
     1072    {"lfsize",  3, AxisLabelFontSizeOp, 4, 4, "axis fontSize"},
     1073    {"lrot",    2, AxisLabelOrientationOp, 4, 4, "axis rot"},
     1074    {"lscale",  2, AxisLabelScaleOp, 7, 7, "axis bool xpow ypow zpow"},
    8611075    {"name",    1, AxisNameOp, 4, 4, "axis title"},
    862     {"tickpos", 2, AxisTickPositionOp, 3, 3, "position"},
    863     {"ticks",   2, AxisTicksVisibleOp, 4, 4, "axis bool"},
     1076    {"tfont",   3, AxisTitleFontOp, 4, 4, "axis font"},
     1077    {"tfsize",  3, AxisTitleFontSizeOp, 4, 4, "axis fontSize"},
     1078    {"tickpos", 5, AxisTickPositionOp, 3, 3, "position"},
     1079    {"ticks",   5, AxisTicksVisibleOp, 4, 4, "axis bool"},
     1080    {"trot",    3, AxisTitleOrientationOp, 4, 4, "axis rot"},
    8641081    {"units",   1, AxisUnitsOp, 4, 4, "axis units"},
    8651082    {"visible", 1, AxisVisibleOp, 4, 4, "axis bool"}
  • branches/Rappture 1.2/packages/vizservers/vtkvis/protocol.txt

    r3168 r3221  
    4646axis flymode <mode>
    4747     <mode> = static_edges|static_triad|outer_edges|furthest_triad|closest_triad
     48axis fontsz <fontPixelSize>
     49     Controls size of labels and text in 3D mode
    4850axis grid <axis> <bool>
    4951     <axis> = x|y|z|all
     
    5153     Toggle visibility of axis labels
    5254     <axis> = x|y|z|all
     55axis lfont <axis> <fontName>
     56     Set label font family
     57     <axis> = x|y|z|all
     58     <fontName> = Arial|Courier|Times
     59axis lformat <axis> <formatString>
     60     <axis> = x|y|z|all
     61     <formatString> = printf style format string
     62axis lfsize <axis> <fontSizePts>
     63     Set font size of labels in 2D mode
     64     <axis> = x|y|z|all
     65     <fontSizePts> = Font size in points
     66axis lrot <axis> <rotation>
     67     <axis> = x|y|z|all
     68     <rotation> = rotation angle in degrees
     69axis lscale <axis> <boolAuto> <xpow> <ypow> <zpow>
     70     Control (auto-)scaling of labels with powers of 10
     71     <axis> = x|y|z|all
     72     <boolAuto> = Enable/disable automatic scaling with powers of 10
     73     <xpow> = Explicitly set power on X axis
     74     <ypow> = Explicitly set power on Y axis
     75     <zpow> = Explicitly set power on Z axis
    5376axis name <axis> <title>
    5477axis tickpos <position>
     
    5881     Toggle visibility of axis tick marks
    5982     <axis> = x|y|z|all
     83axis tfont <axis> <fontName>
     84     Set title font family
     85     <axis> = x|y|z|all
     86     <fontName> = Arial|Courier|Times
     87axis tfsize <axis> <fontSizePts>
     88     Set font size of title in 2D mode
     89     <axis> = x|y|z|all
     90     <fontSizePts> = Font size in points
     91axis trot <axis> <rotation>
     92     <axis> = x|y|z|all
     93     <rotation> = rotation angle in degrees
    6094axis units <axis> <units>
    6195     Currently only supported when camera mode is not image mode
Note: See TracChangeset for help on using the changeset viewer.