NebulaMgr.cpp   NebulaMgr.cpp 
/* /*
* Stellarium * Stellarium
* Copyright (C) 2002 Fabien Chereau * Copyright (C) 2002 Fabien Chereau
* Copyright (C) 2011 Alexander Wolf
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 * as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version. * of the License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
skipping to change at line 34 skipping to change at line 35
#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 "StelTexture.hpp"
#include "StelNavigator.hpp"
#include "StelSkyDrawer.hpp" #include "StelSkyDrawer.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.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 "StelSkyImageTile.hpp" #include "StelSkyImageTile.hpp"
#include "StelPainter.hpp" #include "StelPainter.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), displayNoTexture(false) NebulaMgr::NebulaMgr(void) : nebGrid(200), displayNoTexture(false)
{ {
setObjectName("NebulaMgr"); setObjectName("NebulaMgr");
} }
NebulaMgr::~NebulaMgr() NebulaMgr::~NebulaMgr()
{ {
Nebula::texCircle = StelTextureSP(); Nebula::texCircle = StelTextureSP();
Nebula::texOpenCluster = StelTextureSP();
Nebula::texGlobularCluster = StelTextureSP();
Nebula::texPlanetNebula = StelTextureSP();
} }
/************************************************************************* /*************************************************************************
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 91 skipping to change at line 96
// 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 eTexture("textures/neb.png"); // Load circle texture 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 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());
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 *app = &StelApp::getInstance();
connect(app, SIGNAL(languageChanged()), this, SLOT(updateI18n()));
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 inter* p, bool acheckMaxMagHints) : maxMagHints(amaxMagHints), maxMagLabels (amaxMagLabels), sPainter(p), checkMaxMagHints(acheckMaxMagHints) DrawNebulaFuncObject(float amaxMagHints, float amaxMagLabels, StelPa inter* p, StelCore* aCore, bool acheckMaxMagHints) : maxMagHints(amaxMagHin ts), maxMagLabels(amaxMagLabels), sPainter(p), core(aCore), checkMaxMagHint s(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()(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))
{ {
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); n->drawLabel(*sPainter, maxMagLabels-refmag_add);
n->drawHints(*sPainter, maxMagHints); n->drawHints(*sPainter, maxMagHints -refmag_add);
} }
} }
float maxMagHints; float maxMagHints;
float maxMagLabels; float maxMagLabels;
StelPainter* sPainter; StelPainter* sPainter;
StelCore* core;
float angularSizeLimit; float angularSizeLimit;
bool checkMaxMagHints; bool checkMaxMagHints;
}; };
// 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 150 skipping to change at line 163
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.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); sPainter.setFont(nebulaFont);
DrawNebulaFuncObject func(maxMagHints, maxMagLabels, &sPainter, hint sFader.getInterstate()>0.0001); DrawNebulaFuncObject func(maxMagHints, maxMagLabels, &sPainter, core , hintsFader.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)
{ {
const StelNavigator* nav = core->getNavigator();
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(nav); Vec3d pos=obj->getJ2000EquatorialPos(core);
// Compute 2D pos and return if outside screen // Compute 2D pos and return if outside screen
if (!prj->projectInPlace(pos)) return; if (!prj->projectInPlace(pos)) return;
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
 End of changes. 13 change blocks. 
7 lines changed or deleted 25 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/