Exoplanets.cpp   Exoplanets.cpp 
skipping to change at line 33 skipping to change at line 33
#include "StelGui.hpp" #include "StelGui.hpp"
#include "StelGuiItems.hpp" #include "StelGuiItems.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelTextureMgr.hpp" #include "StelTextureMgr.hpp"
#include "StelJsonParser.hpp" #include "StelJsonParser.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "StarMgr.hpp"
#include "LabelMgr.hpp" #include "LabelMgr.hpp"
#include "Exoplanets.hpp" #include "Exoplanets.hpp"
#include "Exoplanet.hpp" #include "Exoplanet.hpp"
#include "ExoplanetsDialog.hpp" #include "ExoplanetsDialog.hpp"
#include "StelActionMgr.hpp" #include "StelActionMgr.hpp"
#include "StelProgressController.hpp" #include "StelProgressController.hpp"
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include <QNetworkReply> #include <QNetworkReply>
#include <QKeyEvent> #include <QKeyEvent>
skipping to change at line 89 skipping to change at line 90
} }
/* /*
Constructor Constructor
*/ */
Exoplanets::Exoplanets() Exoplanets::Exoplanets()
: PSCount(0) : PSCount(0)
, EPCountAll(0) , EPCountAll(0)
, EPCountPH(0) , EPCountPH(0)
, updateState(CompleteNoUpdates) , updateState(CompleteNoUpdates)
, downloadMgr(NULL) , downloadMgr(Q_NULLPTR)
, updateTimer(0) , updateTimer(Q_NULLPTR)
, messageTimer(0) , messageTimer(Q_NULLPTR)
, updatesEnabled(false) , updatesEnabled(false)
, updateFrequencyHours(0) , updateFrequencyHours(0)
, enableAtStartup(false) , enableAtStartup(false)
, flagShowExoplanets(false) , flagShowExoplanets(false)
, flagShowExoplanetsButton(false) , flagShowExoplanetsButton(false)
, toolbarButton(NULL) , toolbarButton(Q_NULLPTR)
, progressBar(NULL) , progressBar(Q_NULLPTR)
{ {
setObjectName("Exoplanets"); setObjectName("Exoplanets");
exoplanetsConfigDialog = new ExoplanetsDialog(); exoplanetsConfigDialog = new ExoplanetsDialog();
conf = StelApp::getInstance().getSettings(); conf = StelApp::getInstance().getSettings();
font.setPixelSize(StelApp::getInstance().getBaseFontSize()); font.setPixelSize(StelApp::getInstance().getBaseFontSize());
} }
/* /*
Destructor Destructor
*/ */
skipping to change at line 289 skipping to change at line 290
} }
} }
} }
return result; return result;
} }
StelObjectP Exoplanets::searchByName(const QString& englishName) const StelObjectP Exoplanets::searchByName(const QString& englishName) const
{ {
if (!flagShowExoplanets) if (!flagShowExoplanets)
return NULL; return Q_NULLPTR;
foreach(const ExoplanetP& eps, ep) foreach(const ExoplanetP& eps, ep)
{ {
if (eps->getEnglishName().toUpper() == englishName.toUpper() || eps->getDesignation().toUpper() == englishName.toUpper()) if (eps->getEnglishName().toUpper() == englishName.toUpper() || eps->getDesignation().toUpper() == englishName.toUpper())
return qSharedPointerCast<StelObject>(eps); return qSharedPointerCast<StelObject>(eps);
QStringList ppn = eps->getExoplanetsEnglishNames(); QStringList ppn = eps->getExoplanetsEnglishNames();
if (!ppn.isEmpty()) if (!ppn.isEmpty())
{ {
foreach (const QString &str, ppn) foreach (const QString &str, ppn)
skipping to change at line 318 skipping to change at line 319
{ {
foreach (const QString &str, ppn) foreach (const QString &str, ppn)
{ {
if (str.toUpper() == englishName.toUpper()) if (str.toUpper() == englishName.toUpper())
return qSharedPointerCast<StelObject >(eps); return qSharedPointerCast<StelObject >(eps);
} }
} }
} }
return NULL; return Q_NULLPTR;
}
StelObjectP Exoplanets::searchByID(const QString &id) const
{
foreach(const ExoplanetP& eps, ep)
{
if(eps->getID() == id)
return qSharedPointerCast<StelObject>(eps);
}
return Q_NULLPTR;
} }
StelObjectP Exoplanets::searchByNameI18n(const QString& nameI18n) const StelObjectP Exoplanets::searchByNameI18n(const QString& nameI18n) const
{ {
if (!flagShowExoplanets) if (!flagShowExoplanets)
return NULL; return Q_NULLPTR;
foreach(const ExoplanetP& eps, ep) foreach(const ExoplanetP& eps, ep)
{ {
if (eps->getNameI18n().toUpper() == nameI18n.toUpper() || ep s->getDesignation().toUpper() == nameI18n.toUpper()) if (eps->getNameI18n().toUpper() == nameI18n.toUpper() || ep s->getDesignation().toUpper() == nameI18n.toUpper())
return qSharedPointerCast<StelObject>(eps); return qSharedPointerCast<StelObject>(eps);
QStringList ppn = eps->getExoplanetsNamesI18n(); QStringList ppn = eps->getExoplanetsNamesI18n();
if (!ppn.isEmpty()) if (!ppn.isEmpty())
{ {
foreach (const QString &str, ppn) foreach (const QString &str, ppn)
{ {
if (str.toUpper() == nameI18n.toUpper()) if (str.toUpper() == nameI18n.toUpper())
return qSharedPointerCast<StelObject >(eps); return qSharedPointerCast<StelObject >(eps);
} }
} }
} }
return NULL; return Q_NULLPTR;
} }
QStringList Exoplanets::listMatchingObjects(const QString& objPrefix, int m axNbItem, bool useStartOfWords, bool inEnglish) const QStringList Exoplanets::listMatchingObjects(const QString& objPrefix, int m axNbItem, bool useStartOfWords, bool inEnglish) const
{ {
QStringList result; QStringList result;
if (!flagShowExoplanets || maxNbItem <= 0) if (!flagShowExoplanets || maxNbItem <= 0)
{ {
return result; return result;
} }
skipping to change at line 441 skipping to change at line 452
// the json file has been manually removed, that an update i s schreduled in a timely // the json file has been manually removed, that an update i s schreduled in a timely
// manner // manner
conf->remove("Exoplanets/last_update"); conf->remove("Exoplanets/last_update");
lastUpdate = QDateTime::fromString("2012-05-24T12:00:00", Qt ::ISODate); lastUpdate = QDateTime::fromString("2012-05-24T12:00:00", Qt ::ISODate);
} }
} }
/* /*
Creates a backup of the exoplanets.json file called exoplanets.json.old Creates a backup of the exoplanets.json file called exoplanets.json.old
*/ */
bool Exoplanets::backupJsonFile(bool deleteOriginal) bool Exoplanets::backupJsonFile(bool deleteOriginal) const
{ {
QFile old(jsonCatalogPath); QFile old(jsonCatalogPath);
if (!old.exists()) if (!old.exists())
{ {
qWarning() << "[Exoplanets] No file to backup"; qWarning() << "[Exoplanets] No file to backup";
return false; return false;
} }
QString backupPath = jsonCatalogPath + ".old"; QString backupPath = jsonCatalogPath + ".old";
if (QFileInfo(backupPath).exists()) if (QFileInfo(backupPath).exists())
skipping to change at line 529 skipping to change at line 540
jsonFile.close(); jsonFile.close();
} }
return map; return map;
} }
/* /*
Set items for list of struct from data map Set items for list of struct from data map
*/ */
void Exoplanets::setEPMap(const QVariantMap& map) void Exoplanets::setEPMap(const QVariantMap& map)
{ {
StelCore* core = StelApp::getInstance().getCore();
StarMgr* smgr = GETSTELMODULE(StarMgr);
double ra, dec;
StelObjectP star;
ep.clear(); ep.clear();
PSCount = EPCountAll = EPCountPH = 0; PSCount = EPCountAll = EPCountPH = 0;
EPEccentricityAll.clear(); EPEccentricityAll.clear();
EPSemiAxisAll.clear(); EPSemiAxisAll.clear();
EPMassAll.clear(); EPMassAll.clear();
EPRadiusAll.clear(); EPRadiusAll.clear();
EPPeriodAll.clear(); EPPeriodAll.clear();
EPAngleDistanceAll.clear(); EPAngleDistanceAll.clear();
QVariantMap epsMap = map.value("stars").toMap(); QVariantMap epsMap = map.value("stars").toMap();
foreach(QString epsKey, epsMap.keys()) foreach(QString epsKey, epsMap.keys())
{ {
QVariantMap epsData = epsMap.value(epsKey).toMap(); QVariantMap epsData = epsMap.value(epsKey).toMap();
epsData["designation"] = epsKey; epsData["designation"] = epsKey;
PSCount++; PSCount++;
// Let's check existence the star (by designation) in our ca
talog...
star = smgr->searchByName(epsKey.trimmed());
if (!star.isNull())
{
// ...if exists, let's use our coordinates of star i
nstead exoplanets.eu website data
StelUtils::rectToSphe(&ra, &dec, star->getJ2000Equat
orialPos(core));
epsData["RA"] = StelUtils::radToDecDegStr(ra, 6);
epsData["DE"] = StelUtils::radToDecDegStr(dec, 6);
}
ExoplanetP eps(new Exoplanet(epsData)); ExoplanetP eps(new Exoplanet(epsData));
if (eps->initialized) if (eps->initialized)
{ {
ep.append(eps); ep.append(eps);
EPEccentricityAll.append(eps->getData(0)); EPEccentricityAll.append(eps->getData(0));
EPSemiAxisAll.append(eps->getData(1)); EPSemiAxisAll.append(eps->getData(1));
EPMassAll.append(eps->getData(2)); EPMassAll.append(eps->getData(2));
EPRadiusAll.append(eps->getData(3)); EPRadiusAll.append(eps->getData(3));
EPPeriodAll.append(eps->getData(4)); EPPeriodAll.append(eps->getData(4));
EPAngleDistanceAll.append(eps->getData(5)); EPAngleDistanceAll.append(eps->getData(5));
EPEffectiveTempHostStarAll.append(eps->getData(6));
EPYearDiscoveryAll.append(eps->getData(7));
EPMetallicityHostStarAll.append(eps->getData(8));
EPVMagHostStarAll.append(eps->getData(9));
EPRAHostStarAll.append(eps->getData(10));
EPDecHostStarAll.append(eps->getData(11));
EPDistanceHostStarAll.append(eps->getData(12));
EPMassHostStarAll.append(eps->getData(13));
EPRadiusHostStarAll.append(eps->getData(14));
EPCountAll += eps->getCountExoplanets(); EPCountAll += eps->getCountExoplanets();
EPCountPH += eps->getCountHabitableExoplanets(); EPCountPH += eps->getCountHabitableExoplanets();
} }
} }
} }
int Exoplanets::getJsonFileFormatVersion(void) int Exoplanets::getJsonFileFormatVersion(void) const
{ {
int jsonVersion = -1; int jsonVersion = -1;
QFile jsonEPCatalogFile(jsonCatalogPath); QFile jsonEPCatalogFile(jsonCatalogPath);
if (!jsonEPCatalogFile.open(QIODevice::ReadOnly)) if (!jsonEPCatalogFile.open(QIODevice::ReadOnly))
{ {
qWarning() << "[Exoplanets] Cannot open " << QDir::toNativeS eparators(jsonCatalogPath); qWarning() << "[Exoplanets] Cannot open " << QDir::toNativeS eparators(jsonCatalogPath);
return jsonVersion; return jsonVersion;
} }
QVariantMap map; QVariantMap map;
skipping to change at line 584 skipping to change at line 618
jsonEPCatalogFile.close(); jsonEPCatalogFile.close();
if (map.contains("version")) if (map.contains("version"))
{ {
jsonVersion = map.value("version").toInt(); jsonVersion = map.value("version").toInt();
} }
qDebug() << "[Exoplanets] Version of the format of the catalog:" << jsonVersion; qDebug() << "[Exoplanets] Version of the format of the catalog:" << jsonVersion;
return jsonVersion; return jsonVersion;
} }
bool Exoplanets::checkJsonFileFormat() bool Exoplanets::checkJsonFileFormat() const
{ {
QFile jsonEPCatalogFile(jsonCatalogPath); QFile jsonEPCatalogFile(jsonCatalogPath);
if (!jsonEPCatalogFile.open(QIODevice::ReadOnly)) if (!jsonEPCatalogFile.open(QIODevice::ReadOnly))
{ {
qWarning() << "[Exoplanets] Cannot open " << QDir::toNativeS eparators(jsonCatalogPath); qWarning() << "[Exoplanets] Cannot open " << QDir::toNativeS eparators(jsonCatalogPath);
return false; return false;
} }
QVariantMap map; QVariantMap map;
try try
skipping to change at line 715 skipping to change at line 749
{ {
qDebug() << "[Exoplanets] Starting update..."; qDebug() << "[Exoplanets] Starting update...";
} }
lastUpdate = QDateTime::currentDateTime(); lastUpdate = QDateTime::currentDateTime();
conf->setValue("Exoplanets/last_update", lastUpdate.toString(Qt::ISO Date)); conf->setValue("Exoplanets/last_update", lastUpdate.toString(Qt::ISO Date));
updateState = Exoplanets::Updating; updateState = Exoplanets::Updating;
emit(updateStateChanged(updateState)); emit(updateStateChanged(updateState));
if (progressBar==NULL) if (progressBar==Q_NULLPTR)
progressBar = StelApp::getInstance().addProgressBar(); progressBar = StelApp::getInstance().addProgressBar();
progressBar->setValue(0); progressBar->setValue(0);
progressBar->setRange(0, 100); progressBar->setRange(0, 100);
progressBar->setFormat("Update exoplanets"); progressBar->setFormat("Update exoplanets");
QNetworkRequest request; QNetworkRequest request;
request.setUrl(QUrl(updateUrl)); request.setUrl(QUrl(updateUrl));
request.setRawHeader("User-Agent", QString("Mozilla/5.0 (Stellarium Exoplanets Plugin %1; http://stellarium.org/)").arg(EXOPLANETS_PLUGIN_VERSI ON).toUtf8()); request.setRawHeader("User-Agent", QString("Mozilla/5.0 (Stellarium Exoplanets Plugin %1; http://stellarium.org/)").arg(EXOPLANETS_PLUGIN_VERSI ON).toUtf8());
downloadMgr->get(request); downloadMgr->get(request);
skipping to change at line 766 skipping to change at line 800
{ {
qWarning() << "[Exoplanets] Cannot write JSON data t o file:" << e.what(); qWarning() << "[Exoplanets] Cannot write JSON data t o file:" << e.what();
} }
} }
if (progressBar) if (progressBar)
{ {
progressBar->setValue(100); progressBar->setValue(100);
StelApp::getInstance().removeProgressBar(progressBar); StelApp::getInstance().removeProgressBar(progressBar);
progressBar = NULL; progressBar = Q_NULLPTR;
} }
readJsonFile(); readJsonFile();
} }
void Exoplanets::displayMessage(const QString& message, const QString hexCo lor) void Exoplanets::displayMessage(const QString& message, const QString hexCo lor)
{ {
messageIDs << GETSTELMODULE(LabelMgr)->labelScreen(message, 30, 30 + (20*messageIDs.count()), true, 16, hexColor); messageIDs << GETSTELMODULE(LabelMgr)->labelScreen(message, 30, 30 + (20*messageIDs.count()), true, 16, hexColor);
messageTimer->start(); messageTimer->start();
} }
skipping to change at line 802 skipping to change at line 836
if (!conf->contains("Exoplanets/enable_at_startup")) if (!conf->contains("Exoplanets/enable_at_startup"))
conf->setValue("Exoplanets/enable_at_startup", b); conf->setValue("Exoplanets/enable_at_startup", b);
conf->remove("Exoplanets/flag_show_exoplanets"); conf->remove("Exoplanets/flag_show_exoplanets");
} }
} }
// Define whether the button toggling exoplanets should be visible // Define whether the button toggling exoplanets should be visible
void Exoplanets::setFlagShowExoplanetsButton(bool b) void Exoplanets::setFlagShowExoplanetsButton(bool b)
{ {
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui( )); StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance().getGui( ));
if (gui!=NULL) if (gui!=Q_NULLPTR)
{ {
if (b==true) if (b==true)
{ {
if (toolbarButton==NULL) { if (toolbarButton==Q_NULLPTR) {
// Create the exoplanets button // Create the exoplanets button
toolbarButton = new StelButton(NULL, toolbarButton = new StelButton(Q_NULLPTR,
QPixmap(":/Ex oplanets/btExoplanets-on.png"), QPixmap(":/Ex oplanets/btExoplanets-on.png"),
QPixmap(":/Ex oplanets/btExoplanets-off.png"), QPixmap(":/Ex oplanets/btExoplanets-off.png"),
QPixmap(":/gr aphicGui/glow32x32.png"), QPixmap(":/gr aphicGui/glow32x32.png"),
"actionShow_E xoplanets"); "actionShow_E xoplanets");
} }
gui->getButtonBar()->addButton(toolbarButton, "065-p luginsGroup"); gui->getButtonBar()->addButton(toolbarButton, "065-p luginsGroup");
} else { } else {
gui->getButtonBar()->hideButton("actionShow_Exoplane ts"); gui->getButtonBar()->hideButton("actionShow_Exoplane ts");
} }
} }
flagShowExoplanetsButton = b; flagShowExoplanetsButton = b;
} }
bool Exoplanets::getDisplayMode() bool Exoplanets::getDisplayMode() const
{ {
return Exoplanet::distributionMode; return Exoplanet::distributionMode;
} }
void Exoplanets::setDisplayMode(bool b) void Exoplanets::setDisplayMode(bool b)
{ {
Exoplanet::distributionMode=b; Exoplanet::distributionMode=b;
} }
bool Exoplanets::getFlagShowExoplanetsDesignations() bool Exoplanets::getFlagShowExoplanetsDesignations() const
{ {
return Exoplanet::showDesignations; return Exoplanet::showDesignations;
} }
void Exoplanets::setFlagShowExoplanetsDesignations(bool b) void Exoplanets::setFlagShowExoplanetsDesignations(bool b)
{ {
Exoplanet::showDesignations=b; Exoplanet::showDesignations=b;
} }
bool Exoplanets::getTimelineMode() bool Exoplanets::getTimelineMode() const
{ {
return Exoplanet::timelineMode; return Exoplanet::timelineMode;
} }
void Exoplanets::setTimelineMode(bool b) void Exoplanets::setTimelineMode(bool b)
{ {
Exoplanet::timelineMode=b; Exoplanet::timelineMode=b;
} }
bool Exoplanets::getHabitableMode() bool Exoplanets::getHabitableMode() const
{ {
return Exoplanet::habitableMode; return Exoplanet::habitableMode;
} }
void Exoplanets::setHabitableMode(bool b) void Exoplanets::setHabitableMode(bool b)
{ {
Exoplanet::habitableMode=b; Exoplanet::habitableMode=b;
} }
Vec3f Exoplanets::getMarkerColor(bool habitable) Vec3f Exoplanets::getMarkerColor(bool habitable) const
{ {
Vec3f c = Exoplanet::exoplanetMarkerColor; Vec3f c = Exoplanet::exoplanetMarkerColor;
if (habitable) if (habitable)
c = Exoplanet::habitableExoplanetMarkerColor; c = Exoplanet::habitableExoplanetMarkerColor;
return c; return c;
} }
void Exoplanets::setMarkerColor(const Vec3f &c, bool h) void Exoplanets::setMarkerColor(const Vec3f &c, bool h)
{ {
 End of changes. 23 change blocks. 
22 lines changed or deleted 59 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/