StarMgr.cpp   StarMgr.cpp 
skipping to change at line 67 skipping to change at line 67
#include <QCryptographicHash> #include <QCryptographicHash>
#include <errno.h> #include <errno.h>
static QStringList spectral_array; static QStringList spectral_array;
static QStringList component_array; static QStringList component_array;
// This number must be incremented each time the content or file format of the stars catalogs change // This number must be incremented each time the content or file format of the stars catalogs change
// It can also be incremented when the defaultStarsConfig.json file change. // It can also be incremented when the defaultStarsConfig.json file change.
// It should always matchs the version field of the defaultStarsConfig.json file // It should always matchs the version field of the defaultStarsConfig.json file
static const int StarCatalogFormatVersion = 7; static const int StarCatalogFormatVersion = 8;
// Initialise statics // Initialise statics
bool StarMgr::flagSciNames = true; bool StarMgr::flagSciNames = true;
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, wds> StarMgr::wdsStarsMapI18n;
QMap<QString, int> StarMgr::wdsStarsIndexI18n;
QHash<int, int> StarMgr::saoStarsMap; QHash<int, int> StarMgr::saoStarsMap;
QMap<int, int> StarMgr::saoStarsIndex; QMap<int, int> StarMgr::saoStarsIndex;
QHash<int, int> StarMgr::hdStarsMap; QHash<int, int> StarMgr::hdStarsMap;
QMap<int, int> StarMgr::hdStarsIndex; 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))
skipping to change at line 201 skipping to change at line 203
} }
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 StarMgr::getCrossIdentificationDesignations(int hip)
{ {
QString designations; QString designations;
QHash<int,int>::const_iterator it(saoStarsMap.find(hip)); QHash<int,int>::const_iterator it(saoStarsMap.find(hip));
if (it!=saoStarsMap.end()) if (it!=saoStarsMap.end())
designations = QString("SAO %1").arg(it.value()); designations = QString("SAO %1").arg(it.value());
QHash<int,int>::const_iterator it2(hdStarsMap.find(hip)); QHash<int,int>::const_iterator it2(hdStarsMap.find(hip));
if (it2!=hdStarsMap.end()) if (it2!=hdStarsMap.end())
{ {
if (designations.isEmpty()) if (designations.isEmpty())
designations = QString("HD %1").arg(it2.value()); designations = QString("HD %1").arg(it2.value());
else else
designations += QString(" - HD %1").arg(it2.value()) ; designations += QString(" - HD %1").arg(it2.value()) ;
} }
return designations; return designations;
} }
QString StarMgr::getWdsName(int hip)
{
QHash<int,wds>::const_iterator it(wdsStarsMapI18n.find(hip));
if (it!=wdsStarsMapI18n.end())
return QString("WDS J%1").arg(it.value().designation);
return QString();
}
int StarMgr::getWdsLastObservation(int hip)
{
QHash<int,wds>::const_iterator it(wdsStarsMapI18n.find(hip));
if (it!=wdsStarsMapI18n.end())
return it.value().observation;
return 0;
}
int StarMgr::getWdsLastPositionAngle(int hip)
{
QHash<int,wds>::const_iterator it(wdsStarsMapI18n.find(hip));
if (it!=wdsStarsMapI18n.end())
return it.value().positionAngle;
return 0;
}
float StarMgr::getWdsLastSeparation(int hip)
{
QHash<int,wds>::const_iterator it(wdsStarsMapI18n.find(hip));
if (it!=wdsStarsMapI18n.end())
return it.value().separation;
return 0.f;
}
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 358 skipping to change at line 392
} }
} }
loadData(starSettings); loadData(starSettings);
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
QString defaultColor = conf->value("color/default_color").toString()
;
setLabelColor(StelUtils::strToVec3f(conf->value("color/star_label_co
lor", defaultColor).toString()));
objectMgr->registerStelObjectMgr(this); objectMgr->registerStelObjectMgr(this);
texPointer = StelApp::getInstance().getTextureManager().createTextur e(StelFileMgr::getInstallationDir()+"/textures/pointeur2.png"); // Load p ointer texture texPointer = StelApp::getInstance().getTextureManager().createTextur e(StelFileMgr::getInstallationDir()+"/textures/pointeur2.png"); // Load p ointer texture
StelApp::getInstance().getCore()->getGeodesicGrid(maxGeodesicGridLev el)->visitTriangles(maxGeodesicGridLevel,initTriangleFunc,this); StelApp::getInstance().getCore()->getGeodesicGrid(maxGeodesicGridLev el)->visitTriangles(maxGeodesicGridLevel,initTriangleFunc,this);
foreach(ZoneArray* z, gridLevels) foreach(ZoneArray* z, gridLevels)
z->scaleAxis(); z->scaleAxis();
StelApp *app = &StelApp::getInstance(); StelApp *app = &StelApp::getInstance();
connect(app, SIGNAL(languageChanged()), this, SLOT(updateI18n())); connect(app, SIGNAL(languageChanged()), this, SLOT(updateI18n()));
connect(app, SIGNAL(skyCultureChanged(const QString&)), this, SLOT(u connect(&app->getSkyCultureMgr(), SIGNAL(currentSkyCultureChanged(QS
pdateSkyCulture(const QString&))); tring)), this, SLOT(updateSkyCulture(const QString&)));
connect(app, SIGNAL(colorSchemeChanged(const QString&)), this, SLOT(
setStelStyle(const QString&)));
QString displayGroup = N_("Display Options"); QString displayGroup = N_("Display Options");
addAction("actionShow_Stars", displayGroup, N_("Stars"), "flagStarsD isplayed", "S"); addAction("actionShow_Stars", displayGroup, N_("Stars"), "flagStarsD isplayed", "S");
addAction("actionShow_Stars_Labels", displayGroup, N_("Stars labels" ), "flagLabelsDisplayed", "Alt+S"); addAction("actionShow_Stars_Labels", displayGroup, N_("Stars labels" ), "flagLabelsDisplayed", "Alt+S");
} }
void StarMgr::drawPointer(StelPainter& sPainter, const StelCore* core) void StarMgr::drawPointer(StelPainter& sPainter, const StelCore* core)
{ {
const QList<StelObjectP> newSelected = objectMgr->getSelectedObject( "Star"); const QList<StelObjectP> newSelected = objectMgr->getSelectedObject( "Star");
if (!newSelected.empty()) if (!newSelected.empty())
skipping to change at line 393 skipping to change at line 430
// Compute 2D pos and return if outside screen // Compute 2D pos and return if outside screen
if (!sPainter.getProjector()->project(pos, screenpos)) if (!sPainter.getProjector()->project(pos, screenpos))
return; return;
Vec3f c(obj->getInfoColor()); Vec3f c(obj->getInfoColor());
sPainter.setColor(c[0], c[1], c[2]); sPainter.setColor(c[0], c[1], c[2]);
texPointer->bind(); texPointer->bind();
sPainter.enableTexture2d(true); sPainter.enableTexture2d(true);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transparency mode glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transparency mode
sPainter.drawSprite2dMode(screenpos[0], screenpos[1], 13.f, StelApp::getInstance().getTotalRunTime()*40.); sPainter.drawSprite2dMode(screenpos[0], screenpos[1], 13.f, StelApp::getInstance().getAnimationTime()*40.);
} }
} }
void StarMgr::setStelStyle(const QString& section)
{
// Load colors from config file
QSettings* conf = StelApp::getInstance().getSettings();
QString defaultColor = conf->value(section+"/default_color").toStrin
g();
setLabelColor(StelUtils::strToVec3f(conf->value(section+"/star_label
_color", defaultColor).toString()));
}
bool StarMgr::checkAndLoadCatalog(const QVariantMap& catDesc) bool StarMgr::checkAndLoadCatalog(const QVariantMap& catDesc)
{ {
const bool checked = catDesc.value("checked").toBool(); const bool checked = catDesc.value("checked").toBool();
QString catalogFileName = catDesc.value("fileName").toString(); QString catalogFileName = catDesc.value("fileName").toString();
// See if it is an absolute path, else prepend default path // See if it is an absolute path, else prepend default path
if (!(StelFileMgr::isAbsolute(catalogFileName))) if (!(StelFileMgr::isAbsolute(catalogFileName)))
catalogFileName = "stars/default/"+catalogFileName; catalogFileName = "stars/default/"+catalogFileName;
QString catalogFilePath = StelFileMgr::findFile(catalogFileName); QString catalogFilePath = StelFileMgr::findFile(catalogFileName);
skipping to change at line 802 skipping to change at line 830
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 // Load WDS from file
void StarMgr::loadCrossIndex(const QString& crossIndexFile) void StarMgr::loadWds(const QString& WdsFile)
{
wdsStarsMapI18n.clear();
wdsStarsIndexI18n.clear();
qDebug() << "Loading double stars from" << QDir::toNativeSeparators(
WdsFile);
QFile dsFile(WdsFile);
if (!dsFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
qWarning() << "WARNING - could not open" << QDir::toNativeSe
parators(WdsFile);
return;
}
const QStringList& allRecords = QString::fromUtf8(dsFile.readAll()).
split('\n');
dsFile.close();
int readOk=0;
int totalRecords=0;
int lineNumber=0;
// record structure is delimited with a tab character.
foreach(const QString& record, allRecords)
{
++lineNumber;
if (record.isEmpty())
continue;
++totalRecords;
const QStringList& fields = record.split('\t');
bool ok;
unsigned int hip = fields.at(0).toUInt(&ok);
if (!ok)
{
qWarning() << "WARNING - parse error at line" << lin
eNumber << "in" << QDir::toNativeSeparators(WdsFile)
<< " - failed to convert " << fields.at(0
) << "to a number";
continue;
}
// Don't set the star if it's already set
if (wdsStarsMapI18n.find(hip)!=wdsStarsMapI18n.end())
continue;
wds doubleStar;
doubleStar.designation = fields.at(1).trimmed();
doubleStar.observation = fields.at(2).toInt();
doubleStar.positionAngle = fields.at(3).toFloat();
doubleStar.separation = fields.at(4).toFloat();
wdsStarsMapI18n[hip] = doubleStar;
wdsStarsIndexI18n[QString("WDS J%1").arg(doubleStar.designat
ion.toUpper())] = hip;
++readOk;
}
qDebug() << "Loaded" << readOk << "/" << totalRecords << "double sta
rs";
}
// Load cross-identification data from file
void StarMgr::loadCrossIdentificationData(const QString& crossIdFile)
{ {
saoStarsMap.clear(); saoStarsMap.clear();
saoStarsIndex.clear(); saoStarsIndex.clear();
hdStarsMap.clear(); hdStarsMap.clear();
hdStarsIndex.clear(); hdStarsIndex.clear();
qDebug() << "Loading cross-index data from" << QDir::toNativeSeparat qDebug() << "Loading cross-identification data from" << QDir::toNati
ors(crossIndexFile); veSeparators(crossIdFile);
QFile ciFile(crossIndexFile); QFile ciFile(crossIdFile);
if (!ciFile.open(QIODevice::ReadOnly | QIODevice::Text)) if (!ciFile.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
qWarning() << "WARNING - could not open" << QDir::toNativeSe parators(crossIndexFile); qWarning() << "WARNING - could not open" << QDir::toNativeSe parators(crossIdFile);
return; return;
} }
const QStringList& allRecords = QString::fromUtf8(ciFile.readAll()). split('\n'); const QStringList& allRecords = QString::fromUtf8(ciFile.readAll()). split('\n');
ciFile.close(); ciFile.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. Example rec ord strings: // record structure is delimited with a 'tab' character. Example rec ord strings:
// "1 128522 224700" // "1 128522 224700"
skipping to change at line 836 skipping to change at line 922
foreach(const QString& record, allRecords) foreach(const QString& record, allRecords)
{ {
++lineNumber; ++lineNumber;
if (record.isEmpty()) if (record.isEmpty())
continue; continue;
++totalRecords; ++totalRecords;
const QStringList& fields = record.split('\t'); const QStringList& fields = record.split('\t');
if (fields.size()!=3) if (fields.size()!=3)
{ {
qWarning() << "WARNING - parse error at line" << lin eNumber << "in" << QDir::toNativeSeparators(crossIndexFile) qWarning() << "WARNING - parse error at line" << lin eNumber << "in" << QDir::toNativeSeparators(crossIdFile)
<< " - record does not match record patte rn"; << " - record does not match record patte rn";
continue; continue;
} }
else else
{ {
// The record is the right format. Extract the fiel ds // The record is the right format. Extract the fiel ds
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 " << lineNumber << "in" << QDir::toNativeSeparators(crossIndexFile) qWarning() << "WARNING - parse error at line " << lineNumber << "in" << QDir::toNativeSeparators(crossIdFile)
<< " - failed to convert " << fie lds.at(0) << "to a number"; << " - failed to convert " << fie lds.at(0) << "to a number";
continue; continue;
} }
unsigned int sao = fields.at(1).toUInt(&ok); unsigned int sao = fields.at(1).toUInt(&ok);
unsigned int hd = fields.at(2).toUInt(&ok); unsigned int hd = fields.at(2).toUInt(&ok);
if (sao>0) if (sao>0)
{ {
saoStarsMap[hip] = sao; saoStarsMap[hip] = sao;
skipping to change at line 871 skipping to change at line 957
if (hd>0) if (hd>0)
{ {
hdStarsMap[hip] = hd; hdStarsMap[hip] = hd;
hdStarsIndex[hd] = hip; hdStarsIndex[hd] = hip;
} }
++readOk; ++readOk;
} }
} }
qDebug() << "Loaded" << readOk << "/" << totalRecords << "cross-inde x data records"; qDebug() << "Loaded" << readOk << "/" << totalRecords << "cross-iden tification data records for stars";
} }
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)
skipping to change at line 1135 skipping to change at line 1221
return searchHP(it3.value()); return searchHP(it3.value());
} }
// Search by GCVS name // Search by GCVS name
QMap<QString,int>::const_iterator it4 = varStarsIndexI18n.find(objw) ; QMap<QString,int>::const_iterator it4 = varStarsIndexI18n.find(objw) ;
if (it4!=varStarsIndexI18n.end()) if (it4!=varStarsIndexI18n.end())
{ {
return searchHP(it4.value()); return searchHP(it4.value());
} }
// Search by WDS name
QMap<QString,int>::const_iterator wdsIt = wdsStarsIndexI18n.find(obj
w);
if (wdsIt!=wdsStarsIndexI18n.end())
{
return searchHP(wdsIt.value());
}
return StelObjectP(); return StelObjectP();
} }
StelObjectP StarMgr::searchByName(const QString& name) const StelObjectP StarMgr::searchByName(const QString& name) const
{ {
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))
skipping to change at line 1195 skipping to change at line 1288
// 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();
} }
//! Find and return the list of at most maxNbItem objects auto-completing //! Find and return the list of at most maxNbItem objects auto-completing t
//! the passed object I18n name. he passed object name.
QStringList StarMgr::listMatchingObjectsI18n(const QString& objPrefix, int QStringList StarMgr::listMatchingObjects(const QString& objPrefix, int maxN
maxNbItem, bool useStartOfWords) const bItem, bool useStartOfWords, bool inEnglish) const
{ {
QStringList result; QStringList result;
if (maxNbItem==0) return result; if (maxNbItem <= 0)
{
return result;
}
QString objw = objPrefix.toUpper(); QString objw = objPrefix.toUpper();
QMap<QString, int> cNamesIdx = inEnglish ? commonNamesIndex : common
NamesIndexI18n;
// Search for common names // Search for common names
if (useStartOfWords) { if (useStartOfWords)
for (QMap<QString,int>::const_iterator it(commonNamesIndexI1 {
8n.lowerBound(objw)); it!=commonNamesIndexI18n.end(); ++it) for (QMap<QString,int>::const_iterator it(cNamesIdx.lowerBou
nd(objw)); it!=cNamesIdx.end(); ++it)
{ {
if (it.key().startsWith(objw)) if (it.key().startsWith(objw))
{ {
if (maxNbItem==0) if (maxNbItem<=0)
break; break;
result << getCommonName(it.value()); result.append(inEnglish ? getCommonEnglishNa me(it.value()) : getCommonName(it.value()));
--maxNbItem; --maxNbItem;
} }
else else
break; break;
} }
} }
else else
{ {
QMapIterator<QString, int> i(commonNamesIndexI18n); QMapIterator<QString, int> i(cNamesIdx);
while (i.hasNext()) while (i.hasNext())
{ {
i.next(); i.next();
if (i.key().contains(objw)) if (i.key().contains(objw))
{ {
if (maxNbItem==0) if (maxNbItem<=0)
break; break;
result << getCommonName(i.value()); result.append(inEnglish ? getCommonEnglishNa me(i.value()) : getCommonName(i.value()));
--maxNbItem; --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?"));
for (QMap<QString,int>::const_iterator it(sciNamesIndexI18n.lowerBou nd(objw)); it!=sciNamesIndexI18n.end(); ++it) for (QMap<QString,int>::const_iterator it(sciNamesIndexI18n.lowerBou nd(objw)); it!=sciNamesIndexI18n.end(); ++it)
{ {
if (it.key().indexOf(bayerRegEx)==0) if (it.key().indexOf(bayerRegEx)==0)
{ {
if (maxNbItem==0) if (maxNbItem<=0)
break; break;
result << getSciName(it.value()); result << getSciName(it.value());
--maxNbItem; --maxNbItem;
} }
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(sciAdditionalNamesIndexI18 n.lowerBound(objw)); it!=sciAdditionalNamesIndexI18n.end(); ++it) for (QMap<QString,int>::const_iterator it(sciAdditionalNamesIndexI18 n.lowerBound(objw)); it!=sciAdditionalNamesIndexI18n.end(); ++it)
{ {
if (it.key().indexOf(bayerRegEx)==0) if (it.key().indexOf(bayerRegEx)==0)
{ {
if (maxNbItem==0) if (maxNbItem<=0)
break; break;
result << getSciAdditionalName(it.value()); result << getSciAdditionalName(it.value());
--maxNbItem; --maxNbItem;
} }
else if (it.key().at(0) != objw.at(0)) else if (it.key().at(0) != objw.at(0))
break; break;
} }
// 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*$");
skipping to change at line 1339 skipping to change at line 1438
{ {
StelObjectP s = searchHP(hd.value()); StelObjectP s = searchHP(hd.value());
if (s && maxNbItem>0) if (s && maxNbItem>0)
{ {
result << QString("HD%1").arg(hdNum); result << QString("HD%1").arg(hdNum);
maxNbItem--; maxNbItem--;
} }
} }
} }
result.sort(); // Add exact WDS catalogue numbers
return result; QRegExp wdsRx("^(WDS)\\s*(\\S+)\\s*$");
} wdsRx.setCaseSensitivity(Qt::CaseInsensitive);
if (wdsRx.exactMatch(objw))
//! Find and return the list of at most maxNbItem objects auto-completing
//! the passed object English name.
QStringList StarMgr::listMatchingObjects(const QString& objPrefix, int maxN
bItem, bool useStartOfWords) const
{
QStringList result;
if (maxNbItem==0) return result;
QString objw = objPrefix.toUpper();
// Search for common names
if (useStartOfWords)
{ {
for (QMap<QString,int>::const_iterator it(commonNamesIndex.l owerBound(objw)); it!=commonNamesIndex.end(); ++it) for (QMap<QString,int>::const_iterator wds(wdsStarsIndexI18n .lowerBound(objw)); wds!=wdsStarsIndexI18n.end(); ++wds)
{ {
if (it.key().startsWith(objw)) if (wds.key().startsWith(objw))
{ {
if (maxNbItem==0) if (maxNbItem==0)
break; break;
result << getCommonEnglishName(it.value()); result << getWdsName(wds.value());
--maxNbItem; --maxNbItem;
} }
else else
break; break;
} }
} }
else
{
QMapIterator<QString, int> i(commonNamesIndex);
while (i.hasNext())
{
i.next();
if (i.key().contains(objw))
{
if (maxNbItem==0)
break;
result << getCommonEnglishName(i.value());
--maxNbItem;
}
}
}
// Search for sci names
QString bayerPattern = objw;
QRegExp bayerRegEx(bayerPattern);
// if the first character is a Greek letter, check if there's an ind
ex
// after it, such as "alpha1 Cen".
if (objw.at(0).unicode() >= 0x0391 && objw.at(0).unicode() <= 0x03A9
)
bayerRegEx.setPattern(bayerPattern.insert(1,"\\d?"));
for (QMap<QString,int>::const_iterator it(sciNamesIndexI18n.lowerBou
nd(objw)); it!=sciNamesIndexI18n.end(); ++it)
{
if (it.key().indexOf(bayerRegEx)==0)
{
if (maxNbItem==0)
break;
result << getSciName(it.value());
--maxNbItem;
}
else if (it.key().at(0) != objw.at(0))
break;
}
for (QMap<QString,int>::const_iterator it(sciAdditionalNamesIndexI18
n.lowerBound(objw)); it!=sciAdditionalNamesIndexI18n.end(); ++it)
{
if (it.key().indexOf(bayerRegEx)==0)
{
if (maxNbItem==0)
break;
result << getSciAdditionalName(it.value());
--maxNbItem;
}
else if (it.key().at(0) != objw.at(0))
break;
}
// Search for sci names for var stars
for (QMap<QString,int>::const_iterator it(varStarsIndexI18n.lowerBou
nd(objw)); it!=varStarsIndexI18n.end(); ++it)
{
if (it.key().startsWith(objw))
{
if (maxNbItem==0)
break;
result << getGcvsName(it.value());
--maxNbItem;
}
else
break;
}
// Add exact Hp catalogue numbers
QRegExp hpRx("^(HIP|HP)\\s*(\\d+)\\s*$");
hpRx.setCaseSensitivity(Qt::CaseInsensitive);
if (hpRx.exactMatch(objw))
{
bool ok;
int hpNum = hpRx.capturedTexts().at(2).toInt(&ok);
if (ok)
{
StelObjectP s = searchHP(hpNum);
if (s && maxNbItem>0)
{
result << QString("HIP%1").arg(hpNum);
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 1520 skipping to change at line 1488
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"); fic = StelFileMgr::findFile("stars/default/wds_hip_part.dat");
if (fic.isEmpty())
qWarning() << "WARNING: could not load double stars file: st
ars/default/wds_hip_part.dat";
else
loadWds(fic);
fic = StelFileMgr::findFile("stars/default/cross-id.dat");
if (fic.isEmpty()) if (fic.isEmpty())
qWarning() << "WARNING: could not load cross-index data file : stars/default/cross-index.dat"; qWarning() << "WARNING: could not load cross-identification data file: stars/default/cross-id.dat";
else else
loadCrossIndex(fic); loadCrossIdentificationData(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)
 End of changes. 36 change blocks. 
191 lines changed or deleted 168 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/