Satellites.cpp   Satellites.cpp 
skipping to change at line 26 skipping to change at line 26
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelPainter.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 "StelNavigator.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 "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"
skipping to change at line 191 skipping to change at line 190
updateTimer = new QTimer(this); updateTimer = new QTimer(this);
updateTimer->setSingleShot(false); // recurring check for update updateTimer->setSingleShot(false); // recurring check for update
updateTimer->setInterval(13000); // check once every 13 seconds to see if it is time for an update updateTimer->setInterval(13000); // check once every 13 seconds to see if it is time for an update
connect(updateTimer, SIGNAL(timeout()), this, SLOT(checkForUpdate()) ); connect(updateTimer, SIGNAL(timeout()), this, SLOT(checkForUpdate()) );
updateTimer->start(); updateTimer->start();
earth = GETSTELMODULE(SolarSystem)->getEarth(); earth = GETSTELMODULE(SolarSystem)->getEarth();
GETSTELMODULE(StelObjectMgr)->registerStelObjectMgr(this); GETSTELMODULE(StelObjectMgr)->registerStelObjectMgr(this);
// Handle changes to the observer location: // Handle changes to the observer location:
connect(StelApp::getInstance().getCore()->getNavigator(), SIGNAL(loc ationChanged(StelLocation)), this, SLOT(observerLocationChanged(StelLocatio n))); connect(StelApp::getInstance().getCore(), SIGNAL(locationChanged(Ste lLocation)), this, SLOT(observerLocationChanged(StelLocation)));
//Load the module's custom style sheets //Load the module's custom style sheets
QFile styleSheetFile; QFile styleSheetFile;
styleSheetFile.setFileName(":/satellites/normalStyle.css"); styleSheetFile.setFileName(":/satellites/normalStyle.css");
if(styleSheetFile.open(QFile::ReadOnly|QFile::Text)) if(styleSheetFile.open(QFile::ReadOnly|QFile::Text))
{ {
normalStyleSheet = styleSheetFile.readAll(); normalStyleSheet = styleSheetFile.readAll();
} }
styleSheetFile.close(); styleSheetFile.close();
styleSheetFile.setFileName(":/satellites/nightStyle.css"); styleSheetFile.setFileName(":/satellites/nightStyle.css");
if(styleSheetFile.open(QFile::ReadOnly|QFile::Text)) if(styleSheetFile.open(QFile::ReadOnly|QFile::Text))
{ {
nightStyleSheet = styleSheetFile.readAll(); nightStyleSheet = styleSheetFile.readAll();
} }
styleSheetFile.close(); styleSheetFile.close();
connect(&StelApp::getInstance(), SIGNAL(colorSchemeChanged(const QSt ring&)), this, SLOT(setStelStyle(const QString&)));
} }
bool Satellites::backupJsonFile(bool deleteOriginal) bool Satellites::backupJsonFile(bool deleteOriginal)
{ {
QFile old(satellitesJsonPath); QFile old(satellitesJsonPath);
if (!old.exists()) if (!old.exists())
{ {
qWarning() << "Satellites::backupJsonFile no file to backup" ; qWarning() << "Satellites::backupJsonFile no file to backup" ;
return false; return false;
} }
skipping to change at line 278 skipping to change at line 278
double Satellites::getCallOrder(StelModuleActionName actionName) const double Satellites::getCallOrder(StelModuleActionName actionName) const
{ {
if (actionName==StelModule::ActionDraw) if (actionName==StelModule::ActionDraw)
return StelApp::getInstance().getModuleMgr().getModule("Sola rSystem")->getCallOrder(actionName)+1.; return StelApp::getInstance().getModuleMgr().getModule("Sola rSystem")->getCallOrder(actionName)+1.;
return 0; return 0;
} }
QList<StelObjectP> Satellites::searchAround(const Vec3d& av, double limitFo v, const StelCore*) const QList<StelObjectP> Satellites::searchAround(const Vec3d& av, double limitFo v, const StelCore*) const
{ {
QList<StelObjectP> result; QList<StelObjectP> result;
if (!hintFader || StelApp::getInstance().getCore()->getNavigator()-> getCurrentLocation().planetName != earth->getEnglishName()) if (!hintFader || StelApp::getInstance().getCore()->getCurrentLocati on().planetName != earth->getEnglishName())
return result; return result;
Vec3d v(av); Vec3d v(av);
v.normalize(); v.normalize();
double cosLimFov = cos(limitFov * M_PI/180.); double cosLimFov = cos(limitFov * M_PI/180.);
Vec3d equPos; Vec3d equPos;
foreach(const SatelliteP& sat, satellites) foreach(const SatelliteP& sat, satellites)
{ {
if (sat->initialized && sat->visible) if (sat->initialized && sat->visible)
skipping to change at line 303 skipping to change at line 303
{ {
result.append(qSharedPointerCast<StelObject> (sat)); result.append(qSharedPointerCast<StelObject> (sat));
} }
} }
} }
return result; return result;
} }
StelObjectP Satellites::searchByNameI18n(const QString& nameI18n) const StelObjectP Satellites::searchByNameI18n(const QString& nameI18n) const
{ {
if (!hintFader || StelApp::getInstance().getCore()->getNavigator()-> getCurrentLocation().planetName != earth->getEnglishName()) if (!hintFader || StelApp::getInstance().getCore()->getCurrentLocati on().planetName != earth->getEnglishName())
return NULL; return NULL;
QString objw = nameI18n.toUpper(); QString objw = nameI18n.toUpper();
foreach(const SatelliteP& sat, satellites) foreach(const SatelliteP& sat, satellites)
{ {
if (sat->initialized && sat->visible) if (sat->initialized && sat->visible)
{ {
if (sat->getNameI18n().toUpper() == nameI18n) if (sat->getNameI18n().toUpper() == nameI18n)
return qSharedPointerCast<StelObject>(sat); return qSharedPointerCast<StelObject>(sat);
} }
} }
return NULL; return NULL;
} }
StelObjectP Satellites::searchByName(const QString& englishName) const StelObjectP Satellites::searchByName(const QString& englishName) const
{ {
if (!hintFader || StelApp::getInstance().getCore()->getNavigator()-> getCurrentLocation().planetName != earth->getEnglishName()) if (!hintFader || StelApp::getInstance().getCore()->getCurrentLocati on().planetName != earth->getEnglishName())
return NULL; return NULL;
QString objw = englishName.toUpper(); QString objw = englishName.toUpper();
foreach(const SatelliteP& sat, satellites) foreach(const SatelliteP& sat, satellites)
{ {
if (sat->initialized && sat->visible) if (sat->initialized && sat->visible)
{ {
if (sat->getEnglishName().toUpper() == englishName) if (sat->getEnglishName().toUpper() == englishName)
return qSharedPointerCast<StelObject>(sat); return qSharedPointerCast<StelObject>(sat);
} }
} }
return NULL; return NULL;
} }
QStringList Satellites::listMatchingObjectsI18n(const QString& objPrefix, i nt maxNbItem) const QStringList Satellites::listMatchingObjectsI18n(const QString& objPrefix, i nt maxNbItem) const
{ {
QStringList result; QStringList result;
if (!hintFader || StelApp::getInstance().getCore()->getNavigator()-> getCurrentLocation().planetName != earth->getEnglishName()) if (!hintFader || StelApp::getInstance().getCore()->getCurrentLocati on().planetName != earth->getEnglishName())
return result; return result;
if (maxNbItem==0) return result; if (maxNbItem==0) return result;
QString objw = objPrefix.toUpper(); QString objw = objPrefix.toUpper();
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)
skipping to change at line 446 skipping to change at line 446
} }
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(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 483 skipping to change at line 483
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(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(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 602 skipping to change at line 602
defaultHintColorMap << defaultHintColor[0] << defaultHintColor[1] << defaultHintColor[2]; defaultHintColorMap << defaultHintColor[0] << defaultHintColor[1] << defaultHintColor[2];
if (map.contains("hintColor")) if (map.contains("hintColor"))
{ {
defaultHintColorMap = map.value("hintColor").toList(); defaultHintColorMap = map.value("hintColor").toList();
defaultHintColor.set(defaultHintColorMap.at(0).toDouble(), d efaultHintColorMap.at(1).toDouble(), defaultHintColorMap.at(2).toDouble()); defaultHintColor.set(defaultHintColorMap.at(0).toDouble(), d efaultHintColorMap.at(1).toDouble(), defaultHintColorMap.at(2).toDouble());
} }
satellites.clear(); satellites.clear();
QVariantMap satMap = map.value("satellites").toMap(); QVariantMap satMap = map.value("satellites").toMap();
foreach(QString designation, satMap.keys()) foreach(const QString& designation, satMap.keys())
{ {
QVariantMap satData = satMap.value(designation).toMap(); QVariantMap satData = satMap.value(designation).toMap();
satData["designation"] = designation; satData["designation"] = designation;
if (!satData.contains("hintColor")) if (!satData.contains("hintColor"))
satData["hintColor"] = defaultHintColorMap; satData["hintColor"] = defaultHintColorMap;
if (!satData.contains("orbitColor")) if (!satData.contains("orbitColor"))
satData["orbitColor"] = satData["hintColor"]; satData["orbitColor"] = satData["hintColor"];
skipping to change at line 660 skipping to change at line 660
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(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;
} }
QStringList Satellites::getSatellites(const QString& group, Visibility vis) QStringList Satellites::getSatellites(const QString& group, Visibility vis)
skipping to change at line 710 skipping to change at line 710
} }
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(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 (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 824 skipping to change at line 824
if (progressBar) if (progressBar)
progressBar->setValue(numberDownloadsComplete); progressBar->setValue(numberDownloadsComplete);
// all downloads are complete... do the update. // all downloads are complete... do the update.
if (numberDownloadsComplete >= updateUrls.size()) if (numberDownloadsComplete >= updateUrls.size())
{ {
updateFromFiles(updateFiles, true); updateFromFiles(updateFiles, true);
} }
} }
void Satellites::observerLocationChanged(StelLocation loc) void Satellites::observerLocationChanged(StelLocation)
{ {
foreach(const SatelliteP& sat, satellites)
{
if (sat->initialized && sat->visible)
sat->setObserverLocation(&loc);
}
recalculateOrbitLines(); recalculateOrbitLines();
} }
void Satellites::setOrbitLinesFlag(bool b) void Satellites::setOrbitLinesFlag(bool b)
{ {
Satellite::orbitLinesFlag = b; Satellite::orbitLinesFlag = b;
} }
bool Satellites::getOrbitLinesFlag(void) bool Satellites::getOrbitLinesFlag(void)
{ {
skipping to change at line 861 skipping to change at line 856
} }
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(int i, messageIDs) foreach(const int& id, messageIDs)
{ {
GETSTELMODULE(LabelMgr)->deleteLabel(i); 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)
{ {
// define a map of new TLE data - the key is the satellite designati on // define a map of new TLE data - the key is the satellite designati on
QMap< QString, QPair<QString, QString> > newTLE; QMap< QString, QPair<QString, QString> > newTLE;
if (progressBar) if (progressBar)
{ {
progressBar->setValue(0); progressBar->setValue(0);
progressBar->setMaximum(paths.size() + 1); progressBar->setMaximum(paths.size() + 1);
progressBar->setFormat("TLE updating %v/%m"); progressBar->setFormat("TLE updating %v/%m");
} }
foreach(QString tleFilePath, paths) foreach(const QString& tleFilePath, paths)
{ {
QFile tleFile(tleFilePath); QFile tleFile(tleFilePath);
if (tleFile.open(QIODevice::ReadOnly|QIODevice::Text)) if (tleFile.open(QIODevice::ReadOnly|QIODevice::Text))
{ {
int lineNumber = 0; int lineNumber = 0;
QString thisSatId(""); QString thisSatId("");
QPair<QString, QString> tleLines; QPair<QString, QString> tleLines;
while (!tleFile.atEnd()) { while (!tleFile.atEnd()) {
QString line = QString(tleFile.readLine()).t rimmed(); QString line = QString(tleFile.readLine()).t rimmed();
if (line.length() < 65) // this is a new des ignation if (line.length() < 65) // this is a new des ignation
skipping to change at line 980 skipping to change at line 975
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));
} }
void Satellites::update(double deltaTime) void Satellites::update(double deltaTime)
{ {
if (StelApp::getInstance().getCore()->getNavigator()->getCurrentLoca tion().planetName != earth->getEnglishName() || (!hintFader && hintFader.ge tInterstate() <= 0.)) if (StelApp::getInstance().getCore()->getCurrentLocation().planetNam e != earth->getEnglishName() || (!hintFader && hintFader.getInterstate() <= 0.))
return; return;
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)
{ {
if (core->getNavigator()->getCurrentLocation().planetName != earth-> getEnglishName() || (!hintFader && hintFader.getInterstate() <= 0.)) if (core->getCurrentLocation().planetName != earth->getEnglishName() || (!hintFader && hintFader.getInterstate() <= 0.))
return; return;
StelProjectorP prj = core->getProjection(StelCore::FrameAltAz); StelProjectorP prj = core->getProjection(StelCore::FrameAltAz);
StelPainter painter(prj); StelPainter painter(prj);
painter.setFont(labelFont); painter.setFont(labelFont);
Satellite::hintBrightness = hintFader.getInterstate(); Satellite::hintBrightness = hintFader.getInterstate();
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
skipping to change at line 1019 skipping to change at line 1014
if (sat && sat->initialized && sat->visible) if (sat && sat->initialized && sat->visible)
sat->draw(core, painter, 1.0); sat->draw(core, painter, 1.0);
} }
if (GETSTELMODULE(StelObjectMgr)->getFlagSelectedObjectPointer()) if (GETSTELMODULE(StelObjectMgr)->getFlagSelectedObjectPointer())
drawPointer(core, painter); drawPointer(core, painter);
} }
void Satellites::drawPointer(StelCore* core, StelPainter& painter) void Satellites::drawPointer(StelCore* core, StelPainter& painter)
{ {
const StelNavigator* nav = core->getNavigator();
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(nav); 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;
glColor3f(0.4f,0.5f,0.8f); glColor3f(0.4f,0.5f,0.8f);
texPointer->bind(); texPointer->bind();
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND); glEnable(GL_BLEND);
 End of changes. 23 change blocks. 
26 lines changed or deleted 20 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/