AstroCalcDialog.cpp   AstroCalcDialog.cpp 
/* /*
* Stellarium * Stellarium
* Copyright (C) 2015 Alexander Wolf * Copyright (C) 2015 Alexander Wolf
* Copyright (C) 2016 Nick Fedoseev (visualization of ephemeris)
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
skipping to change at line 27 skipping to change at line 28
*/ */
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelMovementMgr.hpp" #include "StelMovementMgr.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelFileMgr.hpp"
#include "SolarSystem.hpp" #include "SolarSystem.hpp"
#include "Planet.hpp" #include "Planet.hpp"
#include "AstroCalcDialog.hpp" #include "AstroCalcDialog.hpp"
#include "ui_astroCalcDialog.h" #include "ui_astroCalcDialog.h"
#include <QTimer> #include <QFileDialog>
QVector<Vec3d> AstroCalcDialog::EphemerisListJ2000;
QVector<QString> AstroCalcDialog::EphemerisListDates;
int AstroCalcDialog::DisplayedPositionIndex = -1;
AstroCalcDialog::AstroCalcDialog(QObject *parent) AstroCalcDialog::AstroCalcDialog(QObject *parent)
: StelDialog(parent) : StelDialog(parent)
, delimiter(", ")
{ {
dialogName = "AstroCalc";
ui = new Ui_astroCalcDialogForm; ui = new Ui_astroCalcDialogForm;
core = StelApp::getInstance().getCore(); core = StelApp::getInstance().getCore();
solarSystem = GETSTELMODULE(SolarSystem); solarSystem = GETSTELMODULE(SolarSystem);
objectMgr = GETSTELMODULE(StelObjectMgr); objectMgr = GETSTELMODULE(StelObjectMgr);
ephemerisHeader.clear();
phenomenaHeader.clear();
planetaryPositionsHeader.clear();
} }
AstroCalcDialog::~AstroCalcDialog() AstroCalcDialog::~AstroCalcDialog()
{ {
delete ui; delete ui;
} }
void AstroCalcDialog::retranslate() void AstroCalcDialog::retranslate()
{ {
if (dialog) if (dialog)
skipping to change at line 80 skipping to change at line 91
#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->planetaryPositionsTreeWidget;
installKineticScrolling(addscroll); installKineticScrolling(addscroll);
#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()));
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)));
initListPlanetaryPositions(); initListPlanetaryPositions();
initListEphemeris(); initListEphemeris();
initListPhenomena(); initListPhenomena();
populateCelestialBodyList(); populateCelestialBodyList();
populateEphemerisTimeStepsList(); populateEphemerisTimeStepsList();
populateMajorPlanetList(); populateMajorPlanetList();
populateGroupCelestialBodyList(); populateGroupCelestialBodyList();
double JD = core->getJD() + StelUtils::getGMTShiftFromQT(core->getJD ())/24; double JD = core->getJD() + StelUtils::getGMTShiftFromQT(core->getJD ())/24;
ui->dateFromDateTimeEdit->setDateTime(StelUtils::jdToQDateTime(JD)); ui->dateFromDateTimeEdit->setDateTime(StelUtils::jdToQDateTime(JD));
ui->dateToDateTimeEdit->setDateTime(StelUtils::jdToQDateTime(JD + 30 .f)); ui->dateToDateTimeEdit->setDateTime(StelUtils::jdToQDateTime(JD + 30 .f));
ui->phenomenFromDateEdit->setDateTime(StelUtils::jdToQDateTime(JD)); ui->phenomenFromDateEdit->setDateTime(StelUtils::jdToQDateTime(JD));
ui->phenomenToDateEdit->setDateTime(StelUtils::jdToQDateTime(JD + 36 5.f)); ui->phenomenToDateEdit->setDateTime(StelUtils::jdToQDateTime(JD + 36 5.f));
// bug #1350669 (https://bugs.launchpad.net/stellarium/+bug/1350669) // bug #1350669 (https://bugs.launchpad.net/stellarium/+bug/1350669)
connect(ui->planetaryPositionsTreeWidget, SIGNAL(currentItemChanged( QTreeWidgetItem*,QTreeWidgetItem*)), connect(ui->planetaryPositionsTreeWidget, SIGNAL(currentItemChanged( QTreeWidgetItem*,QTreeWidgetItem*)),
ui->planetaryPositionsTreeWidget, SLOT(repaint())); ui->planetaryPositionsTreeWidget, SLOT(repaint()));
connect(ui->planetaryPositionsTreeWidget, SIGNAL(doubleClicked(QMode lIndex)), this, SLOT(selectCurrentPlanetaryPosition(QModelIndex))); connect(ui->planetaryPositionsTreeWidget, SIGNAL(doubleClicked(QMode lIndex)), this, SLOT(selectCurrentPlanetaryPosition(QModelIndex)));
connect(ui->planetaryPositionsUpdateButton, SIGNAL(clicked()), this, SLOT(currentPlanetaryPositions()));
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->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->phenomenaPushButton, SIGNAL(clicked()), this, SLOT(calcu latePhenomena())); connect(ui->phenomenaPushButton, SIGNAL(clicked()), this, SLOT(calcu latePhenomena()));
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()));
connectBoolProperty(ui->ephemerisShowMarkersCheckBox, "SolarSystem.e
phemerisMarkersDisplayed");
connectBoolProperty(ui->ephemerisShowDatesCheckBox, "SolarSystem.eph
emerisDatesDisplayed");
// every 5 min, check if it's time to update
QTimer* updateTimer = new QTimer(this);
updateTimer->setInterval(300000);
connect(updateTimer, SIGNAL(timeout()), this, SLOT(currentPlanetaryP
ositions()));
updateTimer->start();
currentPlanetaryPositions(); currentPlanetaryPositions();
} }
void AstroCalcDialog::initListPlanetaryPositions() void AstroCalcDialog::initListPlanetaryPositions()
{ {
ui->planetaryPositionsTreeWidget->clear(); ui->planetaryPositionsTreeWidget->clear();
ui->planetaryPositionsTreeWidget->setColumnCount(ColumnCount); ui->planetaryPositionsTreeWidget->setColumnCount(ColumnCount);
setPlanetaryPositionsHeaderNames(); setPlanetaryPositionsHeaderNames();
ui->planetaryPositionsTreeWidget->header()->setSectionsMovable(false ); ui->planetaryPositionsTreeWidget->header()->setSectionsMovable(false );
} }
void AstroCalcDialog::setPlanetaryPositionsHeaderNames() void AstroCalcDialog::setPlanetaryPositionsHeaderNames()
{ {
QStringList headerStrings; planetaryPositionsHeader.clear();
//TRANSLATORS: name of object //TRANSLATORS: name of object
headerStrings << q_("Name"); planetaryPositionsHeader << q_("Name");
//TRANSLATORS: right ascension //TRANSLATORS: right ascension
headerStrings << q_("RA (J2000)"); planetaryPositionsHeader << q_("RA (J2000)");
//TRANSLATORS: declination //TRANSLATORS: declination
headerStrings << q_("Dec (J2000)"); planetaryPositionsHeader << q_("Dec (J2000)");
//TRANSLATORS: magnitude //TRANSLATORS: magnitude
headerStrings << q_("Mag."); planetaryPositionsHeader << q_("Mag.");
//TRANSLATORS: type of object //TRANSLATORS: type of object
headerStrings << q_("Type"); planetaryPositionsHeader << q_("Type");
ui->planetaryPositionsTreeWidget->setHeaderLabels(headerStrings); ui->planetaryPositionsTreeWidget->setHeaderLabels(planetaryPositions
Header);
// adjust the column width // adjust the column width
for(int i = 0; i < ColumnCount; ++i) for(int i = 0; i < ColumnCount; ++i)
{ {
ui->planetaryPositionsTreeWidget->resizeColumnToContents(i); ui->planetaryPositionsTreeWidget->resizeColumnToContents(i);
} }
} }
void AstroCalcDialog::currentPlanetaryPositions() void AstroCalcDialog::currentPlanetaryPositions()
{ {
float ra, dec; float ra, dec;
QList<PlanetP> allPlanets = solarSystem->getAllPlanets(); QList<PlanetP> allPlanets = solarSystem->getAllPlanets();
initListPlanetaryPositions(); initListPlanetaryPositions();
double JD = StelApp::getInstance().getCore()->getJD();
ui->positionsTimeLabel->setText(q_("Positions on %1").arg(StelUtils:
:jdToQDateTime(JD + StelUtils::getGMTShiftFromQT(JD)/24).toString("yyyy-MM-
dd hh:mm")));
foreach (const PlanetP& planet, allPlanets) foreach (const PlanetP& planet, allPlanets)
{ {
if (planet->getPlanetType()!=Planet::isUNDEFINED && planet-> getEnglishName()!="Sun" && planet->getEnglishName()!=core->getCurrentPlanet ()->getEnglishName()) if (planet->getPlanetType()!=Planet::isUNDEFINED && planet-> getEnglishName()!="Sun" && planet->getEnglishName()!=core->getCurrentPlanet ()->getEnglishName())
{ {
StelUtils::rectToSphe(&ra,&dec,planet->getJ2000Equat orialPos(core)); StelUtils::rectToSphe(&ra,&dec,planet->getJ2000Equat orialPos(core));
ACTreeWidgetItem *treeItem = new ACTreeWidgetItem(ui ->planetaryPositionsTreeWidget); ACTreeWidgetItem *treeItem = new ACTreeWidgetItem(ui ->planetaryPositionsTreeWidget);
treeItem->setText(ColumnName, planet->getNameI18n()) ; treeItem->setText(ColumnName, planet->getNameI18n()) ;
treeItem->setText(ColumnRA, StelUtils::radToHmsStr(r a)); treeItem->setText(ColumnRA, StelUtils::radToHmsStr(r a));
treeItem->setTextAlignment(ColumnRA, Qt::AlignRight) ; treeItem->setTextAlignment(ColumnRA, Qt::AlignRight) ;
treeItem->setText(ColumnDec, StelUtils::radToDmsStr( dec, true)); treeItem->setText(ColumnDec, StelUtils::radToDmsStr( dec, true));
skipping to change at line 179 skipping to change at line 197
// adjust the column width // adjust the column width
for(int i = 0; i < ColumnCount; ++i) for(int i = 0; i < ColumnCount; ++i)
{ {
ui->planetaryPositionsTreeWidget->resizeColumnToContents(i); ui->planetaryPositionsTreeWidget->resizeColumnToContents(i);
} }
// sort-by-name // sort-by-name
ui->planetaryPositionsTreeWidget->sortItems(ColumnName, Qt::Ascendin gOrder); ui->planetaryPositionsTreeWidget->sortItems(ColumnName, Qt::Ascendin gOrder);
} }
void AstroCalcDialog::onChangedEphemerisPosition(const QModelIndex &modelIn
dex)
{
DisplayedPositionIndex = modelIndex.row();
}
void AstroCalcDialog::selectCurrentPlanetaryPosition(const QModelIndex &mod elIndex) void AstroCalcDialog::selectCurrentPlanetaryPosition(const QModelIndex &mod elIndex)
{ {
// Find the object // Find the object
QString nameI18n = modelIndex.sibling(modelIndex.row(), ColumnName). data().toString(); QString nameI18n = modelIndex.sibling(modelIndex.row(), ColumnName). data().toString();
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())
{ {
skipping to change at line 233 skipping to change at line 256
else else
{ {
GETSTELMODULE(StelObjectMgr)->unSelect(); GETSTELMODULE(StelObjectMgr)->unSelect();
} }
} }
} }
} }
void AstroCalcDialog::setEphemerisHeaderNames() void AstroCalcDialog::setEphemerisHeaderNames()
{ {
QStringList headerStrings; ephemerisHeader.clear();
//TRANSLATORS: name of object ephemerisHeader << q_("Date and Time");
headerStrings << q_("Date and Time"); ephemerisHeader << q_("Julian Day");
headerStrings << q_("JD");
//TRANSLATORS: right ascension //TRANSLATORS: right ascension
headerStrings << q_("RA (J2000)"); ephemerisHeader << q_("RA (J2000)");
//TRANSLATORS: declination //TRANSLATORS: declination
headerStrings << q_("Dec (J2000)"); ephemerisHeader << q_("Dec (J2000)");
//TRANSLATORS: magnitude //TRANSLATORS: magnitude
headerStrings << q_("Mag."); ephemerisHeader << q_("Mag.");
ui->ephemerisTreeWidget->setHeaderLabels(headerStrings); 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()
{ {
skipping to change at line 278 skipping to change at line 300
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 = StelCore::JD_HOUR;
break; break;
case 3: case 3:
currentStep = StelCore::JD_DAY; currentStep = StelCore::JD_DAY;
break; break;
case 4: case 4:
currentStep = 10 * StelCore::JD_DAY; currentStep = 5 * StelCore::JD_DAY;
break; break;
case 5: case 5:
currentStep = 10 * StelCore::JD_DAY;
break;
case 6:
currentStep = 15 * StelCore::JD_DAY;
break;
case 7:
currentStep = 30 * StelCore::JD_DAY; currentStep = 30 * StelCore::JD_DAY;
break; break;
case 8:
currentStep = 60 * StelCore::JD_DAY;
break;
default: default:
currentStep = StelCore::JD_DAY; currentStep = StelCore::JD_DAY;
break; break;
} }
StelObjectP obj = solarSystem->searchByName(currentPlanet); StelObjectP obj = solarSystem->searchByName(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 - StelUtils::getGMTShiftFromQT(firstJD)/24 ; firstJD = firstJD - StelUtils::getGMTShiftFromQT(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();
EphemerisListJ2000.reserve(elements);
EphemerisListDates.clear();
EphemerisListDates.reserve(elements);
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
StelUtils::rectToSphe(&ra,&dec,obj->getJ2000Equatori Vec3d pos = obj->getJ2000EquatorialPos(core);
alPos(core)); EphemerisListJ2000.append(pos);
EphemerisListDates.append(StelUtils::jdToQDateTime(J
D + StelUtils::getGMTShiftFromQT(JD)/24).toString("yyyy-MM-dd"));
StelUtils::rectToSphe(&ra,&dec,pos);
ACTreeWidgetItem *treeItem = new ACTreeWidgetItem(ui ->ephemerisTreeWidget); ACTreeWidgetItem *treeItem = new ACTreeWidgetItem(ui ->ephemerisTreeWidget);
// local date and time // local date and time
treeItem->setText(EphemerisDate, StelUtils::jdToQDat eTime(JD + StelUtils::getGMTShiftFromQT(JD)/24).toString("yyyy-MM-dd hh:mm: ss")); treeItem->setText(EphemerisDate, StelUtils::jdToQDat eTime(JD + StelUtils::getGMTShiftFromQT(JD)/24).toString("yyyy-MM-dd hh:mm: ss"));
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, StelUtils::radToHmsSt r(ra));
treeItem->setTextAlignment(EphemerisRA, Qt::AlignRig ht); treeItem->setTextAlignment(EphemerisRA, Qt::AlignRig ht);
treeItem->setText(EphemerisDec, StelUtils::radToDmsS tr(dec, true)); treeItem->setText(EphemerisDec, StelUtils::radToDmsS tr(dec, true));
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);
skipping to change at line 325 skipping to change at line 363
// 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);
} }
// sort-by-date // sort-by-date
ui->ephemerisTreeWidget->sortItems(EphemerisDate, Qt::AscendingOrder ); ui->ephemerisTreeWidget->sortItems(EphemerisDate, Qt::AscendingOrder );
} }
void AstroCalcDialog::saveEphemeris()
{
QString filter = q_("CSV (Comma delimited)");
filter.append(" (*.csv)");
QString filePath = QFileDialog::getSaveFileName(0, q_("Save calculat
ed ephemerides as..."), StelFileMgr::getScreenshotDir(), filter);
QFile ephem(filePath);
if (!ephem.open(QFile::WriteOnly | QFile::Truncate))
{
qWarning() << "AstroCalc: Unable to open file"
<< QDir::toNativeSeparators(filePath);
return;
}
QTextStream ephemList(&ephem);
ephemList.setCodec("UTF-8");
int count = ui->ephemerisTreeWidget->topLevelItemCount();
ephemList << ephemerisHeader.join(delimiter) << endl;
for (int i = 0; i < count; i++)
{
int columns = ephemerisHeader.size();
for (int j=0; j<columns; j++)
{
ephemList << ui->ephemerisTreeWidget->topLevelItem(i
)->text(j);
if (j<columns-1)
ephemList << delimiter;
else
ephemList << endl;
}
}
ephem.close();
}
void AstroCalcDialog::cleanupEphemeris()
{
EphemerisListJ2000.clear();
ui->ephemerisTreeWidget->clear();
}
void AstroCalcDialog::populateCelestialBodyList() void AstroCalcDialog::populateCelestialBodyList()
{ {
Q_ASSERT(ui->celestialBodyComboBox); Q_ASSERT(ui->celestialBodyComboBox);
QComboBox* planets = ui->celestialBodyComboBox; QComboBox* planets = ui->celestialBodyComboBox;
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);
skipping to change at line 367 skipping to change at line 446
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_("1 hour"), "2");
steps->addItem(q_("1 day"), "3"); steps->addItem(q_("1 day"), "3");
steps->addItem(q_("10 days"), "4"); steps->addItem(q_("5 days"), "4");
steps->addItem(q_("30 days"), "5"); steps->addItem(q_("10 days"), "5");
steps->addItem(q_("15 days"), "6");
steps->addItem(q_("30 days"), "7");
steps->addItem(q_("60 days"), "8");
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; index = 2;
steps->setCurrentIndex(index); steps->setCurrentIndex(index);
steps->blockSignals(false); steps->blockSignals(false);
} }
void AstroCalcDialog::populateMajorPlanetList() void AstroCalcDialog::populateMajorPlanetList()
{ {
skipping to change at line 394 skipping to change at line 476
//Save the current selection to be restored later //Save the current selection to be restored later
majorPlanet->blockSignals(true); majorPlanet->blockSignals(true);
int index = majorPlanet->currentIndex(); int index = majorPlanet->currentIndex();
QVariant selectedPlanetId = majorPlanet->itemData(index); QVariant selectedPlanetId = majorPlanet->itemData(index);
majorPlanet->clear(); majorPlanet->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 PlanetP& planet, planets) foreach(const PlanetP& planet, planets)
{ {
if (planet->getPlanetType()==Planet::isPlanet && planet->get // major planets and the Sun
EnglishName()!=core->getCurrentPlanet()->getEnglishName()) if ((planet->getPlanetType()==Planet::isPlanet || planet->ge
tPlanetType()==Planet::isStar) && planet->getEnglishName()!=core->getCurren
tPlanet()->getEnglishName())
majorPlanet->addItem(trans.qtranslate(planet->getNam eI18n()), planet->getEnglishName()); majorPlanet->addItem(trans.qtranslate(planet->getNam eI18n()), planet->getEnglishName());
// moons of the current planet
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());
} }
//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("Mercury", Qt::UserRole, Qt::M atchCaseSensitive);; index = majorPlanet->findData("Mercury", Qt::UserRole, Qt::M atchCaseSensitive);;
majorPlanet->setCurrentIndex(index); majorPlanet->setCurrentIndex(index);
majorPlanet->model()->sort(0); majorPlanet->model()->sort(0);
majorPlanet->blockSignals(false); majorPlanet->blockSignals(false);
} }
skipping to change at line 436 skipping to change at line 524
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("1", Qt::UserRole, Qt::MatchCaseSen sitive);
groups->setCurrentIndex(index); groups->setCurrentIndex(index);
groups->model()->sort(0); groups->model()->sort(0);
groups->blockSignals(false); groups->blockSignals(false);
} }
void AstroCalcDialog::setPhenomenaHeaderNames() void AstroCalcDialog::setPhenomenaHeaderNames()
{ {
QStringList headerStrings; phenomenaHeader.clear();
headerStrings << q_("Phenomenon"); phenomenaHeader << q_("Phenomenon");
headerStrings << q_("Date and Time"); phenomenaHeader << q_("Date and Time");
headerStrings << q_("Object 1"); phenomenaHeader << q_("Object 1");
headerStrings << q_("Object 2"); phenomenaHeader << q_("Object 2");
headerStrings << q_("Separation"); phenomenaHeader << q_("Separation");
ui->phenomenaTreeWidget->setHeaderLabels(headerStrings); ui->phenomenaTreeWidget->setHeaderLabels(phenomenaHeader);
// adjust the column width // adjust the column width
for(int i = 0; i < PhenomenaCount; ++i) for(int i = 0; i < PhenomenaCount; ++i)
{ {
ui->phenomenaTreeWidget->resizeColumnToContents(i); ui->phenomenaTreeWidget->resizeColumnToContents(i);
} }
} }
void AstroCalcDialog::initListPhenomena() void AstroCalcDialog::initListPhenomena()
{ {
skipping to change at line 589 skipping to change at line 677
// adjust the column width // adjust the column width
for(int i = 0; i < PhenomenaCount; ++i) for(int i = 0; i < PhenomenaCount; ++i)
{ {
ui->phenomenaTreeWidget->resizeColumnToContents(i); ui->phenomenaTreeWidget->resizeColumnToContents(i);
} }
// sort-by-date // sort-by-date
ui->phenomenaTreeWidget->sortItems(PhenomenaDate, Qt::AscendingOrder ); ui->phenomenaTreeWidget->sortItems(PhenomenaDate, Qt::AscendingOrder );
} }
void AstroCalcDialog::savePhenomena()
{
QString filter = q_("CSV (Comma delimited)");
filter.append(" (*.csv)");
QString filePath = QFileDialog::getSaveFileName(0, q_("Save calculat
ed phenomena as..."), StelFileMgr::getScreenshotDir(), filter);
QFile phenomena(filePath);
if (!phenomena.open(QFile::WriteOnly | QFile::Truncate))
{
qWarning() << "AstroCalc: Unable to open file"
<< QDir::toNativeSeparators(filePath);
return;
}
QTextStream phenomenaList(&phenomena);
phenomenaList.setCodec("UTF-8");
int count = ui->phenomenaTreeWidget->topLevelItemCount();
phenomenaList << phenomenaHeader.join(delimiter) << endl;
for (int i = 0; i < count; i++)
{
int columns = phenomenaHeader.size();
for (int j=0; j<columns; j++)
{
phenomenaList << ui->phenomenaTreeWidget->topLevelIt
em(i)->text(j);
if (j<columns-1)
phenomenaList << delimiter;
else
phenomenaList << endl;
}
}
phenomena.close();
}
void AstroCalcDialog::fillPhenomenaTable(const QMap<double, double> list, c onst PlanetP object1, const PlanetP object2, bool opposition) void AstroCalcDialog::fillPhenomenaTable(const QMap<double, double> list, c onst PlanetP object1, const PlanetP object2, bool opposition)
{ {
QMap<double, double>::ConstIterator it; QMap<double, double>::ConstIterator it;
for (it=list.constBegin(); it!=list.constEnd(); ++it) for (it=list.constBegin(); it!=list.constEnd(); ++it)
{ {
core->setJD(it.key()); core->setJD(it.key());
core->update(0); core->update(0);
QString phenomenType = q_("Conjunction"); QString phenomenType = q_("Conjunction");
double separation = it.value(); double separation = it.value();
skipping to change at line 617 skipping to change at line 740
// local date and time // local date and time
treeItem->setText(PhenomenaDate, StelUtils::jdToQDateTime(it .key() + StelUtils::getGMTShiftFromQT(it.key())/24).toString("yyyy-MM-dd hh :mm:ss")); treeItem->setText(PhenomenaDate, StelUtils::jdToQDateTime(it .key() + StelUtils::getGMTShiftFromQT(it.key())/24).toString("yyyy-MM-dd hh :mm:ss"));
treeItem->setText(PhenomenaObject1, object1->getNameI18n()); treeItem->setText(PhenomenaObject1, object1->getNameI18n());
treeItem->setText(PhenomenaObject2, object2->getNameI18n()); treeItem->setText(PhenomenaObject2, object2->getNameI18n());
treeItem->setText(PhenomenaSeparation, StelUtils::radToDmsSt r(separation)); treeItem->setText(PhenomenaSeparation, StelUtils::radToDmsSt r(separation));
} }
} }
QMap<double, double> AstroCalcDialog::findClosestApproach(PlanetP &object1, PlanetP &object2, double startJD, double stopJD, float maxSeparation, bool opposition) QMap<double, double> AstroCalcDialog::findClosestApproach(PlanetP &object1, PlanetP &object2, double startJD, double stopJD, float maxSeparation, bool opposition)
{ {
float dist, prevDist, step, step0; double dist, prevDist, step, step0;
int sgn, prevSgn = 0; int sgn, prevSgn = 0;
QMap<double, double> separations; QMap<double, double> separations;
QPair<double, double> extremum; QPair<double, double> extremum;
step0 = (stopJD - startJD)/4.0; step0 = (stopJD - startJD)/4.0;
if (step0>24.8*365.25) if (step0>24.8*365.25)
step0 = 24.8*365.25; step0 = 24.8*365.25;
if (object1->getEnglishName()=="Neptune" || object2->getEnglishName( )=="Neptune" || object1->getEnglishName()=="Uranus" || object2->getEnglishN ame()=="Uranus") if (object1->getEnglishName()=="Neptune" || object2->getEnglishName( )=="Neptune" || object1->getEnglishName()=="Uranus" || object2->getEnglishN ame()=="Uranus")
if (step0 > 3652.5) if (step0 > 3652.5)
 End of changes. 36 change blocks. 
37 lines changed or deleted 176 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/