Skip to content

Commit

Permalink
Added angular distance from the Moon info for AstroCalc/Phenomena tool
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-w committed Jul 12, 2018
1 parent 6dc3adb commit ac9aad3
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 8 deletions.
75 changes: 75 additions & 0 deletions src/gui/AstroCalcDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2815,6 +2815,7 @@ void AstroCalcDialog::setPhenomenaHeaderNames()
phenomenaHeader << q_("Object 2");
phenomenaHeader << q_("Separation");
phenomenaHeader << q_("Elongation");
phenomenaHeader << q_("Angular distance");
ui->phenomenaTreeWidget->setHeaderLabels(phenomenaHeader);

// adjust the column width
Expand Down Expand Up @@ -3143,6 +3144,8 @@ void AstroCalcDialog::fillPhenomenaTable(const QMap<double, double> list, const
QString dash = QChar(0x2014); // dash
PlanetP sun = solarSystem->getSun();
PlanetP moon = solarSystem->getMoon();
PlanetP earth = solarSystem->getEarth();
PlanetP planet = core->getCurrentPlanet();
bool withDecimalDegree = StelApp::getInstance().getFlagShowDecimalDegrees();
for (it = list.constBegin(); it != list.constEnd(); ++it)
{
Expand Down Expand Up @@ -3194,6 +3197,23 @@ void AstroCalcDialog::fillPhenomenaTable(const QMap<double, double> list, const
elongStr = StelUtils::radToDmsStr(elongation, true);
}

QString angDistStr = "";
if (planet != earth)
angDistStr = dash;
else
{
if (object1 == moon || object2 == moon)
angDistStr = dash;
else
{
double angularDistance = object1->getJ2000EquatorialPos(core).angle(moon->getJ2000EquatorialPos(core));
if (withDecimalDegree)
angDistStr = StelUtils::radToDecDegStr(angularDistance, 5, false, true);
else
angDistStr = StelUtils::radToDmsStr(angularDistance, true);
}
}

ACPhenTreeWidgetItem* treeItem = new ACPhenTreeWidgetItem(ui->phenomenaTreeWidget);
treeItem->setText(PhenomenaType, phenomenType);
// local date and time
Expand All @@ -3211,6 +3231,11 @@ void AstroCalcDialog::fillPhenomenaTable(const QMap<double, double> list, const
treeItem->setText(PhenomenaSeparation, StelUtils::radToDmsStr(separation, true));
}
treeItem->setText(PhenomenaElongation, elongStr);
treeItem->setToolTip(PhenomenaElongation, q_("Angular distance from the Sun"));
treeItem->setTextAlignment(PhenomenaElongation, Qt::AlignRight);
treeItem->setText(PhenomenaAngularDistance, angDistStr);
treeItem->setToolTip(PhenomenaAngularDistance, q_("Angular distance from the Moon"));
treeItem->setTextAlignment(PhenomenaAngularDistance, Qt::AlignRight);
}
}

Expand Down Expand Up @@ -3356,6 +3381,9 @@ void AstroCalcDialog::fillPhenomenaTable(const QMap<double, double> list, const
QMap<double, double>::ConstIterator it;
QString dash = QChar(0x2014); // dash
PlanetP sun = solarSystem->getSun();
PlanetP moon = solarSystem->getMoon();
PlanetP earth = solarSystem->getEarth();
PlanetP planet = core->getCurrentPlanet();
bool withDecimalDegree = StelApp::getInstance().getFlagShowDecimalDegrees();
for (it = list.constBegin(); it != list.constEnd(); ++it)
{
Expand All @@ -3382,6 +3410,23 @@ void AstroCalcDialog::fillPhenomenaTable(const QMap<double, double> list, const
elongStr = StelUtils::radToDmsStr(object1->getElongation(core->getObserverHeliocentricEclipticPos()), true);
}

QString angDistStr = "";
if (planet != earth)
angDistStr = dash;
else
{
if (object1 == moon)
angDistStr = dash;
else
{
double angularDistance = object1->getJ2000EquatorialPos(core).angle(moon->getJ2000EquatorialPos(core));
if (withDecimalDegree)
angDistStr = StelUtils::radToDecDegStr(angularDistance, 5, false, true);
else
angDistStr = StelUtils::radToDmsStr(angularDistance, true);
}
}

ACPhenTreeWidgetItem* treeItem = new ACPhenTreeWidgetItem(ui->phenomenaTreeWidget);
treeItem->setText(PhenomenaType, phenomenType);
// local date and time
Expand All @@ -3403,6 +3448,11 @@ void AstroCalcDialog::fillPhenomenaTable(const QMap<double, double> list, const
treeItem->setText(PhenomenaSeparation, StelUtils::radToDmsStr(separation, true));
}
treeItem->setText(PhenomenaElongation, elongStr);
treeItem->setToolTip(PhenomenaElongation, q_("Angular distance from the Sun"));
treeItem->setTextAlignment(PhenomenaElongation, Qt::AlignRight);
treeItem->setText(PhenomenaAngularDistance, angDistStr);
treeItem->setToolTip(PhenomenaAngularDistance, q_("Angular distance from the Moon"));
treeItem->setTextAlignment(PhenomenaAngularDistance, Qt::AlignRight);
}
}

Expand Down Expand Up @@ -3544,6 +3594,9 @@ void AstroCalcDialog::fillPhenomenaTable(const QMap<double, double> list, const
QMap<double, double>::ConstIterator it;
QString dash = QChar(0x2014); // dash
PlanetP sun = solarSystem->getSun();
PlanetP moon = solarSystem->getMoon();
PlanetP earth = solarSystem->getEarth();
PlanetP planet = core->getCurrentPlanet();
bool withDecimalDegree = StelApp::getInstance().getFlagShowDecimalDegrees();
for (it = list.constBegin(); it != list.constEnd(); ++it)
{
Expand All @@ -3570,6 +3623,23 @@ void AstroCalcDialog::fillPhenomenaTable(const QMap<double, double> list, const
elongStr = StelUtils::radToDmsStr(object1->getElongation(core->getObserverHeliocentricEclipticPos()), true);
}

QString angDistStr = "";
if (planet != earth)
angDistStr = dash;
else
{
if (object1 == moon)
angDistStr = dash;
else
{
double angularDistance = object1->getJ2000EquatorialPos(core).angle(moon->getJ2000EquatorialPos(core));
if (withDecimalDegree)
angDistStr = StelUtils::radToDecDegStr(angularDistance, 5, false, true);
else
angDistStr = StelUtils::radToDmsStr(angularDistance, true);
}
}

ACPhenTreeWidgetItem* treeItem = new ACPhenTreeWidgetItem(ui->phenomenaTreeWidget);
treeItem->setText(PhenomenaType, phenomenType);
// local date and time
Expand All @@ -3587,6 +3657,11 @@ void AstroCalcDialog::fillPhenomenaTable(const QMap<double, double> list, const
treeItem->setText(PhenomenaSeparation, StelUtils::radToDmsStr(separation, true));
}
treeItem->setText(PhenomenaElongation, elongStr);
treeItem->setToolTip(PhenomenaElongation, q_("Angular distance from the Sun"));
treeItem->setTextAlignment(PhenomenaElongation, Qt::AlignRight);
treeItem->setText(PhenomenaAngularDistance, angDistStr);
treeItem->setToolTip(PhenomenaAngularDistance, q_("Angular distance from the Moon"));
treeItem->setTextAlignment(PhenomenaAngularDistance, Qt::AlignRight);
}
}

Expand Down
17 changes: 9 additions & 8 deletions src/gui/AstroCalcDialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,14 @@ class AstroCalcDialog : public StelDialog
//! Defines the number and the order of the columns in the phenomena table
//! @enum PhenomenaColumns
enum PhenomenaColumns {
PhenomenaType, //! type of phenomena
PhenomenaDate, //! date and time of ephemeris
PhenomenaObject1, //! first object
PhenomenaObject2, //! second object
PhenomenaSeparation, //! angular separation
PhenomenaElongation, //! elongation
PhenomenaCount //! total number of columns
PhenomenaType, //! type of phenomena
PhenomenaDate, //! date and time of ephemeris
PhenomenaObject1, //! first object
PhenomenaObject2, //! second object
PhenomenaSeparation, //! angular separation
PhenomenaElongation, //! elongation (from the Sun)
PhenomenaAngularDistance, //! angular distance (from the Moon)
PhenomenaCount //! total number of columns
};

//! Defines the type of graphs
Expand Down Expand Up @@ -366,7 +367,7 @@ class ACPhenTreeWidgetItem : public QTreeWidgetItem
{
int column = treeWidget()->sortColumn();

if (column == AstroCalcDialog::PhenomenaSeparation || column == AstroCalcDialog::PhenomenaElongation)
if (column == AstroCalcDialog::PhenomenaSeparation || column == AstroCalcDialog::PhenomenaElongation || column == AstroCalcDialog::PhenomenaAngularDistance)
{
return StelUtils::getDecAngle(text(column)) < StelUtils::getDecAngle(other.text(column));
}
Expand Down

0 comments on commit ac9aad3

Please sign in to comment.