Nebula.cpp   Nebula.cpp 
skipping to change at line 23 skipping to change at line 23
* 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.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "Nebula.hpp" #include "Nebula.hpp"
#include "NebulaMgr.hpp" #include "NebulaMgr.hpp"
#include "StelTexture.hpp"
#include "renderer/StelRenderer.hpp" #include "StelUtils.hpp"
#include "renderer/StelTextureNew.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelTextureMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelUtils.hpp" #include "StelCore.hpp"
#include "StelPainter.hpp"
#include <QBuffer> #include <QTextStream>
#include <QDebug>
#include <QFile> #include <QFile>
#include <QString> #include <QString>
#include <QTextStream>
#include <QDebug>
#include <QBuffer>
StelTextureSP Nebula::texCircle;
StelTextureSP Nebula::texGalaxy;
StelTextureSP Nebula::texOpenCluster;
StelTextureSP Nebula::texGlobularCluster;
StelTextureSP Nebula::texPlanetaryNebula;
StelTextureSP Nebula::texDiffuseNebula;
StelTextureSP Nebula::texOpenClusterWithNebulosity;
float Nebula::circleScale = 1.f; float Nebula::circleScale = 1.f;
float Nebula::hintsBrightness = 0; float Nebula::hintsBrightness = 0;
Vec3f Nebula::labelColor = Vec3f(0.4,0.3,0.5); Vec3f Nebula::labelColor = Vec3f(0.4,0.3,0.5);
Vec3f Nebula::circleColor = Vec3f(0.8,0.8,0.1); Vec3f Nebula::circleColor = Vec3f(0.8,0.8,0.1);
Nebula::NebulaHintTextures::~NebulaHintTextures() Nebula::Nebula()
{ : M_nb(0)
if(!initialized){return;} , NGC_nb(0)
, IC_nb(0)
delete texCircle; , C_nb(0)
delete texGalaxy; , mag(99.)
delete texOpenCluster; , nType()
delete texGlobularCluster;
delete texPlanetaryNebula;
delete texDiffuseNebula;
delete texOpenClusterWithNebulosity;
initialized = false;
}
void Nebula::NebulaHintTextures::lazyInit(StelRenderer* renderer)
{
if(initialized){return;}
texCircle = renderer->createTexture("textures/neb.png");
// Load circle texture
texGalaxy = renderer->createTexture("textures/neb_gal.png")
; // Load ellipse texture
texOpenCluster = renderer->createTexture("textures/neb_ocl.png")
; // Load open cluster marker texture
texGlobularCluster = renderer->createTexture("textures/neb_gcl.png")
; // Load globular cluster marker texture
texPlanetaryNebula = renderer->createTexture("textures/neb_pnb.png")
; // Load planetary nebula marker texture
texDiffuseNebula = renderer->createTexture("textures/neb_dif.png")
; // Load diffuse nebula marker texture
texOpenClusterWithNebulosity = renderer->createTexture("textures/neb
_ocln.png"); // Load Ocl/Nebula marker texture
initialized = true;
}
Nebula::Nebula() :
M_nb(0),
NGC_nb(0),
IC_nb(0),
C_nb(0)
{ {
nameI18 = ""; nameI18 = "";
angularSize = -1; angularSize = -1;
} }
Nebula::~Nebula() Nebula::~Nebula()
{ {
} }
QString Nebula::getInfoString(const StelCore *core, const InfoStringGroup& flags) const QString Nebula::getInfoString(const StelCore *core, const InfoStringGroup& flags) const
skipping to change at line 122 skipping to change at line 103
catIds << QString("C %1").arg(C_nb); catIds << QString("C %1").arg(C_nb);
oss << catIds.join(" - "); oss << catIds.join(" - ");
if (nameI18!="" && flags&Name) if (nameI18!="" && flags&Name)
oss << ")"; oss << ")";
} }
if ((flags&Name) || (flags&CatalogNumber)) if ((flags&Name) || (flags&CatalogNumber))
oss << "</h2>"; oss << "</h2>";
if (flags&Extra1) if (flags&ObjectType)
oss << q_("Type: <b>%1</b>").arg(getTypeString()) << "<br>"; oss << q_("Type: <b>%1</b>").arg(getTypeString()) << "<br>";
if (mag < 50 && flags&Magnitude) if (mag < 50 && flags&Magnitude)
{ {
if (core->getSkyDrawer()->getFlagHasAtmosphere()) if (core->getSkyDrawer()->getFlagHasAtmosphere())
oss << q_("Magnitude: <b>%1</b> (extincted to: <b>%2</b>)"). oss << q_("Magnitude: <b>%1</b> (extincted to: <b>%2
arg(QString::number(getVMagnitude(core, false), 'f', 2), </b>)").arg(QString::number(getVMagnitude(core), 'f', 2),
QString::number(getVMagnitude(core, true), 'f', 2)) << "<br>"; QString::number(getVMagnitudeWithExtinction(core), 'f', 2)) <<
else "<br>";
oss << q_("Magnitude: <b>%1</b>").arg(getVMagnitude(core, fa else
lse), 0, 'f', 2) << "<br>"; oss << q_("Magnitude: <b>%1</b>").arg(getVMagnitude(
core), 0, 'f', 2) << "<br>";
}
if (mag < 50 && flags&Extra)
{
if (core->getSkyDrawer()->getFlagHasAtmosphere())
{
if (getSurfaceBrightness(core)<99 && getSurfaceBrigh
tnessWithExtinction(core)<99)
oss << q_("Surface brightness: <b>%1</b> (ex
tincted to: <b>%2</b>)").arg(QString::number(getSurfaceBrightness(core), 'f
', 2),
QString::number(getSurfaceBrightnessWithExtinc
tion(core), 'f', 2)) << "<br>";
}
else
{
if (getSurfaceBrightness(core)<99)
oss << q_("Surface brightness: <b>%1</b>").a
rg(QString::number(getSurfaceBrightness(core), 'f', 2)) << "<br>";
}
} }
oss << getPositionInfoString(core, flags); oss << getPositionInfoString(core, flags);
if (angularSize>0 && flags&Size) if (angularSize>0 && flags&Size)
oss << q_("Size: %1").arg(StelUtils::radToDmsStr(angularSize *M_PI/180.)) << "<br>"; oss << q_("Size: %1").arg(StelUtils::radToDmsStr(angularSize *M_PI/180.)) << "<br>";
postProcessInfoString(str, flags); postProcessInfoString(str, flags);
return str; return str;
} }
float Nebula::getVMagnitude(const StelCore* core, bool withExtinction) cons t float Nebula::getVMagnitude(const StelCore* core) const
{ {
float extinctionMag=0.0; // track magnitude loss Q_UNUSED(core);
if (withExtinction && core->getSkyDrawer()->getFlagHasAtmosphere()) return mag;
{
Vec3d altAz=getAltAzPosApparent(core);
altAz.normalize();
core->getSkyDrawer()->getExtinction().forward(&altAz[2], &extinction
Mag);
}
return mag+extinctionMag;
} }
float Nebula::getSelectPriority(const StelCore* core) const float Nebula::getSelectPriority(const StelCore* core) const
{ {
if( ((NebulaMgr*)StelApp::getInstance().getModuleMgr().getModule("Ne const NebulaMgr* nebMgr = ((NebulaMgr*)StelApp::getInstance().getMod
bulaMgr"))->getFlagHints() ) uleMgr().getModule("NebulaMgr"));
{ if (!nebMgr->getFlagHints())
// make very easy to select IF LABELED return StelObject::getSelectPriority(core)-2.f;
const float maxMagHint = nebMgr->computeMaxMagHint(core->getSkyDrawe
r());
// make very easy to select if labeled
if (std::min(15.f, getVMagnitude(core))<maxMagHint)
return -10.f; return -10.f;
}
else else
{ return StelObject::getSelectPriority(core)-2.f;
if (getVMagnitude(core, false)>20.f) return 20.f;
return getVMagnitude(core, false);
}
} }
Vec3f Nebula::getInfoColor(void) const Vec3f Nebula::getInfoColor(void) const
{ {
Vec3f col = ((NebulaMgr*)StelApp::getInstance().getModuleMgr().getMo return ((NebulaMgr*)StelApp::getInstance().getModuleMgr().getModule(
dule("NebulaMgr"))->getLabelsColor(); "NebulaMgr"))->getLabelsColor();
return StelApp::getInstance().getVisionModeNight() ? StelUtils::getN
ightColor(col) : col;
} }
double Nebula::getCloseViewFov(const StelCore*) const double Nebula::getCloseViewFov(const StelCore*) const
{ {
return angularSize>0 ? angularSize * 4 : 1; return angularSize>0 ? angularSize * 4 : 1;
} }
void Nebula::drawHints(StelRenderer* renderer, float maxMagHints, NebulaHin float Nebula::getSurfaceBrightness(const StelCore* core) const
tTextures& hintTextures) {
if (getVMagnitude(core)<99 && angularSize>0)
return getVMagnitude(core) + 2.5*log10(M_PI*pow((angularSize
*M_PI/180.)*1800,2));
else
return 99;
}
float Nebula::getSurfaceBrightnessWithExtinction(const StelCore* core) cons
t
{
if (getVMagnitudeWithExtinction(core)<99 && angularSize>0)
return getVMagnitudeWithExtinction(core) + 2.5*log10(M_PI*po
w((angularSize*M_PI/180.)*1800,2));
else
return 99;
}
void Nebula::drawHints(StelPainter& sPainter, float maxMagHints)
{ {
float lim = mag; float lim = mag;
if (lim > 50) lim = 15.f; if (lim > 50) lim = 15.f;
// temporary workaround of this bug: https://bugs.launchpad.net/stel larium/+bug/1115035 --AW // temporary workaround of this bug: https://bugs.launchpad.net/stel larium/+bug/1115035 --AW
if (getEnglishName().contains("Pleiades")) if (getEnglishName().contains("Pleiades"))
lim = 5.f; lim = 5.f;
if (lim>maxMagHints) if (lim>maxMagHints)
return; return;
renderer->setBlendMode(BlendMode_Add); glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
float lum = 1.f;//qMin(1,4.f/getOnScreenSize(core))*0.8; float lum = 1.f;//qMin(1,4.f/getOnScreenSize(core))*0.8;
Vec3f col(circleColor[0]*lum*hintsBrightness, circleColor[1]*lum*hin tsBrightness, circleColor[2]*lum*hintsBrightness); Vec3f col(circleColor[0]*lum*hintsBrightness, circleColor[1]*lum*hin tsBrightness, circleColor[2]*lum*hintsBrightness);
if (StelApp::getInstance().getVisionModeNight())
col = StelUtils::getNightColor(col);
renderer->setGlobalColor(col[0], col[1], col[2], 1); sPainter.setColor(col[0], col[1], col[2], 1);
/* switch (nType)
if (nType == NebGx) hintTextures.texGalaxy->bind(); {
else if (nType == NebOc) hintTextures.texOpenCluster->bind();
else if (nType == NebGc) hintTextures.texGlobularCluster->bind();
else if (nType == NebN) hintTextures.texDiffuseNebula->bind();
else if (nType == NebPn) hintTextures.texPlanetaryNebula->bind();
else if (nType == NebCn) hintTextures.texOpenClusterWithNebulosity->
bind();
else hintTextures.texCircle->bind();
*/
switch (nType) {
case NebGx: case NebGx:
hintTextures.texGalaxy->bind(); Nebula::texGalaxy->bind();
break; break;
case NebOc: case NebOc:
hintTextures.texOpenCluster->bind(); Nebula::texOpenCluster->bind();
break; break;
case NebGc: case NebGc:
hintTextures.texGlobularCluster->bind(); Nebula::texGlobularCluster->bind();
break; break;
case NebN: case NebN:
hintTextures.texDiffuseNebula->bind(); Nebula::texDiffuseNebula->bind();
break; break;
case NebPn: case NebPn:
hintTextures.texPlanetaryNebula->bind(); Nebula::texPlanetaryNebula->bind();
break; break;
case NebCn: case NebCn:
hintTextures.texOpenClusterWithNebulosity->bind(); Nebula::texOpenClusterWithNebulosity->bind();
break; break;
default: default:
hintTextures.texCircle->bind(); Nebula::texCircle->bind();
} }
renderer->drawTexturedRect(XY[0] - 6, XY[1] - 6, 12, 12); sPainter.drawSprite2dMode(XY[0], XY[1], 6);
} }
void Nebula::drawLabel(StelRenderer* renderer, StelProjectorP projector, fl oat maxMagLabel) void Nebula::drawLabel(StelPainter& sPainter, float maxMagLabel)
{ {
float lim = mag; float lim = mag;
if (lim > 50) lim = 15.f; if (lim > 50) lim = 15.f;
// temporary workaround of this bug: https://bugs.launchpad.net/stel larium/+bug/1115035 --AW // temporary workaround of this bug: https://bugs.launchpad.net/stel larium/+bug/1115035 --AW
if (getEnglishName().contains("Pleiades")) if (getEnglishName().contains("Pleiades"))
lim = 5.f; lim = 5.f;
if (lim>maxMagLabel) if (lim>maxMagLabel)
return; return;
Vec3f col(labelColor[0], labelColor[1], labelColor[2]); Vec3f col(labelColor[0], labelColor[1], labelColor[2]);
if (StelApp::getInstance().getVisionModeNight())
col = StelUtils::getNightColor(col);
renderer->setGlobalColor(col[0], col[1], col[2], hintsBrightness);
sPainter.setColor(col[0], col[1], col[2], hintsBrightness);
float size = getAngularSize(NULL)*M_PI/180.*sPainter.getProjector()-
>getPixelPerRadAtCenter();
float shift = 4.f + size/1.8f;
QString str; QString str;
if (!nameI18.isEmpty()) if (!nameI18.isEmpty())
str = getNameI18n(); str = getNameI18n();
else else
{ {
if (M_nb > 0) if (M_nb > 0)
str = QString("M %1").arg(M_nb); str = QString("M %1").arg(M_nb);
else if (C_nb > 0) else if (C_nb > 0)
str = QString("C %1").arg(C_nb); str = QString("C %1").arg(C_nb);
else if (NGC_nb > 0) else if (NGC_nb > 0)
str = QString("NGC %1").arg(NGC_nb); str = QString("NGC %1").arg(NGC_nb);
else if (IC_nb > 0) else if (IC_nb > 0)
str = QString("IC %1").arg(IC_nb); str = QString("IC %1").arg(IC_nb);
} }
float size = getAngularSize(NULL) * M_PI / 180.0 * projector->getPix sPainter.drawText(XY[0]+shift, XY[1]+shift, str, 0, 0, 0, false);
elPerRadAtCenter();
float shift = 4.f + size / 1.8f;
renderer->drawText(TextParams(XY[0] + shift, XY[1] + shift, str).use
Gravity().projector(projector));
} }
void Nebula::readNGC(QDataStream& in) void Nebula::readNGC(QDataStream& in)
{ {
bool isIc; bool isIc;
int nb; int nb;
float ra, dec; float ra, dec;
unsigned int type; unsigned int type;
in >> isIc >> nb >> ra >> dec >> mag >> angularSize >> type; in >> isIc >> nb >> ra >> dec >> mag >> angularSize >> type;
if (isIc) if (isIc)
 End of changes. 32 change blocks. 
117 lines changed or deleted 108 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/