NebulaMgr.cpp   NebulaMgr.cpp 
skipping to change at line 37 skipping to change at line 37
#include <QStringList> #include <QStringList>
#include <QRegExp> #include <QRegExp>
#include "StelApp.hpp" #include "StelApp.hpp"
#include "NebulaMgr.hpp" #include "NebulaMgr.hpp"
#include "Nebula.hpp" #include "Nebula.hpp"
#include "StelTexture.hpp" #include "StelTexture.hpp"
#include "StelNavigator.hpp" #include "StelNavigator.hpp"
#include "StelSkyDrawer.hpp" #include "StelSkyDrawer.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "StelLoadingBar.hpp"
#include "StelTextureMgr.hpp" #include "StelTextureMgr.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelSkyCultureMgr.hpp" #include "StelSkyCultureMgr.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelStyle.hpp"
#include "StelSkyImageTile.hpp" #include "StelSkyImageTile.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
void NebulaMgr::setLabelsColor(const Vec3f& c) {Nebula::labelColor = c;} void NebulaMgr::setLabelsColor(const Vec3f& c) {Nebula::labelColor = c;}
const Vec3f &NebulaMgr::getLabelsColor(void) const {return Nebula::labelCol or;} const Vec3f &NebulaMgr::getLabelsColor(void) const {return Nebula::labelCol or;}
void NebulaMgr::setCirclesColor(const Vec3f& c) {Nebula::circleColor = c;} void NebulaMgr::setCirclesColor(const Vec3f& c) {Nebula::circleColor = c;}
const Vec3f &NebulaMgr::getCirclesColor(void) const {return Nebula::circleC olor;} const Vec3f &NebulaMgr::getCirclesColor(void) const {return Nebula::circleC olor;}
void NebulaMgr::setCircleScale(float scale) {Nebula::circleScale = scale;} void NebulaMgr::setCircleScale(float scale) {Nebula::circleScale = scale;}
float NebulaMgr::getCircleScale(void) const {return Nebula::circleScale;} float NebulaMgr::getCircleScale(void) const {return Nebula::circleScale;}
skipping to change at line 92 skipping to change at line 90
// 2. load all // 2. load all
// 3. flag in nebula_textures.fab (yuk) // 3. flag in nebula_textures.fab (yuk)
// 4. info.ini file in each set containing a "load at startup" item // 4. info.ini file in each set containing a "load at startup" item
// For now (0.9.0), just load the default set // For now (0.9.0), just load the default set
loadNebulaSet("default"); loadNebulaSet("default");
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
Q_ASSERT(conf); Q_ASSERT(conf);
nebulaFont.setPixelSize(13); nebulaFont.setPixelSize(13);
Nebula::texCircle = StelApp::getInstance().getTextureManager().creat Nebula::texCircle = StelApp::getInstance().getTextureManager().creat
eTexture("neb.png"); // Load circle texture eTexture("textures/neb.png"); // Load circle texture
texPointer = StelApp::getInstance().getTextureManager().createTextur texPointer = StelApp::getInstance().getTextureManager().createTextur
e("pointeur5.png"); // Load pointer texture e("textures/pointeur5.png"); // Load pointer 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).toDouble( setHintsAmount(conf->value("astro/nebula_hints_amount", 3).toFloat()
)); );
setLabelsAmount(conf->value("astro/nebula_labels_amount", 3).toDoubl setLabelsAmount(conf->value("astro/nebula_labels_amount", 3).toFloat
e()); ());
setCircleScale(conf->value("astro/nebula_scale",1.0f).toDouble()); setCircleScale(conf->value("astro/nebula_scale",1.0f).toFloat());
setFlagDisplayNoTexture(conf->value("astro/flag_nebula_display_no_te xture", false).toBool()); setFlagDisplayNoTexture(conf->value("astro/flag_nebula_display_no_te xture", false).toBool());
updateI18n(); updateI18n();
GETSTELMODULE(StelObjectMgr)->registerStelObjectMgr(this); GETSTELMODULE(StelObjectMgr)->registerStelObjectMgr(this);
} }
struct DrawNebulaFuncObject struct DrawNebulaFuncObject
{ {
DrawNebulaFuncObject(float amaxMagHints, float amaxMagLabels, StelPa inter* p, bool acheckMaxMagHints) : maxMagHints(amaxMagHints), maxMagLabels (amaxMagLabels), sPainter(p), checkMaxMagHints(acheckMaxMagHints) DrawNebulaFuncObject(float amaxMagHints, float amaxMagLabels, StelPa inter* p, bool acheckMaxMagHints) : maxMagHints(amaxMagHints), maxMagLabels (amaxMagLabels), sPainter(p), checkMaxMagHints(acheckMaxMagHints)
{ {
angularSizeLimit = 5./sPainter->getProjector()->getPixelPerR adAtCenter()*180./M_PI; angularSizeLimit = 5.f/sPainter->getProjector()->getPixelPer RadAtCenter()*180.f/M_PI;
} }
void operator()(StelRegionObjectP obj) void operator()(StelRegionObjectP obj)
{ {
Nebula* n = obj.staticCast<Nebula>().data(); Nebula* n = obj.staticCast<Nebula>().data();
if (n->angularSize>angularSizeLimit || (checkMaxMagHints && n->mag <= maxMagHints)) if (n->angularSize>angularSizeLimit || (checkMaxMagHints && n->mag <= maxMagHints))
{ {
sPainter->getProjector()->project(n->XYZ,n->XY); sPainter->getProjector()->project(n->XYZ,n->XY);
n->drawLabel(*sPainter, maxMagLabels); n->drawLabel(*sPainter, maxMagLabels);
n->drawHints(*sPainter, maxMagHints); n->drawHints(*sPainter, maxMagHints);
} }
skipping to change at line 149 skipping to change at line 147
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 = skyDrawer->getLimitMagnitude()*1.2-2.+(hintsAmou float maxMagHints = skyDrawer->getLimitMagnitude()*1.2f-2.f+(hintsAm
nt*1.2f)-2.f; ount*1.2f)-2.f;
float maxMagLabels = skyDrawer->getLimitMagnitude()-2.+(labelsAmount float maxMagLabels = skyDrawer->getLimitMagnitude()-2.f+(labelsAmoun
*1.2f)-2.f; t*1.2f)-2.f;
sPainter.setFont(nebulaFont); sPainter.setFont(nebulaFont);
DrawNebulaFuncObject func(maxMagHints, maxMagLabels, &sPainter, hint sFader.getInterstate()>0.0001); DrawNebulaFuncObject func(maxMagHints, maxMagLabels, &sPainter, hint sFader.getInterstate()>0.0001);
nebGrid.processIntersectingRegions(p, func); nebGrid.processIntersectingRegions(p, 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 190 skipping to change at line 188
float size = obj->getAngularSize(core)*M_PI/180.*prj->getPix elPerRadAtCenter(); float size = obj->getAngularSize(core)*M_PI/180.*prj->getPix elPerRadAtCenter();
size+=20.f + 10.f*std::sin(2.f * StelApp::getInstance().getT otalRunTime()); size+=20.f + 10.f*std::sin(2.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::updateSkyCulture(const QString& skyCultureDir) void NebulaMgr::setStelStyle(const QString& section)
{;}
void NebulaMgr::setStelStyle(const StelStyle& style)
{ {
// Load colors from config file // Load colors from config file
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
QString section = style.confSectionName;
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()));
} }
// 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, 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
QRegExp catNumRx("^(M|NGC|IC)\\s*(\\d+)$"); static QRegExp catNumRx("^(M|NGC|IC)\\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);
} }
return NebulaP(); return NebulaP();
skipping to change at line 264 skipping to change at line 258
plusProche=n; plusProche=n;
} }
} }
if (anglePlusProche>0.999) if (anglePlusProche>0.999)
{ {
return plusProche; return plusProche;
} }
else return NebulaP(); else return NebulaP();
} }
// Return a stl vector containing the nebulas located inside the limFov cir QList<StelObjectP> NebulaMgr::searchAround(const Vec3d& av, double limitFov
cle around position v , const StelCore*) const
QList<StelObjectP> NebulaMgr::searchAround(const Vec3d& av, double limitFov
, const StelCore* core) 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, nebArray)
skipping to change at line 313 skipping to change at line 306
{ {
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();
} }
#if 0 #if 0
// read from stream // read from stream
bool NebulaMgr::loadNGCOld(const QString& catNGC) bool NebulaMgr::loadNGCOld(const QString& catNGC)
{ {
StelLoadingBar& lb = *StelApp::getInstance().getStelLoadingBar();
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;
while (!in.atEnd()) while (!in.atEnd())
{ {
in.readLine(); in.readLine();
++totalRecords; ++totalRecords;
skipping to change at line 342 skipping to change at line 334
while (!in.atEnd()) while (!in.atEnd())
{ {
record = QString::fromUtf8(in.readLine()); record = QString::fromUtf8(in.readLine());
++currentLineNumber; ++currentLineNumber;
// skip comments // skip comments
if (record.startsWith("//") || record.startsWith("#")) if (record.startsWith("//") || record.startsWith("#"))
continue; continue;
++currentRecordNumber; ++currentRecordNumber;
// Update the status bar every 200 record
if (!(currentRecordNumber%200) || (currentRecordNumber == to
talRecords))
{
lb.SetMessage(q_("Loading NGC catalog: %1/%2").arg(c
urrentRecordNumber).arg(totalRecords));
lb.Draw((float)currentRecordNumber/totalRecords);
}
// Create a new Nebula record // Create a new Nebula record
NebulaP e = NebulaP(new Nebula); NebulaP e = NebulaP(new Nebula);
if (!e->readNGC((char*)record.toLocal8Bit().data())) // read ing error if (!e->readNGC((char*)record.toLocal8Bit().data())) // read ing error
{ {
e.clear(); e.clear();
} }
else else
{ {
nebArray.append(e); nebArray.append(e);
nebGrid.insert(qSharedPointerCast<StelRegionObject>( e)); nebGrid.insert(qSharedPointerCast<StelRegionObject>( e));
skipping to change at line 372 skipping to change at line 357
} }
} }
in.close(); in.close();
qDebug() << "Loaded" << readOk << "/" << totalRecords << "NGC record s"; qDebug() << "Loaded" << readOk << "/" << totalRecords << "NGC record s";
return true; return true;
} }
#endif #endif
bool NebulaMgr::loadNGC(const QString& catNGC) bool NebulaMgr::loadNGC(const QString& catNGC)
{ {
StelLoadingBar& lb = *StelApp::getInstance().getStelLoadingBar();
QFile in(catNGC); QFile in(catNGC);
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_4_5);
lb.SetMessage(q_("Loading NGC catalog"));
lb.Draw(0);
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->readNGC(ins);
nebArray.append(e); nebArray.append(e);
nebGrid.insert(qSharedPointerCast<StelRegionObject>(e)); nebGrid.insert(qSharedPointerCast<StelRegionObject>(e));
 End of changes. 14 change blocks. 
39 lines changed or deleted 18 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/