Changeset 3224 for branches/Rappture 1.2/packages
- Timestamp:
- Dec 21, 2012, 5:53:00 PM (12 years ago)
- 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 33 33 _numContours(numContours), 34 34 _colorMap(NULL), 35 _colorMode(COLOR_ CONSTANT),35 _colorMode(COLOR_BY_SCALAR), 36 36 _colorFieldType(DataSet::POINT_DATA), 37 37 _renderer(NULL) … … 50 50 _contours(contours), 51 51 _colorMap(NULL), 52 _colorMode(COLOR_ CONSTANT),52 _colorMode(COLOR_BY_SCALAR), 53 53 _colorFieldType(DataSet::POINT_DATA), 54 54 _renderer(NULL) -
branches/Rappture 1.2/packages/vizservers/vtkvis/RpContour3D.cpp
r3223 r3224 31 31 _numContours(numContours), 32 32 _colorMap(NULL), 33 _colorMode(COLOR_ CONSTANT),33 _colorMode(COLOR_BY_SCALAR), 34 34 _colorFieldType(DataSet::POINT_DATA), 35 35 _renderer(NULL) … … 44 44 _contours(contours), 45 45 _colorMap(NULL), 46 _colorMode(COLOR_ CONSTANT),46 _colorMode(COLOR_BY_SCALAR), 47 47 _colorFieldType(DataSet::POINT_DATA), 48 48 _renderer(NULL) -
branches/Rappture 1.2/packages/vizservers/vtkvis/RpHeightMap.cpp
r3220 r3224 42 42 VtkGraphicsObject(), 43 43 _numContours(numContours), 44 _colorMap(NULL),45 44 _contourEdgeWidth(1.0), 46 45 _warpScale(heightScale), 47 46 _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) 49 52 { 50 53 _contourEdgeColor[0] = 1.0f; 51 54 _contourEdgeColor[1] = 0.0f; 52 55 _contourEdgeColor[2] = 0.0f; 56 _colorFieldRange[0] = DBL_MAX; 57 _colorFieldRange[1] = -DBL_MAX; 53 58 } 54 59 … … 57 62 _numContours(contours.size()), 58 63 _contours(contours), 59 _colorMap(NULL),60 64 _contourEdgeWidth(1.0), 61 65 _warpScale(heightScale), 62 66 _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) 64 72 { 65 73 _contourEdgeColor[0] = 1.0f; 66 74 _contourEdgeColor[1] = 0.0f; 67 75 _contourEdgeColor[2] = 0.0f; 76 _colorFieldRange[0] = DBL_MAX; 77 _colorFieldRange[1] = -DBL_MAX; 68 78 } 69 79 … … 84 94 _dataSet = dataSet; 85 95 96 _renderer = renderer; 97 86 98 if (_dataSet != NULL) { 87 99 if (renderer->getUseCumulativeRange()) { … … 89 101 _dataSet->getActiveScalarsName(), 90 102 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 } 91 111 } else { 92 112 _dataSet->getScalarRange(_dataRange); 113 _dataSet->getVectorRange(_vectorMagnitudeRange); 114 for (int i = 0; i < 3; i++) { 115 _dataSet->getVectorRange(_vectorComponentRange[i], i); 116 } 93 117 } 94 118 … … 126 150 _dsActor = vtkSmartPointer<vtkActor>::New(); 127 151 _dsActor->GetProperty()->SetOpacity(_opacity); 152 _dsActor->GetProperty()->SetColor(_color[0], 153 _color[1], 154 _color[2]); 128 155 _dsActor->GetProperty()->SetEdgeColor(_edgeColor[0], 129 156 _edgeColor[1], … … 462 489 } 463 490 491 setColorMode(_colorMode); 492 464 493 //setAspect(1.0); 465 494 … … 794 823 } 795 824 825 void 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 865 void 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 909 void 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 924 void 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 796 1030 /** 797 1031 * \brief Called when the color map has been edited … … 811 1045 812 1046 _colorMap = cmap; 813 814 if (_lut == NULL) {1047 1048 if (_lut == NULL) { 815 1049 _lut = vtkSmartPointer<vtkLookupTable>::New(); 816 1050 if (_dsMapper != NULL) { … … 818 1052 _dsMapper->SetLookupTable(_lut); 819 1053 } 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; 837 1100 } 838 1101 } … … 919 1182 _contourActor->SetVisibility((state ? 1 : 0)); 920 1183 } 1184 } 1185 1186 /** 1187 * \brief Set RGB color of mesh 1188 */ 1189 void 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]); 921 1196 } 922 1197 -
branches/Rappture 1.2/packages/vizservers/vtkvis/RpHeightMap.h
r3213 r3224 38 38 class HeightMap : public VtkGraphicsObject { 39 39 public: 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 40 49 HeightMap(int numContours, double heightScale = 1.0); 41 50 … … 53 62 54 63 virtual void setLighting(bool state); 64 65 virtual void setColor(float color[3]); 55 66 56 67 virtual void setEdgeVisibility(bool state); … … 82 93 83 94 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); 84 103 85 104 void setColorMap(ColorMap *colorMap); … … 116 135 int _numContours; 117 136 std::vector<double> _contours; 118 ColorMap *_colorMap;119 137 120 138 float _contourEdgeColor[3]; … … 124 142 Axis _sliceAxis; 125 143 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; 126 153 127 154 vtkSmartPointer<vtkLookupTable> _lut; -
branches/Rappture 1.2/packages/vizservers/vtkvis/RpVtkRenderer.cpp
r3221 r3224 712 712 _cubeAxesActor->GetXAxesLinesProperty()->SetColor(color); 713 713 _cubeAxesActor->GetXAxesGridlinesProperty()->SetColor(color); 714 _cubeAxesActor->GetXAxesInnerGridlinesProperty()->SetColor(color); 714 715 _cubeAxesActor->GetYAxesLinesProperty()->SetColor(color); 715 716 _cubeAxesActor->GetYAxesGridlinesProperty()->SetColor(color); 717 _cubeAxesActor->GetYAxesInnerGridlinesProperty()->SetColor(color); 716 718 _cubeAxesActor->GetZAxesLinesProperty()->SetColor(color); 717 719 _cubeAxesActor->GetZAxesGridlinesProperty()->SetColor(color); 720 _cubeAxesActor->GetZAxesInnerGridlinesProperty()->SetColor(color); 718 721 #endif 719 722 _needsRedraw = true; … … 766 769 767 770 /** 771 * \brief Turn on/off rendering of all axes inner gridlines 772 */ 773 void 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 */ 783 void Renderer::setAxesGridpolysVisibility(bool state) 784 { 785 setAxisGridpolysVisibility(X_AXIS, state); 786 setAxisGridpolysVisibility(Y_AXIS, state); 787 setAxisGridpolysVisibility(Z_AXIS, state); 788 } 789 790 /** 768 791 * \brief Turn on/off rendering of all axis labels 769 792 */ … … 783 806 setAxisTickVisibility(Y_AXIS, state); 784 807 setAxisTickVisibility(Z_AXIS, state); 808 } 809 810 /** 811 * \brief Turn on/off rendering of all axis ticks 812 */ 813 void Renderer::setAxesMinorTickVisibility(bool state) 814 { 815 setAxisMinorTickVisibility(X_AXIS, state); 816 setAxisMinorTickVisibility(Y_AXIS, state); 817 setAxisMinorTickVisibility(Z_AXIS, state); 785 818 } 786 819 … … 948 981 949 982 /** 983 * \brief Turn on/off rendering of single axis gridlines 984 */ 985 void 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 */ 1002 void 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 /** 950 1017 * \brief Toggle label visibility for the specified axis 951 1018 */ … … 1003 1070 } 1004 1071 #endif 1072 } 1073 1074 /** 1075 * \brief Toggle tick visibility for the specified axis 1076 */ 1077 void 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 } 1005 1089 } 1006 1090 -
branches/Rappture 1.2/packages/vizservers/vtkvis/RpVtkRenderer.h
r3223 r3224 231 231 void setAxesGridVisibility(bool state); 232 232 233 void setAxesInnerGridVisibility(bool state); 234 235 void setAxesGridpolysVisibility(bool state); 236 233 237 void setAxesLabelVisibility(bool state); 234 238 235 239 void setAxesTickVisibility(bool state); 236 240 241 void setAxesMinorTickVisibility(bool state); 242 237 243 void setAxesTickPosition(AxesTickPosition pos); 238 244 … … 261 267 void setAxisGridVisibility(Axis axis, bool state); 262 268 269 void setAxisInnerGridVisibility(Axis axis, bool state); 270 271 void setAxisGridpolysVisibility(Axis axis, bool state); 272 263 273 void setAxisLabelVisibility(Axis axis, bool state); 264 274 265 275 void setAxisTickVisibility(Axis axis, bool state); 276 277 void setAxisMinorTickVisibility(Axis axis, bool state); 266 278 267 279 void setAxisTitle(Axis axis, const char *title); … … 555 567 556 568 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 557 579 558 580 // Lines -
branches/Rappture 1.2/packages/vizservers/vtkvis/RpVtkRendererCmd.cpp
r3223 r3224 714 714 715 715 static int 716 AxisGridpolysOp(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 741 static int 742 AxisInnerGridOp(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 767 static int 716 768 AxisLabelFontOp(ClientData clientData, Tcl_Interp *interp, int objc, 717 769 Tcl_Obj *const *objv) … … 877 929 } else { 878 930 Tcl_AppendResult(interp, "bad axis option \"", string, 879 "\": should be axisName title", (char*)NULL);931 "\": should be axisName", (char*)NULL); 880 932 return TCL_ERROR; 881 933 } … … 903 955 } else { 904 956 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 963 static int 964 AxisMinorTicksVisibleOp(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); 906 984 return TCL_ERROR; 907 985 } … … 1063 1141 1064 1142 static 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"} 1083 1164 }; 1084 1165 static int nAxisOps = NumCmdSpecs(axisOps); … … 4697 4778 4698 4779 static int 4780 HeightMapColorOp(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 4798 static int 4699 4799 HeightMapColorMapOp(ClientData clientData, Tcl_Interp *interp, int objc, 4700 4800 Tcl_Obj *const *objv) … … 4706 4806 } else { 4707 4807 g_renderer->setGraphicsObjectColorMap<HeightMap>("all", colorMapName); 4808 } 4809 return TCL_OK; 4810 } 4811 4812 static int 4813 HeightMapColorModeOp(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); 4708 4844 } 4709 4845 return TCL_OK; … … 5087 5223 static Rappture::CmdSpec heightmapOps[] = { 5088 5224 {"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?"}, 5090 5228 {"contourlist", 3, HeightMapContourListOp, 3, 4, "contourList ?dataSetName?"}, 5091 5229 {"delete", 1, HeightMapDeleteOp, 2, 3, "?dataSetName?"}, -
branches/Rappture 1.2/packages/vizservers/vtkvis/RpVtkRendererGraphicsObjs.cpp
r3223 r3224 1698 1698 1699 1699 /** 1700 * \brief Set the color mode for the specified DataSet 1701 */ 1702 void 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 */ 1732 void 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 /** 1700 1759 * \brief Create a new Line and associate it with an ID 1701 1760 */ -
branches/Rappture 1.2/packages/vizservers/vtkvis/protocol.txt
r3223 r3224 48 48 axis fontsz <fontPixelSize> 49 49 Controls size of labels and text in 3D mode 50 axis gpolys <axis> <bool> 51 Turn on/off inner grid polygons/planes 52 <axis> = x|y|z|all 50 53 axis grid <axis> <bool> 54 Turn on/off outer gridlines 55 <axis> = x|y|z|all 56 axis igrid <axis> <bool> 57 Turn on/off inner gridlines 51 58 <axis> = x|y|z|all 52 59 axis labels <axis> <bool> … … 74 81 <ypow> = Explicitly set power on Y axis 75 82 <zpow> = Explicitly set power on Z axis 83 axis minticks <axis> <bool> 84 Toggle visibility of axis minor tick marks 85 <axis> = x|y|z|all 76 86 axis name <axis> <title> 77 87 <axis> = x|y|z|all … … 376 386 list = {isoval1 isoval2 isoval3...} 377 387 heightmap colormap <colorMapName> <?dataSetName?> 388 heightmap 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. 378 394 heightmap contourlist <list> <?dataSetName?> 379 395 heightmap delete <?dataSetName?>
Note: See TracChangeset
for help on using the changeset viewer.