diff --git a/src/gui/SearchDialog.cpp b/src/gui/SearchDialog.cpp index 9909673a4a8cd3..5c62aa7894ece4 100644 --- a/src/gui/SearchDialog.cpp +++ b/src/gui/SearchDialog.cpp @@ -353,6 +353,7 @@ void SearchDialog::setCoordinateSystem(int csID) ui->AxisXSpinBox->setRadians(0.); ui->AxisYSpinBox->setRadians(0.); conf->setValue("search/coordinate_system", currentCoordinateSystemID); + setCenterOfScreenCoordinates(); } // Initialize the dialog widgets and connect the signals/slots @@ -393,6 +394,7 @@ void SearchDialog::createDialogContent() connect(ui->AxisXSpinBox, SIGNAL(valueChanged()), this, SLOT(manualPositionChanged())); connect(ui->AxisYSpinBox, SIGNAL(valueChanged()), this, SLOT(manualPositionChanged())); connect(ui->goPushButton, SIGNAL(clicked(bool)), this, SLOT(manualPositionChanged())); + setCenterOfScreenCoordinates(); connect(ui->alphaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetterClicked())); connect(ui->betaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetterClicked())); @@ -667,6 +669,69 @@ void SearchDialog::setSimpleStyle() ui->coordinateSystemComboBox->setVisible(false); } +void SearchDialog::setCenterOfScreenCoordinates() +{ + StelCore *core = StelApp::getInstance().getCore(); + const auto projector = core->getProjection(StelCore::FrameJ2000, StelCore::RefractionMode::RefractionOff); + Vec2i centerScreen(projector->getViewportPosX() + projector->getViewportWidth() / 2, + projector->getViewportPosY() + projector->getViewportHeight() / 2); + Vec3d centerPos; + projector->unProject(centerScreen[0], centerScreen[1], centerPos); + double spinLong, spinLat; + + switch (getCurrentCoordinateSystem()) + { + case equatorialJ2000: + StelUtils::rectToSphe(&spinLong, &spinLat, centerPos); + break; + case equatorial: + StelUtils::rectToSphe(&spinLong, &spinLat, core->j2000ToEquinoxEqu(centerPos, StelCore::RefractionOff)); + break; + case galactic: + StelUtils::rectToSphe(&spinLong, &spinLat, core->j2000ToGalactic(centerPos)); + break; + case supergalactic: + StelUtils::rectToSphe(&spinLong, &spinLat, core->j2000ToSupergalactic(centerPos)); + break; + case horizontal: + { + StelUtils::rectToSphe(&spinLong, &spinLat, core->j2000ToAltAz(centerPos, StelCore::RefractionAuto)); + spinLong = 3.*M_PI - spinLong; // N is zero, E is 90 degrees + if (spinLong > M_PI*2) + spinLong -= M_PI*2; + break; + } + case eclipticJ2000: + { + double lambda, beta; + StelUtils::rectToSphe(&spinLong, &spinLat, centerPos); + StelUtils::equToEcl(spinLong, spinLat, GETSTELMODULE(SolarSystem)->getEarth()->getRotObliquity(2451545.0), &lambda, &beta); + if (lambda<0) lambda+=2.0*M_PI; + spinLong = lambda; + spinLat = beta; + break; + } + case ecliptic: + { + double lambda, beta; + StelUtils::rectToSphe(&spinLong, &spinLat, core->j2000ToEquinoxEqu(centerPos, StelCore::RefractionOff)); + StelUtils::equToEcl(spinLong, spinLat, GETSTELMODULE(SolarSystem)->getEarth()->getRotObliquity(core->getJDE()), &lambda, &beta); + if (lambda<0) lambda+=2.0*M_PI; + spinLong = lambda; + spinLat = beta; + break; + } + } + + ui->AxisXSpinBox->blockSignals(true); + ui->AxisYSpinBox->blockSignals(true); + + ui->AxisXSpinBox->setRadians(spinLong); + ui->AxisYSpinBox->setRadians(spinLat); + + ui->AxisXSpinBox->blockSignals(false); + ui->AxisYSpinBox->blockSignals(false); +} void SearchDialog::manualPositionChanged() { diff --git a/src/gui/SearchDialog.hpp b/src/gui/SearchDialog.hpp index 6ee7445bd1f2e5..a8b41815203bc9 100644 --- a/src/gui/SearchDialog.hpp +++ b/src/gui/SearchDialog.hpp @@ -250,6 +250,8 @@ private slots: //! Clear recent list's data void recentSearchClearDataClicked(); + void setCenterOfScreenCoordinates(); + private: bool simbadSearchEnabled() const {return useSimbad;} int getSimbadQueryDist () const { return simbadDist;}