------------------------------------------------------------------------------
| 1952 | |
| 1953 | //------------------------------------------------------------------------------ |
| 1954 | void vtkPolarAxesActor::GetSignificantPartFromValues( |
| 1955 | vtkStringArray* valuesStr, std::list<double>& valuesList) |
| 1956 | { |
| 1957 | if (!valuesStr || valuesList.empty()) |
| 1958 | { |
| 1959 | return; |
| 1960 | } |
| 1961 | |
| 1962 | valuesStr->SetNumberOfValues(static_cast<vtkIdType>(valuesList.size())); |
| 1963 | |
| 1964 | std::list<double>::iterator itList; |
| 1965 | vtkIdType i = 0; |
| 1966 | for (itList = valuesList.begin(); itList != valuesList.end(); ++i, ++itList) |
| 1967 | { |
| 1968 | char label[64]; |
| 1969 | if (this->ExponentLocation == VTK_EXPONENT_LABELS) |
| 1970 | { |
| 1971 | VTK_FORMAT_IF_ERROR_RETURN( |
| 1972 | auto result = vtk::format_to_n(label, sizeof(label), this->PolarLabelFormat, *itList); |
| 1973 | *result.out = '\0', ); |
| 1974 | valuesStr->SetValue(i, label); |
| 1975 | } |
| 1976 | else |
| 1977 | { |
| 1978 | std::stringstream ss; |
| 1979 | if (*itList == 0.0) |
| 1980 | { |
| 1981 | ss << std::fixed << std::setw(1) << std::setprecision(0) << 0.0; |
| 1982 | valuesStr->SetValue(i, ss.str().c_str()); |
| 1983 | continue; |
| 1984 | } |
| 1985 | |
| 1986 | // get pow of ten of the value to set the precision of the label |
| 1987 | int exponent = static_cast<int>(std::floor(log10(fabs(*itList)))); |
| 1988 | if (exponent < 0) |
| 1989 | { |
| 1990 | ss << std::fixed << std::setw(1) << setprecision(-exponent) << *itList; |
| 1991 | } |
| 1992 | else |
| 1993 | { |
| 1994 | ss << std::fixed << setprecision(1) << *itList; |
| 1995 | } |
| 1996 | |
| 1997 | valuesStr->SetValue(i, ss.str().c_str()); |
| 1998 | } |
| 1999 | } |
| 2000 | } |
| 2001 | |
| 2002 | //------------------------------------------------------------------------------ |
| 2003 | void vtkPolarAxesActor::AutoScale(vtkViewport* viewport) |