StarMgr.cpp   StarMgr.cpp 
skipping to change at line 199 skipping to change at line 199
} }
QString StarMgr::getSciAdditionalName(int hip) QString StarMgr::getSciAdditionalName(int hip)
{ {
QHash<int,QString>::const_iterator it(sciAdditionalNamesMapI18n.find (hip)); QHash<int,QString>::const_iterator it(sciAdditionalNamesMapI18n.find (hip));
if (it!=sciAdditionalNamesMapI18n.end()) if (it!=sciAdditionalNamesMapI18n.end())
return it.value(); return it.value();
return QString(); return QString();
} }
QString StarMgr::getGCVSName(int hip) QString StarMgr::getGcvsName(int hip)
{ {
QHash<int,varstar>::const_iterator it(varStarsMapI18n.find(hip)); QHash<int,varstar>::const_iterator it(varStarsMapI18n.find(hip));
if (it!=varStarsMapI18n.end()) if (it!=varStarsMapI18n.end())
return it.value().designation; return it.value().designation;
return QString(); return QString();
} }
QString StarMgr::getGCVSVariabilityType(int hip) QString StarMgr::getGcvsVariabilityType(int hip)
{ {
QHash<int,varstar>::const_iterator it(varStarsMapI18n.find(hip)); QHash<int,varstar>::const_iterator it(varStarsMapI18n.find(hip));
if (it!=varStarsMapI18n.end()) if (it!=varStarsMapI18n.end())
return it.value().vtype; return it.value().vtype;
return QString(); return QString();
} }
float StarMgr::getGCVSMaxMagnitude(int hip) float StarMgr::getGcvsMaxMagnitude(int hip)
{ {
QHash<int,varstar>::const_iterator it(varStarsMapI18n.find(hip)); QHash<int,varstar>::const_iterator it(varStarsMapI18n.find(hip));
if (it!=varStarsMapI18n.end()) if (it!=varStarsMapI18n.end())
return it.value().maxmag; return it.value().maxmag;
return -99.f; return -99.f;
} }
int StarMgr::getGCVSMagnitudeFlag(int hip) int StarMgr::getGcvsMagnitudeFlag(int hip)
{ {
QHash<int,varstar>::const_iterator it(varStarsMapI18n.find(hip)); QHash<int,varstar>::const_iterator it(varStarsMapI18n.find(hip));
if (it!=varStarsMapI18n.end()) if (it!=varStarsMapI18n.end())
return it.value().mflag; return it.value().mflag;
return 0; return 0;
} }
float StarMgr::getGCVSMinMagnitude(int hip, bool firstMinimumFlag) float StarMgr::getGcvsMinMagnitude(int hip, bool firstMinimumFlag)
{ {
QHash<int,varstar>::const_iterator it(varStarsMapI18n.find(hip)); QHash<int,varstar>::const_iterator it(varStarsMapI18n.find(hip));
if (it!=varStarsMapI18n.end()) if (it!=varStarsMapI18n.end())
{ {
if (firstMinimumFlag) if (firstMinimumFlag)
{ {
return it.value().min1mag; return it.value().min1mag;
} }
else else
{ {
return it.value().min2mag; return it.value().min2mag;
} }
} }
return -99.f; return -99.f;
} }
QString StarMgr::getGCVSPhotometricSystem(int hip) QString StarMgr::getGcvsPhotometricSystem(int hip)
{ {
QHash<int,varstar>::const_iterator it(varStarsMapI18n.find(hip)); QHash<int,varstar>::const_iterator it(varStarsMapI18n.find(hip));
if (it!=varStarsMapI18n.end()) if (it!=varStarsMapI18n.end())
return it.value().photosys; return it.value().photosys;
return QString(); return QString();
} }
double StarMgr::getGCVSEpoch(int hip) double StarMgr::getGcvsEpoch(int hip)
{ {
QHash<int,varstar>::const_iterator it(varStarsMapI18n.find(hip)); QHash<int,varstar>::const_iterator it(varStarsMapI18n.find(hip));
if (it!=varStarsMapI18n.end()) if (it!=varStarsMapI18n.end())
return it.value().epoch; return it.value().epoch;
return -99.f; return -99.f;
} }
double StarMgr::getGCVSPeriod(int hip) double StarMgr::getGcvsPeriod(int hip)
{ {
QHash<int,varstar>::const_iterator it(varStarsMapI18n.find(hip)); QHash<int,varstar>::const_iterator it(varStarsMapI18n.find(hip));
if (it!=varStarsMapI18n.end()) if (it!=varStarsMapI18n.end())
return it.value().period; return it.value().period;
return -99.f; return -99.f;
} }
int StarMgr::getGCVSMM(int hip) int StarMgr::getGcvsMM(int hip)
{ {
QHash<int,varstar>::const_iterator it(varStarsMapI18n.find(hip)); QHash<int,varstar>::const_iterator it(varStarsMapI18n.find(hip));
if (it!=varStarsMapI18n.end()) if (it!=varStarsMapI18n.end())
return it.value().Mm; return it.value().Mm;
return -99; return -99;
} }
void StarMgr::copyDefaultConfigFile() void StarMgr::copyDefaultConfigFile()
{ {
try try
skipping to change at line 729 skipping to change at line 729
sciNamesIndexI18n[sci_name_i18n.toUpper()] = hip; sciNamesIndexI18n[sci_name_i18n.toUpper()] = hip;
} }
++readOk; ++readOk;
} }
} }
qDebug() << "Loaded" << readOk << "/" << totalRecords << "scientific star names"; qDebug() << "Loaded" << readOk << "/" << totalRecords << "scientific star names";
} }
// Load GCVS from file // Load GCVS from file
void StarMgr::loadGCVS(const QString& GCVSFile) void StarMgr::loadGcvs(const QString& GcvsFile)
{ {
varStarsMapI18n.clear(); varStarsMapI18n.clear();
varStarsIndexI18n.clear(); varStarsIndexI18n.clear();
qDebug() << "Loading variable stars from" << QDir::toNativeSeparator qDebug() << "Loading variable stars from" << QDir::toNativeSeparator
s(GCVSFile); s(GcvsFile);
QFile vsFile(GCVSFile); QFile vsFile(GcvsFile);
if (!vsFile.open(QIODevice::ReadOnly | QIODevice::Text)) if (!vsFile.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
qWarning() << "WARNING - could not open" << QDir::toNativeSe parators(GCVSFile); qWarning() << "WARNING - could not open" << QDir::toNativeSe parators(GcvsFile);
return; return;
} }
const QStringList& allRecords = QString::fromUtf8(vsFile.readAll()). split('\n'); const QStringList& allRecords = QString::fromUtf8(vsFile.readAll()). split('\n');
vsFile.close(); vsFile.close();
int readOk=0; int readOk=0;
int totalRecords=0; int totalRecords=0;
int lineNumber=0; int lineNumber=0;
// record structure is delimited with a tab character. // record structure is delimited with a tab character.
skipping to change at line 762 skipping to change at line 762
if (record.isEmpty()) if (record.isEmpty())
continue; continue;
++totalRecords; ++totalRecords;
const QStringList& fields = record.split('\t'); const QStringList& fields = record.split('\t');
bool ok; bool ok;
unsigned int hip = fields.at(0).toUInt(&ok); unsigned int hip = fields.at(0).toUInt(&ok);
if (!ok) if (!ok)
{ {
qWarning() << "WARNING - parse error at line" << lin eNumber << "in" << QDir::toNativeSeparators(GCVSFile) qWarning() << "WARNING - parse error at line" << lin eNumber << "in" << QDir::toNativeSeparators(GcvsFile)
<< " - failed to convert " << fields.at(0 ) << "to a number"; << " - failed to convert " << fields.at(0 ) << "to a number";
continue; continue;
} }
// Don't set the star if it's already set // Don't set the star if it's already set
if (varStarsMapI18n.find(hip)!=varStarsMapI18n.end()) if (varStarsMapI18n.find(hip)!=varStarsMapI18n.end())
continue; continue;
varstar variableStar; varstar variableStar;
skipping to change at line 1064 skipping to change at line 1064
if (it2!=sciAdditionalNamesIndexI18n.end()) if (it2!=sciAdditionalNamesIndexI18n.end())
{ {
return searchHP(it2.value()); return searchHP(it2.value());
} }
return StelObjectP(); return StelObjectP();
} }
//! Find and return the list of at most maxNbItem objects auto-completing //! Find and return the list of at most maxNbItem objects auto-completing
//! the passed object I18n name. //! the passed object I18n name.
QStringList StarMgr::listMatchingObjectsI18n(const QString& objPrefix, int maxNbItem) const QStringList StarMgr::listMatchingObjectsI18n(const QString& objPrefix, int maxNbItem, bool useStartOfWords) const
{ {
QStringList result; QStringList result;
if (maxNbItem==0) return result; if (maxNbItem==0) return result;
QString objw = objPrefix.toUpper(); QString objw = objPrefix.toUpper();
// Search for common names // Search for common names
for (QMap<QString,int>::const_iterator it(commonNamesIndexI18n.lower if (useStartOfWords) {
Bound(objw)); it!=commonNamesIndexI18n.end(); ++it) for (QMap<QString,int>::const_iterator it(commonNamesIndexI1
{ 8n.lowerBound(objw)); it!=commonNamesIndexI18n.end(); ++it)
if (it.key().startsWith(objw))
{ {
if (maxNbItem==0) if (it.key().startsWith(objw))
{
if (maxNbItem==0)
break;
result << getCommonName(it.value());
--maxNbItem;
}
else
break; break;
result << getCommonName(it.value());
--maxNbItem;
} }
else }
break; else
{
QMapIterator<QString, int> i(commonNamesIndexI18n);
while (i.hasNext())
{
i.next();
if (i.key().contains(objw))
{
if (maxNbItem==0)
break;
result << getCommonName(i.value());
--maxNbItem;
}
}
} }
// Search for sci names // Search for sci names
QString bayerPattern = objw; QString bayerPattern = objw;
QRegExp bayerRegEx(bayerPattern); QRegExp bayerRegEx(bayerPattern);
// if the first character is a Greek letter, check if there's an ind ex // if the first character is a Greek letter, check if there's an ind ex
// after it, such as "alpha1 Cen". // after it, such as "alpha1 Cen".
if (objw.at(0).unicode() >= 0x0391 && objw.at(0).unicode() <= 0x03A9 ) if (objw.at(0).unicode() >= 0x0391 && objw.at(0).unicode() <= 0x03A9 )
bayerRegEx.setPattern(bayerPattern.insert(1,"\\d?")); bayerRegEx.setPattern(bayerPattern.insert(1,"\\d?"));
skipping to change at line 1126 skipping to change at line 1143
else if (it.key().at(0) != objw.at(0)) else if (it.key().at(0) != objw.at(0))
break; break;
} }
for (QMap<QString,int>::const_iterator it(varStarsIndexI18n.lowerBou nd(objw)); it!=varStarsIndexI18n.end(); ++it) for (QMap<QString,int>::const_iterator it(varStarsIndexI18n.lowerBou nd(objw)); it!=varStarsIndexI18n.end(); ++it)
{ {
if (it.key().startsWith(objw)) if (it.key().startsWith(objw))
{ {
if (maxNbItem==0) if (maxNbItem==0)
break; break;
result << getGCVSName(it.value()); result << getGcvsName(it.value());
--maxNbItem; --maxNbItem;
} }
else else
break; break;
} }
// Add exact Hp catalogue numbers // Add exact Hp catalogue numbers
QRegExp hpRx("^(HIP|HP)\\s*(\\d+)\\s*$"); QRegExp hpRx("^(HIP|HP)\\s*(\\d+)\\s*$");
hpRx.setCaseSensitivity(Qt::CaseInsensitive); hpRx.setCaseSensitivity(Qt::CaseInsensitive);
if (hpRx.exactMatch(objw)) if (hpRx.exactMatch(objw))
skipping to change at line 1157 skipping to change at line 1174
} }
} }
} }
result.sort(); result.sort();
return result; return result;
} }
//! Find and return the list of at most maxNbItem objects auto-completing //! Find and return the list of at most maxNbItem objects auto-completing
//! the passed object English name. //! the passed object English name.
QStringList StarMgr::listMatchingObjects(const QString& objPrefix, int maxN bItem) const QStringList StarMgr::listMatchingObjects(const QString& objPrefix, int maxN bItem, bool useStartOfWords) const
{ {
QStringList result; QStringList result;
if (maxNbItem==0) return result; if (maxNbItem==0) return result;
QString objw = objPrefix.toUpper(); QString objw = objPrefix.toUpper();
// Search for common names // Search for common names
for (QMap<QString,int>::const_iterator it(commonNamesIndex.lowerBoun d(objw)); it!=commonNamesIndex.end(); ++it) if (useStartOfWords)
{ {
if (it.key().startsWith(objw)) for (QMap<QString,int>::const_iterator it(commonNamesIndex.l owerBound(objw)); it!=commonNamesIndex.end(); ++it)
{ {
if (maxNbItem==0) if (it.key().startsWith(objw))
{
if (maxNbItem==0)
break;
result << getCommonName(it.value());
--maxNbItem;
}
else
break; break;
result << getCommonName(it.value());
--maxNbItem;
} }
else }
break; else
{
QMapIterator<QString, int> i(commonNamesIndex);
while (i.hasNext())
{
i.next();
if (i.key().contains(objw))
{
if (maxNbItem==0)
break;
result << getCommonName(i.value());
--maxNbItem;
}
}
} }
// Search for sci names // Search for sci names
QString bayerPattern = objw; QString bayerPattern = objw;
QRegExp bayerRegEx(bayerPattern); QRegExp bayerRegEx(bayerPattern);
// if the first character is a Greek letter, check if there's an ind ex // if the first character is a Greek letter, check if there's an ind ex
// after it, such as "alpha1 Cen". // after it, such as "alpha1 Cen".
if (objw.at(0).unicode() >= 0x0391 && objw.at(0).unicode() <= 0x03A9 ) if (objw.at(0).unicode() >= 0x0391 && objw.at(0).unicode() <= 0x03A9 )
bayerRegEx.setPattern(bayerPattern.insert(1,"\\d?")); bayerRegEx.setPattern(bayerPattern.insert(1,"\\d?"));
skipping to change at line 1220 skipping to change at line 1255
break; break;
} }
// Search for sci names for var stars // Search for sci names for var stars
for (QMap<QString,int>::const_iterator it(varStarsIndexI18n.lowerBou nd(objw)); it!=varStarsIndexI18n.end(); ++it) for (QMap<QString,int>::const_iterator it(varStarsIndexI18n.lowerBou nd(objw)); it!=varStarsIndexI18n.end(); ++it)
{ {
if (it.key().startsWith(objw)) if (it.key().startsWith(objw))
{ {
if (maxNbItem==0) if (maxNbItem==0)
break; break;
result << getGCVSName(it.value()); result << getGcvsName(it.value());
--maxNbItem; --maxNbItem;
} }
else else
break; break;
} }
// Add exact Hp catalogue numbers // Add exact Hp catalogue numbers
QRegExp hpRx("^(HIP|HP)\\s*(\\d+)\\s*$"); QRegExp hpRx("^(HIP|HP)\\s*(\\d+)\\s*$");
hpRx.setCaseSensitivity(Qt::CaseInsensitive); hpRx.setCaseSensitivity(Qt::CaseInsensitive);
if (hpRx.exactMatch(objw)) if (hpRx.exactMatch(objw))
skipping to change at line 1278 skipping to change at line 1313
{ {
loadSciNames(StelFileMgr::findFile("stars/default/name.fab") ); loadSciNames(StelFileMgr::findFile("stars/default/name.fab") );
} }
catch (std::runtime_error& e) catch (std::runtime_error& e)
{ {
qWarning() << "WARNING: could not load scientific star names file: " << e.what(); qWarning() << "WARNING: could not load scientific star names file: " << e.what();
} }
try try
{ {
loadGCVS(StelFileMgr::findFile("stars/default/gcvs_hip_part. dat")); loadGcvs(StelFileMgr::findFile("stars/default/gcvs_hip_part. dat"));
} }
catch (std::runtime_error& e) catch (std::runtime_error& e)
{ {
qWarning() << "WARNING: could not load variable stars file: " << e.what(); qWarning() << "WARNING: could not load variable stars file: " << e.what();
} }
// Turn on sci names/catalog names for western culture only // Turn on sci names/catalog names for western culture only
setFlagSciNames(skyCultureDir.startsWith("western")); setFlagSciNames(skyCultureDir.startsWith("western"));
updateI18n(); updateI18n();
} }
 End of changes. 27 change blocks. 
36 lines changed or deleted 71 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/