summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasem Mutlaq <mutlaqja@ikarustech.com>2016-10-30 13:04:25 (GMT)
committerJasem Mutlaq <mutlaqja@ikarustech.com>2016-10-30 13:04:25 (GMT)
commite1ecb2133ad21b2a3afbb13e493af06b64b95ed0 (patch)
treefa1d928d00b13509f143ffc2661baa57eb643e36
parentcd598e8a0e1023c7c7ec62dc9c329c4dcd7b12cf (diff)
Fix manual focus dialog calculating wrong sky point based on bogus epoch
-rw-r--r--kstars/dialogs/focusdialog.cpp38
-rw-r--r--kstars/dialogs/focusdialog.h7
-rw-r--r--kstars/kstarsactions.cpp49
-rw-r--r--kstars/time/kstarsdatetime.cpp15
4 files changed, 65 insertions, 44 deletions
diff --git a/kstars/dialogs/focusdialog.cpp b/kstars/dialogs/focusdialog.cpp
index 11d0b63..4058ace 100644
--- a/kstars/dialogs/focusdialog.cpp
+++ b/kstars/dialogs/focusdialog.cpp
@@ -32,14 +32,14 @@ FocusDialogUI::FocusDialogUI( QWidget *parent ) : QFrame( parent ) {
setupUi( this );
}
-FocusDialog::FocusDialog( KStars *_ks )
- : QDialog( _ks ), ks( _ks )
+FocusDialog::FocusDialog()
+ : QDialog(KStars::Instance())
{
#ifdef Q_OS_OSX
setWindowFlags(Qt::Tool| Qt::WindowStaysOnTopHint);
#endif
//initialize point to the current focus position
- Point = *ks->map()->focus();
+ Point = SkyMap::Instance()->focus();
UsedAltAz = false; //assume RA/Dec by default
@@ -75,26 +75,33 @@ FocusDialog::FocusDialog( KStars *_ks )
FocusDialog::~FocusDialog(){
}
-void FocusDialog::checkLineEdits() {
+void FocusDialog::checkLineEdits()
+{
bool raOk(false), decOk(false), azOk(false), altOk(false);
+
fd->raBox->createDms( false, &raOk );
fd->decBox->createDms( true, &decOk );
fd->azBox->createDms( true, &azOk );
fd->altBox->createDms( true, &altOk );
if ( ( raOk && decOk ) || ( azOk && altOk ) )
- okB->setEnabled(true );
+ okB->setEnabled(true);
else
okB->setEnabled(false);
}
-void FocusDialog::validatePoint() {
+void FocusDialog::validatePoint()
+{
bool raOk(false), decOk(false), azOk(false), altOk(false);
- dms ra( fd->raBox->createDms( false, &raOk ) ); //false means expressed in hours
+
+ //false means expressed in hours
+ dms ra( fd->raBox->createDms( false, &raOk ) );
dms dec( fd->decBox->createDms( true, &decOk ) );
+
QString message;
- if ( raOk && decOk ) {
+ if ( raOk && decOk )
+ {
//make sure values are in valid range
if ( ra.Hours() < 0.0 || ra.Hours() > 24.0 )
message = i18n( "The Right Ascension value must be between 0.0 and 24.0." );
@@ -105,12 +112,13 @@ void FocusDialog::validatePoint() {
return;
}
- Point.set( ra, dec );
- bool ok; // Ignored. FIXME: Make a version of KStarsDateTime::stringToEpoch that doesn't mandate the ok arg
+ Point->set( ra, dec );
+ bool ok;
+
double epoch0 = KStarsDateTime::stringToEpoch( fd->epochBox->text(), ok );
long double jd0 = KStarsDateTime::epochToJd ( epoch0 );
- Point.apparentCoord(jd0, ks->data()->ut().djd() );
- Point.EquatorialToHorizontal( ks->data()->lst(), ks->data()->geo()->lat() );
+ Point->apparentCoord(jd0, KStarsData::Instance()->ut().djd() );
+ Point->EquatorialToHorizontal( KStarsData::Instance()->lst(), KStarsData::Instance()->geo()->lat() );
QDialog::accept();
} else {
@@ -128,9 +136,9 @@ void FocusDialog::validatePoint() {
return;
}
- Point.setAz( az );
- Point.setAlt( alt );
- Point.HorizontalToEquatorial( ks->data()->lst(), ks->data()->geo()->lat() );
+ Point->setAz( az );
+ Point->setAlt( alt );
+ Point->HorizontalToEquatorial( KStarsData::Instance()->lst(), KStarsData::Instance()->geo()->lat() );
UsedAltAz = true;
diff --git a/kstars/dialogs/focusdialog.h b/kstars/dialogs/focusdialog.h
index 8256ef5..75ae9e8 100644
--- a/kstars/dialogs/focusdialog.h
+++ b/kstars/dialogs/focusdialog.h
@@ -41,13 +41,13 @@ class FocusDialog : public QDialog {
Q_OBJECT
public:
/**Constructor. */
- explicit FocusDialog( KStars *_ks );
+ explicit FocusDialog();
/**Destructor (empty). */
~FocusDialog();
/** @return pointer to the SkyPoint described by the entered RA, Dec */
- inline SkyPoint& point() { return Point; }
+ inline SkyPoint* point() { return Point; }
/** @return suggested size of focus window. */
QSize sizeHint() const;
@@ -70,8 +70,7 @@ public slots:
void validatePoint();
private:
- KStars *ks;
- SkyPoint Point;
+ SkyPoint *Point;
FocusDialogUI *fd;
bool UsedAltAz;
QPushButton *okB;
diff --git a/kstars/kstarsactions.cpp b/kstars/kstarsactions.cpp
index 764391a..1c2fef3 100644
--- a/kstars/kstarsactions.cpp
+++ b/kstars/kstarsactions.cpp
@@ -1123,29 +1123,31 @@ void KStars::slotTrack() {
}
void KStars::slotManualFocus() {
- QPointer<FocusDialog> focusDialog = new FocusDialog( this ); // = new FocusDialog( this );
+ QPointer<FocusDialog> focusDialog = new FocusDialog();
if ( Options::useAltAz() ) focusDialog->activateAzAltPage();
- if ( focusDialog->exec() == QDialog::Accepted ) {
- //DEBUG
- qDebug() << "focusDialog point: " << &focusDialog;
-
+ if ( focusDialog->exec() == QDialog::Accepted )
+ {
//If the requested position is very near the pole, we need to point first
//to an intermediate location just below the pole in order to get the longitudinal
//position (RA/Az) right.
- double realAlt( focusDialog->point().alt().Degrees() );
- double realDec( focusDialog->point().dec().Degrees() );
- if ( Options::useAltAz() && realAlt > 89.0 ) {
- focusDialog->point().setAlt( 89.0 );
- focusDialog->point().HorizontalToEquatorial( data()->lst(), data()->geo()->lat() );
+ double realAlt( focusDialog->point()->alt().Degrees() );
+ double realDec( focusDialog->point()->dec().Degrees() );
+ if ( Options::useAltAz() && realAlt > 89.0 )
+ {
+ focusDialog->point()->setAlt( 89.0 );
+ focusDialog->point()->HorizontalToEquatorial( data()->lst(), data()->geo()->lat() );
}
- if ( ! Options::useAltAz() && realDec > 89.0 ) {
- focusDialog->point().setDec( 89.0 );
- focusDialog->point().EquatorialToHorizontal( data()->lst(), data()->geo()->lat() );
+ if ( ! Options::useAltAz() && realDec > 89.0 )
+ {
+ focusDialog->point()->setDec( 89.0 );
+ focusDialog->point()->EquatorialToHorizontal( data()->lst(), data()->geo()->lat() );
}
- map()->setClickedPoint( & focusDialog->point() );
- if ( Options::isTracking() ) slotTrack();
+ map()->setClickedPoint( focusDialog->point() );
+
+ if ( Options::isTracking() )
+ slotTrack();
map()->slotCenter();
@@ -1157,15 +1159,20 @@ void KStars::slotManualFocus() {
//Also, if the requested position was within 1 degree of the coordinate pole, this will
//automatically correct the final pointing from the intermediate offset position to the final position
data()->setSnapNextFocus();
- if ( Options::useAltAz() ) {
- map()->setDestinationAltAz( focusDialog->point().alt(), focusDialog->point().az() );
- } else {
- map()->setDestination( focusDialog->point().ra(), focusDialog->point().dec() );
+ if ( Options::useAltAz() )
+ {
+ map()->setDestinationAltAz( focusDialog->point()->alt(), focusDialog->point()->az() );
+ }
+ else
+ {
+ map()->setDestination( focusDialog->point()->ra(), focusDialog->point()->dec() );
}
//Now, if the requested point was near a pole, we need to reset the Alt/Dec of the focus.
- if ( Options::useAltAz() && realAlt > 89.0 ) map()->focus()->setAlt( realAlt );
- if ( ! Options::useAltAz() && realDec > 89.0 ) map()->focus()->setDec( realAlt );
+ if ( Options::useAltAz() && realAlt > 89.0 )
+ map()->focus()->setAlt( realAlt );
+ if ( ! Options::useAltAz() && realDec > 89.0 )
+ map()->focus()->setDec( realAlt );
//Don't track if we set Alt/Az coordinates. This way, Alt/Az remain constant.
if ( focusDialog->usedAltAz() )
diff --git a/kstars/time/kstarsdatetime.cpp b/kstars/time/kstarsdatetime.cpp
index ee94753..d172b81 100644
--- a/kstars/time/kstarsdatetime.cpp
+++ b/kstars/time/kstarsdatetime.cpp
@@ -263,17 +263,24 @@ double KStarsDateTime::jdToEpoch(long double jd, KStarsDateTime::EpochType type)
}
-double KStarsDateTime::stringToEpoch(const QString& eName, bool &ok) {
- double epoch;
+double KStarsDateTime::stringToEpoch(const QString& eName, bool &ok)
+{
+ double epoch = J2000;
+ ok = false;
+
if ( eName.isEmpty() ) // By default, assume J2000
- return J2000;
+ return epoch;
if ( eName.startsWith( 'J' ) )
epoch = eName.mid( 1 ).toDouble(&ok);
- else if ( eName.startsWith( 'B' ) ) {
+ else if ( eName.startsWith( 'B' ) )
+ {
epoch = eName.mid( 1 ).toDouble(&ok);
epoch = jdToEpoch( epochToJd( epoch, BESSELIAN ), JULIAN ); // Convert Besselian epoch to Julian epoch
}
+ // Assume it's Julian
+ else
+ epoch = eName.toDouble(&ok);
return epoch;
}