NebulaMgr.cpp   NebulaMgr.cpp 
skipping to change at line 33 skipping to change at line 33
#include <QDebug> #include <QDebug>
#include <QFile> #include <QFile>
#include <QSettings> #include <QSettings>
#include <QString> #include <QString>
#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 "STexture.hpp" #include "StelTexture.hpp"
#include "Navigator.hpp" #include "StelNavigator.hpp"
#include "SkyDrawer.hpp" #include "StelSkyDrawer.hpp"
#include "Translator.hpp" #include "StelTranslator.hpp"
#include "LoadingBar.hpp" #include "StelLoadingBar.hpp"
#include "StelTextureMgr.hpp" #include "StelTextureMgr.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelFontMgr.hpp" #include "StelFontMgr.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 "StelStyle.hpp"
#include "SkyImageTile.hpp" #include "StelSkyImageTile.hpp"
#include "StelPainter.hpp"
using namespace std; using namespace std;
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;}
NebulaMgr::NebulaMgr(void) : nebGrid(200), displayNoTexture(false) NebulaMgr::NebulaMgr(void) : nebGrid(200), displayNoTexture(false)
{ {
setObjectName("NebulaMgr"); setObjectName("NebulaMgr");
} }
NebulaMgr::~NebulaMgr() NebulaMgr::~NebulaMgr()
{ {
Nebula::texCircle = STextureSP(); Nebula::texCircle = StelTextureSP();
vector<Nebula *>::iterator iter; vector<Nebula *>::iterator iter;
for(iter=nebArray.begin();iter!=nebArray.end();iter++) for(iter=nebArray.begin();iter!=nebArray.end();iter++)
{ {
delete (*iter); delete (*iter);
} }
} }
/************************************************************************* /*************************************************************************
Reimplementation of the getCallOrder method Reimplementation of the getCallOrder method
skipping to change at line 97 skipping to change at line 98
// TODO: mechanism to specify which sets get loaded at start time. // TODO: mechanism to specify which sets get loaded at start time.
// candidate methods: // candidate methods:
// 1. config file option (list of sets to load at startup) // 1. config file option (list of sets to load at startup)
// 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();
assert(conf); Q_ASSERT(conf);
double fontSize = 12; double fontSize = 12;
Nebula::nebulaFont = &StelApp::getInstance().getFontManager().getSta ndardFont(StelApp::getInstance().getLocaleMgr().getSkyLanguage(), fontSize) ; Nebula::nebulaFont = &StelApp::getInstance().getFontManager().getSta ndardFont(StelApp::getInstance().getLocaleMgr().getSkyLanguage(), fontSize) ;
StelApp::getInstance().getTextureManager().setDefaultParams(); StelApp::getInstance().getTextureManager().setDefaultParams();
StelApp::getInstance().getTextureManager().setMinFilter(GL_LINEAR);
Nebula::texCircle = StelApp::getInstance().getTextureManager().creat eTexture("neb.png"); // Load circle texture Nebula::texCircle = StelApp::getInstance().getTextureManager().creat eTexture("neb.png"); // Load circle texture
texPointer = StelApp::getInstance().getTextureManager().createTextur e("pointeur5.png"); // Load pointer texture texPointer = StelApp::getInstance().getTextureManager().createTextur e("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).toDouble( ));
setLabelsAmount(conf->value("astro/nebula_labels_amount", 3).toDoubl e()); setLabelsAmount(conf->value("astro/nebula_labels_amount", 3).toDoubl e());
setCircleScale(conf->value("astro/nebula_scale",1.0f).toDouble()); setCircleScale(conf->value("astro/nebula_scale",1.0f).toDouble());
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();
StelApp::getInstance().getStelObjectMgr().registerStelObjectMgr(this ); StelApp::getInstance().getStelObjectMgr().registerStelObjectMgr(this );
} }
// Draw all the Nebulae // Draw all the Nebulae
void NebulaMgr::draw(StelCore* core) void NebulaMgr::draw(StelCore* core)
{ {
Projector* prj = core->getProjection(); const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000)
SkyDrawer* skyDrawer = core->getSkyDrawer(); ;
StelPainter sPainter(prj);
StelSkyDrawer* skyDrawer = core->getSkyDrawer();
Nebula::hintsBrightness = hintsFader.getInterstate()*flagShow.getInt erstate(); Nebula::hintsBrightness = hintsFader.getInterstate()*flagShow.getInt erstate();
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE); glBlendFunc(GL_ONE, GL_ONE);
Vec3f pXYZ; Vec3f pXYZ;
prj->setCurrentFrame(Projector::FrameJ2000);
// 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 StelGeom::ConvexPolygon& p = prj->getViewportConvexPolygon(mar gin, margin); const StelGeom::ConvexPolygon& p = prj->getViewportConvexPolygon(mar gin, margin);
nebGrid.filterIntersect(p); nebGrid.filterIntersect(p);
// Print all the nebulae of all the selected zones // Print all the nebulae of all the selected zones
Nebula* n; Nebula* n;
// speed up the computation of n->getOnScreenSize(core)>5: // speed up the computation of n->getOnScreenSize(core)>5:
const float size_limit = 5./prj->getPixelPerRadAtCenter()*180./M_PI; const float size_limit = 5./prj->getPixelPerRadAtCenter()*180./M_PI;
float maxMagHints = skyDrawer->getLimitMagnitude()*1.2-2.+(hintsAmou nt*1.2f)-2.f; float maxMagHints = skyDrawer->getLimitMagnitude()*1.2-2.+(hintsAmou nt*1.2f)-2.f;
float maxMagLabels = skyDrawer->getLimitMagnitude()-2.+(labelsAmount *1.2f)-2.f; float maxMagLabels = skyDrawer->getLimitMagnitude()-2.+(labelsAmount *1.2f)-2.f;
for (TreeGrid::const_iterator iter = nebGrid.begin(); iter != nebGri d.end(); ++iter) for (StelTreeGrid::const_iterator iter = nebGrid.begin(); iter != ne bGrid.end(); ++iter)
{ {
n = static_cast<Nebula*>(*iter); n = static_cast<Nebula*>(*iter);
// improve performance by skipping if too small to see // improve performance by skipping if too small to see
if (n->angularSize>size_limit || (hintsFader.getInterstate() >0.0001 && n->mag <= maxMagHints)) if (n->angularSize>size_limit || (hintsFader.getInterstate() >0.0001 && n->mag <= maxMagHints))
{ {
prj->project(n->XYZ,n->XY); prj->project(n->XYZ,n->XY);
n->drawLabel(core, maxMagLabels); n->drawLabel(core, sPainter, maxMagLabels);
n->drawHints(core, maxMagHints); n->drawHints(sPainter, maxMagHints);
} }
} }
drawPointer(core); drawPointer(core, sPainter);
//nebGrid.draw(prj, p); //nebGrid.draw(prj, p);
} }
void NebulaMgr::drawPointer(const StelCore* core) void NebulaMgr::drawPointer(const StelCore* core, const StelPainter& sPaint er)
{ {
const Navigator* nav = core->getNavigation(); const StelNavigator* nav = core->getNavigator();
const Projector* prj = core->getProjection(); const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000)
;
const QList<StelObjectP> newSelected = StelApp::getInstance().getSte lObjectMgr().getSelectedObject("Nebula"); const QList<StelObjectP> newSelected = StelApp::getInstance().getSte lObjectMgr().getSelectedObject("Nebula");
if (!newSelected.empty()) if (!newSelected.empty())
{ {
const StelObjectP obj = newSelected[0]; const StelObjectP obj = newSelected[0];
Vec3d pos=obj->getObsJ2000Pos(nav); Vec3d pos=obj->getJ2000EquatorialPos(nav);
Vec3d screenpos; Vec3d screenpos;
// Compute 2D pos and return if outside screen // Compute 2D pos and return if outside screen
if (!prj->project(pos, screenpos)) return; if (!prj->project(pos, screenpos)) return;
glColor3f(0.4f,0.5f,0.8f); glColor3f(0.4f,0.5f,0.8f);
texPointer->bind(); texPointer->bind();
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transp arency mode glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal transp arency mode
float size = obj->getOnScreenSize(core); // Size on screen
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());
prj->drawSprite2dMode(screenpos[0]-size/2, screenpos[1]-size sPainter.drawSprite2dMode(screenpos[0]-size/2, screenpos[1]-
/2, 20, 90); size/2, 20, 90);
prj->drawSprite2dMode(screenpos[0]-size/2, screenpos[1]+size sPainter.drawSprite2dMode(screenpos[0]-size/2, screenpos[1]+
/2, 20, 0); size/2, 20, 0);
prj->drawSprite2dMode(screenpos[0]+size/2, screenpos[1]+size sPainter.drawSprite2dMode(screenpos[0]+size/2, screenpos[1]+
/2, 20, -90); size/2, 20, -90);
prj->drawSprite2dMode(screenpos[0]+size/2, screenpos[1]-size sPainter.drawSprite2dMode(screenpos[0]+size/2, screenpos[1]-
/2, 20, -180); size/2, 20, -180);
} }
} }
void NebulaMgr::updateSkyCulture() void NebulaMgr::updateSkyCulture()
{;} {;}
void NebulaMgr::setStelStyle(const StelStyle& style) 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();
skipping to change at line 279 skipping to change at line 283
// Return a stl vector containing the nebulas located inside the limFov cir cle around position v // Return a stl vector containing the nebulas located inside the limFov cir cle around position v
QList<StelObjectP> NebulaMgr::searchAround(const Vec3d& av, double limitFov , const StelCore* core) 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.);
static Vec3d equPos; Vec3d equPos;
vector<Nebula*>::const_iterator iter = nebArray.begin(); vector<Nebula*>::const_iterator iter = nebArray.begin();
while (iter != nebArray.end()) while (iter != nebArray.end())
{ {
equPos = (*iter)->XYZ; equPos = (*iter)->XYZ;
equPos.normalize(); equPos.normalize();
if (equPos[0]*v[0] + equPos[1]*v[1] + equPos[2]*v[2]>=cosLim Fov) if (equPos[0]*v[0] + equPos[1]*v[1] + equPos[2]*v[2]>=cosLim Fov)
{ {
// NOTE: non-labeled nebulas are not returned! // NOTE: non-labeled nebulas are not returned!
skipping to change at line 335 skipping to change at line 339
{ {
if ((*iter)->IC_nb == IC) return (*iter); if ((*iter)->IC_nb == IC) return (*iter);
} }
return NULL; return NULL;
} }
// read from stream // read from stream
bool NebulaMgr::loadNGC(const QString& catNGC) bool NebulaMgr::loadNGC(const QString& catNGC)
{ {
LoadingBar& lb = *StelApp::getInstance().getLoadingBar(); 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;
QRegExp commentRx("^(\\s*#.*|\\s*)$"); QRegExp commentRx("^(\\s*#.*|\\s*)$");
while (!in.atEnd()) while (!in.atEnd())
{ {
record = QString::fromUtf8(in.readLine()); record = QString::fromUtf8(in.readLine());
skipping to change at line 472 skipping to change at line 476
qWarning() << "no position data for " << name << "at line" << lineNumber << "of" << catNGCNames; qWarning() << "no position data for " << name << "at line" << lineNumber << "of" << catNGCNames;
} }
ngcNameFile.close(); ngcNameFile.close();
qDebug() << "Loaded" << readOk << "/" << totalRecords << "NGC name r ecords successfully"; qDebug() << "Loaded" << readOk << "/" << totalRecords << "NGC name r ecords successfully";
return true; return true;
} }
void NebulaMgr::updateI18n() void NebulaMgr::updateI18n()
{ {
Translator trans = StelApp::getInstance().getLocaleMgr().getSkyTrans lator(); StelTranslator trans = StelApp::getInstance().getLocaleMgr().getSkyT ranslator();
vector<Nebula*>::iterator iter; vector<Nebula*>::iterator iter;
for( iter = nebArray.begin(); iter < nebArray.end(); iter++ ) for( iter = nebArray.begin(); iter < nebArray.end(); iter++ )
{ {
(*iter)->translateName(trans); (*iter)->translateName(trans);
} }
double fontSize = 12; double fontSize = 12;
Nebula::nebulaFont = &StelApp::getInstance().getFontManager().getSta ndardFont(trans.getTrueLocaleName(), fontSize); Nebula::nebulaFont = &StelApp::getInstance().getFontManager().getSta ndardFont(trans.getTrueLocaleName(), fontSize);
} }
//! Return the matching Nebula object's pointer if exists or NULL //! Return the matching Nebula object's pointer if exists or NULL
 End of changes. 18 change blocks. 
31 lines changed or deleted 38 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/