NebulaMgr.cpp   NebulaMgr.cpp 
skipping to change at line 56 skipping to change at line 56
#include <QSettings> #include <QSettings>
#include <QString> #include <QString>
#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::setGalaxyColor(const Vec3f& c) {Nebula::galaxyColor = c;}
const Vec3f &NebulaMgr::getGalaxyColor(void) const {return Nebula::galaxyCo
lor;}
void NebulaMgr::setRadioGalaxyColor(const Vec3f& c) {Nebula::radioGalaxyCol
or = c;}
const Vec3f &NebulaMgr::getRadioGalaxyColor(void) const {return Nebula::rad
ioGalaxyColor;}
void NebulaMgr::setActiveGalaxyColor(const Vec3f& c) {Nebula::activeGalaxyC
olor = c;}
const Vec3f &NebulaMgr::getActiveGalaxyColor(void) const {return Nebula::ac
tiveGalaxyColor;}
void NebulaMgr::setInteractingGalaxyColor(const Vec3f& c) {Nebula::interact
ingGalaxyColor = c;}
const Vec3f &NebulaMgr::getInteractingGalaxyColor(void) const {return Nebul
a::interactingGalaxyColor;}
void NebulaMgr::setBrightNebulaColor(const Vec3f& c) {Nebula::brightNebulaC
olor = c;}
const Vec3f &NebulaMgr::getBrightNebulaColor(void) const {return Nebula::br
ightNebulaColor;}
void NebulaMgr::setDarkNebulaColor(const Vec3f& c) {Nebula::darkNebulaColor
= c;}
const Vec3f &NebulaMgr::getDarkNebulaColor(void) const {return Nebula::dark
NebulaColor;}
void NebulaMgr::setHydrogenRegionColor(const Vec3f& c) {Nebula::hydrogenReg
ionColor= c;}
const Vec3f &NebulaMgr::getHydrogenRegionColor(void) const {return Nebula::
hydrogenRegionColor;}
void NebulaMgr::setSupernovaRemnantColor(const Vec3f& c) {Nebula::supernova
RemnantColor = c;}
const Vec3f &NebulaMgr::getSupernovaRemnantColor(void) const {return Nebula
::supernovaRemnantColor;}
void NebulaMgr::setClusterColor(const Vec3f& c) {Nebula::clusterColor= c;}
const Vec3f &NebulaMgr::getClusterColor(void) const {return Nebula::cluster
Color;}
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;} void NebulaMgr::setHintsProportional(const bool proportional) {Nebula::draw HintProportional=proportional;}
bool NebulaMgr::getHintsProportional(void) const {return Nebula::drawHintPr oportional;} 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)
, flagConverter(false)
, flagDecimalCoordinates(true)
{ {
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();
skipping to change at line 94 skipping to change at line 114
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;
return 0; return 0;
} }
// read from stream // read from stream
void NebulaMgr::init() void NebulaMgr::init()
{ {
// TODO: mechanism to specify which sets get loaded at start time.
// candidate methods:
// 1. config file option (list of sets to load at startup)
// 2. load all
// 3. flag in nebula_textures.fab (yuk)
// 4. info.ini file in each set containing a "load at startup" item
// For now (0.9.0), just load the default set
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::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()); setHintsProportional(conf->value("astro/flag_nebula_hints_proportion al", false).toBool());
setFlagSurfaceBrightnessUsage(conf->value("astro/flag_surface_bright
ness_usage", false).toBool());
// for DSO convertor (for developers!)
flagConverter = conf->value("devel/convert_dso_catalog", false).toBo
ol();
flagDecimalCoordinates = conf->value("devel/convert_dso_decimal_coor
d", true).toBool();
setFlagTypeFiltersUsage(conf->value("astro/flag_use_type_filter", fa
lse).toBool());
Nebula::CatalogGroup catalogFilters = Nebula::CatalogGroup(0);
conf->beginGroup("dso_catalog_filters");
if (conf->value("flag_show_ngc", true).toBool())
catalogFilters |= Nebula::CatNGC;
if (conf->value("flag_show_ic", true).toBool())
catalogFilters |= Nebula::CatIC;
if (conf->value("flag_show_m", true).toBool())
catalogFilters |= Nebula::CatM;
if (conf->value("flag_show_c", false).toBool())
catalogFilters |= Nebula::CatC;
if (conf->value("flag_show_b", false).toBool())
catalogFilters |= Nebula::CatB;
if (conf->value("flag_show_sh2", false).toBool())
catalogFilters |= Nebula::CatSh2;
if (conf->value("flag_show_vdb", false).toBool())
catalogFilters |= Nebula::CatVdB;
if (conf->value("flag_show_lbn", false).toBool())
catalogFilters |= Nebula::CatLBN;
if (conf->value("flag_show_ldn", false).toBool())
catalogFilters |= Nebula::CatLDN;
if (conf->value("flag_show_rcw", false).toBool())
catalogFilters |= Nebula::CatRCW;
if (conf->value("flag_show_cr", false).toBool())
catalogFilters |= Nebula::CatCr;
if (conf->value("flag_show_mel", false).toBool())
catalogFilters |= Nebula::CatMel;
if (conf->value("flag_show_pgc", false).toBool())
catalogFilters |= Nebula::CatPGC;
if (conf->value("flag_show_ced", false).toBool())
catalogFilters |= Nebula::CatCed;
if (conf->value("flag_show_ugc", false).toBool())
catalogFilters |= Nebula::CatUGC;
conf->endGroup();
// NB: nebula set loaded inside setter of catalog filter
setCatalogFilters(catalogFilters);
Nebula::TypeGroup typeFilters = Nebula::TypeGroup(0);
conf->beginGroup("dso_type_filters");
if (conf->value("flag_show_galaxies", true).toBool())
typeFilters |= Nebula::TypeGalaxies;
if (conf->value("flag_show_active_galaxies", true).toBool())
typeFilters |= Nebula::TypeActiveGalaxies;
if (conf->value("flag_show_interacting_galaxies", true).toBool())
typeFilters |= Nebula::TypeInteractingGalaxies;
if (conf->value("flag_show_clusters", true).toBool())
typeFilters |= Nebula::TypeStarClusters;
if (conf->value("flag_show_bright_nebulae", true).toBool())
typeFilters |= Nebula::TypeBrightNebulae;
if (conf->value("flag_show_dark_nebulae", true).toBool())
typeFilters |= Nebula::TypeDarkNebulae;
if (conf->value("flag_show_planetary_nebulae", true).toBool())
typeFilters |= Nebula::TypePlanetaryNebulae;
if (conf->value("flag_show_hydrogen_regions", true).toBool())
typeFilters |= Nebula::TypeHydrogenRegions;
if (conf->value("flag_show_supernova_remnants", true).toBool())
typeFilters |= Nebula::TypeSupernovaRemnants;
if (conf->value("flag_show_other", true).toBool())
typeFilters |= Nebula::TypeOther;
conf->endGroup();
setTypeFilters(typeFilters);
// TODO: mechanism to specify which sets get loaded at start time.
// candidate methods:
// 1. config file option (list of sets to load at startup)
// 2. load all
// 3. flag in nebula_textures.fab (yuk)
// 4. info.ini file in each set containing a "load at startup" item
// For now (0.9.0), just load the default set
// NB: nebula set loaded inside setter of catalog filter --AW
// loadNebulaSet("default");
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");
} }
struct DrawNebulaFuncObject struct DrawNebulaFuncObject
{ {
DrawNebulaFuncObject(float amaxMagHints, float amaxMagLabels, StelPa DrawNebulaFuncObject(float amaxMagHints, float amaxMagLabels, StelPa
inter* p, StelCore* aCore, bool acheckMaxMagHints) : maxMagHints(amaxMagHin inter* p, StelCore* aCore, bool acheckMaxMagHints)
ts), maxMagLabels(amaxMagLabels), sPainter(p), core(aCore), checkMaxMagHint : maxMagHints(amaxMagHints)
s(acheckMaxMagHints) , maxMagLabels(amaxMagLabels)
, sPainter(p)
, core(aCore)
, checkMaxMagHints(acheckMaxMagHints)
{ {
angularSizeLimit = 5.f/sPainter->getProjector()->getPixelPer RadAtCenter()*180.f/M_PI; angularSizeLimit = 5.f/sPainter->getProjector()->getPixelPer RadAtCenter()*180.f/M_PI;
} }
void operator()(StelRegionObject* obj) void operator()(StelRegionObject* obj)
{ {
Nebula* n = static_cast<Nebula*>(obj); Nebula* n = static_cast<Nebula*>(obj);
StelSkyDrawer *drawer = core->getSkyDrawer(); StelSkyDrawer *drawer = core->getSkyDrawer();
// filter out DSOs which are too dim to be seen (e.g. for bi no observers) // filter out DSOs which are too dim to be seen (e.g. for bi no observers)
if ((drawer->getFlagNebulaMagnitudeLimit()) && (n->mag > dra wer->getCustomNebulaMagnitudeLimit())) return; if ((drawer->getFlagNebulaMagnitudeLimit()) && (n->vMag > dr awer->getCustomNebulaMagnitudeLimit())) return;
if (n->angularSize>angularSizeLimit || (checkMaxMagHints && n->mag <= maxMagHints)) if (n->majorAxisSize>angularSizeLimit || (checkMaxMagHints & & n->vMag <= maxMagHints))
{ {
float refmag_add=0; // value to adjust hints visibil ity threshold. float refmag_add=0; // value to adjust hints visibil ity threshold.
sPainter->getProjector()->project(n->XYZ,n->XY); sPainter->getProjector()->project(n->XYZ,n->XY);
n->drawLabel(*sPainter, maxMagLabels-refmag_add); n->drawLabel(*sPainter, maxMagLabels-refmag_add);
n->drawHints(*sPainter, maxMagHints -refmag_add); n->drawHints(*sPainter, maxMagHints -refmag_add);
} }
} }
float maxMagHints; float maxMagHints;
float maxMagLabels; float maxMagLabels;
StelPainter* sPainter; StelPainter* sPainter;
StelCore* core; StelCore* core;
float angularSizeLimit; float angularSizeLimit;
bool checkMaxMagHints; bool checkMaxMagHints;
}; };
void NebulaMgr::setCatalogFilters(const Nebula::CatalogGroup &cflags)
{
Nebula::catalogFilters = cflags;
dsoArray.clear();
dsoIndex.clear();
nebGrid.clear();
bool status = getFlagShow();
StelApp::getInstance().getStelObjectMgr().unSelect();
qWarning() << "Reloading DSO data...";
setFlagShow(false);
loadNebulaSet("default");
setFlagShow(status);
}
float NebulaMgr::computeMaxMagHint(const StelSkyDrawer* skyDrawer) const float NebulaMgr::computeMaxMagHint(const StelSkyDrawer* skyDrawer) const
{ {
return skyDrawer->getLimitMagnitude()*1.2f-2.f+(hintsAmount *1.2f)-2 .f; return skyDrawer->getLimitMagnitude()*1.2f-2.f+(hintsAmount *1.2f)-2 .f;
} }
// Draw all the Nebulae // Draw all the Nebulae
void NebulaMgr::draw(StelCore* core) void NebulaMgr::draw(StelCore* core)
{ {
const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000) ; const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000) ;
StelPainter sPainter(prj); StelPainter sPainter(prj);
skipping to change at line 188 skipping to change at line 303
sPainter.enableTexture2d(true); sPainter.enableTexture2d(true);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE); glBlendFunc(GL_ONE, GL_ONE);
// Use a 1 degree margin // Use a 1 degree margin
const double margin = 1.*M_PI/180.*prj->getPixelPerRadAtCenter(); const double margin = 1.*M_PI/180.*prj->getPixelPerRadAtCenter();
const SphericalRegionP& p = prj->getViewportConvexPolygon(margin, ma rgin); const SphericalRegionP& p = prj->getViewportConvexPolygon(margin, ma rgin);
// Print all the nebulae of all the selected zones // Print all the nebulae of all the selected zones
float maxMagHints = computeMaxMagHint(skyDrawer); float maxMagHints = computeMaxMagHint(skyDrawer);
float maxMagLabels = skyDrawer->getLimitMagnitude() -2.f+(labels Amount*1.2f)-2.f; float maxMagLabels = skyDrawer->getLimitMagnitude()-2.f+(labelsAmoun t*1.2f)-2.f;
sPainter.setFont(nebulaFont); sPainter.setFont(nebulaFont);
DrawNebulaFuncObject func(maxMagHints, maxMagLabels, &sPainter, core , hintsFader.getInterstate()>0.0001); DrawNebulaFuncObject func(maxMagHints, maxMagLabels, &sPainter, core , hintsFader.getInterstate()>0.0001);
nebGrid.processIntersectingPointInRegions(p.data(), func); nebGrid.processIntersectingPointInRegions(p.data(), func);
if (GETSTELMODULE(StelObjectMgr)->getFlagSelectedObjectPointer()) if (GETSTELMODULE(StelObjectMgr)->getFlagSelectedObjectPointer())
drawPointer(core, sPainter); drawPointer(core, sPainter);
} }
void NebulaMgr::drawPointer(const StelCore* core, StelPainter& sPainter) void NebulaMgr::drawPointer(const StelCore* core, StelPainter& sPainter)
{ {
skipping to change at line 219 skipping to change at line 334
sPainter.setColor(0.4f,0.5f,0.8f); sPainter.setColor(0.4f,0.5f,0.8f);
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();
if (size>120.f) // avoid oversized marker
size = 120.f;
if (Nebula::drawHintProportional) if (Nebula::drawHintProportional)
size*=1.2f; size*=1.2f;
size+=20.f + 10.f*std::sin(3.f * StelApp::getInstance().getT otalRunTime()); 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
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
QString defaultColor = conf->value(section+"/default_color").toStrin g(); QString defaultColor = conf->value(section+"/default_color").toStrin g();
setLabelsColor(StelUtils::strToVec3f(conf->value(section+"/nebula_la bel_color", defaultColor).toString())); setLabelsColor(StelUtils::strToVec3f(conf->value(section+"/nebula_la bel_color", defaultColor).toString()));
setCirclesColor(StelUtils::strToVec3f(conf->value(section+"/nebula_c ircle_color", defaultColor).toString())); setCirclesColor(StelUtils::strToVec3f(conf->value(section+"/nebula_c ircle_color", defaultColor).toString()));
setGalaxyColor(StelUtils::strToVec3f(conf->value(section+"/nebula_ga
laxy_color", "1.0,0.2,0.2").toString()));
setBrightNebulaColor(StelUtils::strToVec3f(conf->value(section+"/neb
ula_brightneb_color", "0.1,1.0,0.1").toString()));
setDarkNebulaColor(StelUtils::strToVec3f(conf->value(section+"/nebul
a_darkneb_color", "0.3,0.3,0.3").toString()));
setClusterColor(StelUtils::strToVec3f(conf->value(section+"/nebula_c
luster_color", "1.0,1.0,0.1").toString()));
setRadioGalaxyColor(StelUtils::strToVec3f(conf->value(section+"/nebu
la_radioglx_color", "0.3,0.3,0.3").toString()));
setActiveGalaxyColor(StelUtils::strToVec3f(conf->value(section+"/neb
ula_activeglx_color", "1.0,0.5,0.2").toString()));
setInteractingGalaxyColor(StelUtils::strToVec3f(conf->value(section+
"/nebula_intglx_color", "0.2,0.5,1.0").toString()));
setHydrogenRegionColor(StelUtils::strToVec3f(conf->value(section+"/n
ebula_hregion_color", "0.1,1.0,0.1").toString()));
setSupernovaRemnantColor(StelUtils::strToVec3f(conf->value(section+"
/nebula_snr_color", "0.1,1.0,0.1").toString()));
} }
// Search by name // Search by name
NebulaP NebulaMgr::search(const QString& name) NebulaP NebulaMgr::search(const QString& name)
{ {
QString uname = name.toUpper(); QString uname = name.toUpper();
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
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|B|VDB|RCW|LDN|LBN|CR|MEL)\\s*( \\d+)$"); static QRegExp catNumRx("^(M|NGC|IC|C|B|VDB|RCW|LDN|LBN|CR|MEL|PGC|U GC)\\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 == "B") return searchB(num);
if (cat == "VDB") return searchVdB(num); if (cat == "VDB") return searchVdB(num);
if (cat == "RCW") return searchRCW(num); if (cat == "RCW") return searchRCW(num);
if (cat == "LDN") return searchLDN(num); if (cat == "LDN") return searchLDN(num);
if (cat == "LBN") return searchLBN(num); if (cat == "LBN") return searchLBN(num);
if (cat == "CR") return searchCr(num); if (cat == "CR") return searchCr(num);
if (cat == "MEL") return searchMel(num); if (cat == "MEL") return searchMel(num);
if (cat == "PGC") return searchPGC(num);
if (cat == "UGC") return searchUGC(num);
} }
static QRegExp dCatNumRx("^(SH)\\s*\\d-\\s*(\\d+)$"); static QRegExp dCatNumRx("^(SH)\\s*\\d-\\s*(\\d+)$");
if (dCatNumRx.exactMatch(uname)) if (dCatNumRx.exactMatch(uname))
{ {
QString dcat = dCatNumRx.capturedTexts().at(1); QString dcat = dCatNumRx.capturedTexts().at(1);
int dnum = dCatNumRx.capturedTexts().at(2).toInt(); int dnum = dCatNumRx.capturedTexts().at(2).toInt();
if (dcat == "SH") return searchSh2(dnum); if (dcat == "SH") return searchSh2(dnum);
} }
static QRegExp sCatNumRx("^(CED)\\s*(.+)$");
if (sCatNumRx.exactMatch(uname))
{
QString cat = catNumRx.capturedTexts().at(1);
QString num = catNumRx.capturedTexts().at(2).trimmed();
if (cat == "CED") return searchCed(num);
}
return NebulaP(); return NebulaP();
} }
void NebulaMgr::loadNebulaSet(const QString& setName) void NebulaMgr::loadNebulaSet(const QString& setName)
{ {
QString ngcPath = StelFileMgr::findFile("nebulae/" + setName + "/ngc QString srcCatalogPath = StelFileMgr::findFile("nebulae/" +
2000.dat"); setName + "/catalog.txt");
QString barnardPath = StelFileMgr::findFile("nebulae/" + setName + " QString dsoCatalogPath = StelFileMgr::findFile("nebulae/" +
/BarnardCat_tabbed.txt"); setName + "/catalog.dat");
QString sharplessPath = StelFileMgr::findFile("nebulae/" + setName + QString dsoNamesPath = StelFileMgr::findFile("nebulae/" +
"/SharplessCat_tabbed.txt"); setName + "/names.dat");
QString vandenBerghPath = StelFileMgr::findFile("nebulae/" + setName
+ "/VandenBerghCat_tabbed.txt"); if (flagConverter)
QString rcwPath = StelFileMgr::findFile("nebulae/" + setName + "/RCW {
Cat_tabbed.txt"); if (!srcCatalogPath.isEmpty())
QString ldnPath = StelFileMgr::findFile("nebulae/" + setName + "/LDN convertDSOCatalog(srcCatalogPath, dsoCatalogPath, fl
Cat_tabbed.txt"); agDecimalCoordinates);
QString lbnPath = StelFileMgr::findFile("nebulae/" + setName + "/LBN else
Cat_tabbed.txt"); qWarning() << "ERROR convert catalogue, because sour
QString ngcNamesPath = StelFileMgr::findFile("nebulae/" + setName + ce data set is not exists for " << setName;
"/ngc2000names.dat");
if (ngcPath.isEmpty() || ngcNamesPath.isEmpty()) }
if (dsoCatalogPath.isEmpty() || dsoNamesPath.isEmpty())
{ {
qWarning() << "ERROR while loading nebula data set " << setN ame; qWarning() << "ERROR while loading deep-sky data set " << se tName;
return; return;
} }
loadNGC(ngcPath);
loadBarnard(barnardPath); loadDSOCatalog(dsoCatalogPath);
loadSharpless(sharplessPath); loadDSONames(dsoNamesPath);
loadVandenBergh(vandenBerghPath);
loadRCW(rcwPath);
loadLDN(ldnPath);
loadLBN(lbnPath);
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.0f; float anglePlusProche=0.0f;
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
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.999f) if (anglePlusProche>0.999f)
{ {
return plusProche; return plusProche;
skipping to change at line 338 skipping to change at line 474
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())
return result; return result;
Vec3d v(av); Vec3d v(av);
v.normalize(); v.normalize();
double cosLimFov = cos(limitFov * M_PI/180.); double cosLimFov = cos(limitFov * M_PI/180.);
Vec3d equPos; Vec3d equPos;
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
equPos = n->XYZ; equPos = n->XYZ;
equPos.normalize(); equPos.normalize();
if (equPos*v>=cosLimFov) if (equPos*v>=cosLimFov)
{ {
result.push_back(qSharedPointerCast<StelObject>(n)); result.push_back(qSharedPointerCast<StelObject>(n));
} }
} }
return result; return result;
} }
NebulaP NebulaMgr::searchDSO(unsigned int DSO)
{
if (dsoIndex.contains(DSO))
return dsoIndex[DSO];
return NebulaP();
}
NebulaP NebulaMgr::searchM(unsigned int M) NebulaP NebulaMgr::searchM(unsigned int M)
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
if (n->M_nb == M) if (n->M_nb == M)
return n; return n;
return NebulaP(); return NebulaP();
} }
NebulaP NebulaMgr::searchNGC(unsigned int NGC) NebulaP NebulaMgr::searchNGC(unsigned int NGC)
{ {
if (ngcIndex.contains(NGC)) foreach (const NebulaP& n, dsoArray)
return ngcIndex[NGC]; if (n->NGC_nb == NGC)
return n;
return NebulaP(); return NebulaP();
} }
NebulaP NebulaMgr::searchIC(unsigned int IC) NebulaP NebulaMgr::searchIC(unsigned int IC)
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
if (n->IC_nb == IC) return n; if (n->IC_nb == IC)
return n;
return NebulaP(); return NebulaP();
} }
NebulaP NebulaMgr::searchC(unsigned int C) NebulaP NebulaMgr::searchC(unsigned int C)
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
if (n->C_nb == C) if (n->C_nb == C)
return n; return n;
return NebulaP(); return NebulaP();
} }
NebulaP NebulaMgr::searchB(unsigned int B) NebulaP NebulaMgr::searchB(unsigned int B)
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
if (n->B_nb == B) if (n->B_nb == B)
return n; return n;
return NebulaP(); return NebulaP();
} }
NebulaP NebulaMgr::searchSh2(unsigned int Sh2) NebulaP NebulaMgr::searchSh2(unsigned int Sh2)
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
if (n->Sh2_nb == Sh2) if (n->Sh2_nb == Sh2)
return n; return n;
return NebulaP(); return NebulaP();
} }
NebulaP NebulaMgr::searchVdB(unsigned int VdB) NebulaP NebulaMgr::searchVdB(unsigned int VdB)
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
if (n->VdB_nb == VdB) if (n->VdB_nb == VdB)
return n; return n;
return NebulaP(); return NebulaP();
} }
NebulaP NebulaMgr::searchRCW(unsigned int RCW) NebulaP NebulaMgr::searchRCW(unsigned int RCW)
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
if (n->RCW_nb == RCW) if (n->RCW_nb == RCW)
return n; return n;
return NebulaP(); return NebulaP();
} }
NebulaP NebulaMgr::searchLDN(unsigned int LDN) NebulaP NebulaMgr::searchLDN(unsigned int LDN)
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
if (n->LDN_nb == LDN) if (n->LDN_nb == LDN)
return n; return n;
return NebulaP(); return NebulaP();
} }
NebulaP NebulaMgr::searchLBN(unsigned int LBN) NebulaP NebulaMgr::searchLBN(unsigned int LBN)
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
if (n->LBN_nb == LBN) if (n->LBN_nb == LBN)
return n; return n;
return NebulaP(); return NebulaP();
} }
NebulaP NebulaMgr::searchCr(unsigned int Cr) NebulaP NebulaMgr::searchCr(unsigned int Cr)
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
if (n->Cr_nb == Cr) if (n->Cr_nb == Cr)
return n; return n;
return NebulaP(); return NebulaP();
} }
NebulaP NebulaMgr::searchMel(unsigned int Mel) NebulaP NebulaMgr::searchMel(unsigned int Mel)
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
if (n->Mel_nb == Mel) if (n->Mel_nb == Mel)
return n; return n;
return NebulaP(); return NebulaP();
} }
#if 0 NebulaP NebulaMgr::searchPGC(unsigned int PGC)
// read from stream
bool NebulaMgr::loadNGCOld(const QString& catNGC)
{ {
QFile in(catNGC); foreach (const NebulaP& n, dsoArray)
if (!in.open(QIODevice::ReadOnly | QIODevice::Text)) if (n->PGC_nb == PGC)
return false; return n;
return NebulaP();
}
NebulaP NebulaMgr::searchUGC(unsigned int UGC)
{
foreach (const NebulaP& n, dsoArray)
if (n->UGC_nb == UGC)
return n;
return NebulaP();
}
NebulaP NebulaMgr::searchCed(QString Ced)
{
foreach (const NebulaP& n, dsoArray)
if (n->Ced_nb.trimmed().toUpper() == Ced.trimmed().toUpper()
)
return n;
return NebulaP();
}
void NebulaMgr::convertDSOCatalog(const QString &in, const QString &out, bo
ol decimal=false)
{
QFile dsoIn(in);
if (!dsoIn.open(QIODevice::ReadOnly | QIODevice::Text))
return;
QFile dsoOut(out);
if (!dsoOut.open(QIODevice::WriteOnly))
return;
int totalRecords=0; int totalRecords=0;
QString record; QString record;
while (!in.atEnd()) while (!dsoIn.atEnd())
{ {
in.readLine(); dsoIn.readLine();
++totalRecords; ++totalRecords;
} }
// rewind the file to the start // rewind the file to the start
in.seek(0); dsoIn.seek(0);
QDataStream dsoOutStream(&dsoOut);
dsoOutStream.setVersion(QDataStream::Qt_5_2);
int id, orientationAngle, NGC, IC, M, C, B, Sh2, VdB, RCW, LDN,
LBN, Cr, Mel, PGC, UGC;
float raRad, decRad, bMag, vMag, majorAxisSize, minorAxisSize, dis
t, distErr, z, zErr, plx, plxErr;
QString oType, mType, Ced, ra, dec;
unsigned int nType;
int currentLineNumber = 0; // what input line we are on int currentLineNumber = 0; // what input line we are on
int currentRecordNumber = 0; // what record number we are on int currentRecordNumber = 0; // what record number we are on
int readOk = 0; // how many records weree rad withou t problems int readOk = 0; // how many records weree rad withou t problems
while (!in.atEnd()) while (!dsoIn.atEnd())
{ {
record = QString::fromUtf8(in.readLine()); record = QString::fromUtf8(dsoIn.readLine());
++currentLineNumber; ++currentLineNumber;
// skip comments // skip comments
if (record.startsWith("//") || record.startsWith("#")) if (record.startsWith("//") || record.startsWith("#"))
continue; continue;
++currentRecordNumber; ++currentRecordNumber;
// Create a new Nebula record if (!record.isEmpty())
NebulaP e = NebulaP(new Nebula);
if (!e->readNGC((char*)record.toLocal8Bit().data())) // read
ing error
{
e.clear();
}
else
{ {
nebArray.append(e); QStringList list=record.split("\t", QString::KeepEmp
nebGrid.insert(qSharedPointerCast<StelRegionObject>( tyParts);
e));
if (e->NGC_nb!=0) id = list.at(0).toInt(); //
ngcIndex.insert(e->NGC_nb, e); ID (inner identification number)
ra = list.at(1).trimmed();
dec = list.at(2).trimmed();
bMag = list.at(3).toFloat(); //
B magnitude
vMag = list.at(4).toFloat(); //
V magnitude
oType = list.at(5).trimmed(); //
Object type
mType = list.at(6).trimmed(); //
Morphological type of object
majorAxisSize = list.at(7).toFloat(); //
major axis size (arcmin)
minorAxisSize = list.at(8).toFloat(); //
minor axis size (arcmin)
orientationAngle = list.at(9).toInt(); //
orientation angle (degrees)
z = list.at(10).toFloat(); //
redshift
zErr = list.at(11).toFloat(); //
error of redshift
plx = list.at(12).toFloat(); //
parallax (mas)
plxErr = list.at(13).toFloat(); //
error of parallax (mas)
dist = list.at(14).toFloat(); //
distance (Mpc for galaxies, kpc for other objects)
distErr = list.at(15).toFloat(); //
distance error (Mpc for galaxies, kpc for other objects)
// -----------------------------------------------
// cross-index data
// -----------------------------------------------
NGC = list.at(16).toInt(); //
NGC number
IC = list.at(17).toInt(); //
IC number
M = list.at(18).toInt(); //
M number
C = list.at(19).toInt(); //
C number
B = list.at(20).toInt(); //
B number
Sh2 = list.at(21).toInt(); //
Sh2 number
VdB = list.at(22).toInt(); //
VdB number
RCW = list.at(23).toInt(); //
RCW number
LDN = list.at(24).toInt(); //
LDN number
LBN = list.at(25).toInt(); //
LBN number
Cr = list.at(26).toInt(); //
Cr number (alias: Col)
Mel = list.at(27).toInt(); //
Mel number
PGC = list.at(28).toInt(); //
PGC number (subset)
UGC = list.at(29).toInt(); //
UGC number (subset)
Ced = list.at(30).trimmed(); //
Ced number
if (decimal)
{
// Convert from deg to rad
raRad = ra.toFloat()*M_PI/180.;
decRad = dec.toFloat()*M_PI/180.;
}
else
{
QStringList raLst;
if (ra.contains(":"))
raLst = ra.split(":");
else
raLst = ra.split(" ");
QStringList decLst;
if (dec.contains(":"))
decLst = dec.split(":");
else
decLst = dec.split(" ");
raRad = raLst.at(0).toFloat() + raLst.at(1
).toFloat()/60.f + raLst.at(2).toFloat()/3600.f;
decRad = qAbs(decLst.at(0).toFloat()) + dec
Lst.at(1).toFloat()/60.f + decLst.at(2).toFloat()/3600.f;
if (dec.startsWith("-")) decRad *= -1.f;
raRad *= M_PI/12.; // Convert from hour
s to rad
decRad *= M_PI/180.; // Convert from deg
to rad
}
majorAxisSize /= 60.f; // Convert from arcmin to de
grees
minorAxisSize /= 60.f; // Convert from arcmin to de
grees
// Warning: Hyades and LMC has visual magnitude less
than 1.0 (0.5^m and 0.9^m)
if (bMag <= 0.f) bMag = 99.f;
if (vMag <= 0.f) vMag = 99.f;
QStringList oTypes;
oTypes << "G" << "GX" << "GC" << "OC" << "NB" << "PN
" << "DN" << "RN" << "C+N"
<< "RNE" << "HII" << "SNR" << "BN" << "EN" <<
"SA" << "SC" << "CL" << "IG"
<< "RG" << "AGX" << "QSO" << "ISM" << "EMO" <
< "GNE" << "RAD" << "LIN"
<< "BLL" << "BLA" << "MOC" << "YSO" << "Q?" <
< "PN?" << "*" << "SFR"
<< "IR" << "**" << "MUL" << "PPN";
switch (oTypes.indexOf(oType.toUpper()))
{
case 0:
case 1:
nType = (unsigned int)Nebula::NebGx;
break;
case 2:
nType = (unsigned int)Nebula::NebGc;
break;
case 3:
nType = (unsigned int)Nebula::NebOc;
break;
case 4:
nType = (unsigned int)Nebula::NebN;
break;
case 5:
nType = (unsigned int)Nebula::NebPn;
break;
case 6:
case 34:
nType = (unsigned int)Nebula::NebDn;
break;
case 7:
case 9:
nType = (unsigned int)Nebula::NebRn;
break;
case 8:
nType = (unsigned int)Nebula::NebCn;
break;
case 10:
case 23:
nType = (unsigned int)Nebula::NebHII
;
break;
case 11:
nType = (unsigned int)Nebula::NebSNR
;
break;
case 12:
nType = (unsigned int)Nebula::NebBn;
break;
case 13:
nType = (unsigned int)Nebula::NebEn;
break;
case 14:
nType = (unsigned int)Nebula::NebSA;
break;
case 15:
nType = (unsigned int)Nebula::NebSC;
break;
case 16:
nType = (unsigned int)Nebula::NebCl;
break;
case 17:
nType = (unsigned int)Nebula::NebIGx
;
break;
case 18:
nType = (unsigned int)Nebula::NebRGx
;
break;
case 19:
case 25: // LINER-type active galaxies
nType = (unsigned int)Nebula::NebAGx
;
break;
case 20:
nType = (unsigned int)Nebula::NebQSO
;
break;
case 21:
case 24:
nType = (unsigned int)Nebula::NebISM
;
break;
case 22:
nType = (unsigned int)Nebula::NebEMO
;
break;
case 26:
nType = (unsigned int)Nebula::NebBLL
;
break;
case 27:
nType = (unsigned int)Nebula::NebBLA
;
break;
case 28:
case 33:
nType = (unsigned int)Nebula::NebMol
Cld;
break;
case 29:
nType = (unsigned int)Nebula::NebYSO
;
break;
case 30:
nType = (unsigned int)Nebula::NebPos
sQSO;
break;
case 31:
nType = (unsigned int)Nebula::NebPos
sPN;
break;
case 32:
case 35:
case 36:
nType = (unsigned int)Nebula::NebSta
r;
break;
case 37:
nType = (unsigned int)Nebula::NebPPN
;
break;
default:
nType = (unsigned int)Nebula::NebUnk
nown;
break;
}
++readOk; ++readOk;
dsoOutStream << id << raRad << decRad << bMag << vMa
g << nType << mType << majorAxisSize << minorAxisSize
<< orientationAngle << z << zErr << plx
<< plxErr << dist << distErr << NGC << IC << M << C
<< B << Sh2 << VdB << RCW << LDN << LB
N << Cr << Mel << PGC << UGC << Ced;
} }
} }
in.close(); dsoIn.close();
qDebug() << "Loaded" << readOk << "/" << totalRecords << "NGC record dsoOut.flush();
s"; dsoOut.close();
return true; qDebug() << "Converted" << readOk << "/" << totalRecords << "DSO rec
ords";
} }
#endif
bool NebulaMgr::loadNGC(const QString& catNGC) bool NebulaMgr::loadDSOCatalog(const QString &filename)
{ {
QFile in(catNGC); QFile in(filename);
if (!in.open(QIODevice::ReadOnly)) if (!in.open(QIODevice::ReadOnly))
return false; return false;
QDataStream ins(&in); QDataStream ins(&in);
ins.setVersion(QDataStream::Qt_4_5); ins.setVersion(QDataStream::Qt_5_2);
int totalRecords=0; int totalRecords=0;
while (!ins.atEnd()) while (!ins.atEnd())
{ {
// Create a new Nebula record // Create a new Nebula record
NebulaP e = NebulaP(new Nebula); NebulaP e = NebulaP(new Nebula);
e->readNGC(ins); e->readDSO(ins);
if (!objectInDisplayedCatalog(e)) continue;
nebArray.append(e); dsoArray.append(e);
nebGrid.insert(qSharedPointerCast<StelRegionObject>(e)); nebGrid.insert(qSharedPointerCast<StelRegionObject>(e));
if (e->NGC_nb!=0) if (e->DSO_nb!=0)
ngcIndex.insert(e->NGC_nb, e); dsoIndex.insert(e->DSO_nb, e);
++totalRecords; ++totalRecords;
} }
in.close(); in.close();
qDebug() << "Loaded" << totalRecords << "NGC records"; qDebug() << "Loaded" << totalRecords << "DSO records";
return true; return true;
} }
bool NebulaMgr::loadNGCNames(const QString& catNGCNames) bool NebulaMgr::objectInDisplayedCatalog(NebulaP n)
{ {
qDebug() << "Loading NGC name data ..."; bool r = false;
QFile ngcNameFile(catNGCNames); Nebula::CatalogGroup catalogFilters = getCatalogFilters();
if (!ngcNameFile.open(QIODevice::ReadOnly | QIODevice::Text)) if ((catalogFilters&Nebula::CatM) && (n->M_nb>0))
r = true;
else if ((catalogFilters&Nebula::CatC) && (n->C_nb>0))
r = true;
else if ((catalogFilters&Nebula::CatNGC) && (n->NGC_nb>0))
r = true;
else if ((catalogFilters&Nebula::CatIC) && (n->IC_nb>0))
r = true;
else if ((catalogFilters&Nebula::CatB) && (n->B_nb>0))
r = true;
else if ((catalogFilters&Nebula::CatSh2) && (n->Sh2_nb>0))
r = true;
else if ((catalogFilters&Nebula::CatVdB) && (n->VdB_nb>0))
r = true;
else if ((catalogFilters&Nebula::CatRCW) && (n->RCW_nb>0))
r = true;
else if ((catalogFilters&Nebula::CatLDN) && (n->LDN_nb>0))
r = true;
else if ((catalogFilters&Nebula::CatLBN) && (n->LBN_nb>0))
r = true;
else if ((catalogFilters&Nebula::CatCr) && (n->Cr_nb>0))
r = true;
else if ((catalogFilters&Nebula::CatMel) && (n->Mel_nb>0))
r = true;
else if ((catalogFilters&Nebula::CatPGC) && (n->PGC_nb>0))
r = true;
else if ((catalogFilters&Nebula::CatUGC) && (n->UGC_nb>0))
r = true;
else if ((catalogFilters&Nebula::CatCed) && !(n->Ced_nb.isEmpty()))
r = true;
// Special case: objects without ID from current catalogs
if (catalogFilters==Nebula::AllCatalogs)
r = true;
return r;
}
bool NebulaMgr::loadDSONames(const QString &filename)
{
qDebug() << "Loading DSO name data ...";
QFile dsoNameFile(filename);
if (!dsoNameFile.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
qWarning() << "NGC name data file" << QDir::toNativeSeparato rs(catNGCNames) << "not found."; qWarning() << "DSO name data file" << QDir::toNativeSeparato rs(filename) << "not found.";
return false; return false;
} }
// Read the names of the NGC objects // Read the names of the NGC objects
QString name, record, ref; QString name, record, ref, cdes;
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 (!dsoNameFile.atEnd())
{ {
record = QString::fromUtf8(ngcNameFile.readLine()); record = QString::fromUtf8(dsoNameFile.readLine());
lineNumber++; lineNumber++;
if (commentRx.exactMatch(record)) if (commentRx.exactMatch(record))
continue; continue;
totalRecords++; totalRecords++;
nb = record.mid(38,4).toInt();
if (record[37] == 'I')
{
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
{
e = searchNGC(nb);
ref = "NGC ";
}
ref = record.left(4).trimmed();
cdes = record.mid(5, 10).trimmed().toUpper();
// get name, trimmed of whitespace // get name, trimmed of whitespace
name = record.left(36).trimmed(); name = record.mid(20).trimmed();
if (e)
{
// If the name is not a messier number perhaps one i
s already
// defined for this object
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)) {
e->englishName = transRx.capturedTex
ts().at(1).trimmed();
}
else
{
e->englishName = name;
}
}
else if (name.left(2).toUpper() == "M ")
{
// 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 Caldwell number, we will call i
t a Caldwell if there is no better name
name = name.mid(2); // remove "C "
// read the Caldwell number
QTextStream istr(&name);
int num;
istr >> num;
if (istr.status()!=QTextStream::Ok)
{
qWarning() << "cannot read Caldwell
number at line" << lineNumber << "of" << QDir::toNativeSeparators(catNGCNam
es);
continue;
}
e->C_nb=(unsigned int)(num);
e->englishName = QString("C%1").arg(num);
}
else if (name.left(2).toUpper() == "CR")
{
// If it's a Collinder number, we will call
it a Messier if there is no better name
name = name.mid(2); // remove "Cr"
// read the Collinder number
QTextStream istr(&name);
int num;
istr >> num;
if (istr.status()!=QTextStream::Ok)
{
qWarning() << "cannot read Collinder
number at line" << lineNumber << "of" << QDir::toNativeSeparators(catNGCNa
mes);
continue;
}
e->Cr_nb=(unsigned int)(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++;
}
else
qWarning() << "no position data for " << name << "at
line" << lineNumber << "of" << QDir::toNativeSeparators(catNGCNames);
}
ngcNameFile.close();
qDebug() << "Loaded" << readOk << "/" << totalRecords << "NGC name r
ecords successfully";
return true;
}
bool NebulaMgr::loadBarnard(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("#"))
continue;
++currentRecordNumber;
// Create a new Nebula record
NebulaP e = NebulaP(new Nebula);
if (!e->readBarnard(record)) // reading error
{
e.clear();
}
else
{
nebArray.append(e);
nebGrid.insert(qSharedPointerCast<StelRegionObject>(
e));
++readOk;
}
}
in.close();
qDebug() << "Loaded" << readOk << "/" << totalRecords << "Barnard re
cords";
return true;
}
bool NebulaMgr::loadSharpless(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->readSharpless(record)) // reading error
{
e.clear();
}
else
{
nebArray.append(e);
nebGrid.insert(qSharedPointerCast<StelRegionObject>(
e));
++readOk;
}
}
in.close();
qDebug() << "Loaded" << readOk << "/" << totalRecords << "Sharpless
records";
return true;
}
bool NebulaMgr::loadVandenBergh(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->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 nb = cdes.toInt();
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 QStringList catalogs;
NebulaP e = NebulaP(new Nebula); catalogs << "IC" << "M" << "C" << "CR" << "MEL" << "B" << "S
if (!e->readRCW(record)) // reading error H2" << "VDB" << "RCW" << "LDN" << "LBN"
{ << "NGC" << "PGC" << "UGC" << "CED";
e.clear();
} switch (catalogs.indexOf(ref.toUpper()))
else {
{ case 0:
nebArray.append(e); e = searchIC(nb);
nebGrid.insert(qSharedPointerCast<StelRegionObject>( break;
e)); case 1:
++readOk; e = searchM(nb);
break;
case 2:
e = searchC(nb);
break;
case 3:
e = searchCr(nb);
break;
case 4:
e = searchMel(nb);
break;
case 5:
e = searchB(nb);
break;
case 6:
e = searchSh2(nb);
break;
case 7:
e = searchVdB(nb);
break;
case 8:
e = searchRCW(nb);
break;
case 9:
e = searchLDN(nb);
break;
case 10:
e = searchLBN(nb);
break;
case 11:
e = searchNGC(nb);
break;
case 12:
e = searchPGC(nb);
break;
case 13:
e = searchUGC(nb);
break;
case 14:
e = searchCed(cdes);
break;
default:
e = searchDSO(nb);
break;
} }
}
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 (e)
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); if (transRx.exactMatch(name))
nebGrid.insert(qSharedPointerCast<StelRegionObject>( e->setProperName(transRx.capturedTexts().at(
e)); 1).trimmed());
++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; readOk++;
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;
} }
//else
// qWarning() << "no position data for " << name << "at
line" << lineNumber << "of" << QDir::toNativeSeparators(filename);
} }
in.close(); dsoNameFile.close();
qDebug() << "Loaded" << readOk << "/" << totalRecords << "LBN (Lynds qDebug() << "Loaded" << readOk << "/" << totalRecords << "DSO name r
' Catalogue of Bright Nebulae) records"; ecords successfully";
return true; return true;
} }
void NebulaMgr::updateI18n() void NebulaMgr::updateI18n()
{ {
const StelTranslator& trans = StelApp::getInstance().getLocaleMgr(). getSkyTranslator(); const StelTranslator& trans = StelApp::getInstance().getLocaleMgr(). getSkyTranslator();
foreach (NebulaP n, nebArray) foreach (NebulaP n, dsoArray)
n->translateName(trans); n->translateName(trans);
} }
//! Return the matching Nebula object's pointer if exists or NULL //! Return the matching Nebula object's pointer if exists or NULL
StelObjectP NebulaMgr::searchByNameI18n(const QString& nameI18n) const StelObjectP NebulaMgr::searchByNameI18n(const QString& nameI18n) const
{ {
QString objw = nameI18n.toUpper(); QString objw = nameI18n.toUpper();
// Search by NGC numbers (possible formats are "NGC31" or "NGC 31") // Search by NGC numbers (possible formats are "NGC31" or "NGC 31")
if (objw.mid(0, 3) == "NGC") if (objw.left(3) == "NGC")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (QString("NGC%1").arg(n->NGC_nb) == objw || QStri ng("NGC %1").arg(n->NGC_nb) == objw) if (QString("NGC%1").arg(n->NGC_nb) == objw || QStri ng("NGC %1").arg(n->NGC_nb) == objw)
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
} }
// Search by common names // Search by common names
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
QString objwcap = n->nameI18.toUpper(); QString objwcap = n->nameI18.toUpper();
if (objwcap==objw) if (objwcap==objw)
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
// Search by IC numbers (possible formats are "IC466" or "IC 466") // Search by IC numbers (possible formats are "IC466" or "IC 466")
if (objw.mid(0, 2) == "IC") if (objw.left(2) == "IC")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (QString("IC%1").arg(n->IC_nb) == objw || QString ("IC %1").arg(n->IC_nb) == objw) if (QString("IC%1").arg(n->IC_nb) == objw || QString ("IC %1").arg(n->IC_nb) == objw)
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
} }
// Search by Messier numbers (possible formats are "M31" or "M 31") // Search by Messier numbers (possible formats are "M31" or "M 31")
if (objw.mid(0, 1) == "M" && objw.mid(1, 1) != "E") if (objw.left(1) == "M" && objw.left(3) != "MEL")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (QString("M%1").arg(n->M_nb) == objw || QString(" M %1").arg(n->M_nb) == objw) if (QString("M%1").arg(n->M_nb) == objw || QString(" M %1").arg(n->M_nb) == objw)
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
} }
// Search by Caldwell numbers (possible formats are "C31" or "C 31") // Search by Caldwell numbers (possible formats are "C31" or "C 31")
if (objw.mid(0, 1) == "C" && objw.mid(1, 2) != "R") if (objw.left(1) == "C" && objw.left(2) != "CR" && objw.left(3) != " CED")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (QString("C%1").arg(n->C_nb) == objw || QString(" C %1").arg(n->C_nb) == objw) if (QString("C%1").arg(n->C_nb) == objw || QString(" C %1").arg(n->C_nb) == objw)
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
} }
// Search by Barnard numbers (possible formats are "B31" or "B 31") // Search by Barnard numbers (possible formats are "B31" or "B 31")
if (objw.mid(0, 1) == "B") if (objw.left(1) == "B")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (QString("B%1").arg(n->B_nb) == objw || QString(" B %1").arg(n->B_nb) == objw) if (QString("B%1").arg(n->B_nb) == objw || QString(" B %1").arg(n->B_nb) == objw)
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
} }
// Search by Sharpless numbers (possible formats are "Sh2-31" or "Sh 2-31") // Search by Sharpless numbers (possible formats are "Sh2-31" or "Sh 2-31")
if (objw.mid(0, 2) == "SH") if (objw.left(2) == "SH")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (QString("SH2-%1").arg(n->Sh2_nb) == objw || QStr ing("SH 2-%1").arg(n->Sh2_nb) == objw) if (QString("SH2-%1").arg(n->Sh2_nb) == objw || QStr ing("SH 2-%1").arg(n->Sh2_nb) == objw)
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
} }
// Search by Van den Bergh numbers (possible formats are "VdB31" or "VdB 31") // Search by Van den Bergh numbers (possible formats are "VdB31" or "VdB 31")
if (objw.mid(0, 3) == "VDB") if (objw.left(3) == "VDB")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (QString("VDB%1").arg(n->VdB_nb) == objw || QStri ng("VDB %1").arg(n->VdB_nb) == objw) if (QString("VDB%1").arg(n->VdB_nb) == objw || QStri ng("VDB %1").arg(n->VdB_nb) == objw)
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
} }
// Search by RCW numbers (possible formats are "RCW31" or "RCW 31") // Search by RCW numbers (possible formats are "RCW31" or "RCW 31")
if (objw.mid(0, 3) == "RCW") if (objw.left(3) == "RCW")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (QString("RCW%1").arg(n->RCW_nb) == objw || QStri ng("RCW %1").arg(n->RCW_nb) == objw) if (QString("RCW%1").arg(n->RCW_nb) == objw || QStri ng("RCW %1").arg(n->RCW_nb) == objw)
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
} }
// Search by LDN numbers (possible formats are "LDN31" or "LDN 31") // Search by LDN numbers (possible formats are "LDN31" or "LDN 31")
if (objw.mid(0, 3) == "LDN") if (objw.left(3) == "LDN")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (QString("LDN%1").arg(n->LDN_nb) == objw || QStri ng("LDN %1").arg(n->LDN_nb) == objw) if (QString("LDN%1").arg(n->LDN_nb) == objw || QStri ng("LDN %1").arg(n->LDN_nb) == objw)
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
} }
// Search by LBN numbers (possible formats are "LBN31" or "LBN 31") // Search by LBN numbers (possible formats are "LBN31" or "LBN 31")
if (objw.mid(0, 3) == "LBN") if (objw.left(3) == "LBN")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (QString("LBN%1").arg(n->LBN_nb) == objw || QStri ng("LBN %1").arg(n->LBN_nb) == objw) if (QString("LBN%1").arg(n->LBN_nb) == objw || QStri ng("LBN %1").arg(n->LBN_nb) == objw)
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
} }
// Search by Collinder numbers (possible formats are "Cr31" or "Cr 3 1") // Search by Collinder numbers (possible formats are "Cr31" or "Cr 3 1")
if (objw.mid(0, 2) == "CR") if (objw.left(2) == "CR")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (QString("CR%1").arg(n->Cr_nb) == objw || QString ("CR %1").arg(n->Cr_nb) == objw) if (QString("CR%1").arg(n->Cr_nb) == objw || QString ("CR %1").arg(n->Cr_nb) == objw)
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
} }
// Search by Melotte numbers (possible formats are "Mel31" or "Mel 3 1") // Search by Melotte numbers (possible formats are "Mel31" or "Mel 3 1")
if (objw.mid(0, 3) == "MEL") if (objw.left(3) == "MEL")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (QString("MEL%1").arg(n->Mel_nb) == objw || QStri ng("MEL %1").arg(n->Mel_nb) == objw) if (QString("MEL%1").arg(n->Mel_nb) == objw || QStri ng("MEL %1").arg(n->Mel_nb) == objw)
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
} }
// Search by PGC numbers (possible formats are "PGC31" or "PGC 31")
if (objw.left(3) == "PGC")
{
foreach (const NebulaP& n, dsoArray)
{
if (QString("PGC%1").arg(n->PGC_nb) == objw || QStri
ng("PGC %1").arg(n->PGC_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
// Search by UGC numbers (possible formats are "UGC31" or "UGC 31")
if (objw.left(3) == "UGC")
{
foreach (const NebulaP& n, dsoArray)
{
if (QString("UGC%1").arg(n->UGC_nb) == objw || QStri
ng("UGC %1").arg(n->UGC_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
// Search by Cederblad numbers (possible formats are "Ced31" or "Ced
31")
if (objw.left(3) == "CED")
{
foreach (const NebulaP& n, dsoArray)
{
if (QString("CED%1").arg(n->Ced_nb.trimmed().toUpper
()) == objw.trimmed() || QString("CED %1").arg(n->Ced_nb.trimmed().toUpper(
)) == objw.trimmed())
return qSharedPointerCast<StelObject>(n);
}
}
return StelObjectP(); return StelObjectP();
} }
//! Return the matching Nebula object's pointer if exists or NULL //! 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. //! TODO split common parts of this and I18 fn above into a separate fn.
StelObjectP NebulaMgr::searchByName(const QString& name) const StelObjectP NebulaMgr::searchByName(const QString& name) const
{ {
QString objw = name.toUpper(); QString objw = name.toUpper();
// Search by NGC numbers (possible formats are "NGC31" or "NGC 31") // Search by NGC numbers (possible formats are "NGC31" or "NGC 31")
if (objw.startsWith("NGC")) if (objw.startsWith("NGC"))
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (QString("NGC%1").arg(n->NGC_nb) == objw || QStri ng("NGC %1").arg(n->NGC_nb) == objw) if (QString("NGC%1").arg(n->NGC_nb) == objw || QStri ng("NGC %1").arg(n->NGC_nb) == objw)
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
} }
// Search by common names // Search by common names
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
QString objwcap = n->englishName.toUpper(); QString objwcap = n->englishName.toUpper();
if (objwcap==objw) if (objwcap==objw)
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
// Search by IC numbers (possible formats are "IC466" or "IC 466") // Search by IC numbers (possible formats are "IC466" or "IC 466")
if (objw.startsWith("IC")) if (objw.startsWith("IC"))
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (QString("IC%1").arg(n->IC_nb) == objw || QString ("IC %1").arg(n->IC_nb) == objw) if (QString("IC%1").arg(n->IC_nb) == objw || QString ("IC %1").arg(n->IC_nb) == objw)
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
} }
// Search by Messier numbers (possible formats are "M31" or "M 31") // Search by Messier numbers (possible formats are "M31" or "M 31")
if (objw.startsWith("M") && !objw.startsWith("ME")) if (objw.startsWith("M") && !objw.startsWith("ME"))
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (QString("M%1").arg(n->M_nb) == objw || QString(" M %1").arg(n->M_nb) == objw) if (QString("M%1").arg(n->M_nb) == objw || QString(" M %1").arg(n->M_nb) == objw)
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
} }
// Search by Caldwell numbers (possible formats are "C31" or "C 31") // Search by Caldwell numbers (possible formats are "C31" or "C 31")
if (objw.startsWith("C") && !objw.startsWith("CR")) if (objw.startsWith("C") && !objw.startsWith("CR") && !objw.startsWi th("CE"))
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (QString("C%1").arg(n->C_nb) == objw || QString(" C %1").arg(n->C_nb) == objw) if (QString("C%1").arg(n->C_nb) == objw || QString(" C %1").arg(n->C_nb) == objw)
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
} }
// Search by Barnard numbers (possible formats are "B31" or "B 31") // Search by Barnard numbers (possible formats are "B31" or "B 31")
if (objw.startsWith("B")) if (objw.startsWith("B"))
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (QString("B%1").arg(n->B_nb) == objw || QString(" B %1").arg(n->B_nb) == objw) if (QString("B%1").arg(n->B_nb) == objw || QString(" B %1").arg(n->B_nb) == objw)
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
} }
// Search by Sharpless numbers (possible formats are "Sh2-31" or "Sh 2-31") // Search by Sharpless numbers (possible formats are "Sh2-31" or "Sh 2-31")
if (objw.startsWith("SH")) if (objw.startsWith("SH"))
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (QString("SH2-%1").arg(n->Sh2_nb) == objw || QStr ing("SH 2-%1").arg(n->Sh2_nb) == objw) if (QString("SH2-%1").arg(n->Sh2_nb) == objw || QStr ing("SH 2-%1").arg(n->Sh2_nb) == objw)
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
} }
// Search by Van den Bergh numbers (possible formats are "VdB31" or "VdB 31") // Search by Van den Bergh numbers (possible formats are "VdB31" or "VdB 31")
if (objw.startsWith("VDB")) if (objw.startsWith("VDB"))
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (QString("VDB%1").arg(n->VdB_nb) == objw || QStri ng("VDB %1").arg(n->VdB_nb) == objw) if (QString("VDB%1").arg(n->VdB_nb) == objw || QStri ng("VDB %1").arg(n->VdB_nb) == objw)
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
} }
// Search by RCW numbers (possible formats are "RCW31" or "RCW 31") // Search by RCW numbers (possible formats are "RCW31" or "RCW 31")
if (objw.startsWith("RCW")) if (objw.startsWith("RCW"))
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (QString("RCW%1").arg(n->RCW_nb) == objw || QStri ng("RCW %1").arg(n->RCW_nb) == objw) if (QString("RCW%1").arg(n->RCW_nb) == objw || QStri ng("RCW %1").arg(n->RCW_nb) == objw)
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
} }
// Search by LDN numbers (possible formats are "LDN31" or "LDN 31") // Search by LDN numbers (possible formats are "LDN31" or "LDN 31")
if (objw.startsWith("LDN")) if (objw.startsWith("LDN"))
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (QString("LDN%1").arg(n->LDN_nb) == objw || QStri ng("LDN %1").arg(n->LDN_nb) == objw) if (QString("LDN%1").arg(n->LDN_nb) == objw || QStri ng("LDN %1").arg(n->LDN_nb) == objw)
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
} }
// Search by LBN numbers (possible formats are "LBN31" or "LBN 31") // Search by LBN numbers (possible formats are "LBN31" or "LBN 31")
if (objw.startsWith("LBN")) if (objw.startsWith("LBN"))
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (QString("LBN%1").arg(n->LBN_nb) == objw || QStri ng("LBN %1").arg(n->LBN_nb) == objw) if (QString("LBN%1").arg(n->LBN_nb) == objw || QStri ng("LBN %1").arg(n->LBN_nb) == objw)
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
} }
// Search by Collinder numbers (possible formats are "Cr31" or "Cr 3 1") // Search by Collinder numbers (possible formats are "Cr31" or "Cr 3 1")
if (objw.startsWith("CR")) if (objw.startsWith("CR") || objw.startsWith("COL"))
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (QString("CR%1").arg(n->Cr_nb) == objw || QString ("CR %1").arg(n->Cr_nb) == objw) if (QString("CR%1").arg(n->Cr_nb) == objw || QString ("CR %1").arg(n->Cr_nb) == objw)
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
} }
// Search by Melotte numbers (possible formats are "Mel31" or "Mel 3 1") // Search by Melotte numbers (possible formats are "Mel31" or "Mel 3 1")
if (objw.startsWith("MEL")) if (objw.startsWith("MEL"))
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (QString("MEL%1").arg(n->Mel_nb) == objw || QStri ng("MEL %1").arg(n->Mel_nb) == objw) if (QString("MEL%1").arg(n->Mel_nb) == objw || QStri ng("MEL %1").arg(n->Mel_nb) == objw)
return qSharedPointerCast<StelObject>(n); return qSharedPointerCast<StelObject>(n);
} }
} }
// Search by PGC numbers (possible formats are "PGC31" or "PGC 31")
if (objw.startsWith("PGC"))
{
foreach (const NebulaP& n, dsoArray)
{
if (QString("PGC%1").arg(n->PGC_nb) == objw || QStri
ng("PGC %1").arg(n->PGC_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
// Search by UGC numbers (possible formats are "UGC31" or "UGC 31")
if (objw.startsWith("UGC"))
{
foreach (const NebulaP& n, dsoArray)
{
if (QString("UGC%1").arg(n->UGC_nb) == objw || QStri
ng("UGC %1").arg(n->UGC_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
// Search by Cederblad numbers (possible formats are "Ced31" or "Ced
31")
if (objw.startsWith("CED"))
{
foreach (const NebulaP& n, dsoArray)
{
if (QString("CED%1").arg(n->Ced_nb.trimmed().toUpper
()) == objw.trimmed() || QString("CED %1").arg(n->Ced_nb.trimmed().toUpper(
)) == objw.trimmed())
return qSharedPointerCast<StelObject>(n);
}
}
return NULL; return NULL;
} }
//! Find and return the list of at most maxNbItem objects auto-completing t he passed object I18n name //! 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 NebulaMgr::listMatchingObjectsI18n(const QString& objPrefix, in t maxNbItem, bool useStartOfWords) const
{ {
QStringList result; QStringList result;
if (maxNbItem==0) return result; if (maxNbItem==0) return result;
QString objw = objPrefix.toUpper(); QString objw = objPrefix.toUpper();
// Search 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' && objw[1]!='E') if (objw.size()>=1 && objw.left(1)=="M" && objw.left(3)!="MEL")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
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") // Search by Melotte objects number (possible formats are "Mel31" or "Mel 31")
if (objw.size()>=1 && objw[0]=='M' && objw[1]=='E') if (objw.size()>=1 && objw.left(3)=="MEL")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (n->Mel_nb==0) continue; if (n->Mel_nb==0) continue;
QString constw = QString("MEL%1").arg(n->Mel_nb); QString constw = QString("MEL%1").arg(n->Mel_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("MEL %1").arg(n->Mel_nb); constw = QString("MEL %1").arg(n->Mel_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 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.left(2)=="IC")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
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)
{ {
result << constws; result << constws;
continue; // Prevent adding both forms for name continue; // Prevent adding both forms for name
} }
constw = QString("IC %1").arg(n->IC_nb); constw = QString("IC %1").arg(n->IC_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 NGC numbers (possible formats are "NGC31" or "NGC 31") // Search by NGC numbers (possible formats are "NGC31" or "NGC 31")
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (n->NGC_nb==0) continue; if (n->NGC_nb==0) continue;
QString constw = QString("NGC%1").arg(n->NGC_nb); QString constw = QString("NGC%1").arg(n->NGC_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; 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 PGC objects number (possible formats are "PGC31" or "PG
C 31")
if (objw.size()>=1 && objw.left(3)=="PGC")
{
foreach (const NebulaP& n, dsoArray)
{
if (n->PGC_nb==0) continue;
QString constw = QString("PGC%1").arg(n->PGC_nb);
QString constws = constw.mid(0, objw.size());
if (constws==objw)
{
result << constws;
continue; // Prevent adding both forms
for name
}
constw = QString("PGC %1").arg(n->PGC_nb);
constws = constw.mid(0, objw.size());
if (constws==objw)
result << constw;
}
}
// Search by UGC objects number (possible formats are "UGC31" or "UG
C 31")
if (objw.size()>=1 && objw.left(3)=="UGC")
{
foreach (const NebulaP& n, dsoArray)
{
if (n->UGC_nb==0) continue;
QString constw = QString("UGC%1").arg(n->UGC_nb);
QString constws = constw.mid(0, objw.size());
if (constws==objw)
{
result << constws;
continue; // Prevent adding both forms
for name
}
constw = QString("UGC %1").arg(n->UGC_nb);
constws = constw.mid(0, objw.size());
if (constws==objw)
result << constw;
}
}
// Search by Caldwell objects number (possible formats are "C31" or "C 31") // Search by Caldwell objects number (possible formats are "C31" or "C 31")
if (objw.size()>=1 && objw[0]=='C' && objw[1]!='R') if (objw.size()>=1 && objw.left(1)=="C" && objw.left(2)!="CR" && obj w.left(2)!="CE")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
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") // Search by Collinder objects number (possible formats are "Cr31" o r "Cr 31")
if (objw.size()>=1 && objw[0]=='C' && objw[1]=='R') if (objw.size()>=1 && objw.left(2)=="CR")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (n->Cr_nb==0) continue; if (n->Cr_nb==0) continue;
QString constw = QString("CR%1").arg(n->Cr_nb); QString constw = QString("CR%1").arg(n->Cr_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("CR %1").arg(n->Cr_nb); constw = QString("CR %1").arg(n->Cr_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 Ced objects number (possible formats are "Ced31" or "Ce
d 31")
if (objw.size()>=1 && objw.left(3)=="CED")
{
foreach (const NebulaP& n, dsoArray)
{
if (n->Ced_nb==0) continue;
QString constw = QString("Ced%1").arg(n->Ced_nb.trim
med());
QString constws = constw.mid(0, objw.size());
if (constws.toUpper()==objw.toUpper())
{
result << constws;
continue; // Prevent adding both forms
for name
}
constw = QString("Ced %1").arg(n->Ced_nb.trimmed());
constws = constw.mid(0, objw.size());
if (constws.toUpper()==objw.toUpper())
result << constw;
}
}
// Search by Barnard objects number (possible formats are "B31" or " B 31") // Search by Barnard objects number (possible formats are "B31" or " B 31")
if (objw.size()>=1 && objw[0]=='B') if (objw.size()>=1 && objw.left(1)=="B")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (n->B_nb==0) continue; if (n->B_nb==0) continue;
QString constw = QString("B%1").arg(n->B_nb); QString constw = QString("B%1").arg(n->B_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("B %1").arg(n->B_nb); constw = QString("B %1").arg(n->B_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 Sharpless objects number (possible formats are "Sh2-31" or "Sh 2-31") // Search by Sharpless objects number (possible formats are "Sh2-31" or "Sh 2-31")
if (objw.size()>=1 && objw[0]=='S') if (objw.size()>=1 && objw.left(2)=="SH")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (n->Sh2_nb==0) continue; if (n->Sh2_nb==0) continue;
QString constw = QString("SH2-%1").arg(n->Sh2_nb); QString constw = QString("SH2-%1").arg(n->Sh2_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("SH 2-%1").arg(n->Sh2_nb); constw = QString("SH 2-%1").arg(n->Sh2_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 Van den Bergh objects number (possible formats are "VdB 31" or "VdB 31") // Search by Van den Bergh objects number (possible formats are "VdB 31" or "VdB 31")
if (objw.size()>=1 && objw[0]=='V') if (objw.size()>=1 && objw.left(3)=="VDB")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (n->VdB_nb==0) continue; if (n->VdB_nb==0) continue;
QString constw = QString("VDB%1").arg(n->VdB_nb); QString constw = QString("VDB%1").arg(n->VdB_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("VDB %1").arg(n->VdB_nb); constw = QString("VDB %1").arg(n->VdB_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 RCW objects number (possible formats are "RCW31" or "RC W 31") // Search by RCW objects number (possible formats are "RCW31" or "RC W 31")
if (objw.size()>=1 && objw[0]=='R') if (objw.size()>=1 && objw.left(3)=="RCW")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (n->RCW_nb==0) continue; if (n->RCW_nb==0) continue;
QString constw = QString("RCW%1").arg(n->RCW_nb); QString constw = QString("RCW%1").arg(n->RCW_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("RCW %1").arg(n->RCW_nb); constw = QString("RCW %1").arg(n->RCW_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 LDN objects number (possible formats are "LDN31" or "LD N 31") // Search by LDN objects number (possible formats are "LDN31" or "LD N 31")
if (objw.size()>=1 && objw[0]=='L' && objw[1]=='D') if (objw.size()>=1 && objw.left(3)=="LDN")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (n->LDN_nb==0) continue; if (n->LDN_nb==0) continue;
QString constw = QString("LDN%1").arg(n->LDN_nb); QString constw = QString("LDN%1").arg(n->LDN_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("LDN %1").arg(n->LDN_nb); constw = QString("LDN %1").arg(n->LDN_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 LBN objects number (possible formats are "LBN31" or "LB N 31") // Search by LBN objects number (possible formats are "LBN31" or "LB N 31")
if (objw.size()>=1 && objw[0]=='L' && objw[1]=='B') if (objw.size()>=1 && objw.left(3)=="LBN")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (n->LBN_nb==0) continue; if (n->LBN_nb==0) continue;
QString constw = QString("LBN%1").arg(n->LBN_nb); QString constw = QString("LBN%1").arg(n->LBN_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("LBN %1").arg(n->LBN_nb); constw = QString("LBN %1").arg(n->LBN_nb);
constws = constw.mid(0, objw.size()); constws = constw.mid(0, objw.size());
if (constws==objw) if (constws==objw)
result << constw; 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, dsoArray)
{ {
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)
find = true; find = true;
} }
else else
skipping to change at line 1544 skipping to change at line 1712
} }
//! 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' && objw[1]!='E') if (objw.size()>=1 && objw.left(1)=="M" && objw.left(2)!="ME")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
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") // Search by Melotte objects number (possible formats are "Mel31" or "Mel 31")
if (objw.size()>=1 && objw[0]=='M' && objw[1]=='E') if (objw.size()>=1 && objw.left(3)=="MEL")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (n->Mel_nb==0) continue; if (n->Mel_nb==0) continue;
QString constw = QString("MEL%1").arg(n->Mel_nb); QString constw = QString("MEL%1").arg(n->Mel_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("MEL %1").arg(n->Mel_nb); constw = QString("MEL %1").arg(n->Mel_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 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.left(2)=="IC")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
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)
{ {
result << constws; result << constws;
continue; // Prevent adding both forms for name continue; // Prevent adding both forms for name
} }
constw = QString("IC %1").arg(n->IC_nb); constw = QString("IC %1").arg(n->IC_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 NGC numbers (possible formats are "NGC31" or "NGC 31") // Search by NGC numbers (possible formats are "NGC31" or "NGC 31")
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (n->NGC_nb==0) continue; if (n->NGC_nb==0) continue;
QString constw = QString("NGC%1").arg(n->NGC_nb); QString constw = QString("NGC%1").arg(n->NGC_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; 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 PGC numbers (possible formats are "PGC31" or "PGC 31")
if (objw.size()>=1 && objw.left(3)=="PGC")
{
foreach (const NebulaP& n, dsoArray)
{
if (n->PGC_nb==0) continue;
QString constw = QString("PGC%1").arg(n->PGC_nb);
QString constws = constw.mid(0, objw.size());
if (constws==objw)
{
result << constws;
continue;
}
constw = QString("PGC %1").arg(n->PGC_nb);
constws = constw.mid(0, objw.size());
if (constws==objw)
result << constw;
}
}
// Search by UGC numbers (possible formats are "UGC31" or "UGC 31")
if (objw.size()>=1 && objw.left(3)=="UGC")
{
foreach (const NebulaP& n, dsoArray)
{
if (n->UGC_nb==0) continue;
QString constw = QString("UGC%1").arg(n->UGC_nb);
QString constws = constw.mid(0, objw.size());
if (constws==objw)
{
result << constws;
continue;
}
constw = QString("UGC %1").arg(n->UGC_nb);
constws = constw.mid(0, objw.size());
if (constws==objw)
result << constw;
}
}
// Search by Ced numbers (possible formats are "Ced31" or "Ced 31")
if (objw.size()>=1 && objw.left(3)=="CED")
{
foreach (const NebulaP& n, dsoArray)
{
if (n->Ced_nb==0) continue;
QString constw = QString("Ced%1").arg(n->Ced_nb.trim
med());
QString constws = constw.mid(0, objw.size());
if (constws.toUpper()==objw.toUpper())
{
result << constws;
continue;
}
constw = QString("Ced %1").arg(n->Ced_nb.trimmed());
constws = constw.mid(0, objw.size());
if (constws.toUpper()==objw.toUpper())
result << constw;
}
}
// Search by Caldwell objects number (possible formats are "C31" or "C 31") // Search by Caldwell objects number (possible formats are "C31" or "C 31")
if (objw.size()>=1 && objw[0]=='C' && objw[1]!='R') if (objw.size()>=1 && objw.left(1)=="C" && objw.left(2)!="CR" && obj w.left(2)!="CE")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
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") // Search by Collinder objects number (possible formats are "Cr31" o r "Cr 31")
if (objw.size()>=1 && objw[0]=='C' && objw[1]=='R') if (objw.size()>=1 && objw.left(2)=="CR")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (n->Cr_nb==0) continue; if (n->Cr_nb==0) continue;
QString constw = QString("CR%1").arg(n->Cr_nb); QString constw = QString("CR%1").arg(n->Cr_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("CR %1").arg(n->Cr_nb); constw = QString("CR %1").arg(n->Cr_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 Barnard objects number (possible formats are "B31" or " B 31") // Search by Barnard objects number (possible formats are "B31" or " B 31")
if (objw.size()>=1 && objw[0]=='B') if (objw.size()>=1 && objw.left(1)=="B")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (n->B_nb==0) continue; if (n->B_nb==0) continue;
QString constw = QString("B%1").arg(n->B_nb); QString constw = QString("B%1").arg(n->B_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("B %1").arg(n->B_nb); constw = QString("B %1").arg(n->B_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 Sharpless objects number (possible formats are "Sh2-31" or "Sh 2-31") // Search by Sharpless objects number (possible formats are "Sh2-31" or "Sh 2-31")
if (objw.size()>=1 && objw[0]=='S') if (objw.size()>=1 && objw.left(2)=="SH")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (n->Sh2_nb==0) continue; if (n->Sh2_nb==0) continue;
QString constw = QString("SH2-%1").arg(n->Sh2_nb); QString constw = QString("SH2-%1").arg(n->Sh2_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("SH 2-%1").arg(n->Sh2_nb); constw = QString("SH 2-%1").arg(n->Sh2_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 Van den Bergh objects number (possible formats are "VdB 31" or "VdB 31") // Search by Van den Bergh objects number (possible formats are "VdB 31" or "VdB 31")
if (objw.size()>=1 && objw[0]=='V') if (objw.size()>=1 && objw.left(3)=="VDB")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (n->VdB_nb==0) continue; if (n->VdB_nb==0) continue;
QString constw = QString("VDB%1").arg(n->VdB_nb); QString constw = QString("VDB%1").arg(n->VdB_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("VDB %1").arg(n->VdB_nb); constw = QString("VDB %1").arg(n->VdB_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 RCW objects number (possible formats are "RCW31" or "RC W 31") // Search by RCW objects number (possible formats are "RCW31" or "RC W 31")
if (objw.size()>=1 && objw[0]=='R') if (objw.size()>=1 && objw.left(3)=="RCW")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (n->RCW_nb==0) continue; if (n->RCW_nb==0) continue;
QString constw = QString("RCW%1").arg(n->RCW_nb); QString constw = QString("RCW%1").arg(n->RCW_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("RCW %1").arg(n->RCW_nb); constw = QString("RCW %1").arg(n->RCW_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 LDN objects number (possible formats are "LDN31" or "LD N 31") // Search by LDN objects number (possible formats are "LDN31" or "LD N 31")
if (objw.size()>=1 && objw[0]=='L' && objw[1]=='D') if (objw.size()>=1 && objw.left(3)=="LDN")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (n->LDN_nb==0) continue; if (n->LDN_nb==0) continue;
QString constw = QString("LDN%1").arg(n->LDN_nb); QString constw = QString("LDN%1").arg(n->LDN_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("LDN %1").arg(n->LDN_nb); constw = QString("LDN %1").arg(n->LDN_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 LBN objects number (possible formats are "LBN31" or "LB N 31") // Search by LBN objects number (possible formats are "LBN31" or "LB N 31")
if (objw.size()>=1 && objw[0]=='L' && objw[1]=='B') if (objw.size()>=1 && objw.left(3)=="LBN")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, dsoArray)
{ {
if (n->LBN_nb==0) continue; if (n->LBN_nb==0) continue;
QString constw = QString("LBN%1").arg(n->LBN_nb); QString constw = QString("LBN%1").arg(n->LBN_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("LBN %1").arg(n->LBN_nb); constw = QString("LBN %1").arg(n->LBN_nb);
constws = constw.mid(0, objw.size()); constws = constw.mid(0, objw.size());
if (constws==objw) if (constws==objw)
result << constw; 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, dsoArray)
{ {
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)
find = true; find = true;
} }
else else
skipping to change at line 1814 skipping to change at line 2042
{ {
if (result.size()>maxNbItem) result.erase(result.begin()+max NbItem, result.end()); if (result.size()>maxNbItem) result.erase(result.begin()+max NbItem, result.end());
} }
return result; return result;
} }
QStringList NebulaMgr::listAllObjects(bool inEnglish) const QStringList NebulaMgr::listAllObjects(bool inEnglish) const
{ {
QStringList result; QStringList result;
foreach(const NebulaP& n, nebArray) foreach(const NebulaP& n, dsoArray)
{ {
if (!n->getEnglishName().isEmpty()) if (!n->getEnglishName().isEmpty())
{ {
if (inEnglish) if (inEnglish)
result << n->getEnglishName(); result << n->getEnglishName();
else else
result << n->getNameI18n(); result << n->getNameI18n();
} }
} }
return result; return result;
} }
QStringList NebulaMgr::listAllObjectsByType(const QString &objType, bool in English) const QStringList NebulaMgr::listAllObjectsByType(const QString &objType, bool in English) const
{ {
QStringList result; QStringList result;
int type = objType.toInt(); int type = objType.toInt();
switch (type) switch (type)
{ {
case 0: // Bright galaxies? case 0: // Bright galaxies?
foreach(const NebulaP& n, nebArray) foreach(const NebulaP& n, dsoArray)
{ {
if (n->nType==type && n->mag<=10.) if (n->nType==type && qMin(n->vMag, n->bMag) <=10.)
{ {
if (!n->getEnglishName().isEmpty()) if (!n->getEnglishName().isEmpty())
{ {
if (inEnglish) if (inEnglish)
result << n->getEngl ishName(); result << n->getEngl ishName();
else else
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 if (n->IC_nb>0)
result << QString("IC %1").a rg(n->IC_nb); result << QString("IC %1").a rg(n->IC_nb);
else if (n->M_nb>0)
result << QString("M %1").ar
g(n->M_nb);
else if (n->C_nb>0)
result << QString("C %1").ar
g(n->C_nb);
} }
} }
break; break;
case 100: // Messier Catalogue? case 100: // Messier Catalogue?
foreach(const NebulaP& n, nebArray) foreach(const NebulaP& n, dsoArray)
{ {
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 101: // Caldwell Catalogue? case 101: // Caldwell Catalogue?
foreach(const NebulaP& n, nebArray) foreach(const NebulaP& n, dsoArray)
{ {
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? case 102: // Barnard Catalogue?
foreach(const NebulaP& n, nebArray) foreach(const NebulaP& n, dsoArray)
{ {
if (n->B_nb>0) if (n->B_nb>0)
result << QString("B %1").arg(n->B_n b); result << QString("B %1").arg(n->B_n b);
} }
break; break;
case 103: // Sharpless Catalogue? case 103: // Sharpless Catalogue?
foreach(const NebulaP& n, nebArray) foreach(const NebulaP& n, dsoArray)
{ {
if (n->Sh2_nb>0) if (n->Sh2_nb>0)
result << QString("Sh 2-%1").arg(n-> Sh2_nb); result << QString("Sh 2-%1").arg(n-> Sh2_nb);
} }
break; break;
case 104: // Van den Bergh Catalogue case 104: // Van den Bergh Catalogue
foreach(const NebulaP& n, nebArray) foreach(const NebulaP& n, dsoArray)
{ {
if (n->VdB_nb>0) if (n->VdB_nb>0)
result << QString("VdB %1").arg(n->V dB_nb); result << QString("VdB %1").arg(n->V dB_nb);
} }
break; break;
case 105: // RCW Catalogue case 105: // RCW Catalogue
foreach(const NebulaP& n, nebArray) foreach(const NebulaP& n, dsoArray)
{ {
if (n->RCW_nb>0) if (n->RCW_nb>0)
result << QString("RCW %1").arg(n->V dB_nb); result << QString("RCW %1").arg(n->R CW_nb);
} }
break; break;
case 106: // Collinder Catalogue case 106: // Collinder Catalogue
foreach(const NebulaP& n, nebArray) foreach(const NebulaP& n, dsoArray)
{ {
if (n->Cr_nb>0) if (n->Cr_nb>0)
result << QString("Cr %1").arg(n->Cr _nb); result << QString("Cr %1").arg(n->Cr _nb);
} }
break; break;
case 107: // Melotte Catalogue case 107: // Melotte Catalogue
foreach(const NebulaP& n, nebArray) foreach(const NebulaP& n, dsoArray)
{ {
if (n->Mel_nb>0) if (n->Mel_nb>0)
result << QString("Mel %1").arg(n->M el_nb); result << QString("Mel %1").arg(n->M el_nb);
} }
break; break;
default: default:
foreach(const NebulaP& n, nebArray) foreach(const NebulaP& n, dsoArray)
{ {
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
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 if (n->IC_nb>0)
result << QString("IC %1").a rg(n->IC_nb); result << QString("IC %1").a rg(n->IC_nb);
else if (n->M_nb>0)
result << QString("M %1").ar
g(n->M_nb);
else if (n->C_nb>0)
result << QString("C %1").ar
g(n->C_nb);
else if (n->B_nb>0)
result << QString("B %1").ar
g(n->B_nb);
else if (n->Sh2_nb>0)
result << QString("Sh 2-%1")
.arg(n->Sh2_nb);
else if (n->VdB_nb>0)
result << QString("VdB %1").
arg(n->VdB_nb);
else if (n->RCW_nb>0)
result << QString("RCW %1").
arg(n->RCW_nb);
else if (n->LBN_nb>0)
result << QString("LBN %1").
arg(n->LBN_nb);
else if (n->LDN_nb>0)
result << QString("LDN %1").
arg(n->LDN_nb);
else if (n->Cr_nb>0)
result << QString("Cr %1").a
rg(n->Cr_nb);
else if (n->Mel_nb>0)
result << QString("Mel %1").
arg(n->Mel_nb);
} }
} }
break; break;
} }
result.removeDuplicates(); result.removeDuplicates();
return result; return result;
} }
 End of changes. 181 change blocks. 
674 lines changed or deleted 1004 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/