NebulaMgr.cpp   NebulaMgr.cpp 
/* /*
* Stellarium * Stellarium
* Copyright (C) 2002 Fabien Chereau * Copyright (C) 2002 Fabien Chereau
* Copyright (C) 2011 Alexander Wolf * Copyright (C) 2011 Alexander Wolf
* Copyright (C) 2015 Georg Zotti
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
skipping to change at line 57 skipping to change at line 58
#include <QStringList> #include <QStringList>
#include <QRegExp> #include <QRegExp>
#include <QDir> #include <QDir>
void NebulaMgr::setLabelsColor(const Vec3f& c) {Nebula::labelColor = c;} void NebulaMgr::setLabelsColor(const Vec3f& c) {Nebula::labelColor = c;}
const Vec3f &NebulaMgr::getLabelsColor(void) const {return Nebula::labelCol or;} const Vec3f &NebulaMgr::getLabelsColor(void) const {return Nebula::labelCol or;}
void NebulaMgr::setCirclesColor(const Vec3f& c) {Nebula::circleColor = c;} void NebulaMgr::setCirclesColor(const Vec3f& c) {Nebula::circleColor = c;}
const Vec3f &NebulaMgr::getCirclesColor(void) const {return Nebula::circleC olor;} const Vec3f &NebulaMgr::getCirclesColor(void) const {return Nebula::circleC olor;}
void NebulaMgr::setCircleScale(float scale) {Nebula::circleScale = scale;} void NebulaMgr::setCircleScale(float scale) {Nebula::circleScale = scale;}
float NebulaMgr::getCircleScale(void) const {return Nebula::circleScale;} float NebulaMgr::getCircleScale(void) const {return Nebula::circleScale;}
void NebulaMgr::setHintsProportional(const bool proportional) {Nebula::draw
HintProportional=proportional;}
bool NebulaMgr::getHintsProportional(void) const {return Nebula::drawHintPr
oportional;}
NebulaMgr::NebulaMgr(void) NebulaMgr::NebulaMgr(void)
: nebGrid(200), : nebGrid(200),
hintsAmount(0), hintsAmount(0),
labelsAmount(0) labelsAmount(0)
{ {
setObjectName("NebulaMgr"); setObjectName("NebulaMgr");
} }
NebulaMgr::~NebulaMgr() NebulaMgr::~NebulaMgr()
{ {
Nebula::texCircle = StelTextureSP(); Nebula::texCircle = StelTextureSP();
Nebula::texGalaxy = StelTextureSP(); Nebula::texGalaxy = StelTextureSP();
Nebula::texOpenCluster = StelTextureSP(); Nebula::texOpenCluster = StelTextureSP();
Nebula::texGlobularCluster = StelTextureSP(); Nebula::texGlobularCluster = StelTextureSP();
Nebula::texPlanetaryNebula = StelTextureSP(); Nebula::texPlanetaryNebula = StelTextureSP();
Nebula::texDiffuseNebula = StelTextureSP(); Nebula::texDiffuseNebula = StelTextureSP();
Nebula::texDarkNebula = StelTextureSP();
Nebula::texOpenClusterWithNebulosity = StelTextureSP(); Nebula::texOpenClusterWithNebulosity = StelTextureSP();
} }
/************************************************************************* /*************************************************************************
Reimplementation of the getCallOrder method Reimplementation of the getCallOrder method
*************************************************************************/ *************************************************************************/
double NebulaMgr::getCallOrder(StelModuleActionName actionName) const double NebulaMgr::getCallOrder(StelModuleActionName actionName) const
{ {
if (actionName==StelModule::ActionDraw) if (actionName==StelModule::ActionDraw)
return StelApp::getInstance().getModuleMgr().getModule("Milk yWay")->getCallOrder(actionName)+10; return StelApp::getInstance().getModuleMgr().getModule("Milk yWay")->getCallOrder(actionName)+10;
skipping to change at line 103 skipping to change at line 107
// 2. load all // 2. load all
// 3. flag in nebula_textures.fab (yuk) // 3. flag in nebula_textures.fab (yuk)
// 4. info.ini file in each set containing a "load at startup" item // 4. info.ini file in each set containing a "load at startup" item
// For now (0.9.0), just load the default set // For now (0.9.0), just load the default set
loadNebulaSet("default"); loadNebulaSet("default");
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
Q_ASSERT(conf); Q_ASSERT(conf);
nebulaFont.setPixelSize(StelApp::getInstance().getBaseFontSize()); nebulaFont.setPixelSize(StelApp::getInstance().getBaseFontSize());
Nebula::texCircle = StelApp::getInstance().get TextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures /neb.png"); // Load circle texture Nebula::texCircle = StelApp::getInstance().get TextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures /neb.png"); // Load circle texture
Nebula::texGalaxy = StelApp::getInstance().get TextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures /neb_gal.png"); // Load ellipse texture Nebula::texGalaxy = StelApp::getInstance().get TextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures /neb_gal.png"); // Load ellipse texture
Nebula::texOpenCluster = StelApp::getInstance().get TextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures /neb_ocl.png"); // Load open cluster marker texture Nebula::texOpenCluster = StelApp::getInstance().get TextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures /neb_ocl.png"); // Load open cluster marker texture
Nebula::texGlobularCluster = StelApp::getInstance().get TextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures /neb_gcl.png"); // Load globular cluster marker texture Nebula::texGlobularCluster = StelApp::getInstance().get TextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures /neb_gcl.png"); // Load globular cluster marker texture
Nebula::texPlanetaryNebula = StelApp::getInstance().get TextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures /neb_pnb.png"); // Load planetary nebula marker texture Nebula::texPlanetaryNebula = StelApp::getInstance().get TextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures /neb_pnb.png"); // Load planetary nebula marker texture
Nebula::texDiffuseNebula = StelApp::getInstance().get TextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures /neb_dif.png"); // Load diffuse nebula marker texture Nebula::texDiffuseNebula = StelApp::getInstance().get TextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures /neb_dif.png"); // Load diffuse nebula marker texture
Nebula::texDarkNebula = StelApp::getInstance().get TextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures /neb_drk.png"); // Load dark nebula marker texture
Nebula::texOpenClusterWithNebulosity = StelApp::getInstance().get TextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures /neb_ocln.png"); // Load Ocl/Nebula marker texture Nebula::texOpenClusterWithNebulosity = StelApp::getInstance().get TextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures /neb_ocln.png"); // Load Ocl/Nebula marker texture
texPointer = StelApp::getInstance().getTextureManager().createTextur e(StelFileMgr::getInstallationDir()+"/textures/pointeur5.png"); // Load p ointer texture texPointer = StelApp::getInstance().getTextureManager().createTextur e(StelFileMgr::getInstallationDir()+"/textures/pointeur5.png"); // Load p ointer texture
setFlagShow(conf->value("astro/flag_nebula",true).toBool()); setFlagShow(conf->value("astro/flag_nebula",true).toBool());
setFlagHints(conf->value("astro/flag_nebula_name",false).toBool()); setFlagHints(conf->value("astro/flag_nebula_name",false).toBool());
setHintsAmount(conf->value("astro/nebula_hints_amount", 3).toFloat() ); setHintsAmount(conf->value("astro/nebula_hints_amount", 3).toFloat() );
setLabelsAmount(conf->value("astro/nebula_labels_amount", 3).toFloat ()); setLabelsAmount(conf->value("astro/nebula_labels_amount", 3).toFloat ());
setCircleScale(conf->value("astro/nebula_scale",1.0f).toFloat()); setCircleScale(conf->value("astro/nebula_scale",1.0f).toFloat());
setHintsProportional(conf->value("astro/flag_nebula_hints_proportion al", false).toBool());
updateI18n(); updateI18n();
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(colorSchemeChanged(const QString&)), this, SLOT( setStelStyle(const QString&))); connect(app, SIGNAL(colorSchemeChanged(const QString&)), this, SLOT( setStelStyle(const QString&)));
GETSTELMODULE(StelObjectMgr)->registerStelObjectMgr(this); GETSTELMODULE(StelObjectMgr)->registerStelObjectMgr(this);
addAction("actionShow_Nebulas", N_("Display Options"), N_("Deep-sky objects"), "flagHintDisplayed", "D", "N"); addAction("actionShow_Nebulas", N_("Display Options"), N_("Deep-sky objects"), "flagHintDisplayed", "D", "N");
} }
skipping to change at line 214 skipping to change at line 220
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
// Size on screen // Size on screen
float size = obj->getAngularSize(core)*M_PI/180.*prj->getPix elPerRadAtCenter(); float size = obj->getAngularSize(core)*M_PI/180.*prj->getPix elPerRadAtCenter();
size+=20.f + 10.f*std::sin(2.f * StelApp::getInstance().getT if (Nebula::drawHintProportional)
otalRunTime()); size*=1.2f;
size+=20.f + 10.f*std::sin(3.f * StelApp::getInstance().getT
otalRunTime());
sPainter.drawSprite2dMode(pos[0]-size/2, pos[1]-size/2, 10, 90); sPainter.drawSprite2dMode(pos[0]-size/2, pos[1]-size/2, 10, 90);
sPainter.drawSprite2dMode(pos[0]-size/2, pos[1]+size/2, 10, 0); sPainter.drawSprite2dMode(pos[0]-size/2, pos[1]+size/2, 10, 0);
sPainter.drawSprite2dMode(pos[0]+size/2, pos[1]+size/2, 10, -90); sPainter.drawSprite2dMode(pos[0]+size/2, pos[1]+size/2, 10, -90);
sPainter.drawSprite2dMode(pos[0]+size/2, pos[1]-size/2, 10, -180); sPainter.drawSprite2dMode(pos[0]+size/2, pos[1]-size/2, 10, -180);
} }
} }
void NebulaMgr::setStelStyle(const QString& section) void NebulaMgr::setStelStyle(const QString& section)
{ {
// Load colors from config file // Load colors from config file
skipping to change at line 244 skipping to change at line 252
{ {
QString uname = name.toUpper(); QString uname = name.toUpper();
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, nebArray)
{ {
QString testName = n->getEnglishName().toUpper(); QString testName = n->getEnglishName().toUpper();
if (testName==uname) return n; if (testName==uname) return n;
} }
// If no match found, try search by catalog reference // If no match found, try search by catalog reference
static QRegExp catNumRx("^(M|NGC|IC|C)\\s*(\\d+)$"); static QRegExp catNumRx("^(M|NGC|IC|C|B|VDB|RCW|LDN|LBN|CR|MEL)\\s*( \\d+)$");
if (catNumRx.exactMatch(uname)) if (catNumRx.exactMatch(uname))
{ {
QString cat = catNumRx.capturedTexts().at(1); QString cat = catNumRx.capturedTexts().at(1);
int num = catNumRx.capturedTexts().at(2).toInt(); int num = catNumRx.capturedTexts().at(2).toInt();
if (cat == "M") return searchM(num); if (cat == "M") return searchM(num);
if (cat == "NGC") return searchNGC(num); if (cat == "NGC") return searchNGC(num);
if (cat == "IC") return searchIC(num); if (cat == "IC") return searchIC(num);
if (cat == "C") return searchC(num); if (cat == "C") return searchC(num);
if (cat == "B") return searchB(num);
if (cat == "VDB") return searchVdB(num);
if (cat == "RCW") return searchRCW(num);
if (cat == "LDN") return searchLDN(num);
if (cat == "LBN") return searchLBN(num);
if (cat == "CR") return searchCr(num);
if (cat == "MEL") return searchMel(num);
}
static QRegExp dCatNumRx("^(SH)\\s*\\d-\\s*(\\d+)$");
if (dCatNumRx.exactMatch(uname))
{
QString dcat = dCatNumRx.capturedTexts().at(1);
int dnum = dCatNumRx.capturedTexts().at(2).toInt();
if (dcat == "SH") return searchSh2(dnum);
} }
return NebulaP(); return NebulaP();
} }
void NebulaMgr::loadNebulaSet(const QString& setName) void NebulaMgr::loadNebulaSet(const QString& setName)
{ {
QString ngcPath = StelFileMgr::findFile("nebulae/" + setName + "/ngc 2000.dat"); QString ngcPath = StelFileMgr::findFile("nebulae/" + setName + "/ngc 2000.dat");
QString barnardPath = StelFileMgr::findFile("nebulae/" + setName + "
/BarnardCat_tabbed.txt");
QString sharplessPath = StelFileMgr::findFile("nebulae/" + setName +
"/SharplessCat_tabbed.txt");
QString vandenBerghPath = StelFileMgr::findFile("nebulae/" + setName
+ "/VandenBerghCat_tabbed.txt");
QString rcwPath = StelFileMgr::findFile("nebulae/" + setName + "/RCW
Cat_tabbed.txt");
QString ldnPath = StelFileMgr::findFile("nebulae/" + setName + "/LDN
Cat_tabbed.txt");
QString lbnPath = StelFileMgr::findFile("nebulae/" + setName + "/LBN
Cat_tabbed.txt");
QString ngcNamesPath = StelFileMgr::findFile("nebulae/" + setName + "/ngc2000names.dat"); QString ngcNamesPath = StelFileMgr::findFile("nebulae/" + setName + "/ngc2000names.dat");
if (ngcPath.isEmpty() || ngcNamesPath.isEmpty()) if (ngcPath.isEmpty() || ngcNamesPath.isEmpty())
{ {
qWarning() << "ERROR while loading nebula data set " << setN ame; qWarning() << "ERROR while loading nebula data set " << setN ame;
return; return;
} }
loadNGC(ngcPath); loadNGC(ngcPath);
loadBarnard(barnardPath);
loadSharpless(sharplessPath);
loadVandenBergh(vandenBerghPath);
loadRCW(rcwPath);
loadLDN(ldnPath);
loadLBN(lbnPath);
loadNGCNames(ngcNamesPath); loadNGCNames(ngcNamesPath);
} }
// Look for a nebulae by XYZ coords // Look for a nebulae by XYZ coords
NebulaP NebulaMgr::search(const Vec3d& apos) NebulaP NebulaMgr::search(const Vec3d& apos)
{ {
Vec3d pos = apos; Vec3d pos = apos;
pos.normalize(); pos.normalize();
NebulaP plusProche; NebulaP plusProche;
float anglePlusProche=0.; float anglePlusProche=0.0f;
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, nebArray)
{ {
if (n->XYZ*pos>anglePlusProche) if (n->XYZ*pos>anglePlusProche)
{ {
anglePlusProche=n->XYZ*pos; anglePlusProche=n->XYZ*pos;
plusProche=n; plusProche=n;
} }
} }
if (anglePlusProche>0.999) if (anglePlusProche>0.999f)
{ {
return plusProche; return plusProche;
} }
else return NebulaP(); else return NebulaP();
} }
QList<StelObjectP> NebulaMgr::searchAround(const Vec3d& av, double limitFov , const StelCore*) const QList<StelObjectP> NebulaMgr::searchAround(const Vec3d& av, double limitFov , const StelCore*) const
{ {
QList<StelObjectP> result; QList<StelObjectP> result;
if (!getFlagShow()) if (!getFlagShow())
skipping to change at line 345 skipping to change at line 380
} }
NebulaP NebulaMgr::searchC(unsigned int C) NebulaP NebulaMgr::searchC(unsigned int C)
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, nebArray)
if (n->C_nb == C) if (n->C_nb == C)
return n; return n;
return NebulaP(); return NebulaP();
} }
NebulaP NebulaMgr::searchB(unsigned int B)
{
foreach (const NebulaP& n, nebArray)
if (n->B_nb == B)
return n;
return NebulaP();
}
NebulaP NebulaMgr::searchSh2(unsigned int Sh2)
{
foreach (const NebulaP& n, nebArray)
if (n->Sh2_nb == Sh2)
return n;
return NebulaP();
}
NebulaP NebulaMgr::searchVdB(unsigned int VdB)
{
foreach (const NebulaP& n, nebArray)
if (n->VdB_nb == VdB)
return n;
return NebulaP();
}
NebulaP NebulaMgr::searchRCW(unsigned int RCW)
{
foreach (const NebulaP& n, nebArray)
if (n->RCW_nb == RCW)
return n;
return NebulaP();
}
NebulaP NebulaMgr::searchLDN(unsigned int LDN)
{
foreach (const NebulaP& n, nebArray)
if (n->LDN_nb == LDN)
return n;
return NebulaP();
}
NebulaP NebulaMgr::searchLBN(unsigned int LBN)
{
foreach (const NebulaP& n, nebArray)
if (n->LBN_nb == LBN)
return n;
return NebulaP();
}
NebulaP NebulaMgr::searchCr(unsigned int Cr)
{
foreach (const NebulaP& n, nebArray)
if (n->Cr_nb == Cr)
return n;
return NebulaP();
}
NebulaP NebulaMgr::searchMel(unsigned int Mel)
{
foreach (const NebulaP& n, nebArray)
if (n->Mel_nb == Mel)
return n;
return NebulaP();
}
#if 0 #if 0
// read from stream // read from stream
bool NebulaMgr::loadNGCOld(const QString& catNGC) bool NebulaMgr::loadNGCOld(const QString& catNGC)
{ {
QFile in(catNGC); QFile in(catNGC);
if (!in.open(QIODevice::ReadOnly | QIODevice::Text)) if (!in.open(QIODevice::ReadOnly | QIODevice::Text))
return false; return false;
int totalRecords=0; int totalRecords=0;
QString record; QString record;
skipping to change at line 435 skipping to change at line 534
{ {
qDebug() << "Loading NGC name data ..."; qDebug() << "Loading NGC name data ...";
QFile ngcNameFile(catNGCNames); QFile ngcNameFile(catNGCNames);
if (!ngcNameFile.open(QIODevice::ReadOnly | QIODevice::Text)) if (!ngcNameFile.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
qWarning() << "NGC name data file" << QDir::toNativeSeparato rs(catNGCNames) << "not found."; qWarning() << "NGC name data file" << QDir::toNativeSeparato rs(catNGCNames) << "not found.";
return false; return false;
} }
// Read the names of the NGC objects // Read the names of the NGC objects
QString name, record; QString name, record, ref;
int totalRecords=0; int totalRecords=0;
int lineNumber=0; int lineNumber=0;
int readOk=0; int readOk=0;
int nb; int nb;
NebulaP e; NebulaP e;
QRegExp commentRx("^(\\s*#.*|\\s*)$"); QRegExp commentRx("^(\\s*#.*|\\s*)$");
QRegExp transRx("_[(]\"(.*)\"[)]"); QRegExp transRx("_[(]\"(.*)\"[)]");
while (!ngcNameFile.atEnd()) while (!ngcNameFile.atEnd())
{ {
record = QString::fromUtf8(ngcNameFile.readLine()); record = QString::fromUtf8(ngcNameFile.readLine());
lineNumber++; lineNumber++;
if (commentRx.exactMatch(record)) if (commentRx.exactMatch(record))
continue; continue;
totalRecords++; totalRecords++;
nb = record.mid(38,4).toInt(); nb = record.mid(38,4).toInt();
if (record[37] == 'I') if (record[37] == 'I')
{ {
e = searchIC(nb); e = searchIC(nb);
ref = "IC ";
}
else if (record[37] == 'B')
{
e = searchB(nb);
ref = "B";
}
else if (record[37] == 'S')
{
e = searchSh2(nb);
ref = "Sh 2-";
}
else if (record[37] == 'V')
{
e = searchVdB(nb);
ref = "VdB ";
}
else if (record[37] == 'R')
{
e = searchRCW(nb);
ref = "RCW ";
}
else if (record[37] == 'D')
{
e = searchLDN(nb);
ref = "LDN ";
}
else if (record[37] == 'L')
{
e = searchLBN(nb);
ref = "LBN ";
} }
else else
{ {
e = searchNGC(nb); e = searchNGC(nb);
ref = "NGC ";
} }
// get name, trimmed of whitespace // get name, trimmed of whitespace
name = record.left(36).trimmed(); name = record.left(36).trimmed();
if (e) if (e)
{ {
// If the name is not a messier number perhaps one i s already // If the name is not a messier number perhaps one i s already
// defined for this object // defined for this object
if (name.left(2).toUpper() != "M " && name.left(2).t oUpper() != "C ") if (name.left(2).toUpper() != "M " && name.left(2).t oUpper() != "C " && name.left(2).toUpper() != "CR" && name.left(2).toUpper( ) != "ME")
{ {
if (transRx.exactMatch(name)) { if (transRx.exactMatch(name)) {
e->englishName = transRx.capturedTex ts().at(1).trimmed(); e->englishName = transRx.capturedTex ts().at(1).trimmed();
} }
else else
{ {
e->englishName = name; e->englishName = name;
} }
} }
else if (name.left(2).toUpper() != "M " && name.left else if (name.left(2).toUpper() == "M ")
(2).toUpper() == "C ") {
// If it's a Messier number, we will call it
a Messier if there is no better name
name = name.mid(2); // remove "M "
// read the Messier number
QTextStream istr(&name);
int num;
istr >> num;
if (istr.status()!=QTextStream::Ok)
{
qWarning() << "cannot read Messier n
umber at line" << lineNumber << "of" << QDir::toNativeSeparators(catNGCName
s);
continue;
}
e->M_nb=(unsigned int)(num);
e->englishName = QString("M%1").arg(num);
}
else if (name.left(2).toUpper() == "C ")
{ {
// If it's a caldwellnumber, we will call it a caldwell if there is no better name // If it's a Caldwell number, we will call i t a Caldwell if there is no better name
name = name.mid(2); // remove "C " name = name.mid(2); // remove "C "
// read the Caldwell number // read the Caldwell number
QTextStream istr(&name); QTextStream istr(&name);
int num; int num;
istr >> num; istr >> num;
if (istr.status()!=QTextStream::Ok) if (istr.status()!=QTextStream::Ok)
{ {
qWarning() << "cannot read Caldwell number at line" << lineNumber << "of" << QDir::toNativeSeparators(catNGCNam es); qWarning() << "cannot read Caldwell number at line" << lineNumber << "of" << QDir::toNativeSeparators(catNGCNam es);
continue; continue;
} }
e->C_nb=(unsigned int)(num); e->C_nb=(unsigned int)(num);
e->englishName = QString("C%1").arg(num); e->englishName = QString("C%1").arg(num);
} }
else if (name.left(2).toUpper() == "M " && name.left (2).toUpper() != "C ") else if (name.left(2).toUpper() == "CR")
{ {
// If it's a messiernumber, we will call it // If it's a Collinder number, we will call
a messier if there is no better name it a Messier if there is no better name
name = name.mid(2); // remove "M " name = name.mid(2); // remove "Cr"
// read the Messier number // read the Collinder number
QTextStream istr(&name); QTextStream istr(&name);
int num; int num;
istr >> num; istr >> num;
if (istr.status()!=QTextStream::Ok) if (istr.status()!=QTextStream::Ok)
{ {
qWarning() << "cannot read Messier n umber at line" << lineNumber << "of" << QDir::toNativeSeparators(catNGCName s); qWarning() << "cannot read Collinder number at line" << lineNumber << "of" << QDir::toNativeSeparators(catNGCNa mes);
continue; continue;
} }
e->M_nb=(unsigned int)(num); e->Cr_nb=(unsigned int)(num);
e->englishName = QString("M%1").arg(num); if (e->englishName.isEmpty())
e->englishName = QString("%1%2").arg
(ref).arg(nb);
} }
else if (name.left(2).toUpper() == "ME")
{
// If it's a Melotte number, we will call it
a Messier if there is no better name
name = name.mid(2); // remove "Me"
// read the Melotte number
QTextStream istr(&name);
int num;
istr >> num;
if (istr.status()!=QTextStream::Ok)
{
qWarning() << "cannot read Melotte n
umber at line" << lineNumber << "of" << QDir::toNativeSeparators(catNGCName
s);
continue;
}
e->Mel_nb=(unsigned int)(num);
if (e->englishName.isEmpty())
e->englishName = QString("%1%2").arg
(ref).arg(nb);
}
readOk++; readOk++;
} }
else else
qWarning() << "no position data for " << name << "at line" << lineNumber << "of" << QDir::toNativeSeparators(catNGCNames); qWarning() << "no position data for " << name << "at line" << lineNumber << "of" << QDir::toNativeSeparators(catNGCNames);
} }
ngcNameFile.close(); ngcNameFile.close();
qDebug() << "Loaded" << readOk << "/" << totalRecords << "NGC name r ecords successfully"; qDebug() << "Loaded" << readOk << "/" << totalRecords << "NGC name r ecords successfully";
return true; return true;
} }
void NebulaMgr::updateI18n() bool NebulaMgr::loadBarnard(const QString& filename)
{
const StelTranslator& trans = StelApp::getInstance().getLocaleMgr().
getSkyTranslator();
foreach (NebulaP n, nebArray)
n->translateName(trans);
}
//! Return the matching Nebula object's pointer if exists or NULL
StelObjectP NebulaMgr::searchByNameI18n(const QString& nameI18n) const
{ {
QString objw = nameI18n.toUpper(); QFile in(filename);
if (!in.open(QIODevice::ReadOnly | QIODevice::Text))
return false;
// Search by NGC numbers (possible formats are "NGC31" or "NGC 31") int totalRecords=0;
if (objw.mid(0, 3) == "NGC") QString record;
while (!in.atEnd())
{ {
foreach (const NebulaP& n, nebArray) in.readLine();
{ ++totalRecords;
if (QString("NGC%1").arg(n->NGC_nb) == objw || QStri
ng("NGC %1").arg(n->NGC_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
} }
// Search by common names // rewind the file to the start
foreach (const NebulaP& n, nebArray) in.seek(0);
{
QString objwcap = n->nameI18.toUpper();
if (objwcap==objw)
return qSharedPointerCast<StelObject>(n);
}
// Search by IC numbers (possible formats are "IC466" or "IC 466") int currentLineNumber = 0; // what input line we are on
if (objw.mid(0, 2) == "IC") int currentRecordNumber = 0; // what record number we are on
int readOk = 0; // how many records were read withou
t problems
while (!in.atEnd())
{ {
foreach (const NebulaP& n, nebArray) record = QString::fromUtf8(in.readLine());
{ ++currentLineNumber;
if (QString("IC%1").arg(n->IC_nb) == objw || QString
("IC %1").arg(n->IC_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
// Search by Messier numbers (possible formats are "M31" or "M 31") // skip comments
if (objw.mid(0, 1) == "M") if (record.startsWith("//") || record.startsWith("#"))
{ continue;
foreach (const NebulaP& n, nebArray) ++currentRecordNumber;
// Create a new Nebula record
NebulaP e = NebulaP(new Nebula);
if (!e->readBarnard(record)) // reading error
{ {
if (QString("M%1").arg(n->M_nb) == objw || QString(" e.clear();
M %1").arg(n->M_nb) == objw)
return qSharedPointerCast<StelObject>(n);
} }
} else
// Search by Caldwell numbers (possible formats are "C31" or "C 31")
if (objw.mid(0, 1) == "C")
{
foreach (const NebulaP& n, nebArray)
{ {
if (QString("C%1").arg(n->C_nb) == objw || QString(" nebArray.append(e);
C %1").arg(n->C_nb) == objw) nebGrid.insert(qSharedPointerCast<StelRegionObject>(
return qSharedPointerCast<StelObject>(n); e));
++readOk;
} }
} }
in.close();
return StelObjectP(); qDebug() << "Loaded" << readOk << "/" << totalRecords << "Barnard re
cords";
return true;
} }
//! Return the matching Nebula object's pointer if exists or NULL bool NebulaMgr::loadSharpless(const QString& filename)
//! TODO split common parts of this and I18 fn above into a separate fn.
StelObjectP NebulaMgr::searchByName(const QString& name) const
{ {
QString objw = name.toUpper(); QFile in(filename);
if (!in.open(QIODevice::ReadOnly | QIODevice::Text))
return false;
// Search by NGC numbers (possible formats are "NGC31" or "NGC 31") int totalRecords=0;
if (objw.mid(0, 3) == "NGC") QString record;
while (!in.atEnd())
{ {
foreach (const NebulaP& n, nebArray) in.readLine();
{ ++totalRecords;
if (QString("NGC%1").arg(n->NGC_nb) == objw || QStri
ng("NGC %1").arg(n->NGC_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
} }
// Search by common names // rewind the file to the start
foreach (const NebulaP& n, nebArray) in.seek(0);
{
QString objwcap = n->englishName.toUpper();
if (objwcap==objw)
return qSharedPointerCast<StelObject>(n);
}
// Search by IC numbers (possible formats are "IC466" or "IC 466") int currentLineNumber = 0; // what input line we are on
if (objw.mid(0, 2) == "IC") int currentRecordNumber = 0; // what record number we are on
int readOk = 0; // how many records were read withou
t problems
while (!in.atEnd())
{ {
foreach (const NebulaP& n, nebArray) record = QString::fromUtf8(in.readLine());
{ ++currentLineNumber;
if (QString("IC%1").arg(n->IC_nb) == objw || QString
("IC %1").arg(n->IC_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
// Search by Messier numbers (possible formats are "M31" or "M 31") // skip comments
if (objw.mid(0, 1) == "M") if (record.startsWith("//") || record.startsWith("#") || rec
{ ord.isEmpty())
foreach (const NebulaP& n, nebArray) continue;
++currentRecordNumber;
// Create a new Nebula record
NebulaP e = NebulaP(new Nebula);
if (!e->readSharpless(record)) // reading error
{ {
if (QString("M%1").arg(n->M_nb) == objw || QString(" e.clear();
M %1").arg(n->M_nb) == objw)
return qSharedPointerCast<StelObject>(n);
} }
} else
// Search by Caldwell numbers (possible formats are "C31" or "C 31")
if (objw.mid(0, 1) == "C")
{
foreach (const NebulaP& n, nebArray)
{ {
if (QString("C%1").arg(n->C_nb) == objw || QString(" nebArray.append(e);
C %1").arg(n->C_nb) == objw) nebGrid.insert(qSharedPointerCast<StelRegionObject>(
return qSharedPointerCast<StelObject>(n); e));
++readOk;
} }
} }
in.close();
return NULL; qDebug() << "Loaded" << readOk << "/" << totalRecords << "Sharpless
records";
return true;
} }
//! Find and return the list of at most maxNbItem objects auto-completing t bool NebulaMgr::loadVandenBergh(const QString& filename)
he passed object I18n name
QStringList NebulaMgr::listMatchingObjectsI18n(const QString& objPrefix, in
t maxNbItem, bool useStartOfWords) const
{ {
QStringList result; QFile in(filename);
if (maxNbItem==0) return result; if (!in.open(QIODevice::ReadOnly | QIODevice::Text))
return false;
QString objw = objPrefix.toUpper(); int totalRecords=0;
// Search by Messier objects number (possible formats are "M31" or " QString record;
M 31") while (!in.atEnd())
if (objw.size()>=1 && objw[0]=='M')
{ {
foreach (const NebulaP& n, nebArray) in.readLine();
{ ++totalRecords;
if (n->M_nb==0) continue; }
QString constw = QString("M%1").arg(n->M_nb);
QString constws = constw.mid(0, objw.size()); // rewind the file to the start
if (constws==objw) in.seek(0);
{
result << constws; int currentLineNumber = 0; // what input line we are on
continue; // Prevent adding both forms int currentRecordNumber = 0; // what record number we are on
for name int readOk = 0; // how many records were read withou
} t problems
while (!in.atEnd())
{
record = QString::fromUtf8(in.readLine());
++currentLineNumber;
// skip comments
if (record.startsWith("//") || record.startsWith("#") || rec
ord.isEmpty())
continue;
++currentRecordNumber;
// Create a new Nebula record
NebulaP e = NebulaP(new Nebula);
if (!e->readVandenBergh(record)) // reading error
{
e.clear();
}
else
{
nebArray.append(e);
nebGrid.insert(qSharedPointerCast<StelRegionObject>(
e));
++readOk;
}
}
in.close();
qDebug() << "Loaded" << readOk << "/" << totalRecords << "Van den Be
rgh records";
return true;
}
bool NebulaMgr::loadRCW(const QString& filename)
{
QFile in(filename);
if (!in.open(QIODevice::ReadOnly | QIODevice::Text))
return false;
int totalRecords=0;
QString record;
while (!in.atEnd())
{
in.readLine();
++totalRecords;
}
// rewind the file to the start
in.seek(0);
int currentLineNumber = 0; // what input line we are on
int currentRecordNumber = 0; // what record number we are on
int readOk = 0; // how many records were read withou
t problems
while (!in.atEnd())
{
record = QString::fromUtf8(in.readLine());
++currentLineNumber;
// skip comments
if (record.startsWith("//") || record.startsWith("#") || rec
ord.isEmpty())
continue;
++currentRecordNumber;
// Create a new Nebula record
NebulaP e = NebulaP(new Nebula);
if (!e->readRCW(record)) // reading error
{
e.clear();
}
else
{
nebArray.append(e);
nebGrid.insert(qSharedPointerCast<StelRegionObject>(
e));
++readOk;
}
}
in.close();
qDebug() << "Loaded" << readOk << "/" << totalRecords << "RCW (Rodge
rs+) records";
return true;
}
bool NebulaMgr::loadLDN(const QString& filename)
{
QFile in(filename);
if (!in.open(QIODevice::ReadOnly | QIODevice::Text))
return false;
int totalRecords=0;
QString record;
while (!in.atEnd())
{
in.readLine();
++totalRecords;
}
// rewind the file to the start
in.seek(0);
int currentLineNumber = 0; // what input line we are on
int currentRecordNumber = 0; // what record number we are on
int readOk = 0; // how many records were read withou
t problems
while (!in.atEnd())
{
record = QString::fromUtf8(in.readLine());
++currentLineNumber;
// skip comments
if (record.startsWith("//") || record.startsWith("#") || rec
ord.isEmpty())
continue;
++currentRecordNumber;
// Create a new Nebula record
NebulaP e = NebulaP(new Nebula);
if (!e->readLDN(record)) // reading error
{
e.clear();
}
else
{
nebArray.append(e);
nebGrid.insert(qSharedPointerCast<StelRegionObject>(
e));
++readOk;
}
}
in.close();
qDebug() << "Loaded" << readOk << "/" << totalRecords << "LDN (Lynds
' Catalogue of Dark Nebulae) records";
return true;
}
bool NebulaMgr::loadLBN(const QString& filename)
{
QFile in(filename);
if (!in.open(QIODevice::ReadOnly | QIODevice::Text))
return false;
int totalRecords=0;
QString record;
while (!in.atEnd())
{
in.readLine();
++totalRecords;
}
// rewind the file to the start
in.seek(0);
int currentLineNumber = 0; // what input line we are on
int currentRecordNumber = 0; // what record number we are on
int readOk = 0; // how many records were read withou
t problems
while (!in.atEnd())
{
record = QString::fromUtf8(in.readLine());
++currentLineNumber;
// skip comments
if (record.startsWith("//") || record.startsWith("#") || rec
ord.isEmpty())
continue;
++currentRecordNumber;
// Create a new Nebula record
NebulaP e = NebulaP(new Nebula);
if (!e->readLBN(record)) // reading error
{
e.clear();
}
else
{
nebArray.append(e);
nebGrid.insert(qSharedPointerCast<StelRegionObject>(
e));
++readOk;
}
}
in.close();
qDebug() << "Loaded" << readOk << "/" << totalRecords << "LBN (Lynds
' Catalogue of Bright Nebulae) records";
return true;
}
void NebulaMgr::updateI18n()
{
const StelTranslator& trans = StelApp::getInstance().getLocaleMgr().
getSkyTranslator();
foreach (NebulaP n, nebArray)
n->translateName(trans);
}
//! Return the matching Nebula object's pointer if exists or NULL
StelObjectP NebulaMgr::searchByNameI18n(const QString& nameI18n) const
{
QString objw = nameI18n.toUpper();
// Search by NGC numbers (possible formats are "NGC31" or "NGC 31")
if (objw.mid(0, 3) == "NGC")
{
foreach (const NebulaP& n, nebArray)
{
if (QString("NGC%1").arg(n->NGC_nb) == objw || QStri
ng("NGC %1").arg(n->NGC_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
// Search by common names
foreach (const NebulaP& n, nebArray)
{
QString objwcap = n->nameI18.toUpper();
if (objwcap==objw)
return qSharedPointerCast<StelObject>(n);
}
// Search by IC numbers (possible formats are "IC466" or "IC 466")
if (objw.mid(0, 2) == "IC")
{
foreach (const NebulaP& n, nebArray)
{
if (QString("IC%1").arg(n->IC_nb) == objw || QString
("IC %1").arg(n->IC_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
// Search by Messier numbers (possible formats are "M31" or "M 31")
if (objw.mid(0, 1) == "M" && objw.mid(1, 1) != "E")
{
foreach (const NebulaP& n, nebArray)
{
if (QString("M%1").arg(n->M_nb) == objw || QString("
M %1").arg(n->M_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
// Search by Caldwell numbers (possible formats are "C31" or "C 31")
if (objw.mid(0, 1) == "C" && objw.mid(1, 2) != "R")
{
foreach (const NebulaP& n, nebArray)
{
if (QString("C%1").arg(n->C_nb) == objw || QString("
C %1").arg(n->C_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
// Search by Barnard numbers (possible formats are "B31" or "B 31")
if (objw.mid(0, 1) == "B")
{
foreach (const NebulaP& n, nebArray)
{
if (QString("B%1").arg(n->B_nb) == objw || QString("
B %1").arg(n->B_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
// Search by Sharpless numbers (possible formats are "Sh2-31" or "Sh
2-31")
if (objw.mid(0, 2) == "SH")
{
foreach (const NebulaP& n, nebArray)
{
if (QString("SH2-%1").arg(n->Sh2_nb) == objw || QStr
ing("SH 2-%1").arg(n->Sh2_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
// Search by Van den Bergh numbers (possible formats are "VdB31" or
"VdB 31")
if (objw.mid(0, 3) == "VDB")
{
foreach (const NebulaP& n, nebArray)
{
if (QString("VDB%1").arg(n->VdB_nb) == objw || QStri
ng("VDB %1").arg(n->VdB_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
// Search by RCW numbers (possible formats are "RCW31" or "RCW 31")
if (objw.mid(0, 3) == "RCW")
{
foreach (const NebulaP& n, nebArray)
{
if (QString("RCW%1").arg(n->RCW_nb) == objw || QStri
ng("RCW %1").arg(n->RCW_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
// Search by LDN numbers (possible formats are "LDN31" or "LDN 31")
if (objw.mid(0, 3) == "LDN")
{
foreach (const NebulaP& n, nebArray)
{
if (QString("LDN%1").arg(n->LDN_nb) == objw || QStri
ng("LDN %1").arg(n->LDN_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
// Search by LBN numbers (possible formats are "LBN31" or "LBN 31")
if (objw.mid(0, 3) == "LBN")
{
foreach (const NebulaP& n, nebArray)
{
if (QString("LBN%1").arg(n->LBN_nb) == objw || QStri
ng("LBN %1").arg(n->LBN_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
// Search by Collinder numbers (possible formats are "Cr31" or "Cr 3
1")
if (objw.mid(0, 2) == "CR")
{
foreach (const NebulaP& n, nebArray)
{
if (QString("CR%1").arg(n->Cr_nb) == objw || QString
("CR %1").arg(n->Cr_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
// Search by Melotte numbers (possible formats are "Mel31" or "Mel 3
1")
if (objw.mid(0, 3) == "MEL")
{
foreach (const NebulaP& n, nebArray)
{
if (QString("MEL%1").arg(n->Mel_nb) == objw || QStri
ng("MEL %1").arg(n->Mel_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
return StelObjectP();
}
//! Return the matching Nebula object's pointer if exists or NULL
//! TODO split common parts of this and I18 fn above into a separate fn.
StelObjectP NebulaMgr::searchByName(const QString& name) const
{
QString objw = name.toUpper();
// Search by NGC numbers (possible formats are "NGC31" or "NGC 31")
if (objw.startsWith("NGC"))
{
foreach (const NebulaP& n, nebArray)
{
if (QString("NGC%1").arg(n->NGC_nb) == objw || QStri
ng("NGC %1").arg(n->NGC_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
// Search by common names
foreach (const NebulaP& n, nebArray)
{
QString objwcap = n->englishName.toUpper();
if (objwcap==objw)
return qSharedPointerCast<StelObject>(n);
}
// Search by IC numbers (possible formats are "IC466" or "IC 466")
if (objw.startsWith("IC"))
{
foreach (const NebulaP& n, nebArray)
{
if (QString("IC%1").arg(n->IC_nb) == objw || QString
("IC %1").arg(n->IC_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
// Search by Messier numbers (possible formats are "M31" or "M 31")
if (objw.startsWith("M") && !objw.startsWith("ME"))
{
foreach (const NebulaP& n, nebArray)
{
if (QString("M%1").arg(n->M_nb) == objw || QString("
M %1").arg(n->M_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
// Search by Caldwell numbers (possible formats are "C31" or "C 31")
if (objw.startsWith("C") && !objw.startsWith("CR"))
{
foreach (const NebulaP& n, nebArray)
{
if (QString("C%1").arg(n->C_nb) == objw || QString("
C %1").arg(n->C_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
// Search by Barnard numbers (possible formats are "B31" or "B 31")
if (objw.startsWith("B"))
{
foreach (const NebulaP& n, nebArray)
{
if (QString("B%1").arg(n->B_nb) == objw || QString("
B %1").arg(n->B_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
// Search by Sharpless numbers (possible formats are "Sh2-31" or "Sh
2-31")
if (objw.startsWith("SH"))
{
foreach (const NebulaP& n, nebArray)
{
if (QString("SH2-%1").arg(n->Sh2_nb) == objw || QStr
ing("SH 2-%1").arg(n->Sh2_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
// Search by Van den Bergh numbers (possible formats are "VdB31" or
"VdB 31")
if (objw.startsWith("VDB"))
{
foreach (const NebulaP& n, nebArray)
{
if (QString("VDB%1").arg(n->VdB_nb) == objw || QStri
ng("VDB %1").arg(n->VdB_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
// Search by RCW numbers (possible formats are "RCW31" or "RCW 31")
if (objw.startsWith("RCW"))
{
foreach (const NebulaP& n, nebArray)
{
if (QString("RCW%1").arg(n->RCW_nb) == objw || QStri
ng("RCW %1").arg(n->RCW_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
// Search by LDN numbers (possible formats are "LDN31" or "LDN 31")
if (objw.startsWith("LDN"))
{
foreach (const NebulaP& n, nebArray)
{
if (QString("LDN%1").arg(n->LDN_nb) == objw || QStri
ng("LDN %1").arg(n->LDN_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
// Search by LBN numbers (possible formats are "LBN31" or "LBN 31")
if (objw.startsWith("LBN"))
{
foreach (const NebulaP& n, nebArray)
{
if (QString("LBN%1").arg(n->LBN_nb) == objw || QStri
ng("LBN %1").arg(n->LBN_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
// Search by Collinder numbers (possible formats are "Cr31" or "Cr 3
1")
if (objw.startsWith("CR"))
{
foreach (const NebulaP& n, nebArray)
{
if (QString("CR%1").arg(n->Cr_nb) == objw || QString
("CR %1").arg(n->Cr_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
// Search by Melotte numbers (possible formats are "Mel31" or "Mel 3
1")
if (objw.startsWith("MEL"))
{
foreach (const NebulaP& n, nebArray)
{
if (QString("MEL%1").arg(n->Mel_nb) == objw || QStri
ng("MEL %1").arg(n->Mel_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
return NULL;
}
//! Find and return the list of at most maxNbItem objects auto-completing t
he passed object I18n name
QStringList NebulaMgr::listMatchingObjectsI18n(const QString& objPrefix, in
t maxNbItem, bool useStartOfWords) const
{
QStringList result;
if (maxNbItem==0) return result;
QString objw = objPrefix.toUpper();
// Search by Messier objects number (possible formats are "M31" or "
M 31")
if (objw.size()>=1 && objw[0]=='M' && objw[1]!='E')
{
foreach (const NebulaP& n, nebArray)
{
if (n->M_nb==0) continue;
QString constw = QString("M%1").arg(n->M_nb);
QString constws = constw.mid(0, objw.size());
if (constws==objw)
{
result << constws;
continue; // Prevent adding both forms
for name
}
constw = QString("M %1").arg(n->M_nb); constw = QString("M %1").arg(n->M_nb);
constws = constw.mid(0, objw.size()); constws = constw.mid(0, objw.size());
if (constws==objw) if (constws==objw)
result << constw; result << constw;
} }
} }
// Search by Melotte objects number (possible formats are "Mel31" or
"Mel 31")
if (objw.size()>=1 && objw[0]=='M' && objw[1]=='E')
{
foreach (const NebulaP& n, nebArray)
{
if (n->Mel_nb==0) continue;
QString constw = QString("MEL%1").arg(n->Mel_nb);
QString constws = constw.mid(0, objw.size());
if (constws==objw)
{
result << constws;
continue; // Prevent adding both forms
for name
}
constw = QString("MEL %1").arg(n->Mel_nb);
constws = constw.mid(0, objw.size());
if (constws==objw)
result << constw;
}
}
// Search by IC objects number (possible formats are "IC466" or "IC 466") // Search by IC objects number (possible formats are "IC466" or "IC 466")
if (objw.size()>=1 && objw[0]=='I') if (objw.size()>=1 && objw[0]=='I')
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, nebArray)
{ {
if (n->IC_nb==0) continue; if (n->IC_nb==0) continue;
QString constw = QString("IC%1").arg(n->IC_nb); QString constw = QString("IC%1").arg(n->IC_nb);
QString constws = constw.mid(0, objw.size()); QString constws = constw.mid(0, objw.size());
if (constws==objw) if (constws==objw)
{ {
skipping to change at line 710 skipping to change at line 1346
{ {
result << constws; result << constws;
continue; continue;
} }
constw = QString("NGC %1").arg(n->NGC_nb); constw = QString("NGC %1").arg(n->NGC_nb);
constws = constw.mid(0, objw.size()); constws = constw.mid(0, objw.size());
if (constws==objw) if (constws==objw)
result << constw; result << constw;
} }
// Search by caldwell objects number (possible formats are "C31" or // Search by Caldwell objects number (possible formats are "C31" or
"C 31") "C 31")
if (objw.size()>=1 && objw[0]=='C') if (objw.size()>=1 && objw[0]=='C' && objw[1]!='R')
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, nebArray)
{ {
if (n->C_nb==0) continue; if (n->C_nb==0) continue;
QString constw = QString("C%1").arg(n->C_nb); QString constw = QString("C%1").arg(n->C_nb);
QString constws = constw.mid(0, objw.size()); QString constws = constw.mid(0, objw.size());
if (constws==objw) if (constws==objw)
{ {
result << constws; result << constws;
continue; // Prevent adding both forms for name continue; // Prevent adding both forms for name
} }
constw = QString("C %1").arg(n->C_nb); constw = QString("C %1").arg(n->C_nb);
constws = constw.mid(0, objw.size()); constws = constw.mid(0, objw.size());
if (constws==objw) if (constws==objw)
result << constw; result << constw;
} }
} }
// Search by Collinder objects number (possible formats are "Cr31" o
r "Cr 31")
if (objw.size()>=1 && objw[0]=='C' && objw[1]=='R')
{
foreach (const NebulaP& n, nebArray)
{
if (n->Cr_nb==0) continue;
QString constw = QString("CR%1").arg(n->Cr_nb);
QString constws = constw.mid(0, objw.size());
if (constws==objw)
{
result << constws;
continue; // Prevent adding both forms
for name
}
constw = QString("CR %1").arg(n->Cr_nb);
constws = constw.mid(0, objw.size());
if (constws==objw)
result << constw;
}
}
// Search by Barnard objects number (possible formats are "B31" or "
B 31")
if (objw.size()>=1 && objw[0]=='B')
{
foreach (const NebulaP& n, nebArray)
{
if (n->B_nb==0) continue;
QString constw = QString("B%1").arg(n->B_nb);
QString constws = constw.mid(0, objw.size());
if (constws==objw)
{
result << constws;
continue; // Prevent adding both forms
for name
}
constw = QString("B %1").arg(n->B_nb);
constws = constw.mid(0, objw.size());
if (constws==objw)
result << constw;
}
}
// Search by Sharpless objects number (possible formats are "Sh2-31"
or "Sh 2-31")
if (objw.size()>=1 && objw[0]=='S')
{
foreach (const NebulaP& n, nebArray)
{
if (n->Sh2_nb==0) continue;
QString constw = QString("SH2-%1").arg(n->Sh2_nb);
QString constws = constw.mid(0, objw.size());
if (constws==objw)
{
result << constws;
continue; // Prevent adding both forms
for name
}
constw = QString("SH 2-%1").arg(n->Sh2_nb);
constws = constw.mid(0, objw.size());
if (constws==objw)
result << constw;
}
}
// Search by Van den Bergh objects number (possible formats are "VdB
31" or "VdB 31")
if (objw.size()>=1 && objw[0]=='V')
{
foreach (const NebulaP& n, nebArray)
{
if (n->VdB_nb==0) continue;
QString constw = QString("VDB%1").arg(n->VdB_nb);
QString constws = constw.mid(0, objw.size());
if (constws==objw)
{
result << constws;
continue; // Prevent adding both forms
for name
}
constw = QString("VDB %1").arg(n->VdB_nb);
constws = constw.mid(0, objw.size());
if (constws==objw)
result << constw;
}
}
// Search by RCW objects number (possible formats are "RCW31" or "RC
W 31")
if (objw.size()>=1 && objw[0]=='R')
{
foreach (const NebulaP& n, nebArray)
{
if (n->RCW_nb==0) continue;
QString constw = QString("RCW%1").arg(n->RCW_nb);
QString constws = constw.mid(0, objw.size());
if (constws==objw)
{
result << constws;
continue; // Prevent adding both forms
for name
}
constw = QString("RCW %1").arg(n->RCW_nb);
constws = constw.mid(0, objw.size());
if (constws==objw)
result << constw;
}
}
// Search by LDN objects number (possible formats are "LDN31" or "LD
N 31")
if (objw.size()>=1 && objw[0]=='L' && objw[1]=='D')
{
foreach (const NebulaP& n, nebArray)
{
if (n->LDN_nb==0) continue;
QString constw = QString("LDN%1").arg(n->LDN_nb);
QString constws = constw.mid(0, objw.size());
if (constws==objw)
{
result << constws;
continue; // Prevent adding both forms
for name
}
constw = QString("LDN %1").arg(n->LDN_nb);
constws = constw.mid(0, objw.size());
if (constws==objw)
result << constw;
}
}
// Search by LBN objects number (possible formats are "LBN31" or "LB
N 31")
if (objw.size()>=1 && objw[0]=='L' && objw[1]=='B')
{
foreach (const NebulaP& n, nebArray)
{
if (n->LBN_nb==0) continue;
QString constw = QString("LBN%1").arg(n->LBN_nb);
QString constws = constw.mid(0, objw.size());
if (constws==objw)
{
result << constws;
continue; // Prevent adding both forms
for name
}
constw = QString("LBN %1").arg(n->LBN_nb);
constws = constw.mid(0, objw.size());
if (constws==objw)
result << constw;
}
}
QString dson; QString dson;
bool find; bool find;
// Search by common names // Search by common names
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, nebArray)
{ {
dson = n->nameI18; dson = n->nameI18;
find = false; find = false;
if (useStartOfWords) if (useStartOfWords)
{ {
if (dson.mid(0, objw.size()).toUpper()==objw) if (dson.mid(0, objw.size()).toUpper()==objw)
skipping to change at line 768 skipping to change at line 1544
} }
//! Find and return the list of at most maxNbItem objects auto-completing t he passed object English name //! Find and return the list of at most maxNbItem objects auto-completing t he passed object English name
QStringList NebulaMgr::listMatchingObjects(const QString& objPrefix, int ma xNbItem, bool useStartOfWords) const QStringList NebulaMgr::listMatchingObjects(const QString& objPrefix, int ma xNbItem, 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 by Messier objects number (possible formats are "M31" or " M 31") // Search by Messier objects number (possible formats are "M31" or " M 31")
if (objw.size()>=1 && objw[0]=='M') if (objw.size()>=1 && objw[0]=='M' && objw[1]!='E')
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, nebArray)
{ {
if (n->M_nb==0) continue; if (n->M_nb==0) continue;
QString constw = QString("M%1").arg(n->M_nb); QString constw = QString("M%1").arg(n->M_nb);
QString constws = constw.mid(0, objw.size()); QString constws = constw.mid(0, objw.size());
if (constws==objw) if (constws==objw)
{ {
result << constws; result << constws;
continue; // Prevent adding both forms for name continue; // Prevent adding both forms for name
} }
constw = QString("M %1").arg(n->M_nb); constw = QString("M %1").arg(n->M_nb);
constws = constw.mid(0, objw.size()); constws = constw.mid(0, objw.size());
if (constws==objw) if (constws==objw)
result << constw; result << constw;
} }
} }
// Search by Melotte objects number (possible formats are "Mel31" or
"Mel 31")
if (objw.size()>=1 && objw[0]=='M' && objw[1]=='E')
{
foreach (const NebulaP& n, nebArray)
{
if (n->Mel_nb==0) continue;
QString constw = QString("MEL%1").arg(n->Mel_nb);
QString constws = constw.mid(0, objw.size());
if (constws==objw)
{
result << constws;
continue; // Prevent adding both forms
for name
}
constw = QString("MEL %1").arg(n->Mel_nb);
constws = constw.mid(0, objw.size());
if (constws==objw)
result << constw;
}
}
// Search by IC objects number (possible formats are "IC466" or "IC 466") // Search by IC objects number (possible formats are "IC466" or "IC 466")
if (objw.size()>=1 && objw[0]=='I') if (objw.size()>=1 && objw[0]=='I')
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, nebArray)
{ {
if (n->IC_nb==0) continue; if (n->IC_nb==0) continue;
QString constw = QString("IC%1").arg(n->IC_nb); QString constw = QString("IC%1").arg(n->IC_nb);
QString constws = constw.mid(0, objw.size()); QString constws = constw.mid(0, objw.size());
if (constws==objw) if (constws==objw)
{ {
skipping to change at line 824 skipping to change at line 1620
{ {
result << constws; result << constws;
continue; continue;
} }
constw = QString("NGC %1").arg(n->NGC_nb); constw = QString("NGC %1").arg(n->NGC_nb);
constws = constw.mid(0, objw.size()); constws = constw.mid(0, objw.size());
if (constws==objw) if (constws==objw)
result << constw; result << constw;
} }
// Search by caldwell objects number (possible formats are "C31" or // Search by Caldwell objects number (possible formats are "C31" or
"C 31") "C 31")
if (objw.size()>=1 && objw[0]=='C') if (objw.size()>=1 && objw[0]=='C' && objw[1]!='R')
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, nebArray)
{ {
if (n->C_nb==0) continue; if (n->C_nb==0) continue;
QString constw = QString("C%1").arg(n->C_nb); QString constw = QString("C%1").arg(n->C_nb);
QString constws = constw.mid(0, objw.size()); QString constws = constw.mid(0, objw.size());
if (constws==objw) if (constws==objw)
{ {
result << constws; result << constws;
continue; // Prevent adding both forms for name continue; // Prevent adding both forms for name
} }
constw = QString("C %1").arg(n->C_nb); constw = QString("C %1").arg(n->C_nb);
constws = constw.mid(0, objw.size()); constws = constw.mid(0, objw.size());
if (constws==objw) if (constws==objw)
result << constw; result << constw;
} }
} }
// Search by Collinder objects number (possible formats are "Cr31" o
r "Cr 31")
if (objw.size()>=1 && objw[0]=='C' && objw[1]=='R')
{
foreach (const NebulaP& n, nebArray)
{
if (n->Cr_nb==0) continue;
QString constw = QString("CR%1").arg(n->Cr_nb);
QString constws = constw.mid(0, objw.size());
if (constws==objw)
{
result << constws;
continue; // Prevent adding both forms
for name
}
constw = QString("CR %1").arg(n->Cr_nb);
constws = constw.mid(0, objw.size());
if (constws==objw)
result << constw;
}
}
// Search by Barnard objects number (possible formats are "B31" or "
B 31")
if (objw.size()>=1 && objw[0]=='B')
{
foreach (const NebulaP& n, nebArray)
{
if (n->B_nb==0) continue;
QString constw = QString("B%1").arg(n->B_nb);
QString constws = constw.mid(0, objw.size());
if (constws==objw)
{
result << constws;
continue; // Prevent adding both forms
for name
}
constw = QString("B %1").arg(n->B_nb);
constws = constw.mid(0, objw.size());
if (constws==objw)
result << constw;
}
}
// Search by Sharpless objects number (possible formats are "Sh2-31"
or "Sh 2-31")
if (objw.size()>=1 && objw[0]=='S')
{
foreach (const NebulaP& n, nebArray)
{
if (n->Sh2_nb==0) continue;
QString constw = QString("SH2-%1").arg(n->Sh2_nb);
QString constws = constw.mid(0, objw.size());
if (constws==objw)
{
result << constws;
continue; // Prevent adding both forms
for name
}
constw = QString("SH 2-%1").arg(n->Sh2_nb);
constws = constw.mid(0, objw.size());
if (constws==objw)
result << constw;
}
}
// Search by Van den Bergh objects number (possible formats are "VdB
31" or "VdB 31")
if (objw.size()>=1 && objw[0]=='V')
{
foreach (const NebulaP& n, nebArray)
{
if (n->VdB_nb==0) continue;
QString constw = QString("VDB%1").arg(n->VdB_nb);
QString constws = constw.mid(0, objw.size());
if (constws==objw)
{
result << constws;
continue; // Prevent adding both forms
for name
}
constw = QString("VDB %1").arg(n->VdB_nb);
constws = constw.mid(0, objw.size());
if (constws==objw)
result << constw;
}
}
// Search by RCW objects number (possible formats are "RCW31" or "RC
W 31")
if (objw.size()>=1 && objw[0]=='R')
{
foreach (const NebulaP& n, nebArray)
{
if (n->RCW_nb==0) continue;
QString constw = QString("RCW%1").arg(n->RCW_nb);
QString constws = constw.mid(0, objw.size());
if (constws==objw)
{
result << constws;
continue; // Prevent adding both forms
for name
}
constw = QString("RCW %1").arg(n->RCW_nb);
constws = constw.mid(0, objw.size());
if (constws==objw)
result << constw;
}
}
// Search by LDN objects number (possible formats are "LDN31" or "LD
N 31")
if (objw.size()>=1 && objw[0]=='L' && objw[1]=='D')
{
foreach (const NebulaP& n, nebArray)
{
if (n->LDN_nb==0) continue;
QString constw = QString("LDN%1").arg(n->LDN_nb);
QString constws = constw.mid(0, objw.size());
if (constws==objw)
{
result << constws;
continue; // Prevent adding both forms
for name
}
constw = QString("LDN %1").arg(n->LDN_nb);
constws = constw.mid(0, objw.size());
if (constws==objw)
result << constw;
}
}
// Search by LBN objects number (possible formats are "LBN31" or "LB
N 31")
if (objw.size()>=1 && objw[0]=='L' && objw[1]=='B')
{
foreach (const NebulaP& n, nebArray)
{
if (n->LBN_nb==0) continue;
QString constw = QString("LBN%1").arg(n->LBN_nb);
QString constws = constw.mid(0, objw.size());
if (constws==objw)
{
result << constws;
continue; // Prevent adding both forms
for name
}
constw = QString("LBN %1").arg(n->LBN_nb);
constws = constw.mid(0, objw.size());
if (constws==objw)
result << constw;
}
}
QString dson; QString dson;
bool find; bool find;
// Search by common names // Search by common names
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, nebArray)
{ {
dson = n->englishName; dson = n->englishName;
find = false; find = false;
if (useStartOfWords) if (useStartOfWords)
{ {
if (dson.mid(0, objw.size()).toUpper()==objw) if (dson.mid(0, objw.size()).toUpper()==objw)
skipping to change at line 917 skipping to change at line 1853
result << n->getName I18n(); result << n->getName I18n();
} }
else if (n->NGC_nb>0) else if (n->NGC_nb>0)
result << QString("NGC %1"). arg(n->NGC_nb); result << QString("NGC %1"). arg(n->NGC_nb);
else else
result << QString("IC %1").a rg(n->IC_nb); result << QString("IC %1").a rg(n->IC_nb);
} }
} }
break; break;
case 10: // Messier Catalogue? case 100: // Messier Catalogue?
foreach(const NebulaP& n, nebArray) foreach(const NebulaP& n, nebArray)
{ {
if (n->M_nb>0) if (n->M_nb>0)
result << QString("M%1").arg(n->M_nb ); result << QString("M%1").arg(n->M_nb );
} }
break; break;
case 11: // Caldwell Catalogue? case 101: // Caldwell Catalogue?
foreach(const NebulaP& n, nebArray) foreach(const NebulaP& n, nebArray)
{ {
if (n->C_nb>0) if (n->C_nb>0)
result << QString("C%1").arg(n->C_nb ); result << QString("C%1").arg(n->C_nb );
} }
break; break;
case 102: // Barnard Catalogue?
foreach(const NebulaP& n, nebArray)
{
if (n->B_nb>0)
result << QString("B %1").arg(n->B_n
b);
}
break;
case 103: // Sharpless Catalogue?
foreach(const NebulaP& n, nebArray)
{
if (n->Sh2_nb>0)
result << QString("Sh 2-%1").arg(n->
Sh2_nb);
}
break;
case 104: // Van den Bergh Catalogue
foreach(const NebulaP& n, nebArray)
{
if (n->VdB_nb>0)
result << QString("VdB %1").arg(n->V
dB_nb);
}
break;
case 105: // RCW Catalogue
foreach(const NebulaP& n, nebArray)
{
if (n->RCW_nb>0)
result << QString("RCW %1").arg(n->V
dB_nb);
}
break;
case 106: // Collinder Catalogue
foreach(const NebulaP& n, nebArray)
{
if (n->Cr_nb>0)
result << QString("Cr %1").arg(n->Cr
_nb);
}
break;
case 107: // Melotte Catalogue
foreach(const NebulaP& n, nebArray)
{
if (n->Mel_nb>0)
result << QString("Mel %1").arg(n->M
el_nb);
}
break;
default: default:
foreach(const NebulaP& n, nebArray) foreach(const NebulaP& n, nebArray)
{ {
if (n->nType==type) if (n->nType==type)
{ {
if (!n->getEnglishName().isEmpty()) if (!n->getEnglishName().isEmpty())
{ {
if (inEnglish) if (inEnglish)
result << n->getEngl ishName(); result << n->getEngl ishName();
else else
 End of changes. 65 change blocks. 
148 lines changed or deleted 1226 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/