7 #include "modcalcgalcoord.h"
9 #include "ksnotification.h"
10 #include "dialogs/finddialog.h"
11 #include "skyobjects/skyobject.h"
12 #include "skyobjects/skypoint.h"
14 #include <QTextStream>
17 modCalcGalCoord::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()));
39 void modCalcGalCoord::slotObject()
50 void 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);
94 void modCalcGalCoord::galCheck()
96 galLatCheckBatch->setChecked(
false);
97 galLatBoxBatch->setEnabled(
false);
98 galLongCheckBatch->setChecked(
false);
99 galLongBoxBatch->setEnabled(
false);
100 galInputCoords =
false;
103 void 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;
113 void modCalcGalCoord::slotRaCheckedBatch()
115 if (raCheckBatch->isChecked())
117 raBoxBatch->setEnabled(
false);
122 raBoxBatch->setEnabled(
true);
126 void modCalcGalCoord::slotDecCheckedBatch()
128 if (decCheckBatch->isChecked())
130 decBoxBatch->setEnabled(
false);
135 decBoxBatch->setEnabled(
true);
139 void modCalcGalCoord::slotEpochCheckedBatch()
141 epochCheckBatch->setChecked(
false);
143 if (epochCheckBatch->isChecked())
145 epochBoxBatch->setEnabled(
false);
150 epochBoxBatch->setEnabled(
true);
154 void modCalcGalCoord::slotGalLatCheckedBatch()
156 if (galLatCheckBatch->isChecked())
158 galLatBoxBatch->setEnabled(
false);
163 galLatBoxBatch->setEnabled(
true);
167 void modCalcGalCoord::slotGalLongCheckedBatch()
169 if (galLongCheckBatch->isChecked())
171 galLongBoxBatch->setEnabled(
false);
176 galLongBoxBatch->setEnabled(
true);
180 void 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);
204 KSNotification::sorry(
message,
i18n(
"Invalid file"));
205 InputFileBoxBatch->setUrl(
QUrl());
209 void 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;