Engauge Digitizer
2
Toggle main menu visibility
Loading...
Searching...
No Matches
Format
FormatDegreesMinutesSecondsPolarTheta.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 "
CoordSymbol.h
"
8
#include "
EngaugeAssert.h
"
9
#include "
FormatDegreesMinutesSecondsPolarTheta.h
"
10
#include "
Logger.h
"
11
#include <qmath.h>
12
#include <QRegularExpression>
13
#include <QStringList>
14
15
const
int
DECIMAL_TO_MINUTES
= 60.0;
16
17
FormatDegreesMinutesSecondsPolarTheta::FormatDegreesMinutesSecondsPolarTheta
()
18
{
19
}
20
21
QString
FormatDegreesMinutesSecondsPolarTheta::formatOutput
(
CoordUnitsPolarTheta
coordUnits,
22
double
value,
23
bool
isNsHemisphere)
const
24
{
25
//qCInfo(ENGAUGE_LOG) << "FormatDegreesMinutesSecondsPolarTheta::formatOutput";
26
27
// See if similar method with hemisphere argument should have been called
28
ENGAUGE_ASSERT
(coordUnits !=
COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS_NSEW
);
29
30
switch
(coordUnits) {
31
case
COORD_UNITS_POLAR_THETA_DEGREES
:
32
return
formatOutputDegrees (value);
33
34
case
COORD_UNITS_POLAR_THETA_DEGREES_MINUTES
:
35
return
formatOutputDegreesMinutes (value);
36
37
case
COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS
:
38
return
formatOutputDegreesMinutesSeconds
(value);
39
40
case
COORD_UNITS_POLAR_THETA_DEGREES_MINUTES_SECONDS_NSEW
:
41
return
formatOutputDegreesMinutesSecondsNsew
(value,
42
isNsHemisphere);
43
44
default
:
45
break
;
46
}
47
48
qCCritical(ENGAUGE_LOG) <<
"FormatDegreesMinutesSecondsPolarTheta::formatOutput"
;
49
ENGAUGE_ASSERT
(
false
);
50
51
return
""
;
52
}
53
54
QString FormatDegreesMinutesSecondsPolarTheta::formatOutputDegrees (
double
value)
const
55
{
56
//qCInfo(ENGAUGE_LOG) << "FormatDegreesMinutesSecondsPolarTheta::formatOutputDegrees";
57
58
// Since version 6 there has been no number-only option (=without degrees symbol) for theta in CoordUnitsPolarTheta.
59
// The degrees symbol causes more problems than it is worth for COORD_UNITS_POLAR_THETA_DEGREES, so we output only
60
// the number and skip the degrees symbol here
61
return
QString (
"%1"
)
62
.arg (value);
63
}
64
65
QString FormatDegreesMinutesSecondsPolarTheta::formatOutputDegreesMinutes (
double
value)
const
66
{
67
//qCInfo(ENGAUGE_LOG) << "FormatDegreesMinutesSecondsPolarTheta::formatOutputDegreesMinutes";
68
69
// Only smallest resolution value is floating point
70
bool
negative = (value < 0);
71
value = qAbs (value);
72
int
degrees = qFloor (value);
73
value -= degrees;
74
double
minutes = value *
DECIMAL_TO_MINUTES
;
75
degrees *= (negative ? -1.0 : 1.0);
76
77
return
QString (
"%1%2 %3%4"
)
78
.arg (degrees)
79
.arg (QChar (
COORD_SYMBOL_DEGREES
))
80
.arg (minutes)
81
.arg (QChar (
COORD_SYMBOL_MINUTES_PRIME
));
82
}
COORD_SYMBOL_DEGREES
const int COORD_SYMBOL_DEGREES
Mathematical symbols for degrees, minutes, seconds input/outputs from/to users.
Definition
CoordSymbol.cpp:9
COORD_SYMBOL_MINUTES_PRIME
const int COORD_SYMBOL_MINUTES_PRIME
Definition
CoordSymbol.cpp:10
CoordSymbol.h
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_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
EngaugeAssert.h
ENGAUGE_ASSERT
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT.
Definition
EngaugeAssert.h:17
DECIMAL_TO_MINUTES
const int DECIMAL_TO_MINUTES
Definition
FormatDegreesMinutesSecondsPolarTheta.cpp:15
FormatDegreesMinutesSecondsPolarTheta.h
Logger.h
FormatDegreesMinutesSecondsBase::formatOutputDegreesMinutesSeconds
QString formatOutputDegreesMinutesSeconds(double value) const
Format as degrees, minutes and seconds without hemisphere.
Definition
FormatDegreesMinutesSecondsBase.cpp:31
FormatDegreesMinutesSecondsBase::formatOutputDegreesMinutesSecondsNsew
QString formatOutputDegreesMinutesSecondsNsew(double value, bool isNsHemisphere) const
Format as degrees, minutes and seconds with hemisphere.
Definition
FormatDegreesMinutesSecondsBase.cpp:55
FormatDegreesMinutesSecondsPolarTheta::FormatDegreesMinutesSecondsPolarTheta
FormatDegreesMinutesSecondsPolarTheta()
Single constructor.
Definition
FormatDegreesMinutesSecondsPolarTheta.cpp:17
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
Generated on
for Engauge Digitizer by
1.17.0