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 "SatellitesListModel.hpp" #include "SatellitesListModel.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 "StelProgressController.hpp"
#include "StelUtils.hpp"
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include <QNetworkReply> #include <QNetworkReply>
#include <QKeyEvent> #include <QKeyEvent>
#include <QAction>
#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>
#include <QDir> #include <QDir>
StelModule* SatellitesStelPluginInterface::getStelModule() const StelModule* SatellitesStelPluginInterface::getStelModule() const
{ {
skipping to change at line 70 skipping to change at line 71
{ {
// 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, 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;
return info; return info;
} }
Q_EXPORT_PLUGIN2(Satellites, SatellitesStelPluginInterface)
Satellites::Satellites() Satellites::Satellites()
: satelliteListModel(0), : satelliteListModel(NULL)
hintTexture(NULL)
, texPointer(NULL)
, pxmapGlow(NULL)
, pxmapOnIcon(NULL)
, pxmapOffIcon(NULL)
, toolbarButton(NULL) , toolbarButton(NULL)
, earth(NULL) , earth(NULL)
, defaultHintColor(0.0, 0.4, 0.6) , defaultHintColor(0.0, 0.4, 0.6)
, defaultOrbitColor(0.0, 0.3, 0.6) , defaultOrbitColor(0.0, 0.3, 0.6)
, progressBar(NULL) , updateState(CompleteNoUpdates)
, downloadMgr(NULL)
, progressBar(NULL)
, numberDownloadsComplete(0)
, updateTimer(0)
, updatesEnabled(false)
, autoAddEnabled(false)
, autoRemoveEnabled(false)
, updateFrequencyHours(0)
, messageTimer(0)
{ {
setObjectName("Satellites"); setObjectName("Satellites");
configDialog = new SatellitesDialog(); configDialog = new SatellitesDialog();
} }
void Satellites::deinit() void Satellites::deinit()
{ {
if(NULL != hintTexture) Satellite::hintTexture.clear();
{ texPointer.clear();
delete hintTexture;
}
if(NULL != texPointer)
{
delete texPointer;
}
} }
Satellites::~Satellites() Satellites::~Satellites()
{ {
delete configDialog; delete configDialog;
if (pxmapGlow)
delete pxmapGlow;
if (pxmapOnIcon)
delete pxmapOnIcon;
if (pxmapOffIcon)
delete pxmapOffIcon;
} }
void Satellites::init() void Satellites::init()
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
try try
{ {
// TODO: Compatibility with installation-dir modules? --BM // TODO: Compatibility with installation-dir modules? --BM
// It seems that the original code couldn't handle them eith er. // It seems that the original code couldn't handle them eith er.
skipping to change at line 139 skipping to change at line 130
// If no settings in the main config file, create with defau lts // If no settings in the main config file, create with defau lts
if (!conf->childGroups().contains("Satellites")) if (!conf->childGroups().contains("Satellites"))
{ {
//qDebug() << "Stellites: created section in config file."; //qDebug() << "Stellites: created section in config file.";
restoreDefaultSettings(); restoreDefaultSettings();
} }
// populate settings from main config file. // populate settings from main config file.
loadSettings(); loadSettings();
// absolute file name for inner catalog of the satellites
catalogPath = dataDir.absoluteFilePath("satellites.json"); catalogPath = dataDir.absoluteFilePath("satellites.json");
// absolute file name for qs.mag file
qsMagFilePath = dataDir.absoluteFilePath("qs.mag");
// Load and find resources used in the plugin // Load and find resources used in the plugin
texPointer = StelApp::getInstance().getTextureManager().crea
teTexture(StelFileMgr::getInstallationDir()+"/textures/pointeur5.png");
Satellite::hintTexture = StelApp::getInstance().getTextureMa
nager().createTexture(":/satellites/hint.png");
// key bindings and other actions // key bindings and other actions
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance() QString satGroup = N_("Satellites");
.getGui()); addAction("actionShow_Satellite_Hints", satGroup, N_("Satell
gui->getGuiAction("actionShow_Satellite_Hints")->setChecked( ite hints"), "hintsVisible", "Ctrl+Z");
getFlagHints()); addAction("actionShow_Satellite_Labels", satGroup, N_("Satel
gui->getGuiAction("actionShow_Satellite_Labels")->setChecked lite labels"), "labelsVisible", "Shift+Z");
(Satellite::showLabels); addAction("actionShow_Satellite_ConfigDialog_Global", satGro
up, N_("Satellites configuration window"), configDialog, "visible", "Alt+Z"
);
// Gui toolbar button // Gui toolbar button
pxmapGlow = new QPixmap(":/graphicGui/glow32x32.png"); StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance()
pxmapOnIcon = new QPixmap(":/satellites/bt_satellites_on.png .getGui());
"); if (gui!=NULL)
pxmapOffIcon = new QPixmap(":/satellites/bt_satellites_off.p {
ng"); toolbarButton = new StelButton(NULL,
toolbarButton = new StelButton(NULL, *pxmapOnIcon, *pxmapOff QPixmap(":/satellites
Icon, *pxmapGlow, gui->getGuiAction("actionShow_Satellite_Hints")); /bt_satellites_on.png"),
gui->getButtonBar()->addButton(toolbarButton, "065-pluginsGr QPixmap(":/satellites
oup"); /bt_satellites_off.png"),
QPixmap(":/graphicGui
connect(gui->getGuiAction("actionShow_Satellite_ConfigDialog /glow32x32.png"),
_Global"), SIGNAL(toggled(bool)), configDialog, SLOT(setVisible(bool))); "actionShow_Satellite
connect(configDialog, SIGNAL(visibleChanged(bool)), gui->get _Hints");
GuiAction("actionShow_Satellite_ConfigDialog_Global"), SLOT(setChecked(bool gui->getButtonBar()->addButton(toolbarButton, "065-p
))); luginsGroup");
connect(gui->getGuiAction("actionShow_Satellite_Hints"), SIG }
NAL(toggled(bool)), this, SLOT(setFlagHints(bool)));
connect(gui->getGuiAction("actionShow_Satellite_Labels"), SI
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);
messageTimer->setSingleShot(true); // recurring check for update messageTimer->setSingleShot(true); // recurring check for update
messageTimer->setInterval(9000); // 6 seconds should be enough time messageTimer->setInterval(9000); // 6 seconds should be enough time
messageTimer->stop(); messageTimer->stop();
connect(messageTimer, SIGNAL(timeout()), this, SLOT(hideMessages())) ; connect(messageTimer, SIGNAL(timeout()), this, SLOT(hideMessages())) ;
// If the json file does not already exist, create it from the resou rce in the QT resource // If the json file does not already exist, create it from the resou rce in the QT resource
if(QFileInfo(catalogPath).exists()) if(QFileInfo(catalogPath).exists())
{ {
if (readCatalogVersion() != SATELLITES_PLUGIN_VERSION) if (!checkJsonFileFormat() || readCatalogVersion() != SATELL ITES_PLUGIN_VERSION)
{ {
displayMessage(q_("The old satellites.json file is n o longer compatible - using default file"), "#bb0000"); displayMessage(q_("The old satellites.json file is n o longer compatible - using default file"), "#bb0000");
restoreDefaultCatalog(); restoreDefaultCatalog();
} }
} }
else else
{ {
qDebug() << "Satellites::init satellites.json does not exist - copying default file to " << QDir::toNativeSeparators(catalogPath); qDebug() << "Satellites::init satellites.json does not exist - copying default file to " << QDir::toNativeSeparators(catalogPath);
restoreDefaultCatalog(); restoreDefaultCatalog();
} }
if(!QFileInfo(qsMagFilePath).exists())
{
restoreDefaultQSMagFile();
}
qDebug() << "Satellites: loading catalog file:" << QDir::toNativeSep arators(catalogPath); qDebug() << "Satellites: loading catalog file:" << QDir::toNativeSep arators(catalogPath);
// create satellites according to content os satellites.json file // create satellites according to content os satellites.json file
loadCatalog(); loadCatalog();
// Set up download manager and the update schedule // Set up download manager and the update schedule
downloadMgr = new QNetworkAccessManager(this); downloadMgr = new QNetworkAccessManager(this);
connect(downloadMgr, SIGNAL(finished(QNetworkReply*)), connect(downloadMgr, SIGNAL(finished(QNetworkReply*)),
this, SLOT(saveDownloadedUpdate(QNetworkReply*))); this, SLOT(saveDownloadedUpdate(QNetworkReply*)));
updateState = CompleteNoUpdates; updateState = CompleteNoUpdates;
skipping to change at line 213 skipping to change at line 214
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(), connect(StelApp::getInstance().getCore(),
SIGNAL(locationChanged(StelLocation)), SIGNAL(locationChanged(StelLocation)),
this, this,
SLOT(updateObserverLocation(StelLocation))); SLOT(updateObserverLocation(StelLocation)));
//Load the module's custom style sheets
QFile styleSheetFile;
styleSheetFile.setFileName(":/satellites/normalStyle.css");
if(styleSheetFile.open(QFile::ReadOnly|QFile::Text))
{
normalStyleSheet = styleSheetFile.readAll();
}
styleSheetFile.close();
styleSheetFile.setFileName(":/satellites/nightStyle.css");
if(styleSheetFile.open(QFile::ReadOnly|QFile::Text))
{
nightStyleSheet = styleSheetFile.readAll();
}
styleSheetFile.close();
connect(&StelApp::getInstance(), SIGNAL(colorSchemeChanged(const QSt
ring&)), this, SLOT(setStelStyle(const QString&)));
} }
bool Satellites::backupCatalog(bool deleteOriginal) bool Satellites::backupCatalog(bool deleteOriginal)
{ {
QFile old(catalogPath); QFile old(catalogPath);
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 266 skipping to change at line 250
else else
{ {
qWarning() << "Satellites: WARNING: failed to back up catalo g file as" qWarning() << "Satellites: WARNING: failed to back up catalo g file as"
<< QDir::toNativeSeparators(backupPath); << QDir::toNativeSeparators(backupPath);
return false; return false;
} }
return true; return true;
} }
void Satellites::setStelStyle(const QString& mode)
{
foreach(const SatelliteP& sat, satellites)
{
if (sat->initialized)
{
sat->setNightColors(mode=="night_color");
}
}
}
const StelStyle Satellites::getModuleStyleSheet(const StelStyle& style)
{
StelStyle pluginStyle(style);
if (style.confSectionName == "color")
{
pluginStyle.qtStyleSheet.append(normalStyleSheet);
}
else
{
pluginStyle.qtStyleSheet.append(nightStyleSheet);
}
return pluginStyle;
}
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()->getCurrentLocati on().planetName != earth->getEnglishName()) if (!hintFader || StelApp::getInstance().getCore()->getCurrentLocati on().planetName != earth->getEnglishName() || !isValidRangeDates())
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 326 skipping to change at line 285
{ {
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 on().planetName != earth->getEnglishName()) if (!hintFader || StelApp::getInstance().getCore()->getCurrentLocati on().planetName != earth->getEnglishName() || !isValidRangeDates())
return NULL; return NULL;
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)
{ {
skipping to change at line 349 skipping to change at line 308
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()->getCurrentLocati on().planetName != earth->getEnglishName()) if (!hintFader || StelApp::getInstance().getCore()->getCurrentLocati on().planetName != earth->getEnglishName() || !isValidRangeDates())
return NULL; return NULL;
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)
{ {
skipping to change at line 372 skipping to change at line 331
if (sat->getEnglishName().toUpper() == englishName) if (sat->getEnglishName().toUpper() == englishName)
return qSharedPointerCast<StelObject>(sat); return qSharedPointerCast<StelObject>(sat);
} }
} }
return NULL; return NULL;
} }
StelObjectP Satellites::searchByNoradNumber(const QString &noradNumber) con st StelObjectP Satellites::searchByNoradNumber(const QString &noradNumber) con st
{ {
if (!hintFader || StelApp::getInstance().getCore()->getCurrentLocati on().planetName != earth->getEnglishName()) if (!hintFader || StelApp::getInstance().getCore()->getCurrentLocati on().planetName != earth->getEnglishName() || !isValidRangeDates())
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;
/* int number = */ numberString.toInt(&ok);
if (!ok)
return StelObjectP();
foreach(const SatelliteP& sat, satellites) foreach(const SatelliteP& sat, satellites)
{ {
if (sat->initialized && sat->displayed) if (sat->initialized && sat->displayed)
{ {
if (sat->getCatalogNumberString() == numberS tring) if (sat->getCatalogNumberString() == numberS tring)
return qSharedPointerCast<StelObject >(sat); return qSharedPointerCast<StelObject >(sat);
} }
} }
} }
return StelObjectP(); return StelObjectP();
} }
QStringList Satellites::listMatchingObjectsI18n(const QString& objPrefix, i nt maxNbItem, bool useStartOfWords) const QStringList Satellites::listMatchingObjectsI18n(const QString& objPrefix, i nt maxNbItem, bool useStartOfWords) const
{ {
QStringList result; QStringList result;
if (!hintFader || StelApp::getInstance().getCore()->getCurrentLocati on().planetName != earth->getEnglishName()) if (!hintFader || StelApp::getInstance().getCore()->getCurrentLocati on().planetName != earth->getEnglishName() || !isValidRangeDates())
return result; return result;
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; numberPrefix = numberString;
/* int number = */ numberString.toInt(&ok);
if (ok)
numberPrefix = numberString;
} }
bool find; bool find;
foreach(const SatelliteP& sat, satellites) foreach(const SatelliteP& sat, satellites)
{ {
if (sat->initialized && sat->displayed) if (sat->initialized && sat->displayed)
{ {
find = false; find = false;
if (useStartOfWords) if (useStartOfWords)
{ {
if (sat->getNameI18n().toUpper().left(objw.l ength()) == objw) if (sat->getNameI18n().toUpper().left(objw.l ength()) == objw)
skipping to change at line 458 skipping to change at line 410
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::listMatchingObjects(const QString& objPrefix, int m axNbItem, bool useStartOfWords) const QStringList Satellites::listMatchingObjects(const QString& objPrefix, int m axNbItem, bool useStartOfWords) const
{ {
QStringList result; QStringList result;
if (!hintFader || StelApp::getInstance().getCore()->getCurrentLocati on().planetName != earth->getEnglishName()) if (!hintFader || StelApp::getInstance().getCore()->getCurrentLocati on().planetName != earth->getEnglishName() || !isValidRangeDates())
return result; return result;
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);
skipping to change at line 534 skipping to change at line 486
{ {
result << sat->getNameI18n(); result << sat->getNameI18n();
} }
} }
return result; return result;
} }
bool Satellites::configureGui(bool show) bool Satellites::configureGui(bool show)
{ {
if (show) if (show)
{ configDialog->setVisible(true);
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance()
.getGui());
gui->getGuiAction("actionShow_Satellite_ConfigDialog_Global"
)->setChecked(true);
}
return true; return true;
} }
void Satellites::restoreDefaults(void) void Satellites::restoreDefaults(void)
{ {
restoreDefaultSettings(); restoreDefaultSettings();
restoreDefaultCatalog(); restoreDefaultCatalog();
restoreDefaultQSMagFile();
loadCatalog(); loadCatalog();
loadSettings(); loadSettings();
} }
void Satellites::restoreDefaultSettings() void Satellites::restoreDefaultSettings()
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
conf->beginGroup("Satellites"); conf->beginGroup("Satellites");
// delete all existing Satellite settings... // delete all existing Satellite settings...
skipping to change at line 570 skipping to change at line 519
conf->setValue("updates_enabled", true); conf->setValue("updates_enabled", true);
conf->setValue("auto_add_enabled", true); conf->setValue("auto_add_enabled", true);
conf->setValue("auto_remove_enabled", true); conf->setValue("auto_remove_enabled", true);
conf->setValue("hint_color", "0.0,0.4,0.6"); conf->setValue("hint_color", "0.0,0.4,0.6");
conf->setValue("hint_font_size", 10); conf->setValue("hint_font_size", 10);
conf->setValue("update_frequency_hours", 72); conf->setValue("update_frequency_hours", 72);
conf->setValue("orbit_line_flag", true); conf->setValue("orbit_line_flag", true);
conf->setValue("orbit_line_segments", 90); conf->setValue("orbit_line_segments", 90);
conf->setValue("orbit_fade_segments", 5); conf->setValue("orbit_fade_segments", 5);
conf->setValue("orbit_segment_duration", 20); conf->setValue("orbit_segment_duration", 20);
conf->setValue("realistic_mode_enabled", false);
conf->endGroup(); // saveTleSources() opens it for itself conf->endGroup(); // saveTleSources() opens it for itself
// TLE update sources // TLE update sources
QStringList urls; QStringList urls;
urls << "1,http://celestrak.com/NORAD/elements/visual.txt" // Auto-a dd ON! urls << "1,http://celestrak.com/NORAD/elements/visual.txt" // Auto-a dd ON!
<< "http://celestrak.com/NORAD/elements/tle-new.txt" << "http://celestrak.com/NORAD/elements/tle-new.txt"
<< "http://celestrak.com/NORAD/elements/science.txt" << "http://celestrak.com/NORAD/elements/science.txt"
<< "http://celestrak.com/NORAD/elements/noaa.txt" << "http://celestrak.com/NORAD/elements/noaa.txt"
<< "http://celestrak.com/NORAD/elements/goes.txt" << "http://celestrak.com/NORAD/elements/goes.txt"
skipping to change at line 615 skipping to change at line 565
// Make sure that in the case where an online update has pre viously been done, but // Make sure that in the case where an online update has pre viously been done, but
// 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
StelApp::getInstance().getSettings()->remove("Satellites/las t_update"); StelApp::getInstance().getSettings()->remove("Satellites/las t_update");
lastUpdate = QDateTime::fromString("2001-05-25T12:00:00", Qt ::ISODate); lastUpdate = QDateTime::fromString("2001-05-25T12:00:00", Qt ::ISODate);
} }
} }
void Satellites::restoreDefaultQSMagFile()
{
QFile src(":/satellites/qs.mag");
if (!src.copy(qsMagFilePath))
{
qWarning() << "Satellites::restoreDefaultQSMagFile cannot co
py qs.mag resource to " + QDir::toNativeSeparators(qsMagFilePath);
}
else
{
qDebug() << "Satellites::init copied default qs.mag to " <<
QDir::toNativeSeparators(qsMagFilePath);
// The resource is read only, and the new file inherits this
... make sure the new file
// is writable by the Stellarium process so that updates can
be done.
QFile dest(qsMagFilePath);
dest.setPermissions(dest.permissions() | QFile::WriteOwner);
}
}
void Satellites::loadSettings() void Satellites::loadSettings()
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
conf->beginGroup("Satellites"); conf->beginGroup("Satellites");
// Load update sources list... // Load update sources list...
updateUrls.clear(); updateUrls.clear();
// Backward compatibility: try to detect and read an old-stlye array . // Backward compatibility: try to detect and read an old-stlye array .
// TODO: Assume that the user hasn't modified their conf in a stupid way? // TODO: Assume that the user hasn't modified their conf in a stupid way?
skipping to change at line 687 skipping to change at line 654
// Get a font for labels // Get a font for labels
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", true).toB ool(); Satellite::orbitLinesFlag = conf->value("orbit_line_flag", true).toB ool();
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();
// realistic mode
setFlagRelisticMode(conf->value("realistic_mode_enabled", false).toB
ool());
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");
// updater related settings... // updater related settings...
conf->setValue("update_frequency_hours", updateFrequencyHours); conf->setValue("update_frequency_hours", updateFrequencyHours);
skipping to change at line 712 skipping to change at line 682
// Get a font for labels // Get a font for labels
conf->setValue("hint_font_size", labelFont.pixelSize()); conf->setValue("hint_font_size", labelFont.pixelSize());
// orbit drawing params // orbit drawing params
conf->setValue("orbit_line_flag", Satellite::orbitLinesFlag); conf->setValue("orbit_line_flag", Satellite::orbitLinesFlag);
conf->setValue("orbit_line_segments", Satellite::orbitLineSegments); conf->setValue("orbit_line_segments", Satellite::orbitLineSegments);
conf->setValue("orbit_fade_segments", Satellite::orbitLineFadeSegmen ts); conf->setValue("orbit_fade_segments", Satellite::orbitLineFadeSegmen ts);
conf->setValue("orbit_segment_duration", Satellite::orbitLineSegment Duration); conf->setValue("orbit_segment_duration", Satellite::orbitLineSegment Duration);
// realistic mode
conf->setValue("realistic_mode_enabled", getFlagRealisticMode());
conf->endGroup(); conf->endGroup();
// Update sources... // Update sources...
saveTleSources(updateUrls); saveTleSources(updateUrls);
} }
void Satellites::loadCatalog() void Satellites::loadCatalog()
{ {
setDataMap(loadDataMap()); setDataMap(loadDataMap());
} }
skipping to change at line 785 skipping to change at line 758
QVariantMap Satellites::loadDataMap(QString path) QVariantMap Satellites::loadDataMap(QString path)
{ {
if (path.isEmpty()) if (path.isEmpty())
path = catalogPath; path = catalogPath;
QVariantMap map; QVariantMap map;
QFile jsonFile(path); QFile jsonFile(path);
if (!jsonFile.open(QIODevice::ReadOnly)) if (!jsonFile.open(QIODevice::ReadOnly))
qWarning() << "Satellites::loadTleMap cannot open " << QDir: :toNativeSeparators(path); qWarning() << "Satellites::loadTleMap cannot open " << QDir: :toNativeSeparators(path);
else else
{
map = StelJsonParser::parse(&jsonFile).toMap(); map = StelJsonParser::parse(&jsonFile).toMap();
jsonFile.close();
jsonFile.close(); }
return map; return map;
} }
void Satellites::setDataMap(const QVariantMap& map) void Satellites::setDataMap(const QVariantMap& map)
{ {
int numReadOk = 0; int numReadOk = 0;
QVariantList defaultHintColorMap; QVariantList defaultHintColorMap;
defaultHintColorMap << defaultHintColor[0] << defaultHintColor[1] << defaultHintColor[2]; defaultHintColorMap << defaultHintColor[0] << defaultHintColor[1] << defaultHintColor[2];
if (map.contains("hintColor")) if (map.contains("hintColor"))
skipping to change at line 819 skipping to change at line 793
foreach(const QString& satId, satMap.keys()) foreach(const QString& satId, satMap.keys())
{ {
QVariantMap satData = satMap.value(satId).toMap(); QVariantMap satData = satMap.value(satId).toMap();
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"];
if (!satData.contains("stdMag") && qsMagList.contains(satId)
)
satData["stdMag"] = qsMagList[satId];
SatelliteP sat(new Satellite(satId, satData)); SatelliteP sat(new Satellite(satId, satData));
if (sat->initialized) if (sat->initialized)
{ {
satellites.append(sat); satellites.append(sat);
groups.unite(sat->groups); groups.unite(sat->groups);
numReadOk++; numReadOk++;
} }
} }
qSort(satellites); qSort(satellites);
skipping to change at line 855 skipping to change at line 832
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"])
satMap.remove("orbitColor"); satMap.remove("orbitColor");
if (satMap["hintColor"].toList() == defHintCol) if (satMap["hintColor"].toList() == defHintCol)
satMap.remove("hintColor"); satMap.remove("hintColor");
if (satMap["stdMag"].toFloat() == 99.f)
satMap.remove("stdMag");
sats[sat->id] = satMap; sats[sat->id] = satMap;
} }
map["satellites"] = sats; map["satellites"] = sats;
return map; return map;
} }
void Satellites::markLastUpdate() void Satellites::markLastUpdate()
{ {
lastUpdate = QDateTime::currentDateTime(); lastUpdate = QDateTime::currentDateTime();
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
skipping to change at line 962 skipping to change at line 942
<< defaultHintColor[2]; << defaultHintColor[2];
QVariantMap satProperties; QVariantMap satProperties;
satProperties.insert("name", tleData.name); satProperties.insert("name", tleData.name);
satProperties.insert("tle1", tleData.first); satProperties.insert("tle1", tleData.first);
satProperties.insert("tle2", tleData.second); satProperties.insert("tle2", tleData.second);
satProperties.insert("hintColor", hintColor); satProperties.insert("hintColor", hintColor);
//TODO: Decide if newly added satellites are visible by default --BM //TODO: Decide if newly added satellites are visible by default --BM
satProperties.insert("visible", true); satProperties.insert("visible", true);
satProperties.insert("orbitVisible", false); satProperties.insert("orbitVisible", false);
if (qsMagList.contains(tleData.id))
satProperties.insert("stdMag", qsMagList[tleData.id]);
SatelliteP sat(new Satellite(tleData.id, satProperties)); SatelliteP sat(new Satellite(tleData.id, satProperties));
if (sat->initialized) if (sat->initialized)
{ {
qDebug() << "Satellite added:" << tleData.id << tleData.name ; qDebug() << "Satellite added:" << tleData.id << tleData.name ;
satellites.append(sat); satellites.append(sat);
sat->setNew(); sat->setNew();
return true; return true;
} }
return false; return false;
skipping to change at line 1103 skipping to change at line 1085
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()
{
return Satellite::realisticModeFlag;
}
void Satellites::setFlagRelisticMode(bool b)
{
if (Satellite::realisticModeFlag != b)
{
Satellite::realisticModeFlag = b;
emit settingsChanged();
}
}
void Satellites::setFlagHints(bool b) void Satellites::setFlagHints(bool b)
{ {
if (hintFader != b) if (hintFader != b)
{ {
hintFader = b; hintFader = b;
emit settingsChanged(); emit settingsChanged();
} }
} }
void Satellites::setFlagLabels(bool b) void Satellites::setFlagLabels(bool b)
skipping to change at line 1181 skipping to change at line 1177
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==NULL)
progressBar = StelApp::getInstance().getGui()->addProgressBa r(); progressBar = StelApp::getInstance().addProgressBar();
progressBar->setValue(0); progressBar->setValue(0);
progressBar->setMaximum(updateUrls.size()); progressBar->setRange(0, updateUrls.size());
progressBar->setVisible(true);
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;
source.addNew = false; source.addNew = false;
if (url.startsWith("1,")) if (url.startsWith("1,"))
{ {
// Also prevents inconsistent behavior if the user t oggles the flag // Also prevents inconsistent behavior if the user t oggles the flag
skipping to change at line 1268 skipping to change at line 1263
if (progressBar) if (progressBar)
progressBar->setValue(numberDownloadsComplete); progressBar->setValue(numberDownloadsComplete);
// Check if all files have been downloaded. // Check if all files have been downloaded.
// TODO: It's better to keep track of the network requests themselve s. --BM // TODO: It's better to keep track of the network requests themselve s. --BM
if (numberDownloadsComplete < updateSources.size()) if (numberDownloadsComplete < updateSources.size())
return; return;
if (progressBar) if (progressBar)
{ {
delete progressBar; StelApp::getInstance().removeProgressBar(progressBar);
progressBar = 0; progressBar = 0;
} }
// All files have been downloaded, finish the update // All files have been downloaded, finish the update
TleDataHash newData; TleDataHash newData;
for (int i = 0; i < updateSources.count(); i++) for (int i = 0; i < updateSources.count(); i++)
{ {
if (!updateSources[i].file) if (!updateSources[i].file)
continue; continue;
if (updateSources[i].file->open(QFile::ReadOnly|QFile::Text) ) if (updateSources[i].file->open(QFile::ReadOnly|QFile::Text) )
{ {
parseTleFile(*updateSources[i].file, parseTleFile(*updateSources[i].file,
newData, newData,
updateSources[i].addNew); updateSources[i].addNew);
updateSources[i].file->close(); updateSources[i].file->close();
delete updateSources[i].file; delete updateSources[i].file;
updateSources[i].file = 0; updateSources[i].file = 0;
} }
} }
updateSources.clear(); updateSources.clear();
parseQSMagFile(qsMagFilePath);
updateSatellites(newData); updateSatellites(newData);
} }
void Satellites::updateObserverLocation(StelLocation) void Satellites::updateObserverLocation(StelLocation)
{ {
recalculateOrbitLines(); recalculateOrbitLines();
} }
void Satellites::setOrbitLinesFlag(bool b) void Satellites::setOrbitLinesFlag(bool b)
{ {
skipping to change at line 1344 skipping to change at line 1340
void Satellites::updateFromFiles(QStringList paths, bool deleteFiles) void Satellites::updateFromFiles(QStringList paths, bool deleteFiles)
{ {
// Container for the new data. // Container for the new data.
TleDataHash newTleSets; TleDataHash newTleSets;
foreach(const 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))
{ {
parseTleFile(tleFile, newTleSets); parseTleFile(tleFile, newTleSets, autoAddEnabled);
tleFile.close(); tleFile.close();
if (deleteFiles) if (deleteFiles)
tleFile.remove(); tleFile.remove();
} }
} }
parseQSMagFile(qsMagFilePath);
updateSatellites(newTleSets); updateSatellites(newTleSets);
} }
void Satellites::updateSatellites(TleDataHash& newTleSets) void Satellites::updateSatellites(TleDataHash& newTleSets)
{ {
// Save the update time. // Save the update time.
// One of the reasons it's here is that lastUpdate is used below. // One of the reasons it's here is that lastUpdate is used below.
markLastUpdate(); markLastUpdate();
if (newTleSets.isEmpty()) if (newTleSets.isEmpty())
skipping to change at line 1411 skipping to change at line 1407
// 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;
updatedCount++; updatedCount++;
} }
if (qsMagList.contains(id))
sat->stdMag = qsMagList[id];
} }
else else
{ {
if (autoRemoveEnabled) if (autoRemoveEnabled)
toBeRemoved.append(sat->id); toBeRemoved.append(sat->id);
else else
qWarning() << "Satellites:" << sat->id << sa t->name qWarning() << "Satellites:" << sat->id << sa t->name
<< "is missing in the update list s."; << "is missing in the update list s.";
missingCount++; missingCount++;
} }
skipping to change at line 1476 skipping to change at line 1475
void Satellites::parseTleFile(QFile& openFile, void Satellites::parseTleFile(QFile& openFile,
TleDataHash& tleList, TleDataHash& tleList,
bool addFlagValue) bool addFlagValue)
{ {
if (!openFile.isOpen() || !openFile.isReadable()) if (!openFile.isOpen() || !openFile.isReadable())
return; return;
// Code mostly re-used from updateFromFiles() // Code mostly re-used from updateFromFiles()
int lineNumber = 0; int lineNumber = 0;
TleData lastData; TleData lastData;
lastData.addThis = addFlagValue;
while (!openFile.atEnd()) while (!openFile.atEnd())
{ {
QString line = QString(openFile.readLine()).trimmed(); QString line = QString(openFile.readLine()).trimmed();
if (line.length() < 65) // this is title line if (line.length() < 65) // this is title line
{ {
// New entry in the list, so reset all fields // New entry in the list, so reset all fields
lastData = TleData(); lastData = TleData();
lastData.addThis = addFlagValue; lastData.addThis = addFlagValue;
skipping to change at line 1530 skipping to change at line 1530
tleList.insert(id, lastData) ; // Overwrite if necessary tleList.insert(id, lastData) ; // Overwrite if necessary
} }
//TODO: Error warnings? --BM //TODO: Error warnings? --BM
} }
else else
qDebug() << "Satellites: unprocessed line " << lineNumber << " in file " << QDir::toNativeSeparators(openFile.fileName ()); qDebug() << "Satellites: unprocessed line " << lineNumber << " in file " << QDir::toNativeSeparators(openFile.fileName ());
} }
} }
} }
void Satellites::parseQSMagFile(QString qsMagFile)
{
// Description of file and some additional information you can find
here:
// 1) http://www.prismnet.com/~mmccants/tles/mccdesc.html
// 2) http://www.prismnet.com/~mmccants/tles/intrmagdef.html
if (qsMagFile.isEmpty())
return;
QFile qsmFile(qsMagFile);
if (!qsmFile.open(QIODevice::ReadOnly))
{
qWarning() << "Satellites: oops... cannot open " << QDir::to
NativeSeparators(qsMagFile);
return;
}
qsMagList.clear();
while (!qsmFile.atEnd())
{
QString line = QString(qsmFile.readLine());
QString id = line.mid(0,5).trimmed();
QString smag = line.mid(33,4).trimmed();
if (!smag.isEmpty())
qsMagList.insert(id, smag.toDouble());
}
qsmFile.close();
}
void Satellites::update(double deltaTime) void Satellites::update(double deltaTime)
{ {
if (StelApp::getInstance().getCore()->getCurrentLocation().planetNam e != earth->getEnglishName() || (!hintFader && hintFader.getInterstate() <= 0.)) if (StelApp::getInstance().getCore()->getCurrentLocation().planetNam e != earth->getEnglishName() || !isValidRangeDates() || (!hintFader && hint Fader.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->displayed) if (sat->initialized && sat->displayed)
sat->update(deltaTime); sat->update(deltaTime);
} }
} }
void Satellites::draw(StelCore* core, StelRenderer* renderer) void Satellites::draw(StelCore* core)
{ {
if (core->getCurrentLocation().planetName != earth->getEnglishName() if (core->getCurrentLocation().planetName != earth->getEnglishName()
|| || !isValidRangeDates() || (!hintFader && hintFader.getInterstate() <= 0.)
(core->getJDay()<2436116.3115) )
|| // do not draw anything before Oct 4, 1957, 19:28:34GMT ;-)
(!hintFader && hintFader.getInterstate() <= 0.))
return; return;
StelProjectorP prj = core->getProjection(StelCore::FrameAltAz); StelProjectorP prj = core->getProjection(StelCore::FrameAltAz);
renderer->setFont(labelFont); StelPainter painter(prj);
painter.setFont(labelFont);
Satellite::hintBrightness = hintFader.getInterstate(); Satellite::hintBrightness = hintFader.getInterstate();
renderer->setBlendMode(BlendMode_Alpha); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
if(NULL == hintTexture) glEnable(GL_TEXTURE_2D);
{ Satellite::hintTexture->bind();
hintTexture = renderer->createTexture(":/satellites/hint.png Satellite::viewportHalfspace = painter.getProjector()->getBoundingCa
"); p();
}
hintTexture->bind();
Satellite::viewportHalfspace = prj->getBoundingCap();
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, renderer, prj, hintTexture);
}
} }
if (GETSTELMODULE(StelObjectMgr)->getFlagSelectedObjectPointer()) if (GETSTELMODULE(StelObjectMgr)->getFlagSelectedObjectPointer())
{ drawPointer(core, painter);
drawPointer(core, renderer);
}
} }
void Satellites::drawPointer(StelCore* core, StelRenderer* renderer) void Satellites::drawPointer(StelCore* core, StelPainter& painter)
{ {
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;
} painter.setColor(0.4f,0.5f,0.8f);
if(NULL == texPointer)
{
texPointer = renderer->createTexture("textures/point
eur5.png");
}
if (StelApp::getInstance().getVisionModeNight())
renderer->setGlobalColor(0.8f,0.0f,0.0f);
else
renderer->setGlobalColor(0.4f,0.5f,0.8f);
texPointer->bind(); texPointer->bind();
renderer->setBlendMode(BlendMode_Alpha); glEnable(GL_TEXTURE_2D);
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());
const float halfSize = size * 0.5; // size+=20.f + 10.f*std::sin(2.f * StelApp::getInstance().g
const float left = screenpos[0] - halfSize - 20; etTotalRunTime());
const float right = screenpos[0] + halfSize - 20; painter.drawSprite2dMode(screenpos[0]-size/2, screenpos[1]-s
const float top = screenpos[1] - halfSize - 20; ize/2, 20, 90);
const float bottom = screenpos[1] + halfSize - 20; painter.drawSprite2dMode(screenpos[0]-size/2, screenpos[1]+s
renderer->drawTexturedRect(left, top, 40, 40, 90); ize/2, 20, 0);
renderer->drawTexturedRect(left, bottom, 40, 40, 0); painter.drawSprite2dMode(screenpos[0]+size/2, screenpos[1]+s
renderer->drawTexturedRect(right, bottom, 40, 40, -90); ize/2, 20, -90);
renderer->drawTexturedRect(right, top, 40, 40, -180); painter.drawSprite2dMode(screenpos[0]+size/2, screenpos[1]-s
ize/2, 20, -180);
}
}
bool Satellites::checkJsonFileFormat()
{
QFile jsonFile(catalogPath);
if (!jsonFile.open(QIODevice::ReadOnly))
{
qWarning() << "Satellites::checkJsonFileFormat(): cannot ope
n " << QDir::toNativeSeparators(catalogPath);
return false;
} }
QVariantMap map;
try
{
map = StelJsonParser::parse(&jsonFile).toMap();
jsonFile.close();
}
catch (std::runtime_error& e)
{
qDebug() << "Satellites::checkJsonFileFormat(): file format
is wrong!";
qDebug() << "Satellites::checkJsonFileFormat() error:" << e.
what();
return false;
}
return true;
}
bool Satellites::isValidRangeDates() const
{
bool ok;
double tJD = StelApp::getInstance().getCore()->getJDay();
double uJD = StelUtils::getJulianDayFromISO8601String(lastUpdate.toS
tring(Qt::ISODate), &ok);
if (lastUpdate.isNull()) // No updates yet?
uJD = tJD;
// do not draw anything before Oct 4, 1957, 19:28:34GMT ;-)
// upper limit for drawing is +5 years after latest update of TLE
if ((tJD<2436116.3115) || (tJD>(uJD+1825)))
return false;
else
return true;
} }
void Satellites::translations() void Satellites::translations()
{ {
#if 0 #if 0
// Satellite groups // Satellite groups
// TRANSLATORS: Satellite group: Bright/naked-eye-visible satellites // TRANSLATORS: Satellite group: Bright/naked-eye-visible satellites
N_("visual"); N_("visual");
// TRANSLATORS: Satellite group: Scientific satellites // TRANSLATORS: Satellite group: Scientific satellites
N_("scientific"); N_("scientific");
 End of changes. 61 change blocks. 
171 lines changed or deleted 234 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/