20 #include <QTextStream>
22 #include <kfiledialog.h>
23 #include <kmessagebox.h>
35 RA->setDegType(
false);
39 connect( GalLongitude, SIGNAL(editingFinished()),
this, SLOT(
slotComputeCoords()) );
40 connect( GalLatitude, SIGNAL(editingFinished()),
this, SLOT(
slotComputeCoords()) );
42 connect( ObjectButton, SIGNAL(clicked()),
this, SLOT(
slotObject()) );
49 connect(runButtonBatch, SIGNAL(clicked()),
this, SLOT(
slotRunBatch()));
59 QPointer<FindDialog> fd =
new FindDialog(
this );
60 if ( fd->exec() == QDialog::Accepted ) {
62 RA->showInHours( o->
ra() );
63 Dec->showInDegrees( o->
dec() );
70 if ( GalLongitude->hasFocus() )
71 GalLongitude->clearFocus();
75 if ( sender()->objectName() ==
"GalLongitude" || sender()->objectName() ==
"GalLatitude" ) {
79 dms glong = GalLongitude->createDms(
true, &ok );
81 glat = GalLatitude->createDms(
true, &ok );
86 RA->showInHours( sp.
ra() );
87 Dec->showInDegrees( sp.
dec() );
94 dms ra = RA->createDms(
false, &ok );
96 dec = Dec->createDms(
true, &ok );
102 GalLongitude->showInDegrees(glong);
103 GalLatitude->showInDegrees(glat);
108 void modCalcGalCoord::galCheck() {
110 galLatCheckBatch->setChecked(
false);
111 galLatBoxBatch->setEnabled(
false);
112 galLongCheckBatch->setChecked(
false);
113 galLongBoxBatch->setEnabled(
false);
114 galInputCoords =
false;
118 void modCalcGalCoord::equCheck() {
120 raCheckBatch->setChecked(
false);
121 raBoxBatch->setEnabled(
false);
122 decCheckBatch->setChecked(
false);
123 decBoxBatch->setEnabled(
false);
124 epochCheckBatch->setChecked(
false);
125 galInputCoords =
true;
131 if ( raCheckBatch->isChecked() ) {
132 raBoxBatch->setEnabled(
false );
135 raBoxBatch->setEnabled(
true );
141 if ( decCheckBatch->isChecked() ) {
142 decBoxBatch->setEnabled(
false );
145 decBoxBatch->setEnabled(
true );
151 epochCheckBatch->setChecked(
false);
153 if ( epochCheckBatch->isChecked() ) {
154 epochBoxBatch->setEnabled(
false );
157 epochBoxBatch->setEnabled(
true );
163 if ( galLatCheckBatch->isChecked() ) {
164 galLatBoxBatch->setEnabled(
false );
167 galLatBoxBatch->setEnabled(
true );
173 if ( galLongCheckBatch->isChecked() ) {
174 galLongBoxBatch->setEnabled(
false );
177 galLongBoxBatch->setEnabled(
true );
183 QString inputFileName;
185 inputFileName = InputFileBoxBatch->url().toLocalFile();
189 if ( QFile::exists(inputFileName) ) {
190 QFile
f( inputFileName );
191 if ( !f.open( QIODevice::ReadOnly) ) {
192 QString message = i18n(
"Could not open file %1.", f.fileName() );
193 KMessageBox::sorry( 0, message, i18n(
"Could Not Open File" ) );
194 inputFileName.clear();
200 processLines(istream);
204 QString message = i18n(
"Invalid file: %1", inputFileName );
205 KMessageBox::sorry( 0, message, i18n(
"Invalid file" ) );
206 inputFileName.clear();
207 InputFileBoxBatch->setUrl( inputFileName );
212 void modCalcGalCoord::processLines(
QTextStream &istream ) {
217 QString outputFileName;
218 outputFileName = OutputFileBoxBatch->url().toLocalFile();
219 QFile fOut( outputFileName );
220 fOut.open(QIODevice::WriteOnly);
227 dms raB, decB, galLatB, galLongB;
230 while ( ! istream.atEnd() ) {
231 line = istream.readLine();
236 QStringList fields = line.split(
' ' );
242 if (galInputCoords) {
246 if(galLongCheckBatch->isChecked() ) {
247 galLongB = dms::fromString( fields[i],
true);
250 galLongB = galLongBoxBatch->createDms(
true);
252 if ( allRadioBatch->isChecked() )
253 ostream << galLongB.toDMSString() << space;
255 if(galLongCheckBatch->isChecked() )
256 ostream << galLongB.toDMSString() << space;
260 if(galLatCheckBatch->isChecked() ) {
261 galLatB = dms::fromString( fields[i],
true);
264 galLatB = galLatBoxBatch->createDms(
true);
266 if ( allRadioBatch->isChecked() )
267 ostream << galLatB.toDMSString() << space;
269 if(galLatCheckBatch->isChecked() )
270 ostream << galLatB.toDMSString() << space;
274 ostream << sp.
ra().toHMSString() << space << sp.
dec().toDMSString() << epoch0B << endl;
281 if(raCheckBatch->isChecked() ) {
282 raB = dms::fromString( fields[i],
false);
285 raB = raBoxBatch->createDms(
false);
287 if ( allRadioBatch->isChecked() )
288 ostream << raB.toHMSString() << space;
290 if(raCheckBatch->isChecked() )
291 ostream << raB.toHMSString() << space;
295 if(decCheckBatch->isChecked() ) {
296 decB = dms::fromString( fields[i],
true);
299 decB = decBoxBatch->createDms();
301 if ( allRadioBatch->isChecked() )
302 ostream << decB.toDMSString() << space;
304 if(decCheckBatch->isChecked() )
305 ostream << decB.toDMSString() << space;
309 if(epochCheckBatch->isChecked() ) {
313 epoch0B = epochBoxBatch->text();
315 if ( allRadioBatch->isChecked() )
316 ostream << epoch0B << space;
318 if(epochCheckBatch->isChecked() )
319 ostream << epoch0B << space;
324 ostream << galLongB.toDMSString() << space << galLatB.toDMSString() << endl;
334 #include "modcalcgalcoord.moc"
void slotRaCheckedBatch()
void slotEpochCheckedBatch()
void J2000ToB1950(void)
Exact precession from epoch J2000 Besselian epoch 1950.
The sky coordinates of a point in the sky.
modCalcGalCoord(QWidget *p)
void slotGalLatCheckedBatch()
void slotDecCheckedBatch()
void GalacticToEquatorial1950(const dms *galLong, const dms *galLat)
Computes equatorial coordinates referred to 1950 from galactic ones referred to epoch B1950...
void slotGalLongCheckedBatch()
Dialog window for finding SkyObjects by name.
An angle, stored as degrees, but expressible in many ways.
void Equatorial1950ToGalactic(dms &galLong, dms &galLat)
Computes galactic coordinates from equatorial coordinates referred to epoch 1950. ...
Provides all necessary information about an object in the sky: its coordinates, name(s), type, magnitude, and QStringLists of URLs for images and webpages regarding the object.
void B1950ToJ2000(void)
Exact precession from Besselian epoch 1950 to epoch J2000.