26 #include <QTextStream>
27 #include <QFileDialog>
33 ellipsoidList <<
"IAU76"
41 spheRadio->setChecked(
true);
42 ellipsoidBox->insertItems(5, ellipsoidList);
52 void modCalcGeodCoord::showLongLat(
void)
56 LongGeoBox->show(data->
geo()->
lng());
57 LatGeoBox->show(data->
geo()->
lat());
58 AltGeoBox->setText(
QString(
"0.0"));
63 geoPlace->changeEllipsoid(index);
68 geoPlace->setXPos(XGeoBox->text().toDouble() * 1000.);
69 geoPlace->setYPos(YGeoBox->text().toDouble() * 1000.);
70 geoPlace->setZPos(ZGeoBox->text().toDouble() * 1000.);
75 geoPlace->setLong(LongGeoBox->createDms());
76 geoPlace->setLat(LatGeoBox->createDms());
77 geoPlace->setElevation(AltGeoBox->text().toDouble());
82 geoPlace->setLong(
dms(0.0));
83 geoPlace->setLat(
dms(0.0));
84 geoPlace->setElevation(0.0);
85 LatGeoBox->clearFields();
86 LongGeoBox->clearFields();
91 if (cartRadio->isChecked())
105 LongGeoBox->show(geoPlace->lng());
106 LatGeoBox->show(geoPlace->lat());
107 AltGeoBox->setText(
QLocale().toString(geoPlace->elevation(), 3));
112 XGeoBox->setText(
QLocale().toString(geoPlace->xPos() / 1000., 6));
113 YGeoBox->setText(
QLocale().toString(geoPlace->yPos() / 1000., 6));
114 ZGeoBox->setText(
QLocale().toString(geoPlace->zPos() / 1000., 6));
117 void modCalcGeodCoord::geoCheck(
void)
119 XGeoBoxBatch->setEnabled(
false);
120 XGeoCheckBatch->setChecked(
false);
121 YGeoBoxBatch->setEnabled(
false);
122 YGeoCheckBatch->setChecked(
false);
123 YGeoBoxBatch->setEnabled(
false);
124 YGeoCheckBatch->setChecked(
false);
125 xyzInputCoords =
false;
128 void modCalcGeodCoord::xyzCheck(
void)
130 LongGeoBoxBatch->setEnabled(
false);
131 LongGeoCheckBatch->setChecked(
false);
132 LatGeoBoxBatch->setEnabled(
false);
133 LatGeoCheckBatch->setChecked(
false);
134 AltGeoBoxBatch->setEnabled(
false);
135 AltGeoCheckBatch->setChecked(
false);
136 xyzInputCoords =
true;
141 if (LongGeoCheckBatch->isChecked())
143 LongGeoBoxBatch->setEnabled(
false);
148 LongGeoBoxBatch->setEnabled(
true);
154 if (LatGeoCheckBatch->isChecked())
156 LatGeoBoxBatch->setEnabled(
false);
161 LatGeoBoxBatch->setEnabled(
true);
167 if (AltGeoCheckBatch->isChecked())
169 AltGeoBoxBatch->setEnabled(
false);
174 AltGeoBoxBatch->setEnabled(
true);
180 if (XGeoCheckBatch->isChecked())
182 XGeoBoxBatch->setEnabled(
false);
187 XGeoBoxBatch->setEnabled(
true);
193 if (YGeoCheckBatch->isChecked())
195 YGeoBoxBatch->setEnabled(
false);
200 YGeoBoxBatch->setEnabled(
true);
206 if (ZGeoCheckBatch->isChecked())
208 ZGeoBoxBatch->setEnabled(
false);
213 ZGeoBoxBatch->setEnabled(
true);
230 void modCalcGeodCoord::slotRunBatch(
void)
232 const QString inputFileName = InputFileBoxBatch->url().toLocalFile();
239 if (!
f.open(QIODevice::ReadOnly))
241 QString message = i18n(
"Could not open file %1.",
f.fileName());
248 processLines(istream);
254 QString message = i18n(
"Invalid file: %1", inputFileName);
256 InputFileBoxBatch->setUrl(
QUrl());
260 void modCalcGeodCoord::processLines(
QTextStream &istream)
265 const QString outputFileName = OutputFileBoxBatch->url().toLocalFile();
266 QFile fOut(outputFileName);
267 fOut.open(QIODevice::WriteOnly);
274 geoPl.setEllipsoid(0);
276 double xB, yB, zB, hB;
279 while (!istream.
atEnd())
296 if (XGeoCheckBatch->isChecked())
298 xB = fields[i].toDouble();
302 xB = XGeoBoxBatch->text().toDouble();
304 if (AllRadioBatch->isChecked())
305 ostream << xB << space;
306 else if (XGeoCheckBatch->isChecked())
307 ostream << xB << space;
311 if (YGeoCheckBatch->isChecked())
313 yB = fields[i].toDouble();
317 yB = YGeoBoxBatch->text().toDouble();
319 if (AllRadioBatch->isChecked())
320 ostream << yB << space;
321 else if (YGeoCheckBatch->isChecked())
322 ostream << yB << space;
325 if (ZGeoCheckBatch->isChecked())
327 zB = fields[i].toDouble();
331 zB = ZGeoBoxBatch->text().toDouble();
333 if (AllRadioBatch->isChecked())
334 ostream << zB << space;
335 else if (YGeoCheckBatch->isChecked())
336 ostream << zB << space;
338 geoPl.setXPos(xB * 1000.0);
339 geoPl.setYPos(yB * 1000.0);
340 geoPl.setZPos(zB * 1000.0);
341 ostream << geoPl.lng()->toDMSString() << space << geoPl.lat()->toDMSString() << space << geoPl.elevation()
350 if (LongGeoCheckBatch->isChecked())
356 longB = LongGeoBoxBatch->createDms(
true);
358 if (AllRadioBatch->isChecked())
360 else if (LongGeoCheckBatch->isChecked())
365 if (LatGeoCheckBatch->isChecked())
371 latB = LatGeoBoxBatch->createDms(
true);
373 if (AllRadioBatch->isChecked())
375 else if (LatGeoCheckBatch->isChecked())
380 if (AltGeoCheckBatch->isChecked())
382 hB = fields[i].toDouble();
386 hB = AltGeoBoxBatch->text().toDouble();
388 if (AllRadioBatch->isChecked())
389 ostream << hB << space;
390 else if (AltGeoCheckBatch->isChecked())
391 ostream << hB << space;
393 geoPl.setLong(longB);
395 geoPl.setElevation(hB);
397 ostream << geoPl.xPos() / 1000.0 << space << geoPl.yPos() / 1000.0 << space << geoPl.zPos() / 1000.0
KStarsData is the backbone of KStars.
static dms fromString(const QString &s, bool deg)
Static function to create a DMS object from a QString.
QString readLine(qint64 maxlen)
modCalcGeodCoord(QWidget *p)
const CachingDms * lng() const
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
void slotClearGeoCoords(void)
static KStarsData * Instance()
void sorry(const QString &message, const QString &title)
static KStars * Instance()
const CachingDms * lat() const
Contains all relevant information for specifying a location on Earth: City Name, State/Province name...
void showCartGeoCoords(void)
void getSphGeoCoords(void)
void slotLatCheckedBatch()
void slotComputeGeoCoords(void)
An angle, stored as degrees, but expressible in many ways.
void slotElevCheckedBatch()
void getCartGeoCoords(void)
QString getSaveFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFlags< QFileDialog::Option > options)
const QString toDMSString(const bool forceSign=false, const bool machineReadable=false, const bool highPrecision=false) const
QString getOpenFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFlags< QFileDialog::Option > options)
void slotLongCheckedBatch()
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void showSpheGeoCoords(void)
QUrl fromLocalFile(const QString &localFile)