20 #include <QVBoxLayout>
23 #include <kmessagebox.h>
24 #include <knumvalidator.h>
46 setCaption( i18n(
"Set Coordinates Manually" ) );
47 setButtons( KDialog::Ok|KDialog::Cancel );
49 fd->epochBox->setValidator(
new KDoubleValidator( fd->epochBox ) );
50 fd->raBox->setMinimumWidth( fd->raBox->fontMetrics().boundingRect(
"00h 00m 00s").width() );
51 fd->azBox->setMinimumWidth( fd->raBox->fontMetrics().boundingRect(
"00h 00m 00s").width() );
53 fd->raBox->setDegType(
false);
54 fd->raBox->setFocus();
55 enableButtonOk(
false );
57 connect( fd->raBox, SIGNAL(textChanged(
const QString & ) ),
this, SLOT(
checkLineEdits() ) );
58 connect( fd->decBox, SIGNAL(textChanged(
const QString & ) ),
this, SLOT(
checkLineEdits() ) );
59 connect( fd->azBox, SIGNAL(textChanged(
const QString & ) ),
this, SLOT(
checkLineEdits() ) );
60 connect( fd->altBox, SIGNAL(textChanged(
const QString & ) ),
this, SLOT(
checkLineEdits() ) );
61 connect(
this, SIGNAL( okClicked() ),
this, SLOT(
validatePoint() ) );
68 bool raOk(
false), decOk(
false), azOk(
false), altOk(
false);
69 fd->raBox->createDms(
false, &raOk );
70 fd->decBox->createDms(
true, &decOk );
71 fd->azBox->createDms(
true, &azOk );
72 fd->altBox->createDms(
true, &altOk );
73 if ( ( raOk && decOk ) || ( azOk && altOk ) )
74 enableButtonOk(
true );
76 enableButtonOk(
false );
80 bool raOk(
false), decOk(
false), azOk(
false), altOk(
false);
81 dms ra( fd->raBox->createDms(
false, &raOk ) );
82 dms dec( fd->decBox->createDms(
true, &decOk ) );
85 if ( raOk && decOk ) {
87 if ( ra.Hours() < 0.0 || ra.Hours() > 24.0 )
88 message = i18n(
"The Right Ascension value must be between 0.0 and 24.0." );
89 if ( dec.Degrees() < -90.0 || dec.Degrees() > 90.0 )
90 message +=
'\n' + i18n(
"The Declination value must be between -90.0 and 90.0." );
91 if ( ! message.isEmpty() ) {
92 KMessageBox::sorry( 0, message, i18n(
"Invalid Coordinate Data" ) );
97 double epoch0 = getEpoch( fd->epochBox->text() );
98 long double jd0 = epochToJd ( epoch0 );
99 Point.apparentCoord(jd0, ks->data()->ut().djd() );
100 Point.EquatorialToHorizontal( ks->data()->lst(), ks->data()->geo()->lat() );
104 dms az( fd->azBox->createDms(
true, &azOk ) );
105 dms alt( fd->altBox->createDms(
true, &altOk ) );
107 if ( azOk && altOk ) {
109 if ( az.Degrees() < 0.0 || az.Degrees() > 360.0 )
110 message = i18n(
"The Azimuth value must be between 0.0 and 360.0." );
111 if ( alt.Degrees() < -90.0 || alt.Degrees() > 90.0 )
112 message +=
'\n' + i18n(
"The Altitude value must be between -90.0 and 90.0." );
113 if ( ! message.isEmpty() ) {
114 KMessageBox::sorry( 0, message, i18n(
"Invalid Coordinate Data" ) );
120 Point.HorizontalToEquatorial( ks->data()->lst(), ks->data()->geo()->lat() );
134 double epoch = eName.toDouble( &ok );
135 if ( eName.isEmpty() || ! ok )
143 double yearsTo2000 = 2000.0 - epoch;
145 if (epoch == 1950.0) {
147 }
else if ( epoch == 2000.0 ) {
150 return (
J2000 - yearsTo2000 * 365.2425 );
158 return QSize(240,210);
162 fd->fdTab->setCurrentWidget( fd->aaTab );
163 fd->azBox->setFocus();
165 #include "focusdialog.moc"
double getEpoch(const QString &eName)
Convert a string to an epoch number; essentially just converts the string to a double.
long double epochToJd(double epoch)
Convenience function to convert an epoch number (e.g., 2000.0) to the corresponding Julian Day number...
This is the main window for KStars.
void validatePoint()
Attempt to interpret the text in the KLineEdits as Ra and Dec values.
SkyPoint * focus()
Retrieve the Focus point; the position on the sky at the center of the skymap.
An angle, stored as degrees, but expressible in many ways.
~FocusDialog()
Destructor (empty).
void checkLineEdits()
If text has been entered in both KLineEdits, enable the Ok button.
FocusDialogUI(QWidget *parent=0)
FocusDialog(KStars *_ks)
Constructor.
void activateAzAltPage() const
Show the Az/Alt page instead of the RA/Dec page.