Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 5c353657 authored by Bernhard Beschow's avatar Bernhard Beschow

have a twilightZone attribute in Planet to keep planet knowledge in one place

parent b802c2aa
......@@ -29,6 +29,7 @@ public:
qreal epsilon; // obliquity of the ecliptic plane
qreal theta_0, theta_1; // for calculating sidereal time
qreal radius; //in metres
qreal twilightZone;
QString name, id; //localized and nonlocalized names
bool atmosphere;
QColor atmosphereColor;
......@@ -38,6 +39,7 @@ public:
Pi(0.0), epsilon(0.0),
theta_0(0.0), theta_1(0.0),
radius(10000000.0),
twilightZone(0),
name(), id(),
atmosphere(false)
{
......@@ -140,6 +142,11 @@ qreal Planet::radius() const
return d->radius;
}
qreal Planet::twilightZone() const
{
return d->twilightZone;
}
QString Planet::name() const
{
......@@ -211,6 +218,11 @@ void Planet::setRadius( qreal radius )
d->radius = radius;
}
void Planet::setTwilightZone(qreal twilightZone)
{
d->twilightZone = twilightZone;
}
void Planet::setName( const QString& name )
{
d->name = name;
......
......@@ -70,6 +70,9 @@ public:
/// the radius of the planet, in metres
qreal radius() const;
/// the twilight zone of the planet, in radians
qreal twilightZone() const;
/** The user visible name of the planet */
QString name() const;
/** The internal, nonlocalized name of the planet */
......@@ -95,6 +98,8 @@ public:
void setRadius( qreal radius );
void setTwilightZone(qreal twilightZone);
void setName( const QString& name );
void setId( const QString& id );
......
......@@ -74,6 +74,7 @@ Planet PlanetFactory::construct( const QString &id )
planet.setTheta_0( 215.2995*DEG2RAD );
planet.setTheta_1( -1.4813688*DEG2RAD );
planet.setRadius( 6051800.0 );
planet.setTwilightZone(18*DEG2RAD);
planet.setName(QStringLiteral("Venus"));
planet.setHasAtmosphere( true );
planet.setAtmosphereColor( Oxygen::sunYellow4 );
......@@ -91,6 +92,7 @@ Planet PlanetFactory::construct( const QString &id )
planet.setTheta_0( 280.1600*DEG2RAD );
planet.setTheta_1( 360.9856235*DEG2RAD );
planet.setRadius( 6378137.0 );
planet.setTwilightZone(18*DEG2RAD);
planet.setName(QStringLiteral("Earth"));
planet.setHasAtmosphere( true );
planet.setAtmosphereColor( Qt::white );
......@@ -108,6 +110,7 @@ Planet PlanetFactory::construct( const QString &id )
planet.setTheta_0( 313.4803*DEG2RAD );
planet.setTheta_1( 350.89198226*DEG2RAD );
planet.setRadius( 3397000.0 );
planet.setTwilightZone(9.0*DEG2RAD);
planet.setName(QStringLiteral("Mars"));
planet.setHasAtmosphere( true );
planet.setAtmosphereColor( Oxygen::hotOrange2 );
......
......@@ -43,7 +43,7 @@ public:
SunLocatorPrivate( const MarbleClock *clock, const Planet *planet )
: m_lon( 0.0 ),
m_lat( 0.0 ),
m_twilightZone( 0.0 ),
m_twilightZone(planet->twilightZone()),
m_clock( clock ),
m_planet( planet )
{
......@@ -63,7 +63,6 @@ SunLocator::SunLocator( const MarbleClock *clock, const Planet *planet )
: QObject(),
d( new SunLocatorPrivate( clock, planet ))
{
updateTwilightZone();
}
SunLocator::~SunLocator()
......@@ -95,22 +94,6 @@ void SunLocator::updatePosition()
d->m_lat = lat * DEG2RAD;
}
void SunLocator::updateTwilightZone()
{
const QString planetId = d->m_planet->id();
if (planetId == QLatin1String("earth") || planetId == QLatin1String("venus")) {
d->m_twilightZone = 0.1; // this equals 18 deg astronomical twilight.
}
else if (planetId == QLatin1String("mars")) {
d->m_twilightZone = 0.05;
}
else {
d->m_twilightZone = 0.0;
}
}
qreal SunLocator::shading(qreal lon, qreal a, qreal c) const
{
// haversine formula
......@@ -208,7 +191,7 @@ void SunLocator::setPlanet( const Planet *planet )
mDebug() << "SunLocator::setPlanet(Planet*)";
d->m_planet = planet;
updateTwilightZone();
d->m_twilightZone = planet->twilightZone();
updatePosition();
// Initially there might be no planet set.
......
......@@ -54,7 +54,6 @@ class MARBLE_EXPORT SunLocator : public QObject
private:
void updatePosition();
void updateTwilightZone();
SunLocatorPrivate * const d;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment