AstroCalcDialog.cpp   AstroCalcDialog.cpp 
skipping to change at line 42 skipping to change at line 42
#include "NebulaMgr.hpp" #include "NebulaMgr.hpp"
#include "Nebula.hpp" #include "Nebula.hpp"
#include "AstroCalcDialog.hpp" #include "AstroCalcDialog.hpp"
#include "ui_astroCalcDialog.h" #include "ui_astroCalcDialog.h"
#include "external/qcustomplot/qcustomplot.h" #include "external/qcustomplot/qcustomplot.h"
#include <QFileDialog> #include <QFileDialog>
#include <QDir> #include <QDir>
QVector<Vec3d> AstroCalcDialog::EphemerisListJ2000; QVector<Vec3d> AstroCalcDialog::EphemerisListCoords;
QVector<QString> AstroCalcDialog::EphemerisListDates; QVector<QString> AstroCalcDialog::EphemerisListDates;
QVector<float> AstroCalcDialog::EphemerisListMagnitudes;
int AstroCalcDialog::DisplayedPositionIndex = -1; int AstroCalcDialog::DisplayedPositionIndex = -1;
float AstroCalcDialog::brightLimit = 10.f; float AstroCalcDialog::brightLimit = 10.f;
float AstroCalcDialog::minY = -90.f; float AstroCalcDialog::minY = -90.f;
float AstroCalcDialog::maxY = 90.f; float AstroCalcDialog::maxY = 90.f;
float AstroCalcDialog::minY1 = -1001.f;
float AstroCalcDialog::maxY1 = 1001.f;
float AstroCalcDialog::minY2 = -1001.f;
float AstroCalcDialog::maxY2 = 1001.f;
float AstroCalcDialog::transitX = -1.f;
QString AstroCalcDialog::yAxis1Legend = "";
QString AstroCalcDialog::yAxis2Legend = "";
AstroCalcDialog::AstroCalcDialog(QObject *parent) AstroCalcDialog::AstroCalcDialog(QObject *parent)
: StelDialog("AstroCalc",parent) : StelDialog("AstroCalc",parent)
, currentTimeLine(NULL) , currentTimeLine(Q_NULLPTR)
, delimiter(", ") , delimiter(", ")
, acEndl("\n") , acEndl("\n")
{ {
ui = new Ui_astroCalcDialogForm; ui = new Ui_astroCalcDialogForm;
core = StelApp::getInstance().getCore(); core = StelApp::getInstance().getCore();
solarSystem = GETSTELMODULE(SolarSystem); solarSystem = GETSTELMODULE(SolarSystem);
dsoMgr = GETSTELMODULE(NebulaMgr); dsoMgr = GETSTELMODULE(NebulaMgr);
objectMgr = GETSTELMODULE(StelObjectMgr); objectMgr = GETSTELMODULE(StelObjectMgr);
starMgr = GETSTELMODULE(StarMgr); starMgr = GETSTELMODULE(StarMgr);
localeMgr = &StelApp::getInstance().getLocaleMgr();
conf = StelApp::getInstance().getSettings();
ephemerisHeader.clear(); ephemerisHeader.clear();
phenomenaHeader.clear(); phenomenaHeader.clear();
planetaryPositionsHeader.clear(); positionsHeader.clear();
} }
AstroCalcDialog::~AstroCalcDialog() AstroCalcDialog::~AstroCalcDialog()
{ {
if (currentTimeLine) if (currentTimeLine)
{ {
currentTimeLine->stop(); currentTimeLine->stop();
delete currentTimeLine; delete currentTimeLine;
currentTimeLine = NULL; currentTimeLine = Q_NULLPTR;
} }
delete ui; delete ui;
} }
void AstroCalcDialog::retranslate() void AstroCalcDialog::retranslate()
{ {
if (dialog) if (dialog)
{ {
ui->retranslateUi(dialog); ui->retranslateUi(dialog);
setPlanetaryPositionsHeaderNames(); setCelestialPositionsHeaderNames();
setEphemerisHeaderNames(); setEphemerisHeaderNames();
setPhenomenaHeaderNames(); setPhenomenaHeaderNames();
populateCelestialBodyList(); populateCelestialBodyList();
populateCelestialCategoryList();
populateEphemerisTimeStepsList(); populateEphemerisTimeStepsList();
populateMajorPlanetList(); populateMajorPlanetList();
populateGroupCelestialBodyList(); populateGroupCelestialBodyList();
currentPlanetaryPositions(); currentCelestialPositions();
prepareAxesAndGraph();
populateFunctionsList();
prepareXVsTimeAxesAndGraph();
drawAltVsTimeDiagram(); drawAltVsTimeDiagram();
populateTimeIntervalsList();
populateWutGroups();
//Hack to shrink the tabs to optimal size after language cha nge //Hack to shrink the tabs to optimal size after language cha nge
//by causing the list items to be laid out again. //by causing the list items to be laid out again.
updateTabBarListWidgetWidth(); updateTabBarListWidgetWidth();
} }
} }
void AstroCalcDialog::styleChanged() void AstroCalcDialog::styleChanged()
{ {
// Nothing for now // Nothing for now
} }
void AstroCalcDialog::createDialogContent() void AstroCalcDialog::createDialogContent()
{ {
ui->setupUi(dialog); ui->setupUi(dialog);
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
// Kinetic scrolling for tablet pc and pc // Kinetic scrolling for tablet pc and pc
QList<QWidget *> addscroll; QList<QWidget *> addscroll;
addscroll << ui->planetaryPositionsTreeWidget; addscroll << ui->celestialPositionsTreeWidget << ui->ephemerisTreeWi dget << ui->phenomenaTreeWidget << ui->wutCategoryListWidget << ui->wutMatc hingObjectsListWidget;
installKineticScrolling(addscroll); installKineticScrolling(addscroll);
acEndl="\r\n"; acEndl="\r\n";
#else #else
acEndl="\n"; acEndl="\n";
#endif #endif
//Signals and slots //Signals and slots
connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SL OT(retranslate())); connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SL OT(retranslate()));
ui->stackedWidget->setCurrentIndex(0); ui->stackedWidget->setCurrentIndex(0);
ui->stackListWidget->setCurrentRow(0); ui->stackListWidget->setCurrentRow(0);
connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())) ; connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())) ;
connect(ui->TitleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMove dTo(QPoint))); connect(ui->TitleBar, SIGNAL(movedTo(QPoint)), this, SLOT(handleMove dTo(QPoint)));
initListPlanetaryPositions(); initListCelestialPositions();
initListEphemeris();
initListPhenomena(); initListPhenomena();
populateCelestialBodyList(); populateCelestialBodyList();
populateCelestialCategoryList();
populateEphemerisTimeStepsList(); populateEphemerisTimeStepsList();
populateMajorPlanetList(); populateMajorPlanetList();
populateGroupCelestialBodyList(); populateGroupCelestialBodyList();
// Altitude vs. Time feature // Altitude vs. Time feature
prepareAxesAndGraph(); prepareAxesAndGraph();
drawCurrentTimeDiagram(); drawCurrentTimeDiagram();
// Graphs feature
populateFunctionsList();
prepareXVsTimeAxesAndGraph();
// WUT
populateTimeIntervalsList();
populateWutGroups();
double JD = core->getJD() + core->getUTCOffset(core->getJD())/24; double JD = core->getJD() + core->getUTCOffset(core->getJD())/24;
QDateTime currentDT = StelUtils::jdToQDateTime(JD); QDateTime currentDT = StelUtils::jdToQDateTime(JD);
ui->dateFromDateTimeEdit->setDateTime(currentDT); ui->dateFromDateTimeEdit->setDateTime(currentDT);
ui->dateToDateTimeEdit->setDateTime(currentDT.addMonths(1)); ui->dateToDateTimeEdit->setDateTime(currentDT.addMonths(1));
ui->phenomenFromDateEdit->setDateTime(currentDT); ui->phenomenFromDateEdit->setDateTime(currentDT);
ui->phenomenToDateEdit->setDateTime(currentDT.addYears(1)); ui->phenomenToDateEdit->setDateTime(currentDT.addYears(1));
// TODO: Switch a QDateTimeEdit to StelDateTimeEdit widget to apply wide range of dates // TODO: Switch a QDateTimeEdit to StelDateTimeEdit widget to apply wide range of dates
QDate min = QDate(100,1,1); QDate min = QDate(100,1,1);
ui->dateFromDateTimeEdit->setMinimumDate(min); ui->dateFromDateTimeEdit->setMinimumDate(min);
ui->dateToDateTimeEdit->setMinimumDate(min); ui->dateToDateTimeEdit->setMinimumDate(min);
ui->phenomenFromDateEdit->setMinimumDate(min); ui->phenomenFromDateEdit->setMinimumDate(min);
ui->phenomenToDateEdit->setMinimumDate(min); ui->phenomenToDateEdit->setMinimumDate(min);
// bug #1350669 (https://bugs.launchpad.net/stellarium/+bug/1350669) // bug #1350669 (https://bugs.launchpad.net/stellarium/+bug/1350669)
connect(ui->planetaryPositionsTreeWidget, SIGNAL(currentItemChanged( connect(ui->celestialPositionsTreeWidget, SIGNAL(currentItemChanged(
QTreeWidgetItem*,QTreeWidgetItem*)), QTreeWidgetItem*,QTreeWidgetItem*)),
ui->planetaryPositionsTreeWidget, SLOT(repaint())); ui->celestialPositionsTreeWidget, SLOT(repaint()));
ui->celestialMagnitudeDoubleSpinBox->setValue(conf->value("astrocalc
/celestial_magnitude_limit", 6.0).toDouble());
connect(ui->celestialMagnitudeDoubleSpinBox, SIGNAL(valueChanged(dou
ble)), this, SLOT(saveCelestialPositionsMagnitudeLimit(double)));
connect(ui->planetaryPositionsTreeWidget, SIGNAL(doubleClicked(QMode ui->horizontalCoordinatesCheckBox->setChecked(conf->value("astrocalc
lIndex)), this, SLOT(selectCurrentPlanetaryPosition(QModelIndex))); /flag_horizontal_coordinates", false).toBool());
connect(ui->planetaryPositionsUpdateButton, SIGNAL(clicked()), this, connect(ui->horizontalCoordinatesCheckBox, SIGNAL(toggled(bool)), th
SLOT(currentPlanetaryPositions())); is, SLOT(saveCelestialPositionsHorizontalCoordinatesFlag(bool)));
connect(ui->celestialPositionsTreeWidget, SIGNAL(doubleClicked(QMode
lIndex)), this, SLOT(selectCurrentCelestialPosition(QModelIndex)));
connect(ui->celestialPositionsUpdateButton, SIGNAL(clicked()), this,
SLOT(currentCelestialPositions()));
connect(ui->celestialCategoryComboBox, SIGNAL(currentIndexChanged(in
t)), this, SLOT(saveCelestialPositionsCategory(int)));
connect(dsoMgr, SIGNAL(catalogFiltersChanged(Nebula::CatalogGroup)),
this, SLOT(currentCelestialPositions()));
connectBoolProperty(ui->ephemerisShowMarkersCheckBox, "SolarSystem.e
phemerisMarkersDisplayed");
connectBoolProperty(ui->ephemerisShowDatesCheckBox, "SolarSystem.eph
emerisDatesDisplayed");
connectBoolProperty(ui->ephemerisShowMagnitudesCheckBox, "SolarSyste
m.ephemerisMagnitudesDisplayed");
connectBoolProperty(ui->ephemerisHorizontalCoordinatesCheckBox, "Sol
arSystem.ephemerisHorizontalCoordinates");
initListEphemeris();
connect(ui->ephemerisHorizontalCoordinatesCheckBox, SIGNAL(toggled(b
ool)), this, SLOT(reGenerateEphemeris()));
connect(ui->ephemerisPushButton, SIGNAL(clicked()), this, SLOT(gener ateEphemeris())); connect(ui->ephemerisPushButton, SIGNAL(clicked()), this, SLOT(gener ateEphemeris()));
connect(ui->ephemerisCleanupButton, SIGNAL(clicked()), this, SLOT(cl eanupEphemeris())); connect(ui->ephemerisCleanupButton, SIGNAL(clicked()), this, SLOT(cl eanupEphemeris()));
connect(ui->ephemerisSaveButton, SIGNAL(clicked()), this, SLOT(saveE phemeris())); connect(ui->ephemerisSaveButton, SIGNAL(clicked()), this, SLOT(saveE phemeris()));
connect(ui->ephemerisTreeWidget, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(selectCurrentEphemeride(QModelIndex))); connect(ui->ephemerisTreeWidget, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(selectCurrentEphemeride(QModelIndex)));
connect(ui->ephemerisTreeWidget, SIGNAL(clicked(QModelIndex)), this, SLOT(onChangedEphemerisPosition(QModelIndex))); connect(ui->ephemerisTreeWidget, SIGNAL(clicked(QModelIndex)), this, SLOT(onChangedEphemerisPosition(QModelIndex)));
connect(ui->ephemerisStepComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(saveEphemerisTimeStep(int)));
connect(ui->celestialBodyComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(saveEphemerisCelestialBody(int)));
ui->phenomenaOppositionCheckBox->setChecked(conf->value("astrocalc/f
lag_phenomena_opposition", false).toBool());
connect(ui->phenomenaOppositionCheckBox, SIGNAL(toggled(bool)), this
, SLOT(savePhenomenaOppositionFlag(bool)));
ui->allowedSeparationDoubleSpinBox->setValue(conf->value("astrocalc/
phenomena_angular_separation", 1.0).toDouble());
connect(ui->allowedSeparationDoubleSpinBox, SIGNAL(valueChanged(doub
le)), this, SLOT(savePhenomenaAngularSeparation(double)));
connect(ui->phenomenaPushButton, SIGNAL(clicked()), this, SLOT(calcu latePhenomena())); connect(ui->phenomenaPushButton, SIGNAL(clicked()), this, SLOT(calcu latePhenomena()));
connect(ui->phenomenaCleanupButton, SIGNAL(clicked()), this, SLOT(cl eanupPhenomena()));
connect(ui->phenomenaTreeWidget, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(selectCurrentPhenomen(QModelIndex))); connect(ui->phenomenaTreeWidget, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(selectCurrentPhenomen(QModelIndex)));
connect(ui->phenomenaSaveButton, SIGNAL(clicked()), this, SLOT(saveP henomena())); connect(ui->phenomenaSaveButton, SIGNAL(clicked()), this, SLOT(saveP henomena()));
connect(ui->object1ComboBox, SIGNAL(currentIndexChanged(int)), this,
SLOT(savePhenomenaCelestialBody(int)));
connect(ui->object2ComboBox, SIGNAL(currentIndexChanged(int)), this,
SLOT(savePhenomenaCelestialGroup(int)));
connect(ui->altVsTimePlot, SIGNAL(mouseMove(QMouseEvent*)), this, SL OT(mouseOverLine(QMouseEvent*))); connect(ui->altVsTimePlot, SIGNAL(mouseMove(QMouseEvent*)), this, SL OT(mouseOverLine(QMouseEvent*)));
connect(objectMgr, SIGNAL(selectedObjectChanged(StelModule::StelModu leSelectAction)), this, SLOT(drawAltVsTimeDiagram())); connect(objectMgr, SIGNAL(selectedObjectChanged(StelModule::StelModu leSelectAction)), this, SLOT(drawAltVsTimeDiagram()));
connect(core, SIGNAL(locationChanged(StelLocation)), this, SLOT(draw AltVsTimeDiagram()));
connect(core, SIGNAL(dateChanged()), this, SLOT(drawAltVsTimeDiagram ())); connect(core, SIGNAL(dateChanged()), this, SLOT(drawAltVsTimeDiagram ()));
drawAltVsTimeDiagram(); drawAltVsTimeDiagram();
connectBoolProperty(ui->ephemerisShowMarkersCheckBox, "SolarSystem.e connect(ui->graphsCelestialBodyComboBox, SIGNAL(currentIndexChanged(
phemerisMarkersDisplayed"); int)), this, SLOT(saveGraphsCelestialBody(int)));
connectBoolProperty(ui->ephemerisShowDatesCheckBox, "SolarSystem.eph connect(ui->graphsFirstComboBox, SIGNAL(currentIndexChanged(int)), t
emerisDatesDisplayed"); his, SLOT(saveGraphsFirstId(int)));
connect(ui->graphsSecondComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(saveGraphsSecondId(int)));
connect(ui->drawGraphsPushButton, SIGNAL(clicked()), this, SLOT(draw
XVsTimeGraphs()));
ui->wutMagnitudeDoubleSpinBox->setValue(conf->value("astrocalc/wut_m
agnitude_limit", 10.0).toDouble());
connect(ui->wutMagnitudeDoubleSpinBox, SIGNAL(valueChanged(double)),
this, SLOT(saveWutMagnitudeLimit(double)));
connect(ui->wutComboBox, SIGNAL(currentIndexChanged(int)), this, SLO
T(saveWutTimeInterval(int)));
connect(ui->wutCategoryListWidget, SIGNAL(currentRowChanged(int)), t
his, SLOT(calculateWutObjects()));
connect(ui->wutMatchingObjectsListWidget, SIGNAL(currentRowChanged(i
nt)), this, SLOT(selectWutObject()));
connect(dsoMgr, SIGNAL(catalogFiltersChanged(Nebula::CatalogGroup)),
this, SLOT(calculateWutObjects()));
connect(dsoMgr, SIGNAL(typeFiltersChanged(Nebula::TypeGroup)), this,
SLOT(calculateWutObjects()));
currentPlanetaryPositions(); currentCelestialPositions();
currentTimeLine = new QTimer(this); currentTimeLine = new QTimer(this);
connect(currentTimeLine, SIGNAL(timeout()), this, SLOT(drawCurrentTi meDiagram())); connect(currentTimeLine, SIGNAL(timeout()), this, SLOT(drawCurrentTi meDiagram()));
currentTimeLine->start(500); // Update 'now' line position every 0.5 seconds currentTimeLine->start(500); // Update 'now' line position every 0.5 seconds
connect(solarSystem, SIGNAL(solarSystemDataReloaded()), this, SLOT(u pdateSolarSystemData())); connect(solarSystem, SIGNAL(solarSystemDataReloaded()), this, SLOT(u pdateSolarSystemData()));
connect(core, SIGNAL(locationChanged(StelLocation)), this, SLOT(upda teAstroCalcData()));
connect(ui->stackListWidget, SIGNAL(currentItemChanged(QListWidgetIt em *, QListWidgetItem *)), this, SLOT(changePage(QListWidgetItem *, QListWi dgetItem*))); connect(ui->stackListWidget, SIGNAL(currentItemChanged(QListWidgetIt em *, QListWidgetItem *)), this, SLOT(changePage(QListWidgetItem *, QListWi dgetItem*)));
updateTabBarListWidgetWidth();
} }
void AstroCalcDialog::initListPlanetaryPositions() void AstroCalcDialog::updateAstroCalcData()
{ {
ui->planetaryPositionsTreeWidget->clear(); drawAltVsTimeDiagram();
ui->planetaryPositionsTreeWidget->setColumnCount(ColumnCount); populateCelestialBodyList();
setPlanetaryPositionsHeaderNames(); populateMajorPlanetList();
ui->planetaryPositionsTreeWidget->header()->setSectionsMovable(false
);
} }
void AstroCalcDialog::setPlanetaryPositionsHeaderNames() void AstroCalcDialog::initListCelestialPositions()
{ {
planetaryPositionsHeader.clear(); ui->celestialPositionsTreeWidget->clear();
ui->celestialPositionsTreeWidget->setColumnCount(CColumnCount);
setCelestialPositionsHeaderNames();
ui->celestialPositionsTreeWidget->header()->setSectionsMovable(false
);
}
void AstroCalcDialog::setCelestialPositionsHeaderNames()
{
Q_ASSERT(ui->celestialCategoryComboBox);
QComboBox* category = ui->celestialCategoryComboBox;
int celType = category->itemData(category->currentIndex()).toInt();
bool horizon = ui->horizontalCoordinatesCheckBox->isChecked();
positionsHeader.clear();
//TRANSLATORS: name of object //TRANSLATORS: name of object
planetaryPositionsHeader << q_("Name"); positionsHeader << q_("Name");
//TRANSLATORS: right ascension if (horizon)
planetaryPositionsHeader << q_("RA (J2000)"); {
//TRANSLATORS: declination //TRANSLATORS: azimuth
planetaryPositionsHeader << q_("Dec (J2000)"); positionsHeader << q_("Azimuth");
//TRANSLATORS: magnitude //TRANSLATORS: altitude
planetaryPositionsHeader << q_("Mag."); positionsHeader << q_("Altitude");
}
else
{
//TRANSLATORS: right ascension
positionsHeader << q_("RA (J2000)");
//TRANSLATORS: declination
positionsHeader << q_("Dec (J2000)");
}
if (celType==12 || celType==102 || celType==111) // check for dark n
ebulae
{
//TRANSLATORS: opacity
positionsHeader << q_("opacity");
}
else
{
//TRANSLATORS: magnitude
positionsHeader << q_("mag");
}
if (celType==170)
{
//TRANSLATORS: separation, arcseconds
positionsHeader << QString("%1, \"").arg(q_("sep."));
}
else if (celType==171)
{
//TRANSLATORS: period, days
positionsHeader << QString("%1, %2").arg(q_("per."), qc_("d"
, "days"));
}
else if (celType==200)
{
//TRANSLATORS: distance, AU
positionsHeader << QString("%1, %2").arg(q_("dist."), qc_("A
U", "astronomical unit"));
}
else if (celType==172)
{
//TRANSLATORS: proper motion, arcsecond per year
positionsHeader << QString("%1, %2").arg(q_("P.M."), qc_("\"
/yr", "arcsecond per year"));
}
else
{
//TRANSLATORS: surface brightness
positionsHeader << q_("S.B.");
}
//TRANSLATORS: type of object //TRANSLATORS: type of object
planetaryPositionsHeader << q_("Type"); positionsHeader << q_("Type");
ui->planetaryPositionsTreeWidget->setHeaderLabels(planetaryPositions
Header);
ui->celestialPositionsTreeWidget->setHeaderLabels(positionsHeader);
// adjust the column width // adjust the column width
for(int i = 0; i < ColumnCount; ++i) for(int i = 0; i < CColumnCount; ++i)
{
ui->celestialPositionsTreeWidget->resizeColumnToContents(i);
}
}
void AstroCalcDialog::onChangedEphemerisPosition(const QModelIndex &modelIn
dex)
{
DisplayedPositionIndex = modelIndex.row();
}
void AstroCalcDialog::populateCelestialCategoryList()
{
Q_ASSERT(ui->celestialCategoryComboBox);
QComboBox* category = ui->celestialCategoryComboBox;
category->blockSignals(true);
int index = category->currentIndex();
QVariant selectedCategoryId = category->itemData(index);
category->clear();
// TODO: Automatic sync list with QMap<QString, QString> StelObjectM
gr::objectModulesMap() data
category->addItem(q_("Galaxies"), "0");
category->addItem(q_("Active galaxies"), "1");
category->addItem(q_("Radio galaxies"), "2");
category->addItem(q_("Interacting galaxies"), "3");
category->addItem(q_("Bright quasars"), "4");
category->addItem(q_("Star clusters"), "5");
category->addItem(q_("Open star clusters"), "6");
category->addItem(q_("Globular star clusters"), "7");
category->addItem(q_("Stellar associations"), "8");
category->addItem(q_("Star clouds"), "9");
category->addItem(q_("Nebulae"), "10");
category->addItem(q_("Planetary nebulae"), "11");
category->addItem(q_("Dark nebulae"), "12");
category->addItem(q_("Reflection nebulae"), "13");
category->addItem(q_("Bipolar nebulae"), "14");
category->addItem(q_("Emission nebulae"), "15");
category->addItem(q_("Clusters associated with nebulosity"), "16");
category->addItem(q_("HII regions"), "17");
category->addItem(q_("Supernova remnants"), "18");
category->addItem(q_("Interstellar matter"), "19");
category->addItem(q_("Emission objects"), "20");
category->addItem(q_("BL Lac objects"), "21");
category->addItem(q_("Blazars"), "22");
category->addItem(q_("Molecular Clouds"), "23");
category->addItem(q_("Young Stellar Objects"), "24");
category->addItem(q_("Possible Quasars"), "25");
category->addItem(q_("Possible Planetary Nebulae"), "26");
category->addItem(q_("Protoplanetary Nebulae"), "27");
category->addItem(q_("Messier Catalogue"), "100");
category->addItem(q_("Caldwell Catalogue"), "101");
category->addItem(q_("Barnard Catalogue"), "102");
category->addItem(q_("Sharpless Catalogue"), "103");
category->addItem(q_("Van den Bergh Catalogue"), "104");
category->addItem(q_("The Catalogue of Rodgers, Campbell, and Whiteo
ak"), "105");
category->addItem(q_("Collinder Catalogue"), "106");
category->addItem(q_("Melotte Catalogue"), "107");
category->addItem(q_("New General Catalogue"), "108");
category->addItem(q_("Index Catalogue"), "109");
category->addItem(q_("Lynds' Catalogue of Bright Nebulae"), "110");
category->addItem(q_("Lynds' Catalogue of Dark Nebulae"), "111");
category->addItem(q_("Principal Galaxy Catalog"), "112");
category->addItem(q_("The Uppsala General Catalogue of Galaxies"), "
113");
category->addItem(q_("Cederblad Catalog"), "114");
category->addItem(q_("The Catalogue of Peculiar Galaxies"), "115");
category->addItem(q_("The Catalogue of Interacting Galaxies"), "116"
);
category->addItem(q_("The Catalogue of Galactic Planetary Nebulae"),
"117");
category->addItem(q_("Dwarf galaxies"), "150");
category->addItem(q_("Herschel 400 Catalogue"), "151");
category->addItem(q_("Bright double stars"), "170");
category->addItem(q_("Bright variable stars"), "171");
category->addItem(q_("Bright stars with high proper motion"), "172")
;
category->addItem(q_("Solar system objects"), "200");
index = category->findData(selectedCategoryId, Qt::UserRole, Qt::Mat
chCaseSensitive);
if (index<0)
{ {
ui->planetaryPositionsTreeWidget->resizeColumnToContents(i); // default step: Messier Catalogue
index = category->findData(conf->value("astrocalc/celestial_
category", "200").toString(), Qt::UserRole, Qt::MatchCaseSensitive);
} }
category->setCurrentIndex(index);
category->model()->sort(0);
category->blockSignals(false);
} }
void AstroCalcDialog::currentPlanetaryPositions() void AstroCalcDialog::saveCelestialPositionsMagnitudeLimit(double mag)
{
conf->setValue("astrocalc/celestial_magnitude_limit", QString::numbe
r(mag, 'f', 2));
// Refresh the celestial bodies positions table
currentCelestialPositions();
}
void AstroCalcDialog::saveCelestialPositionsHorizontalCoordinatesFlag(bool
b)
{
conf->setValue("astrocalc/flag_horizontal_coordinates", b);
// Refresh the celestial bodies positions table
currentCelestialPositions();
}
void AstroCalcDialog::saveCelestialPositionsCategory(int index)
{
Q_ASSERT(ui->celestialCategoryComboBox);
QComboBox* category = ui->celestialCategoryComboBox;
conf->setValue("astrocalc/celestial_category", category->itemData(in
dex).toInt());
// Refresh the celestial bodies positions table
currentCelestialPositions();
}
void AstroCalcDialog::currentCelestialPositions()
{ {
float ra, dec; float ra, dec;
QList<PlanetP> allPlanets = solarSystem->getAllPlanets(); QString raStr, decStr, extra, celObjName = "", celObjId = "";
initListCelestialPositions();
initListPlanetaryPositions(); double mag = ui->celestialMagnitudeDoubleSpinBox->value();
bool horizon = ui->horizontalCoordinatesCheckBox->isChecked();
bool useSouthAzimuth = StelApp::getInstance().getFlagSouthAzimuthUsa
ge();
StelCore* core = StelApp::getInstance().getCore(); StelCore* core = StelApp::getInstance().getCore();
double JD = core->getJD(); double JD = core->getJD();
ui->positionsTimeLabel->setText(q_("Positions on %1").arg(StelUtils: :jdToQDateTime(JD + core->getUTCOffset(JD)/24).toString("yyyy-MM-dd hh:mm") )); ui->celestialPositionsTimeLabel->setText(q_("Positions on %1").arg(Q String("%1 %2").arg(localeMgr->getPrintableDateLocal(JD), localeMgr->getPri ntableTimeLocal(JD))));
foreach (const PlanetP& planet, allPlanets) Q_ASSERT(ui->celestialCategoryComboBox);
{ QComboBox* category = ui->celestialCategoryComboBox;
if (planet->getPlanetType()!=Planet::isUNDEFINED && planet-> QString celType = category->itemData(category->currentIndex()).toStr
getEnglishName()!="Sun" && planet->getEnglishName()!=core->getCurrentPlanet ing();
()->getEnglishName()) int celTypeId = celType.toInt();
if (celTypeId<170)
{
QString mu = QString("<sup>m</sup>/%1'").arg(QChar(0x2B1C));
if (dsoMgr->getFlagSurfaceBrightnessArcsecUsage())
mu = QString("<sup>m</sup>/%1\"").arg(QChar(0x2B1C))
;
QString dsoName;
// Deep-sky objects
QList<NebulaP> celestialObjects = dsoMgr->getDeepSkyObjectsB
yType(celType);
foreach (const NebulaP& obj, celestialObjects)
{
if (dsoMgr->objectInDisplayedCatalog(obj) && obj->ge
tVMagnitudeWithExtinction(core)<=mag && obj->isAboveRealHorizon(core))
{
if (horizon)
{
StelUtils::rectToSphe(&ra, &dec, obj
->getAltAzPosAuto(core));
float direction = 3.; // N is zero,
E is 90 degrees
if (useSouthAzimuth)
direction = 2.;
ra = direction*M_PI - ra;
if (ra > M_PI*2)
ra -= M_PI*2;
raStr = StelUtils::radToDmsStr(ra, t
rue);
decStr = StelUtils::radToDmsStr(dec,
true);
}
else
{
StelUtils::rectToSphe(&ra, &dec, obj
->getJ2000EquatorialPos(core));
raStr = StelUtils::radToHmsStr(ra);
decStr = StelUtils::radToDmsStr(dec,
true);
}
ACCelPosTreeWidgetItem *treeItem = new ACCel
PosTreeWidgetItem(ui->celestialPositionsTreeWidget);
celObjName = obj->getNameI18n();
celObjId = obj->getDSODesignation();
if (celObjId.isEmpty())
dsoName = celObjName;
else if (celObjName.isEmpty())
dsoName = celObjId;
else
dsoName = QString("%1 (%2)").arg(cel
ObjId, celObjName);
extra = QString::number(obj->getSurfaceBrigh
tnessWithExtinction(core), 'f', 2);
if (extra.toFloat()>90.f)
extra = QChar(0x2014);
treeItem->setText(CColumnName, dsoName);
treeItem->setText(CColumnRA, raStr);
treeItem->setTextAlignment(CColumnRA, Qt::Al
ignRight);
treeItem->setText(CColumnDec, decStr);
treeItem->setTextAlignment(CColumnDec, Qt::A
lignRight);
treeItem->setText(CColumnMagnitude, QString:
:number(obj->getVMagnitudeWithExtinction(core), 'f', 2));
treeItem->setTextAlignment(CColumnMagnitude,
Qt::AlignRight);
treeItem->setText(CColumnExtra, extra);
treeItem->setTextAlignment(CColumnExtra, Qt:
:AlignRight);
treeItem->setToolTip(CColumnExtra, mu);
treeItem->setText(CColumnType, q_(obj->getTy
peString()));
}
}
}
else if (celTypeId==200)
{
QList<PlanetP> allPlanets = solarSystem->getAllPlanets();
QString distanceInfo = q_("Planetocentric distance");
if (core->getUseTopocentricCoordinates())
distanceInfo = q_("Topocentric distance");
QString distanceUM = qc_("AU", "astronomical unit");
QString sToolTip = QString("%1, %2").arg(distanceInfo, dista
nceUM);
Vec3d pos;
foreach (const PlanetP& planet, allPlanets)
{
if ((planet->getPlanetType()!=Planet::isUNDEFINED &&
planet!=core->getCurrentPlanet()) && planet->getVMagnitudeWithExtinction(c
ore)<=mag && planet->isAboveRealHorizon(core))
{
pos = planet->getJ2000EquatorialPos(core);
if (horizon)
{
StelUtils::rectToSphe(&ra, &dec, pla
net->getAltAzPosAuto(core));
float direction = 3.; // N is zero,
E is 90 degrees
if (useSouthAzimuth)
direction = 2.;
ra = direction*M_PI - ra;
if (ra > M_PI*2)
ra -= M_PI*2;
raStr = StelUtils::radToDmsStr(ra, t
rue);
decStr = StelUtils::radToDmsStr(dec,
true);
}
else
{
StelUtils::rectToSphe(&ra, &dec, pos
);
raStr = StelUtils::radToHmsStr(ra);
decStr = StelUtils::radToDmsStr(dec,
true);
}
extra = QString::number(pos.length(), 'f', 5
); // A.U.
ACCelPosTreeWidgetItem *treeItem = new ACCel
PosTreeWidgetItem(ui->celestialPositionsTreeWidget);
treeItem->setText(CColumnName, planet->getNa
meI18n());
treeItem->setText(CColumnRA, raStr);
treeItem->setTextAlignment(CColumnRA, Qt::Al
ignRight);
treeItem->setText(CColumnDec, decStr);
treeItem->setTextAlignment(CColumnDec, Qt::A
lignRight);
treeItem->setText(CColumnMagnitude, QString:
:number(planet->getVMagnitudeWithExtinction(core), 'f', 2));
treeItem->setTextAlignment(CColumnMagnitude,
Qt::AlignRight);
treeItem->setText(CColumnExtra, extra);
treeItem->setTextAlignment(CColumnExtra, Qt:
:AlignRight);
treeItem->setToolTip(CColumnExtra, sToolTip)
;
treeItem->setText(CColumnType, q_(planet->ge
tPlanetTypeString()));
}
}
}
else
{
// stars
QString sType = q_("star");
QString sToolTip = "";
float wdsSep;
QList<StelACStarData> celestialObjects;
if (celTypeId==170)
{
// double stars
celestialObjects = starMgr->getHipparcosDoubleStars(
);
sType = q_("double star");
}
else if (celTypeId==171)
{
// variable stars
celestialObjects = starMgr->getHipparcosVariableStar
s();
sType = q_("variable star");
}
else
{ {
StelUtils::rectToSphe(&ra,&dec,planet->getJ2000Equat // stars with high proper motion
orialPos(core)); celestialObjects = starMgr->getHipparcosHighPMStars(
ACTreeWidgetItem *treeItem = new ACTreeWidgetItem(ui );
->planetaryPositionsTreeWidget); sType = q_("star with high proper motion");
treeItem->setText(ColumnName, planet->getNameI18n())
; }
treeItem->setText(ColumnRA, StelUtils::radToHmsStr(r
a)); foreach (const StelACStarData& star, celestialObjects)
treeItem->setTextAlignment(ColumnRA, Qt::AlignRight) {
; StelObjectP obj = star.firstKey();
treeItem->setText(ColumnDec, StelUtils::radToDmsStr( if (obj->getVMagnitudeWithExtinction(core)<=mag && o
dec, true)); bj->isAboveRealHorizon(core))
treeItem->setTextAlignment(ColumnDec, Qt::AlignRight {
); if (horizon)
treeItem->setText(ColumnMagnitude, QString::number(p {
lanet->getVMagnitudeWithExtinction(core), 'f', 2)); StelUtils::rectToSphe(&ra, &dec, obj
treeItem->setTextAlignment(ColumnMagnitude, Qt::Alig ->getAltAzPosAuto(core));
nRight); float direction = 3.; // N is zero,
treeItem->setText(ColumnType, q_(planet->getPlanetTy E is 90 degrees
peString())); if (useSouthAzimuth)
direction = 2.;
ra = direction*M_PI - ra;
if (ra > M_PI*2)
ra -= M_PI*2;
raStr = StelUtils::radToDmsStr(ra, t
rue);
decStr = StelUtils::radToDmsStr(dec,
true);
}
else
{
StelUtils::rectToSphe(&ra, &dec, obj
->getJ2000EquatorialPos(core));
raStr = StelUtils::radToHmsStr(ra);
decStr = StelUtils::radToDmsStr(dec,
true);
}
if (celTypeId==170) // double stars
{
wdsSep = star.value(obj);
extra = QString::number(wdsSep, 'f',
3); // arcseconds
sToolTip = StelUtils::decDegToDmsStr
(wdsSep/3600.f);
}
else if (celTypeId==171) // variable stars
{
if (star.value(obj)>0.f)
extra = QString::number(star
.value(obj), 'f', 5); // days
else
extra = QChar(0x2014); // da
sh
}
else // stars with high proper motion
extra = QString::number(star.value(o
bj), 'f', 5); // "/yr
ACCelPosTreeWidgetItem *treeItem = new ACCel
PosTreeWidgetItem(ui->celestialPositionsTreeWidget);
treeItem->setText(CColumnName, obj->getNameI
18n());
treeItem->setText(CColumnRA, raStr);
treeItem->setTextAlignment(CColumnRA, Qt::Al
ignRight);
treeItem->setText(CColumnDec, decStr);
treeItem->setTextAlignment(CColumnDec, Qt::A
lignRight);
treeItem->setText(CColumnMagnitude, QString:
:number(obj->getVMagnitudeWithExtinction(core), 'f', 2));
treeItem->setTextAlignment(CColumnMagnitude,
Qt::AlignRight);
treeItem->setText(CColumnExtra, extra);
treeItem->setTextAlignment(CColumnExtra, Qt:
:AlignRight);
treeItem->setToolTip(CColumnExtra, sToolTip)
;
treeItem->setText(CColumnType, sType);
}
} }
} }
// adjust the column width // adjust the column width
for(int i = 0; i < ColumnCount; ++i) for(int i = 0; i < CColumnCount; ++i)
{ {
ui->planetaryPositionsTreeWidget->resizeColumnToContents(i); ui->celestialPositionsTreeWidget->resizeColumnToContents(i);
} }
// sort-by-name // sort-by-name
ui->planetaryPositionsTreeWidget->sortItems(ColumnName, Qt::Ascendin gOrder); ui->celestialPositionsTreeWidget->sortItems(CColumnName, Qt::Ascendi ngOrder);
} }
void AstroCalcDialog::onChangedEphemerisPosition(const QModelIndex &modelIn void AstroCalcDialog::selectCurrentCelestialPosition(const QModelIndex &mod
dex) elIndex)
{
DisplayedPositionIndex = modelIndex.row();
}
void AstroCalcDialog::selectCurrentPlanetaryPosition(const QModelIndex &mod
elIndex)
{ {
// Find the object // Find the object
QString nameI18n = modelIndex.sibling(modelIndex.row(), ColumnName). QString nameI18n = modelIndex.sibling(modelIndex.row(), CColumnName)
data().toString(); .data().toString();
QStringList list = nameI18n.split("(");
if (list.count()>0)
nameI18n = list.at(0).trimmed();
if (objectMgr->findAndSelectI18n(nameI18n) || objectMgr->findAndSele ct(nameI18n)) if (objectMgr->findAndSelectI18n(nameI18n) || objectMgr->findAndSele ct(nameI18n))
{ {
const QList<StelObjectP> newSelected = objectMgr->getSelecte dObject(); const QList<StelObjectP> newSelected = objectMgr->getSelecte dObject();
if (!newSelected.empty()) if (!newSelected.empty())
{ {
// Can't point to home planet StelMovementMgr* mvmgr = GETSTELMODULE(StelMovementM
if (newSelected[0]->getEnglishName()!=core->getCurre gr);
ntLocation().planetName) mvmgr->moveToObject(newSelected[0], mvmgr->getAutoMo
{ veDuration());
StelMovementMgr* mvmgr = GETSTELMODULE(StelM mvmgr->setFlagTracking(true);
ovementMgr);
mvmgr->moveToObject(newSelected[0], mvmgr->g
etAutoMoveDuration());
mvmgr->setFlagTracking(true);
}
else
{
GETSTELMODULE(StelObjectMgr)->unSelect();
}
} }
} }
} }
void AstroCalcDialog::selectCurrentEphemeride(const QModelIndex &modelIndex ) void AstroCalcDialog::selectCurrentEphemeride(const QModelIndex &modelIndex )
{ {
// Find the object // Find the object
QString name = ui->celestialBodyComboBox->currentData().toString(); QString name = ui->celestialBodyComboBox->currentData().toString();
double JD = modelIndex.sibling(modelIndex.row(), EphemerisJD).data() .toDouble(); double JD = modelIndex.sibling(modelIndex.row(), EphemerisJD).data() .toDouble();
skipping to change at line 311 skipping to change at line 707
else else
{ {
GETSTELMODULE(StelObjectMgr)->unSelect(); GETSTELMODULE(StelObjectMgr)->unSelect();
} }
} }
} }
} }
void AstroCalcDialog::setEphemerisHeaderNames() void AstroCalcDialog::setEphemerisHeaderNames()
{ {
bool horizon = ui->ephemerisHorizontalCoordinatesCheckBox->isChecked
();
ephemerisHeader.clear(); ephemerisHeader.clear();
ephemerisHeader << q_("Date and Time"); ephemerisHeader << q_("Date and Time");
ephemerisHeader << q_("Julian Day"); ephemerisHeader << q_("Julian Day");
//TRANSLATORS: right ascension if (horizon)
ephemerisHeader << q_("RA (J2000)"); {
//TRANSLATORS: declination //TRANSLATORS: azimuth
ephemerisHeader << q_("Dec (J2000)"); ephemerisHeader << q_("Azimuth");
//TRANSLATORS: altitude
ephemerisHeader << q_("Altitude");
}
else
{
//TRANSLATORS: right ascension
ephemerisHeader << q_("RA (J2000)");
//TRANSLATORS: declination
ephemerisHeader << q_("Dec (J2000)");
}
//TRANSLATORS: magnitude //TRANSLATORS: magnitude
ephemerisHeader << q_("Mag."); ephemerisHeader << q_("mag");
//TRANSLATORS: phase
ephemerisHeader << q_("phase");
//TRANSLATORS: distance, AU
ephemerisHeader << QString("%1, %2").arg(q_("dist."), qc_("AU", "ast
ronomical unit"));
//TRANSLATORS: elongation
ephemerisHeader << q_("elong.");
ui->ephemerisTreeWidget->setHeaderLabels(ephemerisHeader); ui->ephemerisTreeWidget->setHeaderLabels(ephemerisHeader);
// adjust the column width // adjust the column width
for(int i = 0; i < EphemerisCount; ++i) for(int i = 0; i < EphemerisCount; ++i)
{ {
ui->ephemerisTreeWidget->resizeColumnToContents(i); ui->ephemerisTreeWidget->resizeColumnToContents(i);
} }
} }
void AstroCalcDialog::initListEphemeris() void AstroCalcDialog::initListEphemeris()
{ {
ui->ephemerisTreeWidget->clear(); ui->ephemerisTreeWidget->clear();
ui->ephemerisTreeWidget->setColumnCount(EphemerisCount); ui->ephemerisTreeWidget->setColumnCount(EphemerisCount);
setEphemerisHeaderNames(); setEphemerisHeaderNames();
ui->ephemerisTreeWidget->header()->setSectionsMovable(false); ui->ephemerisTreeWidget->header()->setSectionsMovable(false);
} }
void AstroCalcDialog::reGenerateEphemeris()
{
if (EphemerisListCoords.size()>0)
generateEphemeris(); // Update list of ephemeris
else
initListEphemeris(); // Just update headers
}
void AstroCalcDialog::generateEphemeris() void AstroCalcDialog::generateEphemeris()
{ {
float currentStep, ra, dec; float currentStep, ra, dec;
Vec3d observerHelioPos;
QString currentPlanet = ui->celestialBodyComboBox->currentData().toS tring(); QString currentPlanet = ui->celestialBodyComboBox->currentData().toS tring();
QString distanceInfo = q_("Planetocentric distance");
if (core->getUseTopocentricCoordinates())
distanceInfo = q_("Topocentric distance");
QString distanceUM = qc_("AU", "astronomical unit");
QString elongStr = "", phaseStr = "";
bool horizon = ui->ephemerisHorizontalCoordinatesCheckBox->isChecked
();
bool useSouthAzimuth = StelApp::getInstance().getFlagSouthAzimuthUsa
ge();
initListEphemeris(); initListEphemeris();
switch (ui->ephemerisStepComboBox->currentData().toInt()) { switch (ui->ephemerisStepComboBox->currentData().toInt()) {
case 1: case 1:
currentStep = 10 * StelCore::JD_MINUTE; currentStep = 10 * StelCore::JD_MINUTE;
break; break;
case 2: case 2:
currentStep = StelCore::JD_HOUR; currentStep = 30 * StelCore::JD_MINUTE;
break; break;
case 3: case 3:
currentStep = StelCore::JD_DAY; currentStep = StelCore::JD_HOUR;
break; break;
case 4: case 4:
currentStep = 5 * StelCore::JD_DAY; currentStep = 6 * StelCore::JD_HOUR;
break; break;
case 5: case 5:
currentStep = 10 * StelCore::JD_DAY; currentStep = 12 * StelCore::JD_HOUR;
break; break;
case 6: case 6:
currentStep = 15 * StelCore::JD_DAY; currentStep = StelCore::JD_DAY;
break; break;
case 7: case 7:
currentStep = 30 * StelCore::JD_DAY; currentStep = 5 * StelCore::JD_DAY;
break; break;
case 8: case 8:
currentStep = 10 * StelCore::JD_DAY;
break;
case 9:
currentStep = 15 * StelCore::JD_DAY;
break;
case 10:
currentStep = 30 * StelCore::JD_DAY;
break;
case 11:
currentStep = 60 * StelCore::JD_DAY; currentStep = 60 * StelCore::JD_DAY;
break; break;
default: default:
currentStep = StelCore::JD_DAY; currentStep = StelCore::JD_DAY;
break; break;
} }
StelObjectP obj = solarSystem->searchByName(currentPlanet); PlanetP obj = solarSystem->searchByEnglishName(currentPlanet);
if (obj) if (obj)
{ {
double currentJD = core->getJD(); // save current JD double currentJD = core->getJD(); // save current JD
double firstJD = StelUtils::qDateTimeToJd(ui->dateFromDateTi meEdit->dateTime()); double firstJD = StelUtils::qDateTimeToJd(ui->dateFromDateTi meEdit->dateTime());
firstJD = firstJD - core->getUTCOffset(firstJD)/24; firstJD = firstJD - core->getUTCOffset(firstJD)/24;
int elements = (int)((StelUtils::qDateTimeToJd(ui->dateToDat eTimeEdit->dateTime()) - firstJD)/currentStep); int elements = (int)((StelUtils::qDateTimeToJd(ui->dateToDat eTimeEdit->dateTime()) - firstJD)/currentStep);
EphemerisListJ2000.clear(); EphemerisListCoords.clear();
EphemerisListJ2000.reserve(elements); EphemerisListCoords.reserve(elements);
EphemerisListDates.clear(); EphemerisListDates.clear();
EphemerisListDates.reserve(elements); EphemerisListDates.reserve(elements);
EphemerisListMagnitudes.clear();
EphemerisListMagnitudes.reserve(elements);
bool withTime = false;
QString dash = QChar(0x2014); // dash
if (currentStep<StelCore::JD_DAY)
withTime = true;
if (obj==solarSystem->getSun())
{
phaseStr = dash;
elongStr = dash;
}
Vec3d pos;
QString raStr = "", decStr = "";
for (int i=0; i<elements; i++) for (int i=0; i<elements; i++)
{ {
double JD = firstJD + i*currentStep; double JD = firstJD + i*currentStep;
core->setJD(JD); core->setJD(JD);
core->update(0); // force update to get new coordina tes core->update(0); // force update to get new coordina tes
Vec3d pos = obj->getJ2000EquatorialPos(core);
EphemerisListJ2000.append(pos); if (horizon)
EphemerisListDates.append(StelUtils::jdToQDateTime(J {
D + core->getUTCOffset(JD)/24).toString("yyyy-MM-dd")); pos = obj->getAltAzPosAuto(core);
StelUtils::rectToSphe(&ra, &dec, pos);
float direction = 3.; // N is zero, E is 90
degrees
if (useSouthAzimuth)
direction = 2.;
ra = direction*M_PI - ra;
if (ra > M_PI*2)
ra -= M_PI*2;
raStr = StelUtils::radToDmsStr(ra, true);
decStr = StelUtils::radToDmsStr(dec, true);
}
else
{
pos = obj->getJ2000EquatorialPos(core);
StelUtils::rectToSphe(&ra, &dec, pos);
raStr = StelUtils::radToHmsStr(ra);
decStr = StelUtils::radToDmsStr(dec, true);
}
EphemerisListCoords.append(pos);
if (withTime)
EphemerisListDates.append(QString("%1 %2").a
rg(localeMgr->getPrintableDateLocal(JD), localeMgr->getPrintableTimeLocal(J
D)));
else
EphemerisListDates.append(localeMgr->getPrin
tableDateLocal(JD));
EphemerisListMagnitudes.append(obj->getVMagnitudeWit
hExtinction(core));
StelUtils::rectToSphe(&ra,&dec,pos); StelUtils::rectToSphe(&ra,&dec,pos);
ACTreeWidgetItem *treeItem = new ACTreeWidgetItem(ui
->ephemerisTreeWidget); observerHelioPos = core->getObserverHeliocentricEcli
pticPos();
if (phaseStr!=dash)
phaseStr = QString("%1%").arg(QString::numbe
r(obj->getPhase(observerHelioPos) * 100, 'f', 2));
if (elongStr!=dash)
elongStr = StelUtils::radToDmsStr(obj->getEl
ongation(observerHelioPos), true);
ACEphemTreeWidgetItem *treeItem = new ACEphemTreeWid
getItem(ui->ephemerisTreeWidget);
// local date and time // local date and time
treeItem->setText(EphemerisDate, StelUtils::jdToQDat eTime(JD + core->getUTCOffset(JD)/24).toString("yyyy-MM-dd hh:mm:ss")); treeItem->setText(EphemerisDate, QString("%1 %2").ar g(localeMgr->getPrintableDateLocal(JD), localeMgr->getPrintableTimeLocal(JD )));
treeItem->setText(EphemerisJD, QString::number(JD, ' f', 5)); treeItem->setText(EphemerisJD, QString::number(JD, ' f', 5));
treeItem->setText(EphemerisRA, StelUtils::radToHmsSt r(ra)); treeItem->setText(EphemerisRA, raStr);
treeItem->setTextAlignment(EphemerisRA, Qt::AlignRig ht); treeItem->setTextAlignment(EphemerisRA, Qt::AlignRig ht);
treeItem->setText(EphemerisDec, StelUtils::radToDmsS tr(dec, true)); treeItem->setText(EphemerisDec, decStr);
treeItem->setTextAlignment(EphemerisDec, Qt::AlignRi ght); treeItem->setTextAlignment(EphemerisDec, Qt::AlignRi ght);
treeItem->setText(EphemerisMagnitude, QString::numbe r(obj->getVMagnitudeWithExtinction(core), 'f', 2)); treeItem->setText(EphemerisMagnitude, QString::numbe r(obj->getVMagnitudeWithExtinction(core), 'f', 2));
treeItem->setTextAlignment(EphemerisMagnitude, Qt::A lignRight); treeItem->setTextAlignment(EphemerisMagnitude, Qt::A lignRight);
treeItem->setText(EphemerisPhase, phaseStr);
treeItem->setTextAlignment(EphemerisPhase, Qt::Align
Right);
treeItem->setText(EphemerisDistance, QString::number
(obj->getJ2000EquatorialPos(core).length(), 'f', 6));
treeItem->setTextAlignment(EphemerisDistance, Qt::Al
ignRight);
treeItem->setToolTip(EphemerisDistance, QString("%1,
%2").arg(distanceInfo, distanceUM));
treeItem->setText(EphemerisElongation, elongStr);
treeItem->setTextAlignment(EphemerisElongation, Qt::
AlignRight);
} }
core->setJD(currentJD); // restore time core->setJD(currentJD); // restore time
} }
// adjust the column width // adjust the column width
for(int i = 0; i < EphemerisCount; ++i) for(int i = 0; i < EphemerisCount; ++i)
{ {
ui->ephemerisTreeWidget->resizeColumnToContents(i); ui->ephemerisTreeWidget->resizeColumnToContents(i);
} }
skipping to change at line 455 skipping to change at line 952
else else
ephemList << acEndl; ephemList << acEndl;
} }
} }
ephem.close(); ephem.close();
} }
void AstroCalcDialog::cleanupEphemeris() void AstroCalcDialog::cleanupEphemeris()
{ {
EphemerisListJ2000.clear(); EphemerisListCoords.clear();
ui->ephemerisTreeWidget->clear(); ui->ephemerisTreeWidget->clear();
} }
void AstroCalcDialog::populateCelestialBodyList() void AstroCalcDialog::populateCelestialBodyList()
{ {
Q_ASSERT(ui->celestialBodyComboBox); Q_ASSERT(ui->celestialBodyComboBox);
Q_ASSERT(ui->graphsCelestialBodyComboBox);
QComboBox* planets = ui->celestialBodyComboBox; QComboBox* planets = ui->celestialBodyComboBox;
QComboBox* graphsp = ui->graphsCelestialBodyComboBox;
QStringList planetNames(solarSystem->getAllPlanetEnglishNames()); QStringList planetNames(solarSystem->getAllPlanetEnglishNames());
const StelTranslator& trans = StelApp::getInstance().getLocaleMgr(). getSkyTranslator(); const StelTranslator& trans = StelApp::getInstance().getLocaleMgr(). getSkyTranslator();
//Save the current selection to be restored later //Save the current selection to be restored later
planets->blockSignals(true); planets->blockSignals(true);
int index = planets->currentIndex(); int indexP = planets->currentIndex();
QVariant selectedPlanetId = planets->itemData(index); QVariant selectedPlanetId = planets->itemData(indexP);
planets->clear(); planets->clear();
graphsp->blockSignals(true);
int indexG = graphsp->currentIndex();
QVariant selectedGraphsPId = graphsp->itemData(indexG);
graphsp->clear();
//For each planet, display the localized name and store the original as user //For each planet, display the localized name and store the original as user
//data. Unfortunately, there's no other way to do this than with a c ycle. //data. Unfortunately, there's no other way to do this than with a c ycle.
foreach(const QString& name, planetNames) foreach(const QString& name, planetNames)
{ {
if (!name.contains("Observer", Qt::CaseInsensitive) && name! if (!name.contains("Observer", Qt::CaseInsensitive) && name!
="Sun" && name!=core->getCurrentPlanet()->getEnglishName()) =core->getCurrentPlanet()->getEnglishName())
{
planets->addItem(trans.qtranslate(name), name); planets->addItem(trans.qtranslate(name), name);
graphsp->addItem(trans.qtranslate(name), name);
}
} }
//Restore the selection //Restore the selection
index = planets->findData(selectedPlanetId, Qt::UserRole, Qt::MatchC indexP = planets->findData(selectedPlanetId, Qt::UserRole, Qt::Match
aseSensitive); CaseSensitive);
if (index<0) if (indexP<0)
index = planets->findData("Moon", Qt::UserRole, Qt::MatchCas indexP = planets->findData(conf->value("astrocalc/ephemeris_
eSensitive); celestial_body", "Moon").toString(), Qt::UserRole, Qt::MatchCaseSensitive);
planets->setCurrentIndex(index); planets->setCurrentIndex(indexP);
planets->model()->sort(0); planets->model()->sort(0);
indexG = graphsp->findData(selectedGraphsPId, Qt::UserRole, Qt::Matc
hCaseSensitive);
if (indexG<0)
indexG = graphsp->findData(conf->value("astrocalc/graphs_cel
estial_body", "Moon").toString(), Qt::UserRole, Qt::MatchCaseSensitive);
graphsp->setCurrentIndex(indexG);
graphsp->model()->sort(0);
planets->blockSignals(false); planets->blockSignals(false);
graphsp->blockSignals(false);
}
void AstroCalcDialog::saveEphemerisCelestialBody(int index)
{
Q_ASSERT(ui->celestialBodyComboBox);
QComboBox* planets = ui->celestialBodyComboBox;
conf->setValue("astrocalc/ephemeris_celestial_body", planets->itemDa
ta(index).toString());
}
void AstroCalcDialog::saveGraphsCelestialBody(int index)
{
Q_ASSERT(ui->graphsCelestialBodyComboBox);
QComboBox* planets = ui->graphsCelestialBodyComboBox;
conf->setValue("astrocalc/graphs_celestial_body", planets->itemData(
index).toString());
}
void AstroCalcDialog::saveGraphsFirstId(int index)
{
Q_ASSERT(ui->graphsFirstComboBox);
conf->setValue("astrocalc/graphs_first_id", ui->graphsFirstComboBox-
>itemData(index).toInt());
}
void AstroCalcDialog::saveGraphsSecondId(int index)
{
Q_ASSERT(ui->graphsSecondComboBox);
conf->setValue("astrocalc/graphs_second_id", ui->graphsSecondComboBo
x->itemData(index).toInt());
} }
void AstroCalcDialog::populateEphemerisTimeStepsList() void AstroCalcDialog::populateEphemerisTimeStepsList()
{ {
Q_ASSERT(ui->ephemerisStepComboBox); Q_ASSERT(ui->ephemerisStepComboBox);
QComboBox* steps = ui->ephemerisStepComboBox; QComboBox* steps = ui->ephemerisStepComboBox;
steps->blockSignals(true); steps->blockSignals(true);
int index = steps->currentIndex(); int index = steps->currentIndex();
QVariant selectedStepId = steps->itemData(index); QVariant selectedStepId = steps->itemData(index);
steps->clear(); steps->clear();
steps->addItem(q_("10 minutes"), "1"); steps->addItem(q_("10 minutes"), "1");
steps->addItem(q_("1 hour"), "2"); steps->addItem(q_("30 minutes"), "2");
steps->addItem(q_("1 day"), "3"); steps->addItem(q_("1 hour"), "3");
steps->addItem(q_("5 days"), "4"); steps->addItem(q_("6 hours"), "4");
steps->addItem(q_("10 days"), "5"); steps->addItem(q_("12 hours"), "5");
steps->addItem(q_("15 days"), "6"); steps->addItem(q_("1 day"), "6");
steps->addItem(q_("30 days"), "7"); steps->addItem(q_("5 days"), "7");
steps->addItem(q_("60 days"), "8"); steps->addItem(q_("10 days"), "8");
steps->addItem(q_("15 days"), "9");
steps->addItem(q_("30 days"), "10");
steps->addItem(q_("60 days"), "11");
index = steps->findData(selectedStepId, Qt::UserRole, Qt::MatchCaseS ensitive); index = steps->findData(selectedStepId, Qt::UserRole, Qt::MatchCaseS ensitive);
if (index<0) if (index<0)
index = 2; {
// default step: one day
index = steps->findData(conf->value("astrocalc/ephemeris_tim
e_step", "6").toString(), Qt::UserRole, Qt::MatchCaseSensitive);
}
steps->setCurrentIndex(index); steps->setCurrentIndex(index);
steps->blockSignals(false); steps->blockSignals(false);
} }
void AstroCalcDialog::saveEphemerisTimeStep(int index)
{
Q_ASSERT(ui->ephemerisStepComboBox);
QComboBox* steps = ui->ephemerisStepComboBox;
conf->setValue("astrocalc/ephemeris_time_step", steps->itemData(inde
x).toInt());
}
void AstroCalcDialog::populateMajorPlanetList() void AstroCalcDialog::populateMajorPlanetList()
{ {
Q_ASSERT(ui->object1ComboBox); // object 1 is always major planet Q_ASSERT(ui->object1ComboBox); // object 1 is always major planet
QComboBox* majorPlanet = ui->object1ComboBox; QComboBox* majorPlanet = ui->object1ComboBox;
QList<PlanetP> planets = solarSystem->getAllPlanets(); QList<PlanetP> planets = solarSystem->getAllPlanets();
const StelTranslator& trans = StelApp::getInstance().getLocaleMgr(). getSkyTranslator(); const StelTranslator& trans = StelApp::getInstance().getLocaleMgr(). getSkyTranslator();
//Save the current selection to be restored later //Save the current selection to be restored later
majorPlanet->blockSignals(true); majorPlanet->blockSignals(true);
skipping to change at line 543 skipping to change at line 1099
majorPlanet->addItem(trans.qtranslate(planet->getNam eI18n()), planet->getEnglishName()); majorPlanet->addItem(trans.qtranslate(planet->getNam eI18n()), planet->getEnglishName());
// moons of the current planet // moons of the current planet
if (planet->getPlanetType()==Planet::isMoon && planet->getEn glishName()!=core->getCurrentPlanet()->getEnglishName() && planet->getParen t()==core->getCurrentPlanet()) if (planet->getPlanetType()==Planet::isMoon && planet->getEn glishName()!=core->getCurrentPlanet()->getEnglishName() && planet->getParen t()==core->getCurrentPlanet())
majorPlanet->addItem(trans.qtranslate(planet->getNam eI18n()), planet->getEnglishName()); majorPlanet->addItem(trans.qtranslate(planet->getNam eI18n()), planet->getEnglishName());
} }
//Restore the selection //Restore the selection
index = majorPlanet->findData(selectedPlanetId, Qt::UserRole, Qt::Ma tchCaseSensitive); index = majorPlanet->findData(selectedPlanetId, Qt::UserRole, Qt::Ma tchCaseSensitive);
if (index<0) if (index<0)
index = majorPlanet->findData("Venus", Qt::UserRole, Qt::Mat chCaseSensitive); index = majorPlanet->findData(conf->value("astrocalc/phenome na_celestial_body", "Venus").toString(), Qt::UserRole, Qt::MatchCaseSensiti ve);
majorPlanet->setCurrentIndex(index); majorPlanet->setCurrentIndex(index);
majorPlanet->model()->sort(0); majorPlanet->model()->sort(0);
majorPlanet->blockSignals(false); majorPlanet->blockSignals(false);
} }
void AstroCalcDialog::savePhenomenaCelestialBody(int index)
{
Q_ASSERT(ui->object1ComboBox);
QComboBox* planets = ui->object1ComboBox;
conf->setValue("astrocalc/phenomena_celestial_body", planets->itemDa
ta(index).toString());
}
void AstroCalcDialog::populateGroupCelestialBodyList() void AstroCalcDialog::populateGroupCelestialBodyList()
{ {
Q_ASSERT(ui->object2ComboBox); Q_ASSERT(ui->object2ComboBox);
QComboBox* groups = ui->object2ComboBox; QComboBox* groups = ui->object2ComboBox;
groups->blockSignals(true); groups->blockSignals(true);
int index = groups->currentIndex(); int index = groups->currentIndex();
QVariant selectedGroupId = groups->itemData(index); QVariant selectedGroupId = groups->itemData(index);
QString brLimit = QString::number(brightLimit, 'f', 1); QString brLimit = QString::number(brightLimit, 'f', 1);
groups->clear(); groups->clear();
groups->addItem(q_("Solar system"), "0"); groups->addItem(q_("Solar system"), "0");
groups->addItem(q_("Planets"), "1"); groups->addItem(q_("Planets"), "1");
groups->addItem(q_("Asteroids"), "2"); groups->addItem(q_("Asteroids"), "2");
groups->addItem(q_("Plutinos"), "3"); groups->addItem(q_("Plutinos"), "3");
groups->addItem(q_("Comets"), "4"); groups->addItem(q_("Comets"), "4");
groups->addItem(q_("Dwarf planets"), "5"); groups->addItem(q_("Dwarf planets"), "5");
groups->addItem(q_("Cubewanos"), "6"); groups->addItem(q_("Cubewanos"), "6");
groups->addItem(q_("Scattered disc objects"), "7"); groups->addItem(q_("Scattered disc objects"), "7");
groups->addItem(q_("Oort cloud objects"), "8"); groups->addItem(q_("Oort cloud objects"), "8");
groups->addItem(q_("Bright stars (<%1 mag)").arg(QString::number(bri groups->addItem(q_("Sednoids"), "9");
ghtLimit-5.0f, 'f', 1)), "9"); groups->addItem(q_("Bright stars (<%1 mag)").arg(QString::number(bri
groups->addItem(q_("Bright star clusters (<%1 mag)").arg(brLimit), " ghtLimit-5.0f, 'f', 1)), "10");
10"); groups->addItem(q_("Bright double stars (<%1 mag)").arg(QString::num
groups->addItem(q_("Planetary nebulae"), "11"); ber(brightLimit-5.0f, 'f', 1)), "11");
groups->addItem(q_("Bright nebulae (<%1 mag)").arg(brLimit), "12"); groups->addItem(q_("Bright variable stars (<%1 mag)").arg(QString::n
groups->addItem(q_("Dark nebulae"), "13"); umber(brightLimit-5.0f, 'f', 1)), "12");
groups->addItem(q_("Bright galaxies (<%1 mag)").arg(brLimit), "14"); groups->addItem(q_("Bright star clusters (<%1 mag)").arg(brLimit), "
13");
groups->addItem(q_("Planetary nebulae"), "14");
groups->addItem(q_("Bright nebulae (<%1 mag)").arg(brLimit), "15");
groups->addItem(q_("Dark nebulae"), "16");
groups->addItem(q_("Bright galaxies (<%1 mag)").arg(brLimit), "17");
index = groups->findData(selectedGroupId, Qt::UserRole, Qt::MatchCas eSensitive); index = groups->findData(selectedGroupId, Qt::UserRole, Qt::MatchCas eSensitive);
if (index<0) if (index<0)
index = groups->findData("1", Qt::UserRole, Qt::MatchCaseSen sitive); index = groups->findData(conf->value("astrocalc/phenomena_ce lestial_group", "1").toString(), Qt::UserRole, Qt::MatchCaseSensitive);
groups->setCurrentIndex(index); groups->setCurrentIndex(index);
groups->model()->sort(0); groups->model()->sort(0);
groups->blockSignals(false); groups->blockSignals(false);
} }
void AstroCalcDialog::savePhenomenaCelestialGroup(int index)
{
Q_ASSERT(ui->object2ComboBox);
QComboBox* group = ui->object2ComboBox;
conf->setValue("astrocalc/phenomena_celestial_group", group->itemDat
a(index).toInt());
}
void AstroCalcDialog::cleanupPhenomena()
{
ui->phenomenaTreeWidget->clear();
}
void AstroCalcDialog::savePhenomenaOppositionFlag(bool b)
{
conf->setValue("astrocalc/flag_phenomena_opposition", b);
}
void AstroCalcDialog::savePhenomenaAngularSeparation(double v)
{
conf->setValue("astrocalc/phenomena_angular_separation", QString::nu
mber(v, 'f', 5));
}
void AstroCalcDialog::drawAltVsTimeDiagram() void AstroCalcDialog::drawAltVsTimeDiagram()
{ {
// Avoid crash!
if(core->getCurrentPlanet()->getEnglishName().contains("->")) // We
are on the spaceship!
return;
QList<StelObjectP> selectedObjects = objectMgr->getSelectedObject(); QList<StelObjectP> selectedObjects = objectMgr->getSelectedObject();
if (!selectedObjects.isEmpty()) if (!selectedObjects.isEmpty())
{ {
// X axis - time; Y axis - altitude // X axis - time; Y axis - altitude
QList<double> aX, aY; QList<double> aX, aY;
StelObjectP selectedObject = selectedObjects[0]; StelObjectP selectedObject = selectedObjects[0];
double currentJD = core->getJD(); double currentJD = core->getJD();
double noon = (int)currentJD; double noon = (int)currentJD;
double az, alt, deg; double az, alt, deg;
bool sign; bool sign;
double shift = core->getUTCOffset(currentJD)/24; double shift = core->getUTCOffset(currentJD)/24.0;
for(int i=-1;i<=49;i++) // Every 30 minutes (24 hours + 30 m double xMaxY = -100.f;
in extension in both directions) for(int i=-5;i<=485;i++) // 24 hours + 15 minutes in both di
{ rections
double ltime = i*1800 + 43200; {
// A new point on the graph every 3 minutes with shi
ft to right 12 hours
// to get midnight at the center of diagram (i.e. ac
curacy is 3 minutes)
double ltime = i*180 + 43200;
aX.append(ltime); aX.append(ltime);
double JD = noon + ltime/86400 - shift - 0.5; double JD = noon + ltime/86400 - shift - 0.5;
core->setJD(JD); core->setJD(JD);
StelUtils::rectToSphe(&az, &alt, selectedObject->get AltAzPosAuto(core)); StelUtils::rectToSphe(&az, &alt, selectedObject->get AltAzPosAuto(core));
StelUtils::radToDecDeg(alt, sign, deg); StelUtils::radToDecDeg(alt, sign, deg);
if (!sign) if (!sign)
deg *= -1; deg *= -1;
aY.append(deg); aY.append(deg);
if (deg > xMaxY)
{
xMaxY = deg;
transitX = ltime;
}
core->update(0.0); core->update(0.0);
} }
core->setJD(currentJD); core->setJD(currentJD);
QVector<double> x = aX.toVector(), y = aY.toVector(); QVector<double> x = aX.toVector(), y = aY.toVector();
double minYa = aY.first(); double minYa = aY.first();
double maxYa = aY.first(); double maxYa = aY.first();
foreach (double temp, aY) foreach (double temp, aY)
{ {
if(maxYa < temp) maxYa = temp; if(maxYa < temp) maxYa = temp;
if(minYa > temp) minYa = temp; if(minYa > temp) minYa = temp;
} }
minY = minYa - 2.0; minY = minYa - 2.0;
maxY = maxYa + 2.0; maxY = maxYa + 2.0;
prepareAxesAndGraph(); prepareAxesAndGraph();
drawCurrentTimeDiagram(); drawCurrentTimeDiagram();
QString name = selectedObject->getNameI18n(); QString name = selectedObject->getNameI18n();
if (name.isEmpty() && selectedObject->getType()=="Nebula") if (name.isEmpty() && selectedObject->getType()=="Nebula")
name = GETSTELMODULE(NebulaMgr)->getLatestSelectedDS ODesignation(); name = GETSTELMODULE(NebulaMgr)->getLatestSelectedDS ODesignation();
// FIXME: Satellites have different values for equatorial co
ordinates and same values for horizontal coordinates - a caching?
// NOTE: Drawing a line of transit time was added to else bl
ock to avoid troubles with satellites.
if (selectedObject->getType()=="Satellite")
{
x.clear();
y.clear();
}
else
drawTransitTimeDiagram();
ui->altVsTimePlot->graph(0)->setData(x, y); ui->altVsTimePlot->graph(0)->setData(x, y);
ui->altVsTimePlot->graph(0)->setName(name); ui->altVsTimePlot->graph(0)->setName(name);
ui->altVsTimePlot->replot(); ui->altVsTimePlot->replot();
} }
} }
// Added vertical line indicating "now" // Added vertical line indicating "now"
void AstroCalcDialog::drawCurrentTimeDiagram() void AstroCalcDialog::drawCurrentTimeDiagram()
{ {
double currentJD = core->getJD(); double currentJD = core->getJD();
skipping to change at line 657 skipping to change at line 1267
if (now>129600) if (now>129600)
now -= 86400; now -= 86400;
if (now<43200) if (now<43200)
now += 86400; now += 86400;
QList<double> ax, ay; QList<double> ax, ay;
ax.append(now); ax.append(now);
ax.append(now); ax.append(now);
ay.append(minY); ay.append(minY);
ay.append(maxY); ay.append(maxY);
QVector<double> x = ax.toVector(), y = ay.toVector(); QVector<double> x = ax.toVector(), y = ay.toVector();
ui->altVsTimePlot->removeGraph(1);
ui->altVsTimePlot->addGraph(); ui->altVsTimePlot->addGraph();
ui->altVsTimePlot->graph(1)->setData(x, y); ui->altVsTimePlot->graph(1)->setData(x, y);
ui->altVsTimePlot->graph(1)->setPen(QPen(Qt::yellow, 1)); ui->altVsTimePlot->graph(1)->setPen(QPen(Qt::yellow, 1));
ui->altVsTimePlot->graph(1)->setLineStyle(QCPGraph::lsLine); ui->altVsTimePlot->graph(1)->setLineStyle(QCPGraph::lsLine);
ui->altVsTimePlot->graph(1)->setName("[Now]"); ui->altVsTimePlot->graph(1)->setName("[Now]");
ui->altVsTimePlot->replot(); ui->altVsTimePlot->replot();
} }
// Added vertical line indicating time of transit
void AstroCalcDialog::drawTransitTimeDiagram()
{
QList<double> ax, ay;
ax.append(transitX);
ax.append(transitX);
ay.append(minY);
ay.append(maxY);
QVector<double> x = ax.toVector(), y = ay.toVector();
ui->altVsTimePlot->addGraph();
ui->altVsTimePlot->graph(2)->setData(x, y);
ui->altVsTimePlot->graph(2)->setPen(QPen(Qt::cyan, 1));
ui->altVsTimePlot->graph(2)->setLineStyle(QCPGraph::lsLine);
ui->altVsTimePlot->graph(2)->setName("[Transit]");
ui->altVsTimePlot->replot();
}
void AstroCalcDialog::prepareAxesAndGraph() void AstroCalcDialog::prepareAxesAndGraph()
{ {
QString xAxisStr = q_("Local Time"); QString xAxisStr = q_("Local Time");
QString yAxisStr = QString("%1, %2").arg(q_("Altitude"), QChar(0x00B 0)); QString yAxisStr = QString("%1, %2").arg(q_("Altitude"), QChar(0x00B 0));
QColor axisColor(Qt::white); QColor axisColor(Qt::white);
QPen axisPen(axisColor, 1); QPen axisPen(axisColor, 1);
ui->altVsTimePlot->clearGraphs(); ui->altVsTimePlot->clearGraphs();
ui->altVsTimePlot->addGraph(); ui->altVsTimePlot->addGraph();
skipping to change at line 708 skipping to change at line 1335
ui->altVsTimePlot->yAxis->setRange(minY, maxY); ui->altVsTimePlot->yAxis->setRange(minY, maxY);
ui->altVsTimePlot->yAxis->setScaleType(QCPAxis::stLinear); ui->altVsTimePlot->yAxis->setScaleType(QCPAxis::stLinear);
ui->altVsTimePlot->yAxis->setLabelColor(axisColor); ui->altVsTimePlot->yAxis->setLabelColor(axisColor);
ui->altVsTimePlot->yAxis->setTickLabelColor(axisColor); ui->altVsTimePlot->yAxis->setTickLabelColor(axisColor);
ui->altVsTimePlot->yAxis->setBasePen(axisPen); ui->altVsTimePlot->yAxis->setBasePen(axisPen);
ui->altVsTimePlot->yAxis->setTickPen(axisPen); ui->altVsTimePlot->yAxis->setTickPen(axisPen);
ui->altVsTimePlot->yAxis->setSubTickPen(axisPen); ui->altVsTimePlot->yAxis->setSubTickPen(axisPen);
} }
void AstroCalcDialog::drawXVsTimeGraphs()
{
PlanetP ssObj = solarSystem->searchByEnglishName(ui->graphsCelestial
BodyComboBox->currentData().toString());
if (!ssObj.isNull())
{
// X axis - time; Y axis - altitude
QList<double> aX, aY, bY;
double currentJD = core->getJD();
int year, month, day;
double startJD, JD, ltime, distance, angularSize;
StelUtils::getDateFromJulianDay(currentJD, &year, &month, &d
ay);
StelUtils::getJDFromDate(&startJD, year, 1, 1, 0, 0, 0);
float width = 1.0f;
int dYear = (int)core->getCurrentPlanet()->getSiderealPeriod
() + 3;
for(int i=-2;i<=dYear;i++)
{
JD = startJD + i;
ltime = (JD - startJD) * StelCore::ONE_OVER_JD_SECON
D;
aX.append(ltime);
core->setJD(JD);
switch (ui->graphsFirstComboBox->currentData().toInt
())
{
case GraphMagnitudeVsTime:
aY.append(ssObj->getVMagnitude(core)
);
break;
case GraphPhaseVsTime:
aY.append(ssObj->getPhase(core->getO
bserverHeliocentricEclipticPos()) * 100.f);
break;
case GraphDistanceVsTime:
distance = ssObj->getJ2000Equatorial
Pos(core).length();
if (distance < 0.1)
distance *= AU/1000.f;
aY.append(distance);
break;
case GraphElongationVsTime:
aY.append(ssObj->getElongation(core-
>getObserverHeliocentricEclipticPos())*180./M_PI);
break;
case GraphAngularSizeVsTime:
angularSize = ssObj->getAngularSize(
core)*360./M_PI;
if (angularSize<1.)
angularSize *= 60.;
aY.append(angularSize);
break;
case GraphPhaseAngleVsTime:
aY.append(ssObj->getPhaseAngle(core-
>getObserverHeliocentricEclipticPos())*180./M_PI);
break;
}
switch (ui->graphsSecondComboBox->currentData().toIn
t())
{
case GraphMagnitudeVsTime:
bY.append(ssObj->getVMagnitude(core)
);
break;
case GraphPhaseVsTime:
bY.append(ssObj->getPhase(core->getO
bserverHeliocentricEclipticPos()) * 100.f);
break;
case GraphDistanceVsTime:
distance = ssObj->getJ2000Equatorial
Pos(core).length();
if (distance < 0.1)
distance *= AU/1000.f;
bY.append(distance);
break;
case GraphElongationVsTime:
bY.append(ssObj->getElongation(core-
>getObserverHeliocentricEclipticPos())*180./M_PI);
break;
case GraphAngularSizeVsTime:
angularSize = ssObj->getAngularSize(
core)*360./M_PI;
if (angularSize<1.)
angularSize *= 60.;
bY.append(angularSize);
break;
case GraphPhaseAngleVsTime:
bY.append(ssObj->getPhaseAngle(core-
>getObserverHeliocentricEclipticPos())*180./M_PI);
break;
}
core->update(0.0);
}
core->setJD(currentJD);
QVector<double> x = aX.toVector(), ya = aY.toVector(), yb =
bY.toVector();
double minYa = aY.first();
double maxYa = aY.first();
foreach (double temp, aY)
{
if(maxYa < temp) maxYa = temp;
if(minYa > temp) minYa = temp;
}
width = (maxYa - minYa)/50.f;
minY1 = minYa - width;
maxY1 = maxYa + width;
minYa = bY.first();
maxYa = bY.first();
foreach (double temp, bY)
{
if(maxYa < temp) maxYa = temp;
if(minYa > temp) minYa = temp;
}
width = (maxYa - minYa)/50.f;
minY2 = minYa - width;
maxY2 = maxYa + width;
prepareXVsTimeAxesAndGraph();
ui->graphsPlot->clearGraphs();
ui->graphsPlot->addGraph(ui->graphsPlot->xAxis, ui->graphsPl
ot->yAxis);
ui->graphsPlot->setBackground(QBrush(QColor(86, 87, 90)));
ui->graphsPlot->graph(0)->setPen(QPen(Qt::red, 1));
ui->graphsPlot->graph(0)->setLineStyle(QCPGraph::lsLine);
ui->graphsPlot->graph(0)->rescaleAxes(true);
ui->graphsPlot->graph(0)->setData(x, ya);
ui->graphsPlot->graph(0)->setName("[0]");
ui->graphsPlot->addGraph(ui->graphsPlot->xAxis, ui->graphsPl
ot->yAxis2);
ui->graphsPlot->setBackground(QBrush(QColor(86, 87, 90)));
ui->graphsPlot->graph(1)->setPen(QPen(Qt::yellow, 1));
ui->graphsPlot->graph(1)->setLineStyle(QCPGraph::lsLine);
ui->graphsPlot->graph(1)->rescaleAxes(true);
ui->graphsPlot->graph(1)->setData(x, yb);
ui->graphsPlot->graph(1)->setName("[1]");
ui->graphsPlot->replot();
}
}
void AstroCalcDialog::populateFunctionsList()
{
Q_ASSERT(ui->graphsFirstComboBox);
Q_ASSERT(ui->graphsSecondComboBox);
typedef QPair<QString, GraphsTypes> graph;
graph cf;
QList<graph> functions;
functions.clear();
cf.first = q_("Magnitude vs. Time");
cf.second = GraphMagnitudeVsTime;
functions.append(cf);
cf.first = q_("Phase vs. Time");
cf.second = GraphPhaseVsTime;
functions.append(cf);
cf.first = q_("Distance vs. Time");
cf.second = GraphDistanceVsTime;
functions.append(cf);
cf.first = q_("Elongation vs. Time");
cf.second = GraphElongationVsTime;
functions.append(cf);
cf.first = q_("Angular size vs. Time");
cf.second = GraphAngularSizeVsTime;
functions.append(cf);
cf.first = q_("Phase angle vs. Time");
cf.second = GraphPhaseAngleVsTime;
functions.append(cf);
QComboBox* first = ui->graphsFirstComboBox;
QComboBox* second = ui->graphsSecondComboBox;
first->blockSignals(true);
second->blockSignals(true);
int indexF = first->currentIndex();
QVariant selectedFirstId = first->itemData(indexF);
int indexS = second->currentIndex();
QVariant selectedSecondId = second->itemData(indexS);
foreach(const graph& f, functions)
{
first->addItem(f.first, f.second);
second->addItem(f.first, f.second);
}
indexF = first->findData(selectedFirstId, Qt::UserRole, Qt::MatchCas
eSensitive);
if (indexF<0)
indexF = first->findData(conf->value("astrocalc/graphs_first
_id", GraphMagnitudeVsTime).toInt(), Qt::UserRole, Qt::MatchCaseSensitive);
first->setCurrentIndex(indexF);
first->model()->sort(0);
indexS = second->findData(selectedSecondId, Qt::UserRole, Qt::MatchC
aseSensitive);
if (indexS<0)
indexS = second->findData(conf->value("astrocalc/graphs_seco
nd_id", GraphPhaseVsTime).toInt(), Qt::UserRole, Qt::MatchCaseSensitive);
second->setCurrentIndex(indexS);
second->model()->sort(0);
first->blockSignals(false);
second->blockSignals(false);
}
void AstroCalcDialog::prepareXVsTimeAxesAndGraph()
{
QString xAxisStr = q_("Date");
QString distMU = qc_("AU", "astronomical unit");
QString asMU = QString("'");
PlanetP ssObj = solarSystem->searchByEnglishName(ui->graphsCelestial
BodyComboBox->currentData().toString());
if (!ssObj.isNull())
{
if (ssObj->getJ2000EquatorialPos(core).length() < 0.1)
{
// TRANSLATORS: Megameter (SI symbol: Mm; Megameter
is a unit of length in the metric system, equal to one million metres)
distMU = q_("Mm");
}
if ((ssObj->getAngularSize(core)*360./M_PI) < 1.)
asMU = QString("\"");
}
bool direction1 = false;
bool direction2 = false;
switch (ui->graphsFirstComboBox->currentData().toInt())
{
case GraphMagnitudeVsTime:
yAxis1Legend = q_("Magnitude");
if (minY1<-1000.f) minY1 = 0.f;
if (maxY1>1000.f) maxY1 = 6.f;
direction1 = true;
break;
case GraphPhaseVsTime:
yAxis1Legend = QString("%1, %").arg(q_("Phase"));
if (minY1<-1000.f) minY1 = 0.f;
if (maxY1>1000.f) maxY1 = 100.f;
break;
case GraphDistanceVsTime:
yAxis1Legend = QString("%1, %2").arg(q_("Distance"),
distMU);
if (minY1<-1000.f) minY1 = 0.f;
if (maxY1>1000.f) maxY1 = 50.f;
break;
case GraphElongationVsTime:
yAxis1Legend = QString("%1, %2").arg(q_("Elongation"
), QChar(0x00B0));
if (minY1<-1000.f) minY1 = 0.f;
if (maxY1>1000.f) maxY1 = 180.f;
break;
case GraphAngularSizeVsTime:
yAxis1Legend = QString("%1, %2").arg(q_("Angular siz
e"), asMU);
if (minY1<-1000.f) minY1 = 0.f;
if (maxY1>1000.f) maxY1 = 30.f;
break;
case GraphPhaseAngleVsTime:
yAxis1Legend = QString("%1, %2").arg(q_("Phase angle
"), QChar(0x00B0));
if (minY1<-1000.f) minY1 = 0.f;
if (maxY1>1000.f) maxY1 = 180.f;
break;
}
switch (ui->graphsSecondComboBox->currentData().toInt())
{
case GraphMagnitudeVsTime:
yAxis2Legend = q_("Magnitude");
if (minY2<-1000.f) minY2 = 0.f;
if (maxY2>1000.f) maxY2 = 6.f;
direction2 = true;
break;
case GraphPhaseVsTime:
yAxis2Legend = QString("%1, %").arg(q_("Phase"));
if (minY2<-1000.f) minY2 = 0.f;
if (maxY2>1000.f) maxY2 = 100.f;
break;
case GraphDistanceVsTime:
yAxis2Legend = QString("%1, %2").arg(q_("Distance"),
distMU);
if (minY2<-1000.f) minY2 = 0.f;
if (maxY2>1000.f) maxY2 = 50.f;
break;
case GraphElongationVsTime:
yAxis2Legend = QString("%1, %2").arg(q_("Elongation"
), QChar(0x00B0));
if (minY2<-1000.f) minY2 = 0.f;
if (maxY2>1000.f) maxY2 = 180.f;
break;
case GraphAngularSizeVsTime:
yAxis2Legend = QString("%1, %2").arg(q_("Angular siz
e"), asMU);
if (minY2<-1000.f) minY2 = 0.f;
if (maxY2>1000.f) maxY2 = 30.f;
break;
case GraphPhaseAngleVsTime:
yAxis2Legend = QString("%1, %2").arg(q_("Phase angle
"), QChar(0x00B0));
if (minY2<-1000.f) minY2 = 0.f;
if (maxY2>1000.f) maxY2 = 180.f;
break;
}
QColor axisColor(Qt::white);
QPen axisPen(axisColor, 1);
ui->graphsPlot->xAxis->setLabel(xAxisStr);
ui->graphsPlot->yAxis->setLabel(yAxis1Legend);
ui->graphsPlot->yAxis2->setLabel(yAxis2Legend);
int dYear = ((int)core->getCurrentPlanet()->getSiderealPeriod() + 1)
*86400;
ui->graphsPlot->xAxis->setRange(0, dYear);
ui->graphsPlot->xAxis->setScaleType(QCPAxis::stLinear);
ui->graphsPlot->xAxis->setTickLabelType(QCPAxis::ltDateTime);
ui->graphsPlot->xAxis->setLabelColor(axisColor);
ui->graphsPlot->xAxis->setTickLabelColor(axisColor);
ui->graphsPlot->xAxis->setBasePen(axisPen);
ui->graphsPlot->xAxis->setTickPen(axisPen);
ui->graphsPlot->xAxis->setSubTickPen(axisPen);
ui->graphsPlot->xAxis->setDateTimeFormat("dd/MM");
ui->graphsPlot->xAxis->setDateTimeSpec(Qt::UTC);
ui->graphsPlot->xAxis->setAutoTickStep(true);
ui->graphsPlot->xAxis->setSubTickCount(10);
ui->graphsPlot->yAxis->setRange(minY1, maxY1);
ui->graphsPlot->yAxis->setScaleType(QCPAxis::stLinear);
ui->graphsPlot->yAxis->setLabelColor(axisColor);
ui->graphsPlot->yAxis->setTickLabelColor(axisColor);
ui->graphsPlot->yAxis->setBasePen(axisPen);
ui->graphsPlot->yAxis->setTickPen(axisPen);
ui->graphsPlot->yAxis->setSubTickPen(axisPen);
ui->graphsPlot->yAxis->setRangeReversed(direction1);
ui->graphsPlot->yAxis2->setRange(minY2, maxY2);
ui->graphsPlot->yAxis2->setScaleType(QCPAxis::stLinear);
ui->graphsPlot->yAxis2->setLabelColor(axisColor);
ui->graphsPlot->yAxis2->setTickLabelColor(axisColor);
ui->graphsPlot->yAxis2->setBasePen(axisPen);
ui->graphsPlot->yAxis2->setTickPen(axisPen);
ui->graphsPlot->yAxis2->setSubTickPen(axisPen);
ui->graphsPlot->yAxis2->setRangeReversed(direction2);
ui->graphsPlot->yAxis2->setVisible(true);
ui->graphsPlot->clearGraphs();
ui->graphsPlot->addGraph(ui->graphsPlot->xAxis, ui->graphsPlot->yAxi
s);
ui->graphsPlot->setBackground(QBrush(QColor(86, 87, 90)));
ui->graphsPlot->graph(0)->setPen(QPen(Qt::red, 1));
ui->graphsPlot->graph(0)->setLineStyle(QCPGraph::lsLine);
ui->graphsPlot->graph(0)->rescaleAxes(true);
ui->graphsPlot->addGraph(ui->graphsPlot->xAxis, ui->graphsPlot->yAxi
s2);
ui->graphsPlot->setBackground(QBrush(QColor(86, 87, 90)));
ui->graphsPlot->graph(1)->setPen(QPen(Qt::yellow, 1));
ui->graphsPlot->graph(1)->setLineStyle(QCPGraph::lsLine);
ui->graphsPlot->graph(1)->rescaleAxes(true);
}
void AstroCalcDialog::mouseOverLine(QMouseEvent *event) void AstroCalcDialog::mouseOverLine(QMouseEvent *event)
{ {
double x = ui->altVsTimePlot->xAxis->pixelToCoord(event->pos().x()); double x = ui->altVsTimePlot->xAxis->pixelToCoord(event->pos().x());
double y = ui->altVsTimePlot->yAxis->pixelToCoord(event->pos().y()); double y = ui->altVsTimePlot->yAxis->pixelToCoord(event->pos().y());
QCPAbstractPlottable *abstractGraph = ui->altVsTimePlot->plottableAt (event->pos(), false); QCPAbstractPlottable *abstractGraph = ui->altVsTimePlot->plottableAt (event->pos(), false);
QCPGraph *graph = qobject_cast<QCPGraph *>(abstractGraph); QCPGraph *graph = qobject_cast<QCPGraph *>(abstractGraph);
if (x>ui->altVsTimePlot->xAxis->range().lower && x<ui->altVsTimePlot ->xAxis->range().upper && y>ui->altVsTimePlot->yAxis->range().lower && y<ui ->altVsTimePlot->yAxis->range().upper) if (x>ui->altVsTimePlot->xAxis->range().lower && x<ui->altVsTimePlot ->xAxis->range().upper && y>ui->altVsTimePlot->yAxis->range().lower && y<ui ->altVsTimePlot->yAxis->range().upper)
{ {
if (graph) if (graph)
{ {
double JD = x/86400.0 + (int)core->getJD() - 0.5; double JD = x/86400.0 + (int)core->getJD() - 0.5;
QString LT = StelUtils::jdToQDateTime(JD - core->get UTCOffset(JD)).toString("H:mm"); QString LT = StelUtils::jdToQDateTime(JD - core->get UTCOffset(JD)).toString("H:mm");
QString info; QString info;
if (graph->name()=="[Now]") if (graph->name()=="[Now]")
info = q_("Now is %1").arg(LT); info = q_("Now about %1").arg(LT);
else if (graph->name()=="[Transit]")
info = q_("Passage of meridian at approximat
ely %1").arg(LT);
else else
{ {
if (StelApp::getInstance().getFlagShowDecima lDegrees()) if (StelApp::getInstance().getFlagShowDecima lDegrees())
info = QString("%1<br />%2: %3<br /> %4: %5%6").arg(ui->altVsTimePlot->graph(0)->name(), q_("Local Time"), LT, q _("Altitude"), QString::number(y, 'f', 2), QChar(0x00B0)); info = QString("%1<br />%2: %3<br /> %4: %5%6").arg(ui->altVsTimePlot->graph(0)->name(), q_("Local Time"), LT, q _("Altitude"), QString::number(y, 'f', 2), QChar(0x00B0));
else else
info = QString("%1<br />%2: %3<br /> %4: %5").arg(ui->altVsTimePlot->graph(0)->name(), q_("Local Time"), LT, q_( "Altitude"), StelUtils::decDegToDmsStr(y)); info = QString("%1<br />%2: %3<br /> %4: %5").arg(ui->altVsTimePlot->graph(0)->name(), q_("Local Time"), LT, q_( "Altitude"), StelUtils::decDegToDmsStr(y));
} }
QToolTip::hideText(); QToolTip::hideText();
QToolTip::showText(event->globalPos(), info, ui->alt VsTimePlot, ui->altVsTimePlot->rect()); QToolTip::showText(event->globalPos(), info, ui->alt VsTimePlot, ui->altVsTimePlot->rect());
skipping to change at line 796 skipping to change at line 1767
mvmgr->moveToObject(newSelected[0], mvmgr->getAutoMo veDuration()); mvmgr->moveToObject(newSelected[0], mvmgr->getAutoMo veDuration());
mvmgr->setFlagTracking(true); mvmgr->setFlagTracking(true);
} }
} }
} }
void AstroCalcDialog::calculatePhenomena() void AstroCalcDialog::calculatePhenomena()
{ {
QString currentPlanet = ui->object1ComboBox->currentData().toString( ); QString currentPlanet = ui->object1ComboBox->currentData().toString( );
double separation = ui->allowedSeparationDoubleSpinBox->value(); double separation = ui->allowedSeparationDoubleSpinBox->value();
bool opposition = ui->phenomenaOppositionCheckBox->isChecked();
initListPhenomena(); initListPhenomena();
QList<PlanetP> objects; QList<PlanetP> objects;
objects.clear(); objects.clear();
QList<PlanetP> allObjects = solarSystem->getAllPlanets(); QList<PlanetP> allObjects = solarSystem->getAllPlanets();
QList<NebulaP> dso; QList<NebulaP> dso;
dso.clear(); dso.clear();
QVector<NebulaP> allDSO = dsoMgr->getAllDeepSkyObjects(); QVector<NebulaP> allDSO = dsoMgr->getAllDeepSkyObjects();
QList<StelObjectP> star; QList<StelObjectP> star, doubleStar, variableStar;
star.clear(); star.clear();
doubleStar.clear();
variableStar.clear();
QList<StelObjectP> hipStars = starMgr->getHipparcosStars(); QList<StelObjectP> hipStars = starMgr->getHipparcosStars();
QList<StelACStarData> doubleHipStars = starMgr->getHipparcosDoubleSt
ars();
QList<StelACStarData> variableHipStars = starMgr->getHipparcosVariab
leStars();
int obj2Type = ui->object2ComboBox->currentData().toInt(); int obj2Type = ui->object2ComboBox->currentData().toInt();
switch (obj2Type) switch (obj2Type)
{ {
case 0: // Solar system case 0: // Solar system
foreach(const PlanetP& object, allObjects) foreach(const PlanetP& object, allObjects)
{ {
if (object->getPlanetType()!=Planet::isUNDEF INED) if (object->getPlanetType()!=Planet::isUNDEF INED)
objects.append(object); objects.append(object);
} }
skipping to change at line 877 skipping to change at line 1853
objects.append(object); objects.append(object);
} }
break; break;
case 8: // Oort cloud objects case 8: // Oort cloud objects
foreach(const PlanetP& object, allObjects) foreach(const PlanetP& object, allObjects)
{ {
if (object->getPlanetType()==Planet::isOCO) if (object->getPlanetType()==Planet::isOCO)
objects.append(object); objects.append(object);
} }
break; break;
case 9: // Stars case 9: // Sednoids
foreach(const PlanetP& object, allObjects)
{
if (object->getPlanetType()==Planet::isSedno
id)
objects.append(object);
}
break;
case 10: // Stars
foreach(const StelObjectP& object, hipStars) foreach(const StelObjectP& object, hipStars)
{ {
if (object->getVMagnitude(core)<(brightLimit -5.0f)) if (object->getVMagnitude(core)<(brightLimit -5.0f))
star.append(object); star.append(object);
} }
break; break;
case 10: // Star clusters case 11: // Double stars
foreach(const StelACStarData& object, doubleHipStars
)
{
if (object.firstKey()->getVMagnitude(core)<(
brightLimit-5.0f))
star.append(object.firstKey());
}
break;
case 12: // Variable stars
foreach(const StelACStarData& object, variableHipSta
rs)
{
if (object.firstKey()->getVMagnitude(core)<(
brightLimit-5.0f))
star.append(object.firstKey());
}
break;
case 13: // Star clusters
foreach(const NebulaP& object, allDSO) foreach(const NebulaP& object, allDSO)
{ {
if (object->getVMagnitude(core)<brightLimit && (object->getDSOType()==Nebula::NebCl || object->getDSOType()==Nebula::Ne bOc || object->getDSOType()==Nebula::NebGc || object->getDSOType()==Nebula: :NebSA || object->getDSOType()==Nebula::NebSC || object->getDSOType()==Nebu la::NebCn)) if (object->getVMagnitude(core)<brightLimit && (object->getDSOType()==Nebula::NebCl || object->getDSOType()==Nebula::Ne bOc || object->getDSOType()==Nebula::NebGc || object->getDSOType()==Nebula: :NebSA || object->getDSOType()==Nebula::NebSC || object->getDSOType()==Nebu la::NebCn))
dso.append(object); dso.append(object);
} }
break; break;
case 11: // Planetary nebulae case 14: // Planetary nebulae
foreach(const NebulaP& object, allDSO) foreach(const NebulaP& object, allDSO)
{ {
if (object->getDSOType()==Nebula::NebPn || o bject->getDSOType()==Nebula::NebPossPN || object->getDSOType()==Nebula::Neb PPN) if (object->getDSOType()==Nebula::NebPn || o bject->getDSOType()==Nebula::NebPossPN || object->getDSOType()==Nebula::Neb PPN)
dso.append(object); dso.append(object);
} }
break; break;
case 12: // Bright nebulae case 15: // Bright nebulae
foreach(const NebulaP& object, allDSO) foreach(const NebulaP& object, allDSO)
{ {
if (object->getVMagnitude(core)<brightLimit && (object->getDSOType()==Nebula::NebN || object->getDSOType()==Nebula::Neb Bn || object->getDSOType()==Nebula::NebEn || object->getDSOType()==Nebula:: NebRn || object->getDSOType()==Nebula::NebHII || object->getDSOType()==Nebu la::NebISM || object->getDSOType()==Nebula::NebCn || object->getDSOType()== Nebula::NebSNR)) if (object->getVMagnitude(core)<brightLimit && (object->getDSOType()==Nebula::NebN || object->getDSOType()==Nebula::Neb Bn || object->getDSOType()==Nebula::NebEn || object->getDSOType()==Nebula:: NebRn || object->getDSOType()==Nebula::NebHII || object->getDSOType()==Nebu la::NebISM || object->getDSOType()==Nebula::NebCn || object->getDSOType()== Nebula::NebSNR))
dso.append(object); dso.append(object);
} }
break; break;
case 13: // Dark nebulae case 16: // Dark nebulae
foreach(const NebulaP& object, allDSO) foreach(const NebulaP& object, allDSO)
{ {
if (object->getDSOType()==Nebula::NebDn || o bject->getDSOType()==Nebula::NebMolCld || object->getDSOType()==Nebula::Neb YSO) if (object->getDSOType()==Nebula::NebDn || o bject->getDSOType()==Nebula::NebMolCld || object->getDSOType()==Nebula::Neb YSO)
dso.append(object); dso.append(object);
} }
break; break;
case 14: // Galaxies case 17: // Galaxies
foreach(const NebulaP& object, allDSO) foreach(const NebulaP& object, allDSO)
{ {
if (object->getVMagnitude(core)<brightLimit && (object->getDSOType()==Nebula::NebGx || object->getDSOType()==Nebula::Ne bAGx || object->getDSOType()==Nebula::NebRGx || object->getDSOType()==Nebul a::NebQSO || object->getDSOType()==Nebula::NebPossQSO || object->getDSOType ()==Nebula::NebBLL || object->getDSOType()==Nebula::NebBLA || object->getDS OType()==Nebula::NebIGx)) if (object->getVMagnitude(core)<brightLimit && (object->getDSOType()==Nebula::NebGx || object->getDSOType()==Nebula::Ne bAGx || object->getDSOType()==Nebula::NebRGx || object->getDSOType()==Nebul a::NebQSO || object->getDSOType()==Nebula::NebPossQSO || object->getDSOType ()==Nebula::NebBLL || object->getDSOType()==Nebula::NebBLA || object->getDS OType()==Nebula::NebIGx))
dso.append(object); dso.append(object);
} }
break; break;
} }
PlanetP planet = solarSystem->searchByEnglishName(currentPlanet); PlanetP planet = solarSystem->searchByEnglishName(currentPlanet);
if (planet) if (planet)
{ {
double currentJD = core->getJD(); // save current JD double currentJD = core->getJD(); // save current JD
double currentJDE = core->getJDE(); // save current JDE
double startJD = StelUtils::qDateTimeToJd(QDateTime(ui->phen omenFromDateEdit->date())); double startJD = StelUtils::qDateTimeToJd(QDateTime(ui->phen omenFromDateEdit->date()));
double stopJD = StelUtils::qDateTimeToJd(QDateTime(ui->pheno menToDateEdit->date().addDays(1))); double stopJD = StelUtils::qDateTimeToJd(QDateTime(ui->pheno menToDateEdit->date().addDays(1)));
startJD = startJD - core->getUTCOffset(startJD)/24; startJD = startJD - core->getUTCOffset(startJD)/24;
stopJD = stopJD - core->getUTCOffset(stopJD)/24; stopJD = stopJD - core->getUTCOffset(stopJD)/24;
if (obj2Type<9) // Calculate the limits on coordinates for speed-up of calcu
lations
double coordsLimit = std::abs(core->getCurrentPlanet()->getR
otObliquity(currentJDE)) + std::abs(planet->getRotObliquity(currentJDE)) +
0.026;
coordsLimit += separation*M_PI/180;
double ra, dec;
if (obj2Type<10)
{ {
// Solar system objects // Solar system objects
foreach (PlanetP obj, objects) foreach (PlanetP obj, objects)
{ {
// conjunction // conjunction
fillPhenomenaTable(findClosestApproach(plane t, obj, startJD, stopJD, separation, false), planet, obj, false); fillPhenomenaTable(findClosestApproach(plane t, obj, startJD, stopJD, separation, false), planet, obj, false);
// opposition // opposition
fillPhenomenaTable(findClosestApproach(plane if (opposition)
t, obj, startJD, stopJD, separation, true), planet, obj, true); fillPhenomenaTable(findClosestApproa
ch(planet, obj, startJD, stopJD, separation, true), planet, obj, true);
} }
} }
else if (obj2Type==9) else if (obj2Type==10 || obj2Type==11 || obj2Type==12)
{ {
// Stars // Stars
foreach (StelObjectP obj, star) foreach (StelObjectP obj, star)
{ {
// conjunction StelUtils::rectToSphe(&ra, &dec, obj->getEqu
fillPhenomenaTable(findClosestApproach(plane inoxEquatorialPos(core));
t, obj, startJD, stopJD, separation), planet, obj); // Add limits on coordinates for speed-up ca
lculations
if (dec<=coordsLimit && dec>=-coordsLimit)
{
// conjunction
fillPhenomenaTable(findClosestApproa
ch(planet, obj, startJD, stopJD, separation), planet, obj);
}
} }
} }
else else
{ {
// Deep-sky objects // Deep-sky objects
foreach (NebulaP obj, dso) foreach (NebulaP obj, dso)
{ {
// conjunction StelUtils::rectToSphe(&ra, &dec, obj->getEqu
fillPhenomenaTable(findClosestApproach(plane inoxEquatorialPos(core));
t, obj, startJD, stopJD, separation), planet, obj); // Add limits on coordinates for speed-up ca
lculations
if (dec<=coordsLimit && dec>=-coordsLimit)
{
// conjunction
fillPhenomenaTable(findClosestApproa
ch(planet, obj, startJD, stopJD, separation), planet, obj);
}
} }
} }
core->setJD(currentJD); // restore time core->setJD(currentJD); // restore time
core->update(0); core->update(0);
} }
// adjust the column width // adjust the column width
for(int i = 0; i < PhenomenaCount; ++i) for(int i = 0; i < PhenomenaCount; ++i)
{ {
skipping to change at line 1043 skipping to change at line 2057
else else
phenomenType = q_("Occultation"); phenomenType = q_("Occultation");
// Added a special case - eclipse // Added a special case - eclipse
if (qAbs(s1-s2)<=0.05 && (object1->getEnglishName()= ="Sun" || object2->getEnglishName()=="Sun")) // 5% error of difference of s izes if (qAbs(s1-s2)<=0.05 && (object1->getEnglishName()= ="Sun" || object2->getEnglishName()=="Sun")) // 5% error of difference of s izes
phenomenType = q_("Eclipse"); phenomenType = q_("Eclipse");
occultation = true; occultation = true;
} }
ACTreeWidgetItem *treeItem = new ACTreeWidgetItem(ui->phenom enaTreeWidget); ACPhenTreeWidgetItem *treeItem = new ACPhenTreeWidgetItem(ui ->phenomenaTreeWidget);
treeItem->setText(PhenomenaType, phenomenType); treeItem->setText(PhenomenaType, phenomenType);
// local date and time // local date and time
treeItem->setText(PhenomenaDate, StelUtils::jdToQDateTime(it .key() + core->getUTCOffset(it.key())/24).toString("yyyy-MM-dd hh:mm:ss")); treeItem->setText(PhenomenaDate, QString("%1 %2").arg(locale Mgr->getPrintableDateLocal(it.key()), localeMgr->getPrintableTimeLocal(it.k ey())));
treeItem->setText(PhenomenaObject1, object1->getNameI18n()); treeItem->setText(PhenomenaObject1, object1->getNameI18n());
treeItem->setText(PhenomenaObject2, object2->getNameI18n()); treeItem->setText(PhenomenaObject2, object2->getNameI18n());
if (occultation) if (occultation)
treeItem->setText(PhenomenaSeparation, QChar(0x2014) ); treeItem->setText(PhenomenaSeparation, QChar(0x2014) );
else else
treeItem->setText(PhenomenaSeparation, StelUtils::ra dToDmsStr(separation)); treeItem->setText(PhenomenaSeparation, StelUtils::ra dToDmsStr(separation));
} }
} }
QMap<double, double> AstroCalcDialog::findClosestApproach(PlanetP &object1, PlanetP &object2, double startJD, double stopJD, double maxSeparation, boo l opposition) QMap<double, double> AstroCalcDialog::findClosestApproach(PlanetP &object1, PlanetP &object2, double startJD, double stopJD, double maxSeparation, boo l opposition)
skipping to change at line 1140 skipping to change at line 2154
} }
return separations; return separations;
} }
bool AstroCalcDialog::findPrecise(QPair<double, double> *out, PlanetP objec t1, PlanetP object2, double JD, double step, int prevSign, bool opposition) bool AstroCalcDialog::findPrecise(QPair<double, double> *out, PlanetP objec t1, PlanetP object2, double JD, double step, int prevSign, bool opposition)
{ {
int sgn; int sgn;
double dist, prevDist; double dist, prevDist;
if (out==NULL) if (out==Q_NULLPTR)
return false; return false;
prevDist = findDistance(JD, object1, object2, opposition); prevDist = findDistance(JD, object1, object2, opposition);
step = -step/2.f; step = -step/2.f;
prevSign = -prevSign; prevSign = -prevSign;
while(true) while(true)
{ {
JD += step; JD += step;
dist = findDistance(JD, object1, object2, opposition); dist = findDistance(JD, object1, object2, opposition);
skipping to change at line 1201 skipping to change at line 2215
QString phenomenType = q_("Conjunction"); QString phenomenType = q_("Conjunction");
double separation = it.value(); double separation = it.value();
bool occultation = false; bool occultation = false;
if (separation<(object2->getAngularSize(core)*M_PI/180.) || separation<(object1->getSpheroidAngularSize(core)*M_PI/180.)) if (separation<(object2->getAngularSize(core)*M_PI/180.) || separation<(object1->getSpheroidAngularSize(core)*M_PI/180.))
{ {
phenomenType = q_("Occultation"); phenomenType = q_("Occultation");
occultation = true; occultation = true;
} }
ACTreeWidgetItem *treeItem = new ACTreeWidgetItem(ui->phenom enaTreeWidget); ACPhenTreeWidgetItem *treeItem = new ACPhenTreeWidgetItem(ui ->phenomenaTreeWidget);
treeItem->setText(PhenomenaType, phenomenType); treeItem->setText(PhenomenaType, phenomenType);
// local date and time // local date and time
treeItem->setText(PhenomenaDate, StelUtils::jdToQDateTime(it .key() + core->getUTCOffset(it.key())/24).toString("yyyy-MM-dd hh:mm:ss")); treeItem->setText(PhenomenaDate, StelUtils::jdToQDateTime(it .key() + core->getUTCOffset(it.key())/24).toString("yyyy-MM-dd hh:mm:ss"));
treeItem->setText(PhenomenaObject1, object1->getNameI18n()); treeItem->setText(PhenomenaObject1, object1->getNameI18n());
if (!object2->getNameI18n().isEmpty()) if (!object2->getNameI18n().isEmpty())
treeItem->setText(PhenomenaObject2, object2->getName I18n()); treeItem->setText(PhenomenaObject2, object2->getName I18n());
else else
treeItem->setText(PhenomenaObject2, object2->getDSOD esignation()); treeItem->setText(PhenomenaObject2, object2->getDSOD esignation());
if (occultation) if (occultation)
treeItem->setText(PhenomenaSeparation, QChar(0x2014) ); treeItem->setText(PhenomenaSeparation, QChar(0x2014) );
skipping to change at line 1301 skipping to change at line 2315
} }
return separations; return separations;
} }
bool AstroCalcDialog::findPrecise(QPair<double, double> *out, PlanetP objec t1, NebulaP object2, double JD, double step, int prevSign) bool AstroCalcDialog::findPrecise(QPair<double, double> *out, PlanetP objec t1, NebulaP object2, double JD, double step, int prevSign)
{ {
int sgn; int sgn;
double dist, prevDist; double dist, prevDist;
if (out==NULL) if (out==Q_NULLPTR)
return false; return false;
prevDist = findDistance(JD, object1, object2); prevDist = findDistance(JD, object1, object2);
step = -step/2.f; step = -step/2.f;
prevSign = -prevSign; prevSign = -prevSign;
while(true) while(true)
{ {
JD += step; JD += step;
dist = findDistance(JD, object1, object2); dist = findDistance(JD, object1, object2);
skipping to change at line 1359 skipping to change at line 2373
QString phenomenType = q_("Conjunction"); QString phenomenType = q_("Conjunction");
double separation = it.value(); double separation = it.value();
bool occultation = false; bool occultation = false;
if (separation<(object2->getAngularSize(core)*M_PI/180.) || separation<(object1->getSpheroidAngularSize(core)*M_PI/180.)) if (separation<(object2->getAngularSize(core)*M_PI/180.) || separation<(object1->getSpheroidAngularSize(core)*M_PI/180.))
{ {
phenomenType = q_("Occultation"); phenomenType = q_("Occultation");
occultation = true; occultation = true;
} }
ACTreeWidgetItem *treeItem = new ACTreeWidgetItem(ui->phenom enaTreeWidget); ACPhenTreeWidgetItem *treeItem = new ACPhenTreeWidgetItem(ui ->phenomenaTreeWidget);
treeItem->setText(PhenomenaType, phenomenType); treeItem->setText(PhenomenaType, phenomenType);
// local date and time // local date and time
treeItem->setText(PhenomenaDate, StelUtils::jdToQDateTime(it .key() + core->getUTCOffset(it.key())/24).toString("yyyy-MM-dd hh:mm:ss")); treeItem->setText(PhenomenaDate, QString("%1 %2").arg(locale Mgr->getPrintableDateLocal(it.key()), localeMgr->getPrintableTimeLocal(it.k ey())));
treeItem->setText(PhenomenaObject1, object1->getNameI18n()); treeItem->setText(PhenomenaObject1, object1->getNameI18n());
treeItem->setText(PhenomenaObject2, object2->getNameI18n()); treeItem->setText(PhenomenaObject2, object2->getNameI18n());
if (occultation) if (occultation)
treeItem->setText(PhenomenaSeparation, QChar(0x2014) ); treeItem->setText(PhenomenaSeparation, QChar(0x2014) );
else else
treeItem->setText(PhenomenaSeparation, StelUtils::ra dToDmsStr(separation)); treeItem->setText(PhenomenaSeparation, StelUtils::ra dToDmsStr(separation));
} }
} }
QMap<double, double> AstroCalcDialog::findClosestApproach(PlanetP &object1, StelObjectP &object2, double startJD, double stopJD, double maxSeparation) QMap<double, double> AstroCalcDialog::findClosestApproach(PlanetP &object1, StelObjectP &object2, double startJD, double stopJD, double maxSeparation)
skipping to change at line 1456 skipping to change at line 2470
} }
return separations; return separations;
} }
bool AstroCalcDialog::findPrecise(QPair<double, double> *out, PlanetP objec t1, StelObjectP object2, double JD, double step, int prevSign) bool AstroCalcDialog::findPrecise(QPair<double, double> *out, PlanetP objec t1, StelObjectP object2, double JD, double step, int prevSign)
{ {
int sgn; int sgn;
double dist, prevDist; double dist, prevDist;
if (out==NULL) if (out==Q_NULLPTR)
return false; return false;
prevDist = findDistance(JD, object1, object2); prevDist = findDistance(JD, object1, object2);
step = -step/2.f; step = -step/2.f;
prevSign = -prevSign; prevSign = -prevSign;
while(true) while(true)
{ {
JD += step; JD += step;
dist = findDistance(JD, object1, object2); dist = findDistance(JD, object1, object2);
skipping to change at line 1502 skipping to change at line 2516
Vec3d obj1 = object1->getJ2000EquatorialPos(core); Vec3d obj1 = object1->getJ2000EquatorialPos(core);
Vec3d obj2 = object2->getJ2000EquatorialPos(core); Vec3d obj2 = object2->getJ2000EquatorialPos(core);
return obj1.angle(obj2); return obj1.angle(obj2);
} }
void AstroCalcDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous) void AstroCalcDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous)
{ {
if (!current) if (!current)
current = previous; current = previous;
ui->stackedWidget->setCurrentIndex(ui->stackListWidget->row(current) ); ui->stackedWidget->setCurrentIndex(ui->stackListWidget->row(current) );
// special case
if (ui->stackListWidget->row(current)==0)
currentCelestialPositions();
} }
void AstroCalcDialog::updateTabBarListWidgetWidth() void AstroCalcDialog::updateTabBarListWidgetWidth()
{ {
ui->stackListWidget->setWrapping(false); ui->stackListWidget->setWrapping(false);
// Update list item sizes after translation // Update list item sizes after translation
ui->stackListWidget->adjustSize(); ui->stackListWidget->adjustSize();
QAbstractItemModel* model = ui->stackListWidget->model(); QAbstractItemModel* model = ui->stackListWidget->model();
skipping to change at line 1544 skipping to change at line 2562
// Hack to force the window to be resized... // Hack to force the window to be resized...
ui->stackListWidget->setMinimumWidth(width); ui->stackListWidget->setMinimumWidth(width);
} }
void AstroCalcDialog::updateSolarSystemData() void AstroCalcDialog::updateSolarSystemData()
{ {
if (dialog) if (dialog)
{ {
populateCelestialBodyList(); populateCelestialBodyList();
populateGroupCelestialBodyList(); populateGroupCelestialBodyList();
currentPlanetaryPositions(); currentCelestialPositions();
calculateWutObjects();
}
}
void AstroCalcDialog::populateTimeIntervalsList()
{
Q_ASSERT(ui->wutComboBox);
QComboBox* wut = ui->wutComboBox;
wut->blockSignals(true);
int index = wut->currentIndex();
QVariant selectedIntervalId = wut->itemData(index);
wut->clear();
wut->addItem(qc_("In the Evening", "Celestial object is observed..."
), "0");
wut->addItem(qc_("In the Morning", "Celestial object is observed..."
), "1");
wut->addItem(qc_("Around Midnight", "Celestial object is observed...
"), "2");
wut->addItem(qc_("In Any Time of the Night", "Celestial object is ob
served..."), "3");
index = wut->findData(selectedIntervalId, Qt::UserRole, Qt::MatchCas
eSensitive);
if (index<0)
index = wut->findData(conf->value("astrocalc/wut_time_interv
al", "0").toString(), Qt::UserRole, Qt::MatchCaseSensitive);
wut->setCurrentIndex(index);
wut->model()->sort(0);
wut->blockSignals(false);
}
void AstroCalcDialog::populateWutGroups()
{
Q_ASSERT(ui->wutCategoryListWidget);
QListWidget* category = ui->wutCategoryListWidget;
category->blockSignals(true);
wutCategories.clear();
wutCategories.insert(q_("Planets"), 0);
wutCategories.insert(q_("Bright stars"), 1);
wutCategories.insert(q_("Bright nebulae"), 2);
wutCategories.insert(q_("Dark nebulae"), 3);
wutCategories.insert(q_("Galaxies"), 4);
wutCategories.insert(q_("Star clusters"), 5);
wutCategories.insert(q_("Asteroids"), 6);
wutCategories.insert(q_("Comets"), 7);
wutCategories.insert(q_("Plutinos"), 8);
wutCategories.insert(q_("Dwarf planets"), 9);
wutCategories.insert(q_("Cubewanos"), 10);
wutCategories.insert(q_("Scattered disc objects"), 11);
wutCategories.insert(q_("Oort cloud objects"), 12);
wutCategories.insert(q_("Sednoids"), 13);
wutCategories.insert(q_("Planetary nebulae"), 14);
wutCategories.insert(q_("Bright double stars"), 15);
wutCategories.insert(q_("Bright variable stars"), 16);
wutCategories.insert(q_("Bright stars with high proper motion"), 17)
;
category->clear();
category->addItems(wutCategories.keys());
category->sortItems(Qt::AscendingOrder);
category->blockSignals(false);
}
void AstroCalcDialog::saveWutMagnitudeLimit(double mag)
{
conf->setValue("astrocalc/wut_magnitude_limit", QString::number(mag,
'f', 2));
calculateWutObjects();
}
void AstroCalcDialog::saveWutTimeInterval(int index)
{
Q_ASSERT(ui->wutComboBox);
QComboBox* wutTimeInterval = ui->wutComboBox;
conf->setValue("astrocalc/wut_time_interval", wutTimeInterval->itemD
ata(index).toInt());
// Calculate WUT objects!
calculateWutObjects();
}
void AstroCalcDialog::calculateWutObjects()
{
ui->wutMatchingObjectsListWidget->clear();
if (ui->wutCategoryListWidget->currentItem())
{
QString categoryName = ui->wutCategoryListWidget->currentIte
m()->text();
int categoryId = wutCategories.value(categoryName);
wutObjects.clear();
QList<PlanetP> allObjects = solarSystem->getAllPlanets();
QVector<NebulaP> allDSO = dsoMgr->getAllDeepSkyObjects();
QList<StelObjectP> hipStars = starMgr->getHipparcosStars();
QList<StelACStarData> dblHipStars = starMgr->getHipparcosDou
bleStars();
QList<StelACStarData> varHipStars = starMgr->getHipparcosVar
iableStars();
QList<StelACStarData> hpmHipStars = starMgr->getHipparcosHig
hPMStars();
const Nebula::TypeGroup& tflags = dsoMgr->getTypeFilters();
double magLimit = ui->wutMagnitudeDoubleSpinBox->value();
double JD = core->getJD();
double wutJD = (int)JD;
double az, alt;
// Dirty hack to calculate sunrise/sunset
// FIXME: This block of code should be replaced in future!
PlanetP sun = GETSTELMODULE(SolarSystem)->getSun();
double sunset = -1, sunrise = -1, midnight = -1, lc = 100.0;
bool flag = false;
for (int i=0; i<288; i++) // Check position every 5 minutes.
..
{
wutJD = (int)JD + i*0.0034722;
core->setJD(wutJD);
core->update(0);
StelUtils::rectToSphe(&az, &alt, sun->getAltAzPosAut
o(core));
alt = std::fmod(alt,2.0*M_PI)*180./M_PI;
if (alt>=-7 && alt<=-5 && !flag)
{
sunset = wutJD;
flag = true;
}
if (alt>=-7 && alt<=-5 && flag)
sunrise = wutJD;
if (alt<lc)
{
midnight = wutJD;
lc = alt;
}
}
core->setJD(JD);
QList<double> wutJDList;
wutJDList.clear();
QComboBox* wut = ui->wutComboBox;
switch (wut->itemData(wut->currentIndex()).toInt())
{
case 1: // Morning
wutJDList << sunrise;
break;
case 2: // Night
wutJDList << midnight;
break;
case 3:
wutJDList << sunrise << midnight << sunset;
break;
default: // Evening
wutJDList << sunset;
break;
}
for (int i=0; i<wutJDList.count(); i++)
{
core->setJD(wutJDList.at(i));
core->update(0);
switch (categoryId)
{
case 1: // Bright stars
foreach(const StelObjectP& object, h
ipStars)
{
if (object->getVMagnitudeWit
hExtinction(core)<=magLimit && object->isAboveRealHorizon(core))
wutObjects.insert(ob
ject->getNameI18n(), object->getEnglishName());
}
break;
case 2: // Bright nebulae
foreach(const NebulaP& object, allDS
O)
{
Nebula::NebulaType ntype = o
bject->getDSOType();
if ((bool)(tflags & Nebula::
TypeBrightNebulae) && (ntype==Nebula::NebN || ntype==Nebula::NebBn || ntype
==Nebula::NebEn || ntype==Nebula::NebRn || ntype==Nebula::NebHII || ntype==
Nebula::NebISM || ntype==Nebula::NebCn || ntype==Nebula::NebSNR) && object-
>getVMagnitudeWithExtinction(core)<=magLimit && object->isAboveRealHorizon(
core))
{
QString d = object->
getDSODesignation();
QString n = object->
getNameI18n();
if (d.isEmpty() && n
.isEmpty())
continue;
if (d.isEmpty())
wutObjects.i
nsert(n, n);
else if (n.isEmpty()
)
wutObjects.i
nsert(d, d);
else
wutObjects.i
nsert(QString("%1 (%2)").arg(d, n), d);
}
}
break;
case 3: // Dark nebulae
foreach(const NebulaP& object, allDS
O)
{
Nebula::NebulaType ntype = o
bject->getDSOType();
if ((bool)(tflags & Nebula::
TypeDarkNebulae) && (ntype==Nebula::NebDn || ntype==Nebula::NebMolCld || nt
ype==Nebula::NebYSO) && object->isAboveRealHorizon(core))
{
QString d = object->
getDSODesignation();
QString n = object->
getNameI18n();
if (d.isEmpty() && n
.isEmpty())
continue;
if (d.isEmpty())
wutObjects.i
nsert(n, n);
else if (n.isEmpty()
)
wutObjects.i
nsert(d, d);
else
wutObjects.i
nsert(QString("%1 (%2)").arg(d, n), d);
}
}
break;
case 4: // Galaxies
foreach(const NebulaP& object, allDS
O)
{
Nebula::NebulaType ntype = o
bject->getDSOType();
if ((bool)(tflags & Nebula::
TypeGalaxies) && (ntype==Nebula::NebGx || ntype==Nebula::NebAGx || ntype==N
ebula::NebRGx || ntype==Nebula::NebQSO || ntype==Nebula::NebPossQSO || ntyp
e==Nebula::NebBLL || ntype==Nebula::NebBLA || ntype==Nebula::NebIGx) && obj
ect->getVMagnitudeWithExtinction(core)<=magLimit && object->isAboveRealHori
zon(core))
{
QString d = object->
getDSODesignation();
QString n = object->
getNameI18n();
if (d.isEmpty() && n
.isEmpty())
continue;
if (d.isEmpty())
wutObjects.i
nsert(n, n);
else if (n.isEmpty()
)
wutObjects.i
nsert(d, d);
else
wutObjects.i
nsert(QString("%1 (%2)").arg(d, n), d);
}
}
break;
case 5: // Star clusters
foreach(const NebulaP& object, allDS
O)
{
Nebula::NebulaType ntype = o
bject->getDSOType();
if ((bool)(tflags & Nebula::
TypeStarClusters) && (ntype==Nebula::NebCl || ntype==Nebula::NebOc || ntype
==Nebula::NebGc || ntype==Nebula::NebSA || ntype==Nebula::NebSC || ntype==N
ebula::NebCn) && object->getVMagnitudeWithExtinction(core)<=magLimit && obj
ect->isAboveRealHorizon(core))
{
QString d = object->
getDSODesignation();
QString n = object->
getNameI18n();
if (d.isEmpty() && n
.isEmpty())
continue;
if (d.isEmpty())
wutObjects.i
nsert(n, n);
else if (n.isEmpty()
)
wutObjects.i
nsert(d, d);
else
wutObjects.i
nsert(QString("%1 (%2)").arg(d, n), d);
}
}
break;
case 6: // Asteroids
foreach(const PlanetP& object, allOb
jects)
{
if (object->getPlanetType()=
=Planet::isAsteroid && object->getVMagnitudeWithExtinction(core)<=magLimit
&& object->isAboveRealHorizon(core))
wutObjects.insert(ob
ject->getNameI18n(), object->getEnglishName());
}
break;
case 7: // Comets
foreach(const PlanetP& object, allOb
jects)
{
if (object->getPlanetType()=
=Planet::isComet && object->getVMagnitudeWithExtinction(core)<=magLimit &&
object->isAboveRealHorizon(core))
wutObjects.insert(ob
ject->getNameI18n(), object->getEnglishName());
}
break;
case 8: // Plutinos
foreach(const PlanetP& object, allOb
jects)
{
if (object->getPlanetType()=
=Planet::isPlutino && object->getVMagnitudeWithExtinction(core)<=magLimit &
& object->isAboveRealHorizon(core))
wutObjects.insert(ob
ject->getNameI18n(), object->getEnglishName());
}
break;
case 9: // Dwarf planets
foreach(const PlanetP& object, allOb
jects)
{
if (object->getPlanetType()=
=Planet::isDwarfPlanet && object->getVMagnitudeWithExtinction(core)<=magLim
it && object->isAboveRealHorizon(core))
wutObjects.insert(ob
ject->getNameI18n(), object->getEnglishName());
}
break;
case 10: // Cubewanos
foreach(const PlanetP& object, allOb
jects)
{
if (object->getPlanetType()=
=Planet::isCubewano && object->getVMagnitudeWithExtinction(core)<=magLimit
&& object->isAboveRealHorizon(core))
wutObjects.insert(ob
ject->getNameI18n(), object->getEnglishName());
}
break;
case 11: // Scattered disc objects
foreach(const PlanetP& object, allOb
jects)
{
if (object->getPlanetType()=
=Planet::isSDO && object->getVMagnitudeWithExtinction(core)<=magLimit && ob
ject->isAboveRealHorizon(core))
wutObjects.insert(ob
ject->getNameI18n(), object->getEnglishName());
}
break;
case 12: // Oort cloud objects
foreach(const PlanetP& object, allOb
jects)
{
if (object->getPlanetType()=
=Planet::isOCO && object->getVMagnitudeWithExtinction(core)<=magLimit && ob
ject->isAboveRealHorizon(core))
wutObjects.insert(ob
ject->getNameI18n(), object->getEnglishName());
}
break;
case 13: // Sednoids
foreach(const PlanetP& object, allOb
jects)
{
if (object->getPlanetType()=
=Planet::isSednoid && object->getVMagnitudeWithExtinction(core)<=magLimit &
& object->isAboveRealHorizon(core))
wutObjects.insert(ob
ject->getNameI18n(), object->getEnglishName());
}
break;
case 14: // Planetary nebulae
foreach(const NebulaP& object, allDS
O)
{
Nebula::NebulaType ntype = o
bject->getDSOType();
if ((bool)(tflags & Nebula::
TypePlanetaryNebulae) && (ntype==Nebula::NebPn || ntype==Nebula::NebPossPN
|| ntype==Nebula::NebPPN) && object->getVMagnitudeWithExtinction(core)<=mag
Limit && object->isAboveRealHorizon(core))
{
QString d = object->
getDSODesignation();
QString n = object->
getNameI18n();
if (d.isEmpty() && n
.isEmpty())
continue;
if (d.isEmpty())
wutObjects.i
nsert(n, n);
else if (n.isEmpty()
)
wutObjects.i
nsert(d, d);
else
wutObjects.i
nsert(QString("%1 (%2)").arg(d, n), d);
}
}
break;
case 15: // Bright double stars
foreach(const StelACStarData& dblSta
r, dblHipStars)
{
StelObjectP object = dblStar
.firstKey();
if (object->getVMagnitudeWit
hExtinction(core)<=magLimit && object->isAboveRealHorizon(core))
wutObjects.insert(ob
ject->getNameI18n(), object->getEnglishName());
}
break;
case 16: // Bright variale stars
foreach(const StelACStarData& varSta
r, varHipStars)
{
StelObjectP object = varStar
.firstKey();
if (object->getVMagnitudeWit
hExtinction(core)<=magLimit && object->isAboveRealHorizon(core))
wutObjects.insert(ob
ject->getNameI18n(), object->getEnglishName());
}
break;
case 17: // Bright stars with high proper mo
tion
foreach(const StelACStarData& hpmSta
r, hpmHipStars)
{
StelObjectP object = hpmStar
.firstKey();
if (object->getVMagnitudeWit
hExtinction(core)<=magLimit && object->isAboveRealHorizon(core))
wutObjects.insert(ob
ject->getNameI18n(), object->getEnglishName());
}
break;
default: // Planets
foreach(const PlanetP& object, allOb
jects)
{
if (object->getPlanetType()=
=Planet::isPlanet && object->getVMagnitudeWithExtinction(core)<=magLimit &&
object->isAboveRealHorizon(core))
wutObjects.insert(ob
ject->getNameI18n(), object->getEnglishName());
}
break;
}
}
core->setJD(JD);
ui->wutMatchingObjectsListWidget->blockSignals(true);
ui->wutMatchingObjectsListWidget->clear();
ui->wutMatchingObjectsListWidget->addItems(wutObjects.keys()
);
ui->wutMatchingObjectsListWidget->sortItems(Qt::AscendingOrd
er);
ui->wutMatchingObjectsListWidget->blockSignals(false);
}
}
void AstroCalcDialog::selectWutObject()
{
if(ui->wutMatchingObjectsListWidget->currentItem())
{
QString wutObjectEnglisName = wutObjects.value(ui->wutMatchi
ngObjectsListWidget->currentItem()->text());
if (objectMgr->findAndSelectI18n(wutObjectEnglisName) || obj
ectMgr->findAndSelect(wutObjectEnglisName))
{
const QList<StelObjectP> newSelected = objectMgr->ge
tSelectedObject();
if (!newSelected.empty())
{
// Can't point to home planet
if (newSelected[0]->getEnglishName()!=core->
getCurrentLocation().planetName)
{
StelMovementMgr* mvmgr = GETSTELMODU
LE(StelMovementMgr);
mvmgr->moveToObject(newSelected[0],
mvmgr->getAutoMoveDuration());
mvmgr->setFlagTracking(true);
}
else
{
GETSTELMODULE(StelObjectMgr)->unSele
ct();
}
}
}
} }
} }
 End of changes. 123 change blocks. 
184 lines changed or deleted 1910 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/