NebulaMgr.cpp   NebulaMgr.cpp 
skipping to change at line 131 skipping to change at line 131
, nebulaHintTextures(nebulaHintTextures) , nebulaHintTextures(nebulaHintTextures)
{ {
angularSizeLimit = 5.0f / projector->getPixelPerRadAtCenter( ) * 180.0f / M_PI; angularSizeLimit = 5.0f / projector->getPixelPerRadAtCenter( ) * 180.0f / M_PI;
} }
// Optimization: Smart pointer is intentionally not used. // Optimization: Smart pointer is intentionally not used.
// This is safe as long as we don't save it (the caller owns the poi nter). // This is safe as long as we don't save it (the caller owns the poi nter).
void operator()(StelRegionObject* obj) void operator()(StelRegionObject* obj)
{ {
Nebula* n = static_cast<Nebula*>(obj); Nebula* n = static_cast<Nebula*>(obj);
StelSkyDrawer *drawer = core->getSkyDrawer();
// 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 (n->angularSize>angularSizeLimit || (checkMaxMagHints && n->mag <= maxMagHints)) if (n->angularSize>angularSizeLimit || (checkMaxMagHints && n->mag <= maxMagHints))
{ {
float refmag_add=0; // value to adjust hints visibil ity threshold. float refmag_add=0; // value to adjust hints visibil ity threshold.
projector->project(n->XYZ,n->XY); projector->project(n->XYZ,n->XY);
n->drawLabel(renderer, projector, maxMagLabels-refma g_add); n->drawLabel(renderer, projector, maxMagLabels-refma g_add);
n->drawHints(renderer, maxMagHints -refmag_add, nebu laHintTextures); n->drawHints(renderer, maxMagHints -refmag_add, nebu laHintTextures);
} }
} }
float maxMagHints; float maxMagHints;
float maxMagLabels; float maxMagLabels;
skipping to change at line 163 skipping to change at line 167
StelSkyDrawer* skyDrawer = core->getSkyDrawer(); StelSkyDrawer* skyDrawer = core->getSkyDrawer();
Nebula::hintsBrightness = hintsFader.getInterstate()*flagShow.getInt erstate(); Nebula::hintsBrightness = hintsFader.getInterstate()*flagShow.getInt erstate();
// 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 = skyDrawer->getLimitMagnitude()*1.2f-2.f+(hintsAm float maxMagHints = skyDrawer->getLimitMagnitude()*1.2f-2.f+(hintsA
ount*1.2f)-2.f; mount *1.2f)-2.f;
float maxMagLabels = skyDrawer->getLimitMagnitude()-2.f+(labelsAmoun float maxMagLabels = skyDrawer->getLimitMagnitude() -2.f+(labels
t*1.2f)-2.f; Amount*1.2f)-2.f;
renderer->setFont(nebulaFont); renderer->setFont(nebulaFont);
nebulaHintTextures.lazyInit(renderer); nebulaHintTextures.lazyInit(renderer);
DrawNebulaFuncObject func(maxMagHints, maxMagLabels, prj, renderer, core, DrawNebulaFuncObject func(maxMagHints, maxMagLabels, prj, renderer, core,
hintsFader.getInterstate()>0.0001, nebulaH intTextures); hintsFader.getInterstate()>0.0001, nebulaH intTextures);
nebGrid.processIntersectingRegions(p, func); nebGrid.processIntersectingRegions(p, func);
if (GETSTELMODULE(StelObjectMgr)->getFlagSelectedObjectPointer()) if (GETSTELMODULE(StelObjectMgr)->getFlagSelectedObjectPointer())
{ {
drawPointer(core, renderer); drawPointer(core, renderer);
} }
} }
// Draw the pointer around the object if selected
void NebulaMgr::drawPointer(const StelCore* core, StelRenderer* renderer) void NebulaMgr::drawPointer(const StelCore* core, StelRenderer* renderer)
{ {
const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000) ; const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000) ;
const QList<StelObjectP> newSelected = GETSTELMODULE(StelObjectMgr)- >getSelectedObject("Nebula"); const QList<StelObjectP> newSelected = GETSTELMODULE(StelObjectMgr)- >getSelectedObject("Nebula");
if (!newSelected.empty()) if (!newSelected.empty())
{ {
const StelObjectP obj = newSelected[0]; const StelObjectP obj = newSelected[0];
Vec3d pos=obj->getJ2000EquatorialPos(core); Vec3d pos=obj->getJ2000EquatorialPos(core);
skipping to change at line 245 skipping to change at line 250
{ {
QString uname = name.toUpper(); QString uname = name.toUpper();
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, nebArray)
{ {
QString testName = n->getEnglishName().toUpper(); QString testName = n->getEnglishName().toUpper();
if (testName==uname) return n; if (testName==uname) return n;
} }
// If no match found, try search by catalog reference // If no match found, try search by catalog reference
static QRegExp catNumRx("^(M|NGC|IC)\\s*(\\d+)$"); static QRegExp catNumRx("^(M|NGC|IC|C)\\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);
} }
return NebulaP(); return NebulaP();
} }
void NebulaMgr::loadNebulaSet(const QString& setName) void NebulaMgr::loadNebulaSet(const QString& setName)
{ {
try try
{ {
loadNGC(StelFileMgr::findFile("nebulae/" + setName + "/ngc20 00.dat")); loadNGC(StelFileMgr::findFile("nebulae/" + setName + "/ngc20 00.dat"));
loadNGCNames(StelFileMgr::findFile("nebulae/" + setName + "/ ngc2000names.dat")); loadNGCNames(StelFileMgr::findFile("nebulae/" + setName + "/ ngc2000names.dat"));
skipping to change at line 337 skipping to change at line 343
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, nebArray)
if (n->IC_nb == IC) return n; if (n->IC_nb == IC) return n;
return NebulaP(); return NebulaP();
} }
NebulaP NebulaMgr::searchC(unsigned int C)
{
foreach (const NebulaP& n, nebArray)
if (n->C_nb == C)
return n;
return NebulaP();
}
#if 0 #if 0
// read from stream // read from stream
bool NebulaMgr::loadNGCOld(const QString& catNGC) bool NebulaMgr::loadNGCOld(const QString& catNGC)
{ {
QFile in(catNGC); QFile in(catNGC);
if (!in.open(QIODevice::ReadOnly | QIODevice::Text)) if (!in.open(QIODevice::ReadOnly | QIODevice::Text))
return false; return false;
int totalRecords=0; int totalRecords=0;
QString record; QString record;
skipping to change at line 460 skipping to change at line 474
e = searchNGC(nb); e = searchNGC(nb);
} }
// get name, trimmed of whitespace // get name, trimmed of whitespace
name = record.left(36).trimmed(); name = record.left(36).trimmed();
if (e) if (e)
{ {
// If the name is not a messier number perhaps one i s already // If the name is not a messier number perhaps one i s already
// defined for this object // defined for this object
if (name.left(2).toUpper() != "M ") if (name.left(2).toUpper() != "M " && name.left(2).t oUpper() != "C ")
{ {
if (transRx.exactMatch(name)) { if (transRx.exactMatch(name)) {
e->englishName = transRx.capturedTex ts().at(1).trimmed(); e->englishName = transRx.capturedTex ts().at(1).trimmed();
} }
else else
{ {
e->englishName = name; e->englishName = name;
} }
} }
else else if (name.left(2).toUpper() != "M " && name.left
(2).toUpper() == "C ")
{
// If it's a caldwellnumber, we will call it
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" << catNGCNames;
continue;
}
e->C_nb=(unsigned int)(num);
e->englishName = QString("C%1").arg(num);
}
else if (name.left(2).toUpper() == "M " && name.left
(2).toUpper() != "C ")
{ {
// If it's a messiernumber, we will call it a messier if there is no better name // If it's a messiernumber, we will call it a messier if there is no better name
name = name.mid(2); // remove "M " name = name.mid(2); // remove "M "
// read the Messier number // read the Messier number
QTextStream istr(&name); QTextStream istr(&name);
int num; int num;
istr >> num; istr >> num;
if (istr.status()!=QTextStream::Ok) if (istr.status()!=QTextStream::Ok)
{ {
skipping to change at line 540 skipping to change at line 572
// 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") if (objw.mid(0, 1) == "M")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, nebArray)
{ {
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")
if (objw.mid(0, 1) == "C")
{
foreach (const NebulaP& n, nebArray)
{
if (QString("C%1").arg(n->C_nb) == objw || QString("
C %1").arg(n->C_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
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")
skipping to change at line 577 skipping to change at line 619
// 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") if (objw.mid(0, 1) == "M")
{ {
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, nebArray)
{ {
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")
if (objw.mid(0, 1) == "C")
{
foreach (const NebulaP& n, nebArray)
{
if (QString("C%1").arg(n->C_nb) == objw || QString("
C %1").arg(n->C_nb) == objw)
return qSharedPointerCast<StelObject>(n);
}
}
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) const QStringList NebulaMgr::listMatchingObjectsI18n(const QString& objPrefix, in t maxNbItem) const
{ {
QStringList result; QStringList result;
if (maxNbItem==0) return result; if (maxNbItem==0) return result;
QString objw = objPrefix.toUpper(); QString objw = objPrefix.toUpper();
skipping to change at line 625 skipping to change at line 677
{ {
result << constw; result << constw;
continue; continue;
} }
constw = QString("NGC %1").arg(n->NGC_nb); constw = QString("NGC %1").arg(n->NGC_nb);
constws = constw.mid(0, objw.size()); constws = constw.mid(0, objw.size());
if (constws==objw) if (constws==objw)
result << constw; result << constw;
} }
// Search by caldwell objects number (possible formats are "C31" or
"C 31")
if (objw.size()>=1 && objw[0]=='C')
{
foreach (const NebulaP& n, nebArray)
{
if (n->C_nb==0) continue;
QString constw = QString("C%1").arg(n->C_nb);
QString constws = constw.mid(0, objw.size());
if (constws==objw)
{
result << constw;
continue; // Prevent adding both forms
for name
}
constw = QString("C %1").arg(n->C_nb);
constws = constw.mid(0, objw.size());
if (constws==objw)
result << constw;
}
}
// Search by common names // Search by common names
foreach (const NebulaP& n, nebArray) foreach (const NebulaP& n, nebArray)
{ {
QString constw = n->nameI18.mid(0, objw.size()).toUpper(); QString constw = n->nameI18.mid(0, objw.size()).toUpper();
if (constw==objw) if (constw==objw)
result << n->nameI18; result << n->nameI18;
} }
result.sort(); result.sort();
if (result.size()>maxNbItem) result.erase(result.begin()+maxNbItem, result.end()); if (result.size()>maxNbItem) result.erase(result.begin()+maxNbItem, result.end());
return result; return result;
} }
//! 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) const
{
QStringList result;
if (maxNbItem==0) return result;
QString objw = objPrefix.toUpper();
// Search by messier objects number (possible formats are "M31" or "
M 31")
if (objw.size()>=1 && objw[0]=='M')
{
foreach (const NebulaP& n, nebArray)
{
if (n->M_nb==0) continue;
QString constw = QString("M%1").arg(n->M_nb);
QString constws = constw.mid(0, objw.size());
if (constws==objw)
{
result << constw;
continue; // Prevent adding both forms
for name
}
constw = QString("M %1").arg(n->M_nb);
constws = constw.mid(0, objw.size());
if (constws==objw)
result << constw;
}
}
// Search by NGC numbers (possible formats are "NGC31" or "NGC 31")
foreach (const NebulaP& n, nebArray)
{
if (n->NGC_nb==0) continue;
QString constw = QString("NGC%1").arg(n->NGC_nb);
QString constws = constw.mid(0, objw.size());
if (constws==objw)
{
result << constw;
continue;
}
constw = QString("NGC %1").arg(n->NGC_nb);
constws = constw.mid(0, objw.size());
if (constws==objw)
result << constw;
}
// Search by caldwell objects number (possible formats are "C31" or
"C 31")
if (objw.size()>=1 && objw[0]=='C')
{
foreach (const NebulaP& n, nebArray)
{
if (n->C_nb==0) continue;
QString constw = QString("C%1").arg(n->C_nb);
QString constws = constw.mid(0, objw.size());
if (constws==objw)
{
result << constw;
continue; // Prevent adding both forms
for name
}
constw = QString("C %1").arg(n->C_nb);
constws = constw.mid(0, objw.size());
if (constws==objw)
result << constw;
}
}
// Search by common names
foreach (const NebulaP& n, nebArray)
{
QString constw = n->englishName.mid(0, objw.size()).toUpper(
);
if (constw==objw)
result << n->englishName;
}
result.sort();
if (result.size()>maxNbItem) result.erase(result.begin()+maxNbItem,
result.end());
return result;
}
 End of changes. 12 change blocks. 
7 lines changed or deleted 89 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/