diff options
author | Alexander V. Wolf <alex.v.wolf@gmail.com> | 2024-03-03 19:29:16 +0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-03 19:29:16 +0700 |
commit | 5b3c1a33f5a0b3c1279c4b736c737bccb3981583 (patch) | |
tree | efface0cad2a5a7e36208dcae4b8636eafe165a3 | |
parent | f0d93fa0d2121c440462a0e77773910e00f33fdc (diff) |
Following current position in Search Tool (#3643)
-rw-r--r-- | src/core/StelMovementMgr.cpp | 1 | ||||
-rw-r--r-- | src/core/StelMovementMgr.hpp | 1 | ||||
-rw-r--r-- | src/gui/SearchDialog.cpp | 71 | ||||
-rw-r--r-- | src/gui/SearchDialog.hpp | 3 |
4 files changed, 76 insertions, 0 deletions
diff --git a/src/core/StelMovementMgr.cpp b/src/core/StelMovementMgr.cpp index ad7cf89192..8f4524f1fb 100644 --- a/src/core/StelMovementMgr.cpp +++ b/src/core/StelMovementMgr.cpp @@ -1610,6 +1610,7 @@ void StelMovementMgr::panView(const double deltaAz, const double deltaAlt) { setViewUpVector(Vec3d(0., 0., 1.)); } + emit currentDirectionChanged(); } } diff --git a/src/core/StelMovementMgr.hpp b/src/core/StelMovementMgr.hpp index 2f1ec2f24e..39b9f35d66 100644 --- a/src/core/StelMovementMgr.hpp +++ b/src/core/StelMovementMgr.hpp @@ -480,6 +480,7 @@ signals: void flagEnableZoomKeysChanged(bool b); void userMaxFovChanged(double fov); void currentFovChanged(double fov); + void currentDirectionChanged(); private slots: //! Called when the selected object changes. diff --git a/src/gui/SearchDialog.cpp b/src/gui/SearchDialog.cpp index 9909673a4a..f4f26580f6 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,9 @@ 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())); + // following the current direction of FOV + connect(GETSTELMODULE(StelMovementMgr), &StelMovementMgr::currentDirectionChanged, this, &SearchDialog::setCenterOfScreenCoordinates); + setCenterOfScreenCoordinates(); connect(ui->alphaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetterClicked())); connect(ui->betaPushButton, SIGNAL(clicked(bool)), this, SLOT(greekLetterClicked())); @@ -512,6 +516,7 @@ void SearchDialog::changeTab(int index) if (index==2) // Position { + setCenterOfScreenCoordinates(); if (useFOVCenterMarker) GETSTELMODULE(SpecialMarkersMgr)->setFlagFOVCenterMarker(true); } @@ -667,6 +672,72 @@ 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); + Vector2<qreal> cpos = projector->getViewportCenter(); + Vec3d centerPos; + projector->unProject(cpos[0], cpos[1], centerPos); + double spinLong =0., spinLat = 0.; + + // Getting coordinates (in radians) of position of the center of the screen + 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; + } + } + + // disable following the changes of spinbox + const bool axisXState = ui->AxisXSpinBox->blockSignals(true); + const bool axisYState = ui->AxisYSpinBox->blockSignals(true); + + // set coordinates in spinboxes + ui->AxisXSpinBox->setRadians(spinLong); + ui->AxisYSpinBox->setRadians(spinLat); + + // restore following the changes of spinbox + ui->AxisXSpinBox->blockSignals(axisXState); + ui->AxisYSpinBox->blockSignals(axisYState); +} void SearchDialog::manualPositionChanged() { diff --git a/src/gui/SearchDialog.hpp b/src/gui/SearchDialog.hpp index 6ee7445bd1..6e9fb5f577 100644 --- a/src/gui/SearchDialog.hpp +++ b/src/gui/SearchDialog.hpp @@ -250,6 +250,9 @@ private slots: //! Clear recent list's data void recentSearchClearDataClicked(); + //! Setting coordinates of the center of screen in spinboxes (following axes of current coordinate system) + void setCenterOfScreenCoordinates(); + private: bool simbadSearchEnabled() const {return useSimbad;} int getSimbadQueryDist () const { return simbadDist;} |