Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AstroCalc: show current location of object #3289

Merged
merged 2 commits into from
Jul 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/core/modules/SolarSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ SolarSystem::SolarSystem() : StelObjectModule()
, ephemerisHorizontalCoordinates(false)
, ephemerisLineDisplayed(false)
, ephemerisAlwaysOn(false)
, ephemerisNow(false)
, ephemerisLineThickness(1)
, ephemerisSkipDataDisplayed(false)
, ephemerisSkipMarkersDisplayed(false)
Expand Down Expand Up @@ -140,6 +141,7 @@ SolarSystem::~SolarSystem()

texEphemerisMarker.clear();
texEphemerisCometMarker.clear();
texEphemerisNowMarker.clear();
texPointer.clear();

delete allTrails;
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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");

Expand Down Expand Up @@ -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 = "";
Expand All @@ -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<int>(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<float>(win[0]), static_cast<float>(win[1]), 6.f, 0.f);
}
}

for (int i =0; i < fsize; i++)
{
skipFlag = (((i + 1)%dataStep)!=1 && dataStep!=1);
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions src/core/modules/SolarSystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1083,6 +1090,7 @@ private slots:
StelTextureSP texPointer;
StelTextureSP texEphemerisMarker;
StelTextureSP texEphemerisCometMarker;
StelTextureSP texEphemerisNowMarker;

bool flagShow;
bool flagPointer; // show red cross selection pointer?
Expand All @@ -1100,6 +1108,7 @@ private slots:
bool ephemerisHorizontalCoordinates;
bool ephemerisLineDisplayed;
bool ephemerisAlwaysOn;
bool ephemerisNow;
int ephemerisLineThickness;
bool ephemerisSkipDataDisplayed;
bool ephemerisSkipMarkersDisplayed;
Expand Down
2 changes: 2 additions & 0 deletions src/gui/AstroCalcDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ AstroCalcDialog::AstroCalcDialog(QObject* parent)

AstroCalcDialog::~AstroCalcDialog()
{
EphemerisList.clear();
if (currentTimeLine)
{
currentTimeLine->stop();
Expand Down Expand Up @@ -1969,6 +1970,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();
Expand Down
1 change: 1 addition & 0 deletions src/gui/AstroCalcDialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ struct Ephemeris
QString objDateStr;
float magnitude;
bool isComet;
PlanetP sso;
};
Q_DECLARE_METATYPE(Ephemeris)

Expand Down
3 changes: 2 additions & 1 deletion src/gui/AstroCalcExtraEphemerisDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
9 changes: 8 additions & 1 deletion src/gui/astroCalcExtraEphemerisDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>305</width>
<height>155</height>
<height>209</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
Expand Down Expand Up @@ -226,6 +226,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="currentLocationCheckBox">
<property name="text">
<string>Show marker for current location</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="alwaysOnCheckBox">
<property name="text">
Expand Down
Loading