SolarSystemEditor.cpp   SolarSystemEditor.cpp 
skipping to change at line 24 skipping to change at line 24
* 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 "SolarSystemEditor.hpp" #include "SolarSystemEditor.hpp"
#include "SolarSystemManagerWindow.hpp" #include "SolarSystemManagerWindow.hpp"
#include "StelUtils.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelGui.hpp" #include "StelGui.hpp"
#include "StelGuiItems.hpp" #include "StelGuiItems.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelIniParser.hpp" #include "StelIniParser.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "SolarSystem.hpp" #include "SolarSystem.hpp"
skipping to change at line 59 skipping to change at line 60
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";
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. Still a work in progre ss."); 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. Still a work in progre ss.");
info.version = SOLARSYSTEMEDITOR_VERSION;
return info; return info;
} }
Q_EXPORT_PLUGIN2(SolarSystemEditor, SolarSystemEditorStelPluginInterface)
SolarSystemEditor::SolarSystemEditor() SolarSystemEditor::SolarSystemEditor()
{ {
setObjectName("SolarSystemEditor"); setObjectName("SolarSystemEditor");
isInitialized = false; isInitialized = false;
mainWindow = NULL; mainWindow = NULL;
solarSystemConfigurationFile = NULL; solarSystemConfigurationFile = NULL;
solarSystemManager = GETSTELMODULE(SolarSystem); 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
skipping to change at line 129 skipping to change at line 129
void SolarSystemEditor::deinit() void SolarSystemEditor::deinit()
{ {
// //
} }
void SolarSystemEditor::update(double) //deltaTime void SolarSystemEditor::update(double) //deltaTime
{ {
// //
} }
void SolarSystemEditor::draw(StelCore*, class StelRenderer*) //core 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)
skipping to change at line 421 skipping to change at line 421
" 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)
{ {
SsoElements result; SsoElements result;
qDebug() << "readMpcOneLineCometElements started..."; // GZ
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 473
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");
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");
result.insert("orbit_good", 1000); // default validity for osculatin g elements, days
result.insert("lighting", false); result.insert("lighting", false);
result.insert("color", "1.0, 1.0, 1.0"); result.insert("color", "1.0, 1.0, 1.0");
result.insert("tex_map", "nomap.png"); result.insert("tex_map", "nomap.png");
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();
skipping to change at line 519 skipping to change at line 521
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
result.insert("radius", radius); result.insert("radius", radius);
result.insert("albedo", 1); 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_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.
qDebug() << "readMpcOneLineCometElements done\n";
return result; return result;
} }
SsoElements SolarSystemEditor::readMpcOneLineMinorPlanetElements(QString on eLineElements) SsoElements SolarSystemEditor::readMpcOneLineMinorPlanetElements(QString on eLineElements)
{ {
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.
skipping to change at line 569 skipping to change at line 574
//See if it is a number, but packed //See if it is a number, but packed
//I hope the format is right (I've seen prefixes only betwee n A and P) //I hope the format is right (I've seen prefixes only betwee n A and P)
QRegExp packedMinorPlanetNumber("^([A-Za-z])(\\d+)$"); QRegExp packedMinorPlanetNumber("^([A-Za-z])(\\d+)$");
if (packedMinorPlanetNumber.indexIn(column) == 0) if (packedMinorPlanetNumber.indexIn(column) == 0)
{ {
minorPlanetNumber = packedMinorPlanetNumber.cap(2).t oInt(&ok); minorPlanetNumber = packedMinorPlanetNumber.cap(2).t oInt(&ok);
//TODO: Validation //TODO: Validation
QChar prefix = packedMinorPlanetNumber.cap(1).at(0); QChar prefix = packedMinorPlanetNumber.cap(1).at(0);
if (prefix.isUpper()) if (prefix.isUpper())
{ {
minorPlanetNumber += ((10 + prefix.toAscii() - 'A') * 10000); minorPlanetNumber += ((10 + prefix.toLatin1( ) - 'A') * 10000);
} }
else else
{ {
minorPlanetNumber += ((10 + prefix.toAscii() - 'a' + 26) * 10000); minorPlanetNumber += ((10 + prefix.toLatin1( ) - 'a' + 26) * 10000);
} }
} }
else else
{ {
provisionalDesignation = unpackMinorPlanetProvisiona lDesignation(column); provisionalDesignation = unpackMinorPlanetProvisiona lDesignation(column);
} }
} }
if (minorPlanetNumber) if (minorPlanetNumber)
{ {
skipping to change at line 701 skipping to change at line 706
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():" qDebug() << "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).toAscii()) switch (packedDateFormat.cap(1).at(0).toLatin1())
{ {
case 'I': case 'I':
year += 1800; year += 1800;
break; break;
case 'J': case 'J':
year += 1900; year += 1900;
break; break;
case 'K': case 'K':
default: default:
year += 2000; year += 2000;
skipping to change at line 1151 skipping to change at line 1156
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
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.ini: Unable to find" << QDir::toNativeSeparators(customSolarSystemFilePath);
return false; return false;
skipping to change at line 1231 skipping to change at line 1237
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
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;
} }
} }
bool SolarSystemEditor::appendToSolarSystemConfigurationFile(SsoElements ob ject) bool SolarSystemEditor::appendToSolarSystemConfigurationFile(SsoElements ob ject)
skipping to change at line 1284 skipping to change at line 1292
} }
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 contstructor?
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
ADDITION (4x)
<< "dust_lengthfactor"
<< "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 1445
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, but the function is supposed to return 0 on failure.
if (digit.isDigit()) if (digit.isDigit())
{ {
return digit.digitValue(); return digit.digitValue();
} }
if (digit.isUpper()) if (digit.isUpper())
{ {
char letter = digit.toAscii(); 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 0;
} }
} }
skipping to change at line 1467 skipping to change at line 1479
} }
//Can be used both for minor planets and comets with no additional modifica tion, //Can be used both for minor planets and comets with no additional modifica tion,
//as the regular expression for comets will match only capital letters. //as the regular expression for comets will match only capital letters.
int SolarSystemEditor::unpackAlphanumericNumber (QChar prefix, int lastDigi t) int SolarSystemEditor::unpackAlphanumericNumber (QChar prefix, int lastDigi t)
{ {
int cycleCount = lastDigit; int cycleCount = lastDigit;
if (prefix.isDigit()) if (prefix.isDigit())
cycleCount += prefix.digitValue() * 10; cycleCount += prefix.digitValue() * 10;
else if (prefix.isLetter() && prefix.isUpper()) else if (prefix.isLetter() && prefix.isUpper())
cycleCount += (10 + prefix.toAscii() - QChar('A').toAscii()) * 10; cycleCount += (10 + prefix.toLatin1() - QChar('A').toLatin1( )) * 10;
else if (prefix.isLetter() && prefix.isLower()) else if (prefix.isLetter() && prefix.isLower())
cycleCount += (10 + prefix.toAscii() - QChar('a').toAscii()) * 10 + 26*10; cycleCount += (10 + prefix.toLatin1() - QChar('a').toLatin1( )) * 10 + 26*10;
else else
cycleCount = 0; //Error cycleCount = 0; //Error
return cycleCount; return cycleCount;
} }
QString SolarSystemEditor::unpackMinorPlanetProvisionalDesignation (QString packedDesignation) QString SolarSystemEditor::unpackMinorPlanetProvisionalDesignation (QString packedDesignation)
{ {
QRegExp packedFormat("^([IJK])(\\d\\d)([A-Z])([\\dA-Za-z])(\\d)([A-Z ])$"); QRegExp packedFormat("^([IJK])(\\d\\d)([A-Z])([\\dA-Za-z])(\\d)([A-Z ])$");
if (packedFormat.indexIn(packedDesignation) != 0) if (packedFormat.indexIn(packedDesignation) != 0)
 End of changes. 16 change blocks. 
11 lines changed or deleted 29 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/