Skip to content

Commit

Permalink
Improve proportional size textures for large DSO (Stellarium#159)
Browse files Browse the repository at this point in the history
* Added a few scaled size textures for large DSO.
* Also fix rendering of either proportional or outlined DSO.
* Improve label placement for DSO.
  • Loading branch information
gzotti authored May 19, 2018
1 parent 6f16aaa commit dc44813
Show file tree
Hide file tree
Showing 13 changed files with 101 additions and 79 deletions.
144 changes: 65 additions & 79 deletions src/core/modules/Nebula.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,22 @@
const QString Nebula::NEBULA_TYPE = QStringLiteral("Nebula");

StelTextureSP Nebula::texCircle;
StelTextureSP Nebula::texCircleLarge;
StelTextureSP Nebula::texGalaxy;
StelTextureSP Nebula::texGalaxyLarge;
StelTextureSP Nebula::texOpenCluster;
StelTextureSP Nebula::texOpenClusterLarge;
StelTextureSP Nebula::texOpenClusterXLarge;
StelTextureSP Nebula::texGlobularCluster;
StelTextureSP Nebula::texGlobularClusterLarge;
StelTextureSP Nebula::texPlanetaryNebula;
StelTextureSP Nebula::texDiffuseNebula;
StelTextureSP Nebula::texDiffuseNebulaLarge;
StelTextureSP Nebula::texDiffuseNebulaXLarge;
StelTextureSP Nebula::texDarkNebula;
StelTextureSP Nebula::texDarkNebulaLarge;
StelTextureSP Nebula::texOpenClusterWithNebulosity;
StelTextureSP Nebula::texOpenClusterWithNebulosityLarge;
bool Nebula::drawHintProportional = false;
bool Nebula::surfaceBrightnessUsage = false;
bool Nebula::designationUsage = false;
Expand Down Expand Up @@ -774,6 +783,8 @@ void Nebula::drawOutlines(StelPainter &sPainter, float maxMagHints) const
void Nebula::drawHints(StelPainter& sPainter, float maxMagHints) const
{
size_t segments = outlineSegments.size();
if (segments>0 && flagUseOutlines)
return;
Vec3d win;
// Check visibility of DSO hints
if (!(sPainter.getProjector()->projectCheck(XYZ, win)))
Expand All @@ -783,109 +794,92 @@ void Nebula::drawHints(StelPainter& sPainter, float maxMagHints) const
return;

Vec3f color = getHintColor();

const float size = 6.0f;
float scaledSize = 0.0f;
if (drawHintProportional)
{
scaledSize = getAngularSize(Q_NULLPTR) *0.5 *M_PI/180.*sPainter.getProjector()->getPixelPerRadAtCenter();

}
const float finalSize=qMax(size, scaledSize);

switch (nType)
{
case NebGx:
Nebula::texGalaxy->bind();
break;
case NebIGx:
Nebula::texGalaxy->bind();
break;
case NebAGx:
Nebula::texGalaxy->bind();
break;
case NebQSO:
Nebula::texGalaxy->bind();
break;
case NebPossQSO:
Nebula::texGalaxy->bind();
break;
case NebBLL:
Nebula::texGalaxy->bind();
break;
case NebBLA:
Nebula::texGalaxy->bind();
break;
case NebRGx:
Nebula::texGalaxy->bind();
case NebGxCl:
if (finalSize > 35.0)
Nebula::texGalaxyLarge->bind();
else
Nebula::texGalaxy->bind();
break;
case NebOc:
Nebula::texOpenCluster->bind();
break;
case NebSA:
Nebula::texOpenCluster->bind();
break;
case NebSC:
Nebula::texOpenCluster->bind();
break;
case NebCl:
Nebula::texOpenCluster->bind();
if (finalSize > 75.0)
Nebula::texOpenClusterXLarge->bind();
else if (finalSize > 35.0)
Nebula::texOpenClusterLarge->bind();
else
Nebula::texOpenCluster->bind();
break;
case NebGc:
Nebula::texGlobularCluster->bind();
if (finalSize > 35.0)
Nebula::texGlobularClusterLarge->bind();
else
Nebula::texGlobularCluster->bind();
break;
case NebN:
Nebula::texDiffuseNebula->bind();
break;
case NebHII:
Nebula::texDiffuseNebula->bind();
break;
case NebMolCld:
Nebula::texDiffuseNebula->bind();
break;
case NebYSO:
Nebula::texDiffuseNebula->bind();
break;
case NebRn:
Nebula::texDiffuseNebula->bind();
break;
case NebSNR:
Nebula::texDiffuseNebula->bind();
break;
case NebBn:
Nebula::texDiffuseNebula->bind();
break;
case NebEn:
Nebula::texDiffuseNebula->bind();
case NebSNC:
case NebSNRC:
if (finalSize > 75.0)
Nebula::texDiffuseNebulaXLarge->bind();
else if (finalSize > 35.0)
Nebula::texDiffuseNebulaLarge->bind();
else
Nebula::texDiffuseNebula->bind();
break;
case NebPn:
Nebula::texPlanetaryNebula->bind();
break;
case NebPossPN:
Nebula::texPlanetaryNebula->bind();
break;
case NebPPN:
Nebula::texPlanetaryNebula->bind();
break;
case NebDn:
Nebula::texDarkNebula->bind();
case NebDn:
if (finalSize > 35.0)
Nebula::texDarkNebulaLarge->bind();
else
Nebula::texDarkNebula->bind();
break;
case NebCn:
Nebula::texOpenClusterWithNebulosity->bind();
break;
case NebEMO:
Nebula::texCircle->bind();
break;
case NebStar:
Nebula::texCircle->bind();
break;
case NebSymbioticStar:
Nebula::texCircle->bind();
break;
case NebEmissionLineStar:
Nebula::texCircle->bind();
break;
case NebSNC:
Nebula::texDiffuseNebula->bind();
break;
case NebSNRC:
Nebula::texDiffuseNebula->bind();
break;
case NebGxCl:
Nebula::texGalaxy->bind();
if (finalSize > 35.0)
Nebula::texOpenClusterWithNebulosityLarge->bind();
else
Nebula::texOpenClusterWithNebulosity->bind();
break;
//case NebEMO:
//case NebStar:
//case NebSymbioticStar:
//case NebEmissionLineStar:
default:
Nebula::texCircle->bind();
if (finalSize > 35.0)
Nebula::texCircleLarge->bind();
else
Nebula::texCircle->bind();
}

float lum = 1.f;
Expand All @@ -894,15 +888,7 @@ void Nebula::drawHints(StelPainter& sPainter, float maxMagHints) const
col = Vec3f(0.f,0.f,0.f);
sPainter.setColor(col[0], col[1], col[2], 1);

float size = 6.0f;
float scaledSize = 0.0f;
if (drawHintProportional && segments==0)
{
if (majorAxisSize>0.)
scaledSize = majorAxisSize *0.5 *M_PI/180.*sPainter.getProjector()->getPixelPerRadAtCenter();
else
scaledSize = minorAxisSize *0.5 *M_PI/180.*sPainter.getProjector()->getPixelPerRadAtCenter();
}


sPainter.setBlending(true, GL_ONE, GL_ONE);

Expand All @@ -916,10 +902,10 @@ void Nebula::drawHints(StelPainter& sPainter, float maxMagHints) const
Vec3d XYrel;
sPainter.getProjector()->project(XYZrel, XYrel);
float screenAngle=atan2(XYrel[1]-XY[1], XYrel[0]-XY[0]);
sPainter.drawSprite2dMode(XY[0], XY[1], qMax(size, scaledSize), screenAngle*180./M_PI + orientationAngle);
sPainter.drawSprite2dMode(XY[0], XY[1], finalSize, screenAngle*180./M_PI + orientationAngle);
}
else // no galaxy
sPainter.drawSprite2dMode(XY[0], XY[1], qMax(size, scaledSize));
sPainter.drawSprite2dMode(XY[0], XY[1], finalSize);

}

Expand All @@ -940,7 +926,7 @@ void Nebula::drawLabel(StelPainter& sPainter, float maxMagLabel) const
sPainter.setColor(col[0], col[1], col[2], 0.f);

float size = getAngularSize(Q_NULLPTR)*M_PI/180.*sPainter.getProjector()->getPixelPerRadAtCenter();
float shift = 4.f + (drawHintProportional ? size : size/1.8f);
float shift = 5.f + (drawHintProportional ? size*0.48f : 0.f);

QString str = getNameI18n();
if (str.isEmpty() || designationUsage)
Expand Down
9 changes: 9 additions & 0 deletions src/core/modules/Nebula.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,22 @@ friend class NebulaMgr;
SphericalRegionP pointRegion;

static StelTextureSP texCircle; // The symbolic circle texture
static StelTextureSP texCircleLarge; // The symbolic circle texture for large objects
static StelTextureSP texGalaxy; // Type 0
static StelTextureSP texGalaxyLarge; // Type 0_large
static StelTextureSP texOpenCluster; // Type 1
static StelTextureSP texOpenClusterLarge; // Type 1_large
static StelTextureSP texOpenClusterXLarge; // Type 1_extralarge
static StelTextureSP texGlobularCluster; // Type 2
static StelTextureSP texGlobularClusterLarge; // Type 2_large
static StelTextureSP texPlanetaryNebula; // Type 3
static StelTextureSP texDiffuseNebula; // Type 4
static StelTextureSP texDiffuseNebulaLarge; // Type 4_large
static StelTextureSP texDiffuseNebulaXLarge; // Type 4_extralarge
static StelTextureSP texDarkNebula; // Type 5
static StelTextureSP texDarkNebulaLarge; // Type 5_large
static StelTextureSP texOpenClusterWithNebulosity; // Type 6
static StelTextureSP texOpenClusterWithNebulosityLarge; // Type 6_large
static float hintsBrightness;

static Vec3f labelColor; // The color of labels
Expand Down
27 changes: 27 additions & 0 deletions src/core/modules/NebulaMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,22 @@ NebulaMgr::NebulaMgr(void)
NebulaMgr::~NebulaMgr()
{
Nebula::texCircle = StelTextureSP();
Nebula::texCircleLarge = StelTextureSP();
Nebula::texGalaxy = StelTextureSP();
Nebula::texGalaxyLarge = StelTextureSP();
Nebula::texOpenCluster = StelTextureSP();
Nebula::texOpenClusterLarge = StelTextureSP();
Nebula::texOpenClusterXLarge = StelTextureSP();
Nebula::texGlobularCluster = StelTextureSP();
Nebula::texGlobularClusterLarge = StelTextureSP();
Nebula::texPlanetaryNebula = StelTextureSP();
Nebula::texDiffuseNebula = StelTextureSP();
Nebula::texDiffuseNebulaLarge = StelTextureSP();
Nebula::texDiffuseNebulaXLarge = StelTextureSP();
Nebula::texDarkNebula = StelTextureSP();
Nebula::texDarkNebulaLarge = StelTextureSP();
Nebula::texOpenClusterWithNebulosity = StelTextureSP();
Nebula::texOpenClusterWithNebulosityLarge = StelTextureSP();
}

/*************************************************************************
Expand All @@ -178,20 +187,38 @@ void NebulaMgr::init()
nebulaFont.setPixelSize(StelApp::getInstance().getBaseFontSize());
// Load circle texture
Nebula::texCircle = StelApp::getInstance().getTextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures/neb.png");
// Load circle texture for large DSO
Nebula::texCircleLarge = StelApp::getInstance().getTextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures/neb_lrg.png");
// Load ellipse texture
Nebula::texGalaxy = StelApp::getInstance().getTextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures/neb_gal.png");
// Load ellipse texture for large galaxies
Nebula::texGalaxyLarge = StelApp::getInstance().getTextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures/neb_gal_lrg.png");
// Load open cluster marker texture
Nebula::texOpenCluster = StelApp::getInstance().getTextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures/neb_ocl.png");
// Load open cluster marker texture for large objects
Nebula::texOpenClusterLarge = StelApp::getInstance().getTextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures/neb_ocl_lrg.png");
// Load open cluster marker texture for extra large objects
Nebula::texOpenClusterXLarge = StelApp::getInstance().getTextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures/neb_ocl_xlrg.png");
// Load globular cluster marker texture
Nebula::texGlobularCluster = StelApp::getInstance().getTextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures/neb_gcl.png");
// Load globular cluster marker texture for large GCls
Nebula::texGlobularClusterLarge = StelApp::getInstance().getTextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures/neb_gcl_lrg.png");
// Load planetary nebula marker texture
Nebula::texPlanetaryNebula = StelApp::getInstance().getTextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures/neb_pnb.png");
// Load diffuse nebula marker texture
Nebula::texDiffuseNebula = StelApp::getInstance().getTextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures/neb_dif.png");
// Load diffuse nebula marker texture for large DSO
Nebula::texDiffuseNebulaLarge = StelApp::getInstance().getTextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures/neb_dif_lrg.png");
// Load diffuse nebula marker texture for extra large DSO
Nebula::texDiffuseNebulaXLarge = StelApp::getInstance().getTextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures/neb_dif_xlrg.png");
// Load dark nebula marker texture
Nebula::texDarkNebula = StelApp::getInstance().getTextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures/neb_drk.png");
// Load dark nebula marker texture for large DSO
Nebula::texDarkNebulaLarge = StelApp::getInstance().getTextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures/neb_drk_lrg.png");
// Load Ocl/Nebula marker texture
Nebula::texOpenClusterWithNebulosity = StelApp::getInstance().getTextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures/neb_ocln.png");
// Load Ocl/Nebula marker texture for large objects
Nebula::texOpenClusterWithNebulosityLarge = StelApp::getInstance().getTextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures/neb_ocln_lrg.png");
// Load pointer texture
texPointer = StelApp::getInstance().getTextureManager().createTexture(StelFileMgr::getInstallationDir()+"/textures/pointeur5.png");

Expand Down
Binary file added textures/neb_dif_lrg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added textures/neb_dif_xlrg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added textures/neb_drk_lrg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added textures/neb_gal_lrg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified textures/neb_gcl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added textures/neb_gcl_lrg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added textures/neb_lrg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added textures/neb_ocl_lrg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added textures/neb_ocl_xlrg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added textures/neb_ocln_lrg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit dc44813

Please sign in to comment.