From 623dfb44f080e4e58e07ccdbfe4b418fae7e783f Mon Sep 17 00:00:00 2001 From: "Alexander V. Wolf" Date: Wed, 28 Jun 2023 16:04:55 +0700 Subject: [PATCH 1/2] astrocalc: show current location of object --- src/core/modules/SolarSystem.cpp | 40 +++++++++++++++++++++++ src/core/modules/SolarSystem.hpp | 9 +++++ src/gui/AstroCalcDialog.cpp | 1 + src/gui/AstroCalcDialog.hpp | 1 + src/gui/AstroCalcExtraEphemerisDialog.cpp | 3 +- src/gui/astroCalcExtraEphemerisDialog.ui | 9 ++++- 6 files changed, 61 insertions(+), 2 deletions(-) diff --git a/src/core/modules/SolarSystem.cpp b/src/core/modules/SolarSystem.cpp index f83c32fe0e93c..9b743e5708998 100644 --- a/src/core/modules/SolarSystem.cpp +++ b/src/core/modules/SolarSystem.cpp @@ -94,6 +94,7 @@ SolarSystem::SolarSystem() : StelObjectModule() , ephemerisHorizontalCoordinates(false) , ephemerisLineDisplayed(false) , ephemerisAlwaysOn(false) + , ephemerisNow(false) , ephemerisLineThickness(1) , ephemerisSkipDataDisplayed(false) , ephemerisSkipMarkersDisplayed(false) @@ -140,6 +141,7 @@ SolarSystem::~SolarSystem() texEphemerisMarker.clear(); texEphemerisCometMarker.clear(); + texEphemerisNowMarker.clear(); texPointer.clear(); delete allTrails; @@ -252,6 +254,7 @@ void SolarSystem::init() // Ephemeris stuff setFlagEphemerisMarkers(conf->value("astrocalc/flag_ephemeris_markers", true).toBool()); setFlagEphemerisAlwaysOn(conf->value("astrocalc/flag_ephemeris_alwayson", true).toBool()); + setFlagEphemerisNow(conf->value("astrocalc/flag_ephemeris_now", false).toBool()); setFlagEphemerisDates(conf->value("astrocalc/flag_ephemeris_dates", false).toBool()); setFlagEphemerisMagnitudes(conf->value("astrocalc/flag_ephemeris_magnitudes", false).toBool()); setFlagEphemerisHorizontalCoordinates(conf->value("astrocalc/flag_ephemeris_horizontal", false).toBool()); @@ -283,6 +286,7 @@ void SolarSystem::init() texPointer = StelApp::getInstance().getTextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures/pointeur4.png"); texEphemerisMarker = StelApp::getInstance().getTextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures/disk.png"); + texEphemerisNowMarker = StelApp::getInstance().getTextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures/gear.png"); texEphemerisCometMarker = StelApp::getInstance().getTextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures/cometIcon.png"); Planet::hintCircleTex = StelApp::getInstance().getTextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures/planet-indicator.png"); @@ -1453,6 +1457,7 @@ void SolarSystem::drawEphemerisMarkers(const StelCore *core) const bool showMagnitudes = getFlagEphemerisMagnitudes(); const bool showSkippedData = getFlagEphemerisSkipData(); const bool skipMarkers = getFlagEphemerisSkipMarkers(); + const bool isNowVisible = getFlagEphemerisNow(); const int dataStep = getEphemerisDataStep(); const int sizeCoeff = getEphemerisLineThickness() - 1; QString info = ""; @@ -1463,6 +1468,26 @@ void SolarSystem::drawEphemerisMarkers(const StelCore *core) if (getFlagEphemerisLine() && getFlagEphemerisScaleMarkers()) baseSize = 3.f; // The line lies through center of marker + if (isNowVisible) + { + const int limit = getEphemerisDataLimit(); + const int nsize = static_cast(fsize/limit); + sPainter.setBlending(true, GL_ONE, GL_ONE); + texEphemerisNowMarker->bind(); + Vec3d pos; + Vec3f win; + for (int i =0; i < limit; i++) + { + sPainter.setColor(getEphemerisMarkerColor(AstroCalcDialog::EphemerisList[i*nsize].colorIndex)); + if (getFlagEphemerisHorizontalCoordinates()) + pos = AstroCalcDialog::EphemerisList[i*nsize].sso->getAltAzPosAuto(core); + else + pos = AstroCalcDialog::EphemerisList[i*nsize].sso->getJ2000EquatorialPos(core); + if (prj->project(pos, win)) + sPainter.drawSprite2dMode(static_cast(win[0]), static_cast(win[1]), 6.f, 0.f); + } + } + for (int i =0; i < fsize; i++) { skipFlag = (((i + 1)%dataStep)!=1 && dataStep!=1); @@ -2317,6 +2342,21 @@ void SolarSystem::setFlagEphemerisAlwaysOn(bool b) } } +bool SolarSystem::getFlagEphemerisNow() const +{ + return ephemerisNow; +} + +void SolarSystem::setFlagEphemerisNow(bool b) +{ + if (b != ephemerisNow) + { + ephemerisNow = b; + conf->setValue("astrocalc/flag_ephemeris_now", b); // Immediate saving of state + emit ephemerisNowChanged(b); + } +} + void SolarSystem::setFlagEphemerisHorizontalCoordinates(bool b) { if (b!=ephemerisHorizontalCoordinates) diff --git a/src/core/modules/SolarSystem.hpp b/src/core/modules/SolarSystem.hpp index 47b63d139c371..9e32168f42538 100644 --- a/src/core/modules/SolarSystem.hpp +++ b/src/core/modules/SolarSystem.hpp @@ -98,6 +98,7 @@ class SolarSystem : public StelObjectModule Q_PROPERTY(bool ephemerisSmartDates READ getFlagEphemerisSmartDates WRITE setFlagEphemerisSmartDates NOTIFY ephemerisSmartDatesChanged) Q_PROPERTY(bool ephemerisScaleMarkersDisplayed READ getFlagEphemerisScaleMarkers WRITE setFlagEphemerisScaleMarkers NOTIFY ephemerisScaleMarkersChanged) Q_PROPERTY(bool ephemerisAlwaysOn READ getFlagEphemerisAlwaysOn WRITE setFlagEphemerisAlwaysOn NOTIFY ephemerisAlwaysOnChanged) + Q_PROPERTY(bool ephemerisNow READ getFlagEphemerisNow WRITE setFlagEphemerisNow NOTIFY ephemerisNowChanged) // Great Red Spot (GRS) properties Q_PROPERTY(int grsLongitude READ getGrsLongitude WRITE setGrsLongitude NOTIFY grsLongitudeChanged) Q_PROPERTY(double grsDrift READ getGrsDrift WRITE setGrsDrift NOTIFY grsDriftChanged) @@ -771,6 +772,7 @@ public slots: void ephemerisMagnitudesChanged(bool b); void ephemerisLineChanged(bool b); void ephemerisAlwaysOnChanged(bool b); + void ephemerisNowChanged(bool b); void ephemerisLineThicknessChanged(int v); void ephemerisSkipDataChanged(bool b); void ephemerisSkipMarkersChanged(bool b); @@ -911,6 +913,11 @@ private slots: //! Get the current value of the flag which makes ephemeris lines and marks always on bool getFlagEphemerisAlwaysOn() const; + //! Set flag, which enables ephemeris marks on position "now" + void setFlagEphemerisNow(bool b); + //! Get the current value of the flag which makes ephemeris marks on position "now" + bool getFlagEphemerisNow() const; + //! Set the thickness of ephemeris line void setEphemerisLineThickness(int v); //! Get the thickness of ephemeris line @@ -1083,6 +1090,7 @@ private slots: StelTextureSP texPointer; StelTextureSP texEphemerisMarker; StelTextureSP texEphemerisCometMarker; + StelTextureSP texEphemerisNowMarker; bool flagShow; bool flagPointer; // show red cross selection pointer? @@ -1100,6 +1108,7 @@ private slots: bool ephemerisHorizontalCoordinates; bool ephemerisLineDisplayed; bool ephemerisAlwaysOn; + bool ephemerisNow; int ephemerisLineThickness; bool ephemerisSkipDataDisplayed; bool ephemerisSkipMarkersDisplayed; diff --git a/src/gui/AstroCalcDialog.cpp b/src/gui/AstroCalcDialog.cpp index f1e785bd8c66c..edce9532f6339 100644 --- a/src/gui/AstroCalcDialog.cpp +++ b/src/gui/AstroCalcDialog.cpp @@ -1969,6 +1969,7 @@ void AstroCalcDialog::generateEphemeris() item.objDate = JD; item.magnitude = obj->getVMagnitudeWithExtinction(core); item.isComet = obj->getPlanetType()==Planet::isComet; + item.sso = obj; EphemerisList.append(item); Vec3d observerHelioPos = core->getObserverHeliocentricEclipticPos(); diff --git a/src/gui/AstroCalcDialog.hpp b/src/gui/AstroCalcDialog.hpp index 235c862b01d92..188bf5e6f02ff 100644 --- a/src/gui/AstroCalcDialog.hpp +++ b/src/gui/AstroCalcDialog.hpp @@ -59,6 +59,7 @@ struct Ephemeris QString objDateStr; float magnitude; bool isComet; + PlanetP sso; }; Q_DECLARE_METATYPE(Ephemeris) diff --git a/src/gui/AstroCalcExtraEphemerisDialog.cpp b/src/gui/AstroCalcExtraEphemerisDialog.cpp index 27874dd983cf1..c5cd7d096e3de 100644 --- a/src/gui/AstroCalcExtraEphemerisDialog.cpp +++ b/src/gui/AstroCalcExtraEphemerisDialog.cpp @@ -57,7 +57,8 @@ void AstroCalcExtraEphemerisDialog::createDialogContent() connectIntProperty(ui->dataStepSpinBox, "SolarSystem.ephemerisDataStep"); connectBoolProperty(ui->smartDatesCheckBox, "SolarSystem.ephemerisSmartDates"); connectBoolProperty(ui->scaleMarkersCheckBox, "SolarSystem.ephemerisScaleMarkersDisplayed"); - connectBoolProperty(ui->alwaysOnCheckBox, "SolarSystem.ephemerisAlwaysOn"); + connectBoolProperty(ui->alwaysOnCheckBox, "SolarSystem.ephemerisAlwaysOn"); + connectBoolProperty(ui->currentLocationCheckBox,"SolarSystem.ephemerisNow" ); connectIntProperty(ui->lineThicknessSpinBox, "SolarSystem.ephemerisLineThickness"); setOptionStatus(); diff --git a/src/gui/astroCalcExtraEphemerisDialog.ui b/src/gui/astroCalcExtraEphemerisDialog.ui index 5af04e3dee55c..bc3051d96cc1f 100644 --- a/src/gui/astroCalcExtraEphemerisDialog.ui +++ b/src/gui/astroCalcExtraEphemerisDialog.ui @@ -7,7 +7,7 @@ 0 0 305 - 155 + 209 @@ -226,6 +226,13 @@ + + + + Show marker for current location + + + From e051c9c1d02ade6c39ff54717aa19bf44ffa4140 Mon Sep 17 00:00:00 2001 From: "Alexander V. Wolf" Date: Sun, 2 Jul 2023 19:49:17 +0700 Subject: [PATCH 2/2] Fix possible crash --- src/gui/AstroCalcDialog.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/AstroCalcDialog.cpp b/src/gui/AstroCalcDialog.cpp index edce9532f6339..734793d8d435c 100644 --- a/src/gui/AstroCalcDialog.cpp +++ b/src/gui/AstroCalcDialog.cpp @@ -139,6 +139,7 @@ AstroCalcDialog::AstroCalcDialog(QObject* parent) AstroCalcDialog::~AstroCalcDialog() { + EphemerisList.clear(); if (currentTimeLine) { currentTimeLine->stop();