From kde-commits Tue Dec 31 21:00:31 2013 From: Torsten Rahn Date: Tue, 31 Dec 2013 21:00:31 +0000 To: kde-commits Subject: [marble] src/plugins/render/stars: More integration with astrolib: Use SolarSystem::getPlanetocentri Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=138852364428637 Git commit e0c9c1999ad13f0e36df4d59e75e7f259765c5f4 by Torsten Rahn. Committed on 31/12/2013 at 20:57. Pushed by rahn into branch 'master'. More integration with astrolib: Use SolarSystem::getPlanetocentric instead of the Earth-specific siderealTime code. This prepares for making the stars plugin work for other planets. M +13 -31 src/plugins/render/stars/StarsPlugin.cpp M +0 -2 src/plugins/render/stars/StarsPlugin.h http://commits.kde.org/marble/e0c9c1999ad13f0e36df4d59e75e7f259765c5f4 diff --git a/src/plugins/render/stars/StarsPlugin.cpp b/src/plugins/render/= stars/StarsPlugin.cpp index 2e7c905..93f5a32 100644 --- a/src/plugins/render/stars/StarsPlugin.cpp +++ b/src/plugins/render/stars/StarsPlugin.cpp @@ -751,9 +751,10 @@ bool StarsPlugin::render( GeoPainter *painter, Viewpor= tParams *viewport, Q_UNUSED( renderPos ) Q_UNUSED( layer ) = + QString planetId =3D marbleModel()->planetId(); const bool doRender =3D !viewport->mapCoversViewport() && viewport->projection() =3D=3D Spherical && - marbleModel()->planetId() =3D=3D "earth"; // = So far displaying stars is only supported on earth. + planetId =3D=3D "earth"; // So far displaying= stars is only supported on earth. = if ( doRender !=3D m_doRender ) { if ( doRender ) { @@ -769,10 +770,18 @@ bool StarsPlugin::render( GeoPainter *painter, Viewpo= rtParams *viewport, = painter->save(); = - QDateTime currentDateTime =3D marbleModel()->clockDateTime(); + SolarSystem sys; + QDateTime dateTime =3D marbleModel()->clock()->dateTime(); + sys.setCurrentMJD( + dateTime.date().year(), dateTime.date().month(), dateTime.= date().day(), + dateTime.time().hour(), dateTime.time().minute(), + (double)dateTime.time().second()); + QString pname =3D planetId.at(0).toUpper() + planetId.right(planetId.s= ize() - 1); + char *centralBody =3D pname.toLatin1().data(); + sys.setCentralBody( centralBody ); = - qreal gmst =3D siderealTime( currentDateTime ); - qreal skyRotationAngle =3D gmst / 12.0 * M_PI; + Vec3 skyVector =3D sys.getPlanetocentric (0.0, 0.0); + qreal skyRotationAngle =3D -atan2(skyVector[1], skyVector[0]); = const qreal centerLon =3D viewport->centerLongitude(); const qreal centerLat =3D viewport->centerLatitude(); @@ -1064,15 +1073,6 @@ bool StarsPlugin::render( GeoPainter *painter, Viewp= ortParams *viewport, } } = - SolarSystem sys; - QDateTime dateTime =3D marbleModel()->clock()->dateTime(); - sys.setCurrentMJD( - dateTime.date().year(), dateTime.date().month(), dateT= ime.date().day(), - dateTime.time().hour(), dateTime.time().minute(), - (double)dateTime.time().second()); - char *centralBody =3D QString("Earth").toLatin1().data(); - sys.setCentralBody( centralBody ); - if ( m_renderSun ) { // sun double ra =3D 0.0; @@ -1290,24 +1290,6 @@ bool StarsPlugin::render( GeoPainter *painter, Viewp= ortParams *viewport, return true; } = -qreal StarsPlugin::siderealTime( const QDateTime& localDateTime ) -{ - QDateTime utcDateTime =3D localDateTime.toTimeSpec( Qt::UTC ); - qreal mjdUtc =3D ( qreal )( utcDateTime.date().toJulianDay() ); - - qreal offsetUtcSecs =3D -utcDateTime.time().secsTo( QTime( 00, 00 ) ); - qreal d_days =3D mjdUtc - 2451545.5; - qreal d =3D d_days + ( offsetUtcSecs / ( 24.0 * 3600 ) ); - - // Appendix A of USNO Circular No. 163 (1981): - // Approximate value for Greenwich mean sidereal time in hours: - // (Loss of precision: 0.1 secs per century) - qreal gmst =3D 18.697374558 + 24.06570982441908 * d; - - // Range (0..24) for gmst: - return gmst - ( int )( gmst / 24.0 ) * 24.0; -} - void StarsPlugin::requestRepaint() { emit repaintNeeded( QRegion() ); diff --git a/src/plugins/render/stars/StarsPlugin.h b/src/plugins/render/st= ars/StarsPlugin.h index 1f2297c..52fd890 100644 --- a/src/plugins/render/stars/StarsPlugin.h +++ b/src/plugins/render/stars/StarsPlugin.h @@ -204,8 +204,6 @@ private: QHash m_nativeHash; int m_nameIndex; = - // sidereal time in hours: - qreal siderealTime( const QDateTime& ); void createStarPixmaps(); void loadStars(); void loadConstellations();