6#include <QIntValidator>
8#include "ui_coordinateform.h"
18using namespace swift::misc::geo;
19using namespace swift::misc::aviation;
20using namespace swift::misc::physical_quantities;
22namespace swift::gui::editors
28 ui->lblp_LatCheck->setToolTips(
"ok",
"wrong format");
29 ui->lblp_LngCheck->setToolTips(
"ok",
"wrong format");
30 ui->lblp_ElvCheck->setToolTips(
"ok",
"wrong format");
32 ui->le_LatDeg->setValidator(
new QIntValidator(-90, 90, ui->le_LatDeg));
33 ui->le_LatMin->setValidator(
new QIntValidator(0, 60, ui->le_LatMin));
34 ui->le_LatSec->setValidator(
new QIntValidator(0, 60, ui->le_LatSec));
35 ui->le_LatSecFrag->setValidator(
new QIntValidator(0, 10E7, ui->le_LatSecFrag));
37 ui->le_LngDeg->setValidator(
new QIntValidator(-180, 180, ui->le_LngDeg));
38 ui->le_LngMin->setValidator(
new QIntValidator(0, 60, ui->le_LngMin));
39 ui->le_LngSec->setValidator(
new QIntValidator(0, 60, ui->le_LngSec));
40 ui->le_LngSecFrag->setValidator(
new QIntValidator(0, 10E7, ui->le_LngSecFrag));
62 this->setCoordinate(c);
69 if (coordinate == m_coordinate)
73 m_coordinate = coordinate;
77 ui->le_Latitude->setText(latWgs);
79 ui->lblp_LatCheck->setTicked(!lat.
isNull());
82 ui->rb_S->setChecked(
true);
86 ui->rb_N->setChecked(
true);
91 ui->le_Longitude->setText(lngWgs);
93 ui->lblp_LngCheck->setTicked(!lng.
isNull());
96 ui->rb_W->setChecked(
true);
100 ui->rb_E->setChecked(
true);
116 ui->le_Elevation->setText(elvString);
117 ui->lblp_ElvCheck->setTicked(!elvString.
isEmpty());
123 ui->le_X->home(
false);
124 ui->le_Y->home(
false);
125 ui->le_Z->home(
false);
132 ui->le_Elevation->setReadOnly(readonly);
133 ui->le_LatDeg->setReadOnly(readonly);
134 ui->le_Latitude->setReadOnly(readonly);
135 ui->le_LatMin->setReadOnly(readonly);
136 ui->le_LatSec->setReadOnly(readonly);
137 ui->le_LatSecFrag->setReadOnly(readonly);
138 ui->le_LngDeg->setReadOnly(readonly);
139 ui->le_LngMin->setReadOnly(readonly);
140 ui->le_LngSec->setReadOnly(readonly);
141 ui->le_LngSecFrag->setReadOnly(readonly);
142 ui->le_Longitude->setReadOnly(readonly);
144 ui->rb_E->setEnabled(!readonly);
145 ui->rb_N->setEnabled(!readonly);
146 ui->rb_S->setEnabled(!readonly);
147 ui->rb_W->setEnabled(!readonly);
149 ui->le_Location->setReadOnly(readonly);
150 ui->le_Location->setVisible(!readonly);
151 ui->lbl_Location->setVisible(!readonly);
168 ui->le_Elevation->setVisible(
show);
169 ui->lbl_Elevation->setVisible(
show);
170 ui->lblp_ElvCheck->setVisible(
show);
171 m_coordinate.setGeodeticHeightToNull();
174 void CCoordinateForm::locationEntered()
176 const QString l = ui->le_Location->text().trimmed().simplified().toUpper();
179 if (sApp && sApp->hasWebDataServices())
184 if (l.
length() == 4 && sApp->getWebDataServices()->getAirportsCount() > 0)
186 airport = sApp->getWebDataServices()->getAirportForIcaoDesignator(l);
194 airport = sApp->getWebDataServices()->getAirportForNameOrLocation(l);
205 const QStringList parts = l.
split(
' ');
206 for (
const QString &p : parts)
208 if (p.contains(
'S') || p.contains(
'N'))
212 else if (p.contains(
'E') || p.contains(
'W'))
219 CCoordinateGeodetic c = m_coordinate;
226 void CCoordinateForm::latEntered()
228 const QString ls = ui->le_Latitude->text();
229 const CLatitude l = CLatitude::fromWgs84(ls);
230 ui->lblp_LatCheck->setTicked(!l.
isNull());
231 CCoordinateGeodetic c = m_coordinate;
236 void CCoordinateForm::latCombinedEntered()
239 int deg = ui->le_LatDeg->text().trimmed().toInt(&ok);
242 int min = ui->le_LatMin->text().trimmed().toInt(&ok);
245 const QString secStr = ui->le_LatSec->text().trimmed() +
"." + ui->le_LatSecFrag->text().trimmed();
250 const CAngle a(deg, min, sec);
252 lat.roundToEpsilon();
253 CCoordinateGeodetic c = m_coordinate;
258 void CCoordinateForm::lngEntered()
260 const QString ls = ui->le_Longitude->text();
261 const CLongitude l = CLongitude::fromWgs84(ls);
262 ui->lblp_LatCheck->setTicked(!l.
isNull());
263 CCoordinateGeodetic c = m_coordinate;
268 void CCoordinateForm::lngCombinedEntered()
271 int deg = ui->le_LngDeg->text().trimmed().toInt(&ok);
274 int min = ui->le_LngMin->text().trimmed().toInt(&ok);
277 const QString secStr = ui->le_LngSec->text().
trimmed() +
"." + ui->le_LngSecFrag->text().
trimmed();
282 const CAngle a(deg, min, sec);
284 lng.roundToEpsilon();
285 CCoordinateGeodetic c = m_coordinate;
290 void CCoordinateForm::elvEntered()
292 const QString e = ui->le_Elevation->text().trimmed();
295 ui->lblp_ElvCheck->setTicked(!e.
isNull());
296 CCoordinateGeodetic c = m_coordinate;
301 void CCoordinateForm::presetOwnAircraftPosition()
static void unifySign(int degrees, int &minutes, double &seconds)
Minutes and secods will get same sign as degrees.
static CAngleUnit deg()
Degrees.
const context::IContextOwnAircraft * getIContextOwnAircraft() const
Direct access to contexts if a CCoreFacade has been initialized.
bool isShuttingDown() const
Is application shutting down?
virtual swift::misc::simulation::CSimulatedAircraft getOwnAircraft() const =0
Get own aircraft.
Status messages, e.g. from Core -> GUI.
Value object encapsulating information about an airpot.
void parseFromString(const QString &value)
Parse value from string.
bool hasValidDbKey() const
Has valid DB key.
void setLatLongFromWgs84(const QString &latitude, const QString &longitude)
Set latitude and longitude.
void setLatitude(const CLatitude &latitude)
Set latitude.
void setGeodeticHeight(const aviation::CAltitude &height)
Set height (ellipsoidal or geodetic height).
void setLongitude(const CLongitude &longitude)
Set longitude.
QString toWgs84(int fractionalDigits=3) const
To WGS84 string.
QString toWgs84(int withFragmentSecDigits=3) const
To WGS84 string.
Geodetic coordinate, a position in 3D space relative to the reference geoid.
virtual CLongitude longitude() const =0
Longitude.
virtual std::array< double, 3 > normalVectorDouble() const =0
Normal vector with double precision.
QString geodeticHeightAsString() const
Height as string.
virtual CLatitude latitude() const =0
Latitude.
DegMinSecFractionalSec asSexagesimalDegMinSec(bool range180Degrees=false) const
As individual values.
bool isNull() const
Is quantity null?
double value(MU unit) const
Value in given unit.
@ SeparatorBestGuess
try to figure out
const aviation::CAircraftSituation & getSituation() const
Get situation.
SWIFT_GUI_EXPORT swift::gui::CGuiApplication * sGui
Single instance of GUI application object.
Free functions in swift::misc.
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QObject * parent() const const
bool contains(QChar ch, Qt::CaseSensitivity cs) const const
bool isEmpty() const const
bool isNull() const const
qsizetype length() const const
QString number(double n, char format, int precision)
QStringList split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
double toDouble(bool *ok) const const
QString trimmed() const const
Value as individual values.
QString fractionalSecAsString(int width=-1) const
Fractional seconds as string.
QString secAsString() const
Seconds as string.
QString minAsString() const
Minutes as string.
QString degAsString() const
Degrees as string.