SolarSystem.cpp   SolarSystem.cpp 
skipping to change at line 23 skipping to change at line 23
* 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 "SolarSystem.hpp" #include "SolarSystem.hpp"
#include "StelTexture.hpp" #include "renderer/StelGLSLShader.hpp"
#include "renderer/StelRenderer.hpp"
#include "renderer/StelTextureNew.hpp"
#include "stellplanet.h" #include "stellplanet.h"
#include "Orbit.hpp" #include "Orbit.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.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 "StelIniParser.hpp" #include "StelIniParser.hpp"
#include "StelUtils.hpp"
#include "Planet.hpp" #include "Planet.hpp"
#include "MinorPlanet.hpp" #include "MinorPlanet.hpp"
#include "Comet.hpp" #include "Comet.hpp"
#include "StelSkyDrawer.hpp" #include "StelSkyDrawer.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelPainter.hpp"
#include "TrailGroup.hpp" #include "TrailGroup.hpp"
#include "RefractionExtinction.hpp" #include "RefractionExtinction.hpp"
#include <functional>
#include <algorithm> #include <algorithm>
#include <functional>
#include <QTextStream> #include <QDebug>
#include <QFile>
#include <QMap>
#include <QMapIterator>
#include <QMultiMap>
#include <QSettings> #include <QSettings>
#include <QVariant>
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
#include <QMap> #include <QTextStream>
#include <QMultiMap> #include <QVariant>
#include <QMapIterator>
#include <QDebug>
SolarSystem::SolarSystem() : moonScale(1.), flagOrbits(false), flagLight SolarSystem::SolarSystem()
TravelTime(false), allTrails(NULL) : moonScale(1.)
, flagOrbits(false)
, flagLightTravelTime(false)
, texPointer(NULL)
, allTrails(NULL)
{ {
planetNameFont.setPixelSize(StelApp::getInstance().getSettings()->va lue("gui/base_font_size", 13).toInt()); planetNameFont.setPixelSize(StelApp::getInstance().getSettings()->va lue("gui/base_font_size", 13).toInt());
setObjectName("SolarSystem"); setObjectName("SolarSystem");
} }
void SolarSystem::setFontSize(float newFontSize) void SolarSystem::setFontSize(float newFontSize)
{ {
planetNameFont.setPixelSize(newFontSize); planetNameFont.setPixelSize(newFontSize);
} }
skipping to change at line 83 skipping to change at line 90
// release selected: // release selected:
selected.clear(); selected.clear();
foreach (Orbit* orb, orbits) foreach (Orbit* orb, orbits)
{ {
delete orb; delete orb;
orb = NULL; orb = NULL;
} }
sun.clear(); sun.clear();
moon.clear(); moon.clear();
earth.clear(); earth.clear();
Planet::hintCircleTex.clear();
Planet::texEarthShadow.clear();
delete allTrails; delete allTrails;
allTrails = NULL; allTrails = NULL;
if(NULL != texPointer)
{
delete texPointer;
texPointer = NULL;
}
// Get rid of circular reference between the shared pointers which p revent proper destruction of the Planet objects. // Get rid of circular reference between the shared pointers which p revent proper destruction of the Planet objects.
foreach (PlanetP p, systemPlanets) foreach (PlanetP p, systemPlanets)
{ {
p->satellites.clear(); p->satellites.clear();
} }
} }
/************************************************************************* /*************************************************************************
Reimplementation of the getCallOrder method Reimplementation of the getCallOrder method
*************************************************************************/ *************************************************************************/
skipping to change at line 137 skipping to change at line 148
recreateTrails(); recreateTrails();
setFlagTrails(conf->value("astro/flag_object_trails", false).toBool( )); setFlagTrails(conf->value("astro/flag_object_trails", false).toBool( ));
StelObjectMgr *objectManager = GETSTELMODULE(StelObjectMgr); StelObjectMgr *objectManager = GETSTELMODULE(StelObjectMgr);
objectManager->registerStelObjectMgr(this); objectManager->registerStelObjectMgr(this);
connect(objectManager, SIGNAL(selectedObjectChanged(StelModule::Stel ModuleSelectAction)), connect(objectManager, SIGNAL(selectedObjectChanged(StelModule::Stel ModuleSelectAction)),
this, SLOT(selectedObjectChange(StelModule::StelModu leSelectAction))); this, SLOT(selectedObjectChange(StelModule::StelModu leSelectAction)));
texPointer = StelApp::getInstance().getTextureManager().createTextur
e("textures/pointeur4.png");
Planet::hintCircleTex = StelApp::getInstance().getTextureManager().c
reateTexture("textures/planet-indicator.png");
StelApp *app = &StelApp::getInstance(); StelApp *app = &StelApp::getInstance();
connect(app, SIGNAL(languageChanged()), this, SLOT(updateI18n())); connect(app, SIGNAL(languageChanged()), this, SLOT(updateI18n()));
connect(app, SIGNAL(colorSchemeChanged(const QString&)), this, SLOT( setStelStyle(const QString&))); connect(app, SIGNAL(colorSchemeChanged(const QString&)), this, SLOT( setStelStyle(const QString&)));
} }
void SolarSystem::recreateTrails() void SolarSystem::recreateTrails()
{ {
// Create a trail group containing all the planets orbiting the sun (not including satellites) // Create a trail group containing all the planets orbiting the sun (not including satellites)
if (allTrails!=NULL) if (allTrails!=NULL)
delete allTrails; delete allTrails;
allTrails = new TrailGroup(365.f); allTrails = new TrailGroup(365.f);
foreach (const PlanetP& p, getSun()->satellites) foreach (const PlanetP& p, getSun()->satellites)
{ {
allTrails->addObject((QSharedPointer<StelObject>)p, &trailCo lor); allTrails->addObject((QSharedPointer<StelObject>)p, &trailCo lor);
} }
} }
void SolarSystem::drawPointer(const StelCore* core) void SolarSystem::drawPointer(const StelCore* core, StelRenderer* renderer)
{ {
const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000) ; const StelProjectorP prj = core->getProjection(StelCore::FrameJ2000) ;
const QList<StelObjectP> newSelected = GETSTELMODULE(StelObjectMgr)- >getSelectedObject("Planet"); const QList<StelObjectP> newSelected = GETSTELMODULE(StelObjectMgr)- >getSelectedObject("Planet");
if (!newSelected.empty()) if (!newSelected.empty())
{ {
const StelObjectP obj = newSelected[0]; const StelObjectP obj = newSelected[0];
Vec3d pos=obj->getJ2000EquatorialPos(core); Vec3d pos=obj->getJ2000EquatorialPos(core);
Vec3d screenpos; Vec3d screenpos;
// Compute 2D pos and return if outside screen // Compute 2D pos and return if outside screen
if (!prj->project(pos, screenpos)) if (!prj->project(pos, screenpos))
return; return;
StelPainter sPainter(prj); const Vec4f color = StelApp::getInstance().getVisionModeNigh
if (StelApp::getInstance().getVisionModeNight()) t()
sPainter.setColor(1.0f,0.0f,0.0f); ? Vec4f(1.0f,0.0f,0.0f,1.0f) : Vec4f(1.0f,
else 0.3f,0.3f,1.0f);
sPainter.setColor(1.0f,0.3f,0.3f); renderer->setGlobalColor(color);
float size = obj->getAngularSize(core)*M_PI/180.*prj->getPix elPerRadAtCenter()*2.; float size = obj->getAngularSize(core)*M_PI/180.*prj->getPix elPerRadAtCenter()*2.;
size+=40.f + 10.f*std::sin(2.f * StelApp::getInstance().getT otalRunTime()); size+=40.f + 10.f*std::sin(2.f * StelApp::getInstance().getT otalRunTime());
if(NULL == texPointer)
{
texPointer = renderer->createTexture("textures/point
eur4.png");
}
texPointer->bind(); texPointer->bind();
sPainter.enableTexture2d(true); renderer->setBlendMode(BlendMode_Alpha);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Normal
transparency mode
size*=0.5; size*=0.5;
const float angleBase = StelApp::getInstance().getTotalRunTi me() * 10; const float angleBase = StelApp::getInstance().getTotalRunTi me() * 10;
// We draw 4 instances of the sprite at the corners of the p ointer // We draw 4 instances of the sprite at the corners of the p ointer
for (int i = 0; i < 4; ++i) for (int i = 0; i < 4; ++i)
{ {
const float angle = angleBase + i * 90; const float angle = angleBase + i * 90;
const double x = screenpos[0] + size * cos(angle / 1 80 * M_PI); const double x = screenpos[0] + size * cos(angle / 1 80 * M_PI);
const double y = screenpos[1] + size * sin(angle / 1 80 * M_PI); const double y = screenpos[1] + size * sin(angle / 1 80 * M_PI);
sPainter.drawSprite2dMode(x, y, 10, angle); renderer->drawTexturedRect(x - 10, y - 10, 20, 20, a ngle);
} }
} }
} }
void ellipticalOrbitPosFunc(double jd,double xyz[3], void* userDataPtr) void ellipticalOrbitPosFunc(double jd,double xyz[3], void* userDataPtr)
{ {
static_cast<EllipticalOrbit*>(userDataPtr)->positionAtTimevInVSOP87C oordinates(jd, xyz); static_cast<EllipticalOrbit*>(userDataPtr)->positionAtTimevInVSOP87C oordinates(jd, xyz);
} }
void cometOrbitPosFunc(double jd,double xyz[3], void* userDataPtr) void cometOrbitPosFunc(double jd,double xyz[3], void* userDataPtr)
{ {
skipping to change at line 256 skipping to change at line 265
if (QFile::rename(solarSystemFile, newName)) if (QFile::rename(solarSystemFile, newName))
qWarning() << "Invalid Solar System file" << solarSystemFile << "has been renamed to" << newName; qWarning() << "Invalid Solar System file" << solarSystemFile << "has been renamed to" << newName;
else else
{ {
qWarning() << "Invalid Solar System file" << solarSystemFile << "cannot be removed!"; qWarning() << "Invalid Solar System file" << solarSystemFile << "cannot be removed!";
qWarning() << "Please either delete it, rename it or move it elsewhere."; qWarning() << "Please either delete it, rename it or move it elsewhere.";
} }
} }
} }
} }
shadowPlanetCount = 0;
foreach (const PlanetP& planet, systemPlanets)
if(planet->parent != sun || !planet->satellites.isEmpty())
shadowPlanetCount++;
} }
bool SolarSystem::loadPlanets(const QString& filePath) bool SolarSystem::loadPlanets(const QString& filePath)
{ {
QSettings pd(filePath, StelIniFormat); QSettings pd(filePath, StelIniFormat);
if (pd.status() != QSettings::NoError) if (pd.status() != QSettings::NoError)
{ {
qWarning() << "ERROR while parsing" << filePath; qWarning() << "ERROR while parsing" << filePath;
return false; return false;
} }
skipping to change at line 713 skipping to change at line 728
pd.value(secname+"/lighting").toBool( ), pd.value(secname+"/lighting").toBool( ),
pd.value(secname+"/radius").toDouble( )/AU, pd.value(secname+"/radius").toDouble( )/AU,
pd.value(secname+"/oblateness", 0.0). toDouble(), pd.value(secname+"/oblateness", 0.0). toDouble(),
StelUtils::strToVec3f(pd.value(secnam e+"/color").toString()), StelUtils::strToVec3f(pd.value(secnam e+"/color").toString()),
pd.value(secname+"/albedo").toFloat() , pd.value(secname+"/albedo").toFloat() ,
pd.value(secname+"/tex_map").toString (), pd.value(secname+"/tex_map").toString (),
posfunc, posfunc,
userDataPtr, userDataPtr,
osculatingFunc, osculatingFunc,
closeOrbit, closeOrbit,
pd.value(secname+"/hidden", 0).toBool pd.value(secname+"/hidden", 0).toBool
())); (),
type));
QSharedPointer<MinorPlanet> mp = p.dynamicCast<Mino rPlanet>(); QSharedPointer<MinorPlanet> mp = p.dynamicCast<Mino rPlanet>();
//Number //Number
int minorPlanetNumber = pd.value(secname+"/minor_pla net_number", 0).toInt(); int minorPlanetNumber = pd.value(secname+"/minor_pla net_number", 0).toInt();
if (minorPlanetNumber) if (minorPlanetNumber)
{ {
mp->setMinorPlanetNumber(minorPlanetNumber); mp->setMinorPlanetNumber(minorPlanetNumber);
} }
skipping to change at line 763 skipping to change at line 779
pd.value(secname+"/lighting").toBool( ), pd.value(secname+"/lighting").toBool( ),
pd.value(secname+"/radius").toDouble( )/AU, pd.value(secname+"/radius").toDouble( )/AU,
pd.value(secname+"/oblateness", 0.0). toDouble(), pd.value(secname+"/oblateness", 0.0). toDouble(),
StelUtils::strToVec3f(pd.value(secnam e+"/color").toString()), StelUtils::strToVec3f(pd.value(secnam e+"/color").toString()),
pd.value(secname+"/albedo").toFloat() , pd.value(secname+"/albedo").toFloat() ,
pd.value(secname+"/tex_map").toString (), pd.value(secname+"/tex_map").toString (),
posfunc, posfunc,
userDataPtr, userDataPtr,
osculatingFunc, osculatingFunc,
closeOrbit, closeOrbit,
pd.value(secname+"/hidden", 0).toBool pd.value(secname+"/hidden", 0).toBool
())); (),
type));
QSharedPointer<Comet> mp = p.dynamicCast<Comet>(); QSharedPointer<Comet> mp = p.dynamicCast<Comet>();
//g,k magnitude system //g,k magnitude system
double magnitude = pd.value(secname+"/absolute_magni tude", -99).toDouble(); double magnitude = pd.value(secname+"/absolute_magni tude", -99).toDouble();
double slope = pd.value(secname+"/slope_parameter", 4.0).toDouble(); double slope = pd.value(secname+"/slope_parameter", 4.0).toDouble();
if (magnitude > -99) if (magnitude > -99)
{ {
if (slope >= 0 && slope <= 20) if (slope >= 0 && slope <= 20)
{ {
mp->setAbsoluteMagnitudeAndSlope(mag nitude, slope); mp->setAbsoluteMagnitudeAndSlope(mag nitude, slope);
} }
else else
{ {
mp->setAbsoluteMagnitudeAndSlope(mag nitude, 4.0); mp->setAbsoluteMagnitudeAndSlope(mag nitude, 4.0);
} }
} }
mp->setSemiMajorAxis(pd.value(secname+"/orbit_SemiMa
jorAxis", 0).toDouble());
} }
else else
{ {
p = PlanetP(new Planet(englishName, p = PlanetP(new Planet(englishName,
pd.value(secname+"/lighting").toBool( ), pd.value(secname+"/lighting").toBool( ),
pd.value(secname+"/radius").toDouble( )/AU, pd.value(secname+"/radius").toDouble( )/AU,
pd.value(secname+"/oblateness", 0.0). toDouble(), pd.value(secname+"/oblateness", 0.0). toDouble(),
StelUtils::strToVec3f(pd.value(secnam e+"/color").toString()), StelUtils::strToVec3f(pd.value(secnam e+"/color").toString()),
pd.value(secname+"/albedo").toFloat() , pd.value(secname+"/albedo").toFloat() ,
pd.value(secname+"/tex_map").toString (), pd.value(secname+"/tex_map").toString (),
posfunc, posfunc,
userDataPtr, userDataPtr,
osculatingFunc, osculatingFunc,
closeOrbit, closeOrbit,
pd.value(secname+"/hidden", 0).toBool (), pd.value(secname+"/hidden", 0).toBool (),
pd.value(secname+"/atmosphere", false pd.value(secname+"/atmosphere", false
).toBool())); ).toBool(),
type));
} }
if (!parent.isNull()) if (!parent.isNull())
{ {
parent->satellites.append(p); parent->satellites.append(p);
p->parent = parent; p->parent = parent;
} }
if (secname=="earth") earth = p; if (secname=="earth") earth = p;
if (secname=="sun") sun = p; if (secname=="sun") sun = p;
if (secname=="moon") moon = p; if (secname=="moon") moon = p;
skipping to change at line 861 skipping to change at line 881
systemPlanets.push_back(p); systemPlanets.push_back(p);
readOk++; readOk++;
} }
if (systemPlanets.isEmpty()) if (systemPlanets.isEmpty())
{ {
qWarning() << "No Solar System objects loaded from" << fileP ath; qWarning() << "No Solar System objects loaded from" << fileP ath;
return false; return false;
} }
// special case: load earth shadow texture
Planet::texEarthShadow = StelApp::getInstance().getTextureManager().
createTexture("textures/earth-shadow.png");
qDebug() << "Loaded" << readOk << "/" << totalPlanets << "planet orb its from" << filePath; qDebug() << "Loaded" << readOk << "/" << totalPlanets << "planet orb its from" << filePath;
return true; return true;
} }
// Compute the position for every elements of the solar system. // Compute the position for every elements of the solar system.
// The order is not important since the position is computed relatively to the mother body // The order is not important since the position is computed relatively to the mother body
void SolarSystem::computePositions(double date, const Vec3d& observerPos) void SolarSystem::computePositions(double date, const Vec3d& observerPos)
{ {
if (flagLightTravelTime) if (flagLightTravelTime)
{ {
skipping to change at line 924 skipping to change at line 941
// And sort them from the furthest to the closest to the observer // And sort them from the furthest to the closest to the observer
struct biggerDistance : public std::binary_function<PlanetP, PlanetP, bool> struct biggerDistance : public std::binary_function<PlanetP, PlanetP, bool>
{ {
bool operator()(PlanetP p1, PlanetP p2) bool operator()(PlanetP p1, PlanetP p2)
{ {
return p1->getDistance() > p2->getDistance(); return p1->getDistance() > p2->getDistance();
} }
}; };
StelTextureNew* SolarSystem::computeShadowInfo(StelRenderer* renderer)
{
// Acquire shadow informations
if(shadowModelMatricesBuffer.size() < shadowPlanetCount)
{
shadowModelMatricesBuffer.resize(shadowPlanetCount);
}
Mat4d* modelMatrices = shadowModelMatricesBuffer.data();
int p = 1;
foreach (const PlanetP& planet, systemPlanets)
{
if(planet->parent != sun || !planet->satellites.isEmpty())
{
planet->computeModelMatrix(modelMatrices[planet == s
un ? 0 : p++]);
}
}
const int size = StelUtils::smallestPowerOfTwoGreaterOrEqualTo(shado
wPlanetCount);
if(shadowInfoBuffer.size() < size * size)
{
shadowInfoBuffer.resize(size * size);
}
// Shadow info texture data
Vec4f* data = shadowInfoBuffer.data();
memset(data, '\0', size * size * sizeof(Vec4f));
int y = 1;
foreach (const PlanetP& target, systemPlanets)
{
if(target == sun || (target->parent == sun && target->satell
ites.isEmpty()))
continue;
const Mat4d mTarget = modelMatrices[y].inverse();
data[y * size] = Vec4f(mTarget[12], mTarget[13], mTarget[14]
, sun->getRadius());
int x = 1;
foreach (const PlanetP& source, systemPlanets)
{
if(source == sun || (source->parent == sun && source
->satellites.isEmpty()))
continue;
const Mat4d& mSource(modelMatrices[x]);
const Vec4d position = mTarget * mSource.getColumn(3
);
data[y * size + x] = Vec4f(position[0], position[1],
position[2], source->getRadius());
x++;
}
y++;
}
return renderer->createTexture(data, QSize(size, size), TextureDataF
ormat_RGBA_F32,
TextureParams().filtering(TextureFilt
ering_Nearest));
}
// Draw all the elements of the solar system // Draw all the elements of the solar system
// We are supposed to be in heliocentric coordinate // We are supposed to be in heliocentric coordinate
void SolarSystem::draw(StelCore* core) void SolarSystem::draw(StelCore* core, class StelRenderer* renderer)
{ {
if (!flagShow) if (!flagShow)
return; return;
// Compute each Planet distance to the observer // Compute each Planet distance to the observer
Vec3d obsHelioPos = core->getObserverHeliocentricEclipticPos(); Vec3d obsHelioPos = core->getObserverHeliocentricEclipticPos();
foreach (PlanetP p, systemPlanets) foreach (PlanetP p, systemPlanets)
{ {
p->computeDistance(obsHelioPos); p->computeDistance(obsHelioPos);
} }
// And sort them from the furthest to the closest // And sort them from the furthest to the closest
sort(systemPlanets.begin(),systemPlanets.end(),biggerDistance()); sort(systemPlanets.begin(),systemPlanets.end(),biggerDistance());
if (trailFader.getInterstate()>0.0000001f) if (trailFader.getInterstate()>0.0000001f)
{ {
StelPainter* sPainter = new StelPainter(core->getProjection2 d());
allTrails->setOpacity(trailFader.getInterstate()); allTrails->setOpacity(trailFader.getInterstate());
allTrails->draw(core, sPainter); allTrails->draw(core, renderer);
delete sPainter;
} }
// Make some voodoo to determine when labels should be displayed // Make some voodoo to determine when labels should be displayed
float maxMagLabel = (core->getSkyDrawer()->getLimitMagnitude()<5.f ? core->getSkyDrawer()->getLimitMagnitude() : float maxMagLabel = (core->getSkyDrawer()->getLimitMagnitude()<5.f ? core->getSkyDrawer()->getLimitMagnitude() :
5.f+(core->getSkyDrawer()->getLimitMagnitude()-5.f)* 1.2f) +(labelsAmount-3.f)*1.2f; 5.f+(core->getSkyDrawer()->getLimitMagnitude()-5.f)* 1.2f) +(labelsAmount-3.f)*1.2f;
// Draw the elements sharedPlanetGraphics.lazyInit(renderer);
foreach (const PlanetP& p, systemPlanets)
if(StelApp::getInstance().getRenderSolarShadows() && sharedPlanetGra
phics.shadowPlanetShader)
{ {
p->draw(core, maxMagLabel, planetNameFont); StelTextureNew* shadowInfo = computeShadowInfo(renderer);
sharedPlanetGraphics.planetShader = sharedPlanetGraphics.sha
dowPlanetShader;
sharedPlanetGraphics.info.info = 1;
sharedPlanetGraphics.info.infoCount = shadowPlanetCount;
const QSize size = shadowInfo->getDimensions();
Q_ASSERT_X(size.width() == size.height(), Q_FUNC_INFO,
"Shadow info texture is not square");
sharedPlanetGraphics.info.infoSize = size.width();
shadowInfo->bind(1);
// Draw the elements
int i = 1;
foreach (const PlanetP& p, systemPlanets)
{
if((p == sun || (p->parent == sun && p->satellites.i
sEmpty())) && sharedPlanetGraphics.planetShader == sharedPlanetGraphics.sha
dowPlanetShader)
{
sharedPlanetGraphics.info.current = 0;
sharedPlanetGraphics.planetShader = sharedPl
anetGraphics.simplePlanetShader;
p->draw(core, renderer, maxMagLabel, planetN
ameFont, sharedPlanetGraphics);
sharedPlanetGraphics.planetShader = sharedPl
anetGraphics.shadowPlanetShader;
}
else
{
sharedPlanetGraphics.info.current = i;
p->draw(core, renderer, maxMagLabel, planetN
ameFont, sharedPlanetGraphics);
i++;
}
}
delete shadowInfo;
}
else
{
sharedPlanetGraphics.planetShader = sharedPlanetGraphics.sim
plePlanetShader;
// Draw the elements
foreach (const PlanetP& p, systemPlanets)
{
p->draw(core, renderer, maxMagLabel, planetNameFont,
sharedPlanetGraphics);
}
} }
if (GETSTELMODULE(StelObjectMgr)->getFlagSelectedObjectPointer()) if (GETSTELMODULE(StelObjectMgr)->getFlagSelectedObjectPointer())
drawPointer(core); drawPointer(core, renderer);
} }
void SolarSystem::setStelStyle(const QString& section) void SolarSystem::setStelStyle(const QString& section)
{ {
// Load colors from config file // Load colors from config file
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
QString defaultColor = conf->value(section+"/default_color").toStrin g(); QString defaultColor = conf->value(section+"/default_color").toStrin g();
setLabelsColor(StelUtils::strToVec3f(conf->value(section+"/planet_na mes_color", defaultColor).toString())); setLabelsColor(StelUtils::strToVec3f(conf->value(section+"/planet_na mes_color", defaultColor).toString()));
setOrbitsColor(StelUtils::strToVec3f(conf->value(section+"/planet_or bits_color", defaultColor).toString())); setOrbitsColor(StelUtils::strToVec3f(conf->value(section+"/planet_or bits_color", defaultColor).toString()));
setTrailsColor(StelUtils::strToVec3f(conf->value(section+"/object_tr ails_color", defaultColor).toString())); setTrailsColor(StelUtils::strToVec3f(conf->value(section+"/object_tr ails_color", defaultColor).toString()));
skipping to change at line 1015 skipping to change at line 1133
} }
float SolarSystem::getPlanetVMagnitude(QString planetName, bool withExtinct ion) const float SolarSystem::getPlanetVMagnitude(QString planetName, bool withExtinct ion) const
{ {
PlanetP p = searchByEnglishName(planetName); PlanetP p = searchByEnglishName(planetName);
float r = 0.f; float r = 0.f;
r = p->getVMagnitude(StelApp::getInstance().getCore(), withExtinctio n); r = p->getVMagnitude(StelApp::getInstance().getCore(), withExtinctio n);
return r; return r;
} }
double SolarSystem::getDistanceToPlanet(QString planetName) const
{
PlanetP p = searchByEnglishName(planetName);
double r = 0.f;
r = p->getDistance();
return r;
}
double SolarSystem::getElongationForPlanet(QString planetName) const
{
PlanetP p = searchByEnglishName(planetName);
double r = 0.f;
r = p->getElongation(StelApp::getInstance().getCore()->getObserverHe
liocentricEclipticPos());
return r;
}
double SolarSystem::getPhaseAngleForPlanet(QString planetName) const
{
PlanetP p = searchByEnglishName(planetName);
double r = 0.f;
r = p->getPhaseAngle(StelApp::getInstance().getCore()->getObserverHe
liocentricEclipticPos());
return r;
}
float SolarSystem::getPhaseForPlanet(QString planetName) const
{
PlanetP p = searchByEnglishName(planetName);
float r = 0.f;
r = p->getPhase(StelApp::getInstance().getCore()->getObserverHelioce
ntricEclipticPos());
return r;
}
// Search if any Planet is close to position given in earth equatorial posi tion and return the distance // Search if any Planet is close to position given in earth equatorial posi tion and return the distance
StelObjectP SolarSystem::search(Vec3d pos, const StelCore* core) const StelObjectP SolarSystem::search(Vec3d pos, const StelCore* core) const
{ {
pos.normalize(); pos.normalize();
PlanetP closest; PlanetP closest;
double cos_angle_closest = 0.; double cos_angle_closest = 0.;
Vec3d equPos; Vec3d equPos;
foreach (const PlanetP& p, systemPlanets) foreach (const PlanetP& p, systemPlanets)
{ {
skipping to change at line 1233 skipping to change at line 1383
if (constw==objw) if (constw==objw)
{ {
result << p->getNameI18n(); result << p->getNameI18n();
if (result.size()==maxNbItem) if (result.size()==maxNbItem)
return result; return result;
} }
} }
return result; return result;
} }
QStringList SolarSystem::listAllObjects(bool inEnglish) const
{
QStringList result;
if (inEnglish)
{
foreach(const PlanetP& p, systemPlanets)
{
result << p->getEnglishName();
}
}
else
{
foreach(const PlanetP& p, systemPlanets)
{
result << p->getNameI18n();
}
}
return result;
}
void SolarSystem::selectedObjectChange(StelModule::StelModuleSelectAction) void SolarSystem::selectedObjectChange(StelModule::StelModuleSelectAction)
{ {
const QList<StelObjectP> newSelected = GETSTELMODULE(StelObjectMgr)- >getSelectedObject("Planet"); const QList<StelObjectP> newSelected = GETSTELMODULE(StelObjectMgr)- >getSelectedObject("Planet");
if (!newSelected.empty()) if (!newSelected.empty())
setSelected(qSharedPointerCast<Planet>(newSelected[0])); setSelected(qSharedPointerCast<Planet>(newSelected[0]));
} }
// Activate/Deactivate planets display // Activate/Deactivate planets display
void SolarSystem::setFlagPlanets(bool b) void SolarSystem::setFlagPlanets(bool b)
{ {
skipping to change at line 1322 skipping to change at line 1492
foreach (Orbit* orb, orbits) foreach (Orbit* orb, orbits)
{ {
delete orb; delete orb;
orb = NULL; orb = NULL;
} }
orbits.clear(); orbits.clear();
sun.clear(); sun.clear();
moon.clear(); moon.clear();
earth.clear(); earth.clear();
Planet::texEarthShadow.clear(); //Loaded in loadPlanets()
delete allTrails; delete allTrails;
allTrails = NULL; allTrails = NULL;
foreach (PlanetP p, systemPlanets) foreach (PlanetP p, systemPlanets)
{ {
p->satellites.clear(); p->satellites.clear();
p.clear(); p.clear();
} }
systemPlanets.clear(); systemPlanets.clear();
skipping to change at line 1355 skipping to change at line 1524
setFlagMoonScale(flagScaleMoon); setFlagMoonScale(flagScaleMoon);
setMoonScale(moonScale); setMoonScale(moonScale);
setFlagPlanets(flagPlanets); setFlagPlanets(flagPlanets);
setFlagHints(flagHints); setFlagHints(flagHints);
setFlagLabels(flagLabels); setFlagLabels(flagLabels);
setFlagOrbits(flagOrbits); setFlagOrbits(flagOrbits);
// Restore translations // Restore translations
updateI18n(); updateI18n();
} }
double SolarSystem::getEclipseFactor(const StelCore* core) const
{
Vec3d Lp = sun->getEclipticPos();
Vec3d P3 = core->getObserverHeliocentricEclipticPos();
const double RS = sun->getRadius();
double final_illumination = 1.0;
foreach (const PlanetP& planet, systemPlanets)
{
if(planet == sun || planet == core->getCurrentPlanet())
continue;
Mat4d trans;
planet->computeModelMatrix(trans);
const Vec3d C = trans * Vec3d(0, 0, 0);
const double radius = planet->getRadius();
Vec3d v1 = Lp - P3;
Vec3d v2 = C - P3;
const double L = v1.length();
const double l = v2.length();
v1 = v1 / L;
v2 = v2 / l;
const double R = RS / L;
const double r = radius / l;
const double d = ( v1 - v2 ).length();
/*double L = (Lp - P3).length();
double l = (C - P3).length();
double R = RS / L;
double r = radius / l;
double d = ( (Lp - P3) / L - (C - P3) / l ).length();*/
if(planet->englishName == "Moon")
{
v1 = planet->getHeliocentricEclipticPos();
//C = planet->getHeliocentricEclipticPos();
}
double illumination;
// distance too far
if(d >= R + r)
{
illumination = 1.0;
}
// umbra
else if(r >= R + d)
{
illumination = 0.0;
}
// penumbra completely inside
else if(d + r <= R)
{
illumination = 1.0 - r * r / (R * R);
}
// penumbra partially inside
else
{
const double x = (R * R + d * d - r * r) / (2.0 * d)
;
const double alpha = std::acos(x / R);
const double beta = std::acos((d - x) / r);
const double AR = R * R * (alpha - 0.5 * std::sin(2.
0 * alpha));
const double Ar = r * r * (beta - 0.5 * std::sin(2.0
* beta));
const double AS = R * R * 2.0 * std::asin(1.0);
illumination = 1.0 - (AR + Ar) / AS;
}
if(illumination < final_illumination)
final_illumination = illumination;
}
return final_illumination;
}
 End of changes. 35 change blocks. 
49 lines changed or deleted 239 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/