Engauge Digitizer
2
Toggle main menu visibility
Loading...
Searching...
No Matches
Format
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
7
#include "
DocumentModelGeneral.h
"
8
#include "
EngaugeAssert.h
"
9
#include "
FormatCoordsUnitsStrategyPolarTheta.h
"
10
#include "
FormatDegreesMinutesSecondsPolarTheta.h
"
11
#include "
Logger.h
"
12
#include <QLocale>
13
14
FormatCoordsUnitsStrategyPolarTheta::FormatCoordsUnitsStrategyPolarTheta
()
15
{
16
}
17
18
double
FormatCoordsUnitsStrategyPolarTheta::formattedToUnformatted
(
const
QString &
string
,
19
const
QLocale &locale,
20
CoordUnitsPolarTheta
coordUnits)
const
21
{
22
//qCDebug(ENGAUGE_LOG) << "FormatCoordsUnitsStrategyPolarTheta::formattedToUnformatted";
23
24
double
value;
25
26
switch
(coordUnits) {
27
case
COORD_UNITS_POLAR_THETA_DEGREES
:
28
case
COORD_UNITS_POLAR_THETA_DEGREES_MINUTES
:
29
case
COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS
:
30
case
COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS_NSEW
:
31
{
32
FormatDegreesMinutesSecondsPolarTheta
format;
33
ENGAUGE_ASSERT
(format.
parseInput
(
string
,
34
value) == QValidator::Acceptable);
35
}
36
break
;
37
38
case
COORD_UNITS_POLAR_THETA_GRADIANS
:
39
case
COORD_UNITS_POLAR_THETA_RADIANS
:
40
case
COORD_UNITS_POLAR_THETA_TURNS
:
41
value = locale.toDouble (
string
);
42
break
;
43
44
default
:
45
qCCritical(ENGAUGE_LOG) <<
"FormatCoordsUnitsStrategyPolarTheta::unformattedToFormattedStrategyPolarTheta"
;
46
ENGAUGE_ASSERT
(
false
);
47
break
;
48
}
49
50
return
value;
51
}
52
53
QString
FormatCoordsUnitsStrategyPolarTheta::unformattedToFormatted
(
double
valueUnformatted,
54
const
QLocale &locale,
55
CoordUnitsPolarTheta
coordUnits,
56
const
DocumentModelGeneral
&modelGeneral,
57
const
Transformation
&transformation,
58
double
valueUnformattedOther)
const
59
{
60
//qCDebug(ENGAUGE_LOG) << "FormatCoordsUnitsStrategyPolarTheta::unformattedToFormatted";
61
62
const
char
FORMAT (
'g'
);
63
const
bool
IS_X_THETA
=
true
;
64
65
QString valueFormatted;
66
67
switch
(coordUnits) {
68
case
COORD_UNITS_POLAR_THETA_DEGREES
:
69
case
COORD_UNITS_POLAR_THETA_DEGREES_MINUTES
:
70
case
COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS
:
71
case
COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS_NSEW
:
72
{
73
FormatDegreesMinutesSecondsPolarTheta
format;
74
valueFormatted = format.
formatOutput
(coordUnits,
75
valueUnformatted,
76
IS_X_THETA
);
77
}
78
break
;
79
80
case
COORD_UNITS_POLAR_THETA_GRADIANS
:
81
case
COORD_UNITS_POLAR_THETA_RADIANS
:
82
case
COORD_UNITS_POLAR_THETA_TURNS
:
83
valueFormatted = locale.toString (valueUnformatted,
84
FORMAT,
85
precisionDigitsForRawNumber
(valueUnformatted,
86
valueUnformattedOther,
87
IS_X_THETA
,
88
modelGeneral,
89
transformation));
90
break
;
91
92
default
:
93
qCCritical(ENGAUGE_LOG) <<
"FormatCoordsUnitsStrategyPolarTheta::unformattedToFormattedStrategyPolarTheta"
;
94
ENGAUGE_ASSERT
(
false
);
95
break
;
96
}
97
98
return
valueFormatted;
99
}
CoordUnitsPolarTheta
CoordUnitsPolarTheta
Definition
CoordUnitsPolarTheta.h:14
COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS_NSEW
@ COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS_NSEW
Definition
CoordUnitsPolarTheta.h:18
COORD_UNITS_POLAR_THETA_TURNS
@ COORD_UNITS_POLAR_THETA_TURNS
Definition
CoordUnitsPolarTheta.h:21
COORD_UNITS_POLAR_THETA_RADIANS
@ COORD_UNITS_POLAR_THETA_RADIANS
Definition
CoordUnitsPolarTheta.h:20
COORD_UNITS_POLAR_THETA_DEGREES_MINUTES
@ COORD_UNITS_POLAR_THETA_DEGREES_MINUTES
Definition
CoordUnitsPolarTheta.h:16
COORD_UNITS_POLAR_THETA_DEGREES
@ COORD_UNITS_POLAR_THETA_DEGREES
Definition
CoordUnitsPolarTheta.h:15
COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS
@ COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS
Definition
CoordUnitsPolarTheta.h:17
COORD_UNITS_POLAR_THETA_GRADIANS
@ COORD_UNITS_POLAR_THETA_GRADIANS
Definition
CoordUnitsPolarTheta.h:19
IS_X_THETA
const bool IS_X_THETA
Definition
DlgEditPointAxis.cpp:36
DocumentModelGeneral.h
EngaugeAssert.h
ENGAUGE_ASSERT
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT.
Definition
EngaugeAssert.h:17
FormatCoordsUnitsStrategyPolarTheta.h
FormatDegreesMinutesSecondsPolarTheta.h
Logger.h
DocumentModelGeneral
Model for DlgSettingsGeneral and CmdSettingsGeneral.
Definition
DocumentModelGeneral.h:17
FormatCoordsUnitsStrategyAbstractBase::precisionDigitsForRawNumber
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...
Definition
FormatCoordsUnitsStrategyAbstractBase.cpp:17
FormatCoordsUnitsStrategyPolarTheta::formattedToUnformatted
double formattedToUnformatted(const QString &string, const QLocale &locale, CoordUnitsPolarTheta coordUnits) const
Convert formatted string to simple unformatted number.
Definition
FormatCoordsUnitsStrategyPolarTheta.cpp:18
FormatCoordsUnitsStrategyPolarTheta::FormatCoordsUnitsStrategyPolarTheta
FormatCoordsUnitsStrategyPolarTheta()
Single constructor.
Definition
FormatCoordsUnitsStrategyPolarTheta.cpp:14
FormatCoordsUnitsStrategyPolarTheta::unformattedToFormatted
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.
Definition
FormatCoordsUnitsStrategyPolarTheta.cpp:53
FormatDegreesMinutesSecondsBase::parseInput
QValidator::State parseInput(const QString &stringUntrimmed, double &value) const
Parse the input string into a number value.
Definition
FormatDegreesMinutesSecondsBase.cpp:88
FormatDegreesMinutesSecondsPolarTheta
Angular units according to CoordUnitsPolarTheta.
Definition
FormatDegreesMinutesSecondsPolarTheta.h:16
FormatDegreesMinutesSecondsPolarTheta::formatOutput
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/...
Definition
FormatDegreesMinutesSecondsPolarTheta.cpp:21
Transformation
Affine transformation between screen and graph coordinates, based on digitized axis points.
Definition
Transformation.h:32
Generated on
for Engauge Digitizer by
1.17.0