20 #include <QTextStream>
24 #include <kfiledialog.h>
25 #include <kmessagebox.h>
37 :
QFrame(parentSplit), horInputCoords(false)
42 RA->setDegType(
false);
45 geoPlace = data->
geo();
46 LocationButton->setText( geoPlace->
fullName() );
49 connect(DateTime, SIGNAL(dateTimeChanged(
const QDateTime&)),
this, SLOT(
slotDateTimeChanged(
const QDateTime&)));
50 DateTime->setDateTime( data->
lt().dateTime() );
52 connect(NowButton, SIGNAL(clicked()),
this, SLOT(
slotNow()));
53 connect(LocationButton, SIGNAL(clicked()),
this, SLOT(
slotLocation()));
54 connect(ObjectButton, SIGNAL(clicked()),
this, SLOT(
slotObject()));
56 connect(RA, SIGNAL(editingFinished()),
this, SLOT(
slotCompute()));
57 connect(Dec, SIGNAL(editingFinished()),
this, SLOT(
slotCompute()));
58 connect(Az, SIGNAL(editingFinished()),
this, SLOT(
slotCompute()));
59 connect(Alt, SIGNAL(editingFinished()),
this, SLOT(
slotCompute()));
61 connect(runButtonBatch, SIGNAL(clicked()),
this, SLOT(
slotRunBatch()));
62 connect(utCheckBatch, SIGNAL(clicked()),
this, SLOT(
slotUtChecked()));
63 connect(dateCheckBatch, SIGNAL(clicked()),
this, SLOT(
slotDateChecked()));
64 connect(azCheckBatch, SIGNAL(clicked()),
this, SLOT(
slotAzChecked()));
65 connect(elCheckBatch, SIGNAL(clicked()),
this, SLOT(
slotElChecked()));
66 connect(latCheckBatch, SIGNAL(clicked()),
this, SLOT(
slotLatChecked()));
67 connect(longCheckBatch, SIGNAL(clicked()),
this, SLOT(
slotLongChecked()));
68 connect(raCheckBatch, SIGNAL(clicked()),
this, SLOT(
slotRaChecked()));
69 connect(decCheckBatch, SIGNAL(clicked()),
this, SLOT(
slotDecChecked()));
86 if ( ld->exec() == QDialog::Accepted ) {
90 LocationButton->setText( geoPlace->fullName() );
100 if ( fd->exec() == QDialog::Accepted ) {
102 RA->showInHours( o->
ra() );
103 Dec->showInDegrees( o->
dec() );
112 LST = geoPlace->GSTtoLST( ut.
gst() );
120 if ( sender()->objectName() ==
"Az" || sender()->objectName() ==
"Alt" ) {
124 dms az = Az->createDms(
true, &ok );
125 if ( ok ) alt = Alt->createDms(
true, &ok );
131 RA->showInHours( sp.
ra() );
132 Dec->showInDegrees( sp.
dec() );
139 dms dec = Dec->createDms(
true, &ok );
140 if ( ok ) ra = RA->createDms(
false, &ok );
144 Az->showInDegrees( sp.
az() );
145 Alt->showInDegrees( sp.
alt() );
151 utBoxBatch->setEnabled( !utCheckBatch->isChecked() );
155 dateBoxBatch->setEnabled( !dateCheckBatch->isChecked() );
159 if ( raCheckBatch->isChecked() ) {
160 raBoxBatch->setEnabled(
false );
164 raBoxBatch->setEnabled(
true );
169 if ( decCheckBatch->isChecked() ) {
170 decBoxBatch->setEnabled(
false );
174 decBoxBatch->setEnabled(
true );
179 epochBoxBatch->setEnabled( !epochCheckBatch->isChecked() );
183 longBoxBatch->setEnabled( !longCheckBatch->isChecked());
187 latBoxBatch->setEnabled( !latCheckBatch->isChecked() );
191 if ( azCheckBatch->isChecked() ) {
192 azBoxBatch->setEnabled(
false );
196 azBoxBatch->setEnabled(
true );
201 if ( elCheckBatch->isChecked() ) {
202 elBoxBatch->setEnabled(
false );
206 elBoxBatch->setEnabled(
true );
210 void modCalcAltAz::horNoCheck() {
211 azCheckBatch->setChecked(
false);
212 azBoxBatch->setEnabled(
false);
213 elCheckBatch->setChecked(
false);
214 elBoxBatch->setEnabled(
false);
215 horInputCoords =
false;
219 void modCalcAltAz::equNoCheck() {
220 raCheckBatch->setChecked(
false);
221 raBoxBatch->setEnabled(
false);
222 decCheckBatch->setChecked(
false);
223 decBoxBatch->setEnabled(
false);
224 horInputCoords =
true;
230 QString inputFileName = InputLineEditBatch->url().toLocalFile();
234 if ( QFile::exists(inputFileName) ) {
235 QFile
f( inputFileName );
236 if ( !f.open( QIODevice::ReadOnly) ) {
237 QString message = i18n(
"Could not open file %1.", f.fileName() );
238 KMessageBox::sorry( 0, message, i18n(
"Could Not Open File" ) );
239 inputFileName.clear();
245 processLines(istream);
249 QString message = i18n(
"Invalid file: %1", inputFileName );
250 KMessageBox::sorry( 0, message, i18n(
"Invalid file" ) );
251 inputFileName.clear();
252 InputLineEditBatch->setText( inputFileName );
257 void modCalcAltAz::processLines(
QTextStream &istream ) {
262 QString outputFileName;
263 outputFileName = OutputLineEditBatch->text();
264 QFile fOut( outputFileName );
265 fOut.open(QIODevice::WriteOnly);
271 long double jd0, jdf;
274 dms raB, decB, latB, longB, azB, elB;
279 while ( ! istream.atEnd() ) {
280 line = istream.readLine();
285 QStringList fields = line.split(
' ' );
291 if(utCheckBatch->isChecked() ) {
292 utB = QTime::fromString( fields[i] );
295 utB = utBoxBatch->time();
297 if ( allRadioBatch->isChecked() )
298 ostream << KGlobal::locale()->formatTime( utB ) << space;
300 if(utCheckBatch->isChecked() )
301 ostream << KGlobal::locale()->formatTime( utB ) << space;
305 if(dateCheckBatch->isChecked() ) {
306 dtB = QDate::fromString( fields[i] );
309 dtB = dateBoxBatch->date();
310 if ( allRadioBatch->isChecked() )
311 ostream << KGlobal::locale()->formatDate( dtB, KLocale::LongDate ).append(space);
313 if(dateCheckBatch->isChecked() )
314 ostream << KGlobal::locale()->formatDate( dtB, KLocale::LongDate ).append(space);
318 if (longCheckBatch->isChecked() ) {
319 longB = dms::fromString( fields[i],
true);
322 longB = longBoxBatch->createDms(
true);
324 if ( allRadioBatch->isChecked() )
325 ostream << longB.toDMSString() << space;
327 if (longCheckBatch->isChecked() )
328 ostream << longB.toDMSString() << space;
333 if (latCheckBatch->isChecked() ) {
334 latB = dms::fromString( fields[i],
true);
337 latB = latBoxBatch->createDms(
true);
338 if ( allRadioBatch->isChecked() )
339 ostream << latB.toDMSString() << space;
341 if (latCheckBatch->isChecked() )
342 ostream << latB.toDMSString() << space;
346 if(epochCheckBatch->isChecked() ) {
350 epoch0B = epochBoxBatch->text();
352 if ( allRadioBatch->isChecked() )
353 ostream << epoch0B << space;
355 if(epochCheckBatch->isChecked() )
356 ostream << epoch0B << space;
367 if (!horInputCoords) {
370 if(raCheckBatch->isChecked() ) {
371 raB = dms::fromString( fields[i],
false);
374 raB = raBoxBatch->createDms(
false);
376 if ( allRadioBatch->isChecked() )
377 ostream << raB.toHMSString() << space;
379 if(raCheckBatch->isChecked() )
380 ostream << raB.toHMSString() << space;
384 if(decCheckBatch->isChecked() ) {
385 decB = dms::fromString( fields[i],
true);
388 decB = decBoxBatch->createDms();
390 if ( allRadioBatch->isChecked() )
391 ostream << decB.toDMSString() << space;
393 if(decCheckBatch->isChecked() )
394 ostream << decB.toDMSString() << space;
399 ostream << sp.
az().toDMSString() << space << sp.
alt().toDMSString() << endl;
404 if(azCheckBatch->isChecked() ) {
405 azB = dms::fromString( fields[i],
false);
408 azB = azBoxBatch->createDms();
410 if ( allRadioBatch->isChecked() )
411 ostream << azB.toHMSString() << space;
413 if(raCheckBatch->isChecked() )
414 ostream << azB.toHMSString() << space;
418 if(elCheckBatch->isChecked() ) {
419 elB = dms::fromString( fields[i],
true);
422 elB = decBoxBatch->createDms();
424 if ( allRadioBatch->isChecked() )
425 ostream << elB.toDMSString() << space;
427 if(elCheckBatch->isChecked() )
428 ostream << elB.toDMSString() << space;
433 ostream << sp.
ra().toHMSString() << space << sp.
dec().toDMSString() << endl;
442 #include "modcalcaltaz.moc"
Dialog for changing the geographic location of the observer.
KStarsData is the backbone of KStars.
void apparentCoord(long double jd0, long double jdf)
Computes the apparent coordinates for this SkyPoint for any epoch, accounting for the effects of prec...
void setAz(dms az)
Sets Az, the Azimuth.
static KStarsData * Instance()
void slotDateTimeChanged(const QDateTime &)
static KStars * Instance()
bool setFromEpoch(double e)
Set the Date/Time from an epoch value, represented as a double.
The sky coordinates of a point in the sky.
const KStarsDateTime & lt() const
Contains all relevant information for specifying a location on Earth: City Name, State/Province name...
static KStarsDateTime currentDateTime(KDateTime::Spec ts=KDateTime::Spec::ClockTime())
void HorizontalToEquatorial(const dms *LST, const dms *lat)
Determine the (RA, Dec) coordinates of the SkyPoint from its (Altitude, Azimuth) coordinates, given the local sidereal time and the observer's latitude.
Extension of KDateTime for KStars KStarsDateTime can represent the date/time as a Julian Day...
An angle, stored as degrees, but expressible in many ways.
void EquatorialToHorizontal(const dms *LST, const dms *lat)
Determine the (Altitude, Azimuth) coordinates of the SkyPoint from its (RA, Dec) coordinates, given the local sidereal time and the observer's latitude.
void setAlt(dms alt)
Sets Alt, the Altitude.
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.