EquationOfTime.cpp   EquationOfTime.cpp 
skipping to change at line 36 skipping to change at line 36
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelGui.hpp" #include "StelGui.hpp"
#include "StelGuiItems.hpp" #include "StelGuiItems.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "Planet.hpp" #include "Planet.hpp"
#include "EquationOfTime.hpp" #include "EquationOfTime.hpp"
#include "EquationOfTimeWindow.hpp" #include "EquationOfTimeWindow.hpp"
#include "sidereal_time.h" //#include "sidereal_time.h"
#include "precession.h"
#include <QFontMetrics> #include <QFontMetrics>
#include <QSettings> #include <QSettings>
#include <QPixmap> #include <QPixmap>
#include <cmath> #include <cmath>
StelModule* EquationOfTimeStelPluginInterface::getStelModule() const StelModule* EquationOfTimeStelPluginInterface::getStelModule() const
{ {
return new EquationOfTime(); return new EquationOfTime();
} }
skipping to change at line 116 skipping to change at line 117
void EquationOfTime::deinit() void EquationOfTime::deinit()
{ {
// //
} }
void EquationOfTime::draw(StelCore *core) void EquationOfTime::draw(StelCore *core)
{ {
if (!isEnabled()) if (!isEnabled())
return; return;
if (core->getCurrentPlanet()->getEnglishName()!="Earth")
return;
StelPainter sPainter(core->getProjection2d()); StelPainter sPainter(core->getProjection2d());
sPainter.setColor(textColor[0], textColor[1], textColor[2], 1.f); sPainter.setColor(textColor[0], textColor[1], textColor[2], 1.f);
font.setPixelSize(getFontSize()); font.setPixelSize(getFontSize());
sPainter.setFont(font); sPainter.setFont(font);
QString timeText; QString timeText;
double time = getSolutionEquationOfTime(core->getJDay()); double eqTime = getSolutionEquationOfTime(core->getJDE());
if (getFlagInvertedValue()) if (getFlagInvertedValue())
time *= -1; eqTime *= -1;
if (getFlagMsFormat()) if (getFlagMsFormat())
{ {
int seconds = qRound((time - (int)time)*60); int seconds = qRound((eqTime - (int)eqTime)*60);
QString messageSecondsValue = QString("%1").arg(qAbs(seconds ), 2, 10, QLatin1Char('0')); QString messageSecondsValue = QString("%1").arg(qAbs(seconds ), 2, 10, QLatin1Char('0'));
timeText = QString("%1: %2%3%4%5%6").arg(messageEquation, (t ime<0? QString(QLatin1Char('-')):QString()), QString::number((int)qAbs(time )), messageEquationMinutes, messageSecondsValue, messageEquationSeconds); timeText = QString("%1: %2%3%4%5%6").arg(messageEquation, (e qTime<0? QString(QLatin1Char('-')):QString()), QString::number((int)qAbs(eq Time)), messageEquationMinutes, messageSecondsValue, messageEquationSeconds );
} }
else else
timeText = QString("%1: %2%3").arg(messageEquation, QString: :number(time, 'f', 2), messageEquationMinutes); timeText = QString("%1: %2%3").arg(messageEquation, QString: :number(eqTime, 'f', 2), messageEquationMinutes);
QFontMetrics fm(font); QFontMetrics fm(font);
QSize fs = fm.size(Qt::TextSingleLine, timeText); QSize fs = fm.size(Qt::TextSingleLine, timeText);
if (core->getCurrentPlanet().data()->getEnglishName()=="Earth")
sPainter.drawText(gui->getSkyGui()->getSkyGuiWidth()/2 - fs. sPainter.drawText(gui->getSkyGui()->getSkyGuiWidth()/2 - fs.width()/
width()/2, gui->getSkyGui()->getSkyGuiHeight() - fs.height()*1.5, timeText) 2, gui->getSkyGui()->getSkyGuiHeight() - fs.height()*1.5, timeText);
;
//qDebug() << timeText; //qDebug() << timeText;
} }
double EquationOfTime::getCallOrder(StelModuleActionName actionName) const double EquationOfTime::getCallOrder(StelModuleActionName actionName) const
{ {
if (actionName==StelModule::ActionDraw) if (actionName==StelModule::ActionDraw)
return StelApp::getInstance().getModuleMgr().getModule("Land scapeMgr")->getCallOrder(actionName)+10.; return StelApp::getInstance().getModuleMgr().getModule("Land scapeMgr")->getCallOrder(actionName)+10.;
return 0; return 0;
} }
skipping to change at line 214 skipping to change at line 217
conf->setValue("enable_at_startup", getFlagEnableAtStartup()); conf->setValue("enable_at_startup", getFlagEnableAtStartup());
conf->setValue("flag_use_ms_format", getFlagMsFormat()); conf->setValue("flag_use_ms_format", getFlagMsFormat());
conf->setValue("flag_use_inverted_value", getFlagInvertedValue()); conf->setValue("flag_use_inverted_value", getFlagInvertedValue());
conf->setValue("flag_show_button", getFlagShowEOTButton()); conf->setValue("flag_show_button", getFlagShowEOTButton());
//conf->setValue("text_color", "0,0.5,1"); //conf->setValue("text_color", "0,0.5,1");
conf->setValue("font_size", getFontSize()); conf->setValue("font_size", getFontSize());
conf->endGroup(); conf->endGroup();
} }
double EquationOfTime::getSolutionEquationOfTime(const double JDay) const double EquationOfTime::getSolutionEquationOfTime(const double JDE) const
{ {
StelCore* core = StelApp::getInstance().getCore(); StelCore* core = StelApp::getInstance().getCore();
double tau = (JDay - 2451545.0)/365250.0; double tau = (JDE - 2451545.0)/365250.0;
double sunMeanLongitude = 280.4664567 + tau*(360007.6892779 + tau*(0 .03032028 + tau*(1./49931. - tau*(1./15300. - tau/2000000.)))); double sunMeanLongitude = 280.4664567 + tau*(360007.6892779 + tau*(0 .03032028 + tau*(1./49931. - tau*(1./15300. - tau/2000000.))));
// reduce the angle // reduce the angle
sunMeanLongitude = std::fmod(sunMeanLongitude, 360.); sunMeanLongitude = std::fmod(sunMeanLongitude, 360.);
// force it to be the positive remainder, so that 0 <= angle < 360 // force it to be the positive remainder, so that 0 <= angle < 360
sunMeanLongitude = std::fmod(sunMeanLongitude + 360., 360.); sunMeanLongitude = std::fmod(sunMeanLongitude + 360., 360.);
Vec3d pos = GETSTELMODULE(StelObjectMgr)->searchByName("Sun")->getEq uinoxEquatorialPos(core); Vec3d pos = GETSTELMODULE(StelObjectMgr)->searchByName("Sun")->getEq uinoxEquatorialPos(core);
double ra, dec; double ra, dec;
StelUtils::rectToSphe(&ra, &dec, pos); StelUtils::rectToSphe(&ra, &dec, pos);
// covert radians to degrees and reduce the angle // covert radians to degrees and reduce the angle
double alpha = std::fmod(ra*180./M_PI, 360.); double alpha = std::fmod(ra*180./M_PI, 360.);
// force it to be the positive remainder, so that 0 <= angle < 360 // force it to be the positive remainder, so that 0 <= angle < 360
alpha = std::fmod(alpha + 360., 360.); alpha = std::fmod(alpha + 360., 360.);
double equation = 4*(sunMeanLongitude - 0.0057183 - alpha + get_nuta double deltaPsi, deltaEps;
tion_longitude(JDay)*cos(get_mean_ecliptical_obliquity(JDay))); getNutationAngles(JDE, &deltaPsi, &deltaEps); // these are radians!
//double equation = 4*(sunMeanLongitude - 0.0057183 - alpha + get_nu
tation_longitude(JDE)*cos(get_mean_ecliptical_obliquity(JDE)));
double equation = 4*(sunMeanLongitude - 0.0057183 - alpha + deltaPsi
*180./M_PI*cos(getPrecessionAngleVondrakEpsilon(JDE)));
// The equation of time is always smaller 20 minutes in absolute val ue // The equation of time is always smaller 20 minutes in absolute val ue
if (qAbs(equation)>20) if (qAbs(equation)>20)
{ {
// If absolute value of the equation of time appears to be t oo large, add 24 hours (1440 minutes) to or subtract it from our result // If absolute value of the equation of time appears to be t oo large, add 24 hours (1440 minutes) to or subtract it from our result
if (equation>0.) if (equation>0.)
equation -= 1440.; equation -= 1440.;
else else
equation += 1440.; equation += 1440.;
} }
 End of changes. 11 change blocks. 
14 lines changed or deleted 20 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/