7#include "modcalcvlsr.h"
10#include "geolocation.h"
13#include "ksnotification.h"
14#include "kstarsdata.h"
15#include "kstarsdatetime.h"
16#include "dialogs/locationdialog.h"
17#include "dialogs/finddialog.h"
18#include "skyobjects/skypoint.h"
19#include "widgets/dmsbox.h"
21#include <KLocalizedString>
26modCalcVlsr::modCalcVlsr(
QWidget *parentSplit) :
QFrame(parentSplit), velocityFlag(0)
29 RA->setUnits(dmsBox::HOURS);
40 connect(Date, SIGNAL(dateTimeChanged(
QDateTime)),
this, SLOT(slotCompute()));
41 connect(NowButton, SIGNAL(clicked()),
this, SLOT(slotNow()));
42 connect(LocationButton, SIGNAL(clicked()),
this, SLOT(slotLocation()));
43 connect(ObjectButton, SIGNAL(clicked()),
this, SLOT(slotFindObject()));
44 connect(RA, SIGNAL(editingFinished()),
this, SLOT(slotCompute()));
45 connect(Dec, SIGNAL(editingFinished()),
this, SLOT(slotCompute()));
46 connect(VLSR, SIGNAL(editingFinished()),
this, SLOT(slotCompute()));
47 connect(VHelio, SIGNAL(editingFinished()),
this, SLOT(slotCompute()));
48 connect(VGeo, SIGNAL(editingFinished()),
this, SLOT(slotCompute()));
49 connect(VTopo, SIGNAL(editingFinished()),
this, SLOT(slotCompute()));
51 connect(RunButtonBatch, SIGNAL(clicked()),
this, SLOT(slotRunBatch()));
56void modCalcVlsr::initGeo(
void)
58 geoPlace = KStarsData::Instance()->
geo();
59 LocationButton->setText(geoPlace->
fullName());
62void modCalcVlsr::slotNow()
68void modCalcVlsr::slotFindObject()
78void modCalcVlsr::slotLocation()
88 LocationButton->setText(geoPlace->
fullName());
96void modCalcVlsr::slotCompute()
98 bool ok1(
false), ok2(
false);
99 SkyPoint sp(RA->createDms(&ok1), Dec->createDms(&ok2));
117 switch (velocityFlag)
121 double vlsr = VLSR->text().toDouble();
122 double vhelio = sp.vHeliocentric(vlsr, dt.djd());
123 double vgeo = sp.vGeocentric(vhelio, dt.djd());
133 double vhelio = VHelio->text().toDouble();
134 double vlsr = sp.vHelioToVlsr(vhelio, dt.djd());
135 double vgeo = sp.vGeocentric(vhelio, dt.djd());
145 double vgeo = VGeo->text().toDouble();
146 double vhelio = sp.vGeoToVHelio(vgeo, dt.djd());
147 double vlsr = sp.vHelioToVlsr(vhelio, dt.djd());
157 double vtopo = VTopo->text().toDouble();
158 double vgeo = sp.vTopoToVGeo(vtopo, vst);
159 double vhelio = sp.vGeoToVHelio(vgeo, dt.djd());
160 double vlsr = sp.vHelioToVlsr(vhelio, dt.djd());
169 qDebug() << Q_FUNC_INFO <<
"Error: do not know which velocity to use for input.";
174void modCalcVlsr::slotUtChecked()
176 if (UTCheckBatch->isChecked())
177 UTBoxBatch->setEnabled(
false);
180 UTBoxBatch->setEnabled(
true);
184void modCalcVlsr::slotDateChecked()
186 if (DateCheckBatch->isChecked())
187 DateBoxBatch->setEnabled(
false);
190 DateBoxBatch->setEnabled(
true);
194void modCalcVlsr::slotRaChecked()
196 if (RACheckBatch->isChecked())
198 RABoxBatch->setEnabled(
false);
202 RABoxBatch->setEnabled(
true);
206void modCalcVlsr::slotDecChecked()
208 if (DecCheckBatch->isChecked())
210 DecBoxBatch->setEnabled(
false);
214 DecBoxBatch->setEnabled(
true);
218void modCalcVlsr::slotEpochChecked()
220 if (EpochCheckBatch->isChecked())
221 EpochBoxBatch->setEnabled(
false);
223 EpochBoxBatch->setEnabled(
true);
226void modCalcVlsr::slotLongChecked()
228 if (LongCheckBatch->isChecked())
229 LongitudeBoxBatch->setEnabled(
false);
231 LongitudeBoxBatch->setEnabled(
true);
234void modCalcVlsr::slotLatChecked()
236 if (LatCheckBatch->isChecked())
237 LatitudeBoxBatch->setEnabled(
false);
240 LatitudeBoxBatch->setEnabled(
true);
244void modCalcVlsr::slotHeightChecked()
246 if (ElevationCheckBatch->isChecked())
247 ElevationBoxBatch->setEnabled(
false);
250 ElevationBoxBatch->setEnabled(
true);
254void modCalcVlsr::slotVlsrChecked()
256 if (InputVelocityCheckBatch->isChecked())
257 InputVelocityBoxBatch->setEnabled(
false);
260 InputVelocityBoxBatch->setEnabled(
true);
264void modCalcVlsr::slotInputFile()
271void modCalcVlsr::slotOutputFile()
278void modCalcVlsr::slotRunBatch()
280 const QString inputFileName = InputFileBoxBatch->url().toLocalFile();
286 QFile f(inputFileName);
289 KSNotification::sorry(
i18n(
"Could not open file %1.", f.fileName()),
i18n(
"Could Not Open File"));
295 processLines(istream);
301 KSNotification::sorry(
i18n(
"Invalid file: %1", inputFileName),
i18n(
"Invalid file"));
302 InputFileBoxBatch->setUrl(
QUrl());
306void modCalcVlsr::processLines(
QTextStream &istream)
312 outputFileName = OutputFileBoxBatch->url().toLocalFile();
313 QFile fOut(outputFileName);
322 double sra, cra, sdc, cdc;
323 dms raB, decB, latB, longB;
325 double vhB, vgB, vtB, vlsrB, heightB;
331 while (!istream.
atEnd())
344 if (UTCheckBatch->isChecked())
350 utB = UTBoxBatch->time();
352 if (AllRadioBatch->isChecked())
354 else if (UTCheckBatch->isChecked())
359 if (DateCheckBatch->isChecked())
365 dtB = DateBoxBatch->date();
366 if (AllRadioBatch->isChecked())
368 else if (DateCheckBatch->isChecked())
373 if (RACheckBatch->isChecked())
379 raB = RABoxBatch->createDms();
381 if (AllRadioBatch->isChecked())
383 else if (RACheckBatch->isChecked())
388 if (DecCheckBatch->isChecked())
394 decB = DecBoxBatch->createDms();
396 if (AllRadioBatch->isChecked())
398 else if (DecCheckBatch->isChecked())
403 if (EpochCheckBatch->isChecked())
409 epoch0B = EpochBoxBatch->text();
411 if (AllRadioBatch->isChecked())
412 ostream << epoch0B << space;
413 else if (EpochCheckBatch->isChecked())
414 ostream << epoch0B << space;
418 if (InputVelocityCheckBatch->isChecked())
420 vlsrB = fields[i].toDouble();
424 vlsrB = InputVelocityComboBatch->currentText().toDouble();
426 if (AllRadioBatch->isChecked())
427 ostream << vlsrB << space;
428 else if (InputVelocityCheckBatch->isChecked())
429 ostream << vlsrB << space;
433 if (LongCheckBatch->isChecked())
439 longB = LongitudeBoxBatch->createDms();
441 if (AllRadioBatch->isChecked())
443 else if (LongCheckBatch->isChecked())
448 if (LatCheckBatch->isChecked())
454 latB = LatitudeBoxBatch->createDms();
455 if (AllRadioBatch->isChecked())
457 else if (LatCheckBatch->isChecked())
462 if (ElevationCheckBatch->isChecked())
464 heightB = fields[i].toDouble();
468 heightB = ElevationBoxBatch->text().toDouble();
470 if (AllRadioBatch->isChecked())
471 ostream << heightB << space;
472 else if (ElevationCheckBatch->isChecked())
473 ostream << heightB << space;
489 vtB = vgB - (vtopo[0] * cdc * cra + vtopo[1] * cdc * sra + vtopo[2] * sdc);
491 ostream << vhB << space << vgB << space << vtB <<
'\n';
void SinCos(double &s, double &c) const
Get the sine and cosine together.
SkyObject * targetObject()
Contains all relevant information for specifying a location on Earth: City Name, State/Province name,...
void setLong(const dms &l)
Set longitude according to dms argument.
void setLat(const dms &l)
Set latitude according to dms argument.
void setElevation(double hg)
Set elevation above sea level.
void TopocentricVelocity(double vtopo[], const dms >)
Computes the velocity in km/s of an observer on the surface of the Earth referred to a system whose o...
Extension of QDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day,...
bool setFromEpoch(double e, EpochType type)
Set the Date/Time from an epoch value, represented as a double.
static KStarsDateTime currentDateTime()
static KStars * Instance()
Dialog for changing the geographic location of the observer.
Provides all necessary information about an object in the sky: its coordinates, name(s),...
The sky coordinates of a point in the sky.
const CachingDms & dec() const
const CachingDms & ra0() const
const CachingDms & ra() const
double vHeliocentric(double vlsr, long double jd)
Computes the radial velocity of a source referred to the solar system barycenter from the radial velo...
double vGeocentric(double vhelio, long double jd)
Computes the radial velocity of a source referred to the center of the earth from the radial velocity...
const CachingDms & dec0() const
An angle, stored as degrees, but expressible in many ways.
static dms fromString(const QString &s, bool deg)
Static function to create a DMS object from a QString.
const QString toDMSString(const bool forceSign=false, const bool machineReadable=false, const bool highPrecision=false) const
const QString toHMSString(const bool machineReadable=false, const bool highPrecision=false) const
QString i18n(const char *text, const TYPE &arg...)
QDate fromString(QStringView string, QStringView format, QCalendar cal)
bool exists() const const
QString getOpenFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, Options options)
QString getSaveFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, Options options)
QString toString(QDate date, FormatType format) const const
QObject * sender() const const
QString & append(QChar ch)
bool isEmpty() const const
QString number(double n, char format, int precision)
QStringList split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
QString trimmed() const const
QString readLine(qint64 maxlen)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
QTime fromString(QStringView string, QStringView format)
QUrl fromLocalFile(const QString &localFile)