------------------------------------------------------------------------------ Method: vtkCubeAxesActor::AdjustRange Purpose: If the range is small, adjust the precision of the values displayed. Arguments: ranges The minimum and maximum specified values in each coordinate direction (min_x, max_x, min_y, max_y, min_z, max_z). NOTE: This may not the bounds of the box in physical space if the user
| 954 | // max_z). NOTE: This may not the bounds of the box in physical space |
| 955 | // if the user has specified a custom axis range. |
| 956 | void vtkCubeAxesActor::AdjustRange(const double ranges[6]) |
| 957 | { |
| 958 | double xrange[2], yrange[2], zrange[2]; |
| 959 | |
| 960 | xrange[0] = ranges[0]; |
| 961 | xrange[1] = ranges[1]; |
| 962 | yrange[0] = ranges[2]; |
| 963 | yrange[1] = ranges[3]; |
| 964 | zrange[0] = ranges[4]; |
| 965 | zrange[1] = ranges[5]; |
| 966 | |
| 967 | if (this->LastXPow != 0) |
| 968 | { |
| 969 | xrange[0] /= pow(10., this->LastXPow); |
| 970 | xrange[1] /= pow(10., this->LastXPow); |
| 971 | } |
| 972 | if (this->LastYPow != 0) |
| 973 | { |
| 974 | yrange[0] /= pow(10., this->LastYPow); |
| 975 | yrange[1] /= pow(10., this->LastYPow); |
| 976 | } |
| 977 | if (this->LastZPow != 0) |
| 978 | { |
| 979 | zrange[0] /= pow(10., this->LastZPow); |
| 980 | zrange[1] /= pow(10., this->LastZPow); |
| 981 | } |
| 982 | |
| 983 | int xAxisDigits = this->Digits(xrange[0], xrange[1]); |
| 984 | if (xAxisDigits != this->LastXAxisDigits) |
| 985 | { |
| 986 | char format[16]; |
| 987 | auto result = vtk::format_to_n(format, sizeof(format), "{{:.{:d}f}}", xAxisDigits); |
| 988 | *result.out = '\0'; |
| 989 | this->SetXLabelFormat(format); |
| 990 | this->LastXAxisDigits = xAxisDigits; |
| 991 | } |
| 992 | |
| 993 | int yAxisDigits = this->Digits(yrange[0], yrange[1]); |
| 994 | if (yAxisDigits != this->LastYAxisDigits) |
| 995 | { |
| 996 | char format[16]; |
| 997 | auto result = vtk::format_to_n(format, sizeof(format), "{{:.{:d}f}}", yAxisDigits); |
| 998 | *result.out = '\0'; |
| 999 | this->SetYLabelFormat(format); |
| 1000 | this->LastYAxisDigits = yAxisDigits; |
| 1001 | } |
| 1002 | |
| 1003 | int zAxisDigits = this->Digits(zrange[0], zrange[1]); |
| 1004 | if (zAxisDigits != this->LastZAxisDigits) |
| 1005 | { |
| 1006 | char format[16]; |
| 1007 | auto result = vtk::format_to_n(format, sizeof(format), "{{:.{:d}f}}", zAxisDigits); |
| 1008 | *result.out = '\0'; |
| 1009 | this->SetZLabelFormat(format); |
| 1010 | this->LastZAxisDigits = zAxisDigits; |
| 1011 | } |
| 1012 | } |
| 1013 |
no test coverage detected