SolarSystemEditor.cpp   SolarSystemEditor.cpp 
skipping to change at line 57 skipping to change at line 57
return new SolarSystemEditor(); return new SolarSystemEditor();
} }
StelPluginInfo SolarSystemEditorStelPluginInterface::getPluginInfo() const StelPluginInfo SolarSystemEditorStelPluginInterface::getPluginInfo() const
{ {
//Q_INIT_RESOURCE(solarSystemEditor); //Q_INIT_RESOURCE(solarSystemEditor);
StelPluginInfo info; StelPluginInfo info;
info.id = "SolarSystemEditor"; info.id = "SolarSystemEditor";
info.displayedName = N_("Solar System Editor"); info.displayedName = N_("Solar System Editor");
info.authors = "Bogdan Marinov"; info.authors = "Bogdan Marinov, Georg Zotti";
info.contact = "http://stellarium.org"; info.contact = "http://stellarium.org";
info.description = N_("An interface for adding asteroids and comets to Stellarium. It can download object lists from the Minor Planet Center's website and perform searches in its online database."); info.description = N_("An interface for adding asteroids and comets to Stellarium. It can download object lists from the Minor Planet Center's website and perform searches in its online database.");
info.version = SOLARSYSTEMEDITOR_VERSION; info.version = SOLARSYSTEMEDITOR_VERSION;
return info; return info;
} }
SolarSystemEditor::SolarSystemEditor() SolarSystemEditor::SolarSystemEditor():
isInitialized(false),
mainWindow(Q_NULLPTR),
solarSystemConfigurationFile(Q_NULLPTR)
{ {
setObjectName("SolarSystemEditor"); setObjectName("SolarSystemEditor");
solarSystem = GETSTELMODULE(SolarSystem);
isInitialized = false;
mainWindow = NULL;
solarSystemConfigurationFile = NULL;
solarSystemManager = GETSTELMODULE(SolarSystem);
//I really hope that the file manager is instantiated before this //I really hope that the file manager is instantiated before this
defaultSolarSystemFilePath = QFileInfo(StelFileMgr::getInstalla // GZ new: Not sure whether this should be major or minor here.
tionDir() + "/data/ssystem.ini").absoluteFilePath(); defaultSolarSystemFilePath = QFileInfo(StelFileMgr::getInstalla
customSolarSystemFilePath = QFileInfo(StelFileMgr::getUserDir( tionDir() + "/data/ssystem_minor.ini").absoluteFilePath();
) + "/data/ssystem.ini").absoluteFilePath(); customSolarSystemFilePath = QFileInfo(StelFileMgr::getUserDir(
) + "/data/ssystem_minor.ini").absoluteFilePath();
majorSolarSystemFilePath = QFileInfo(StelFileMgr::getInstalla
tionDir() + "/data/ssystem_major.ini").absoluteFilePath();
} }
SolarSystemEditor::~SolarSystemEditor() SolarSystemEditor::~SolarSystemEditor()
{ {
if (solarSystemConfigurationFile != NULL) if (solarSystemConfigurationFile != Q_NULLPTR)
{ {
delete solarSystemConfigurationFile; delete solarSystemConfigurationFile;
} }
} }
void SolarSystemEditor::init() void SolarSystemEditor::init()
{ {
//Get a list of the "default" Solar System objects' names: //Get a list of the "default" minor Solar System objects' names:
//TODO: Use it as validation for the loading of the plug-in //TODO: Use it as validation for the loading of the plug-in
if (QFile::exists(defaultSolarSystemFilePath)) // GZ TBD: Maybe only load the names from ssystem_major.ini, so that
even default minor bodies can be reduced by the user.
// The current solution loads the default major objects and thus pre
vents Pluto from deletion.
// if (QFile::exists(defaultSolarSystemFilePath))
// {
// // GZ We no longer prevent users from deleting minor bodies
even when they came in the default file!
// //defaultSsoIdentifiers = listAllLoadedObjectsInFile(default
SolarSystemFilePath);
// }
// else
// {
// //TODO: Better error message
// qDebug() << "SolarSystemEditor: Something is horribly wrong
with installdir (minor)" << QDir::toNativeSeparators(StelFileMgr::getInstal
lationDir());
// return;
// }
if (QFile::exists(majorSolarSystemFilePath))
{ {
defaultSsoIdentifiers = listAllLoadedObjectsInFile(defaultSo //defaultSsoIdentifiers.unite(listAllLoadedObjectsInFile(maj
larSystemFilePath); orSolarSystemFilePath));
defaultSsoIdentifiers=listAllLoadedObjectsInFile(majorSolarS
ystemFilePath);
} }
else else
{ {
//TODO: Better error message qDebug() << "SolarSystemEditor: Something is horribly wrong
qDebug() << "Something is horribly wrong:" << QDir::toNative with installdir (major)" << QDir::toNativeSeparators(StelFileMgr::getInstal
Separators(StelFileMgr::getInstallationDir()); lationDir());
return; return;
} }
try try
{ {
//Make sure that a user ssystem.ini actually exists //Make sure that a user ssystem_minor.ini actually exists
if (!cloneSolarSystemConfigurationFile()) if (!cloneSolarSystemConfigurationFile())
return; return;
mainWindow = new SolarSystemManagerWindow(); mainWindow = new SolarSystemManagerWindow();
} }
catch (std::runtime_error &e) catch (std::runtime_error &e)
{ {
qWarning() << "init() error: " << e.what(); qWarning() << "init() error: " << e.what();
return; return;
} }
connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SL OT(updateI18n())); connect(&StelApp::getInstance(), SIGNAL(languageChanged()), this, SL OT(updateI18n()));
isInitialized = true; isInitialized = true;
// key bindings and other actions // key bindings and other actions
addAction("actionShow_MPC_Import", N_("Solar System Editor"), N_("Im port orbital elements in MPC format..."), mainWindow, "newImportMPC()", "Ct rl+Alt+S"); addAction("actionShow_MPC_Import", N_("Solar System Editor"), N_("Im port orbital elements in MPC format..."), mainWindow, "newImportMPC()", "Ct rl+Alt+S");
} }
void SolarSystemEditor::deinit()
{
//
}
void SolarSystemEditor::update(double) //deltaTime
{
//
}
void SolarSystemEditor::draw(StelCore*) //core
{
//
}
double SolarSystemEditor::getCallOrder(StelModuleActionName) const// action Name double SolarSystemEditor::getCallOrder(StelModuleActionName) const// action Name
{ {
return 0.; return 0.;
} }
bool SolarSystemEditor::configureGui(bool show) bool SolarSystemEditor::configureGui(bool show)
{ {
//If the plug-in has failed to initialize, disable the button //If the plug-in has failed to initialize, disable the button
//TODO: Display a message in the window instead. //TODO: Display a message in the window instead.
if (!isInitialized) if (!isInitialized)
skipping to change at line 194 skipping to change at line 193
//solarSystemManager->reloadPlanets(); //solarSystemManager->reloadPlanets();
} }
} }
return true; return true;
} }
void SolarSystemEditor::updateI18n() void SolarSystemEditor::updateI18n()
{ {
//The Solar System MUST be translated before updating the window //The Solar System MUST be translated before updating the window
//TODO: Remove this if/when you merge this module in the Solar Syste m module //TODO: Remove this if/when you merge this module in the Solar Syste m module
solarSystemManager->updateI18n(); solarSystem->updateI18n();
} }
bool SolarSystemEditor::cloneSolarSystemConfigurationFile() bool SolarSystemEditor::cloneSolarSystemConfigurationFile() const
{ {
QDir userDataDirectory(StelFileMgr::getUserDir()); QDir userDataDirectory(StelFileMgr::getUserDir());
if (!userDataDirectory.exists()) if (!userDataDirectory.exists())
{ {
qDebug() << "Unable to find user data directory:" << QDir::t oNativeSeparators(userDataDirectory.absolutePath()); qCritical() << "Unable to find user data directory:" << QDir ::toNativeSeparators(userDataDirectory.absolutePath());
return false; return false;
} }
if (!userDataDirectory.exists("data") && !userDataDirectory.mkdir("d ata")) if (!userDataDirectory.exists("data") && !userDataDirectory.mkdir("d ata"))
{ {
qDebug() << "Unable to create a \"data\" subdirectory in" << QDir::toNativeSeparators(userDataDirectory.absolutePath()); qDebug() << "Unable to create a \"data\" subdirectory in" << QDir::toNativeSeparators(userDataDirectory.absolutePath());
return false; return false;
} }
if (QFile::exists(customSolarSystemFilePath)) if (QFile::exists(customSolarSystemFilePath))
{ {
qDebug() << "Using the ssystem.ini file that already exists in the user directory..."; qDebug() << "Using the ssystem_minor.ini file that already e xists in the user directory...";
return true; return true;
} }
if (QFile::exists(defaultSolarSystemFilePath)) if (QFile::exists(defaultSolarSystemFilePath))
{ {
qDebug() << "Trying to copy ssystem.ini to" << QDir::toNativ eSeparators(customSolarSystemFilePath); qDebug() << "Trying to copy ssystem_minor.ini to" << QDir::t oNativeSeparators(customSolarSystemFilePath);
return QFile::copy(defaultSolarSystemFilePath, customSolarSy stemFilePath); return QFile::copy(defaultSolarSystemFilePath, customSolarSy stemFilePath);
} }
else else
{ {
qDebug() << "This should be impossible."; qCritical() << "SolarSystemEditor: Cannot find default ssyst
em_minor.ini. This branch should be unreachable.";
Q_ASSERT(0);
return false; return false;
} }
} }
bool SolarSystemEditor::resetSolarSystemConfigurationFile() bool SolarSystemEditor::resetSolarSystemConfigurationFile() const
{ {
if (QFile::exists(customSolarSystemFilePath)) if (QFile::exists(customSolarSystemFilePath))
{ {
if (!QFile::remove((customSolarSystemFilePath))) if (!QFile::remove((customSolarSystemFilePath)))
{ {
qWarning() << "Unable to delete" << QDir::toNativeSe parators(customSolarSystemFilePath) qWarning() << "Unable to delete" << QDir::toNativeSe parators(customSolarSystemFilePath)
<< endl << "Please remove the file manually ."; << endl << "Please remove the file manually .";
return false; return false;
} }
} }
skipping to change at line 255 skipping to change at line 255
{ {
if (isInitialized) if (isInitialized)
{ {
if (resetSolarSystemConfigurationFile()) if (resetSolarSystemConfigurationFile())
{ {
//Deselect all currently selected objects //Deselect all currently selected objects
StelObjectMgr * objectManager = GETSTELMODULE(StelOb jectMgr); StelObjectMgr * objectManager = GETSTELMODULE(StelOb jectMgr);
//TODO //TODO
objectManager->unSelect(); objectManager->unSelect();
solarSystemManager->reloadPlanets(); solarSystem->reloadPlanets();
emit solarSystemChanged(); emit solarSystemChanged();
} }
} }
} }
bool SolarSystemEditor::copySolarSystemConfigurationFileTo(QString filePath ) bool SolarSystemEditor::copySolarSystemConfigurationFileTo(QString filePath )
{ {
if (QFile::exists(customSolarSystemFilePath)) if (QFile::exists(customSolarSystemFilePath))
{ {
QFileInfo targetFile(filePath); QFileInfo targetFile(filePath);
skipping to change at line 278 skipping to change at line 278
else else
{ {
return false; return false;
} }
} }
bool SolarSystemEditor::replaceSolarSystemConfigurationFileWith(QString fil ePath) bool SolarSystemEditor::replaceSolarSystemConfigurationFileWith(QString fil ePath)
{ {
if (!QFile::exists(filePath)) if (!QFile::exists(filePath))
{ {
//TODO: Message qCritical() << "SolarSystemEditor: Cannot replace, file not found: " << filePath;
return false; return false;
} }
//Is it a valid configuration file? //Is it a valid configuration file?
QSettings settings(filePath, QSettings::IniFormat); QSettings settings(filePath, StelIniFormat);
if (settings.status() != QSettings::NoError) if (settings.status() != QSettings::NoError)
{ {
qWarning() << QDir::toNativeSeparators(filePath) << "is not a valid configuration file."; qCritical() << "SolarSystemEditor: " << QDir::toNativeSepara tors(filePath) << "is not a valid configuration file.";
return false; return false;
} }
//Remove the existingfile //Remove the existingfile
if (QFile::exists(customSolarSystemFilePath)) if (QFile::exists(customSolarSystemFilePath))
{ {
if(!QFile::remove(customSolarSystemFilePath)) if(!QFile::remove(customSolarSystemFilePath))
{ {
//TODO: Message qCritical() << "SolarSystemEditor: Cannot remove old file.";
return false; return false;
} }
} }
//Copy the new file //Copy the new file
//If the copy fails, reset to the default configuration //If the copy fails, reset to the default configuration
if (QFile::copy(filePath, customSolarSystemFilePath)) if (QFile::copy(filePath, customSolarSystemFilePath))
{ {
solarSystemManager->reloadPlanets(); solarSystem->reloadPlanets();
emit solarSystemChanged(); emit solarSystemChanged();
return true; return true;
} }
else else
{ {
//TODO: Message qWarning() << "SolarSystemEditor: Could not replace file. Re storing default.";
if (cloneSolarSystemConfigurationFile()) if (cloneSolarSystemConfigurationFile())
{ {
solarSystemManager->reloadPlanets(); solarSystem->reloadPlanets();
emit solarSystemChanged(); emit solarSystemChanged();
return true; return true;
} }
else else
{ {
//TODO: Message qCritical() << "SolarSystemEditor: Could neither rep lace nor then restore default file. This comes unexpected.";
return false; return false;
} }
} }
} }
QHash<QString,QString> SolarSystemEditor::listAllLoadedObjectsInFile(QStrin bool SolarSystemEditor::addFromSolarSystemConfigurationFile(QString filePat
g filePath) h)
{
if (!QFile::exists(filePath))
{
qCritical() << "SolarSystemEditor: Cannot add data from file
, file" << filePath << "not found.";
return false;
}
//Is it a valid configuration file?
QSettings newData(filePath, StelIniFormat);
if (newData.status() != QSettings::NoError)
{
qCritical() << "SolarSystemEditor: Cannot add data from file
," << QDir::toNativeSeparators(filePath) << "is not a valid configuration f
ile.";
return false;
}
//Process the existing and new files:
if (QFile::exists(customSolarSystemFilePath))
{
QSettings minorBodies(customSolarSystemFilePath, StelIniForm
at);
// add and overwrite existing data in the user's ssystem_min
or.ini by the data in the new file.
qDebug() << "ADD OBJECTS: Data for " << newData.childGroups(
).count() << "objects to minor file with " << minorBodies.childGroups().cou
nt() << "entries";
foreach (QString group, newData.childGroups())
{
QString fixedGroupName=fixGroupName(group);
newData.beginGroup(group);
qDebug() << " Group: " << group << "for object " <<
newData.value("name");
qDebug() << " ";
QStringList minorChildGroups=minorBodies.childGroups
();
if (minorChildGroups.contains(fixedGroupName))
{
qDebug() << "This group " << fixedGroupName
<< "already exists. Updating values";
}
else
qDebug() << "This group " << fixedGroupName
<< "does not yet exist. Adding values";
minorBodies.beginGroup(fixedGroupName);
QStringList newKeys=newData.allKeys(); // limited to
the group!
foreach (QString key, newKeys)
{
minorBodies.setValue(key, newData.value(key)
);
}
minorBodies.endGroup();
newData.endGroup();
}
minorBodies.sync();
qDebug() << "Minor groups now: " << minorBodies.childGroups(
);
qDebug() << "Checking for stupid General group.";
// There may be a generic group "General" in the updated fil
e, created from comments. We must remove it.
if (minorBodies.childGroups().contains("General"))
{
minorBodies.remove("General");
}
qDebug() << "Minor groups after fix now: " << minorBodies.ch
ildGroups();
minorBodies.sync();
solarSystem->reloadPlanets();
emit solarSystemChanged();
return true;
}
else
{
qCritical() << "SolarSystemEditor: Cannot add data to use fi
le," << QDir::toNativeSeparators(customSolarSystemFilePath) << "not found."
;
return false;
}
}
QHash<QString,QString> SolarSystemEditor::listAllLoadedObjectsInFile(QStrin
g filePath) const
{ {
if (!QFile::exists(filePath)) if (!QFile::exists(filePath))
return QHash<QString,QString>(); return QHash<QString,QString>();
QSettings solarSystem(filePath, QSettings::IniFormat); QSettings solarSystemIni(filePath, StelIniFormat);
if (solarSystem.status() != QSettings::NoError) if (solarSystemIni.status() != QSettings::NoError)
return QHash<QString,QString>(); return QHash<QString,QString>();
QStringList groups = solarSystem.childGroups(); QStringList groups = solarSystemIni.childGroups();
QStringList planetNames = solarSystemManager->getAllPlanetEnglishNam QStringList planetNames = solarSystem->getAllPlanetEnglishNames();
es();
QHash<QString,QString> loadedObjects; QHash<QString,QString> loadedObjects;
foreach (QString group, groups) foreach (QString group, groups)
{ {
QString name = solarSystem.value(group + "/name").toString() ; QString name = solarSystemIni.value(group + "/name").toStrin g();
if (planetNames.contains(name)) if (planetNames.contains(name))
{ {
loadedObjects.insert(name, group); loadedObjects.insert(name, group);
} }
} }
return loadedObjects; return loadedObjects;
} }
QHash<QString,QString> SolarSystemEditor::listAllLoadedSsoIdentifiers() QHash<QString,QString> SolarSystemEditor::listAllLoadedSsoIdentifiers() con st
{ {
if (QFile::exists(customSolarSystemFilePath)) if (QFile::exists(customSolarSystemFilePath))
{ {
return listAllLoadedObjectsInFile(customSolarSystemFilePath) ; return listAllLoadedObjectsInFile(customSolarSystemFilePath) ;
} }
else else
{ {
//TODO: Error message //TODO: Error message
return QHash<QString,QString>(); return QHash<QString,QString>();
} }
} }
bool SolarSystemEditor::removeSsoWithName(QString name) bool SolarSystemEditor::removeSsoWithName(QString name)
{ {
if (name.isEmpty()) if (name.isEmpty())
return false; return false;
//qDebug() << name; //qDebug() << name;
if (defaultSsoIdentifiers.keys().contains(name)) if (defaultSsoIdentifiers.keys().contains(name))
{ {
qWarning() << "You can't delete the default Solar System obj qWarning() << "You can't delete the default Solar System obj
ects for the moment."; ects like" << name << "for the moment.";
qCritical() << "As of 0.16, this line should be impossible t
o reach!";
return false; return false;
} }
//Make sure that the file exists //Make sure that the file exists
if (!QFile::exists(customSolarSystemFilePath)) if (!QFile::exists(customSolarSystemFilePath))
{ {
qDebug() << "Can't remove" << name << "to ssystem.ini: Unabl e to find" << QDir::toNativeSeparators(customSolarSystemFilePath); qDebug() << "Can't remove" << name << "from ssystem_minor.in i: Unable to find" << QDir::toNativeSeparators(customSolarSystemFilePath);
return false; return false;
} }
//Open the file //Open the file
QSettings settings(customSolarSystemFilePath, QSettings::IniFormat); QSettings settings(customSolarSystemFilePath, StelIniFormat);
if (settings.status() != QSettings::NoError) if (settings.status() != QSettings::NoError)
{ {
qDebug() << "Error opening ssystem.ini:" << QDir::toNativeSe parators(customSolarSystemFilePath); qDebug() << "Error opening ssystem_minor.ini:" << QDir::toNa tiveSeparators(customSolarSystemFilePath);
return false; return false;
} }
//Remove the section //Remove the section
foreach (QString group, settings.childGroups()) foreach (QString group, settings.childGroups())
{ {
if (settings.value(group + "/name").toString() == name) if (settings.value(group + "/name").toString() == name)
{ {
settings.remove(group); settings.remove(group);
settings.sync(); settings.sync();
break; break;
} }
} }
//Deselect all currently selected objects //Deselect all currently selected objects
//TODO: I bet that someone will complains, so: unselect only the rem oved one //TODO: I bet that someone will complain, so: unselect only the remo ved one
GETSTELMODULE(StelObjectMgr)->unSelect(); GETSTELMODULE(StelObjectMgr)->unSelect();
//Reload the Solar System //Reload the Solar System
solarSystemManager->reloadPlanets(); //solarSystem->reloadPlanets();
// Better: just remove this one object!
solarSystem->removePlanet(name);
emit solarSystemChanged(); emit solarSystemChanged();
return true; return true;
} }
//TODO: Strings that have failed to be parsed. The usual source of discrepa ncies is //TODO: Strings that have failed to be parsed. The usual source of discrepa ncies is
//http://www.minorplanetcenter.org/iau/Ephemerides/Comets/Soft00Cmt.txt //http://www.minorplanetcenter.org/iau/Ephemerides/Comets/Soft00Cmt.txt
//It seems that some entries in the list don't match the described format. //It seems that some entries in the list don't match the described format.
/* /*
" CJ95O010 1997 03 31.4141 0.906507 0.994945 130.5321 282.6820 89.3193 20100723 -2.0 4.0 C/1995 O1 (Hale-Bopp) MPC 61436" -> minus sign, fixed " CJ95O010 1997 03 31.4141 0.906507 0.994945 130.5321 282.6820 89.3193 20100723 -2.0 4.0 C/1995 O1 (Hale-Bopp) MPC 61436" -> minus sign, fixed
" CK09K030 2011 01 9.266 3.90156 1.00000 251.413 0.032 1 46.680 8.5 4.0 C/2009 K3 (Beshore) MPC 66205" -> lower precision than the spec, fixed " CK09K030 2011 01 9.266 3.90156 1.00000 251.413 0.032 1 46.680 8.5 4.0 C/2009 K3 (Beshore) MPC 66205" -> lower precision than the spec, fixed
" CK10F040 2010 04 6.109 0.61383 1.00000 120.718 237.294 89.143 13.5 4.0 C/2010 F4 (Machholz) MPC 69906" -> lower precision than the spec, fixed " CK10F040 2010 04 6.109 0.61383 1.00000 120.718 237.294 89.143 13.5 4.0 C/2010 F4 (Machholz) MPC 69906" -> lower precision than the spec, fixed
" CK10M010 2012 02 7.840 2.29869 1.00000 265.318 82.150 78.373 9.0 4.0 C/2010 M1 (Gibbs) MPC 70817" -> lower precision than the spec, fixed " CK10M010 2012 02 7.840 2.29869 1.00000 265.318 82.150 78.373 9.0 4.0 C/2010 M1 (Gibbs) MPC 70817" -> lower precision than the spec, fixed
" CK10R010 2011 11 28.457 6.66247 1.00000 96.009 345.949 1 57.437 6.0 4.0 C/2010 R1 (LINEAR) MPEC 2010-R99" -> lower precision than the spec, fixed " CK10R010 2011 11 28.457 6.66247 1.00000 96.009 345.949 1 57.437 6.0 4.0 C/2010 R1 (LINEAR) MPEC 2010-R99" -> lower precision than the spec, fixed
"0128P b 2007 06 13.8064 3.062504 0.320891 210.3319 214.3583 4.3606 20100723 8.5 4.0 128P/Shoemaker-Holt MPC 51822" -> fragment, fixed "0128P b 2007 06 13.8064 3.062504 0.320891 210.3319 214.3583 4.3606 20100723 8.5 4.0 128P/Shoemaker-Holt MPC 51822" -> fragment, fixed
"0141P d 2010 05 29.7106 0.757809 0.749215 149.3298 246.0849 12.8032 20100723 12.0 12.0 141P/Machholz MPC 59599" -> fragment, fixed "0141P d 2010 05 29.7106 0.757809 0.749215 149.3298 246.0849 12.8032 20100723 12.0 12.0 141P/Machholz MPC 59599" -> fragment, fixed
*/ */
SsoElements SolarSystemEditor::readMpcOneLineCometElements(QString oneLineE lements) SsoElements SolarSystemEditor::readMpcOneLineCometElements(QString oneLineE lements) const
{ {
SsoElements result; SsoElements result;
//qDebug() << "readMpcOneLineCometElements started..."; // GZ //qDebug() << "readMpcOneLineCometElements started...";
QRegExp mpcParser("^\\s*(\\d{4})?([A-Z])((?:\\w{6}|\\s{6})?[0a-zA-Z] )?\\s+(\\d{4})\\s+(\\d{2})\\s+(\\d{1,2}\\.\\d{3,4})\\s+(\\d{1,2}\\.\\d{5,6} )\\s+(\\d\\.\\d{5,6})\\s+(\\d{1,3}\\.\\d{3,4})\\s+(\\d{1,3}\\.\\d{3,4})\\s+ (\\d{1,3}\\.\\d{3,4})\\s+(?:(\\d{4})(\\d\\d)(\\d\\d))?\\s+(\\-?\\d{1,2}\\.\ \d)\\s+(\\d{1,2}\\.\\d)\\s+(\\S.{1,54}\\S)(?:\\s+(\\S.*))?$");// QRegExp mpcParser("^\\s*(\\d{4})?([A-Z])((?:\\w{6}|\\s{6})?[0a-zA-Z] )?\\s+(\\d{4})\\s+(\\d{2})\\s+(\\d{1,2}\\.\\d{3,4})\\s+(\\d{1,2}\\.\\d{5,6} )\\s+(\\d\\.\\d{5,6})\\s+(\\d{1,3}\\.\\d{3,4})\\s+(\\d{1,3}\\.\\d{3,4})\\s+ (\\d{1,3}\\.\\d{3,4})\\s+(?:(\\d{4})(\\d\\d)(\\d\\d))?\\s+(\\-?\\d{1,2}\\.\ \d)\\s+(\\d{1,2}\\.\\d)\\s+(\\S.{1,54}\\S)(?:\\s+(\\S.*))?$");//
int match = mpcParser.indexIn(oneLineElements); int match = mpcParser.indexIn(oneLineElements);
//qDebug() << "RegExp captured:" << match << mpcParser.capturedTexts (); //qDebug() << "RegExp captured:" << match << mpcParser.capturedTexts ();
if (match < 0) if (match < 0)
{ {
qWarning() << "No match for" << oneLineElements; qWarning() << "No match for" << oneLineElements;
return result; return result;
skipping to change at line 472 skipping to change at line 544
result.insert("name", name); result.insert("name", name);
QString sectionName = convertToGroupName(name); QString sectionName = convertToGroupName(name);
if (sectionName.isEmpty()) if (sectionName.isEmpty())
{ {
return SsoElements(); return SsoElements();
} }
result.insert("section_name", sectionName); result.insert("section_name", sectionName);
//After a name has been determined, insert the essential keys //After a name has been determined, insert the essential keys
result.insert("parent", "Sun"); //result.insert("parent", "Sun"); // 0.16: omit obvious default.
result.insert("type", "comet"); result.insert("type", "comet");
//"comet_orbit" is used for all cases: //"comet_orbit" is used for all cases:
//"ell_orbit" interprets distances as kilometers, not AUs //"ell_orbit" interprets distances as kilometers, not AUs
result.insert("coord_func", "comet_orbit"); result.insert("coord_func", "comet_orbit");
// GZ: moved next line below! // GZ: moved next line below!
//result.insert("orbit_good", 1000); // default validity for osculat ing elements, days //result.insert("orbit_good", 1000); // default validity for osculat ing elements, days
result.insert("lighting", false); //result.insert("color", "1.0, 1.0, 1.0"); // 0.16: omit obvious de
result.insert("color", "1.0, 1.0, 1.0"); fault.
result.insert("tex_map", "nomap.png"); //result.insert("tex_map", "nomap.png"); // 0.16: omit obvious de
fault.
bool ok = false; bool ok = false;
//TODO: Use this for VALIDATION! //TODO: Use this for VALIDATION!
int year = mpcParser.cap(4).toInt(); int year = mpcParser.cap(4).toInt();
int month = mpcParser.cap(5).toInt(); int month = mpcParser.cap(5).toInt();
double dayFraction = mpcParser.cap(6).toDouble(&ok); double dayFraction = mpcParser.cap(6).toDouble(&ok);
int day = (int) dayFraction; int day = (int) dayFraction;
QDate datePerihelionPassage(year, month, day); QDate datePerihelionPassage(year, month, day);
int fraction = (int) ((dayFraction - day) * 24 * 60 * 60); int fraction = (int) ((dayFraction - day) * 24 * 60 * 60);
skipping to change at line 537 skipping to change at line 608
else else
result.insert("orbit_good", 1000); // default validity for o sculating elements, days result.insert("orbit_good", 1000); // default validity for o sculating elements, days
double absoluteMagnitude = mpcParser.cap(15).toDouble(&ok); double absoluteMagnitude = mpcParser.cap(15).toDouble(&ok);
result.insert("absolute_magnitude", absoluteMagnitude); result.insert("absolute_magnitude", absoluteMagnitude);
//This is not the same "slope parameter" as used in asteroids. Bette r name? //This is not the same "slope parameter" as used in asteroids. Bette r name?
double slopeParameter = mpcParser.cap(16).toDouble(&ok); double slopeParameter = mpcParser.cap(16).toDouble(&ok);
result.insert("slope_parameter", slopeParameter); result.insert("slope_parameter", slopeParameter);
double radius = 5; //Fictitious double radius = 5; //Fictitious default assumption
result.insert("radius", radius); result.insert("radius", radius);
result.insert("albedo", 0.1); // GZ 2014-01-10: Comets are very dark , should even be 0.03! result.insert("albedo", 0.1); // GZ 2014-01-10: Comets are very dark , should even be 0.03!
result.insert("dust_lengthfactor", 0.4); // dust tail length w.r.t. gas tail length result.insert("dust_lengthfactor", 0.4); // dust tail length w.r.t. gas tail length
result.insert("dust_brightnessfactor", 1.5); // dust tail brightness w.r.t. gas tail. result.insert("dust_brightnessfactor", 1.5); // dust tail brightness w.r.t. gas tail.
result.insert("dust_widthfactor", 1.5); // opening w.r.t. gas tail o pening width. result.insert("dust_widthfactor", 1.5); // opening w.r.t. gas tail o pening width.
//qDebug() << "readMpcOneLineCometElements done\n"; //qDebug() << "readMpcOneLineCometElements done\n";
return result; return result;
} }
SsoElements SolarSystemEditor::readMpcOneLineMinorPlanetElements(QString on eLineElements) SsoElements SolarSystemEditor::readMpcOneLineMinorPlanetElements(QString on eLineElements) const
{ {
SsoElements result; SsoElements result;
//This time I'll try splitting the line to columns, instead of //This time I'll try splitting the line to columns, instead of
//using a regular expression. //using a regular expression.
//Using QString::mid() allows parsing it in a random sequence. //Using QString::mid() allows parsing it in a random sequence.
//Length validation //Length validation
if (oneLineElements.isEmpty() || if (oneLineElements.isEmpty() ||
oneLineElements.length() > 202 || oneLineElements.length() > 202 ||
skipping to change at line 657 skipping to change at line 728
//Section name //Section name
QString sectionName = convertToGroupName(name, minorPlanetNumber); QString sectionName = convertToGroupName(name, minorPlanetNumber);
if (sectionName.isEmpty()) if (sectionName.isEmpty())
{ {
return SsoElements(); return SsoElements();
} }
result.insert("section_name", sectionName); result.insert("section_name", sectionName);
//After a name has been determined, insert the essential keys //After a name has been determined, insert the essential keys
result.insert("parent", "Sun"); //result.insert("parent", "Sun"); // 0.16: omit obvious defau lt.
//"comet_orbit" is used for all cases: //"comet_orbit" is used for all cases:
//"ell_orbit" interprets distances as kilometers, not AUs //"ell_orbit" interprets distances as kilometers, not AUs
result.insert("coord_func","comet_orbit"); result.insert("coord_func","comet_orbit");
result.insert("lighting", false); //result.insert("color", "1.0, 1.0, 1.0"); // 0.16: omit obvious def
result.insert("color", "1.0, 1.0, 1.0"); ault.
result.insert("tex_map", "nomap.png"); //result.insert("tex_map", "nomap.png"); // 0.16: omit obvious def
ault.
//Magnitude and slope parameter //Magnitude and slope parameter
column = oneLineElements.mid(8,5).trimmed(); column = oneLineElements.mid(8,5).trimmed();
double absoluteMagnitude = column.toDouble(&ok); double absoluteMagnitude = column.toDouble(&ok);
if (!ok) if (!ok)
return SsoElements(); return SsoElements();
column = oneLineElements.mid(14,5).trimmed(); column = oneLineElements.mid(14,5).trimmed();
double slopeParameter = column.toDouble(&ok); double slopeParameter = column.toDouble(&ok);
if (!ok) if (!ok)
return SsoElements(); return SsoElements();
skipping to change at line 719 skipping to change at line 789
column = oneLineElements.mid(92, 11).trimmed(); column = oneLineElements.mid(92, 11).trimmed();
double semiMajorAxis = column.toDouble(&ok); double semiMajorAxis = column.toDouble(&ok);
if (!ok) if (!ok)
return SsoElements(); return SsoElements();
result.insert("orbit_SemiMajorAxis", semiMajorAxis); result.insert("orbit_SemiMajorAxis", semiMajorAxis);
column = oneLineElements.mid(20, 5).trimmed();//Epoch, in packed for m column = oneLineElements.mid(20, 5).trimmed();//Epoch, in packed for m
QRegExp packedDateFormat("^([IJK])(\\d\\d)([1-9A-C])([1-9A-V])$"); QRegExp packedDateFormat("^([IJK])(\\d\\d)([1-9A-C])([1-9A-V])$");
if (packedDateFormat.indexIn(column) != 0) if (packedDateFormat.indexIn(column) != 0)
{ {
qDebug() << "readMpcOneLineMinorPlanetElements():" qWarning() << "readMpcOneLineMinorPlanetElements():"
<< column << "is not a date in packed format"; << column << "is not a date in packed format";
return SsoElements(); return SsoElements();
} }
int year = packedDateFormat.cap(2).toInt(); int year = packedDateFormat.cap(2).toInt();
switch (packedDateFormat.cap(1).at(0).toLatin1()) switch (packedDateFormat.cap(1).at(0).toLatin1())
{ {
case 'I': case 'I':
year += 1800; year += 1800;
break; break;
case 'J': case 'J':
skipping to change at line 742 skipping to change at line 812
case 'K': case 'K':
default: default:
year += 2000; year += 2000;
} }
int month = unpackDayOrMonthNumber(packedDateFormat.cap(3).at(0)); int month = unpackDayOrMonthNumber(packedDateFormat.cap(3).at(0));
int day = unpackDayOrMonthNumber(packedDateFormat.cap(4).at(0)); int day = unpackDayOrMonthNumber(packedDateFormat.cap(4).at(0));
//qDebug() << column << year << month << day; //qDebug() << column << year << month << day;
QDate epochDate(year, month, day); QDate epochDate(year, month, day);
if (!epochDate.isValid()) if (!epochDate.isValid())
{ {
qDebug() << "readMpcOneLineMinorPlanetElements():" qWarning() << "readMpcOneLineMinorPlanetElements():"
<< column << "unpacks to" << column << "unpacks to"
<< QString("%1-%2-%3").arg(year).arg(month).arg(day ) << QString("%1-%2-%3").arg(year).arg(month).arg(day )
<< "This is not a valid date for an Epoch." ; << "This is not a valid date for an Epoch." ;
return SsoElements(); return SsoElements();
} }
//Epoch is at .0 TT, i.e. midnight //Epoch is at .0 TT, i.e. midnight
double epochJD; double epochJD;
StelUtils::getJDFromDate(&epochJD, year, month, day, 0, 0, 0); StelUtils::getJDFromDate(&epochJD, year, month, day, 0, 0, 0);
result.insert("orbit_Epoch", epochJD); result.insert("orbit_Epoch", epochJD);
column = oneLineElements.mid(26, 9).trimmed(); column = oneLineElements.mid(26, 9).trimmed();
double meanAnomalyAtEpoch = column.toDouble(&ok);//degrees double meanAnomalyAtEpoch = column.toDouble(&ok);//degrees
if (!ok) if (!ok)
return SsoElements(); return SsoElements();
result.insert("orbit_MeanAnomaly", meanAnomalyAtEpoch); result.insert("orbit_MeanAnomaly", meanAnomalyAtEpoch);
// add period for visualization of orbit // add period for visualization of orbit
if (semiMajorAxis>0) if (semiMajorAxis>0)
result.insert("orbit_visualization_period", StelUtils::calcu lateSiderealPeriod(semiMajorAxis)); result.insert("orbit_visualization_period", StelUtils::calcu lateSiderealPeriod(semiMajorAxis));
// 2:3 resonanse to Neptune // 2:3 resonance to Neptune [https://en.wikipedia.org/wiki/Plutino]
if ((int)semiMajorAxis == 39) if ((int)semiMajorAxis == 39)
objectType = "plutino"; objectType = "plutino";
// Classical Kuiper belt objects // Classical Kuiper belt objects [https://en.wikipedia.org/wiki/Clas sical_Kuiper_belt_object]
if (semiMajorAxis>=40 && semiMajorAxis<=50) if (semiMajorAxis>=40 && semiMajorAxis<=50)
objectType = "cubewano"; objectType = "cubewano";
// Calculate perihelion // Calculate perihelion
float r = (1 - eccentricity)*semiMajorAxis; float r = (1 - eccentricity)*semiMajorAxis;
// Scattered disc objects // Scattered disc objects
if (r > 35) if (r > 35)
objectType = "scattered disc object"; objectType = "scattered disc object";
// Sednoids // Sednoids [https://en.wikipedia.org/wiki/Planet_Nine]
if (r > 50 && semiMajorAxis > 150) if (r > 30 && semiMajorAxis > 250)
objectType = "sednoid"; objectType = "sednoid";
//Radius and albedo //Radius and albedo
//Assume albedo of 0.15 and calculate a radius based on the absolute magnitude //Assume albedo of 0.15 and calculate a radius based on the absolute magnitude
//as described here: http://www.physics.sfasu.edu/astro/asteroids/si zemagnitude.html //as described here: http://www.physics.sfasu.edu/astro/asteroids/si zemagnitude.html
double albedo = 0.15; //Assumed double albedo = 0.15; //Assumed
double radius = std::ceil((1329 / std::sqrt(albedo)) * std::pow(10, -0.2 * absoluteMagnitude)); double radius = std::ceil((1329 / std::sqrt(albedo)) * std::pow(10, -0.2 * absoluteMagnitude));
result.insert("albedo", albedo); result.insert("albedo", albedo);
result.insert("radius", radius); result.insert("radius", radius);
result.insert("type", objectType); result.insert("type", objectType);
return result; return result;
} }
/* DEAD CODE. MAYBE REACTIVATE FOR SCRIPTING ACCESS
SsoElements SolarSystemEditor::readXEphemOneLineElements(QString oneLineEle ments) SsoElements SolarSystemEditor::readXEphemOneLineElements(QString oneLineEle ments)
{ {
SsoElements result; SsoElements result;
enum OrbitType {Elliptic, Hyperbolic, Parabolic} orbitType; enum OrbitType {Elliptic, Hyperbolic, Parabolic} orbitType;
QStringList fields = oneLineElements.split(','); QStringList fields = oneLineElements.split(',');
if (fields.isEmpty() || fields.count() < 10 || fields.count() > 14) if (fields.isEmpty() || fields.count() < 10 || fields.count() > 14)
return result; return result;
//qDebug() << fields; //qDebug() << fields;
skipping to change at line 1049 skipping to change at line 1119
if (r > 50 && semiMajorAxis > 150) if (r > 50 && semiMajorAxis > 150)
objectType = "sednoid"; objectType = "sednoid";
} }
result.insert("albedo", albedo); result.insert("albedo", albedo);
result.insert("radius", radius); result.insert("radius", radius);
result.insert("type", objectType); result.insert("type", objectType);
return result; return result;
} }
*/
QList<SsoElements> SolarSystemEditor::readMpcOneLineCometElementsFromFile(Q String filePath) QList<SsoElements> SolarSystemEditor::readMpcOneLineCometElementsFromFile(Q String filePath) const
{ {
QList<SsoElements> objectList; QList<SsoElements> objectList;
if (!QFile::exists(filePath)) if (!QFile::exists(filePath))
{ {
qDebug() << "Can't find" << QDir::toNativeSeparators(filePat h); qDebug() << "Can't find" << QDir::toNativeSeparators(filePat h);
return objectList; return objectList;
} }
QFile mpcElementsFile(filePath); QFile mpcElementsFile(filePath);
skipping to change at line 1104 skipping to change at line 1175
else else
{ {
qDebug() << "Unable to open for reading" << QDir::toNativeSe parators(filePath); qDebug() << "Unable to open for reading" << QDir::toNativeSe parators(filePath);
qDebug() << "File error:" << mpcElementsFile.errorString(); qDebug() << "File error:" << mpcElementsFile.errorString();
return objectList; return objectList;
} }
return objectList; return objectList;
} }
QList<SsoElements> SolarSystemEditor::readMpcOneLineMinorPlanetElementsFrom File(QString filePath) QList<SsoElements> SolarSystemEditor::readMpcOneLineMinorPlanetElementsFrom File(QString filePath) const
{ {
QList<SsoElements> objectList; QList<SsoElements> objectList;
if (!QFile::exists(filePath)) if (!QFile::exists(filePath))
{ {
qDebug() << "Can't find" << QDir::toNativeSeparators(filePat h); qDebug() << "Can't find" << QDir::toNativeSeparators(filePat h);
return objectList; return objectList;
} }
QFile mpcElementsFile(filePath); QFile mpcElementsFile(filePath);
skipping to change at line 1158 skipping to change at line 1229
else else
{ {
qDebug() << "Unable to open for reading" << QDir::toNativeSe parators(filePath); qDebug() << "Unable to open for reading" << QDir::toNativeSe parators(filePath);
qDebug() << "File error:" << mpcElementsFile.errorString(); qDebug() << "File error:" << mpcElementsFile.errorString();
return objectList; return objectList;
} }
return objectList; return objectList;
} }
/*
* // UNUSED FUNCTON as of 0.16pre. Maybe reactivate as public slot for scr
ipting.
QList<SsoElements> SolarSystemEditor::readXEphemOneLineElementsFromFile(QSt ring filePath) QList<SsoElements> SolarSystemEditor::readXEphemOneLineElementsFromFile(QSt ring filePath)
{ {
QList<SsoElements> objectList; QList<SsoElements> objectList;
if (!QFile::exists(filePath)) if (!QFile::exists(filePath))
{ {
qDebug() << "Can't find" << QDir::toNativeSeparators(filePat h); qDebug() << "Can't find" << QDir::toNativeSeparators(filePat h);
return objectList; return objectList;
} }
skipping to change at line 1216 skipping to change at line 1289
} }
else else
{ {
qDebug() << "Unable to open for reading" << QDir::toNativeSe parators(filePath); qDebug() << "Unable to open for reading" << QDir::toNativeSe parators(filePath);
qDebug() << "File error:" << xEphemElementsFile.errorString( ); qDebug() << "File error:" << xEphemElementsFile.errorString( );
return objectList; return objectList;
} }
return objectList; return objectList;
} }
*/
bool SolarSystemEditor::appendToSolarSystemConfigurationFile(QList<SsoEleme nts> objectList) bool SolarSystemEditor::appendToSolarSystemConfigurationFile(QList<SsoEleme nts> objectList)
{ {
qDebug() << "appendToSolarSystemConfigurationFile begin ... "; // GZ qDebug() << "appendToSolarSystemConfigurationFile begin ... ";
if (objectList.isEmpty()) if (objectList.isEmpty())
{ {
return false; return false;
} }
//Check if the configuration file exists //Check if the configuration file exists
if (!QFile::exists(customSolarSystemFilePath)) if (!QFile::exists(customSolarSystemFilePath))
{ {
qDebug() << "Can't append object data to ssystem.ini: Unable to find" << QDir::toNativeSeparators(customSolarSystemFilePath); qDebug() << "Can't append object data to ssystem_minor.ini: Unable to find" << QDir::toNativeSeparators(customSolarSystemFilePath);
return false; return false;
} }
QHash<QString,QString> loadedObjects = listAllLoadedSsoIdentifiers() ; QHash<QString,QString> loadedObjects = listAllLoadedSsoIdentifiers() ;
//Remove duplicates (identified by name, not by section name) //Remove duplicates (identified by name, not by section name)
QSettings * solarSystemSettings = new QSettings(customSolarSystemFil ePath, QSettings::IniFormat); QSettings * solarSystemSettings = new QSettings(customSolarSystemFil ePath, StelIniFormat);
if (solarSystemSettings->status() != QSettings::NoError) if (solarSystemSettings->status() != QSettings::NoError)
{ {
qDebug() << "Error opening ssystem.ini:" << QDir::toNativeSe parators(customSolarSystemFilePath); qDebug() << "Error opening ssystem_minor.ini:" << QDir::toNa tiveSeparators(customSolarSystemFilePath);
return false; return false;
} }
foreach (SsoElements object, objectList) foreach (SsoElements object, objectList)
{ {
QString name = object.value("name").toString(); QString name = object.value("name").toString();
if (name.isEmpty()) if (name.isEmpty())
continue; continue;
QString group = object.value("section_name").toString(); QString group = object.value("section_name").toString();
if (group.isEmpty()) if (group.isEmpty())
skipping to change at line 1264 skipping to change at line 1337
loadedObjects.remove(name); loadedObjects.remove(name);
} }
else if (solarSystemSettings->childGroups().contains(group)) else if (solarSystemSettings->childGroups().contains(group))
{ {
loadedObjects.remove(solarSystemSettings->value(grou p + "/name").toString()); loadedObjects.remove(solarSystemSettings->value(grou p + "/name").toString());
solarSystemSettings->remove(group); solarSystemSettings->remove(group);
} }
} }
solarSystemSettings->sync(); solarSystemSettings->sync();
delete solarSystemSettings; delete solarSystemSettings;
solarSystemSettings = NULL; solarSystemSettings = Q_NULLPTR;
//Write to file //Write to file. (Handle as regular text file, not QSettings.)
//TODO: The usual validation //TODO: The usual validation
qDebug() << "Appending to file..."; qDebug() << "Appending to file...";
QFile solarSystemConfigurationFile(customSolarSystemFilePath); QFile solarSystemConfigurationFile(customSolarSystemFilePath);
if(solarSystemConfigurationFile.open(QFile::WriteOnly | QFile::Appen d | QFile::Text)) if(solarSystemConfigurationFile.open(QFile::WriteOnly | QFile::Appen d | QFile::Text))
{ {
QTextStream output (&solarSystemConfigurationFile); QTextStream output (&solarSystemConfigurationFile);
bool appendedAtLeastOne = false; bool appendedAtLeastOne = false;
foreach (SsoElements object, objectList) foreach (SsoElements object, objectList)
{ {
skipping to change at line 1300 skipping to change at line 1373
foreach(QString key, object.keys()) foreach(QString key, object.keys())
{ {
output << QString("%1 = %2").arg(key).arg(ob ject.value(key).toString()) << endl; output << QString("%1 = %2").arg(key).arg(ob ject.value(key).toString()) << endl;
} }
output.flush(); output.flush();
qDebug() << "Appended successfully" << sectionName; qDebug() << "Appended successfully" << sectionName;
appendedAtLeastOne = true; appendedAtLeastOne = true;
} }
solarSystemConfigurationFile.close(); solarSystemConfigurationFile.close();
qDebug() << "appendToSolarSystemConfigurationFile appended: " << appendedAtLeastOne; // GZ qDebug() << "appendToSolarSystemConfigurationFile appended: " << appendedAtLeastOne;
return appendedAtLeastOne; return appendedAtLeastOne;
} }
else else
{ {
qDebug() << "Unable to open for writing" << QDir::toNativeSe parators(customSolarSystemFilePath); qDebug() << "Unable to open for writing" << QDir::toNativeSe parators(customSolarSystemFilePath);
return false; return false;
} }
} }
skipping to change at line 1340 skipping to change at line 1413
return true; return true;
} }
//Check if the configuration file exists //Check if the configuration file exists
if (!QFile::exists(customSolarSystemFilePath)) if (!QFile::exists(customSolarSystemFilePath))
{ {
qDebug() << "Can't update ssystem.ini: Unable to find" << QD ir::toNativeSeparators(customSolarSystemFilePath); qDebug() << "Can't update ssystem.ini: Unable to find" << QD ir::toNativeSeparators(customSolarSystemFilePath);
return false; return false;
} }
QSettings solarSystem(customSolarSystemFilePath, QSettings::IniForma t); QSettings solarSystem(customSolarSystemFilePath, StelIniFormat);
if (solarSystem.status() != QSettings::NoError) if (solarSystem.status() != QSettings::NoError)
{ {
qDebug() << "Error opening ssystem.ini:" << QDir::toNativeSe parators(customSolarSystemFilePath); qDebug() << "Error opening ssystem.ini:" << QDir::toNativeSe parators(customSolarSystemFilePath);
return false; return false;
} }
QStringList existingSections = solarSystem.childGroups(); QStringList existingSections = solarSystem.childGroups();
QHash<QString,QString> loadedObjects = listAllLoadedSsoIdentifiers() ; QHash<QString,QString> loadedObjects = listAllLoadedSsoIdentifiers() ;
//TODO: Move to contstructor? //TODO: Move to constructor?
// This list of elements gets temporarily deleted.
// GZ: Note that the original implementation assumed that the coord_
func could ever change. This is not possible at least in 0.13 and later:
// ell_orbit is used for moons (distances in km) while comet_orbit i
s used for minor bodies around the sun.
QStringList orbitalElementsKeys; QStringList orbitalElementsKeys;
orbitalElementsKeys << "coord_func" orbitalElementsKeys << "coord_func"
<< "orbit_ArgOfPericenter" << "orbit_ArgOfPericenter"
<< "orbit_AscendingNode" << "orbit_AscendingNode"
<< "orbit_Eccentricity" << "orbit_Eccentricity"
<< "orbit_Epoch" << "orbit_Epoch"
<< "orbit_good" // GZ // GZ It seems to have been an error to include these. They might simply b
ADDITION (4x) e updated without prior deletion.
<< "dust_lengthfactor" // << "orbit_good"
<< "dust_brightnessfactor" // << "dust_lengthfactor"
<< "dust_widthfactor" // << "dust_brightnessfactor"
// << "dust_widthfactor"
<< "orbit_Inclination" << "orbit_Inclination"
<< "orbit_LongOfPericenter" << "orbit_LongOfPericenter"
<< "orbit_MeanAnomaly" << "orbit_MeanAnomaly"
<< "orbit_MeanLongitude" << "orbit_MeanLongitude"
<< "orbit_MeanMotion" << "orbit_MeanMotion"
<< "orbit_PericenterDistance" << "orbit_PericenterDistance"
<< "orbit_Period" << "orbit_Period"
<< "orbit_SemiMajorAxis" << "orbit_SemiMajorAxis"
<< "orbit_TimeAtPericenter"; << "orbit_TimeAtPericenter";
skipping to change at line 1433 skipping to change at line 1510
if (flags.testFlag(UpdateType)) if (flags.testFlag(UpdateType))
{ {
updateSsoProperty(solarSystem, object, "type"); updateSsoProperty(solarSystem, object, "type");
} }
if (flags.testFlag(UpdateOrbitalElements)) if (flags.testFlag(UpdateOrbitalElements))
{ {
//Remove all orbital elements first, in case //Remove all orbital elements first, in case
//the new ones use another coordinate function //the new ones use another coordinate function
// GZ This seems completely useless now. Type of orb it will not change as it is always comet_orbit.
foreach (QString key, orbitalElementsKeys) foreach (QString key, orbitalElementsKeys)
{ {
solarSystem.remove(key); solarSystem.remove(key);
} }
foreach (QString key, orbitalElementsKeys) foreach (QString key, orbitalElementsKeys)
{ {
updateSsoProperty(solarSystem, object, key); updateSsoProperty(solarSystem, object, key);
} }
} }
if (flags.testFlag(UpdateMagnitudeParameters)) if (flags.testFlag(UpdateMagnitudeParameters))
{ {
if (object.contains("absolute_magnitude") && object. contains("slope_parameter")) if (object.contains("absolute_magnitude") && object. contains("slope_parameter"))
{ {
QString type = solarSystem.value("type").toS tring(); QString type = solarSystem.value("type").toS tring();
if (type == "asteroid" || type == "comet" ) if (type == "asteroid" || type == "plutino" || type == "cubewano" || type == "scattered disc object" || type == "sednoi d" || type == "comet" )
{ {
updateSsoProperty(solarSystem, objec t, "absolute_magnitude"); updateSsoProperty(solarSystem, objec t, "absolute_magnitude");
updateSsoProperty(solarSystem, objec t, "slope_parameter"); updateSsoProperty(solarSystem, objec t, "slope_parameter");
} }
else else
{ {
//TODO: Do what, log a message? //TODO: Do what, log a message?
} }
} }
} }
skipping to change at line 1498 skipping to change at line 1576
//insert the minor planet number in the section name //insert the minor planet number in the section name
//(if an asteroid is named, it must be numbered) //(if an asteroid is named, it must be numbered)
if (minorPlanetNumber) if (minorPlanetNumber)
{ {
groupName.prepend(QString::number(minorPlanetNumber)); groupName.prepend(QString::number(minorPlanetNumber));
} }
return groupName; return groupName;
} }
QString SolarSystemEditor::fixGroupName(QString &name)
{
QString groupName(name);
groupName.replace("%25", "%");
groupName.replace("%28", "(");
groupName.replace("%29", ")");
return groupName;
}
int SolarSystemEditor::unpackDayOrMonthNumber(QChar digit) int SolarSystemEditor::unpackDayOrMonthNumber(QChar digit)
{ {
//0-9, 0 is an invalid value, but the function is supposed to return 0 on failure. //0-9, 0 is an invalid value in the designed use of this function.
if (digit.isDigit()) if (digit.isDigit())
{ {
return digit.digitValue(); return digit.digitValue();
} }
if (digit.isUpper()) if (digit.isUpper())
{ {
char letter = digit.toLatin1(); char letter = digit.toLatin1();
if (letter < 'A' || letter > 'V') if (letter < 'A' || letter > 'V')
return 0; return 0;
return (10 + (letter - 'A')); return (10 + (letter - 'A'));
} }
else else
{ {
return 0; return -1;
} }
} }
int SolarSystemEditor::unpackYearNumber (QChar prefix, int lastTwoDigits) int SolarSystemEditor::unpackYearNumber (QChar prefix, int lastTwoDigits)
{ {
int year = lastTwoDigits; int year = lastTwoDigits;
if (prefix == 'I') if (prefix == 'I')
year += 1800; year += 1800;
else if (prefix == 'J') else if (prefix == 'J')
year += 1900; year += 1900;
 End of changes. 72 change blocks. 
106 lines changed or deleted 229 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/