Engauge Digitizer 2
Loading...
Searching...
No Matches
FormatCoordsUnitsStrategyPolarTheta.cpp
Go to the documentation of this file.
1/******************************************************************************************************
2 * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3 * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4 * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5 ******************************************************************************************************/
6
8#include "EngaugeAssert.h"
11#include "Logger.h"
12#include <QLocale>
13
17
19 const QLocale &locale,
21{
22 //LOG4CPP_DEBUG_S ((*mainCat)) << "FormatCoordsUnitsStrategyPolarTheta::formattedToUnformatted";
23
24 double value;
25
26 switch (coordUnits) {
31 {
33 ENGAUGE_ASSERT (format.parseInput (string,
34 value) == QValidator::Acceptable);
35 }
36 break;
37
41 value = locale.toDouble (string);
42 break;
43
44 default:
45 LOG4CPP_ERROR_S ((*mainCat)) << "FormatCoordsUnitsStrategyPolarTheta::unformattedToFormattedStrategyPolarTheta";
46 ENGAUGE_ASSERT (false);
47 break;
48 }
49
50 return value;
51}
52
54 const QLocale &locale,
56 const DocumentModelGeneral &modelGeneral,
57 const Transformation &transformation,
58 double valueUnformattedOther) const
59{
60 //LOG4CPP_DEBUG_S ((*mainCat)) << "FormatCoordsUnitsStrategyPolarTheta::unformattedToFormatted";
61
62 const char FORMAT ('g');
63 const bool IS_X_THETA = true;
64
66
67 switch (coordUnits) {
72 {
77 }
78 break;
79
83 valueFormatted = locale.toString (valueUnformatted,
84 FORMAT,
88 modelGeneral,
89 transformation));
90 break;
91
92 default:
93 LOG4CPP_ERROR_S ((*mainCat)) << "FormatCoordsUnitsStrategyPolarTheta::unformattedToFormattedStrategyPolarTheta";
94 ENGAUGE_ASSERT (false);
95 break;
96 }
97
98 return valueFormatted;
99}
CoordUnitsPolarTheta
@ COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS_NSEW
@ COORD_UNITS_POLAR_THETA_TURNS
@ COORD_UNITS_POLAR_THETA_RADIANS
@ COORD_UNITS_POLAR_THETA_DEGREES_MINUTES
@ COORD_UNITS_POLAR_THETA_DEGREES
@ COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS
@ COORD_UNITS_POLAR_THETA_GRADIANS
const bool IS_X_THETA
const int INNER_RADIUS_MIN
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) define ENGAUGE...
log4cpp::Category * mainCat
Definition Logger.cpp:14
Model for DlgSettingsGeneral and CmdSettingsGeneral.
int precisionDigitsForRawNumber(double valueUnformatted, double valueUnformattedOther, bool isXTheta, const DocumentModelGeneral &modelGeneral, const Transformation &transformation) const
Compute precision for outputting an unformatted value, consistent with the resolution at the point wh...
double formattedToUnformatted(const QString &string, const QLocale &locale, CoordUnitsPolarTheta coordUnits) const
Convert formatted string to simple unformatted number.
QString unformattedToFormatted(double valueUnformatted, const QLocale &locale, CoordUnitsPolarTheta coordUnits, const DocumentModelGeneral &modelGeneral, const Transformation &transformation, double valueUnformattedOther) const
Convert simple unformatted number to formatted string.
QValidator::State parseInput(const QString &stringUntrimmed, double &value) const
Parse the input string into a number value.
Angular units according to CoordUnitsPolarTheta.
QString formatOutput(CoordUnitsPolarTheta coordUnits, double value, bool isXTheta) const
Format the degrees/minutes/seconds value. Distinguishing x/theta versus y/radius is required for N/S/...
Affine transformation between screen and graph coordinates, based on digitized axis points.
#define LOG4CPP_ERROR_S(logger)
Definition convenience.h:12