Nebula.cpp   Nebula.cpp 
skipping to change at line 21 skipping to change at line 21
* 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.
* *
* 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 <QTextStream>
#include <QFile>
#include <QString>
#include "Nebula.hpp" #include "Nebula.hpp"
#include "NebulaMgr.hpp" #include "NebulaMgr.hpp"
#include "StelTexture.hpp"
#include "StelUtils.hpp" #include "renderer/StelRenderer.hpp"
#include "renderer/StelTextureNew.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelTextureMgr.hpp"
#include "StelModuleMgr.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelPainter.hpp" #include "StelModuleMgr.hpp"
#include "StelUtils.hpp"
#include <QDebug>
#include <QBuffer> #include <QBuffer>
#include <QDebug>
#include <QFile>
#include <QString>
#include <QTextStream>
StelTextureSP Nebula::texCircle;
StelTextureSP Nebula::texOpenCluster;
StelTextureSP Nebula::texGlobularCluster;
StelTextureSP Nebula::texPlanetNebula;
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()
{
if(!initialized){return;}
delete texCircle;
delete texOpenCluster;
delete texGlobularCluster;
delete texPlanetaryNebula;
initialized = false;
}
void Nebula::NebulaHintTextures::lazyInit(StelRenderer* renderer)
{
if(initialized){return;}
texCircle = renderer->createTexture("textures/neb.png");
// Load circle texture
texOpenCluster = renderer->createTexture("textures/ocl.png");
// Load open cluster marker texture
texGlobularCluster = renderer->createTexture("textures/gcl.png");
// Load globular cluster marker texture
texPlanetaryNebula = renderer->createTexture("textures/pnb.png");
// Load planetary nebula marker texture
initialized = true;
}
Nebula::Nebula() : Nebula::Nebula() :
M_nb(0), M_nb(0),
NGC_nb(0), NGC_nb(0),
IC_nb(0) IC_nb(0)
{ {
nameI18 = ""; nameI18 = "";
angularSize = -1; angularSize = -1;
} }
Nebula::~Nebula() Nebula::~Nebula()
skipping to change at line 154 skipping to change at line 172
{ {
Vec3f col = ((NebulaMgr*)StelApp::getInstance().getModuleMgr().getMo dule("NebulaMgr"))->getLabelsColor(); Vec3f col = ((NebulaMgr*)StelApp::getInstance().getModuleMgr().getMo dule("NebulaMgr"))->getLabelsColor();
return StelApp::getInstance().getVisionModeNight() ? StelUtils::getN ightColor(col) : col; 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(StelPainter& sPainter, float maxMagHints) void Nebula::drawHints(StelRenderer* renderer, float maxMagHints, NebulaHin tTextures& hintTextures)
{ {
float lim = mag; float lim = mag;
if (lim > 50) lim = 15.f; if (lim > 50) lim = 15.f;
if (lim>maxMagHints) if (lim>maxMagHints)
return; return;
glEnable(GL_BLEND); renderer->setBlendMode(BlendMode_Add);
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()) if (StelApp::getInstance().getVisionModeNight())
col = StelUtils::getNightColor(col); col = StelUtils::getNightColor(col);
sPainter.setColor(col[0], col[1], col[2], 1); renderer->setGlobalColor(col[0], col[1], col[2], 1);
if (nType == 1) if (nType == 1)
Nebula::texOpenCluster->bind(); {
hintTextures.texOpenCluster->bind();
if (nType == 2) }
Nebula::texGlobularCluster->bind(); else if (nType == 2)
{
if (nType == 4) hintTextures.texGlobularCluster->bind();
Nebula::texPlanetNebula->bind(); }
else if (nType == 4)
if (nType != 1 && nType != 2 && nType != 4) {
Nebula::texCircle->bind(); hintTextures.texPlanetaryNebula->bind();
}
else
{
hintTextures.texCircle->bind();
}
sPainter.drawSprite2dMode(XY[0], XY[1], 6); renderer->drawTexturedRect(XY[0] - 6, XY[1] - 6, 12, 12);
} }
void Nebula::drawLabel(StelPainter& sPainter, float maxMagLabel) void Nebula::drawLabel(StelRenderer* renderer, StelProjectorP projector, fl oat maxMagLabel)
{ {
float lim = mag; float lim = mag;
if (lim > 50) lim = 15.f; if (lim > 50) lim = 15.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()) if (StelApp::getInstance().getVisionModeNight())
col = StelUtils::getNightColor(col); 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!="") 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(XY[0]+shift, XY[1]+shift, str, 0, 0, 0, false); float size = getAngularSize(NULL) * M_PI / 180.0 * projector->getPix
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. 18 change blocks. 
35 lines changed or deleted 63 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/