Ignore:
Timestamp:
Dec 21, 2012, 5:53:00 PM (12 years ago)
Author:
ldelgass
Message:

Add protocol to axes for toggling minor ticks, inner gridlines, inner grid
polygons/planes. Make contour2d/3d default to scalar color mode. Add color
mode to heightmap consistent with other objects: currently affects only
pseudocolor mesh portion of heightmap, not contour lines.

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

Legend:

Unmodified
Added
Removed
  • branches/Rappture 1.2/packages/vizservers/vtkvis/RpContour2D.cpp

    r3203 r3224  
    3333    _numContours(numContours),
    3434    _colorMap(NULL),
    35     _colorMode(COLOR_CONSTANT),
     35    _colorMode(COLOR_BY_SCALAR),
    3636    _colorFieldType(DataSet::POINT_DATA),
    3737    _renderer(NULL)
     
    5050    _contours(contours),
    5151    _colorMap(NULL),
    52     _colorMode(COLOR_CONSTANT),
     52    _colorMode(COLOR_BY_SCALAR),
    5353    _colorFieldType(DataSet::POINT_DATA),
    5454    _renderer(NULL)
  • branches/Rappture 1.2/packages/vizservers/vtkvis/RpContour3D.cpp

    r3223 r3224  
    3131    _numContours(numContours),
    3232    _colorMap(NULL),
    33     _colorMode(COLOR_CONSTANT),
     33    _colorMode(COLOR_BY_SCALAR),
    3434    _colorFieldType(DataSet::POINT_DATA),
    3535    _renderer(NULL)
     
    4444    _contours(contours),
    4545    _colorMap(NULL),
    46     _colorMode(COLOR_CONSTANT),
     46    _colorMode(COLOR_BY_SCALAR),
    4747    _colorFieldType(DataSet::POINT_DATA),
    4848    _renderer(NULL)
  • branches/Rappture 1.2/packages/vizservers/vtkvis/RpHeightMap.cpp

    r3220 r3224  
    4242    VtkGraphicsObject(),
    4343    _numContours(numContours),
    44     _colorMap(NULL),
    4544    _contourEdgeWidth(1.0),
    4645    _warpScale(heightScale),
    4746    _sliceAxis(Z_AXIS),
    48     _pipelineInitialized(false)
     47    _pipelineInitialized(false),
     48    _colorMap(NULL),
     49    _colorMode(COLOR_BY_SCALAR),
     50    _colorFieldType(DataSet::POINT_DATA),
     51    _renderer(NULL)
    4952{
    5053    _contourEdgeColor[0] = 1.0f;
    5154    _contourEdgeColor[1] = 0.0f;
    5255    _contourEdgeColor[2] = 0.0f;
     56    _colorFieldRange[0] = DBL_MAX;
     57    _colorFieldRange[1] = -DBL_MAX;
    5358}
    5459
     
    5762    _numContours(contours.size()),
    5863    _contours(contours),
    59     _colorMap(NULL),
    6064    _contourEdgeWidth(1.0),
    6165    _warpScale(heightScale),
    6266    _sliceAxis(Z_AXIS),
    63     _pipelineInitialized(false)
     67    _pipelineInitialized(false),
     68    _colorMap(NULL),
     69    _colorMode(COLOR_BY_SCALAR),
     70    _colorFieldType(DataSet::POINT_DATA),
     71    _renderer(NULL)
    6472{
    6573    _contourEdgeColor[0] = 1.0f;
    6674    _contourEdgeColor[1] = 0.0f;
    6775    _contourEdgeColor[2] = 0.0f;
     76    _colorFieldRange[0] = DBL_MAX;
     77    _colorFieldRange[1] = -DBL_MAX;
    6878}
    6979
     
    8494        _dataSet = dataSet;
    8595
     96        _renderer = renderer;
     97
    8698        if (_dataSet != NULL) {
    8799            if (renderer->getUseCumulativeRange()) {
     
    89101                                                 _dataSet->getActiveScalarsName(),
    90102                                                 1);
     103                renderer->getCumulativeDataRange(_vectorMagnitudeRange,
     104                                                 _dataSet->getActiveVectorsName(),
     105                                                 3);
     106                for (int i = 0; i < 3; i++) {
     107                    renderer->getCumulativeDataRange(_vectorComponentRange[i],
     108                                                     _dataSet->getActiveVectorsName(),
     109                                                     3, i);
     110                }
    91111            } else {
    92112                _dataSet->getScalarRange(_dataRange);
     113                _dataSet->getVectorRange(_vectorMagnitudeRange);
     114                for (int i = 0; i < 3; i++) {
     115                    _dataSet->getVectorRange(_vectorComponentRange[i], i);
     116                }
    93117            }
    94118
     
    126150        _dsActor = vtkSmartPointer<vtkActor>::New();
    127151        _dsActor->GetProperty()->SetOpacity(_opacity);
     152        _dsActor->GetProperty()->SetColor(_color[0],
     153                                          _color[1],
     154                                          _color[2]);
    128155        _dsActor->GetProperty()->SetEdgeColor(_edgeColor[0],
    129156                                              _edgeColor[1],
     
    462489    }
    463490
     491    setColorMode(_colorMode);
     492
    464493    //setAspect(1.0);
    465494
     
    794823}
    795824
     825void HeightMap::updateRanges(Renderer *renderer)
     826{
     827    if (_dataSet == NULL) {
     828        ERROR("called before setDataSet");
     829        return;
     830    }
     831
     832    if (renderer->getUseCumulativeRange()) {
     833        renderer->getCumulativeDataRange(_dataRange,
     834                                         _dataSet->getActiveScalarsName(),
     835                                         1);
     836        renderer->getCumulativeDataRange(_vectorMagnitudeRange,
     837                                         _dataSet->getActiveVectorsName(),
     838                                         3);
     839        for (int i = 0; i < 3; i++) {
     840            renderer->getCumulativeDataRange(_vectorComponentRange[i],
     841                                             _dataSet->getActiveVectorsName(),
     842                                             3, i);
     843        }
     844    } else {
     845        _dataSet->getScalarRange(_dataRange);
     846        _dataSet->getVectorRange(_vectorMagnitudeRange);
     847        for (int i = 0; i < 3; i++) {
     848            _dataSet->getVectorRange(_vectorComponentRange[i], i);
     849        }
     850    }
     851 
     852    // Need to update color map ranges
     853    double *rangePtr = _colorFieldRange;
     854    if (_colorFieldRange[0] > _colorFieldRange[1]) {
     855        rangePtr = NULL;
     856    }
     857    setColorMode(_colorMode, _colorFieldType, _colorFieldName.c_str(), rangePtr);
     858
     859    if (_contours.empty() && _numContours > 0) {
     860        // Contour isovalues need to be recomputed
     861        update();
     862    }
     863}
     864
     865void HeightMap::setColorMode(ColorMode mode)
     866{
     867    _colorMode = mode;
     868    if (_dataSet == NULL)
     869        return;
     870
     871    switch (mode) {
     872    case COLOR_BY_SCALAR:
     873        setColorMode(mode,
     874                     _dataSet->getActiveScalarsType(),
     875                     _dataSet->getActiveScalarsName(),
     876                     _dataRange);
     877        break;
     878    case COLOR_BY_VECTOR_MAGNITUDE:
     879        setColorMode(mode,
     880                     _dataSet->getActiveVectorsType(),
     881                     _dataSet->getActiveVectorsName(),
     882                     _vectorMagnitudeRange);
     883        break;
     884    case COLOR_BY_VECTOR_X:
     885        setColorMode(mode,
     886                     _dataSet->getActiveVectorsType(),
     887                     _dataSet->getActiveVectorsName(),
     888                     _vectorComponentRange[0]);
     889        break;
     890    case COLOR_BY_VECTOR_Y:
     891        setColorMode(mode,
     892                     _dataSet->getActiveVectorsType(),
     893                     _dataSet->getActiveVectorsName(),
     894                     _vectorComponentRange[1]);
     895        break;
     896    case COLOR_BY_VECTOR_Z:
     897        setColorMode(mode,
     898                     _dataSet->getActiveVectorsType(),
     899                     _dataSet->getActiveVectorsName(),
     900                     _vectorComponentRange[2]);
     901        break;
     902    case COLOR_CONSTANT:
     903    default:
     904        setColorMode(mode, DataSet::POINT_DATA, NULL, NULL);
     905        break;
     906    }
     907}
     908
     909void HeightMap::setColorMode(ColorMode mode,
     910                             const char *name, double range[2])
     911{
     912    if (_dataSet == NULL)
     913        return;
     914    DataSet::DataAttributeType type = DataSet::POINT_DATA;
     915    int numComponents = 1;
     916    if (name != NULL && strlen(name) > 0 &&
     917        !_dataSet->getFieldInfo(name, &type, &numComponents)) {
     918        ERROR("Field not found: %s", name);
     919        return;
     920    }
     921    setColorMode(mode, type, name, range);
     922}
     923
     924void HeightMap::setColorMode(ColorMode mode, DataSet::DataAttributeType type,
     925                             const char *name, double range[2])
     926{
     927    _colorMode = mode;
     928    _colorFieldType = type;
     929    if (name == NULL)
     930        _colorFieldName.clear();
     931    else
     932        _colorFieldName = name;
     933    if (range == NULL) {
     934        _colorFieldRange[0] = DBL_MAX;
     935        _colorFieldRange[1] = -DBL_MAX;
     936    } else {
     937        memcpy(_colorFieldRange, range, sizeof(double)*2);
     938    }
     939
     940    if (_dataSet == NULL || _dsMapper == NULL)
     941        return;
     942
     943    switch (type) {
     944    case DataSet::POINT_DATA:
     945        _dsMapper->SetScalarModeToUsePointFieldData();
     946        break;
     947    case DataSet::CELL_DATA:
     948        _dsMapper->SetScalarModeToUseCellFieldData();
     949        break;
     950    default:
     951        ERROR("Unsupported DataAttributeType: %d", type);
     952        return;
     953    }
     954
     955    if (name != NULL && strlen(name) > 0) {
     956        _dsMapper->SelectColorArray(name);
     957    } else {
     958        _dsMapper->SetScalarModeToDefault();
     959    }
     960
     961    if (_lut != NULL) {
     962        if (range != NULL) {
     963            _lut->SetRange(range);
     964        } else if (name != NULL && strlen(name) > 0) {
     965            double r[2];
     966            int comp = -1;
     967            if (mode == COLOR_BY_VECTOR_X)
     968                comp = 0;
     969            else if (mode == COLOR_BY_VECTOR_Y)
     970                comp = 1;
     971            else if (mode == COLOR_BY_VECTOR_Z)
     972                comp = 2;
     973
     974            if (_renderer->getUseCumulativeRange()) {
     975                int numComponents;
     976                if  (!_dataSet->getFieldInfo(name, type, &numComponents)) {
     977                    ERROR("Field not found: %s, type: %d", name, type);
     978                    return;
     979                } else if (numComponents < comp+1) {
     980                    ERROR("Request for component %d in field with %d components",
     981                          comp, numComponents);
     982                    return;
     983                }
     984                _renderer->getCumulativeDataRange(r, name, type, numComponents, comp);
     985            } else {
     986                _dataSet->getDataRange(r, name, type, comp);
     987            }
     988            _lut->SetRange(r);
     989        }
     990    }
     991
     992    switch (mode) {
     993    case COLOR_BY_SCALAR:
     994        _dsMapper->ScalarVisibilityOn();
     995        break;
     996    case COLOR_BY_VECTOR_MAGNITUDE:
     997        _dsMapper->ScalarVisibilityOn();
     998        if (_lut != NULL) {
     999            _lut->SetVectorModeToMagnitude();
     1000        }
     1001        break;
     1002    case COLOR_BY_VECTOR_X:
     1003        _dsMapper->ScalarVisibilityOn();
     1004        if (_lut != NULL) {
     1005            _lut->SetVectorModeToComponent();
     1006            _lut->SetVectorComponent(0);
     1007        }
     1008        break;
     1009    case COLOR_BY_VECTOR_Y:
     1010        _dsMapper->ScalarVisibilityOn();
     1011        if (_lut != NULL) {
     1012            _lut->SetVectorModeToComponent();
     1013            _lut->SetVectorComponent(1);
     1014        }
     1015        break;
     1016    case COLOR_BY_VECTOR_Z:
     1017        _dsMapper->ScalarVisibilityOn();
     1018        if (_lut != NULL) {
     1019            _lut->SetVectorModeToComponent();
     1020            _lut->SetVectorComponent(2);
     1021        }
     1022        break;
     1023    case COLOR_CONSTANT:
     1024    default:
     1025        _dsMapper->ScalarVisibilityOff();
     1026        break;
     1027    }
     1028}
     1029
    7961030/**
    7971031 * \brief Called when the color map has been edited
     
    8111045
    8121046    _colorMap = cmap;
    813  
    814     if (_lut == NULL) {
     1047
     1048        if (_lut == NULL) {
    8151049        _lut = vtkSmartPointer<vtkLookupTable>::New();
    8161050        if (_dsMapper != NULL) {
     
    8181052            _dsMapper->SetLookupTable(_lut);
    8191053        }
    820     }
    821 
    822     _lut->DeepCopy(cmap->getLookupTable());
    823     _lut->SetRange(_dataRange);
    824 }
    825 
    826 void HeightMap::updateRanges(Renderer *renderer)
    827 {
    828     VtkGraphicsObject::updateRanges(renderer);
    829 
    830     if (_lut != NULL) {
    831         _lut->SetRange(_dataRange);
    832     }
    833 
    834     if (_contours.empty() && _numContours > 0) {
    835         // Need to recompute isovalues
    836         update();
     1054        _lut->DeepCopy(cmap->getLookupTable());
     1055        switch (_colorMode) {
     1056        case COLOR_CONSTANT:
     1057        case COLOR_BY_SCALAR:
     1058            _lut->SetRange(_dataRange);
     1059            break;
     1060        case COLOR_BY_VECTOR_MAGNITUDE:
     1061            _lut->SetRange(_vectorMagnitudeRange);
     1062            break;
     1063        case COLOR_BY_VECTOR_X:
     1064            _lut->SetRange(_vectorComponentRange[0]);
     1065            break;
     1066        case COLOR_BY_VECTOR_Y:
     1067            _lut->SetRange(_vectorComponentRange[1]);
     1068            break;
     1069        case COLOR_BY_VECTOR_Z:
     1070            _lut->SetRange(_vectorComponentRange[2]);
     1071            break;
     1072        default:
     1073            break;
     1074        }
     1075    } else {
     1076        double range[2];
     1077        _lut->GetTableRange(range);
     1078        _lut->DeepCopy(cmap->getLookupTable());
     1079        _lut->SetRange(range);
     1080    }
     1081
     1082    switch (_colorMode) {
     1083    case COLOR_BY_VECTOR_MAGNITUDE:
     1084        _lut->SetVectorModeToMagnitude();
     1085        break;
     1086    case COLOR_BY_VECTOR_X:
     1087        _lut->SetVectorModeToComponent();
     1088        _lut->SetVectorComponent(0);
     1089        break;
     1090    case COLOR_BY_VECTOR_Y:
     1091        _lut->SetVectorModeToComponent();
     1092        _lut->SetVectorComponent(1);
     1093        break;
     1094    case COLOR_BY_VECTOR_Z:
     1095        _lut->SetVectorModeToComponent();
     1096        _lut->SetVectorComponent(2);
     1097        break;
     1098    default:
     1099         break;
    8371100    }
    8381101}
     
    9191182        _contourActor->SetVisibility((state ? 1 : 0));
    9201183    }
     1184}
     1185
     1186/**
     1187 * \brief Set RGB color of mesh
     1188 */
     1189void HeightMap::setColor(float color[3])
     1190{
     1191    _color[0] = color[0];
     1192    _color[1] = color[1];
     1193    _color[2] = color[2];
     1194    if (_dsActor != NULL)
     1195        _dsActor->GetProperty()->SetColor(_color[0], _color[1], _color[2]);
    9211196}
    9221197
  • branches/Rappture 1.2/packages/vizservers/vtkvis/RpHeightMap.h

    r3213 r3224  
    3838class HeightMap : public VtkGraphicsObject {
    3939public:
     40    enum ColorMode {
     41        COLOR_BY_SCALAR,
     42        COLOR_BY_VECTOR_MAGNITUDE,
     43        COLOR_BY_VECTOR_X,
     44        COLOR_BY_VECTOR_Y,
     45        COLOR_BY_VECTOR_Z,
     46        COLOR_CONSTANT
     47    };
     48
    4049    HeightMap(int numContours, double heightScale = 1.0);
    4150
     
    5362
    5463    virtual void setLighting(bool state);
     64
     65    virtual void setColor(float color[3]);
    5566
    5667    virtual void setEdgeVisibility(bool state);
     
    8293
    8394    const std::vector<double>& getContourList() const;
     95   
     96    void setColorMode(ColorMode mode, DataSet::DataAttributeType type,
     97                      const char *name, double range[2] = NULL);
     98
     99    void setColorMode(ColorMode mode,
     100                      const char *name, double range[2] = NULL);
     101
     102    void setColorMode(ColorMode mode);
    84103
    85104    void setColorMap(ColorMap *colorMap);
     
    116135    int _numContours;
    117136    std::vector<double> _contours;
    118     ColorMap *_colorMap;
    119137
    120138    float _contourEdgeColor[3];
     
    124142    Axis _sliceAxis;
    125143    bool _pipelineInitialized;
     144
     145    ColorMap *_colorMap;
     146    ColorMode _colorMode;
     147    std::string _colorFieldName;
     148    DataSet::DataAttributeType _colorFieldType;
     149    double _colorFieldRange[2];
     150    double _vectorMagnitudeRange[2];
     151    double _vectorComponentRange[3][2];
     152    Renderer *_renderer;
    126153
    127154    vtkSmartPointer<vtkLookupTable> _lut;
  • branches/Rappture 1.2/packages/vizservers/vtkvis/RpVtkRenderer.cpp

    r3221 r3224  
    712712        _cubeAxesActor->GetXAxesLinesProperty()->SetColor(color);
    713713        _cubeAxesActor->GetXAxesGridlinesProperty()->SetColor(color);
     714        _cubeAxesActor->GetXAxesInnerGridlinesProperty()->SetColor(color);
    714715        _cubeAxesActor->GetYAxesLinesProperty()->SetColor(color);
    715716        _cubeAxesActor->GetYAxesGridlinesProperty()->SetColor(color);
     717        _cubeAxesActor->GetYAxesInnerGridlinesProperty()->SetColor(color);
    716718        _cubeAxesActor->GetZAxesLinesProperty()->SetColor(color);
    717719        _cubeAxesActor->GetZAxesGridlinesProperty()->SetColor(color);
     720        _cubeAxesActor->GetZAxesInnerGridlinesProperty()->SetColor(color);
    718721#endif
    719722        _needsRedraw = true;
     
    766769
    767770/**
     771 * \brief Turn on/off rendering of all axes inner gridlines
     772 */
     773void Renderer::setAxesInnerGridVisibility(bool state)
     774{
     775    setAxisInnerGridVisibility(X_AXIS, state);
     776    setAxisInnerGridVisibility(Y_AXIS, state);
     777    setAxisInnerGridVisibility(Z_AXIS, state);
     778}
     779
     780/**
     781 * \brief Turn on/off rendering of all axes inner grid polygons
     782 */
     783void Renderer::setAxesGridpolysVisibility(bool state)
     784{
     785    setAxisGridpolysVisibility(X_AXIS, state);
     786    setAxisGridpolysVisibility(Y_AXIS, state);
     787    setAxisGridpolysVisibility(Z_AXIS, state);
     788}
     789
     790/**
    768791 * \brief Turn on/off rendering of all axis labels
    769792 */
     
    783806    setAxisTickVisibility(Y_AXIS, state);
    784807    setAxisTickVisibility(Z_AXIS, state);
     808}
     809
     810/**
     811 * \brief Turn on/off rendering of all axis ticks
     812 */
     813void Renderer::setAxesMinorTickVisibility(bool state)
     814{
     815    setAxisMinorTickVisibility(X_AXIS, state);
     816    setAxisMinorTickVisibility(Y_AXIS, state);
     817    setAxisMinorTickVisibility(Z_AXIS, state);
    785818}
    786819
     
    948981
    949982/**
     983 * \brief Turn on/off rendering of single axis gridlines
     984 */
     985void Renderer::setAxisInnerGridVisibility(Axis axis, bool state)
     986{
     987    if (_cubeAxesActor != NULL) {
     988        if (axis == X_AXIS) {
     989            _cubeAxesActor->SetDrawXInnerGridlines((state ? 1 : 0));
     990        } else if (axis == Y_AXIS) {
     991            _cubeAxesActor->SetDrawYInnerGridlines((state ? 1 : 0));
     992        } else if (axis == Z_AXIS) {
     993            _cubeAxesActor->SetDrawZInnerGridlines((state ? 1 : 0));
     994        }
     995        _needsRedraw = true;
     996    }
     997}
     998
     999/**
     1000 * \brief Turn on/off rendering of single axis gridlines
     1001 */
     1002void Renderer::setAxisGridpolysVisibility(Axis axis, bool state)
     1003{
     1004    if (_cubeAxesActor != NULL) {
     1005        if (axis == X_AXIS) {
     1006            _cubeAxesActor->SetDrawXGridpolys((state ? 1 : 0));
     1007        } else if (axis == Y_AXIS) {
     1008            _cubeAxesActor->SetDrawYGridpolys((state ? 1 : 0));
     1009        } else if (axis == Z_AXIS) {
     1010            _cubeAxesActor->SetDrawZGridpolys((state ? 1 : 0));
     1011        }
     1012        _needsRedraw = true;
     1013    }
     1014}
     1015
     1016/**
    9501017 * \brief Toggle label visibility for the specified axis
    9511018 */
     
    10031070    }
    10041071#endif
     1072}
     1073
     1074/**
     1075 * \brief Toggle tick visibility for the specified axis
     1076 */
     1077void Renderer::setAxisMinorTickVisibility(Axis axis, bool state)
     1078{
     1079    if (_cubeAxesActor != NULL) {
     1080        if (axis == X_AXIS) {
     1081            _cubeAxesActor->SetXAxisMinorTickVisibility((state ? 1 : 0));
     1082        } else if (axis == Y_AXIS) {
     1083            _cubeAxesActor->SetYAxisMinorTickVisibility((state ? 1 : 0));
     1084        } else if (axis == Z_AXIS) {
     1085            _cubeAxesActor->SetZAxisMinorTickVisibility((state ? 1 : 0));
     1086        }
     1087        _needsRedraw = true;
     1088    }
    10051089}
    10061090
  • branches/Rappture 1.2/packages/vizservers/vtkvis/RpVtkRenderer.h

    r3223 r3224  
    231231    void setAxesGridVisibility(bool state);
    232232
     233    void setAxesInnerGridVisibility(bool state);
     234
     235    void setAxesGridpolysVisibility(bool state);
     236
    233237    void setAxesLabelVisibility(bool state);
    234238
    235239    void setAxesTickVisibility(bool state);
    236240
     241    void setAxesMinorTickVisibility(bool state);
     242
    237243    void setAxesTickPosition(AxesTickPosition pos);
    238244
     
    261267    void setAxisGridVisibility(Axis axis, bool state);
    262268
     269    void setAxisInnerGridVisibility(Axis axis, bool state);
     270
     271    void setAxisGridpolysVisibility(Axis axis, bool state);
     272
    263273    void setAxisLabelVisibility(Axis axis, bool state);
    264274
    265275    void setAxisTickVisibility(Axis axis, bool state);
     276
     277    void setAxisMinorTickVisibility(Axis axis, bool state);
    266278
    267279    void setAxisTitle(Axis axis, const char *title);
     
    555567
    556568    void setHeightMapContourEdgeWidth(const DataSetId& id, float edgeWidth);
     569
     570    void setHeightMapColorMode(const DataSetId& id,
     571                               HeightMap::ColorMode mode,
     572                               const char *name, double range[2] = NULL);
     573
     574    void setHeightMapColorMode(const DataSetId& id,
     575                               HeightMap::ColorMode mode,
     576                               DataSet::DataAttributeType type,
     577                               const char *name, double range[2] = NULL);
     578
    557579
    558580    // Lines
  • branches/Rappture 1.2/packages/vizservers/vtkvis/RpVtkRendererCmd.cpp

    r3223 r3224  
    714714
    715715static int
     716AxisGridpolysOp(ClientData clientData, Tcl_Interp *interp, int objc,
     717                Tcl_Obj *const *objv)
     718{
     719    bool visible;
     720    if (GetBooleanFromObj(interp, objv[3], &visible) != TCL_OK) {
     721        return TCL_ERROR;
     722    }
     723    const char *string = Tcl_GetString(objv[2]);
     724    char c = string[0];
     725    if ((c == 'x') && (strcmp(string, "x") == 0)) {
     726        g_renderer->setAxisGridpolysVisibility(X_AXIS, visible);
     727    } else if ((c == 'y') && (strcmp(string, "y") == 0)) {
     728        g_renderer->setAxisGridpolysVisibility(Y_AXIS, visible);
     729    } else if ((c == 'z') && (strcmp(string, "z") == 0)) {
     730        g_renderer->setAxisGridpolysVisibility(Z_AXIS, visible);
     731    } else if ((c == 'a') && (strcmp(string, "all") == 0)) {
     732        g_renderer->setAxesGridpolysVisibility(visible);
     733    } else {
     734        Tcl_AppendResult(interp, "bad axis option \"", string,
     735                         "\": should be axisName", (char*)NULL);
     736        return TCL_ERROR;
     737    }
     738    return TCL_OK;
     739}
     740
     741static int
     742AxisInnerGridOp(ClientData clientData, Tcl_Interp *interp, int objc,
     743                Tcl_Obj *const *objv)
     744{
     745    bool visible;
     746    if (GetBooleanFromObj(interp, objv[3], &visible) != TCL_OK) {
     747        return TCL_ERROR;
     748    }
     749    const char *string = Tcl_GetString(objv[2]);
     750    char c = string[0];
     751    if ((c == 'x') && (strcmp(string, "x") == 0)) {
     752        g_renderer->setAxisInnerGridVisibility(X_AXIS, visible);
     753    } else if ((c == 'y') && (strcmp(string, "y") == 0)) {
     754        g_renderer->setAxisInnerGridVisibility(Y_AXIS, visible);
     755    } else if ((c == 'z') && (strcmp(string, "z") == 0)) {
     756        g_renderer->setAxisInnerGridVisibility(Z_AXIS, visible);
     757    } else if ((c == 'a') && (strcmp(string, "all") == 0)) {
     758        g_renderer->setAxesInnerGridVisibility(visible);
     759    } else {
     760        Tcl_AppendResult(interp, "bad axis option \"", string,
     761                         "\": should be axisName", (char*)NULL);
     762        return TCL_ERROR;
     763    }
     764    return TCL_OK;
     765}
     766
     767static int
    716768AxisLabelFontOp(ClientData clientData, Tcl_Interp *interp, int objc,
    717769                Tcl_Obj *const *objv)
     
    877929    } else {
    878930        Tcl_AppendResult(interp, "bad axis option \"", string,
    879                          "\": should be axisName title", (char*)NULL);
     931                         "\": should be axisName", (char*)NULL);
    880932        return TCL_ERROR;
    881933    }
     
    903955    } else {
    904956        Tcl_AppendResult(interp, "bad axis option \"", string,
    905                          "\": should be axisName visible", (char*)NULL);
     957                         "\": should be axisName", (char*)NULL);
     958        return TCL_ERROR;
     959    }
     960    return TCL_OK;
     961}
     962
     963static int
     964AxisMinorTicksVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc,
     965                        Tcl_Obj *const *objv)
     966{
     967    bool visible;
     968    if (GetBooleanFromObj(interp, objv[3], &visible) != TCL_OK) {
     969        return TCL_ERROR;
     970    }
     971    const char *string = Tcl_GetString(objv[2]);
     972    char c = string[0];
     973    if ((c == 'x') && (strcmp(string, "x") == 0)) {
     974        g_renderer->setAxisMinorTickVisibility(X_AXIS, visible);
     975    } else if ((c == 'y') && (strcmp(string, "y") == 0)) {
     976        g_renderer->setAxisMinorTickVisibility(Y_AXIS, visible);
     977    } else if ((c == 'z') && (strcmp(string, "z") == 0)) {
     978        g_renderer->setAxisMinorTickVisibility(Z_AXIS, visible);
     979    } else if ((c == 'a') && (strcmp(string, "all") == 0)) {
     980        g_renderer->setAxesMinorTickVisibility(visible);
     981    } else {
     982        Tcl_AppendResult(interp, "bad axis option \"", string,
     983                         "\": should be axisName", (char*)NULL);
    906984        return TCL_ERROR;
    907985    }
     
    10631141
    10641142static Rappture::CmdSpec axisOps[] = {
    1065     {"color",   1, AxisColorOp, 5, 5, "r g b"},
    1066     {"flymode", 2, AxisFlyModeOp, 3, 3, "mode"},
    1067     {"fontsz",  2, AxisFontSizeOp, 3, 3, "fontPixelSize"},
    1068     {"grid",    1, AxisGridOp, 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"},
    1075     {"name",    1, AxisNameOp, 4, 4, "axis title"},
    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"},
    1081     {"units",   1, AxisUnitsOp, 4, 4, "axis units"},
    1082     {"visible", 1, AxisVisibleOp, 4, 4, "axis bool"}
     1143    {"color",    1, AxisColorOp, 5, 5, "r g b"},
     1144    {"flymode",  2, AxisFlyModeOp, 3, 3, "mode"},
     1145    {"fontsz",   2, AxisFontSizeOp, 3, 3, "fontPixelSize"},
     1146    {"gpolys",   2, AxisGridpolysOp, 4, 4, "axis bool"},
     1147    {"grid",     2, AxisGridOp, 4, 4, "axis bool"},
     1148    {"igrid",    1, AxisInnerGridOp, 4, 4, "axis bool"},
     1149    {"labels",   2, AxisLabelsVisibleOp, 4, 4, "axis bool"},
     1150    {"lfont",    4, AxisLabelFontOp, 4, 4, "axis font"},
     1151    {"lformat",  4, AxisLabelFormatOp, 4, 4, "axis format"},
     1152    {"lfsize",   3, AxisLabelFontSizeOp, 4, 4, "axis fontSize"},
     1153    {"lrot",     2, AxisLabelOrientationOp, 4, 4, "axis rot"},
     1154    {"lscale",   2, AxisLabelScaleOp, 7, 7, "axis bool xpow ypow zpow"},
     1155    {"minticks", 1, AxisMinorTicksVisibleOp, 4, 4, "axis bool"},
     1156    {"name",     1, AxisNameOp, 4, 4, "axis title"},
     1157    {"tfont",    3, AxisTitleFontOp, 4, 4, "axis font"},
     1158    {"tfsize",   3, AxisTitleFontSizeOp, 4, 4, "axis fontSize"},
     1159    {"tickpos",  5, AxisTickPositionOp, 3, 3, "position"},
     1160    {"ticks",    5, AxisTicksVisibleOp, 4, 4, "axis bool"},
     1161    {"trot",     3, AxisTitleOrientationOp, 4, 4, "axis rot"},
     1162    {"units",    1, AxisUnitsOp, 4, 4, "axis units"},
     1163    {"visible",  1, AxisVisibleOp, 4, 4, "axis bool"}
    10831164};
    10841165static int nAxisOps = NumCmdSpecs(axisOps);
     
    46974778
    46984779static int
     4780HeightMapColorOp(ClientData clientData, Tcl_Interp *interp, int objc,
     4781                 Tcl_Obj *const *objv)
     4782{
     4783    float color[3];
     4784    if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK ||
     4785        GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK ||
     4786        GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) {
     4787        return TCL_ERROR;
     4788    }
     4789    if (objc == 6) {
     4790        const char *name = Tcl_GetString(objv[5]);
     4791        g_renderer->setGraphicsObjectColor<HeightMap>(name, color);
     4792    } else {
     4793        g_renderer->setGraphicsObjectColor<HeightMap>("all", color);
     4794    }
     4795    return TCL_OK;
     4796}
     4797
     4798static int
    46994799HeightMapColorMapOp(ClientData clientData, Tcl_Interp *interp, int objc,
    47004800                    Tcl_Obj *const *objv)
     
    47064806    } else {
    47074807        g_renderer->setGraphicsObjectColorMap<HeightMap>("all", colorMapName);
     4808    }
     4809    return TCL_OK;
     4810}
     4811
     4812static int
     4813HeightMapColorModeOp(ClientData clientData, Tcl_Interp *interp, int objc,
     4814                     Tcl_Obj *const *objv)
     4815{
     4816    HeightMap::ColorMode mode;
     4817    const char *str = Tcl_GetString(objv[2]);
     4818    if (str[0] == 'c' && strcmp(str, "ccolor") == 0) {
     4819        mode = HeightMap::COLOR_CONSTANT;
     4820    } else if (str[0] == 's' && strcmp(str, "scalar") == 0) {
     4821        mode = HeightMap::COLOR_BY_SCALAR;
     4822    } else if (str[0] == 'v' && strcmp(str, "vmag") == 0) {
     4823        mode = HeightMap::COLOR_BY_VECTOR_MAGNITUDE;
     4824    } else if (str[0] == 'v' && strcmp(str, "vx") == 0) {
     4825        mode = HeightMap::COLOR_BY_VECTOR_X;
     4826    } else if (str[0] == 'v' && strcmp(str, "vy") == 0) {
     4827        mode = HeightMap::COLOR_BY_VECTOR_Y;
     4828    } else if (str[0] == 'v' && strcmp(str, "vz") == 0) {
     4829        mode = HeightMap::COLOR_BY_VECTOR_Z;
     4830    } else {
     4831        Tcl_AppendResult(interp, "bad color mode option \"", str,
     4832                         "\": should be one of: 'scalar', 'vmag', 'vx', 'vy', 'vz', 'ccolor'", (char*)NULL);
     4833        return TCL_ERROR;
     4834    }
     4835    const char *fieldName = Tcl_GetString(objv[3]);
     4836    if (mode == HeightMap::COLOR_CONSTANT) {
     4837        fieldName = NULL;
     4838    }
     4839    if (objc == 5) {
     4840        const char *name = Tcl_GetString(objv[4]);
     4841        g_renderer->setHeightMapColorMode(name, mode, fieldName);
     4842    } else {
     4843        g_renderer->setHeightMapColorMode("all", mode, fieldName);
    47084844    }
    47094845    return TCL_OK;
     
    50875223static Rappture::CmdSpec heightmapOps[] = {
    50885224    {"add",          1, HeightMapAddOp, 5, 6, "oper value heightscale ?dataSetName?"},
    5089     {"colormap",     3, HeightMapColorMapOp, 3, 4, "colorMapName ?dataSetName?"},
     5225    {"ccolor",       2, HeightMapColorOp, 5, 6, "r g b ?dataSetName?"},
     5226    {"colormap",     7, HeightMapColorMapOp, 3, 4, "colorMapName ?dataSetName?"},
     5227    {"colormode",    7, HeightMapColorModeOp, 4, 5, "mode fieldName ?dataSetName?"},
    50905228    {"contourlist",  3, HeightMapContourListOp, 3, 4, "contourList ?dataSetName?"},
    50915229    {"delete",       1, HeightMapDeleteOp, 2, 3, "?dataSetName?"},
  • branches/Rappture 1.2/packages/vizservers/vtkvis/RpVtkRendererGraphicsObjs.cpp

    r3223 r3224  
    16981698
    16991699/**
     1700 * \brief Set the color mode for the specified DataSet
     1701 */
     1702void Renderer::setHeightMapColorMode(const DataSetId& id,
     1703                                     HeightMap::ColorMode mode,
     1704                                     DataSet::DataAttributeType type,
     1705                                     const char *name, double range[2])
     1706{
     1707    HeightMapHashmap::iterator itr;
     1708
     1709    bool doAll = false;
     1710
     1711    if (id.compare("all") == 0) {
     1712        itr = _heightMaps.begin();
     1713        doAll = true;
     1714    } else {
     1715        itr = _heightMaps.find(id);
     1716    }
     1717    if (itr == _heightMaps.end()) {
     1718        ERROR("HeightMap not found: %s", id.c_str());
     1719        return;
     1720    }
     1721
     1722    do {
     1723        itr->second->setColorMode(mode, type, name, range);
     1724    } while (doAll && ++itr != _heightMaps.end());
     1725
     1726    _needsRedraw = true;
     1727}
     1728
     1729/**
     1730 * \brief Set the color mode for the specified DataSet
     1731 */
     1732void Renderer::setHeightMapColorMode(const DataSetId& id,
     1733                                     HeightMap::ColorMode mode,
     1734                                     const char *name, double range[2])
     1735{
     1736    HeightMapHashmap::iterator itr;
     1737
     1738    bool doAll = false;
     1739
     1740    if (id.compare("all") == 0) {
     1741        itr = _heightMaps.begin();
     1742        doAll = true;
     1743    } else {
     1744        itr = _heightMaps.find(id);
     1745    }
     1746    if (itr == _heightMaps.end()) {
     1747        ERROR("HeightMap not found: %s", id.c_str());
     1748        return;
     1749    }
     1750
     1751    do {
     1752        itr->second->setColorMode(mode, name, range);
     1753    } while (doAll && ++itr != _heightMaps.end());
     1754
     1755    _needsRedraw = true;
     1756}
     1757
     1758/**
    17001759 * \brief Create a new Line and associate it with an ID
    17011760 */
  • branches/Rappture 1.2/packages/vizservers/vtkvis/protocol.txt

    r3223 r3224  
    4848axis fontsz <fontPixelSize>
    4949     Controls size of labels and text in 3D mode
     50axis gpolys <axis> <bool>
     51     Turn on/off inner grid polygons/planes
     52     <axis> = x|y|z|all
    5053axis grid <axis> <bool>
     54     Turn on/off outer gridlines
     55     <axis> = x|y|z|all
     56axis igrid <axis> <bool>
     57     Turn on/off inner gridlines
    5158     <axis> = x|y|z|all
    5259axis labels <axis> <bool>
     
    7481     <ypow> = Explicitly set power on Y axis
    7582     <zpow> = Explicitly set power on Z axis
     83axis minticks <axis> <bool>
     84     Toggle visibility of axis minor tick marks
     85     <axis> = x|y|z|all
    7686axis name <axis> <title>
    7787     <axis> = x|y|z|all
     
    376386          list = {isoval1 isoval2 isoval3...}
    377387heightmap colormap <colorMapName> <?dataSetName?>
     388heightmap colormode <scalar|vmag|vx|vy|vz|ccolor> <fieldName> <?datasetName?>
     389          Set the field used to color the object.  'ccolor' means to use
     390          the constant color defined by the ccolor subcommand.  'scalar' uses
     391          the active scalar field.  'vmag' uses the magnitude of the current
     392          vector field, and 'vx','vy','vz' use the corresponding component of
     393          the active vector field.
    378394heightmap contourlist <list> <?dataSetName?>
    379395heightmap delete <?dataSetName?>
Note: See TracChangeset for help on using the changeset viewer.