----------------------------------------------------------------------------
| 1125 | |
| 1126 | //---------------------------------------------------------------------------- |
| 1127 | void vtkSMTransferFunctionProxy::ResetPropertiesToDefaults( |
| 1128 | const char* arrayName, bool preserve_range) |
| 1129 | { |
| 1130 | try |
| 1131 | { |
| 1132 | if (!preserve_range) |
| 1133 | { |
| 1134 | throw true; |
| 1135 | } |
| 1136 | |
| 1137 | vtkSMProperty* controlPointsProperty = GetControlPointsProperty(this); |
| 1138 | if (!controlPointsProperty) |
| 1139 | { |
| 1140 | throw true; |
| 1141 | } |
| 1142 | |
| 1143 | vtkSMPropertyHelper cntrlPoints(controlPointsProperty); |
| 1144 | unsigned int num_elements = cntrlPoints.GetNumberOfElements(); |
| 1145 | if (num_elements == 0 || num_elements == 4) |
| 1146 | { |
| 1147 | // nothing to do, so restore without rescaling the range |
| 1148 | throw true; |
| 1149 | } |
| 1150 | |
| 1151 | std::vector<vtkTuple<double, 4>> points; |
| 1152 | points.resize(num_elements / 4); |
| 1153 | cntrlPoints.Get(points[0].GetData(), num_elements); |
| 1154 | |
| 1155 | // sort the points by x, just in case user didn't add them correctly. |
| 1156 | std::sort(points.begin(), points.end(), StrictWeakOrdering()); |
| 1157 | |
| 1158 | double range[2] = { points.front().GetData()[0], points.back().GetData()[0] }; |
| 1159 | |
| 1160 | this->RestoreFromSiteSettingsOrXML(arrayName); |
| 1161 | |
| 1162 | this->RescaleTransferFunction(range[0], range[1], false); |
| 1163 | } |
| 1164 | catch (bool val) |
| 1165 | { |
| 1166 | if (val) |
| 1167 | { |
| 1168 | this->RestoreFromSiteSettingsOrXML(arrayName); |
| 1169 | } |
| 1170 | } |
| 1171 | |
| 1172 | // Ensure the lookup table is rebuilt. |
| 1173 | this->UpdateVTKObjects(); |
| 1174 | } |
| 1175 | |
| 1176 | //---------------------------------------------------------------------------- |
| 1177 | Json::Value vtkSMTransferFunctionProxy::ConvertLegacyColorMapXMLToJSON(vtkPVXMLElement* xml) |
no test coverage detected