NebulaMgr.cpp   NebulaMgr.cpp 
skipping to change at line 34 skipping to change at line 34
#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 "StelTexture.hpp" #include "renderer/StelRenderer.hpp"
#include "StelSkyDrawer.hpp" #include "StelSkyDrawer.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.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 "StelSkyImageTile.hpp" #include "StelSkyImageTile.hpp"
#include "StelPainter.hpp"
#include "RefractionExtinction.hpp" #include "RefractionExtinction.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;}
NebulaMgr::NebulaMgr(void) : nebGrid(200) NebulaMgr::NebulaMgr(void) : nebGrid(200), texPointer(NULL)
{ {
setObjectName("NebulaMgr"); setObjectName("NebulaMgr");
} }
NebulaMgr::~NebulaMgr() NebulaMgr::~NebulaMgr()
{ {
Nebula::texCircle = StelTextureSP(); if(NULL != texPointer)
Nebula::texOpenCluster = StelTextureSP(); {
Nebula::texGlobularCluster = StelTextureSP(); delete texPointer;
Nebula::texPlanetNebula = StelTextureSP(); texPointer = NULL;
}
} }
/************************************************************************* /*************************************************************************
Reimplementation of the getCallOrder method Reimplementation of the getCallOrder method
*************************************************************************/ *************************************************************************/
double NebulaMgr::getCallOrder(StelModuleActionName actionName) const double NebulaMgr::getCallOrder(StelModuleActionName actionName) const
{ {
if (actionName==StelModule::ActionDraw) if (actionName==StelModule::ActionDraw)
return StelApp::getInstance().getModuleMgr().getModule("Milk yWay")->getCallOrder(actionName)+10; return StelApp::getInstance().getModuleMgr().getModule("Milk yWay")->getCallOrder(actionName)+10;
return 0; return 0;
skipping to change at line 95 skipping to change at line 94
// 2. load all // 2. load all
// 3. flag in nebula_textures.fab (yuk) // 3. flag in nebula_textures.fab (yuk)
// 4. info.ini file in each set containing a "load at startup" item // 4. info.ini file in each set containing a "load at startup" item
// For now (0.9.0), just load the default set // For now (0.9.0), just load the default set
loadNebulaSet("default"); loadNebulaSet("default");
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
Q_ASSERT(conf); Q_ASSERT(conf);
nebulaFont.setPixelSize(StelApp::getInstance().getSettings()->value( "gui/base_font_size", 13).toInt()); nebulaFont.setPixelSize(StelApp::getInstance().getSettings()->value( "gui/base_font_size", 13).toInt());
Nebula::texCircle = StelApp::getInstance().getTextureManager().creat
eTexture("textures/neb.png"); // Load circle texture
Nebula::texOpenCluster = StelApp::getInstance().getTextureManager().
createTexture("textures/ocl.png"); // Load open clister marker texture
Nebula::texGlobularCluster = StelApp::getInstance().getTextureManage
r().createTexture("textures/gcl.png"); // Load globular clister marker te
xture
Nebula::texPlanetNebula = StelApp::getInstance().getTextureManager()
.createTexture("textures/pnb.png"); // Load planetary nebula marker textu
re
texPointer = StelApp::getInstance().getTextureManager().createTextur
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).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());
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);
} }
struct DrawNebulaFuncObject struct DrawNebulaFuncObject
{ {
DrawNebulaFuncObject(float amaxMagHints, float amaxMagLabels, StelPa DrawNebulaFuncObject
inter* p, StelCore* aCore, bool acheckMaxMagHints) : maxMagHints(amaxMagHin (float amaxMagHints, float amaxMagLabels, StelProjectorP pro
ts), maxMagLabels(amaxMagLabels), sPainter(p), core(aCore), checkMaxMagHint jector,
s(acheckMaxMagHints) StelRenderer* renderer, StelCore* aCore, bool acheckMaxMagH
ints,
Nebula::NebulaHintTextures& nebulaHintTextures)
: maxMagHints(amaxMagHints)
, maxMagLabels(amaxMagLabels)
, projector(projector)
, renderer(renderer)
, core(aCore)
, checkMaxMagHints(acheckMaxMagHints)
, nebulaHintTextures(nebulaHintTextures)
{ {
angularSizeLimit = 5.f/sPainter->getProjector()->getPixelPer RadAtCenter()*180.f/M_PI; angularSizeLimit = 5.0f / projector->getPixelPerRadAtCenter( ) * 180.0f / M_PI;
} }
void operator()(StelRegionObjectP obj)
// Optimization: Smart pointer is intentionally not used.
// This is safe as long as we don't save it (the caller owns the poi
nter).
void operator()(StelRegionObject* obj)
{ {
Nebula* n = obj.staticCast<Nebula>().data(); Nebula* n = static_cast<Nebula*>(obj);
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.
sPainter->getProjector()->project(n->XYZ,n->XY); projector->project(n->XYZ,n->XY);
n->drawLabel(*sPainter, maxMagLabels-refmag_add); n->drawLabel(renderer, projector, maxMagLabels-refma
n->drawHints(*sPainter, maxMagHints -refmag_add); g_add);
n->drawHints(renderer, maxMagHints -refmag_add, nebu
laHintTextures);
} }
} }
float maxMagHints; float maxMagHints;
float maxMagLabels; float maxMagLabels;
StelPainter* sPainter; StelProjectorP projector;
StelRenderer* renderer;
StelCore* core; StelCore* core;
float angularSizeLimit; float angularSizeLimit;
bool checkMaxMagHints; bool checkMaxMagHints;
Nebula::NebulaHintTextures& nebulaHintTextures;
}; };
// Draw all the Nebulae // Draw all the Nebulae
void NebulaMgr::draw(StelCore* core) void NebulaMgr::draw(StelCore* core, StelRenderer* renderer)
{ {
const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000) ; const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000) ;
StelPainter sPainter(prj);
StelSkyDrawer* skyDrawer = core->getSkyDrawer(); StelSkyDrawer* skyDrawer = core->getSkyDrawer();
Nebula::hintsBrightness = hintsFader.getInterstate()*flagShow.getInt erstate(); Nebula::hintsBrightness = hintsFader.getInterstate()*flagShow.getInt erstate();
sPainter.enableTexture2d(true);
glEnable(GL_BLEND);
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.2f-2.f+(hintsAm ount*1.2f)-2.f; float maxMagHints = skyDrawer->getLimitMagnitude()*1.2f-2.f+(hintsAm ount*1.2f)-2.f;
float maxMagLabels = skyDrawer->getLimitMagnitude()-2.f+(labelsAmoun t*1.2f)-2.f; float maxMagLabels = skyDrawer->getLimitMagnitude()-2.f+(labelsAmoun t*1.2f)-2.f;
sPainter.setFont(nebulaFont);
DrawNebulaFuncObject func(maxMagHints, maxMagLabels, &sPainter, core renderer->setFont(nebulaFont);
, hintsFader.getInterstate()>0.0001); nebulaHintTextures.lazyInit(renderer);
DrawNebulaFuncObject func(maxMagHints, maxMagLabels, prj, renderer,
core,
hintsFader.getInterstate()>0.0001, nebulaH
intTextures);
nebGrid.processIntersectingRegions(p, func); nebGrid.processIntersectingRegions(p, func);
if (GETSTELMODULE(StelObjectMgr)->getFlagSelectedObjectPointer()) if (GETSTELMODULE(StelObjectMgr)->getFlagSelectedObjectPointer())
drawPointer(core, sPainter); {
drawPointer(core, renderer);
}
} }
void NebulaMgr::drawPointer(const StelCore* core, StelPainter& sPainter) 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);
// Compute 2D pos and return if outside screen // Compute 2D pos and don't draw if outside screen
if (!prj->projectInPlace(pos)) return; if (!prj->projectInPlace(pos)) return;
if (StelApp::getInstance().getVisionModeNight())
sPainter.setColor(0.8f,0.0f,0.0f);
else
sPainter.setColor(0.4f,0.5f,0.8f);
const Vec4f color = StelApp::getInstance().getVisionModeNigh
t()
? Vec4f(0.8f,0.0f,0.0f,1.0f) : Vec4f(0.4f,
0.5f,0.8f,1.0f);
renderer->setGlobalColor(color);
if(NULL == texPointer)
{
texPointer = renderer->createTexture("textures/point
eur5.png"); // Load pointer texture
}
texPointer->bind(); texPointer->bind();
sPainter.enableTexture2d(true); renderer->setBlendMode(BlendMode_Alpha);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal
transparency mode
// Size on screen // Size of the whole pointer on screen
float size = obj->getAngularSize(core)*M_PI/180.*prj->getPix elPerRadAtCenter(); float size = obj->getAngularSize(core)*M_PI/180.*prj->getPix elPerRadAtCenter();
size+=20.f + 10.f*std::sin(2.f * StelApp::getInstance().getT 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); const float halfSize = size * 0.5;
sPainter.drawSprite2dMode(pos[0]-size/2, pos[1]+size/2, 10,
0); const float xLeft = pos[0] - halfSize - 10;
sPainter.drawSprite2dMode(pos[0]+size/2, pos[1]+size/2, 10, const float xRight = pos[0] + halfSize - 10;
-90); const float yTop = pos[1] - halfSize - 10;
sPainter.drawSprite2dMode(pos[0]+size/2, pos[1]-size/2, 10, const float yBottom = pos[1] + halfSize - 10;
-180);
// Every part of the pointer has size 20.
renderer->drawTexturedRect(xLeft, yTop, 20, 20, 90);
renderer->drawTexturedRect(xLeft, yBottom, 20, 20, 0);
renderer->drawTexturedRect(xRight, yBottom, 20, 20, -90);
renderer->drawTexturedRect(xRight, yTop, 20, 20, -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()));
 End of changes. 25 change blocks. 
60 lines changed or deleted 74 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/