mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-31 09:05:14 +01:00
Added support for nautical units
This commit is contained in:
parent
27632bf07e
commit
820f967bd6
@ -62,12 +62,17 @@ ExportDialog::ExportDialog(Export *exp, QWidget *parent)
|
||||
_bottomMargin = new QDoubleSpinBox();
|
||||
_leftMargin = new QDoubleSpinBox();
|
||||
_rightMargin = new QDoubleSpinBox();
|
||||
QString us = (_export->units == Imperial) ? tr("in") : tr("mm");
|
||||
QString us = (_export->units == Metric) ? tr("mm") : tr("in");
|
||||
_topMargin->setSuffix(UNIT_SPACE + us);
|
||||
_bottomMargin->setSuffix(UNIT_SPACE + us);
|
||||
_leftMargin->setSuffix(UNIT_SPACE + us);
|
||||
_rightMargin->setSuffix(UNIT_SPACE + us);
|
||||
if (_export->units == Imperial) {
|
||||
if (_export->units == Metric) {
|
||||
_topMargin->setValue(_export->margins.top());
|
||||
_bottomMargin->setValue(_export->margins.bottom());
|
||||
_leftMargin->setValue(_export->margins.left());
|
||||
_rightMargin->setValue(_export->margins.right());
|
||||
} else {
|
||||
_topMargin->setValue(_export->margins.top() * MM2IN);
|
||||
_bottomMargin->setValue(_export->margins.bottom() * MM2IN);
|
||||
_leftMargin->setValue(_export->margins.left() * MM2IN);
|
||||
@ -76,11 +81,6 @@ ExportDialog::ExportDialog(Export *exp, QWidget *parent)
|
||||
_bottomMargin->setSingleStep(0.1);
|
||||
_leftMargin->setSingleStep(0.1);
|
||||
_rightMargin->setSingleStep(0.1);
|
||||
} else {
|
||||
_topMargin->setValue(_export->margins.top());
|
||||
_bottomMargin->setValue(_export->margins.bottom());
|
||||
_leftMargin->setValue(_export->margins.left());
|
||||
_rightMargin->setValue(_export->margins.right());
|
||||
}
|
||||
|
||||
QGridLayout *marginsLayout = new QGridLayout();
|
||||
|
@ -53,6 +53,13 @@ QString Format::distance(qreal value, Units units)
|
||||
else
|
||||
return QString::number(value * M2MI, 'f', 1) + UNIT_SPACE
|
||||
+ qApp->translate("Format", "mi");
|
||||
} else if (units == Nautical) {
|
||||
if (value < NMIINM)
|
||||
return QString::number(value * M2FT, 'f', 0) + UNIT_SPACE
|
||||
+ qApp->translate("Format", "ft");
|
||||
else
|
||||
return QString::number(value * M2NMI, 'f', 1) + UNIT_SPACE
|
||||
+ qApp->translate("Format", "nmi");
|
||||
} else {
|
||||
if (value < KMINM)
|
||||
return QString::number(value, 'f', 0) + UNIT_SPACE
|
||||
|
@ -104,15 +104,7 @@ void GraphView::setYUnits(const QString &units)
|
||||
void GraphView::setXUnits()
|
||||
{
|
||||
if (_graphType == Distance) {
|
||||
if (_units == Metric) {
|
||||
if (bounds().width() < KMINM) {
|
||||
_xUnits = tr("m");
|
||||
_xScale = 1;
|
||||
} else {
|
||||
_xUnits = tr("km");
|
||||
_xScale = M2KM;
|
||||
}
|
||||
} else {
|
||||
if (_units == Imperial) {
|
||||
if (bounds().width() < MIINM) {
|
||||
_xUnits = tr("ft");
|
||||
_xScale = M2FT;
|
||||
@ -120,6 +112,22 @@ void GraphView::setXUnits()
|
||||
_xUnits = tr("mi");
|
||||
_xScale = M2MI;
|
||||
}
|
||||
} else if (_units == Nautical) {
|
||||
if (bounds().width() < NMIINM) {
|
||||
_xUnits = tr("ft");
|
||||
_xScale = M2FT;
|
||||
} else {
|
||||
_xUnits = tr("nmi");
|
||||
_xScale = M2NMI;
|
||||
}
|
||||
} else {
|
||||
if (bounds().width() < KMINM) {
|
||||
_xUnits = tr("m");
|
||||
_xScale = 1;
|
||||
} else {
|
||||
_xUnits = tr("km");
|
||||
_xScale = M2KM;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (bounds().width() < MININS) {
|
||||
|
@ -372,6 +372,11 @@ void GUI::createActions()
|
||||
_imperialUnitsAction->setActionGroup(ag);
|
||||
connect(_imperialUnitsAction, SIGNAL(triggered()), this,
|
||||
SLOT(setImperialUnits()));
|
||||
_nauticalUnitsAction = new QAction(tr("Nautical"), this);
|
||||
_nauticalUnitsAction->setCheckable(true);
|
||||
_nauticalUnitsAction->setActionGroup(ag);
|
||||
connect(_nauticalUnitsAction, SIGNAL(triggered()), this,
|
||||
SLOT(setNauticalUnits()));
|
||||
ag = new QActionGroup(this);
|
||||
ag->setExclusive(true);
|
||||
_decimalDegreesAction = new QAction(tr("Decimal degrees (DD)"), this);
|
||||
@ -479,6 +484,7 @@ void GUI::createMenus()
|
||||
QMenu *unitsMenu = settingsMenu->addMenu(tr("Units"));
|
||||
unitsMenu->addAction(_metricUnitsAction);
|
||||
unitsMenu->addAction(_imperialUnitsAction);
|
||||
unitsMenu->addAction(_nauticalUnitsAction);
|
||||
QMenu *coordinatesMenu = settingsMenu->addMenu(tr("Coordinates format"));
|
||||
coordinatesMenu->addAction(_decimalDegreesAction);
|
||||
coordinatesMenu->addAction(_degreesMinutesAction);
|
||||
@ -1463,10 +1469,10 @@ void GUI::writeSettings()
|
||||
TIME_TYPE_DEFAULT)
|
||||
settings.setValue(TIME_TYPE_SETTING, _movingTimeAction->isChecked()
|
||||
? Moving : Total);
|
||||
if ((_imperialUnitsAction->isChecked() ? Imperial : Metric) !=
|
||||
UNITS_DEFAULT)
|
||||
settings.setValue(UNITS_SETTING, _imperialUnitsAction->isChecked()
|
||||
? Imperial : Metric);
|
||||
Units units = _imperialUnitsAction->isChecked() ? Imperial
|
||||
: _nauticalUnitsAction->isChecked() ? Nautical : Metric;
|
||||
if (units != UNITS_DEFAULT)
|
||||
settings.setValue(UNITS_SETTING, units);
|
||||
CoordinatesFormat format = _DMSAction->isChecked() ? DMS
|
||||
: _degreesMinutesAction->isChecked() ? DegreesMinutes : DecimalDegrees;
|
||||
if (format != COORDINATES_DEFAULT)
|
||||
@ -1630,6 +1636,7 @@ void GUI::writeSettings()
|
||||
|
||||
void GUI::readSettings()
|
||||
{
|
||||
int value;
|
||||
QSettings settings(APP_NAME, APP_NAME);
|
||||
|
||||
settings.beginGroup(WINDOW_SETTINGS_GROUP);
|
||||
@ -1644,15 +1651,18 @@ void GUI::readSettings()
|
||||
else
|
||||
_totalTimeAction->activate(QAction::Trigger);
|
||||
|
||||
if (settings.value(UNITS_SETTING, UNITS_DEFAULT).toInt() == Imperial)
|
||||
value = settings.value(UNITS_SETTING, UNITS_DEFAULT).toInt();
|
||||
if (value == Imperial)
|
||||
_imperialUnitsAction->activate(QAction::Trigger);
|
||||
else if (value == Nautical)
|
||||
_nauticalUnitsAction->activate(QAction::Trigger);
|
||||
else
|
||||
_metricUnitsAction->activate(QAction::Trigger);
|
||||
|
||||
if (settings.value(COORDINATES_SETTING, COORDINATES_DEFAULT).toInt() == DMS)
|
||||
value = settings.value(COORDINATES_SETTING, COORDINATES_DEFAULT).toInt();
|
||||
if (value == DMS)
|
||||
_DMSAction->activate(QAction::Trigger);
|
||||
else if (settings.value(COORDINATES_SETTING, COORDINATES_DEFAULT).toInt()
|
||||
== DegreesMinutes)
|
||||
else if (value == DegreesMinutes)
|
||||
_degreesMinutesAction->activate(QAction::Trigger);
|
||||
else
|
||||
_decimalDegreesAction->activate(QAction::Trigger);
|
||||
@ -1900,7 +1910,8 @@ int GUI::mapIndex(const QString &name)
|
||||
|
||||
Units GUI::units() const
|
||||
{
|
||||
return _imperialUnitsAction->isChecked() ? Imperial : Metric;
|
||||
return _imperialUnitsAction->isChecked() ? Imperial
|
||||
: _nauticalUnitsAction->isChecked() ? Nautical : Metric;
|
||||
}
|
||||
|
||||
qreal GUI::distance() const
|
||||
|
@ -74,6 +74,7 @@ private slots:
|
||||
void setMovingTime() {setTimeType(Moving);}
|
||||
void setMetricUnits() {setUnits(Metric);}
|
||||
void setImperialUnits() {setUnits(Imperial);}
|
||||
void setNauticalUnits() {setUnits(Nautical);}
|
||||
void setDistanceGraph() {setGraphType(Distance);}
|
||||
void setTimeGraph() {setGraphType(Time);}
|
||||
void setDecimalDegrees() {setCoordinatesFormat(DecimalDegrees);}
|
||||
@ -170,6 +171,7 @@ private:
|
||||
QAction *_firstAction;
|
||||
QAction *_metricUnitsAction;
|
||||
QAction *_imperialUnitsAction;
|
||||
QAction *_nauticalUnitsAction;
|
||||
QAction *_decimalDegreesAction;
|
||||
QAction *_degreesMinutesAction;
|
||||
QAction *_DMSAction;
|
||||
|
@ -291,6 +291,9 @@ QWidget *OptionsDialog::createDataPage()
|
||||
if (_options->units == Imperial) {
|
||||
_pauseSpeed->setValue(_options->pauseSpeed * MS2MIH);
|
||||
_pauseSpeed->setSuffix(UNIT_SPACE + tr("mi/h"));
|
||||
} else if (_options->units == Nautical) {
|
||||
_pauseSpeed->setValue(_options->pauseSpeed * MS2KN);
|
||||
_pauseSpeed->setSuffix(UNIT_SPACE + tr("kn"));
|
||||
} else {
|
||||
_pauseSpeed->setValue(_options->pauseSpeed * MS2KMH);
|
||||
_pauseSpeed->setSuffix(UNIT_SPACE + tr("km/h"));
|
||||
@ -323,6 +326,9 @@ QWidget *OptionsDialog::createPOIPage()
|
||||
if (_options->units == Imperial) {
|
||||
_poiRadius->setValue(_options->poiRadius / MIINM);
|
||||
_poiRadius->setSuffix(UNIT_SPACE + tr("mi"));
|
||||
} else if (_options->units == Nautical) {
|
||||
_poiRadius->setValue(_options->poiRadius / NMIINM);
|
||||
_poiRadius->setSuffix(UNIT_SPACE + tr("nmi"));
|
||||
} else {
|
||||
_poiRadius->setValue(_options->poiRadius / KMINM);
|
||||
_poiRadius->setSuffix(UNIT_SPACE + tr("km"));
|
||||
@ -525,13 +531,15 @@ void OptionsDialog::accept()
|
||||
_options->powerFilter = _powerFilter->value();
|
||||
_options->outlierEliminate = _outlierEliminate->isChecked();
|
||||
qreal pauseSpeed = (_options->units == Imperial)
|
||||
? _pauseSpeed->value() / MS2MIH : _pauseSpeed->value() / MS2KMH;
|
||||
? _pauseSpeed->value() / MS2MIH : (_options->units == Nautical)
|
||||
? _pauseSpeed->value() / MS2KN : _pauseSpeed->value() / MS2KMH;
|
||||
if (qAbs(pauseSpeed - _options->pauseSpeed) > 0.01)
|
||||
_options->pauseSpeed = pauseSpeed;
|
||||
_options->pauseInterval = _pauseInterval->value();
|
||||
|
||||
qreal poiRadius = (_options->units == Imperial)
|
||||
? _poiRadius->value() * MIINM : _poiRadius->value() * KMINM;
|
||||
? _poiRadius->value() * MIINM : (_options->units == Nautical)
|
||||
? _poiRadius->value() * NMIINM : _poiRadius->value() * KMINM;
|
||||
if (qAbs(poiRadius - _options->poiRadius) > 0.01)
|
||||
_options->poiRadius = poiRadius;
|
||||
|
||||
|
@ -82,6 +82,9 @@ QString ScaleItem::units() const
|
||||
if (_units == Imperial)
|
||||
return _scale ? qApp->translate("ScaleItem", "mi")
|
||||
: qApp->translate("ScaleItem", "ft");
|
||||
else if (_units == Nautical)
|
||||
return _scale ? qApp->translate("ScaleItem", "nmi")
|
||||
: qApp->translate("ScaleItem", "ft");
|
||||
else
|
||||
return _scale ? qApp->translate("ScaleItem", "km")
|
||||
: qApp->translate("ScaleItem", "m");
|
||||
@ -94,8 +97,18 @@ void ScaleItem::computeScale()
|
||||
if (_units == Imperial) {
|
||||
_length = niceNum((res * M2FT * SCALE_WIDTH) / SEGMENTS, 1);
|
||||
if (_length >= MIINFT) {
|
||||
_length = niceNum((res * M2FT * FT2MI * SCALE_WIDTH) / SEGMENTS, 1);
|
||||
_width = (_length / (res * M2FT * FT2MI));
|
||||
_length = niceNum((res * M2MI * SCALE_WIDTH) / SEGMENTS, 1);
|
||||
_width = (_length / (res * M2MI));
|
||||
_scale = true;
|
||||
} else {
|
||||
_width = (_length / (res * M2FT));
|
||||
_scale = false;
|
||||
}
|
||||
} else if (_units == Nautical) {
|
||||
_length = niceNum((res * M2FT * SCALE_WIDTH) / SEGMENTS, 1);
|
||||
if (_length >= NMIINFT) {
|
||||
_length = niceNum((res * M2NMI * SCALE_WIDTH) / SEGMENTS, 1);
|
||||
_width = (_length / (res * M2NMI));
|
||||
_scale = true;
|
||||
} else {
|
||||
_width = (_length / (res * M2FT));
|
||||
|
@ -79,12 +79,15 @@ void SpeedGraph::clear()
|
||||
|
||||
void SpeedGraph::setYUnits(Units units)
|
||||
{
|
||||
if (units == Metric) {
|
||||
GraphView::setYUnits(tr("km/h"));
|
||||
setYScale(MS2KMH);
|
||||
} else {
|
||||
if (units == Nautical) {
|
||||
GraphView::setYUnits(tr("kn"));
|
||||
setYScale(MS2KN);
|
||||
} else if (units == Imperial) {
|
||||
GraphView::setYUnits(tr("mi/h"));
|
||||
setYScale(MS2MIH);
|
||||
} else {
|
||||
GraphView::setYUnits(tr("km/h"));
|
||||
setYScale(MS2KMH);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,8 +16,10 @@ SpeedGraphItem::SpeedGraphItem(const Graph &graph, GraphType type,
|
||||
QString SpeedGraphItem::toolTip() const
|
||||
{
|
||||
ToolTip tt;
|
||||
qreal scale = (_units == Metric) ? MS2KMH : MS2MIH;
|
||||
QString su = (_units == Metric) ? tr("km/h") : tr("mi/h");
|
||||
qreal scale = (_units == Imperial) ? MS2MIH : (_units == Nautical)
|
||||
? MS2KN : MS2KMH;
|
||||
QString su = (_units == Imperial) ? tr("mi/h") : (_units == Nautical)
|
||||
? tr("kn") : tr("km/h");
|
||||
|
||||
tt.insert(tr("Maximum"), QString::number(max() * scale, 'f', 1)
|
||||
+ UNIT_SPACE + su);
|
||||
|
@ -3,14 +3,17 @@
|
||||
|
||||
enum Units {
|
||||
Metric,
|
||||
Imperial
|
||||
Imperial,
|
||||
Nautical
|
||||
};
|
||||
|
||||
#define M2KM 0.001000000000 // m -> km
|
||||
#define M2MI 0.000621371192 // m -> mi
|
||||
#define M2NMI 0.000539956803 // m -> nmi
|
||||
#define M2FT 3.280839900000 // m -> ft
|
||||
#define MS2KMH 3.600000000000 // m/s -> km/h
|
||||
#define MS2MIH 2.236936290000 // m/s -> mi/h
|
||||
#define MS2KN 1.943844490000 // m/s -> kn
|
||||
#define FT2MI 0.000189393939 // ft -> mi
|
||||
#define MM2IN 0.039370100000 // mm -> in
|
||||
#define H2S 0.000277777778 // h -> s
|
||||
@ -18,7 +21,9 @@ enum Units {
|
||||
|
||||
#define KMINM 1000.0 // 1 km in m
|
||||
#define MIINFT 5280.0 // 1 mi in ft
|
||||
#define NMIINFT 6076.11549 // 1 nm in ft
|
||||
#define MIINM 1609.344 // 1 mi in m
|
||||
#define NMIINM 1852 // 1 nmi in m
|
||||
#define MININS 60.0 // 1 min in s
|
||||
#define HINS 3600.0 // 1 hins
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user