StarMgr.cpp   StarMgr.cpp 
skipping to change at line 418 skipping to change at line 418
copyDefaultConfigFile(); copyDefaultConfigFile();
QFile fic2(starConfigFileFullPath); QFile fic2(starConfigFileFullPath);
if(fic2.open(QIODevice::ReadOnly)) if(fic2.open(QIODevice::ReadOnly))
{ {
starSettings = StelJsonParser::parse(&fic2).toMap(); starSettings = StelJsonParser::parse(&fic2).toMap();
fic2.close(); fic2.close();
} }
} }
loadData(starSettings); loadData(starSettings);
populateStarsDesignations();
populateHipparcosLists();
starFont.setPixelSize(StelApp::getInstance().getBaseFontSize()); starFont.setPixelSize(StelApp::getInstance().getBaseFontSize());
setFlagStars(conf->value("astro/flag_stars", true).toBool()); setFlagStars(conf->value("astro/flag_stars", true).toBool());
setFlagLabels(conf->value("astro/flag_star_name",true).toBool()); setFlagLabels(conf->value("astro/flag_star_name",true).toBool());
setLabelsAmount(conf->value("stars/labels_amount",3.f).toFloat()); setLabelsAmount(conf->value("stars/labels_amount",3.f).toFloat());
// Load colors from config file // Load colors from config file
QString defaultColor = conf->value("color/default_color").toString() ; QString defaultColor = conf->value("color/default_color").toString() ;
setLabelColor(StelUtils::strToVec3f(conf->value("color/star_label_co lor", defaultColor).toString())); setLabelColor(StelUtils::strToVec3f(conf->value("color/star_label_co lor", defaultColor).toString()));
skipping to change at line 496 skipping to change at line 500
{ {
qWarning() << QString("Warning: User does not have permissio ns to read catalog %1").arg(QDir::toNativeSeparators(catalogFilePath)); qWarning() << QString("Warning: User does not have permissio ns to read catalog %1").arg(QDir::toNativeSeparators(catalogFilePath));
return false; return false;
} }
if (!checked) if (!checked)
{ {
// The file is not checked but we found it, maybe from a pre vious download/version // The file is not checked but we found it, maybe from a pre vious download/version
qWarning() << "Found file " << QDir::toNativeSeparators(cata logFilePath) << ", checking md5sum.."; qWarning() << "Found file " << QDir::toNativeSeparators(cata logFilePath) << ", checking md5sum..";
QFile fic(catalogFilePath); QFile file(catalogFilePath);
if(fic.open(QIODevice::ReadOnly | QIODevice::Unbuffered)) if(file.open(QIODevice::ReadOnly | QIODevice::Unbuffered))
{ {
// Compute the MD5 sum // Compute the MD5 sum
QCryptographicHash md5Hash(QCryptographicHash::Md5); QCryptographicHash md5Hash(QCryptographicHash::Md5);
const qint64 cat_sz = fic.size(); const qint64 cat_sz = file.size();
qint64 maxStarBufMd5 = qMin(cat_sz, 9223372036854775 807LL); qint64 maxStarBufMd5 = qMin(cat_sz, 9223372036854775 807LL);
uchar *cat = maxStarBufMd5 ? fic.map(0, maxStarBufMd 5) : NULL; uchar *cat = maxStarBufMd5 ? file.map(0, maxStarBufM d5) : Q_NULLPTR;
if (!cat) if (!cat)
{ {
// The OS was not able to map the file, reve rt to slower not mmap based method // The OS was not able to map the file, reve rt to slower not mmap based method
static const qint64 maxStarBufMd5 = 1024*102 4*8; static const qint64 maxStarBufMd5 = 1024*102 4*8;
char* mmd5buf = (char*)malloc(maxStarBufMd5) ; char* mmd5buf = (char*)malloc(maxStarBufMd5) ;
while (!fic.atEnd()) while (!file.atEnd())
{ {
qint64 sz = fic.read(mmd5buf, maxSta rBufMd5); qint64 sz = file.read(mmd5buf, maxSt arBufMd5);
md5Hash.addData(mmd5buf, sz); md5Hash.addData(mmd5buf, sz);
} }
free(mmd5buf); free(mmd5buf);
} }
else else
{ {
md5Hash.addData((const char*)cat, cat_sz); md5Hash.addData((const char*)cat, cat_sz);
fic.unmap(cat); file.unmap(cat);
} }
fic.close(); file.close();
if (md5Hash.result().toHex()!=catDesc.value("checksu m").toByteArray()) if (md5Hash.result().toHex()!=catDesc.value("checksu m").toByteArray())
{ {
qWarning() << "Error: File " << QDir::toNati veSeparators(catalogFileName) << " is corrupt, MD5 mismatch! Found " << md5 Hash.result().toHex() << " expected " << catDesc.value("checksum").toByteAr ray(); qWarning() << "Error: File " << QDir::toNati veSeparators(catalogFileName) << " is corrupt, MD5 mismatch! Found " << md5 Hash.result().toHex() << " expected " << catDesc.value("checksum").toByteAr ray();
fic.remove(); file.remove();
return false; return false;
} }
qWarning() << "MD5 sum correct!"; qWarning() << "MD5 sum correct!";
setCheckFlag(catDesc.value("id").toString(), true); setCheckFlag(catDesc.value("id").toString(), true);
} }
} }
ZoneArray* z = ZoneArray::create(catalogFilePath, true); ZoneArray* z = ZoneArray::create(catalogFilePath, true);
if (z) if (z)
{ {
skipping to change at line 628 skipping to change at line 632
{ {
QString tmpFic = StelFileMgr::findFile("stars/default/" + ca t_hip_cids_file_name); QString tmpFic = StelFileMgr::findFile("stars/default/" + ca t_hip_cids_file_name);
if (tmpFic.isEmpty()) if (tmpFic.isEmpty())
qWarning() << "ERROR while loading data from " << QD ir::toNativeSeparators(("stars/default/" + cat_hip_cids_file_name)); qWarning() << "ERROR while loading data from " << QD ir::toNativeSeparators(("stars/default/" + cat_hip_cids_file_name));
else else
component_array = initStringListFromFile(tmpFic); component_array = initStringListFromFile(tmpFic);
} }
lastMaxSearchLevel = maxGeodesicGridLevel; lastMaxSearchLevel = maxGeodesicGridLevel;
qDebug() << "Finished loading star catalogue data, max_geodesic_leve l: " << maxGeodesicGridLevel; qDebug() << "Finished loading star catalogue data, max_geodesic_leve l: " << maxGeodesicGridLevel;
}
void StarMgr::populateHipparcosLists()
{
hipparcosStars.clear(); hipparcosStars.clear();
hipStarsHighPM.clear();
doubleHipStars.clear();
variableHipStars.clear();
const int pmLimit = 1; // arcsecond per year!
for (int hip=0; hip<=NR_OF_HIP; hip++) for (int hip=0; hip<=NR_OF_HIP; hip++)
{ {
const Star1 *const s = hipIndex[hip].s; const Star1 *const s = hipIndex[hip].s;
if (s) if (s)
{ {
const SpecialZoneArray<Star1> *const a = hipIndex[hi p].a; const SpecialZoneArray<Star1> *const a = hipIndex[hi p].a;
const SpecialZoneData<Star1> *const z = hipIndex[hip ].z; const SpecialZoneData<Star1> *const z = hipIndex[hip ].z;
hipparcosStars.push_back(s->createStelObject(a,z)); StelObjectP so = s->createStelObject(a,z);
hipparcosStars.push_back(so);
if (!getGcvsVariabilityType(s->getHip()).isEmpty())
{
QMap<StelObjectP, float> sa;
sa[so] = getGcvsPeriod(s->getHip());
variableHipStars.push_back(sa);
}
if (!getWdsName(s->getHip()).isEmpty())
{
QMap<StelObjectP, float> sd;
sd[so] = getWdsLastSeparation(s->getHip());
doubleHipStars.push_back(sd);
}
// use separate variables for avoid the overflow (es
p. for Barnard's star)
float pmX = 0.1 * s->getDx0();
float pmY = 0.1 * s->getDx1();
float pm = 0.001 * std::sqrt((pmX*pmX) + (pmY*pmY));
if (qAbs(pm)>=pmLimit)
{
QMap<StelObjectP, float> spm;
spm[so] = pm;
hipStarsHighPM.push_back(spm);
}
} }
} }
} }
// Load common names from file // Load common names from file
int StarMgr::loadCommonNames(const QString& commonNameFile) int StarMgr::loadCommonNames(const QString& commonNameFile)
{ {
commonNamesMap.clear(); commonNamesMap.clear();
commonNamesMapI18n.clear(); commonNamesMapI18n.clear();
additionalNamesMap.clear(); additionalNamesMap.clear();
skipping to change at line 762 skipping to change at line 796
} }
// Load scientific names from file // Load scientific names from file
void StarMgr::loadSciNames(const QString& sciNameFile) void StarMgr::loadSciNames(const QString& sciNameFile)
{ {
sciNamesMapI18n.clear(); sciNamesMapI18n.clear();
sciNamesIndexI18n.clear(); sciNamesIndexI18n.clear();
sciAdditionalNamesMapI18n.clear(); sciAdditionalNamesMapI18n.clear();
sciAdditionalNamesIndexI18n.clear(); sciAdditionalNamesIndexI18n.clear();
qDebug() << "Loading star names from" << QDir::toNativeSeparators(sc iNameFile); qDebug() << "Loading scientific star names from" << QDir::toNativeSe parators(sciNameFile);
QFile snFile(sciNameFile); QFile snFile(sciNameFile);
if (!snFile.open(QIODevice::ReadOnly | QIODevice::Text)) if (!snFile.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
qWarning() << "WARNING - could not open" << QDir::toNativeSe parators(sciNameFile); qWarning() << "WARNING - could not open" << QDir::toNativeSe parators(sciNameFile);
return; return;
} }
const QStringList& allRecords = QString::fromUtf8(snFile.readAll()). split('\n'); const QStringList& allRecords = QString::fromUtf8(snFile.readAll()). split('\n');
snFile.close(); snFile.close();
int readOk=0; int readOk=0;
skipping to change at line 1428 skipping to change at line 1462
// Search by additional sci name // Search by additional sci name
QMap<QString,int>::const_iterator it3 = sciAdditionalNamesIndexI18n. find(objw); QMap<QString,int>::const_iterator it3 = sciAdditionalNamesIndexI18n. find(objw);
if (it3!=sciAdditionalNamesIndexI18n.end()) if (it3!=sciAdditionalNamesIndexI18n.end())
{ {
return searchHP(it3.value()); return searchHP(it3.value());
} }
return StelObjectP(); return StelObjectP();
} }
StelObjectP StarMgr::searchByID(const QString &id) const
{
return searchByName(id);
}
//! Find and return the list of at most maxNbItem objects auto-completing t he passed object name. //! Find and return the list of at most maxNbItem objects auto-completing t he passed object name.
QStringList StarMgr::listMatchingObjects(const QString& objPrefix, int maxN bItem, bool useStartOfWords, bool inEnglish) const QStringList StarMgr::listMatchingObjects(const QString& objPrefix, int maxN bItem, bool useStartOfWords, bool inEnglish) const
{ {
QStringList result; QStringList result;
if (maxNbItem <= 0) if (maxNbItem <= 0)
{ {
return result; return result;
} }
QString objw = objPrefix.toUpper(); QString objw = objPrefix.toUpper();
skipping to change at line 1675 skipping to change at line 1714
void StarMgr::updateSkyCulture(const QString& skyCultureDir) void StarMgr::updateSkyCulture(const QString& skyCultureDir)
{ {
// Load culture star names in english // Load culture star names in english
QString fic = StelFileMgr::findFile("skycultures/" + skyCultureDir + "/star_names.fab"); QString fic = StelFileMgr::findFile("skycultures/" + skyCultureDir + "/star_names.fab");
if (fic.isEmpty()) if (fic.isEmpty())
qDebug() << "Could not load star_names.fab for sky culture " << QDir::toNativeSeparators(skyCultureDir); qDebug() << "Could not load star_names.fab for sky culture " << QDir::toNativeSeparators(skyCultureDir);
else else
loadCommonNames(fic); loadCommonNames(fic);
// Turn on sci names/catalog names for western culture only
setFlagSciNames(skyCultureDir.startsWith("western"));
updateI18n();
}
void StarMgr::populateStarsDesignations()
{
QString fic;
fic = StelFileMgr::findFile("stars/default/name.fab"); fic = StelFileMgr::findFile("stars/default/name.fab");
if (fic.isEmpty()) if (fic.isEmpty())
qWarning() << "WARNING: could not load scientific star names file: stars/default/name.fab"; qWarning() << "WARNING: could not load scientific star names file: stars/default/name.fab";
else else
loadSciNames(fic); loadSciNames(fic);
fic = StelFileMgr::findFile("stars/default/gcvs_hip_part.dat"); fic = StelFileMgr::findFile("stars/default/gcvs_hip_part.dat");
if (fic.isEmpty()) if (fic.isEmpty())
qWarning() << "WARNING: could not load variable stars file: stars/default/gcvs_hip_part.dat"; qWarning() << "WARNING: could not load variable stars file: stars/default/gcvs_hip_part.dat";
else else
skipping to change at line 1698 skipping to change at line 1745
if (fic.isEmpty()) if (fic.isEmpty())
qWarning() << "WARNING: could not load double stars file: st ars/default/wds_hip_part.dat"; qWarning() << "WARNING: could not load double stars file: st ars/default/wds_hip_part.dat";
else else
loadWds(fic); loadWds(fic);
fic = StelFileMgr::findFile("stars/default/cross-id.dat"); fic = StelFileMgr::findFile("stars/default/cross-id.dat");
if (fic.isEmpty()) if (fic.isEmpty())
qWarning() << "WARNING: could not load cross-identification data file: stars/default/cross-id.dat"; qWarning() << "WARNING: could not load cross-identification data file: stars/default/cross-id.dat";
else else
loadCrossIdentificationData(fic); loadCrossIdentificationData(fic);
// Turn on sci names/catalog names for western culture only
setFlagSciNames(skyCultureDir.startsWith("western"));
updateI18n();
} }
QStringList StarMgr::listAllObjects(bool inEnglish) const QStringList StarMgr::listAllObjects(bool inEnglish) const
{ {
QStringList result; QStringList result;
if (inEnglish) if (inEnglish)
{ {
QMapIterator<QString, int> i(commonNamesIndex); QMapIterator<QString, int> i(commonNamesIndex);
while (i.hasNext()) while (i.hasNext())
{ {
skipping to change at line 1736 skipping to change at line 1779
} }
QStringList StarMgr::listAllObjectsByType(const QString &objType, bool inEn glish) const QStringList StarMgr::listAllObjectsByType(const QString &objType, bool inEn glish) const
{ {
QStringList result; QStringList result;
int type = objType.toInt(); int type = objType.toInt();
// Use SkyTranslator for translation star names // Use SkyTranslator for translation star names
const StelTranslator& trans = StelApp::getInstance().getLocaleMgr(). getSkyTranslator(); const StelTranslator& trans = StelApp::getInstance().getLocaleMgr(). getSkyTranslator();
switch (type) switch (type)
{ {
case 0: // Double stars case 0: // Interesting double stars
{ {
QStringList doubleStars; QStringList doubleStars;
doubleStars << "Asterope" << "Atlas" << "77 Tau" << "δ1 Tau" << "V1016 Ori" doubleStars << "Asterope" << "Atlas" << "77 Tau" << "δ1 Tau" << "V1016 Ori"
<< "42 Ori" << "ι Ori" << "ζ Crv" << "M izar" << "Zubenelgenubi" << "42 Ori" << "ι Ori" << "ζ Crv" << "M izar" << "Zubenelgenubi"
<< "ω1 Sco" << "λ Sco" << "μ1 Sco" << " ζ1 Sco" << "ε1 Lyr" << "δ1 Lyr" << "ω1 Sco" << "λ Sco" << "μ1 Sco" << " ζ1 Sco" << "ε1 Lyr" << "δ1 Lyr"
<< "ν1 Sgr" << "ο1 Cyg" << "ο2 Cyg" << "Algedi" << "Albireo" << "Rigel" << "ν1 Sgr" << "ο1 Cyg" << "ο2 Cyg" << "Algedi" << "Albireo" << "Rigel"
<< "Almaak" << "ξ Boo" << "Rasalgethi" << "T Dra" << "Kuma" << "70 Oph" << "Almaak" << "ξ Boo" << "Rasalgethi" << "T Dra" << "Kuma" << "70 Oph"
<< "Castor" << "ζ Her" << "Keid" << "Me sarthim" << "Porrima" << "Algieba" << "Castor" << "ζ Her" << "Keid" << "Me sarthim" << "Porrima" << "Algieba"
<< "β Mon" << "Izar" << "44 Boo" << "Ac rab" << "Tegmine" << "φ2 Cnc" << "β Mon" << "Izar" << "44 Boo" << "Ac rab" << "Tegmine" << "φ2 Cnc"
<< "Regulus" << "Cor Caroli" << "ι Cas" << "ε Ari" << "Markeb" << "γ1 Del" << "Regulus" << "Cor Caroli" << "ι Cas" << "ε Ari" << "Markeb" << "γ1 Del"
skipping to change at line 1762 skipping to change at line 1805
} }
else else
{ {
foreach (QString star, doubleStars) foreach (QString star, doubleStars)
{ {
result << trans.qtranslate(star); result << trans.qtranslate(star);
} }
} }
break; break;
} }
case 1: // Variable stars case 1: // Interesting variable stars
{ {
QStringList variableStars; QStringList variableStars;
variableStars << "δ Cep" << "Algol" << "Mira" << "λ Tau" << "Sheliak" << "ζ Gem" << "μ Cep" variableStars << "δ Cep" << "Algol" << "Mira" << "λ Tau" << "Sheliak" << "ζ Gem" << "μ Cep"
<< "Rasalgethi" << "η Gem" << "η Aql" << "γ Cas" << "Betelgeuse" << "R And" << "Rasalgethi" << "η Gem" << "η Aql" << "γ Cas" << "Betelgeuse" << "R And"
<< "U Ant" << "θ Aps" << "R Aql" << "V Aql" << "R Aqr" << "ε Aur" << "R Aur" << "U Ant" << "θ Aps" << "R Aql" << "V Aql" << "R Aqr" << "ε Aur" << "R Aur"
<< "AE Aur" << "W Boo" << "VZ Cam" << "l Car" << "γ Cas" << "WZ Cas" << "AE Aur" << "W Boo" << "VZ Cam" << "l Car" << "γ Cas" << "WZ Cas"
<< "S Cen" << "Proxima" << "T Cep" << "U Cep" << "R CMa" << "VY CMa" << "S Cen" << "Proxima" << "T Cep" << "U Cep" << "R CMa" << "VY CMa"
<< "S Cnc" << "Alphekka" << "R CrB" << "T CrB" << "U CrB" << "R Cru" << "S Cnc" << "Alphekka" << "R CrB" << "T CrB" << "U CrB" << "R Cru"
<< "SU Cyg" << "EU Del" << "β Dor" << "R Gem" << "30 Her" << "68 Her" << "SU Cyg" << "EU Del" << "β Dor" << "R Gem" << "30 Her" << "68 Her"
<< "R Hor" << "Hind's Crimson Star" << "R Leo" << "RR Lyr" << "U Mon" << "R Hor" << "Hind's Crimson Star" << "R Leo" << "RR Lyr" << "U Mon"
skipping to change at line 1788 skipping to change at line 1831
} }
else else
{ {
foreach (QString star, variableStars) foreach (QString star, variableStars)
{ {
result << trans.qtranslate(star); result << trans.qtranslate(star);
} }
} }
break; break;
} }
case 2: // Bright double stars
{
foreach (const StelACStarData& star, doubleHipStars)
{
if (inEnglish)
result << star.firstKey()->getEnglis
hName();
else
result << star.firstKey()->getNameI1
8n();
}
break;
}
case 3: // Bright variable stars
{
foreach (const StelACStarData& star, variableHipStar
s)
{
if (inEnglish)
result << star.firstKey()->getEnglis
hName();
else
result << star.firstKey()->getNameI1
8n();
}
break;
}
case 4:
{
foreach (const StelACStarData& star, hipStarsHighPM)
{
if (inEnglish)
result << star.firstKey()->getEnglis
hName();
else
result << star.firstKey()->getNameI1
8n();
}
}
default: default:
{ {
// No stars yet? // No stars yet?
break; break;
} }
} }
result.removeDuplicates(); result.removeDuplicates();
return result; return result;
} }
QString StarMgr::getStelObjectType() const
{
return STAR_TYPE;
}
 End of changes. 21 change blocks. 
17 lines changed or deleted 100 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/