StarMgr.cpp   StarMgr.cpp 
skipping to change at line 81 skipping to change at line 81
QHash<int,QString> StarMgr::commonNamesMap; QHash<int,QString> StarMgr::commonNamesMap;
QHash<int,QString> StarMgr::commonNamesMapI18n; QHash<int,QString> StarMgr::commonNamesMapI18n;
QMap<QString,int> StarMgr::commonNamesIndexI18n; QMap<QString,int> StarMgr::commonNamesIndexI18n;
QMap<QString,int> StarMgr::commonNamesIndex; QMap<QString,int> StarMgr::commonNamesIndex;
QHash<int,QString> StarMgr::sciNamesMapI18n; QHash<int,QString> StarMgr::sciNamesMapI18n;
QMap<QString,int> StarMgr::sciNamesIndexI18n; QMap<QString,int> StarMgr::sciNamesIndexI18n;
QHash<int,QString> StarMgr::sciAdditionalNamesMapI18n; QHash<int,QString> StarMgr::sciAdditionalNamesMapI18n;
QMap<QString,int> StarMgr::sciAdditionalNamesIndexI18n; QMap<QString,int> StarMgr::sciAdditionalNamesIndexI18n;
QHash<int, varstar> StarMgr::varStarsMapI18n; QHash<int, varstar> StarMgr::varStarsMapI18n;
QMap<QString, int> StarMgr::varStarsIndexI18n; QMap<QString, int> StarMgr::varStarsIndexI18n;
QHash<int, int> StarMgr::saoStarsMap;
QMap<int, int> StarMgr::saoStarsIndex;
QHash<int, int> StarMgr::hdStarsMap;
QMap<int, int> StarMgr::hdStarsIndex;
QStringList initStringListFromFile(const QString& file_name) QStringList initStringListFromFile(const QString& file_name)
{ {
QStringList list; QStringList list;
QFile f(file_name); QFile f(file_name);
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) if (f.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
while (!f.atEnd()) while (!f.atEnd())
{ {
QString s = QString::fromUtf8(f.readLine()); QString s = QString::fromUtf8(f.readLine());
skipping to change at line 197 skipping to change at line 201
} }
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::getCrossIndexDesignations(int hip)
{
QString designations;
QHash<int,int>::const_iterator it(saoStarsMap.find(hip));
if (it!=saoStarsMap.end())
designations = QString("SAO %1").arg(it.value());
QHash<int,int>::const_iterator it2(hdStarsMap.find(hip));
if (it2!=hdStarsMap.end())
{
if (designations.isEmpty())
designations = QString("HD %1").arg(it2.value());
else
designations += QString(" - HD %1").arg(it2.value())
;
}
return designations;
}
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)
{ {
skipping to change at line 752 skipping to change at line 775
} }
// 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;
variableStar.designation = fields.at(1).trimmed(); variableStar.designation = fields.at(1).trimmed();
variableStar.vtype = fields.at(2).trimmed(); variableStar.vtype = fields.at(2).trimmed();
variableStar.maxmag = fields.at(3).toFloat(); if (fields.at(3).isEmpty())
variableStar.maxmag = 99.f;
else
variableStar.maxmag = fields.at(3).toFloat();
variableStar.mflag = fields.at(4).toInt(); variableStar.mflag = fields.at(4).toInt();
variableStar.min1mag = fields.at(5).toFloat(); if (fields.at(5).isEmpty())
variableStar.min1mag = 99.f;
else
variableStar.min1mag = fields.at(5).toFloat();
if (fields.at(6).isEmpty()) if (fields.at(6).isEmpty())
variableStar.min2mag = 99.f; variableStar.min2mag = 99.f;
else else
variableStar.min2mag = fields.at(6).toFloat(); variableStar.min2mag = fields.at(6).toFloat();
variableStar.photosys = fields.at(7).trimmed(); variableStar.photosys = fields.at(7).trimmed();
variableStar.epoch = fields.at(8).toDouble(); variableStar.epoch = fields.at(8).toDouble();
variableStar.period = fields.at(9).toDouble(); variableStar.period = fields.at(9).toDouble();
variableStar.Mm = fields.at(10).toInt(); variableStar.Mm = fields.at(10).toInt();
variableStar.stype = fields.at(11).trimmed(); variableStar.stype = fields.at(11).trimmed();
varStarsMapI18n[hip] = variableStar; varStarsMapI18n[hip] = variableStar;
varStarsIndexI18n[variableStar.designation.toUpper()] = hip; varStarsIndexI18n[variableStar.designation.toUpper()] = hip;
++readOk; ++readOk;
} }
qDebug() << "Loaded" << readOk << "/" << totalRecords << "variable s tars"; qDebug() << "Loaded" << readOk << "/" << totalRecords << "variable s tars";
} }
// Load cross-index data from file
void StarMgr::loadCrossIndex(const QString& crossIndexFile)
{
saoStarsMap.clear();
saoStarsIndex.clear();
hdStarsMap.clear();
hdStarsIndex.clear();
qDebug() << "Loading cross-index data from" << QDir::toNativeSeparat
ors(crossIndexFile);
QFile ciFile(crossIndexFile);
if (!ciFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
qWarning() << "WARNING - could not open" << QDir::toNativeSe
parators(crossIndexFile);
return;
}
const QStringList& allRecords = QString::fromUtf8(ciFile.readAll()).
split('\n');
ciFile.close();
int readOk=0;
int totalRecords=0;
int lineNumber=0;
// record structure is delimited with a 'tab' character. Example rec
ord strings:
// "1 128522 224700"
// "2 165988 224690"
foreach(const QString& record, allRecords)
{
++lineNumber;
if (record.isEmpty())
continue;
++totalRecords;
const QStringList& fields = record.split('\t');
if (fields.size()!=3)
{
qWarning() << "WARNING - parse error at line" << lin
eNumber << "in" << QDir::toNativeSeparators(crossIndexFile)
<< " - record does not match record patte
rn";
continue;
}
else
{
// The record is the right format. Extract the fiel
ds
bool ok;
unsigned int hip = fields.at(0).toUInt(&ok);
if (!ok)
{
qWarning() << "WARNING - parse error at line
" << lineNumber << "in" << QDir::toNativeSeparators(crossIndexFile)
<< " - failed to convert " << fie
lds.at(0) << "to a number";
continue;
}
unsigned int sao = fields.at(1).toUInt(&ok);
unsigned int hd = fields.at(2).toUInt(&ok);
if (sao>0)
{
saoStarsMap[hip] = sao;
saoStarsIndex[sao] = hip;
}
if (hd>0)
{
hdStarsMap[hip] = hd;
hdStarsIndex[hd] = hip;
}
++readOk;
}
}
qDebug() << "Loaded" << readOk << "/" << totalRecords << "cross-inde
x data records";
}
int StarMgr::getMaxSearchLevel() const int StarMgr::getMaxSearchLevel() const
{ {
int rval = -1; int rval = -1;
foreach(const ZoneArray* z, gridLevels) foreach(const ZoneArray* z, gridLevels)
{ {
const float mag_min = 0.001f*z->mag_min; const float mag_min = 0.001f*z->mag_min;
RCMag rcmag; RCMag rcmag;
if (StelApp::getInstance().getCore()->getSkyDrawer()->comput eRCMag(mag_min, &rcmag)==false) if (StelApp::getInstance().getCore()->getSkyDrawer()->comput eRCMag(mag_min, &rcmag)==false)
break; break;
rval = z->level; rval = z->level;
skipping to change at line 984 skipping to change at line 1085
{ {
QString objw = nameI18n.toUpper(); QString objw = nameI18n.toUpper();
// Search by HP number if it's an HP formated number // Search by HP number if it's an HP formated number
QRegExp rx("^\\s*(HIP|HP)\\s*(\\d+)\\s*$", Qt::CaseInsensitive); QRegExp rx("^\\s*(HIP|HP)\\s*(\\d+)\\s*$", Qt::CaseInsensitive);
if (rx.exactMatch(objw)) if (rx.exactMatch(objw))
{ {
return searchHP(rx.capturedTexts().at(2).toInt()); return searchHP(rx.capturedTexts().at(2).toInt());
} }
// Search by SAO number if it's an SAO formated number
QRegExp rx2("^\\s*(SAO)\\s*(\\d+)\\s*$", Qt::CaseInsensitive);
if (rx2.exactMatch(objw))
{
QMap<int,int>::const_iterator sao(saoStarsIndex.find(rx2.cap
turedTexts().at(2).toInt()));
if (sao!=saoStarsIndex.end())
{
return searchHP(sao.value());
}
}
// Search by HD number if it's an HD formated number
QRegExp rx3("^\\s*(HD)\\s*(\\d+)\\s*$", Qt::CaseInsensitive);
if (rx3.exactMatch(objw))
{
QMap<int,int>::const_iterator hd(hdStarsIndex.find(rx3.captu
redTexts().at(2).toInt()));
if (hd!=hdStarsIndex.end())
{
return searchHP(hd.value());
}
}
// Search by I18n common name // Search by I18n common name
QMap<QString,int>::const_iterator it(commonNamesIndexI18n.find(objw) ); QMap<QString,int>::const_iterator it(commonNamesIndexI18n.find(objw) );
if (it!=commonNamesIndexI18n.end()) if (it!=commonNamesIndexI18n.end())
{ {
return searchHP(it.value()); return searchHP(it.value());
} }
// Search by sci name // Search by sci name
QMap<QString,int>::const_iterator it2 = sciNamesIndexI18n.find(objw) ; QMap<QString,int>::const_iterator it2 = sciNamesIndexI18n.find(objw) ;
if (it2!=sciNamesIndexI18n.end()) if (it2!=sciNamesIndexI18n.end())
skipping to change at line 1026 skipping to change at line 1149
{ {
QString objw = name.toUpper(); QString objw = name.toUpper();
// Search by HP number if it's an HP formated number // Search by HP number if it's an HP formated number
QRegExp rx("^\\s*(HP|HIP)\\s*(\\d+)\\s*$", Qt::CaseInsensitive); QRegExp rx("^\\s*(HP|HIP)\\s*(\\d+)\\s*$", Qt::CaseInsensitive);
if (rx.exactMatch(objw)) if (rx.exactMatch(objw))
{ {
return searchHP(rx.capturedTexts().at(2).toInt()); return searchHP(rx.capturedTexts().at(2).toInt());
} }
// Search by SAO number if it's an SAO formated number
QRegExp rx2("^\\s*(SAO)\\s*(\\d+)\\s*$", Qt::CaseInsensitive);
if (rx2.exactMatch(objw))
{
QMap<int,int>::const_iterator sao(saoStarsIndex.find(rx2.cap
turedTexts().at(2).toInt()));
if (sao!=saoStarsIndex.end())
{
return searchHP(sao.value());
}
}
// Search by HD number if it's an HD formated number
QRegExp rx3("^\\s*(HD)\\s*(\\d+)\\s*$", Qt::CaseInsensitive);
if (rx3.exactMatch(objw))
{
QMap<int,int>::const_iterator hd(hdStarsIndex.find(rx3.captu
redTexts().at(2).toInt()));
if (hd!=hdStarsIndex.end())
{
return searchHP(hd.value());
}
}
// Search by I18n common name // Search by I18n common name
QMap<QString,int>::const_iterator it(commonNamesIndex.find(objw)); QMap<QString,int>::const_iterator it(commonNamesIndex.find(objw));
if (it!=commonNamesIndex.end()) if (it!=commonNamesIndex.end())
{ {
return searchHP(it.value()); return searchHP(it.value());
} }
// Search by sci name // Search by sci name
QMap<QString,int>::const_iterator it2 = sciNamesIndexI18n.find(objw) ; QMap<QString,int>::const_iterator it2 = sciNamesIndexI18n.find(objw) ;
if (it2!=sciNamesIndexI18n.end()) if (it2!=sciNamesIndexI18n.end())
skipping to change at line 1156 skipping to change at line 1301
{ {
StelObjectP s = searchHP(hpNum); StelObjectP s = searchHP(hpNum);
if (s && maxNbItem>0) if (s && maxNbItem>0)
{ {
result << QString("HIP%1").arg(hpNum); result << QString("HIP%1").arg(hpNum);
maxNbItem--; maxNbItem--;
} }
} }
} }
// Add exact SAO catalogue numbers
QRegExp saoRx("^(SAO)\\s*(\\d+)\\s*$");
saoRx.setCaseSensitivity(Qt::CaseInsensitive);
if (saoRx.exactMatch(objw))
{
bool ok;
int saoNum = saoRx.capturedTexts().at(2).toInt(&ok);
QMap<int,int>::const_iterator sao(saoStarsIndex.find(saoNum)
);
if (sao!=saoStarsIndex.end())
{
StelObjectP s = searchHP(sao.value());
if (s && maxNbItem>0)
{
result << QString("SAO%1").arg(saoNum);
maxNbItem--;
}
}
}
// Add exact HD catalogue numbers
QRegExp hdRx("^(HD)\\s*(\\d+)\\s*$");
hdRx.setCaseSensitivity(Qt::CaseInsensitive);
if (hdRx.exactMatch(objw))
{
bool ok;
int hdNum = hdRx.capturedTexts().at(2).toInt(&ok);
QMap<int,int>::const_iterator hd(hdStarsIndex.find(hdNum));
if (hd!=hdStarsIndex.end())
{
StelObjectP s = searchHP(hd.value());
if (s && maxNbItem>0)
{
result << QString("HD%1").arg(hdNum);
maxNbItem--;
}
}
}
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, bool useStartOfWords) 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;
skipping to change at line 1268 skipping to change at line 1451
{ {
StelObjectP s = searchHP(hpNum); StelObjectP s = searchHP(hpNum);
if (s && maxNbItem>0) if (s && maxNbItem>0)
{ {
result << QString("HIP%1").arg(hpNum); result << QString("HIP%1").arg(hpNum);
maxNbItem--; maxNbItem--;
} }
} }
} }
// Add exact SAO catalogue numbers
QRegExp saoRx("^(SAO)\\s*(\\d+)\\s*$");
saoRx.setCaseSensitivity(Qt::CaseInsensitive);
if (saoRx.exactMatch(objw))
{
bool ok;
int saoNum = saoRx.capturedTexts().at(2).toInt(&ok);
QMap<int,int>::const_iterator sao(saoStarsIndex.find(saoNum)
);
if (sao!=saoStarsIndex.end())
{
StelObjectP s = searchHP(sao.value());
if (s && maxNbItem>0)
{
result << QString("SAO%1").arg(saoNum);
maxNbItem--;
}
}
}
// Add exact HD catalogue numbers
QRegExp hdRx("^(HD)\\s*(\\d+)\\s*$");
hdRx.setCaseSensitivity(Qt::CaseInsensitive);
if (hdRx.exactMatch(objw))
{
bool ok;
int hdNum = hdRx.capturedTexts().at(2).toInt(&ok);
QMap<int,int>::const_iterator hd(hdStarsIndex.find(hdNum));
if (hd!=hdStarsIndex.end())
{
StelObjectP s = searchHP(hd.value());
if (s && maxNbItem>0)
{
result << QString("HD%1").arg(hdNum);
maxNbItem--;
}
}
}
result.sort(); result.sort();
return result; return result;
} }
//! Define font file name and size to use for star names display //! Define font file name and size to use for star names display
void StarMgr::setFontSize(float newFontSize) void StarMgr::setFontSize(float newFontSize)
{ {
starFont.setPixelSize(newFontSize); starFont.setPixelSize(newFontSize);
} }
skipping to change at line 1299 skipping to change at line 1520
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
loadGcvs(fic); loadGcvs(fic);
fic = StelFileMgr::findFile("stars/default/cross-index.dat");
if (fic.isEmpty())
qWarning() << "WARNING: could not load cross-index data file
: stars/default/cross-index.dat";
else
loadCrossIndex(fic);
// 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();
} }
QStringList StarMgr::listAllObjects(bool inEnglish) const QStringList StarMgr::listAllObjects(bool inEnglish) const
{ {
QStringList result; QStringList result;
if (inEnglish) if (inEnglish)
{ {
skipping to change at line 1327 skipping to change at line 1554
{ {
QMapIterator<QString, int> i(commonNamesIndexI18n); QMapIterator<QString, int> i(commonNamesIndexI18n);
while (i.hasNext()) while (i.hasNext())
{ {
i.next(); i.next();
result << getCommonName(i.value()); result << getCommonName(i.value());
} }
} }
return result; return result;
} }
QStringList StarMgr::listAllObjectsByType(const QString &objType, bool inEn
glish) const
{
QStringList result;
int type = objType.toInt();
// Use SkyTranslator for translation star names
const StelTranslator& trans = StelApp::getInstance().getLocaleMgr().
getSkyTranslator();
switch (type)
{
case 0: // Double stars
{
QStringList doubleStars;
doubleStars << "Asterope" << "Atlas" << "77 Tau" <<
"δ1 Tau" << "V1016 Ori"
<< "42 Ori" << "ι Ori" << "ζ Crv" << "M
izar" << "Zubenelgenubi"
<< "ω1 Sco" << "λ Sco" << "μ1 Sco" << "
ζ1 Sco" << "ε1 Lyr" << "δ1 Lyr"
<< "ν1 Sgr" << "ο1 Cyg" << "ο2 Cyg" <<
"Algedi" << "Albireo" << "Rigel"
<< "Almaak" << "ξ Boo" << "Rasalgethi"
<< "T Dra" << "Kuma" << "70 Oph"
<< "Castor" << "ζ Her" << "Keid" << "Me
sarthim" << "Porrima" << "Algieba"
<< "β Mon" << "Izar" << "44 Boo" << "Ac
rab" << "Tegmine" << "φ2 Cnc"
<< "Regulus" << "Cor Caroli" << "ι Cas"
<< "ε Ari" << "Markeb" << "γ1 Del"
<< "Bessel's Star" << "55 Aqr" << "σ Ca
s" << "Achird" << "Polaris" << "36 Oph"
<< "65 UMa" << "σ2 UMa" << "55 Cnc" <<
"16 Cyg" << "HIP 28393" << "HIP 84709";
if (inEnglish)
{
result = doubleStars;
}
else
{
foreach (QString star, doubleStars)
{
result << trans.qtranslate(star);
}
}
break;
}
case 1: // Variable stars
{
QStringList variableStars;
variableStars << "δ Cep" << "Algol" << "Mira" << "λ
Tau" << "Sheliak" << "ζ Gem" << "μ Cep"
<< "Rasalgethi" << "η Gem" << "η Aql"
<< "γ Cas" << "Betelgeuse" << "R And"
<< "U Ant" << "θ Aps" << "R Aql" << "V
Aql" << "R Aqr" << "ε Aur" << "R Aur"
<< "AE Aur" << "W Boo" << "VZ Cam" <<
"l Car" << "γ Cas" << "WZ Cas"
<< "S Cen" << "Proxima" << "T Cep" <<
"U Cep" << "R CMa" << "VY CMa"
<< "S Cnc" << "Alphekka" << "R CrB" <<
"T CrB" << "U CrB" << "R Cru"
<< "SU Cyg" << "EU Del" << "β Dor" <<
"R Gem" << "30 Her" << "68 Her"
<< "R Hor" << "Hind's Crimson Star" <<
"R Leo" << "RR Lyr" << "U Mon"
<< "Mintaka" << "VV Ori" << "κ Pav" <<
"β Peg" << "Enif" << "ζ Phe" << "R Sct"
<< "U Sgr" << "RY Sgr" << "W UMa" << "
Polaris";
if (inEnglish)
{
result = variableStars;
}
else
{
foreach (QString star, variableStars)
{
result << trans.qtranslate(star);
}
}
break;
}
default:
{
// No stars yet?
break;
}
}
result.removeDuplicates();
return result;
}
 End of changes. 11 change blocks. 
2 lines changed or deleted 247 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/