7#include "modcalcgalcoord.h"
9#include "ksnotification.h"
10#include "dialogs/finddialog.h"
11#include "skyobjects/skyobject.h"
12#include "skyobjects/skypoint.h"
17modCalcGalCoord::modCalcGalCoord(
QWidget *parentSplit) :
QFrame(parentSplit)
20 RA->setUnits(dmsBox::HOURS);
22 connect(RA, SIGNAL(editingFinished()),
this, SLOT(slotComputeCoords()));
23 connect(Dec, SIGNAL(editingFinished()),
this, SLOT(slotComputeCoords()));
24 connect(GalLongitude, SIGNAL(editingFinished()),
this, SLOT(slotComputeCoords()));
25 connect(GalLatitude, SIGNAL(editingFinished()),
this, SLOT(slotComputeCoords()));
27 connect(ObjectButton, SIGNAL(clicked()),
this, SLOT(slotObject()));
29 connect(decCheckBatch, SIGNAL(clicked()),
this, SLOT(slotDecCheckedBatch()));
30 connect(raCheckBatch, SIGNAL(clicked()),
this, SLOT(slotRaCheckedBatch()));
31 connect(epochCheckBatch, SIGNAL(clicked()),
this, SLOT(slotEpochCheckedBatch()));
32 connect(galLongCheckBatch, SIGNAL(clicked()),
this, SLOT(slotGalLongCheckedBatch()));
33 connect(galLatCheckBatch, SIGNAL(clicked()),
this, SLOT(slotGalLatCheckedBatch()));
34 connect(runButtonBatch, SIGNAL(clicked()),
this, SLOT(slotRunBatch()));
39void modCalcGalCoord::slotObject()
50void modCalcGalCoord::slotComputeCoords()
52 if (GalLongitude->hasFocus())
53 GalLongitude->clearFocus();
62 dms glong = GalLongitude->createDms(&ok);
64 glat = GalLatitude->createDms(&ok);
79 dms ra = RA->createDms(&ok);
81 dec = Dec->createDms(&ok);
88 GalLongitude->show(glong);
89 GalLatitude->show(glat);
94void modCalcGalCoord::galCheck()
96 galLatCheckBatch->setChecked(
false);
97 galLatBoxBatch->setEnabled(
false);
98 galLongCheckBatch->setChecked(
false);
99 galLongBoxBatch->setEnabled(
false);
100 galInputCoords =
false;
103void modCalcGalCoord::equCheck()
105 raCheckBatch->setChecked(
false);
106 raBoxBatch->setEnabled(
false);
107 decCheckBatch->setChecked(
false);
108 decBoxBatch->setEnabled(
false);
109 epochCheckBatch->setChecked(
false);
110 galInputCoords =
true;
113void modCalcGalCoord::slotRaCheckedBatch()
115 if (raCheckBatch->isChecked())
117 raBoxBatch->setEnabled(
false);
122 raBoxBatch->setEnabled(
true);
126void modCalcGalCoord::slotDecCheckedBatch()
128 if (decCheckBatch->isChecked())
130 decBoxBatch->setEnabled(
false);
135 decBoxBatch->setEnabled(
true);
139void modCalcGalCoord::slotEpochCheckedBatch()
141 epochCheckBatch->setChecked(
false);
143 if (epochCheckBatch->isChecked())
145 epochBoxBatch->setEnabled(
false);
150 epochBoxBatch->setEnabled(
true);
154void modCalcGalCoord::slotGalLatCheckedBatch()
156 if (galLatCheckBatch->isChecked())
158 galLatBoxBatch->setEnabled(
false);
163 galLatBoxBatch->setEnabled(
true);
167void modCalcGalCoord::slotGalLongCheckedBatch()
169 if (galLongCheckBatch->isChecked())
171 galLongBoxBatch->setEnabled(
false);
176 galLongBoxBatch->setEnabled(
true);
180void modCalcGalCoord::slotRunBatch()
182 const QString inputFileName = InputFileBoxBatch->url().toLocalFile();
188 QFile f(inputFileName);
191 KSNotification::sorry(
i18n(
"Could not open file %1.", f.fileName()),
i18n(
"Could Not Open File"));
197 processLines(istream);
203 QString message =
i18n(
"Invalid file: %1", inputFileName);
204 KSNotification::sorry(message,
i18n(
"Invalid file"));
205 InputFileBoxBatch->setUrl(
QUrl());
209void modCalcGalCoord::processLines(
QTextStream &istream)
214 const QString outputFileName = OutputFileBoxBatch->url().toLocalFile();
215 QFile fOut(outputFileName);
223 dms raB, decB, galLatB, galLongB;
226 while (!istream.
atEnd())
243 if (galLongCheckBatch->isChecked())
249 galLongB = galLongBoxBatch->createDms();
251 if (allRadioBatch->isChecked())
253 else if (galLongCheckBatch->isChecked())
258 if (galLatCheckBatch->isChecked())
264 galLatB = galLatBoxBatch->createDms();
266 if (allRadioBatch->isChecked())
268 else if (galLatCheckBatch->isChecked())
280 if (raCheckBatch->isChecked())
286 raB = raBoxBatch->createDms();
288 if (allRadioBatch->isChecked())
290 else if (raCheckBatch->isChecked())
295 if (decCheckBatch->isChecked())
301 decB = decBoxBatch->createDms();
303 if (allRadioBatch->isChecked())
305 else if (decCheckBatch->isChecked())
310 if (epochCheckBatch->isChecked())
316 epoch0B = epochBoxBatch->text();
318 if (allRadioBatch->isChecked())
319 ostream << epoch0B << space;
320 else if (epochCheckBatch->isChecked())
321 ostream << epoch0B << space;
SkyObject * targetObject()
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 & ra() const
void B1950ToJ2000(void)
Exact precession from Besselian epoch 1950 to epoch J2000.
void GalacticToEquatorial1950(const dms *galLong, const dms *galLat)
Computes equatorial coordinates referred to 1950 from galactic ones referred to epoch B1950.
void J2000ToB1950(void)
Exact precession from epoch J2000 Besselian epoch 1950.
void Equatorial1950ToGalactic(dms &galLong, dms &galLat)
Computes galactic coordinates from equatorial coordinates referred to epoch 1950.
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...)
bool exists() const const
QObject * sender() const const
QStringList split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
QString trimmed() const const
QTextStream & dec(QTextStream &stream)
QString readLine(qint64 maxlen)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)