Satellites.cpp   Satellites.cpp 
skipping to change at line 77 skipping to change at line 77
info.id = "Satellites"; info.id = "Satellites";
info.displayedName = N_("Satellites"); info.displayedName = N_("Satellites");
info.authors = "Matthew Gates, Jose Luis Canales, Bogdan Marinov"; info.authors = "Matthew Gates, Jose Luis Canales, Bogdan Marinov";
info.contact = "http://stellarium.org/"; info.contact = "http://stellarium.org/";
info.description = N_("Prediction of artificial satellite positions in Earth orbit based on NORAD TLE data"); info.description = N_("Prediction of artificial satellite positions in Earth orbit based on NORAD TLE data");
info.version = SATELLITES_PLUGIN_VERSION; info.version = SATELLITES_PLUGIN_VERSION;
return info; return info;
} }
Satellites::Satellites() Satellites::Satellites()
: satelliteListModel(NULL) : satelliteListModel(Q_NULLPTR)
, toolbarButton(NULL) , toolbarButton(Q_NULLPTR)
, earth(NULL) , earth(Q_NULLPTR)
, defaultHintColor(0.0f, 0.4f, 0.6f) , defaultHintColor(0.0f, 0.4f, 0.6f)
, defaultOrbitColor(0.0f, 0.3f, 0.6f) , defaultOrbitColor(0.0f, 0.3f, 0.6f)
, updateState(CompleteNoUpdates) , updateState(CompleteNoUpdates)
, downloadMgr(NULL) , downloadMgr(Q_NULLPTR)
, progressBar(NULL) , progressBar(Q_NULLPTR)
, numberDownloadsComplete(0) , numberDownloadsComplete(0)
, updateTimer(0) , updateTimer(Q_NULLPTR)
, updatesEnabled(false) , updatesEnabled(false)
, autoAddEnabled(false) , autoAddEnabled(false)
, autoRemoveEnabled(false) , autoRemoveEnabled(false)
, updateFrequencyHours(0) , updateFrequencyHours(0)
, messageTimer(0) , messageTimer(Q_NULLPTR)
, iridiumFlaresPredictionDepth(7) , iridiumFlaresPredictionDepth(7)
{ {
setObjectName("Satellites"); setObjectName("Satellites");
configDialog = new SatellitesDialog(); configDialog = new SatellitesDialog();
} }
void Satellites::deinit() void Satellites::deinit()
{ {
Satellite::hintTexture.clear(); Satellite::hintTexture.clear();
texPointer.clear(); texPointer.clear();
skipping to change at line 149 skipping to change at line 149
Satellite::hintTexture = StelApp::getInstance().getTextureMa nager().createTexture(":/satellites/hint.png"); Satellite::hintTexture = StelApp::getInstance().getTextureMa nager().createTexture(":/satellites/hint.png");
// key bindings and other actions // key bindings and other actions
QString satGroup = N_("Satellites"); QString satGroup = N_("Satellites");
addAction("actionShow_Satellite_Hints", satGroup, N_("Satell ite hints"), "hintsVisible", "Ctrl+Z"); addAction("actionShow_Satellite_Hints", satGroup, N_("Satell ite hints"), "hintsVisible", "Ctrl+Z");
addAction("actionShow_Satellite_Labels", satGroup, N_("Satel lite labels"), "labelsVisible", "Alt+Shift+Z"); addAction("actionShow_Satellite_Labels", satGroup, N_("Satel lite labels"), "labelsVisible", "Alt+Shift+Z");
addAction("actionShow_Satellite_ConfigDialog_Global", satGro up, N_("Satellites configuration window"), configDialog, "visible", "Alt+Z" ); addAction("actionShow_Satellite_ConfigDialog_Global", satGro up, N_("Satellites configuration window"), configDialog, "visible", "Alt+Z" );
// Gui toolbar button // Gui toolbar button
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance() .getGui()); StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance() .getGui());
if (gui!=NULL) if (gui!=Q_NULLPTR)
{ {
toolbarButton = new StelButton(NULL, toolbarButton = new StelButton(Q_NULLPTR,
QPixmap(":/satellites /bt_satellites_on.png"), QPixmap(":/satellites /bt_satellites_on.png"),
QPixmap(":/satellites /bt_satellites_off.png"), QPixmap(":/satellites /bt_satellites_off.png"),
QPixmap(":/graphicGui /glow32x32.png"), QPixmap(":/graphicGui /glow32x32.png"),
"actionShow_Satellite _Hints"); "actionShow_Satellite _Hints");
gui->getButtonBar()->addButton(toolbarButton, "065-p luginsGroup"); gui->getButtonBar()->addButton(toolbarButton, "065-p luginsGroup");
} }
} }
catch (std::runtime_error &e) catch (std::runtime_error &e)
{ {
qWarning() << "[Satellites] init error: " << e.what(); qWarning() << "[Satellites] init error: " << e.what();
skipping to change at line 256 skipping to change at line 256
return true; return true;
} }
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* core) const
{ {
QList<StelObjectP> result; QList<StelObjectP> result;
if (!hintFader || StelApp::getInstance().getCore()->getCurrentLocati if (!hintFader)
on().planetName != earth->getEnglishName() || !isValidRangeDates()) return result;
if (qAbs(core->getTimeRate())>=Satellite::timeRateLimit) // Do not s
how satellites when time rate is over limit
return result;
if (core->getCurrentPlanet()!=earth || !isValidRangeDates(core))
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->displayed) if (sat->initialized && sat->displayed)
skipping to change at line 284 skipping to change at line 290
{ {
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()->getCurrentLocati if (!hintFader)
on().planetName != earth->getEnglishName() || !isValidRangeDates()) return Q_NULLPTR;
return NULL;
StelCore* core = StelApp::getInstance().getCore();
if (qAbs(core->getTimeRate())>=Satellite::timeRateLimit) // Do not s
how satellites when time rate is over limit
return Q_NULLPTR;
if (core->getCurrentPlanet()!=earth || !isValidRangeDates(core))
return Q_NULLPTR;
QString objw = nameI18n.toUpper(); QString objw = nameI18n.toUpper();
StelObjectP result = searchByNoradNumber(objw); StelObjectP result = searchByNoradNumber(objw);
if (result) if (result)
return result; return result;
foreach(const SatelliteP& sat, satellites) foreach(const SatelliteP& sat, satellites)
{ {
if (sat->initialized && sat->displayed) if (sat->initialized && sat->displayed)
{ {
if (sat->getNameI18n().toUpper() == objw) if (sat->getNameI18n().toUpper() == objw)
return qSharedPointerCast<StelObject>(sat); return qSharedPointerCast<StelObject>(sat);
} }
} }
return NULL; return Q_NULLPTR;
} }
StelObjectP Satellites::searchByName(const QString& englishName) const StelObjectP Satellites::searchByName(const QString& englishName) const
{ {
if (!hintFader || StelApp::getInstance().getCore()->getCurrentLocati if (!hintFader)
on().planetName != earth->getEnglishName() || !isValidRangeDates()) return Q_NULLPTR;
return NULL;
StelCore* core = StelApp::getInstance().getCore();
if (qAbs(core->getTimeRate())>=Satellite::timeRateLimit) // Do not s
how satellites when time rate is over limit
return Q_NULLPTR;
if (core->getCurrentPlanet()!=earth || !isValidRangeDates(core))
return Q_NULLPTR;
QString objw = englishName.toUpper(); QString objw = englishName.toUpper();
StelObjectP result = searchByNoradNumber(objw); StelObjectP result = searchByNoradNumber(objw);
if (result) if (result)
return result; return result;
foreach(const SatelliteP& sat, satellites) foreach(const SatelliteP& sat, satellites)
{ {
if (sat->initialized && sat->displayed) if (sat->initialized && sat->displayed)
{ {
if (sat->getEnglishName().toUpper() == objw) if (sat->getEnglishName().toUpper() == objw)
return qSharedPointerCast<StelObject>(sat); return qSharedPointerCast<StelObject>(sat);
} }
} }
return NULL; return Q_NULLPTR;
}
StelObjectP Satellites::searchByID(const QString &id) const
{
foreach(const SatelliteP& sat, satellites)
{
if (sat->initialized && sat->getID() == id)
{
return qSharedPointerCast<StelObject>(sat);
}
}
return Q_NULLPTR;
} }
StelObjectP Satellites::searchByNoradNumber(const QString &noradNumber) con st StelObjectP Satellites::searchByNoradNumber(const QString &noradNumber) con st
{ {
if (!hintFader || StelApp::getInstance().getCore()->getCurrentLocati if (!hintFader)
on().planetName != earth->getEnglishName() || !isValidRangeDates()) return Q_NULLPTR;
return NULL;
StelCore* core = StelApp::getInstance().getCore();
if (qAbs(core->getTimeRate())>=Satellite::timeRateLimit) // Do not s
how satellites when time rate is over limit
return Q_NULLPTR;
if (core->getCurrentPlanet()!=earth || !isValidRangeDates(core))
return Q_NULLPTR;
// 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);
foreach(const SatelliteP& sat, satellites) foreach(const SatelliteP& sat, satellites)
{ {
if (sat->initialized && sat->displayed) if (sat->initialized && sat->displayed)
skipping to change at line 355 skipping to change at line 398
} }
} }
} }
return StelObjectP(); return StelObjectP();
} }
QStringList Satellites::listMatchingObjects(const QString& objPrefix, int m axNbItem, bool useStartOfWords, bool inEnglish) const QStringList Satellites::listMatchingObjects(const QString& objPrefix, int m axNbItem, bool useStartOfWords, bool inEnglish) const
{ {
QStringList result; QStringList result;
if (!hintFader if (!hintFader || maxNbItem <= 0)
|| maxNbItem <= 0 return result;
|| StelApp::getInstance().getCore()->getCurrentLocation().pl
anetName != earth->getEnglishName() StelCore* core = StelApp::getInstance().getCore();
|| !isValidRangeDates())
{ if (qAbs(core->getTimeRate())>=Satellite::timeRateLimit) // Do not s
how satellites when time rate is over limit
return result;
if (core->getCurrentPlanet()!=earth || !isValidRangeDates(core))
return result; 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);
skipping to change at line 406 skipping to change at line 452
} }
} }
result.sort(); result.sort();
return result; return result;
} }
QStringList Satellites::listAllObjects(bool inEnglish) const QStringList Satellites::listAllObjects(bool inEnglish) const
{ {
QStringList result; QStringList result;
if (!hintFader || StelApp::getInstance().getCore()->getCurrentLocati
on().planetName != earth->getEnglishName() || !isValidRangeDates()) if (!hintFader)
return result;
StelCore* core = StelApp::getInstance().getCore();
if (qAbs(core->getTimeRate())>=Satellite::timeRateLimit) // Do not s
how satellites when time rate is over limit
return result;
if (core->getCurrentPlanet()!=earth || !isValidRangeDates(core))
return result; return result;
if (inEnglish) if (inEnglish)
{ {
foreach(const SatelliteP& sat, satellites) foreach(const SatelliteP& sat, satellites)
{ {
result << sat->getEnglishName(); result << sat->getEnglishName();
} }
} }
else else
skipping to change at line 626 skipping to change at line 681
labelFont.setPixelSize(conf->value("hint_font_size", 10).toInt()); labelFont.setPixelSize(conf->value("hint_font_size", 10).toInt());
// orbit drawing params // orbit drawing params
Satellite::orbitLinesFlag = conf->value("orbit_line_flag", false).to Bool(); Satellite::orbitLinesFlag = conf->value("orbit_line_flag", false).to Bool();
Satellite::orbitLineSegments = conf->value("orbit_line_segments", 90 ).toInt(); Satellite::orbitLineSegments = conf->value("orbit_line_segments", 90 ).toInt();
Satellite::orbitLineFadeSegments = conf->value("orbit_fade_segments" , 5).toInt(); Satellite::orbitLineFadeSegments = conf->value("orbit_fade_segments" , 5).toInt();
Satellite::orbitLineSegmentDuration = conf->value("orbit_segment_dur ation", 20).toInt(); Satellite::orbitLineSegmentDuration = conf->value("orbit_segment_dur ation", 20).toInt();
Satellite::invisibleSatelliteColor = StelUtils::strToVec3f(conf->val ue("invisible_satellite_color", "0.2,0.2,0.2").toString()); Satellite::invisibleSatelliteColor = StelUtils::strToVec3f(conf->val ue("invisible_satellite_color", "0.2,0.2,0.2").toString());
Satellite::timeRateLimit = conf->value("time_rate_limit", 1.0).toDou
ble();
// realistic mode // realistic mode
setFlagRelisticMode(conf->value("realistic_mode_enabled", true).toBo ol()); setFlagRelisticMode(conf->value("realistic_mode_enabled", true).toBo ol());
conf->endGroup(); conf->endGroup();
} }
void Satellites::saveSettings() void Satellites::saveSettings()
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
conf->beginGroup("Satellites"); conf->beginGroup("Satellites");
skipping to change at line 702 skipping to change at line 759
//qDebug() << "[Satellites] catalog version from file:" << jsonVersi on; //qDebug() << "[Satellites] catalog version from file:" << jsonVersi on;
return jsonVersion; return jsonVersion;
} }
bool Satellites::saveDataMap(const QVariantMap& map, QString path) bool Satellites::saveDataMap(const QVariantMap& map, QString path)
{ {
if (path.isEmpty()) if (path.isEmpty())
path = catalogPath; path = catalogPath;
QFile jsonFile(path); QFile jsonFile(path);
StelJsonParser parser;
if (jsonFile.exists()) if (jsonFile.exists())
jsonFile.remove(); jsonFile.remove();
if (!jsonFile.open(QIODevice::WriteOnly)) if (!jsonFile.open(QIODevice::WriteOnly))
{ {
qWarning() << "[Satellites] cannot open for writing:" << QDi r::toNativeSeparators(path); qWarning() << "[Satellites] cannot open for writing:" << QDi r::toNativeSeparators(path);
return false; return false;
} }
else else
{ {
qDebug() << "[Satellites] writing to:" << QDir::toNativeSepa rators(path); qDebug() << "[Satellites] writing to:" << QDir::toNativeSepa rators(path);
parser.write(map, &jsonFile); StelJsonParser::write(map, &jsonFile);
jsonFile.close(); jsonFile.close();
return true; return true;
} }
} }
QVariantMap Satellites::loadDataMap(QString path) QVariantMap Satellites::loadDataMap(QString path)
{ {
if (path.isEmpty()) if (path.isEmpty())
path = catalogPath; path = catalogPath;
skipping to change at line 843 skipping to change at line 899
return groupList; return groupList;
} }
void Satellites::addGroup(const QString& groupId) void Satellites::addGroup(const QString& groupId)
{ {
if (groupId.isEmpty()) if (groupId.isEmpty())
return; return;
groups.insert(groupId); groups.insert(groupId);
} }
QHash<QString,QString> Satellites::getSatellites(const QString& group, Stat us vis) QHash<QString,QString> Satellites::getSatellites(const QString& group, Stat us vis) const
{ {
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->groups.contains(group)) && ! result.contains(sat->id)) if ((group.isEmpty() || sat->groups.contains(group)) && ! result.contains(sat->id))
{ {
if (vis==Both || if (vis==Both ||
skipping to change at line 872 skipping to change at line 928
return result; return result;
} }
SatellitesListModel* Satellites::getSatellitesListModel() SatellitesListModel* Satellites::getSatellitesListModel()
{ {
if (!satelliteListModel) if (!satelliteListModel)
satelliteListModel = new SatellitesListModel(&satellites, th is); satelliteListModel = new SatellitesListModel(&satellites, th is);
return satelliteListModel; return satelliteListModel;
} }
SatelliteP Satellites::getById(const QString& id) SatelliteP Satellites::getById(const QString& id) const
{ {
foreach(const SatelliteP& sat, satellites) foreach(const SatelliteP& sat, satellites)
{ {
if (sat->initialized && sat->id == id) if (sat->initialized && sat->id == id)
return sat; return sat;
} }
return SatelliteP(); return SatelliteP();
} }
QStringList Satellites::listAllIds() QStringList Satellites::listAllIds() const
{ {
QStringList result; QStringList result;
foreach(const SatelliteP& sat, satellites) foreach(const SatelliteP& sat, satellites)
{ {
if (sat->initialized) if (sat->initialized)
result.append(sat->id); result.append(sat->id);
} }
return result; return result;
} }
skipping to change at line 1030 skipping to change at line 1086
} }
else if (url.startsWith("0,")) else if (url.startsWith("0,"))
url.remove(0, 2); url.remove(0, 2);
conf->setValue("url", url); conf->setValue("url", url);
} }
conf->endArray(); conf->endArray();
conf->endGroup(); conf->endGroup();
} }
bool Satellites::getFlagLabels() bool Satellites::getFlagLabels() const
{ {
return Satellite::showLabels; return Satellite::showLabels;
} }
void Satellites::enableInternetUpdates(bool enabled) void Satellites::enableInternetUpdates(bool enabled)
{ {
if (enabled != updatesEnabled) if (enabled != updatesEnabled)
{ {
updatesEnabled = enabled; updatesEnabled = enabled;
emit settingsChanged(); emit settingsChanged();
skipping to change at line 1062 skipping to change at line 1118
void Satellites::enableAutoRemove(bool enabled) void Satellites::enableAutoRemove(bool enabled)
{ {
if (autoRemoveEnabled != enabled) if (autoRemoveEnabled != enabled)
{ {
autoRemoveEnabled = enabled; autoRemoveEnabled = enabled;
emit settingsChanged(); emit settingsChanged();
} }
} }
bool Satellites::getFlagRealisticMode() bool Satellites::getFlagRealisticMode() const
{ {
return Satellite::realisticModeFlag; return Satellite::realisticModeFlag;
} }
void Satellites::setFlagRelisticMode(bool b) void Satellites::setFlagRelisticMode(bool b)
{ {
if (Satellite::realisticModeFlag != b) if (Satellite::realisticModeFlag != b)
{ {
Satellite::realisticModeFlag = b; Satellite::realisticModeFlag = b;
emit settingsChanged(); emit settingsChanged();
skipping to change at line 1124 skipping to change at line 1180
void Satellites::checkForUpdate(void) void Satellites::checkForUpdate(void)
{ {
if (updatesEnabled && updateState != Updating if (updatesEnabled && updateState != Updating
&& lastUpdate.addSecs(updateFrequencyHours * 3600) <= QDateTime: :currentDateTime() && lastUpdate.addSecs(updateFrequencyHours * 3600) <= QDateTime: :currentDateTime()
&& downloadMgr->networkAccessible()==QNetworkAccessManager::Acce ssible) && downloadMgr->networkAccessible()==QNetworkAccessManager::Acce ssible)
updateFromOnlineSources(); updateFromOnlineSources();
} }
void Satellites::updateFromOnlineSources() void Satellites::updateFromOnlineSources()
{ {
// never update TLE's for any date before Oct 4, 1957, 19:28:34GMT ;
-)
if (StelApp::getInstance().getCore()->getJD()<2436116.3115)
return;
if (updateState==Satellites::Updating) if (updateState==Satellites::Updating)
{ {
qWarning() << "[Satellites] Internet update already in progr ess!"; qWarning() << "[Satellites] Internet update already in progr ess!";
return; return;
} }
else else
{ {
qDebug() << "[Satellites] starting Internet update..."; qDebug() << "[Satellites] starting Internet update...";
} }
skipping to change at line 1156 skipping to change at line 1216
emit updateStateChanged(OtherError); emit updateStateChanged(OtherError);
emit tleUpdateComplete(0, satellites.count(), 0, 0); emit tleUpdateComplete(0, satellites.count(), 0, 0);
return; return;
} }
updateState = Satellites::Updating; updateState = Satellites::Updating;
emit(updateStateChanged(updateState)); emit(updateStateChanged(updateState));
updateSources.clear(); updateSources.clear();
numberDownloadsComplete = 0; numberDownloadsComplete = 0;
if (progressBar==NULL) if (progressBar==Q_NULLPTR)
progressBar = StelApp::getInstance().addProgressBar(); progressBar = StelApp::getInstance().addProgressBar();
progressBar->setValue(0); progressBar->setValue(0);
progressBar->setRange(0, updateUrls.size()); progressBar->setRange(0, updateUrls.size());
progressBar->setFormat("TLE download %v/%m"); progressBar->setFormat("TLE download %v/%m");
foreach (QString url, updateUrls) foreach (QString url, updateUrls)
{ {
TleSource source; TleSource source;
source.file = 0; source.file = 0;
skipping to change at line 1278 skipping to change at line 1338
void Satellites::updateObserverLocation(StelLocation) void Satellites::updateObserverLocation(StelLocation)
{ {
recalculateOrbitLines(); recalculateOrbitLines();
} }
void Satellites::setOrbitLinesFlag(bool b) void Satellites::setOrbitLinesFlag(bool b)
{ {
Satellite::orbitLinesFlag = b; Satellite::orbitLinesFlag = b;
} }
bool Satellites::getOrbitLinesFlag() bool Satellites::getOrbitLinesFlag() const
{ {
return Satellite::orbitLinesFlag; return Satellite::orbitLinesFlag;
} }
void Satellites::recalculateOrbitLines(void) void Satellites::recalculateOrbitLines(void)
{ {
foreach(const SatelliteP& sat, satellites) foreach(const SatelliteP& sat, satellites)
{ {
if (sat->initialized && sat->displayed && sat->orbitDisplaye d) if (sat->initialized && sat->displayed && sat->orbitDisplaye d)
sat->recalculateOrbitLines(); sat->recalculateOrbitLines();
skipping to change at line 1588 skipping to change at line 1648
qsMagList.insert(id, smag.toDouble()); qsMagList.insert(id, smag.toDouble());
} }
qsmFile.close(); qsmFile.close();
} }
void Satellites::update(double deltaTime) void Satellites::update(double deltaTime)
{ {
// Separated because first test should be very fast. // Separated because first test should be very fast.
if (!hintFader && hintFader.getInterstate() <= 0.) if (!hintFader && hintFader.getInterstate() <= 0.)
return; return;
if (StelApp::getInstance().getCore()->getCurrentLocation().planetNam
e != earth->getEnglishName() || !isValidRangeDates()) StelCore *core = StelApp::getInstance().getCore();
if (qAbs(core->getTimeRate())>=Satellite::timeRateLimit) // Do not s
how satellites when time rate is over limit
return;
if (core->getCurrentPlanet() != earth || !isValidRangeDates(core))
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->displayed) if (sat->initialized && sat->displayed)
sat->update(deltaTime); sat->update(deltaTime);
} }
} }
void Satellites::draw(StelCore* core) void Satellites::draw(StelCore* core)
{ {
// Separated because first test should be very fast. // Separated because first test should be very fast.
if (!hintFader && hintFader.getInterstate() <= 0.) if (!hintFader && hintFader.getInterstate() <= 0.)
return; return;
if (core->getCurrentLocation().planetName != earth->getEnglishName()
|| !isValidRangeDates()) if (qAbs(core->getTimeRate())>=Satellite::timeRateLimit) // Do not s
how satellites when time rate is over limit
return; return;
StelProjectorP prj = core->getProjection(StelCore::FrameAltAz, StelC if (core->getCurrentPlanet()!=earth || !isValidRangeDates(core))
ore::RefractionAuto); return;
StelProjectorP prj = core->getProjection(StelCore::FrameJ2000);
StelPainter painter(prj); StelPainter painter(prj);
painter.setFont(labelFont); painter.setFont(labelFont);
Satellite::hintBrightness = hintFader.getInterstate(); Satellite::hintBrightness = hintFader.getInterstate();
painter.setBlending(true); painter.setBlending(true);
Satellite::hintTexture->bind(); Satellite::hintTexture->bind();
Satellite::viewportHalfspace = painter.getProjector()->getBoundingCa p(); Satellite::viewportHalfspace = painter.getProjector()->getBoundingCa p();
foreach (const SatelliteP& sat, satellites) foreach (const SatelliteP& sat, satellites)
{ {
if (sat && sat->initialized && sat->displayed) if (sat && sat->initialized && sat->displayed)
sat->draw(core, painter, 1.0); sat->draw(core, painter);
} }
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 StelProjectorP prj = core->getProjection(StelCore::FrameJ2000) ; const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000) ;
skipping to change at line 1682 skipping to change at line 1752
{ {
qDebug() << "[Satellites] file format is wrong!"; qDebug() << "[Satellites] file format is wrong!";
qDebug() << "[Satellites] error:" << e.what(); qDebug() << "[Satellites] error:" << e.what();
return false; return false;
} }
return true; return true;
} }
bool Satellites::isValidRangeDates() const bool Satellites::isValidRangeDates(const StelCore *core) const
{ {
bool ok; bool ok;
double tJD = StelApp::getInstance().getCore()->getJD(); double tJD = core->getJD();
double uJD = StelUtils::getJulianDayFromISO8601String(lastUpdate.toS tring(Qt::ISODate), &ok); double uJD = StelUtils::getJulianDayFromISO8601String(lastUpdate.toS tring(Qt::ISODate), &ok);
if (lastUpdate.isNull()) // No updates yet? if (lastUpdate.isNull()) // No updates yet?
uJD = tJD; uJD = tJD;
// do not draw anything before Oct 4, 1957, 19:28:34GMT ;-) // do not draw anything before Oct 4, 1957, 19:28:34GMT ;-)
// upper limit for drawing is +5 years after latest update of TLE // upper limit for drawing is +5 years after latest update of TLE
if ((tJD<2436116.3115) || (tJD>(uJD+1825))) if ((tJD<2436116.3115) || (tJD>(uJD+1825)))
return false; return false;
else else
return true; return true;
} }
skipping to change at line 1920 skipping to change at line 1990
} }
i.value().nextJD = predictionJD + t; i.value().nextJD = predictionJD + t;
if (nextJD>i.value().nextJD) if (nextJD>i.value().nextJD)
nextJD = i.value().nextJD; nextJD = i.value().nextJD;
} }
++i; ++i;
} }
predictionJD = nextJD; predictionJD = nextJD;
} }
Satellite::timeShift = 0.; //Satellite::timeShift = 0.;
if (isTimeNow) if (isTimeNow)
pcore->setTimeNow(); pcore->setTimeNow();
else else
pcore->setJD(currentJD); pcore->setJD(currentJD);
return predictions; return predictions;
} }
#endif #endif
void Satellites::translations() void Satellites::translations()
 End of changes. 34 change blocks. 
51 lines changed or deleted 122 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/