Nebula.cpp   Nebula.cpp 
skipping to change at line 27 skipping to change at line 27
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#include <QTextStream> #include <QTextStream>
#include <QFile> #include <QFile>
#include <QString> #include <QString>
#include "Nebula.hpp" #include "Nebula.hpp"
#include "NebulaMgr.hpp" #include "NebulaMgr.hpp"
#include "StelTexture.hpp" #include "StelTexture.hpp"
#include "StelFont.hpp"
#include "StelNavigator.hpp" #include "StelNavigator.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelTextureMgr.hpp" #include "StelTextureMgr.hpp"
#include "StelFont.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include <QDebug> #include <QDebug>
#include <QBuffer>
StelTextureSP Nebula::texCircle; StelTextureSP Nebula::texCircle;
StelFont* Nebula::nebulaFont = NULL;
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::Nebula() : Nebula::Nebula() :
M_nb(0), M_nb(0),
NGC_nb(0), NGC_nb(0),
IC_nb(0) IC_nb(0)
{ {
skipping to change at line 133 skipping to change at line 131
Vec3f Nebula::getInfoColor(void) const Vec3f Nebula::getInfoColor(void) const
{ {
return StelApp::getInstance().getVisionModeNight() ? Vec3f(0.6, 0.0, 0.4) : ((NebulaMgr*)StelApp::getInstance().getModuleMgr().getModule("Nebul aMgr"))->getLabelsColor(); return StelApp::getInstance().getVisionModeNight() ? Vec3f(0.6, 0.0, 0.4) : ((NebulaMgr*)StelApp::getInstance().getModuleMgr().getModule("Nebul aMgr"))->getLabelsColor();
} }
double Nebula::getCloseViewFov(const StelNavigator*) const double Nebula::getCloseViewFov(const StelNavigator*) const
{ {
return angularSize>0 ? angularSize * 4 : 1; return angularSize>0 ? angularSize * 4 : 1;
} }
void Nebula::drawHints(const StelPainter& sPainter, float maxMagHints) void Nebula::drawHints(StelPainter& sPainter, float maxMagHints)
{ {
if (mag>maxMagHints) if (mag>maxMagHints)
return; return;
//if (4.f/getOnScreenSize(core)<0.1) return; glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE); glBlendFunc(GL_ONE, GL_ONE);
float lum = 1.;//qMin(1,4.f/getOnScreenSize(core))*0.8; float lum = 1.;//qMin(1,4.f/getOnScreenSize(core))*0.8;
glColor3f(circleColor[0]*lum*hintsBrightness, circleColor[1]*lum*hin tsBrightness, circleColor[2]*lum*hintsBrightness); sPainter.setColor(circleColor[0]*lum*hintsBrightness, circleColor[1] *lum*hintsBrightness, circleColor[2]*lum*hintsBrightness, 1);
Nebula::texCircle->bind(); Nebula::texCircle->bind();
sPainter.drawSprite2dMode(XY[0], XY[1], 8); sPainter.drawSprite2dMode(XY[0], XY[1], 4);
} }
void Nebula::drawLabel(const StelCore* core, const StelPainter& sPainter, f loat maxMagLabel) void Nebula::drawLabel(StelPainter& sPainter, float maxMagLabel)
{ {
if (mag>maxMagLabel) if (mag>maxMagLabel)
return; return;
glColor4f(labelColor[0], labelColor[1], labelColor[2], hintsBrightne sPainter.setColor(labelColor[0], labelColor[1], labelColor[2], hints
ss); Brightness);
float size = getAngularSize(core)*M_PI/180.*core->getProjection(Stel float size = getAngularSize(NULL)*M_PI/180.*sPainter.getProjector()-
Core::FrameJ2000)->getPixelPerRadAtCenter(); >getPixelPerRadAtCenter();
float shift = 4.f + size/1.8f; float shift = 4.f + size/1.8f;
QString str; QString str;
if (nameI18!="") if (nameI18!="")
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 (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);
} }
sPainter.drawText(nebulaFont,XY[0]+shift, XY[1]+shift, str, 0, 0, 0, false); sPainter.drawText(XY[0]+shift, XY[1]+shift, str, 0, 0, 0, false);
} }
void Nebula::readNGC(QDataStream& in)
{
bool isIc;
int nb;
float ra, dec;
unsigned int type;
in >> isIc >> nb >> ra >> dec >> mag >> angularSize >> type;
if (isIc)
{
IC_nb = nb;
}
else
{
NGC_nb = nb;
}
StelUtils::spheToRect(ra,dec,XYZ);
Q_ASSERT(fabs(XYZ.lengthSquared()-1.)<0.000000001);
nType = (Nebula::NebulaType)type;
pointRegion = SphericalRegionP(new SphericalPoint(getJ2000Equatorial
Pos(NULL)));
}
#if 0
QFile filess("filess.dat");
QDataStream out;
out.setVersion(QDataStream::Qt_4_5);
bool Nebula::readNGC(char *recordstr) bool Nebula::readNGC(char *recordstr)
{ {
int rahr; int rahr;
float ramin; float ramin;
int dedeg; int dedeg;
float demin; float demin;
int nb; int nb;
sscanf(&recordstr[1],"%d",&nb); sscanf(&recordstr[1],"%d",&nb);
skipping to change at line 210 skipping to change at line 233
if (mag < 1) mag = 99; if (mag < 1) mag = 99;
// Calc the angular size in radian : TODO this should be independant of tex_angular_size // Calc the angular size in radian : TODO this should be independant of tex_angular_size
float size; float size;
sscanf(&recordstr[40],"%f",&size); sscanf(&recordstr[40],"%f",&size);
angularSize = size/60; angularSize = size/60;
if (angularSize<0) if (angularSize<0)
angularSize=0; angularSize=0;
if (size < 0)
size = 1;
// this is a huge performance drag if called every frame, so cache h ere // this is a huge performance drag if called every frame, so cache h ere
if (!strncmp(&recordstr[8],"Gx",2)) { nType = NebGx;} if (!strncmp(&recordstr[8],"Gx",2)) { nType = NebGx;}
else if (!strncmp(&recordstr[8],"OC",2)) { nType = NebOc;} else if (!strncmp(&recordstr[8],"OC",2)) { nType = NebOc;}
else if (!strncmp(&recordstr[8],"Gb",2)) { nType = NebGc;} else if (!strncmp(&recordstr[8],"Gb",2)) { nType = NebGc;}
else if (!strncmp(&recordstr[8],"Nb",2)) { nType = NebN;} else if (!strncmp(&recordstr[8],"Nb",2)) { nType = NebN;}
else if (!strncmp(&recordstr[8],"Pl",2)) { nType = NebPn;} else if (!strncmp(&recordstr[8],"Pl",2)) { nType = NebPn;}
else if (!strncmp(&recordstr[8]," ",2)) { return false;} else if (!strncmp(&recordstr[8]," ",2)) { return false;}
else if (!strncmp(&recordstr[8]," -",2)) { return false;} else if (!strncmp(&recordstr[8]," -",2)) { return false;}
else if (!strncmp(&recordstr[8]," *",2)) { return false;} else if (!strncmp(&recordstr[8]," *",2)) { return false;}
else if (!strncmp(&recordstr[8],"D*",2)) { return false;} else if (!strncmp(&recordstr[8],"D*",2)) { return false;}
else if (!strncmp(&recordstr[7],"***",3)) { return false;} else if (!strncmp(&recordstr[7],"***",3)) { return false;}
else if (!strncmp(&recordstr[7],"C+N",3)) { nType = NebCn;} else if (!strncmp(&recordstr[7],"C+N",3)) { nType = NebCn;}
else if (!strncmp(&recordstr[8]," ?",2)) { nType = NebUnknown;} else if (!strncmp(&recordstr[8]," ?",2)) { nType = NebUnknown;}
else { nType = NebUnknown;} else { nType = NebUnknown;}
if (!filess.isOpen())
{
filess.open(QIODevice::WriteOnly);
out.setDevice(&filess);
}
out << ((bool)(recordstr[0] == 'I')) << nb << RaRad << DecRad << mag
<< angularSize << ((unsigned int)nType);
if (nb==5369 && recordstr[0] == 'I')
filess.close();
return true; return true;
} }
#endif
QString Nebula::getTypeString(void) const QString Nebula::getTypeString(void) const
{ {
QString wsType; QString wsType;
switch(nType) switch(nType)
{ {
case NebGx: case NebGx:
wsType = q_("Galaxy"); wsType = q_("Galaxy");
break; break;
 End of changes. 15 change blocks. 
16 lines changed or deleted 48 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/