/* * Stellarium Exoplanets Plug-in GUI * * Copyright (C) 2012 Alexander Wolf * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. */ #include "config.h" #include #include #include #include #include #include "StelApp.hpp" #include "ui_exoplanetsDialog.h" #include "ExoplanetsDialog.hpp" #include "Exoplanets.hpp" #include "StelModuleMgr.hpp" #include "StelObjectMgr.hpp" #include "StelMovementMgr.hpp" #include "StelStyle.hpp" #include "StelGui.hpp" #include "StelMainView.hpp" #include "StelFileMgr.hpp" #include "StelTranslator.hpp" ExoplanetsDialog::ExoplanetsDialog() : ep(NULL) , updateTimer(NULL) { ui = new Ui_exoplanetsDialog; } ExoplanetsDialog::~ExoplanetsDialog() { if (updateTimer) { updateTimer->stop(); delete updateTimer; updateTimer = NULL; } delete ui; } void ExoplanetsDialog::retranslate() { if (dialog) { ui->retranslateUi(dialog); refreshUpdateValues(); setAboutHtml(); setInfoHtml(); setWebsitesHtml(); } } // Initialize the dialog widgets and connect the signals/slots void ExoplanetsDialog::createDialogContent() { ep = GETSTELMODULE(Exoplanets); ui->setupUi(dialog); ui->tabs->setCurrentIndex(0); connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SLOT(retranslate())); // Settings tab / updates group ui->displayAtStartupCheckBox->setChecked(ep->getEnableAtStartup()); connect(ui->displayAtStartupCheckBox, SIGNAL(stateChanged(int)), this, SLOT(setDisplayAtStartupEnabled(int))); ui->displayModeCheckBox->setChecked(ep->getDisplayMode()); connect(ui->displayModeCheckBox, SIGNAL(stateChanged(int)), this, SLOT(setDistributionEnabled(int))); ui->displayShowExoplanetsButton->setChecked(ep->getFlagShowExoplanetsButton()); connect(ui->displayShowExoplanetsButton, SIGNAL(stateChanged(int)), this, SLOT(setDisplayShowExoplanetsButton(int))); ui->timelineModeCheckBox->setChecked(ep->getTimelineMode()); connect(ui->timelineModeCheckBox, SIGNAL(stateChanged(int)), this, SLOT(setTimelineEnabled(int))); ui->habitableModeCheckBox->setChecked(ep->getHabitableMode()); connect(ui->habitableModeCheckBox, SIGNAL(stateChanged(int)), this, SLOT(setHabitableEnabled(int))); connect(ui->internetUpdatesCheckbox, SIGNAL(stateChanged(int)), this, SLOT(setUpdatesEnabled(int))); connect(ui->updateButton, SIGNAL(clicked()), this, SLOT(updateJSON())); connect(ep, SIGNAL(updateStateChanged(Exoplanets::UpdateState)), this, SLOT(updateStateReceiver(Exoplanets::UpdateState))); connect(ep, SIGNAL(jsonUpdateComplete(void)), this, SLOT(updateCompleteReceiver(void))); connect(ui->updateFrequencySpinBox, SIGNAL(valueChanged(int)), this, SLOT(setUpdateValues(int))); refreshUpdateValues(); // fetch values for last updated and so on // if the state didn't change, setUpdatesEnabled will not be called, so we force it setUpdatesEnabled(ui->internetUpdatesCheckbox->checkState()); updateTimer = new QTimer(this); connect(updateTimer, SIGNAL(timeout()), this, SLOT(refreshUpdateValues())); updateTimer->start(7000); connect(ui->closeStelWindow, SIGNAL(clicked()), this, SLOT(close())); connect(ui->restoreDefaultsButton, SIGNAL(clicked()), this, SLOT(restoreDefaults())); connect(ui->saveSettingsButton, SIGNAL(clicked()), this, SLOT(saveSettings())); // About & Info tabs setAboutHtml(); setInfoHtml(); setWebsitesHtml(); StelGui* gui = dynamic_cast(StelApp::getInstance().getGui()); if(gui!=NULL) { ui->aboutTextBrowser->document()->setDefaultStyleSheet(QString(gui->getStelStyle().htmlStyleSheet)); ui->infoTextBrowser->document()->setDefaultStyleSheet(QString(gui->getStelStyle().htmlStyleSheet)); ui->websitesTextBrowser->document()->setDefaultStyleSheet(QString(gui->getStelStyle().htmlStyleSheet)); } updateGuiFromSettings(); } void ExoplanetsDialog::setAboutHtml(void) { QString html = ""; html += "

" + q_("Exoplanets Plug-in") + "

"; html += ""; html += "
" + q_("Version") + ":" + EXOPLANETS_PLUGIN_VERSION + "
" + q_("Author") + ":Alexander Wolf <alex.v.wolf@gmail.com>
"; html += "

" + QString(q_("This plugin plots the position of stars with exoplanets. Exoplanets data is derived from \"%1The Extrasolar Planets Encyclopaedia%2\"")).arg("").arg("") + ". "; html += QString(q_("The list of potential habitable exoplanets and data about them were taken from \"%1The Habitable Exoplanets Catalog%3\" by %2Planetary Habitability Laboratory%3.")).arg("").arg("").arg("") + "

"; html += "

" + q_("The current catalog contains info about %1 planetary systems, which altogether have %2 exoplanets (including %3 potentially habitable exoplanets).").arg(ep->getCountPlanetarySystems()).arg(ep->getCountAllExoplanets()).arg(ep->getCountHabitableExoplanets()) + "

"; html += "

" + q_("Links") + "

"; html += "

" + QString(q_("Support is provided via the Launchpad website. Be sure to put \"%1\" in the subject when posting.")).arg("Exoplanets plugin") + "

"; html += "

    "; // TRANSLATORS: The numbers contain the opening and closing tag of an HTML link html += "
  • " + QString(q_("If you have a question, you can %1get an answer here%2").arg("")).arg("") + "
  • "; // TRANSLATORS: The numbers contain the opening and closing tag of an HTML link html += "
  • " + QString(q_("Bug reports can be made %1here%2.")).arg("").arg("") + "
  • "; // TRANSLATORS: The numbers contain the opening and closing tag of an HTML link html += "
  • " + q_("If you would like to make a feature request, you can create a bug report, and set the severity to \"wishlist\".") + "
  • "; // TRANSLATORS: The numbers contain the opening and closing tag of an HTML link html += "
  • " + q_("If you want to read full information about the plugin, its history and format of the catalog you can %1get info here%2.").arg("").arg("") + "
  • "; html += "

"; StelGui* gui = dynamic_cast(StelApp::getInstance().getGui()); if(gui!=NULL) { QString htmlStyleSheet(gui->getStelStyle().htmlStyleSheet); ui->aboutTextBrowser->document()->setDefaultStyleSheet(htmlStyleSheet); } ui->aboutTextBrowser->setHtml(html); } void ExoplanetsDialog::setInfoHtml(void) { QString html = ""; html += "

" + q_("Potential habitable exoplanets") + "

"; html += QString("

%1

").arg(q_("This plugin can display potential habitable exoplanets (orange marker) and some information about those planets - habitable class, mean surface temperature and Earth Similarity Index.")); html += QString("

%1 — %2

").arg(q_("Habitable Class")).arg(q_("Classifies habitable planets based on temperature: hypopsychroplanets (O or hP) = very cold (less −50°C); psychroplanets (P) = cold; mesoplanets (M) = medium-temperature (0–50°C); thermoplanets (T) = hot; hyperthermoplanets (E or hT) = very hot (above 100°C). Mesoplanets would be ideal for complex life, whereas class O or E would only support extremophilic life. Non-habitable planets are simply given the class X (or NH).")); html += QString("

%1 — %2

").arg(q_("Mean Surface Temperature")).arg(q_("Temperature in (°C) based on a similar terrestrial atmosphere to planet mass ratio and a greenhouse effect due to 1 percent of CO2 (assuming an albedo of 0.3 in all cases).")); html += QString("

%1 — %2

").arg(q_("Earth Similarity Index (ESI)")).arg(q_("Similarity to Earth on a scale from 0 to 1, with 1 being the most Earth-like. ESI depends on the planet's radius, density, escape velocity, and surface temperature.")); html += ""; StelGui* gui = dynamic_cast(StelApp::getInstance().getGui()); if(gui!=NULL) { QString htmlStyleSheet(gui->getStelStyle().htmlStyleSheet); ui->infoTextBrowser->document()->setDefaultStyleSheet(htmlStyleSheet); } ui->infoTextBrowser->setHtml(html); } void ExoplanetsDialog::setWebsitesHtml(void) { QString html = ""; html += "

" + q_("General professional Web sites relevant to extrasolar planets") + "

    "; html += QString("
  • %2
  • ").arg("http://codementum.org/exoplanets/").arg(q_("Exoplanets: an interactive version of XKCD 1071")); html += QString("
  • %2
  • ").arg("http://www.cfa.harvard.edu/HEK/").arg(q_("HEK (The Hunt for Exomoons with Kepler)")); html += QString("
  • %2
  • ").arg("http://www.univie.ac.at/adg/schwarz/multiple.html").arg(q_("Exoplanets in binaries and multiple systems (Richard Schwarz)")); html += QString("
  • %2
  • ").arg("http://www.iau.org/public/naming/#exoplanets").arg(q_("Naming exoplanets (IAU)")); html += QString("
  • %2 (%3)
  • ").arg("http://voparis-exoplanet.obspm.fr/people.html").arg(q_("Some Astronomers and Groups active in extrasolar planets studies")).arg(q_("update: 16 April 2012")); html += QString("
  • %2
  • ").arg("http://exoplanets.org/").arg(q_("The Exoplanet Data Explorer")); html += QString("
  • %2
  • ").arg("http://www.phys.unsw.edu.au/~cgt/planet/AAPS_Home.html").arg(q_("The Anglo-Australian Planet Search")); html += QString("
  • %2
  • ").arg("http://www.exoplanets.ch/").arg(q_("Geneva Extrasolar Planet Search Programmes")); html += QString("
  • %2
  • ").arg("http://olbin.jpl.nasa.gov/").arg(q_("OLBIN (Optical Long-Baseline Interferometry News)")); html += QString("
  • %2
  • ").arg("http://exep.jpl.nasa.gov/").arg(q_("NASA's Exoplanet Exploration Program")); html += QString("
  • %2
  • ").arg("http://www.astro.psu.edu/users/alex/pulsar_planets.htm").arg(q_("Pulsar planets")); html += QString("
  • %2
  • ").arg("http://exoplanetarchive.ipac.caltech.edu/").arg(q_("The NASA Exoplanet Archive")); html += QString("
  • %2
  • ").arg("http://www.dtm.ciw.edu/boss/c53index.html").arg(q_("IAU Commission 53: Extrasolar Planets")); html += QString("
  • %2
  • ").arg("http://www.exomol.com/").arg(q_("ExoMol")); html += QString("
  • %2
  • ").arg("http://www.hzgallery.org/").arg(q_("The Habitable Zone Gallery")); html += QString("
  • %2
  • ").arg("http://planetquest.jpl.nasa.gov/").arg(q_("PlanetQuest - The Search for Another Earth")); html += QString("
  • %2
  • ").arg("http://www.openexoplanetcatalogue.com/").arg(q_("Open Exoplanet Catalogue")); html += QString("
  • %2
  • ").arg("http://phl.upr.edu/projects/habitable-exoplanets-catalog").arg(q_("The Habitable Exoplanets Catalog")); html += "
"; StelGui* gui = dynamic_cast(StelApp::getInstance().getGui()); if(gui!=NULL) { QString htmlStyleSheet(gui->getStelStyle().htmlStyleSheet); ui->websitesTextBrowser->document()->setDefaultStyleSheet(htmlStyleSheet); } ui->websitesTextBrowser->setHtml(html); } void ExoplanetsDialog::refreshUpdateValues(void) { ui->lastUpdateDateTimeEdit->setDateTime(ep->getLastUpdate()); ui->updateFrequencySpinBox->setValue(ep->getUpdateFrequencyHours()); int secondsToUpdate = ep->getSecondsToUpdate(); ui->internetUpdatesCheckbox->setChecked(ep->getUpdatesEnabled()); if (!ep->getUpdatesEnabled()) ui->nextUpdateLabel->setText(q_("Internet updates disabled")); else if (ep->getUpdateState() == Exoplanets::Updating) ui->nextUpdateLabel->setText(q_("Updating now...")); else if (secondsToUpdate <= 60) ui->nextUpdateLabel->setText(q_("Next update: < 1 minute")); else if (secondsToUpdate < 3600) ui->nextUpdateLabel->setText(QString(q_("Next update: %1 minutes")).arg((secondsToUpdate/60)+1)); else ui->nextUpdateLabel->setText(QString(q_("Next update: %1 hours")).arg((secondsToUpdate/3600)+1)); } void ExoplanetsDialog::setUpdateValues(int hours) { ep->setUpdateFrequencyHours(hours); refreshUpdateValues(); } void ExoplanetsDialog::setDistributionEnabled(int checkState) { bool b = checkState != Qt::Unchecked; ep->setDisplayMode(b); } void ExoplanetsDialog::setTimelineEnabled(int checkState) { bool b = checkState != Qt::Unchecked; ep->setTimelineMode(b); } void ExoplanetsDialog::setHabitableEnabled(int checkState) { bool b = checkState != Qt::Unchecked; ep->setHabitableMode(b); } void ExoplanetsDialog::setDisplayAtStartupEnabled(int checkState) { bool b = checkState != Qt::Unchecked; ep->setEnableAtStartup(b); } void ExoplanetsDialog::setDisplayShowExoplanetsButton(int checkState) { bool b = checkState != Qt::Unchecked; ep->setFlagShowExoplanetsButton(b); } void ExoplanetsDialog::setUpdatesEnabled(int checkState) { bool b = checkState != Qt::Unchecked; ep->setUpdatesEnabled(b); ui->updateFrequencySpinBox->setEnabled(b); if(b) ui->updateButton->setText(q_("Update now")); else ui->updateButton->setText(q_("Update from files")); refreshUpdateValues(); } void ExoplanetsDialog::updateStateReceiver(Exoplanets::UpdateState state) { //qDebug() << "ExoplanetsDialog::updateStateReceiver got a signal"; if (state==Exoplanets::Updating) ui->nextUpdateLabel->setText(q_("Updating now...")); else if (state==Exoplanets::DownloadError || state==Exoplanets::OtherError) { ui->nextUpdateLabel->setText(q_("Update error")); updateTimer->start(); // make sure message is displayed for a while... } } void ExoplanetsDialog::updateCompleteReceiver(void) { ui->nextUpdateLabel->setText(QString(q_("Exoplanets is updated"))); // display the status for another full interval before refreshing status updateTimer->start(); ui->lastUpdateDateTimeEdit->setDateTime(ep->getLastUpdate()); QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(refreshUpdateValues())); } void ExoplanetsDialog::restoreDefaults(void) { qDebug() << "Exoplanets::restoreDefaults"; ep->restoreDefaults(); ep->loadConfiguration(); updateGuiFromSettings(); } void ExoplanetsDialog::updateGuiFromSettings(void) { ui->internetUpdatesCheckbox->setChecked(ep->getUpdatesEnabled()); refreshUpdateValues(); } void ExoplanetsDialog::saveSettings(void) { ep->saveConfiguration(); } void ExoplanetsDialog::updateJSON(void) { if(ep->getUpdatesEnabled()) { ep->updateJSON(); } }