Satellites.cpp   Satellites.cpp 
skipping to change at line 20 skipping to change at line 20
* 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.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelPainter.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelGui.hpp" #include "StelGui.hpp"
#include "StelGuiItems.hpp" #include "StelGuiItems.hpp"
#include "StelLocation.hpp" #include "StelLocation.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelTextureMgr.hpp"
#include "StelIniParser.hpp" #include "StelIniParser.hpp"
#include "Satellites.hpp" #include "Satellites.hpp"
#include "Satellite.hpp" #include "Satellite.hpp"
#include "Planet.hpp" #include "Planet.hpp"
#include "SolarSystem.hpp" #include "SolarSystem.hpp"
#include "StelJsonParser.hpp" #include "StelJsonParser.hpp"
#include "SatellitesDialog.hpp" #include "SatellitesDialog.hpp"
#include "LabelMgr.hpp" #include "LabelMgr.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "renderer/StelRenderer.hpp"
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include <QNetworkReply> #include <QNetworkReply>
#include <QKeyEvent> #include <QKeyEvent>
#include <QAction> #include <QAction>
#include <QProgressBar> #include <QProgressBar>
#include <QDebug> #include <QDebug>
#include <QFileInfo> #include <QFileInfo>
#include <QFile> #include <QFile>
#include <QTimer> #include <QTimer>
#include <QVariantMap> #include <QVariantMap>
#include <QVariant> #include <QVariant>
StelModule* SatellitesStelPluginInterface::getStelModule() const StelModule* SatellitesStelPluginInterface::getStelModule() const
{ {
return new Satellites(); return new Satellites();
} }
StelPluginInfo SatellitesStelPluginInterface::getPluginInfo() const StelPluginInfo SatellitesStelPluginInterface::getPluginInfo() const
{ {
// Allow to load the resources when used as a static plugin // Allow to load the resources when used as a static plugin
Q_INIT_RESOURCE(Satellites); Q_INIT_RESOURCE(Satellites);
StelPluginInfo info; StelPluginInfo info;
info.id = "Satellites"; info.id = "Satellites";
info.displayedName = N_("Satellites"); info.displayedName = N_("Satellites");
info.authors = "Matthew Gates, Jose Luis Canales"; info.authors = "Matthew Gates, Jose Luis Canales";
info.contact = "http://stellarium.org/"; info.contact = "http://stellarium.org/";
info.description = N_("Prediction of artificial satellite po info.description = N_("Prediction of artificial satellite positions
sitions in Earth orbit based on NORAD TLE data"); in Earth orbit based on NORAD TLE data");
return info; return info;
} }
Q_EXPORT_PLUGIN2(Satellites, SatellitesStelPluginInterface) Q_EXPORT_PLUGIN2(Satellites, SatellitesStelPluginInterface)
Satellites::Satellites() Satellites::Satellites()
: pxmapGlow(NULL), pxmapOnIcon(NULL), pxmapOffIcon(NULL), toolbarBut : hintTexture(NULL)
ton(NULL), , texPointer(NULL)
earth(NULL), defaultHintColor(0.0, 0.4, 0.6), defaultOrbitColor(0. , pxmapGlow(NULL)
0, 0.3, 0.6), , pxmapOnIcon(NULL)
progressBar(NULL) , pxmapOffIcon(NULL)
, toolbarButton(NULL)
, earth(NULL)
, defaultHintColor(0.0, 0.4, 0.6)
, defaultOrbitColor(0.0, 0.3, 0.6)
, progressBar(NULL)
{ {
setObjectName("Satellites"); setObjectName("Satellites");
configDialog = new SatellitesDialog(); configDialog = new SatellitesDialog();
} }
void Satellites::deinit() void Satellites::deinit()
{ {
Satellite::hintTexture.clear(); if(NULL != hintTexture)
texPointer.clear(); {
delete hintTexture;
}
if(NULL != texPointer)
{
delete texPointer;
}
} }
Satellites::~Satellites() Satellites::~Satellites()
{ {
delete configDialog; delete configDialog;
if (pxmapGlow) if (pxmapGlow)
delete pxmapGlow; delete pxmapGlow;
if (pxmapOnIcon) if (pxmapOnIcon)
delete pxmapOnIcon; delete pxmapOnIcon;
skipping to change at line 122 skipping to change at line 134
qDebug() << "Stellites::init no Satellites section e xists in main config file - creating with defaults"; qDebug() << "Stellites::init no Satellites section e xists in main config file - creating with defaults";
restoreDefaultConfigIni(); restoreDefaultConfigIni();
} }
// populate settings from main config file. // populate settings from main config file.
readSettingsFromConfig(); readSettingsFromConfig();
satellitesJsonPath = StelFileMgr::findFile("modules/Satellit es", (StelFileMgr::Flags)(StelFileMgr::Directory|StelFileMgr::Writable)) + "/satellites.json"; satellitesJsonPath = StelFileMgr::findFile("modules/Satellit es", (StelFileMgr::Flags)(StelFileMgr::Directory|StelFileMgr::Writable)) + "/satellites.json";
// Load and find resources used in the plugin // Load and find resources used in the plugin
texPointer = StelApp::getInstance().getTextureManager().crea
teTexture("textures/pointeur5.png");
Satellite::hintTexture = StelApp::getInstance().getTextureMa
nager().createTexture(":/satellites/hint.png");
// key bindings and other actions // key bindings and other actions
// TRANSLATORS: Title of a group of key bindings in the Help
window
QString groupName = N_("Plugin Key Bindings");
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance() .getGui()); StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance() .getGui());
gui->addGuiActions("actionShow_Satellite_ConfigDialog_Global gui->getGuiAction("actionShow_Satellite_Hints")->setChecked(
", N_("Satellites configuration window"), "Alt+Z", groupName, true, false, getFlagHints());
true); gui->getGuiAction("actionShow_Satellite_Labels")->setChecked
gui->addGuiActions("actionShow_Satellite_Hints", N_("Satelli (Satellite::showLabels);
te hints"), "Ctrl+Z", groupName, true, false);
gui->getGuiActions("actionShow_Satellite_Hints")->setChecked
(getFlagHints());
gui->addGuiActions("actionShow_Satellite_Labels", N_("Satell
ite labels"), "Shift+Z", groupName, true, false);
gui->getGuiActions("actionShow_Satellite_Labels")->setChecke
d(Satellite::showLabels);
// Gui toolbar button // Gui toolbar button
pxmapGlow = new QPixmap(":/graphicGui/glow32x32.png"); pxmapGlow = new QPixmap(":/graphicGui/glow32x32.png");
pxmapOnIcon = new QPixmap(":/satellites/bt_satellites_on.png "); pxmapOnIcon = new QPixmap(":/satellites/bt_satellites_on.png ");
pxmapOffIcon = new QPixmap(":/satellites/bt_satellites_off.p ng"); pxmapOffIcon = new QPixmap(":/satellites/bt_satellites_off.p ng");
toolbarButton = new StelButton(NULL, *pxmapOnIcon, *pxmapOff Icon, *pxmapGlow, gui->getGuiActions("actionShow_Satellite_Hints")); toolbarButton = new StelButton(NULL, *pxmapOnIcon, *pxmapOff Icon, *pxmapGlow, gui->getGuiAction("actionShow_Satellite_Hints"));
gui->getButtonBar()->addButton(toolbarButton, "065-pluginsGr oup"); gui->getButtonBar()->addButton(toolbarButton, "065-pluginsGr oup");
connect(gui->getGuiActions("actionShow_Satellite_ConfigDialo connect(gui->getGuiAction("actionShow_Satellite_ConfigDialog
g_Global"), SIGNAL(toggled(bool)), configDialog, SLOT(setVisible(bool))); _Global"), SIGNAL(toggled(bool)), configDialog, SLOT(setVisible(bool)));
connect(configDialog, SIGNAL(visibleChanged(bool)), gui->get connect(configDialog, SIGNAL(visibleChanged(bool)), gui->get
GuiActions("actionShow_Satellite_ConfigDialog_Global"), SLOT(setChecked(boo GuiAction("actionShow_Satellite_ConfigDialog_Global"), SLOT(setChecked(bool
l))); )));
connect(gui->getGuiActions("actionShow_Satellite_Hints"), SI connect(gui->getGuiAction("actionShow_Satellite_Hints"), SIG
GNAL(toggled(bool)), this, SLOT(setFlagHints(bool))); NAL(toggled(bool)), this, SLOT(setFlagHints(bool)));
connect(gui->getGuiActions("actionShow_Satellite_Labels"), S connect(gui->getGuiAction("actionShow_Satellite_Labels"), SI
IGNAL(toggled(bool)), this, SLOT(setFlagLabels(bool))); GNAL(toggled(bool)), this, SLOT(setFlagLabels(bool)));
} }
catch (std::runtime_error &e) catch (std::runtime_error &e)
{ {
qWarning() << "Satellites::init error: " << e.what(); qWarning() << "Satellites::init error: " << e.what();
return; return;
} }
// A timer for hiding alert messages // A timer for hiding alert messages
messageTimer = new QTimer(this); messageTimer = new QTimer(this);
skipping to change at line 363 skipping to change at line 368
{ {
if (!hintFader || StelApp::getInstance().getCore()->getCurrentLocati on().planetName != earth->getEnglishName()) if (!hintFader || StelApp::getInstance().getCore()->getCurrentLocati on().planetName != earth->getEnglishName())
return NULL; return NULL;
// If the search string is a catalog number... // If the search string is a catalog number...
QRegExp regExp("^(NORAD)\\s*(\\d+)\\s*$"); QRegExp regExp("^(NORAD)\\s*(\\d+)\\s*$");
if (regExp.exactMatch(noradNumber)) if (regExp.exactMatch(noradNumber))
{ {
QString numberString = regExp.capturedTexts().at(2); QString numberString = regExp.capturedTexts().at(2);
bool ok; bool ok;
int number = numberString.toInt(&ok); /* int number = */ numberString.toInt(&ok);
if (!ok) if (!ok)
return StelObjectP(); return StelObjectP();
foreach(const SatelliteP& sat, satellites) foreach(const SatelliteP& sat, satellites)
{ {
if (sat->initialized && sat->visible) if (sat->initialized && sat->visible)
{ {
if (sat->getCatalogNumberString() == numberS tring) if (sat->getCatalogNumberString() == numberS tring)
return qSharedPointerCast<StelObject >(sat); return qSharedPointerCast<StelObject >(sat);
} }
skipping to change at line 395 skipping to change at line 400
if (maxNbItem==0) return result; if (maxNbItem==0) return result;
QString objw = objPrefix.toUpper(); QString objw = objPrefix.toUpper();
QString numberPrefix; QString numberPrefix;
QRegExp regExp("^(NORAD)\\s*(\\d+)\\s*$"); QRegExp regExp("^(NORAD)\\s*(\\d+)\\s*$");
if (regExp.exactMatch(objw)) if (regExp.exactMatch(objw))
{ {
QString numberString = regExp.capturedTexts().at(2); QString numberString = regExp.capturedTexts().at(2);
bool ok; bool ok;
int number = numberString.toInt(&ok); /* int number = */ numberString.toInt(&ok);
if (ok) if (ok)
numberPrefix = numberString; numberPrefix = numberString;
} }
foreach(const SatelliteP& sat, satellites) foreach(const SatelliteP& sat, satellites)
{ {
if (sat->initialized && sat->visible) if (sat->initialized && sat->visible)
{ {
if (sat->getNameI18n().toUpper().left(objw.length()) == objw) if (sat->getNameI18n().toUpper().left(objw.length()) == objw)
{ {
result << sat->getNameI18n().toUpper(); result << sat->getNameI18n().toUpper();
} }
else if (sat->getCatalogNumberString().left(numberPr efix.length()) == numberPrefix) else if (!numberPrefix.isEmpty() && sat->getCatalogN umberString().left(numberPrefix.length()) == numberPrefix)
{ {
result << QString("NORAD %1").arg(sat->getCa talogNumberString()); result << QString("NORAD %1").arg(sat->getCa talogNumberString());
} }
} }
} }
result.sort(); result.sort();
if (result.size()>maxNbItem) result.erase(result.begin()+maxNbItem, result.end()); if (result.size()>maxNbItem) result.erase(result.begin()+maxNbItem, result.end());
return result; return result;
} }
QStringList Satellites::listAllObjects(bool inEnglish) const
{
QStringList result;
if (inEnglish)
{
foreach(const SatelliteP& sat, satellites)
{
result << sat->getEnglishName();
}
}
else
{
foreach(const SatelliteP& sat, satellites)
{
result << sat->getNameI18n();
}
}
return result;
}
bool Satellites::configureGui(bool show) bool Satellites::configureGui(bool show)
{ {
if (show) if (show)
{ {
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance() .getGui()); StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance() .getGui());
gui->getGuiActions("actionShow_Satellite_ConfigDialog_Global ")->setChecked(true); gui->getGuiAction("actionShow_Satellite_ConfigDialog_Global" )->setChecked(true);
} }
return true; return true;
} }
void Satellites::restoreDefaults(void) void Satellites::restoreDefaults(void)
{ {
restoreDefaultConfigIni(); restoreDefaultConfigIni();
restoreDefaultJsonFile(); restoreDefaultJsonFile();
readJsonFile(); readJsonFile();
skipping to change at line 506 skipping to change at line 531
} }
void Satellites::readSettingsFromConfig(void) void Satellites::readSettingsFromConfig(void)
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
conf->beginGroup("Satellites"); conf->beginGroup("Satellites");
// populate updateUrls from tle_url? keys // populate updateUrls from tle_url? keys
QRegExp keyRE("^tle_url\\d+$"); QRegExp keyRE("^tle_url\\d+$");
updateUrls.clear(); updateUrls.clear();
foreach(const QString& key, conf->childKeys()) foreach(const QString& key, conf->childKeys())
{ {
if (keyRE.exactMatch(key)) if (keyRE.exactMatch(key))
{ {
QString s = conf->value(key, "").toString(); QString s = conf->value(key, "").toString();
if (!s.isEmpty() && s!="") if (!s.isEmpty() && s!="")
updateUrls << s; updateUrls << s;
} }
} }
// updater related settings... // updater related settings...
skipping to change at line 543 skipping to change at line 568
conf->endGroup(); conf->endGroup();
} }
void Satellites::saveSettingsToConfig(void) void Satellites::saveSettingsToConfig(void)
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
conf->beginGroup("Satellites"); conf->beginGroup("Satellites");
// update tle urls... first clear the existing ones in the file // update tle urls... first clear the existing ones in the file
QRegExp keyRE("^tle_url\\d+$"); QRegExp keyRE("^tle_url\\d+$");
foreach(const QString& key, conf->childKeys()) foreach(const QString& key, conf->childKeys())
{ {
if (keyRE.exactMatch(key)) if (keyRE.exactMatch(key))
conf->remove(key); conf->remove(key);
} }
// populate updateUrls from tle_url? keys // populate updateUrls from tle_url? keys
int n=0; int n=0;
foreach(const QString& url, updateUrls) foreach(const QString& url, updateUrls)
{ {
QString key = QString("tle_url%1").arg(n++); QString key = QString("tle_url%1").arg(n++);
conf->setValue(key, url); conf->setValue(key, url);
} }
// updater related settings... // updater related settings...
conf->setValue("update_frequency_hours", updateFrequencyHours); conf->setValue("update_frequency_hours", updateFrequencyHours);
conf->setValue("show_satellite_hints", getFlagHints()); conf->setValue("show_satellite_hints", getFlagHints());
conf->setValue("show_satellite_labels", Satellite::showLabels); conf->setValue("show_satellite_labels", Satellite::showLabels);
conf->setValue("updates_enabled", updatesEnabled ); conf->setValue("updates_enabled", updatesEnabled );
skipping to change at line 686 skipping to change at line 711
numReadOk++; numReadOk++;
} }
} }
} }
QVariantMap Satellites::getTleMap(void) QVariantMap Satellites::getTleMap(void)
{ {
QVariantMap map; QVariantMap map;
QVariantList defHintCol; QVariantList defHintCol;
defHintCol << Satellite::roundToDp(defaultHintColor[0],3) defHintCol << Satellite::roundToDp(defaultHintColor[0],3)
<< Satellite::roundToDp(defaultHintColor[1],3) << Satellite::roundToDp(def
<< Satellite::roundToDp(defaultHintColor[2],3); aultHintColor[1],3)
<< Satellite::roundToDp(def
aultHintColor[2],3);
map["creator"] = QString("Satellites plugin version %1 (updated)").a rg(SATELLITES_PLUGIN_VERSION); map["creator"] = QString("Satellites plugin version %1 (updated)").a rg(SATELLITES_PLUGIN_VERSION);
map["hintColor"] = defHintCol; map["hintColor"] = defHintCol;
map["shortName"] = "satellite orbital data"; map["shortName"] = "satellite orbital data";
QVariantMap sats; QVariantMap sats;
foreach(const SatelliteP& sat, satellites) foreach(const SatelliteP& sat, satellites)
{ {
QVariantMap satMap = sat->getMap(); QVariantMap satMap = sat->getMap();
if (satMap["orbitColor"] == satMap["hintColor"]) if (satMap["orbitColor"] == satMap["hintColor"])
skipping to change at line 716 skipping to change at line 741
return map; return map;
} }
QStringList Satellites::getGroups(void) const QStringList Satellites::getGroups(void) const
{ {
QStringList groups; QStringList groups;
foreach (const SatelliteP& sat, satellites) foreach (const SatelliteP& sat, satellites)
{ {
if (sat->initialized) if (sat->initialized)
{ {
foreach(const QString& group, sat->groupIDs) foreach(const QString& group, sat->groupIDs)
{ {
if (!groups.contains(group)) if (!groups.contains(group))
groups << group; groups << group;
} }
} }
} }
return groups; return groups;
} }
QHash<QString,QString> Satellites::getSatellites(const QString& group, Stat us vis) QHash<QString,QString> Satellites::getSatellites(const QString& group, Stat us vis)
{ {
QHash<QString,QString> result; QHash<QString,QString> result;
foreach(const SatelliteP& sat, satellites) foreach(const SatelliteP& sat, satellites)
{ {
if (sat->initialized) if (sat->initialized)
{ {
if ((group.isEmpty() || sat->groupIDs.contains(group )) && ! result.contains(sat->id)) if ((group.isEmpty() || sat->groupIDs.contains(group )) && ! result.contains(sat->id))
{ {
if (vis==Both || if (vis==Both ||
(vis==Visible && sat->visible) || (vis==Visible && sat->visibl
(vis==NotVisible && !sat->visible) | e) ||
| (vis==NotVisible && !sat->vi
(vis==OrbitError && !sat->orbitValid sible) ||
) || (vis==OrbitError && !sat->or
(vis==NewlyAdded && sat->isNew())) bitValid) ||
(vis==NewlyAdded && sat->isN
ew()))
result.insert(sat->id, sat->name); result.insert(sat->id, sat->name);
} }
} }
} }
return result; return result;
} }
SatelliteP Satellites::getByID(const QString& id) SatelliteP Satellites::getByID(const QString& id)
{ {
foreach(const SatelliteP& sat, satellites) foreach(const SatelliteP& sat, satellites)
skipping to change at line 774 skipping to change at line 799
result.append(sat->id); result.append(sat->id);
} }
return result; return result;
} }
void Satellites::add(const TleDataList& newSatellites) void Satellites::add(const TleDataList& newSatellites)
{ {
int numAdded = 0; int numAdded = 0;
QVariantList defaultHintColorMap; QVariantList defaultHintColorMap;
defaultHintColorMap << defaultHintColor[0] << defaultHintColor[1] defaultHintColorMap << defaultHintColor[0] << defaultHintColor[1]
<< defaultHintColor[2]; << defaultHintColor[2];
foreach (const TleData& tleSet, newSatellites) foreach (const TleData& tleSet, newSatellites)
{ {
//TODO: Duplicates check? --BM //TODO: Duplicates check? --BM
if (tleSet.id.isEmpty() || if (tleSet.id.isEmpty() ||
tleSet.name.isEmpty() || tleSet.name.isEmpty() ||
tleSet.first.isEmpty() || tleSet.first.isEmpty() ||
tleSet.second.isEmpty()) tleSet.second.isEmpty())
continue; continue;
QVariantMap satProperties; QVariantMap satProperties;
satProperties.insert("name", tleSet.name); satProperties.insert("name", tleSet.name);
satProperties.insert("tle1", tleSet.first); satProperties.insert("tle1", tleSet.first);
satProperties.insert("tle2", tleSet.second); satProperties.insert("tle2", tleSet.second);
satProperties.insert("hintColor", defaultHintColorMap); satProperties.insert("hintColor", defaultHintColorMap);
//TODO: Decide if newly added satellites are visible by defa ult --BM //TODO: Decide if newly added satellites are visible by defa ult --BM
satProperties.insert("visible", true); satProperties.insert("visible", true);
satProperties.insert("orbitVisible", false); satProperties.insert("orbitVisible", false);
skipping to change at line 805 skipping to change at line 830
SatelliteP sat(new Satellite(tleSet.id, satProperties)); SatelliteP sat(new Satellite(tleSet.id, satProperties));
if (sat->initialized) if (sat->initialized)
{ {
qDebug() << "Satellites: added" << tleSet.id << tleS et.name; qDebug() << "Satellites: added" << tleSet.id << tleS et.name;
satellites.append(sat); satellites.append(sat);
sat->setNew(); sat->setNew();
numAdded++; numAdded++;
} }
} }
qDebug() << "Satellites: " qDebug() << "Satellites: "
<< newSatellites.count() << "satellites proposed for additi << newSatellites.count() << "satell
on, " ites proposed for addition, "
<< numAdded << " added, " << numAdded << " added, "
<< satellites.count() << " total after the operation."; << satellites.count() << " total af
ter the operation.";
} }
void Satellites::remove(const QStringList& idList) void Satellites::remove(const QStringList& idList)
{ {
StelObjectMgr* objMgr = GETSTELMODULE(StelObjectMgr); StelObjectMgr* objMgr = GETSTELMODULE(StelObjectMgr);
int numRemoved = 0; int numRemoved = 0;
for (int i = 0; i < satellites.size(); i++) for (int i = 0; i < satellites.size(); i++)
{ {
const SatelliteP& sat = satellites.at(i); const SatelliteP& sat = satellites.at(i);
if (idList.contains(sat->id)) if (idList.contains(sat->id))
skipping to change at line 831 skipping to change at line 856
objMgr->unSelect(); objMgr->unSelect();
qDebug() << "Satellite removed:" << sat->id << sat-> name; qDebug() << "Satellite removed:" << sat->id << sat-> name;
satellites.removeAt(i); satellites.removeAt(i);
i--; //Compensate for the change in the array's inde xing i--; //Compensate for the change in the array's inde xing
numRemoved++; numRemoved++;
} }
} }
qDebug() << "Satellites: " qDebug() << "Satellites: "
<< idList.count() << "satellites proposed for removal, " << idList.count() << "satellites pr
<< numRemoved << " removed, " oposed for removal, "
<< satellites.count() << " remain."; << numRemoved << " removed, "
<< satellites.count() << " remain."
;
} }
int Satellites::getSecondsToUpdate(void) int Satellites::getSecondsToUpdate(void)
{ {
QDateTime nextUpdate = lastUpdate.addSecs(updateFrequencyHours * 360 0); QDateTime nextUpdate = lastUpdate.addSecs(updateFrequencyHours * 360 0);
return QDateTime::currentDateTime().secsTo(nextUpdate); return QDateTime::currentDateTime().secsTo(nextUpdate);
} }
void Satellites::setTleSources(QStringList tleSources) void Satellites::setTleSources(QStringList tleSources)
{ {
updateUrls = tleSources; updateUrls = tleSources;
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
conf->beginGroup("Satellites"); conf->beginGroup("Satellites");
// clear old source list // clear old source list
QRegExp keyRE("^tle_url\\d+$"); QRegExp keyRE("^tle_url\\d+$");
foreach(const QString& key, conf->childKeys()) foreach(const QString& key, conf->childKeys())
{ {
if (keyRE.exactMatch(key)) if (keyRE.exactMatch(key))
conf->remove(key); conf->remove(key);
} }
// set the new sources list // set the new sources list
int i=0; int i=0;
foreach (const QString& url, updateUrls) foreach (const QString& url, updateUrls)
{ {
conf->setValue(QString("tle_url%1").arg(i++), url); conf->setValue(QString("tle_url%1").arg(i++), url);
} }
conf->endGroup(); conf->endGroup();
} }
bool Satellites::getFlagLabels(void) bool Satellites::getFlagLabels(void)
{ {
return Satellite::showLabels; return Satellite::showLabels;
skipping to change at line 996 skipping to change at line 1021
} }
void Satellites::displayMessage(const QString& message, const QString hexCo lor) void Satellites::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();
} }
void Satellites::messageTimeout(void) void Satellites::messageTimeout(void)
{ {
foreach(const int& id, messageIDs) foreach(const int& id, messageIDs)
{ {
GETSTELMODULE(LabelMgr)->deleteLabel(id); GETSTELMODULE(LabelMgr)->deleteLabel(id);
} }
} }
void Satellites::saveTleData(QString path) void Satellites::saveTleData(QString path)
{ {
saveTleMap(getTleMap(), path); saveTleMap(getTleMap(), path);
} }
void Satellites::updateFromFiles(QStringList paths, bool deleteFiles) void Satellites::updateFromFiles(QStringList paths, bool deleteFiles)
{ {
skipping to change at line 1048 skipping to change at line 1073
int totalSats = 0; int totalSats = 0;
int numMissing = 0; int numMissing = 0;
foreach(const SatelliteP& sat, satellites) foreach(const SatelliteP& sat, satellites)
{ {
totalSats++; totalSats++;
QString id = sat->id; QString id = sat->id;
if (newTleSets.contains(id)) if (newTleSets.contains(id))
{ {
TleData newTle = newTleSets.value(id); TleData newTle = newTleSets.value(id);
if (sat->tleElements.first != newTle.first || if (sat->tleElements.first != newTle.first ||
sat->tleElements.second != newTle.second || sat->tleElements.second != newTle.se
sat->name != newTle.name) cond ||
sat->name != newTle.name)
{ {
// We have updated TLE elements for this sat ellite // We have updated TLE elements for this sat ellite
sat->setNewTleElements(newTle.first, newTle. second); sat->setNewTleElements(newTle.first, newTle. second);
// Update the name if it has been changed in the source list // Update the name if it has been changed in the source list
sat->name = newTle.name; sat->name = newTle.name;
// we reset this to "now" when we started th e update. // we reset this to "now" when we started th e update.
sat->lastUpdated = lastUpdate; sat->lastUpdated = lastUpdate;
numUpdated++; numUpdated++;
} }
} }
else else
{ {
qWarning() << "Satellites: could not update orbital elements for" qWarning() << "Satellites: could not update orbital elements for"
<< sat->name << sat->nam
<< sat->id e
<< ": no entry found in the source TLE li << sat->id
sts."; << ": no en
try found in the source TLE lists.";
numMissing++; numMissing++;
} }
} }
if (numUpdated>0) if (numUpdated>0)
{ {
saveTleMap(getTleMap()); saveTleMap(getTleMap());
} }
delete progressBar; delete progressBar;
progressBar = NULL; progressBar = NULL;
qDebug() << "Satellites: updated" << numUpdated << "/" << totalSats qDebug() << "Satellites: updated" << numUpdated << "/" << totalSats
<< "satellites. Update URLs contained" << newTleSets.size( << "satellites. Update URLs contai
) << "objects. " ned" << newTleSets.size() << "objects. "
<< "There were" << numMissing << "satellies missing from th << "There were" << numMissing << "s
e update URLs"; atellies missing from the update URLs";
if (numUpdated==0) if (numUpdated==0)
updateState = CompleteNoUpdates; updateState = CompleteNoUpdates;
else else
updateState = CompleteUpdates; updateState = CompleteUpdates;
emit(updateStateChanged(updateState)); emit(updateStateChanged(updateState));
emit(tleUpdateComplete(numUpdated, totalSats, numMissing)); emit(tleUpdateComplete(numUpdated, totalSats, numMissing));
} }
skipping to change at line 1132 skipping to change at line 1157
// The Satellite Catalog Number is the secon d number // The Satellite Catalog Number is the secon d number
// on the second line. // on the second line.
QString id = line.split(' ').at(1).trimmed() ; QString id = line.split(' ').at(1).trimmed() ;
if (id.isEmpty()) if (id.isEmpty())
continue; continue;
lastData.id = id; lastData.id = id;
// This is the second line and there will be no more, // This is the second line and there will be no more,
// so if everything is OK, save the elements . // so if everything is OK, save the elements .
if (!lastData.name.isEmpty() && if (!lastData.name.isEmpty() &&
!lastData.first.isEmpty()) !lastData.first.isEmpty())
{ {
//TODO: This overwrites duplicates. Display warning? --BM //TODO: This overwrites duplicates. Display warning? --BM
tleList.insert(id, lastData); tleList.insert(id, lastData);
} }
//TODO: Error warnings? --BM //TODO: Error warnings? --BM
} }
else else
qDebug() << "Satellites: unprocessed line " << lineNumber << " in file " << openFile.fileName(); qDebug() << "Satellites: unprocessed line " << lineNumber << " in file " << openFile.fileName();
} }
} }
skipping to change at line 1159 skipping to change at line 1184
hintFader.update((int)(deltaTime*1000)); hintFader.update((int)(deltaTime*1000));
foreach(const SatelliteP& sat, satellites) foreach(const SatelliteP& sat, satellites)
{ {
if (sat->initialized && sat->visible) if (sat->initialized && sat->visible)
sat->update(deltaTime); sat->update(deltaTime);
} }
} }
void Satellites::draw(StelCore* core) void Satellites::draw(StelCore* core, StelRenderer* renderer)
{ {
if (core->getCurrentLocation().planetName != earth->getEnglishName() || if (core->getCurrentLocation().planetName != earth->getEnglishName() ||
(core->getJDay()<2436116.3115) || // do not draw anything before Oct 4, 1957, 19:28:34GMT ;-) (core->getJDay()<2436116.3115) || // do not draw anything before Oct 4, 1957, 19:28:34GMT ;-)
(!hintFader && hintFader.getInterstate() <= 0.)) (!hintFader && hintFader.getInterstate() <= 0.))
return; return;
StelProjectorP prj = core->getProjection(StelCore::FrameAltAz); StelProjectorP prj = core->getProjection(StelCore::FrameAltAz);
StelPainter painter(prj); renderer->setFont(labelFont);
painter.setFont(labelFont);
Satellite::hintBrightness = hintFader.getInterstate(); Satellite::hintBrightness = hintFader.getInterstate();
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); renderer->setBlendMode(BlendMode_Alpha);
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D); if(NULL == hintTexture)
Satellite::hintTexture->bind(); {
Satellite::viewportHalfspace = painter.getProjector()->getBoundingCa hintTexture = renderer->createTexture(":/satellites/hint.png
p(); ");
}
hintTexture->bind();
Satellite::viewportHalfspace = prj->getBoundingCap();
foreach (const SatelliteP& sat, satellites) foreach (const SatelliteP& sat, satellites)
{ {
if (sat && sat->initialized && sat->visible) if (sat && sat->initialized && sat->visible)
sat->draw(core, painter, 1.0); {
sat->draw(core, renderer, prj, hintTexture);
}
} }
if (GETSTELMODULE(StelObjectMgr)->getFlagSelectedObjectPointer()) if (GETSTELMODULE(StelObjectMgr)->getFlagSelectedObjectPointer())
drawPointer(core, painter); {
drawPointer(core, renderer);
}
} }
void Satellites::drawPointer(StelCore* core, StelPainter& painter) void Satellites::drawPointer(StelCore* core, StelRenderer* renderer)
{ {
const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000) ; const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000) ;
const QList<StelObjectP> newSelected = GETSTELMODULE(StelObjectMgr)- >getSelectedObject("Satellite"); const QList<StelObjectP> newSelected = GETSTELMODULE(StelObjectMgr)- >getSelectedObject("Satellite");
if (!newSelected.empty()) if (!newSelected.empty())
{ {
const StelObjectP obj = newSelected[0]; const StelObjectP obj = newSelected[0];
Vec3d pos=obj->getJ2000EquatorialPos(core); Vec3d pos=obj->getJ2000EquatorialPos(core);
Vec3d screenpos; Vec3d screenpos;
// Compute 2D pos and return if outside screen // Compute 2D pos and return if outside screen
if (!prj->project(pos, screenpos)) if (!prj->project(pos, screenpos))
{
return; return;
}
if(NULL == texPointer)
{
texPointer = renderer->createTexture("textures/point
eur5.png");
}
if (StelApp::getInstance().getVisionModeNight()) if (StelApp::getInstance().getVisionModeNight())
glColor3f(0.8f,0.0f,0.0f); renderer->setGlobalColor(0.8f,0.0f,0.0f);
else else
glColor3f(0.4f,0.5f,0.8f); renderer->setGlobalColor(0.4f,0.5f,0.8f);
texPointer->bind(); texPointer->bind();
glEnable(GL_TEXTURE_2D); renderer->setBlendMode(BlendMode_Alpha);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal
transparency mode
// Size on screen // Size on screen
float size = obj->getAngularSize(core)*M_PI/180.*prj->getPix elPerRadAtCenter(); float size = obj->getAngularSize(core)*M_PI/180.*prj->getPix elPerRadAtCenter();
size += 12.f + 3.f*std::sin(2.f * StelApp::getInstance().get TotalRunTime()); size += 12.f + 3.f*std::sin(2.f * StelApp::getInstance().get TotalRunTime());
// size+=20.f + 10.f*std::sin(2.f * StelApp::getInstance().g const float halfSize = size * 0.5;
etTotalRunTime()); const float left = screenpos[0] - halfSize - 20;
painter.drawSprite2dMode(screenpos[0]-size/2, screenpos[1]-s const float right = screenpos[0] + halfSize - 20;
ize/2, 20, 90); const float top = screenpos[1] - halfSize - 20;
painter.drawSprite2dMode(screenpos[0]-size/2, screenpos[1]+s const float bottom = screenpos[1] + halfSize - 20;
ize/2, 20, 0); renderer->drawTexturedRect(left, top, 40, 40, 90);
painter.drawSprite2dMode(screenpos[0]+size/2, screenpos[1]+s renderer->drawTexturedRect(left, bottom, 40, 40, 0);
ize/2, 20, -90); renderer->drawTexturedRect(right, bottom, 40, 40, -90);
painter.drawSprite2dMode(screenpos[0]+size/2, screenpos[1]-s renderer->drawTexturedRect(right, top, 40, 40, -180);
ize/2, 20, -180);
} }
} }
 End of changes. 47 change blocks. 
117 lines changed or deleted 151 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/