00001
00002
00003
00004
00005
00006
00007 #include "EngaugeAssert.h"
00008 #include "FormatCoordsUnitsStrategyPolarTheta.h"
00009 #include "FormatDegreesMinutesSecondsPolarTheta.h"
00010 #include "Logger.h"
00011 #include <QLocale>
00012
00013 FormatCoordsUnitsStrategyPolarTheta::FormatCoordsUnitsStrategyPolarTheta ()
00014 {
00015 }
00016
00017 double FormatCoordsUnitsStrategyPolarTheta::formattedToUnformatted (const QString &string,
00018 const QLocale &locale,
00019 CoordUnitsPolarTheta coordUnits) const
00020 {
00021 LOG4CPP_DEBUG_S ((*mainCat)) << "FormatCoordsUnitsStrategyPolarTheta::formattedToUnformatted";
00022
00023 double value;
00024
00025 switch (coordUnits) {
00026 case COORD_UNITS_POLAR_THETA_DEGREES:
00027 case COORD_UNITS_POLAR_THETA_DEGREES_MINUTES:
00028 case COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS:
00029 case COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS_NSEW:
00030 {
00031 FormatDegreesMinutesSecondsPolarTheta format;
00032 ENGAUGE_ASSERT (format.parseInput (string,
00033 value) == QValidator::Acceptable);
00034 }
00035 break;
00036
00037 case COORD_UNITS_POLAR_THETA_GRADIANS:
00038 case COORD_UNITS_POLAR_THETA_RADIANS:
00039 case COORD_UNITS_POLAR_THETA_TURNS:
00040 value = locale.toDouble (string);
00041 break;
00042
00043 default:
00044 LOG4CPP_ERROR_S ((*mainCat)) << "FormatCoordsUnitsStrategyPolarTheta::unformattedToFormattedStrategyPolarTheta";
00045 ENGAUGE_ASSERT (false);
00046 break;
00047 }
00048
00049 return value;
00050 }
00051
00052 QString FormatCoordsUnitsStrategyPolarTheta::unformattedToFormatted (double valueUnformatted,
00053 const QLocale &locale,
00054 CoordUnitsPolarTheta coordUnits,
00055 const Transformation &transformation,
00056 double valueUnformattedOther) const
00057 {
00058 LOG4CPP_DEBUG_S ((*mainCat)) << "FormatCoordsUnitsStrategyPolarTheta::unformattedToFormatted";
00059
00060 const char FORMAT ('g');
00061 const bool IS_X_THETA = true;
00062
00063 QString valueFormatted;
00064
00065 switch (coordUnits) {
00066 case COORD_UNITS_POLAR_THETA_DEGREES:
00067 case COORD_UNITS_POLAR_THETA_DEGREES_MINUTES:
00068 case COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS:
00069 case COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS_NSEW:
00070 {
00071 FormatDegreesMinutesSecondsPolarTheta format;
00072 valueFormatted = format.formatOutput (coordUnits,
00073 valueUnformatted,
00074 IS_X_THETA);
00075 }
00076 break;
00077
00078 case COORD_UNITS_POLAR_THETA_GRADIANS:
00079 case COORD_UNITS_POLAR_THETA_RADIANS:
00080 case COORD_UNITS_POLAR_THETA_TURNS:
00081 valueFormatted = locale.toString (valueUnformatted,
00082 FORMAT,
00083 precisionDigitsForRawNumber (valueUnformatted,
00084 valueUnformattedOther,
00085 IS_X_THETA,
00086 transformation));
00087 break;
00088
00089 default:
00090 LOG4CPP_ERROR_S ((*mainCat)) << "FormatCoordsUnitsStrategyPolarTheta::unformattedToFormattedStrategyPolarTheta";
00091 ENGAUGE_ASSERT (false);
00092 break;
00093 }
00094
00095 return valueFormatted;
00096 }