7#include "modcalcangdist.h"
11#include "ksnotification.h"
12#include "dialogs/finddialog.h"
13#include "skyobjects/skyobject.h"
14#include "skyobjects/skypoint.h"
15#include "widgets/dmsbox.h"
17#include <KLocalizedString>
25 FirstRA->setUnits(dmsBox::HOURS);
26 SecondRA->setUnits(dmsBox::HOURS);
28 connect(FirstRA, SIGNAL(editingFinished()),
this, SLOT(slotValidatePositions()));
29 connect(FirstDec, SIGNAL(editingFinished()),
this, SLOT(slotValidatePositions()));
30 connect(SecondRA, SIGNAL(editingFinished()),
this, SLOT(slotValidatePositions()));
31 connect(SecondDec, SIGNAL(editingFinished()),
this, SLOT(slotValidatePositions()));
32 connect(FirstRA, SIGNAL(textEdited(
QString)),
this, SLOT(slotResetTitle()));
33 connect(FirstDec, SIGNAL(textEdited(
QString)),
this, SLOT(slotResetTitle()));
34 connect(SecondRA, SIGNAL(textEdited(
QString)),
this, SLOT(slotResetTitle()));
35 connect(SecondDec, SIGNAL(textEdited(
QString)),
this, SLOT(slotResetTitle()));
36 connect(FirstObjectButton, SIGNAL(clicked()),
this, SLOT(slotObjectButton()));
37 connect(SecondObjectButton, SIGNAL(clicked()),
this, SLOT(slotObjectButton()));
38 connect(runButtonBatch, SIGNAL(clicked()),
this, SLOT(slotRunBatch()));
41 slotValidatePositions();
46 dms raCoord, decCoord;
67void modCalcAngDist::slotValidatePositions()
71 sp0 = getCoords(FirstRA, FirstDec, &ok);
74 sp1 = getCoords(SecondRA, SecondDec, &ok);
84 AngDist->setText(
" .... ");
85 PositionAngle->setText(
" .... ");
89void modCalcAngDist::slotObjectButton()
96 FirstRA->show(o->
ra());
97 FirstDec->show(o->
dec());
98 FirstPositionBox->setTitle(
i18n(
"First position: %1", o->
name()));
102 SecondRA->show(o->
ra());
103 SecondDec->show(o->
dec());
104 SecondPositionBox->setTitle(
i18n(
"Second position: %1", o->
name()));
107 slotValidatePositions();
111void modCalcAngDist::slotResetTitle()
115 FirstPositionBox->setTitle(
i18n(
"First position"));
117 SecondPositionBox->setTitle(
i18n(
"Second position"));
120void modCalcAngDist::slotRunBatch()
122 QString inputFileName = InputLineEditBatch->url().toLocalFile();
128 QFile f(inputFileName);
131 QString message =
i18n(
"Could not open file %1.", f.fileName());
132 KSNotification::sorry(message,
i18n(
"Could Not Open File"));
133 inputFileName.
clear();
139 processLines(istream);
145 QString message =
i18n(
"Invalid file: %1", inputFileName);
146 KSNotification::sorry(message,
i18n(
"Invalid file"));
147 inputFileName.
clear();
148 InputLineEditBatch->setText(inputFileName);
154void modCalcAngDist::processLines(
QTextStream &istream)
160 outputFileName = OutputLineEditBatch->text();
161 QFile fOut(outputFileName);
170 dms ra0B, dec0B, ra1B, dec1B, dist;
172 while (!istream.
atEnd())
185 if (ra0CheckBatch->isChecked())
191 ra0B = ra0BoxBatch->createDms();
193 if (allRadioBatch->isChecked())
195 else if (ra0CheckBatch->isChecked())
200 if (dec0CheckBatch->isChecked())
206 dec0B = dec0BoxBatch->createDms();
208 if (allRadioBatch->isChecked())
210 else if (dec0CheckBatch->isChecked())
215 if (ra1CheckBatch->isChecked())
221 ra1B = ra1BoxBatch->createDms();
223 if (allRadioBatch->isChecked())
225 else if (ra1CheckBatch->isChecked())
230 if (dec1CheckBatch->isChecked())
236 dec1B = dec1BoxBatch->createDms();
238 if (allRadioBatch->isChecked())
240 else if (dec1CheckBatch->isChecked())
SkyObject * targetObject()
Provides all necessary information about an object in the sky: its coordinates, name(s),...
virtual QString name(void) const
The sky coordinates of a point in the sky.
const CachingDms & dec() const
const CachingDms & ra() const
dms angularDistanceTo(const SkyPoint *sp, double *const positionAngle=nullptr) const
Computes the angular distance between two SkyObjects.
A QLineEdit which is capable of displaying and parsing angle values flexibly and robustly.
dms createDms(bool *ok=nullptr)
Parse the text in the dmsBox as an angle.
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
modCalcAngDist(QWidget *p)
Constructor.
QString i18n(const char *text, const TYPE &arg...)
QString name(GameStandardAction id)
bool exists() const const
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QObject * sender() const const
bool contains(QChar ch, Qt::CaseSensitivity cs) 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)