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