Observability.cpp   Observability.cpp 
skipping to change at line 22 skipping to change at line 22
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#include <QSettings> #include <QSettings>
#include <QPixmap> #include <QPixmap>
#include <QTimer> #include <QTimer>
#include <QtOpenGL>
#include <QString> #include <QString>
#include <QDebug> #include <QDebug>
#include <QAction> #include <QAction>
#include <QKeyEvent> #include <QKeyEvent>
#include <QtNetwork> #include <QtNetwork>
#include <QKeyEvent> #include <QKeyEvent>
#include <QMouseEvent> #include <QMouseEvent>
#include "renderer/StelRenderer.hpp"
#include "StelIniParser.hpp" #include "StelIniParser.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StarMgr.hpp" #include "StarMgr.hpp"
#include "StelObject.hpp" #include "StelObject.hpp"
#include "StelObserver.hpp" #include "StelObserver.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelGui.hpp" #include "StelGui.hpp"
#include "StelGuiItems.hpp" #include "StelGuiItems.hpp"
#include "StelMovementMgr.hpp" #include "StelMovementMgr.hpp"
#include "StelFileMgr.hpp" #include "StelFileMgr.hpp"
#include "StelVertexArray.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelPainter.hpp"
#include "ZoneArray.hpp" #include "ZoneArray.hpp"
#include "StelSkyDrawer.hpp" #include "StelSkyDrawer.hpp"
#include "Observability.hpp" #include "Observability.hpp"
#include "ObservabilityDialog.hpp" #include "ObservabilityDialog.hpp"
#include "SolarSystem.hpp" #include "SolarSystem.hpp"
#include "Planet.hpp" #include "Planet.hpp"
#include "StelFader.hpp" #include "StelFader.hpp"
StelModule* ObservabilityStelPluginInterface::getStelModule() const StelModule* ObservabilityStelPluginInterface::getStelModule() const
skipping to change at line 95 skipping to change at line 93
Rad2Hr = 12./3.1415927; // Convert hours into radians Rad2Hr = 12./3.1415927; // Convert hours into radians
UA = 1.4958e+8; // Astronomical Unit in Km. UA = 1.4958e+8; // Astronomical Unit in Km.
TFrac = 0.9972677595628414; // Convert sidereal time into Solar tim e TFrac = 0.9972677595628414; // Convert sidereal time into Solar tim e
JDsec = 1./86400.; // A second in days. JDsec = 1./86400.; // A second in days.
halfpi = 1.57079632675; // pi/2 halfpi = 1.57079632675; // pi/2
MoonT = 29.530588; // Moon synodic period (used as first estimate of Full Moon). MoonT = 29.530588; // Moon synodic period (used as first estimate of Full Moon).
RefFullMoon = 2451564.696; // Reference Julian date of a Full Moon. RefFullMoon = 2451564.696; // Reference Julian date of a Full Moon.
MoonPerilune = 0.0024236308; // Smallest Earth-Moon distance (in AU) . MoonPerilune = 0.0024236308; // Smallest Earth-Moon distance (in AU) .
nextFullMoon = 0.0; nextFullMoon = 0.0;
prevFullMoon = 0.0; prevFullMoon = 0.0;
RefracHoriz = 0.0; // Geometric altitude at refraction-corrected h orizon.
selName = ""; selName = "";
//////////////////////////// ////////////////////////////
// Read configuration: // Read configuration:
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
// Setup defaults if not present // Setup defaults if not present
if (!conf->contains("Observability/font_size")) conf->beginGroup("Observability");
conf->setValue("Observability/font_size", 15); if (!conf->contains("font_size"))
conf->setValue("font_size", 15);
if (!conf->contains("Observability/font_color")) if (!conf->contains("font_color"))
conf->setValue("Observability/font_color", "0,0.5,1"); conf->setValue("font_color", "0,0.5,1");
if (!conf->contains("Observability/show_AcroCos")) if (!conf->contains("show_AcroCos"))
conf->setValue("Observability/show_AcroCos", true); conf->setValue("show_AcroCos", true);
if (!conf->contains("Observability/show_Good_Nights")) if (!conf->contains("show_Good_Nights"))
conf->setValue("Observability/show_Good_Nights", true); conf->setValue("show_Good_Nights", true);
if (!conf->contains("Observability/show_Best_Night")) if (!conf->contains("show_Best_Night"))
conf->setValue("Observability/show_Best_Night", true); conf->setValue("show_Best_Night", true);
if (!conf->contains("Observability/show_Today")) if (!conf->contains("show_Today"))
conf->setValue("Observability/show_Today", true); conf->setValue("show_Today", true);
if (!conf->contains("Observability/Sun_Altitude")) if (!conf->contains("Sun_Altitude"))
conf->setValue("Observability/Sun_Altitude", 12); conf->setValue("Sun_Altitude", 12);
if (!conf->contains("Observability/show_FullMoon")) if (!conf->contains("Horizon_Altitude"))
conf->setValue("Observability/show_FullMoon", true); conf->setValue("Horizon_Altitude", 0);
// if (!conf->contains("Observability/show_Crescent")) if (!conf->contains("show_FullMoon"))
// conf->setValue("Observability/show_Crescent", true); conf->setValue("show_FullMoon", true);
// if (!conf->contains("Observability/show_SuperMoon")) // if (!conf->contains("show_Crescent"))
// conf->setValue("Observability/show_SuperMoon", true); // conf->setValue("show_Crescent", true);
// if (!conf->contains("show_SuperMoon"))
// conf->setValue("show_SuperMoon", true);
// Load settings from main config file // Load settings from main config file
fontSize = conf->value("Observability/font_size",15).toInt(); fontSize = conf->value("font_size",15).toInt();
iAltitude = conf->value("Observability/Sun_Altitude",12).toInt(); iAltitude = conf->value("Sun_Altitude",12).toInt();
iHorizAltitude = conf->value("Horizon_Altitude",0).toInt();
AstroTwiAlti = -((double) iAltitude)/Rad2Deg ; AstroTwiAlti = -((double) iAltitude)/Rad2Deg ;
HorizAlti = ((double) iHorizAltitude)/Rad2Deg ;
font.setPixelSize(fontSize); font.setPixelSize(fontSize);
QString fontColorStr = conf->value("Observability/font_color", "0,0. 5,1").toString(); QString fontColorStr = conf->value("font_color", "0,0.5,1").toString ();
fontColor = StelUtils::strToVec3f(fontColorStr); fontColor = StelUtils::strToVec3f(fontColorStr);
show_AcroCos = conf->value("Observability/show_AcroCos", true).toBoo show_AcroCos = conf->value("show_AcroCos", true).toBool();
l(); show_Good_Nights = conf->value("show_Good_Nights", true).toBool();
show_Good_Nights = conf->value("Observability/show_Good_Nights", tru show_Best_Night = conf->value("show_Best_Night", true).toBool();
e).toBool(); show_Today = conf->value("show_Today", true).toBool();
show_Best_Night = conf->value("Observability/show_Best_Night", true) show_FullMoon = conf->value("show_FullMoon", true).toBool();
.toBool(); // show_Crescent = conf->value("show_Crescent", true).toBool();
show_Today = conf->value("Observability/show_Today", true).toBool(); // show_SuperMoon = conf->value("show_SuperMoon", true).toBool();
show_FullMoon = conf->value("Observability/show_FullMoon", true).toB
ool();
// show_Crescent = conf->value("Observability/show_Crescent", true).toB
ool();
// show_SuperMoon = conf->value("Observability/show_SuperMoon", true).t
oBool();
conf->endGroup();
///////////////////////////////// /////////////////////////////////
// Dummy initial values for parameters and data vectors: // Dummy initial values for parameters and data vectors:
mylat = 1000.; mylon = 1000.; mylat = 1000.; mylon = 1000.;
myJD = 0.0; myJD = 0.0;
currYear = 0; currYear = 0;
isStar = true; isStar = true;
isMoon = false; isMoon = false;
isSun = false; isSun = false;
isScreen = true; isScreen = true;
skipping to change at line 216 skipping to change at line 222
{ {
qDebug() << "init called for Observability"; qDebug() << "init called for Observability";
try try
{ {
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance() .getGui()); StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance() .getGui());
GlowIcon = new QPixmap(":/graphicGui/glow32x32.png"); GlowIcon = new QPixmap(":/graphicGui/glow32x32.png");
OnIcon = new QPixmap(":/observability/bt_observab_on.png"); OnIcon = new QPixmap(":/observability/bt_observab_on.png");
OffIcon = new QPixmap(":/observability/bt_observab_off.png") ; OffIcon = new QPixmap(":/observability/bt_observab_off.png") ;
gui->addGuiActions("actionShow_Observability",N_("Observabil gui->getGuiAction("actionShow_Observability")->setChecked(fl
ity"),"",N_("Plugin Key Bindings"),true, false); agShowObservability);
gui->getGuiActions("actionShow_Observability")->setChecked(f toolbarButton = new StelButton(NULL, *OnIcon, *OffIcon, *Glo
lagShowObservability); wIcon, gui->getGuiAction("actionShow_Observability"));
toolbarButton = new StelButton(NULL, *OnIcon, *OffIcon, *Glo
wIcon, gui->getGuiActions("actionShow_Observability"));
gui->getButtonBar()->addButton(toolbarButton, "065-pluginsGr oup"); gui->getButtonBar()->addButton(toolbarButton, "065-pluginsGr oup");
connect(gui->getGuiActions("actionShow_Observability"), SIGN connect(gui->getGuiAction("actionShow_Observability"), SIGNA
AL(toggled(bool)), this, SLOT(enableObservability(bool))); L(toggled(bool)), this, SLOT(enableObservability(bool)));
connect(gui->getGuiAction("actionShow_Observability_ConfigDi
gui->addGuiActions("actionShow_Observability_ConfigDialog", alog"), SIGNAL(toggled(bool)), configDialog, SLOT(setVisible(bool)));
N_("Observability configuration window"), "",N_("Plugin Key Bindings"), tru connect(configDialog, SIGNAL(visibleChanged(bool)), gui->get
e); GuiAction("actionShow_Observability_ConfigDialog"), SLOT(setChecked(bool)))
connect(gui->getGuiActions("actionShow_Observability_ConfigD ;
ialog"), SIGNAL(toggled(bool)), configDialog, SLOT(setVisible(bool)));
connect(configDialog, SIGNAL(visibleChanged(bool)), gui->get
GuiActions("actionShow_Observability_ConfigDialog"), SLOT(setChecked(bool))
);
} }
catch (std::exception &e) catch (std::exception &e)
{ {
qWarning() << "WARNING: unable create toolbar button for Obs ervability plugin (or load gonfig GUI). " << e.what(); qWarning() << "WARNING: unable create toolbar button for Obs ervability plugin (or load gonfig GUI). " << e.what();
}; };
} }
///////////////////////////////////////////// /////////////////////////////////////////////
// MAIN CODE: // MAIN CODE:
void Observability::draw(StelCore* core) void Observability::draw(StelCore* core, StelRenderer* renderer)
{ {
if (!flagShowObservability) return; // Button is off. if (!flagShowObservability) return; // Button is off.
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// PRELIMINARS: // PRELIMINARS:
bool locChanged, yearChanged; bool locChanged, yearChanged;
StelObjectP selectedObject; StelObjectP selectedObject;
Planet* currPlanet; Planet* currPlanet;
PlanetP Object, parent; PlanetP Object, parent;
// Only execute plugin if we are on Earth. // Only execute plugin if we are on Earth.
if (core->getCurrentLocation().planetName != "Earth") {return;}; if (core->getCurrentLocation().planetName != "Earth") {return;};
// Set the painter: // Set the painter:
StelPainter paintresult(core->getProjection2d()); StelProjectorP projector = core->getProjection2d();
paintresult.setColor(fontColor[0],fontColor[1],fontColor[2],1); renderer->setGlobalColor(fontColor[0],fontColor[1],fontColor[2],1);
font.setPixelSize(fontSize); font.setPixelSize(fontSize);
paintresult.setFont(font); renderer->setFont(font);
// Get current date, location, and check if there is something selected. // Get current date, location, and check if there is something selected.
double currlat = (core->getCurrentLocation().latitude)/Rad2Deg; double currlat = (core->getCurrentLocation().latitude)/Rad2Deg;
double currlon = (core->getCurrentLocation().longitude)/Rad2Deg; double currlon = (core->getCurrentLocation().longitude)/Rad2Deg;
double currheight = (6371.+(core->getCurrentLocation().altitude)/100 0.)/UA; double currheight = (6371.+(core->getCurrentLocation().altitude)/100 0.)/UA;
double currJD = core->getJDay(); double currJD = core->getJDay();
double currJDint; double currJDint;
// GMTShift = StelUtils::getGMTShiftFromQT(currJD)/24.0;
GMTShift = StelApp::getInstance().getLocaleMgr().getGMTShift(currJD) /24.0; GMTShift = StelApp::getInstance().getLocaleMgr().getGMTShift(currJD) /24.0;
// qDebug() << QString("%1%2 ").arg(GMTShift);
double currLocalT = 24.*modf(currJD + GMTShift,&currJDint); double currLocalT = 24.*modf(currJD + GMTShift,&currJDint);
int auxm, auxd, auxy; int auxm, auxd, auxy;
StelUtils::getDateFromJulianDay(currJD,&auxy,&auxm,&auxd); StelUtils::getDateFromJulianDay(currJD,&auxy,&auxm,&auxd);
bool isSource = StelApp::getInstance().getStelObjectMgr().getWasSele cted(); bool isSource = StelApp::getInstance().getStelObjectMgr().getWasSele cted();
bool show_Year = show_Best_Night || show_Good_Nights || show_AcroCos ; bool show_Year = show_Best_Night || show_Good_Nights || show_AcroCos ;
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
skipping to change at line 298 skipping to change at line 305
locChanged = false;} locChanged = false;}
else { else {
locChanged = true; locChanged = true;
mylat = currlat; mylon = currlon; mylat = currlat; mylon = currlon;
double temp1 = currheight*std::cos(currlat); double temp1 = currheight*std::cos(currlat);
ObserverLoc[0] = temp1*std::cos(currlon); ObserverLoc[0] = temp1*std::cos(currlon);
ObserverLoc[1] = temp1*std::sin(currlon); ObserverLoc[1] = temp1*std::sin(currlon);
ObserverLoc[2] = currheight*std::sin(currlat); ObserverLoc[2] = currheight*std::sin(currlat);
}; };
// Add refraction, if necessary:
Vec3d TempRefr;
TempRefr[0] = std::cos(HorizAlti);
TempRefr[1] = 0.0;
TempRefr[2] = std::sin(HorizAlti);
Vec3d CorrRefr = core->altAzToEquinoxEqu(TempRefr,StelCore::Refracti
onAuto);
TempRefr = core->equinoxEquToAltAz(CorrRefr,StelCore::RefractionOff)
;
double RefracAlt = std::asin(TempRefr[2]);
if (std::abs(RefracHoriz-RefracAlt)>2.91e-4) // Diference larger th
an 1 arcminute.
{ // Configuration for refraction changed notably:
RefracHoriz = RefracAlt;
configChanged = true;
souChanged = true;
};
// If we have changed latitude (or year), we update the vector of Sun's hou r // If we have changed latitude (or year), we update the vector of Sun's hou r
// angles at twilight, and re-compute Sun/Moon ephemeris (if selected): // angles at twilight, and re-compute Sun/Moon ephemeris (if selected):
if (locChanged || yearChanged || configChanged) if (locChanged || yearChanged || configChanged)
{ {
SunHTwi(); SunHTwi();
lastJDMoon = 0.0; lastJDMoon = 0.0;
}; };
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
skipping to change at line 402 skipping to change at line 425
{ {
souChanged=true; souChanged=true;
configChanged=false; configChanged=false;
}; };
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// NOW WE COMPUTE RISE/SET/TRANSIT TIMES FOR THE CURRENT DAY: // NOW WE COMPUTE RISE/SET/TRANSIT TIMES FOR THE CURRENT DAY:
double currH = HourAngle(mylat,alti,selDec); double currH = HourAngle(mylat,alti,selDec);
horizH = HourAngle(mylat,0.0,selDec); horizH = HourAngle(mylat,RefracHoriz,selDec);
QString RS1, RS2, Cul; // strings with Rise/Set/Culmination times QString RS1, RS2, Cul; // strings with Rise/Set/Culmination times
double Rise, Set; // Actual Rise/Set times (in GMT). double Rise, Set; // Actual Rise/Set times (in GMT).
int d1,m1,s1,d2,m2,s2,dc,mc,sc; // Integers for the time spans in hh :mm:ss. int d1,m1,s1,d2,m2,s2,dc,mc,sc; // Integers for the time spans in hh :mm:ss.
bool solvedMoon = false; // Check if solutions were found for Sun, M oon, or planet. bool solvedMoon = false; // Check if solutions were found for Sun, M oon, or planet.
bool transit = false; // Is the source above the horizon? Did it cul minate? bool transit = false; // Is the source above the horizon? Did it cul minate?
int ephHour, ephMinute, ephSecond; // Local time for selected ephem eris int ephHour, ephMinute, ephSecond; // Local time for selected ephem eris
if (show_Today) { // We show ephemeris for today (i.e., rise, set, and transit times). if (show_Today) { // We show ephemeris for today (i.e., rise, set, and transit times).
skipping to change at line 482 skipping to change at line 505
SetTime = QString("%1:%2").arg(ephHour).arg( ephMinute,2,10,QLatin1Char('0')); SetTime = QString("%1:%2").arg(ephHour).arg( ephMinute,2,10,QLatin1Char('0'));
double2hms(toUnsignedRA(currLocalT+TFrac*Ri se+12.),ephHour,ephMinute,ephSecond); double2hms(toUnsignedRA(currLocalT+TFrac*Ri se+12.),ephHour,ephMinute,ephSecond);
RiseTime = QString("%1:%2").arg(ephHour).arg (ephMinute,2,10,QLatin1Char('0')); RiseTime = QString("%1:%2").arg(ephHour).arg (ephMinute,2,10,QLatin1Char('0'));
RS1 = q_("Set at %1 (%2 ago)").arg(SetTime). arg(RS1); RS1 = q_("Set at %1 (%2 ago)").arg(SetTime). arg(RS1);
RS2 = q_("Rises at %1 (in %2)").arg(RiseTime ).arg(RS2); RS2 = q_("Rises at %1 (in %2)").arg(RiseTime ).arg(RS2);
}; };
} }
else { // The source is either circumpolar or never rises: else { // The source is either circumpolar or never rises:
(alti>0.0)? RS1 = q_("Circumpolar."): RS1 = q_("No r ise."); (alti>RefracHoriz)? RS1 = q_("Circumpolar."): RS1 = q_("No rise.");
RS2 = ""; RS2 = "";
}; };
// Culmination: // Culmination:
if (isStar) if (isStar)
{ {
culmAlt = std::abs(mylat-selDec); // 90.-altitude at transit . culmAlt = std::abs(mylat-selDec); // 90.-altitude at transit .
transit = LocPos[1]<0.0; transit = LocPos[1]<0.0;
}; };
if (culmAlt<halfpi) { // Source can be observed. if (culmAlt<halfpi-RefracHoriz) { // Source can be observed.
double altiAtCulmi = Rad2Deg*(halfpi-culmAlt); double altiAtCulmi = Rad2Deg*(halfpi-culmAlt-RefracHoriz);
double2hms(TFrac*currH,dc,mc,sc); double2hms(TFrac*currH,dc,mc,sc);
// String with the time span for culmination: // String with the time span for culmination:
Cul = (dc==0)?"":QString("%1%2 ").arg(dc).arg(q_("h")); Cul += (mc==0)?"":QString("%1%2 ").arg(mc).arg(q_("m")); Cul += QString("%1%2") .arg(sc).arg(q_("s")); Cul = (dc==0)?"":QString("%1%2 ").arg(dc).arg(q_("h")); Cul += (mc==0)?"":QString("%1%2 ").arg(mc).arg(q_("m")); Cul += QString("%1%2") .arg(sc).arg(q_("s"));
if (transit==false) { if (transit==false) {
double2hms(toUnsignedRA(currLocalT+TFrac*currH+12.) ,ephHour,ephMinute,ephSecond); // Local time at transit. double2hms(toUnsignedRA(currLocalT+TFrac*currH+12.) ,ephHour,ephMinute,ephSecond); // Local time at transit.
CulmTime = QString("%1:%2").arg(ephHour).arg(ephMinu te,2,10,QLatin1Char('0')); CulmTime = QString("%1:%2").arg(ephHour).arg(ephMinu te,2,10,QLatin1Char('0'));
Cul = q_("Culminates at %1 (in %2) at %3 deg.").arg( CulmTime).arg(Cul).arg(altiAtCulmi,0,'f',1);} Cul = q_("Culminates at %1 (in %2) at %3 deg.").arg( CulmTime).arg(Cul).arg(altiAtCulmi,0,'f',1);}
else { else {
skipping to change at line 530 skipping to change at line 553
if (isSun) if (isSun)
{ {
bestNight=""; ObsRange = ""; bestNight=""; ObsRange = "";
} }
else if (!isMoon && show_Year) { else if (!isMoon && show_Year) {
if (isStar==false && (souChanged || yearChanged)) { // Objec t moves. if (isStar==false && (souChanged || yearChanged)) { // Objec t moves.
PlanetRADec(core);} // Re-compute ephemeris. PlanetRADec(core);} // Re-compute ephemeris.
else { // Object is fixed on the sky. else { // Object is fixed on the sky.
double auxH = HourAngle(mylat,0.0,selDec); double auxH = HourAngle(mylat,RefracHoriz,selDec);
double auxSidT1 = toUnsignedRA(selRA - auxH); double auxSidT1 = toUnsignedRA(selRA - auxH);
double auxSidT2 = toUnsignedRA(selRA + auxH); double auxSidT2 = toUnsignedRA(selRA + auxH);
for (int i=0;i<nDays;i++) { for (int i=0;i<nDays;i++) {
ObjectH0[i] = auxH; ObjectH0[i] = auxH;
ObjectRA[i] = selRA; ObjectRA[i] = selRA;
ObjectDec[i] = selDec; ObjectDec[i] = selDec;
ObjectSidT[0][i] = auxSidT1; ObjectSidT[0][i] = auxSidT1;
ObjectSidT[1][i] = auxSidT2; ObjectSidT[1][i] = auxSidT2;
}; };
}; };
// Determine source observability (only if something changed): // Determine source observability (only if something changed):
if ((souChanged || locChanged || yearChanged)) { if ((souChanged || locChanged || yearChanged)) {
bestNight=""; ObsRange = ""; bestNight=""; ObsRange = "";
if (culmAlt>=halfpi) { // Source cannot be seen. if (culmAlt>=halfpi-RefracHoriz) { // Source cannot be seen.
ObsRange = q_("Source is not observable."); ObsRange = q_("Source is not observable.");
AcroCos = q_("No Acronychal nor Cosmical ris e/set."); AcroCos = q_("No Acronychal nor Cosmical ris e/set.");
} }
else { // Source can be seen. else { // Source can be seen.
/////////////////////////// ///////////////////////////
// - Part 1. Determine the best observing night (i.e., opposition to the Su n): // - Part 1. Determine the best observing night (i.e., opposition to the Su n):
if (show_Best_Night) { if (show_Best_Night) {
int selday = 0; int selday = 0;
double deltaPhs = -1.0; // Initial d ummy value double deltaPhs = -1.0; // Initial d ummy value
skipping to change at line 583 skipping to change at line 606
/////////////////////////////// ///////////////////////////////
// - Part 2. Determine Acronychal and Cosmical rise and set: // - Part 2. Determine Acronychal and Cosmical rise and set:
if (show_AcroCos) { if (show_AcroCos) {
int selRise, selSet, selRise2, selSe t2; // days of year for Acronical and Cosmical rise/set. int selRise, selSet, selRise2, selSe t2; // days of year for Acronical and Cosmical rise/set.
int Acro = CheckAcro(selRise,selSet, selRise2,selSet2); int Acro = CheckAcro(selRise,selSet, selRise2,selSet2);
QString AcroRiseStr, AcroSetStr; QString AcroRiseStr, AcroSetStr;
QString CosmRiseStr, CosmSetStr; QString CosmRiseStr, CosmSetStr;
AcroRiseStr = (selRise>0)?CalenDate( AcroRiseStr = (selRise>0)?CalenDate(
selRise):q_("N/A"); selRise):q_("None");
AcroSetStr = (selSet>0)?CalenDate(se AcroSetStr = (selSet>0)?CalenDate(se
lSet):q_("N/A"); lSet):q_("None");
CosmRiseStr = (selRise2>0)?CalenDate CosmRiseStr = (selRise2>0)?CalenDate
(selRise2):q_("N/A"); (selRise2):q_("None");
CosmSetStr = (selSet2>0)?CalenDate(s CosmSetStr = (selSet2>0)?CalenDate(s
elSet2):q_("N/A"); elSet2):q_("None");
AcroCos = (Acro==3 || Acro==1)?QStri ng("%1: %2/%3.").arg(q_("Acronychal rise/set")).arg(AcroRiseStr).arg(AcroSe tStr):q_("No Acronychal rise/set."); AcroCos = (Acro==3 || Acro==1)?QStri ng("%1: %2/%3.").arg(q_("Acronychal rise/set")).arg(AcroRiseStr).arg(AcroSe tStr):q_("No Acronychal rise/set.");
AcroCos += (Acro==3 || Acro==2)?QStr ing(" %1: %2/%3.").arg(q_("Cosmical rise/set")).arg(CosmRiseStr).arg(CosmSe tStr):QString(" %1").arg(q_("No Cosmical rise/set.")); AcroCos += (Acro==3 || Acro==2)?QStr ing(" %1: %2/%3.").arg(q_("Cosmical rise/set")).arg(CosmRiseStr).arg(CosmSe tStr):QString(" %1").arg(q_("No Cosmical rise/set."));
}; };
//////////////////////////// ////////////////////////////
// - Part 3. Determine range of good nights // - Part 3. Determine range of good nights
// (i.e., above horizon before/after twilight): // (i.e., above horizon before/after twilight):
skipping to change at line 656 skipping to change at line 679
}; // Comes from show_Good_Nights==True" }; // Comes from show_Good_Nights==True"
}; // Comes from the "else" of "culmAlt>=..." }; // Comes from the "else" of "culmAlt>=..."
};// Comes from "souChanged || ..." };// Comes from "souChanged || ..."
}; // Comes from the "else" with "!isMoon" }; // Comes from the "else" with "!isMoon"
// Print all results: // Print all results:
int spacing = (int) (1.3* ( (double) fontSize)); // between lines int spacing = (int) (1.3* ( (double) fontSize)); // between lines
int spacing2 = 6*fontSize; // between daily and yearly results int spacing2 = 6*fontSize; // between daily and yearly results
int yLine = 8*fontSize+80; int yLine = 8*fontSize+110;
int xLine = 50; int xLine = 80;
if (show_Today) if (show_Today)
{ {
paintresult.drawText(xLine, yLine,q_("TODAY:")); renderer->drawText(TextParams(xLine, yLine,q_("TODAY:")));
paintresult.drawText(xLine+fontSize, yLine-spacing, RS2); renderer->drawText(TextParams(xLine+fontSize, yLine-spacing,
paintresult.drawText(xLine+fontSize, yLine-spacing*2, RS1); RS2));
paintresult.drawText(xLine+fontSize, yLine-spacing*3, Cul); renderer->drawText(TextParams(xLine+fontSize, yLine-spacing*
2, RS1));
renderer->drawText(TextParams(xLine+fontSize, yLine-spacing*
3, Cul));
yLine -= spacing2; yLine -= spacing2;
}; };
if ((isMoon && show_FullMoon) || (!isSun && !isMoon && show_Year)) if ((isMoon && show_FullMoon) || (!isSun && !isMoon && show_Year))
{ {
paintresult.drawText(xLine,yLine,q_("THIS YEAR:")); renderer->drawText(TextParams(xLine,yLine,q_("THIS YEAR:"))) ;
if (show_Best_Night || show_FullMoon) if (show_Best_Night || show_FullMoon)
{ {
yLine -= spacing; yLine -= spacing;
paintresult.drawText(xLine+fontSize, yLine, bestNigh t); renderer->drawText(TextParams(xLine+fontSize, yLine, bestNight));
}; };
if (show_Good_Nights) if (show_Good_Nights)
{ {
yLine -= spacing; yLine -= spacing;
paintresult.drawText(xLine+fontSize, yLine, ObsRange ); renderer->drawText(TextParams(xLine+fontSize, yLine, ObsRange));
}; };
if (show_AcroCos) if (show_AcroCos)
{ {
yLine -= spacing; yLine -= spacing;
paintresult.drawText(xLine+fontSize, yLine, AcroCos) ; renderer->drawText(TextParams(xLine+fontSize, yLine, AcroCos));
}; };
}; };
} }
// END OF MAIN CODE // END OF MAIN CODE
/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////
////////////////////////////// //////////////////////////////
skipping to change at line 811 skipping to change at line 834
// Returns the RA and Dec of the selected planet // Returns the RA and Dec of the selected planet
//for each day of the current year: //for each day of the current year:
void Observability::PlanetRADec(StelCore *core) void Observability::PlanetRADec(StelCore *core)
{ {
double TempH; double TempH;
// Compute planet's position for each day of the current year: // Compute planet's position for each day of the current year:
for (int i=0;i<nDays;i++) { for (int i=0;i<nDays;i++) {
getPlanetCoords(core,yearJD[i],ObjectRA[i],ObjectDec[i],fals e); getPlanetCoords(core,yearJD[i],ObjectRA[i],ObjectDec[i],fals e);
TempH = HourAngle(mylat,0.0,ObjectDec[i]); TempH = HourAngle(mylat,RefracHoriz,ObjectDec[i]);
ObjectH0[i] = TempH; ObjectH0[i] = TempH;
ObjectSidT[0][i] = toUnsignedRA(ObjectRA[i]-TempH); ObjectSidT[0][i] = toUnsignedRA(ObjectRA[i]-TempH);
ObjectSidT[1][i] = toUnsignedRA(ObjectRA[i]+TempH); ObjectSidT[1][i] = toUnsignedRA(ObjectRA[i]+TempH);
} }
// Return the planet to its current time: // Return the planet to its current time:
getPlanetCoords(core,myJD,ObjectRA[0],ObjectDec[0],true); getPlanetCoords(core,myJD,ObjectRA[0],ObjectDec[0],true);
} }
skipping to change at line 864 skipping to change at line 887
/////////////////////////////////////////////////// ///////////////////////////////////////////////////
//////////////////////////////////////////// ////////////////////////////////////////////
// Computes Sun's Sidereal Times at twilight and culmination: // Computes Sun's Sidereal Times at twilight and culmination:
void Observability::SunHTwi() void Observability::SunHTwi()
{ {
double TempH, TempH00; double TempH, TempH00;
for (int i=0; i<nDays; i++) { for (int i=0; i<nDays; i++) {
TempH = HourAngle(mylat,AstroTwiAlti,SunDec[i]); TempH = HourAngle(mylat,AstroTwiAlti,SunDec[i]);
TempH00 = HourAngle(mylat,0.0,SunDec[i]); TempH00 = HourAngle(mylat,RefracHoriz,SunDec[i]);
if (TempH>0.0) { if (TempH>0.0) {
SunSidT[0][i] = toUnsignedRA(SunRA[i]-TempH*(1.00278 )); SunSidT[0][i] = toUnsignedRA(SunRA[i]-TempH*(1.00278 ));
SunSidT[1][i] = toUnsignedRA(SunRA[i]+TempH*(1.00278 ));} SunSidT[1][i] = toUnsignedRA(SunRA[i]+TempH*(1.00278 ));}
else { else {
SunSidT[0][i] = -1000.0; SunSidT[0][i] = -1000.0;
SunSidT[1][i] = -1000.0;}; SunSidT[1][i] = -1000.0;};
if (TempH00>0.0) { if (TempH00>0.0) {
SunSidT[2][i] = toUnsignedRA(SunRA[i]+TempH00); SunSidT[2][i] = toUnsignedRA(SunRA[i]+TempH00);
SunSidT[3][i] = toUnsignedRA(SunRA[i]-TempH00);} SunSidT[3][i] = toUnsignedRA(SunRA[i]-TempH00);}
else { else {
skipping to change at line 996 skipping to change at line 1019
// Just return the sign of a double // Just return the sign of a double
double Observability::sign(double d) double Observability::sign(double d)
{ {
return (d<0.0)?-1.0:1.0; return (d<0.0)?-1.0:1.0;
} }
////////////////////////// //////////////////////////
////////////////////////// //////////////////////////
// Get the coordinates of Sun or Moon for a given JD: // Get the coordinates of Sun or Moon for a given JD:
// getBack controls whether Earth and Moon must be returned to their origin al positions after computation. // getBack controls whether Earth and Moon must be returned to their origin al positions after computation.
void Observability::getSunMoonCoords(StelCore *core, double JD, double &RAS un, double &DecSun, double &RAMoon, double &DecMoon, bool getBack) //, Vec3 d &AltAzVector) void Observability::getSunMoonCoords(StelCore *core, double JD, double &RAS un, double &DecSun, double &RAMoon, double &DecMoon, double &EclLon, bool g etBack) //, Vec3d &AltAzVector)
{ {
if (getBack) // Return the Moon and Earth to their current position: if (getBack) // Return the Moon and Earth to their current position:
{ {
myEarth->computePosition(JD); myEarth->computePosition(JD);
myEarth->computeTransMatrix(JD); myEarth->computeTransMatrix(JD);
myMoon->computePosition(JD); myMoon->computePosition(JD);
myMoon->computeTransMatrix(JD); myMoon->computeTransMatrix(JD);
} }
else else
skipping to change at line 1026 skipping to change at line 1049
// Moon coordinates: // Moon coordinates:
currSidT = myEarth->getSiderealTime(JD)/Rad2Deg; currSidT = myEarth->getSiderealTime(JD)/Rad2Deg;
RotObserver = (Mat4d::zrotation(currSidT))*ObserverLoc; RotObserver = (Mat4d::zrotation(currSidT))*ObserverLoc;
LocTrans = (core->matVsop87ToJ2000)*(Mat4d::translation(-Pos 0)); LocTrans = (core->matVsop87ToJ2000)*(Mat4d::translation(-Pos 0));
myMoon->computePosition(JD); myMoon->computePosition(JD);
myMoon->computeTransMatrix(JD); myMoon->computeTransMatrix(JD);
Pos1 = myMoon->getHeliocentricEclipticPos(); Pos1 = myMoon->getHeliocentricEclipticPos();
Pos2 = (core->j2000ToEquinoxEqu(LocTrans*Pos1))-RotObserver; Pos2 = (core->j2000ToEquinoxEqu(LocTrans*Pos1))-RotObserver;
EclLon = Pos1[0]*Pos0[1] - Pos1[1]*Pos0[0];
toRADec(Pos2,RAMoon,DecMoon); toRADec(Pos2,RAMoon,DecMoon);
}; };
} }
////////////////////////////////////////////// //////////////////////////////////////////////
////////////////////////// //////////////////////////
// Get the Observer-to-Moon distance JD: // Get the Observer-to-Moon distance JD:
// getBack controls whether Earth and Moon must be returned to their origin al positions after computation. // getBack controls whether Earth and Moon must be returned to their origin al positions after computation.
void Observability::getMoonDistance(StelCore *core, double JD, double &Dist ance, bool getBack) void Observability::getMoonDistance(StelCore *core, double JD, double &Dist ance, bool getBack)
{ {
skipping to change at line 1107 skipping to change at line 1132
} }
////////////////////////////////////////////// //////////////////////////////////////////////
////////////////////////////////////////////// //////////////////////////////////////////////
// Solves Moon's, Sun's, or Planet's ephemeris by bissection. Returns JD: // Solves Moon's, Sun's, or Planet's ephemeris by bissection. Returns JD:
bool Observability::SolarSystemSolve(StelCore* core, int Kind) bool Observability::SolarSystemSolve(StelCore* core, int Kind)
{ {
int Niter = 100; int Niter = 100;
int i; int i;
double Hhoriz, RA, Dec, RAS, DecS, TempH, jd1, tempEphH, currSidT; double Hhoriz, RA, Dec, RAS, DecS, TempH, jd1, tempEphH, currSidT, E clLon;
Vec3d Observer; Vec3d Observer;
Hhoriz = HourAngle(mylat,0.0,selDec); Hhoriz = HourAngle(mylat,RefracHoriz,selDec);
bool raises = Hhoriz > 0.0; bool raises = Hhoriz > 0.0;
// Only recompute ephemeris from second to second (at least) // Only recompute ephemeris from second to second (at least)
// or if the source has changed (i.e., Sun <-> Moon). This saves resources: // or if the source has changed (i.e., Sun <-> Moon). This saves resources:
if (std::abs(myJD-lastJDMoon)>JDsec || LastObject!=Kind || souChange d) if (std::abs(myJD-lastJDMoon)>JDsec || LastObject!=Kind || souChange d)
{ {
// qDebug() << q_("%1 %2 %3 %4").arg(Kind).arg(LastObject) .arg(myJD,0,'f',5).arg(lastJDMoon,0,'f',5); // qDebug() << q_("%1 %2 %3 %4").arg(Kind).arg(LastObject) .arg(myJD,0,'f',5).arg(lastJDMoon,0,'f',5);
LastObject = Kind; LastObject = Kind;
skipping to change at line 1149 skipping to change at line 1174
{ // Planet position: { // Planet position:
myPlanet->computePosition(myJD); myPlanet->computePosition(myJD);
myPlanet->computeTransMatrix(myJD); myPlanet->computeTransMatrix(myJD);
Pos1 = myPlanet->getHeliocentricEclipticPos( ); Pos1 = myPlanet->getHeliocentricEclipticPos( );
LocTrans = (core->matVsop87ToJ2000)*(Mat4d:: translation(-Pos0)); LocTrans = (core->matVsop87ToJ2000)*(Mat4d:: translation(-Pos0));
Pos2 = core->j2000ToEquinoxEqu(LocTrans*Pos1); Pos2 = core->j2000ToEquinoxEqu(LocTrans*Pos1);
}; };
toRADec(Pos2,RA,Dec); toRADec(Pos2,RA,Dec);
Vec3d MoonAltAz = core->equinoxEquToAltAz(Pos2,StelCore::Ref ractionOff); Vec3d MoonAltAz = core->equinoxEquToAltAz(Pos2,StelCore::Ref ractionOff);
raised = MoonAltAz[2] > 0.0; raised = MoonAltAz[2] > RefracHoriz;
// Initial guesses of rise/set/transit times. // Initial guesses of rise/set/transit times.
// They are called 'Moon', but are also used for the Sun or planet: // They are called 'Moon', but are also used for the Sun or planet:
double Hcurr = -HourAngle(mylat,alti,selDec)*sign(LocPos[1]) ; double Hcurr = -HourAngle(mylat,alti,selDec)*sign(LocPos[1]) ;
double SidT = toUnsignedRA(selRA + Hcurr); double SidT = toUnsignedRA(selRA + Hcurr);
MoonCulm = -Hcurr; MoonCulm = -Hcurr;
MoonRise = (-Hhoriz-Hcurr); MoonRise = (-Hhoriz-Hcurr);
MoonSet = (Hhoriz-Hcurr); MoonSet = (Hhoriz-Hcurr);
skipping to change at line 1177 skipping to change at line 1202
// Rise time: // Rise time:
tempEphH = MoonRise*TFrac; tempEphH = MoonRise*TFrac;
MoonRise = myJD + (MoonRise/24.); MoonRise = myJD + (MoonRise/24.);
for (i=0; i<Niter; i++) for (i=0; i<Niter; i++)
{ {
// Get modified coordinates: // Get modified coordinates:
jd1 = MoonRise; jd1 = MoonRise;
if (Kind<3) if (Kind<3)
{ {
getSunMoonCoords(core,jd1,RAS,DecS,R A,Dec,false); getSunMoonCoords(core,jd1,RAS,DecS,R A,Dec,EclLon,false);
} else } else
{ {
getPlanetCoords(core,jd1,RA,Dec,fals e); getPlanetCoords(core,jd1,RA,Dec,fals e);
}; };
if (Kind==1) {RA = RAS; Dec = DecS;}; if (Kind==1) {RA = RAS; Dec = DecS;};
// Current hour angle at mod. coordinates: // Current hour angle at mod. coordinates:
Hcurr = toUnsignedRA(SidT-RA); Hcurr = toUnsignedRA(SidT-RA);
Hcurr -= (raised)?0.0:24.; Hcurr -= (raised)?0.0:24.;
Hcurr -= (Hcurr>12.)?24.0:0.0; Hcurr -= (Hcurr>12.)?24.0:0.0;
// H at horizon for mod. coordinates: // H at horizon for mod. coordinates:
Hhoriz = HourAngle(mylat,0.0,Dec); Hhoriz = HourAngle(mylat,RefracHoriz,Dec);
// Compute eph. times for mod. coordinates: // Compute eph. times for mod. coordinates:
TempH = (-Hhoriz-Hcurr)*TFrac; TempH = (-Hhoriz-Hcurr)*TFrac;
if (raised==false) TempH += (TempH<0.0)?24.0 :0.0; if (raised==false) TempH += (TempH<0.0)?24.0 :0.0;
// Check convergence: // Check convergence:
if (std::abs(TempH-tempEphH)<JDsec) break; if (std::abs(TempH-tempEphH)<JDsec) break;
// Update rise-time estimate: // Update rise-time estimate:
tempEphH = TempH; tempEphH = TempH;
MoonRise = myJD + (tempEphH/24.); MoonRise = myJD + (tempEphH/24.);
}; };
// Set time: // Set time:
tempEphH = MoonSet; tempEphH = MoonSet;
MoonSet = myJD + (MoonSet/24.); MoonSet = myJD + (MoonSet/24.);
for (i=0; i<Niter; i++) for (i=0; i<Niter; i++)
{ {
// Get modified coordinates: // Get modified coordinates:
jd1 = MoonSet; jd1 = MoonSet;
if (Kind<3) if (Kind<3)
{ {
getSunMoonCoords(core,jd1,RAS,DecS,R A,Dec,false); getSunMoonCoords(core,jd1,RAS,DecS,R A,Dec,EclLon,false);
} else } else
{ {
getPlanetCoords(core,jd1,RA,Dec,fals e); getPlanetCoords(core,jd1,RA,Dec,fals e);
}; };
if (Kind==1) {RA = RAS; Dec = DecS;}; if (Kind==1) {RA = RAS; Dec = DecS;};
// Current hour angle at mod. coordinates: // Current hour angle at mod. coordinates:
Hcurr = toUnsignedRA(SidT-RA); Hcurr = toUnsignedRA(SidT-RA);
Hcurr -= (raised)?24.:0.; Hcurr -= (raised)?24.:0.;
Hcurr += (Hcurr<-12.)?24.0:0.0; Hcurr += (Hcurr<-12.)?24.0:0.0;
// H at horizon for mod. coordinates: // H at horizon for mod. coordinates:
Hhoriz = HourAngle(mylat,0.0,Dec); Hhoriz = HourAngle(mylat,RefracHoriz,Dec);
// Compute eph. times for mod. coordinates: // Compute eph. times for mod. coordinates:
TempH = (Hhoriz-Hcurr)*TFrac; TempH = (Hhoriz-Hcurr)*TFrac;
if (raised==false) TempH -= (TempH>0.0)?24.0 :0.0; if (raised==false) TempH -= (TempH>0.0)?24.0 :0.0;
// Check convergence: // Check convergence:
if (std::abs(TempH-tempEphH)<JDsec) break; if (std::abs(TempH-tempEphH)<JDsec) break;
// Update set-time estimate: // Update set-time estimate:
tempEphH = TempH; tempEphH = TempH;
MoonSet = myJD + (tempEphH/24.); MoonSet = myJD + (tempEphH/24.);
}; };
} }
skipping to change at line 1252 skipping to change at line 1277
tempEphH = MoonCulm; tempEphH = MoonCulm;
MoonCulm = myJD + (MoonCulm/24.); MoonCulm = myJD + (MoonCulm/24.);
for (i=0; i<Niter; i++) for (i=0; i<Niter; i++)
{ {
// Get modified coordinates: // Get modified coordinates:
jd1 = MoonCulm; jd1 = MoonCulm;
if (Kind<3) if (Kind<3)
{ {
getSunMoonCoords(core,jd1,RAS,DecS,R A,Dec,false); getSunMoonCoords(core,jd1,RAS,DecS,R A,Dec,EclLon,false);
} else } else
{ {
getPlanetCoords(core,jd1,RA,Dec,fals e); getPlanetCoords(core,jd1,RA,Dec,fals e);
}; };
if (Kind==1) {RA = RAS; Dec = DecS;}; if (Kind==1) {RA = RAS; Dec = DecS;};
// Current hour angle at mod. coordinates: // Current hour angle at mod. coordinates:
Hcurr = toUnsignedRA(SidT-RA); Hcurr = toUnsignedRA(SidT-RA);
Hcurr += (LocPos[1]<0.0)?24.0:-24.0; Hcurr += (LocPos[1]<0.0)?24.0:-24.0;
skipping to change at line 1276 skipping to change at line 1301
TempH = -Hcurr*TFrac; TempH = -Hcurr*TFrac;
// Check convergence: // Check convergence:
if (std::abs(TempH-tempEphH)<JDsec) break; if (std::abs(TempH-tempEphH)<JDsec) break;
tempEphH = TempH; tempEphH = TempH;
MoonCulm = myJD + (tempEphH/24.); MoonCulm = myJD + (tempEphH/24.);
culmAlt = std::abs(mylat-Dec); // 90 - altitude at t ransit. culmAlt = std::abs(mylat-Dec); // 90 - altitude at t ransit.
}; };
// qDebug() << q_("%1").arg(MoonCulm,0,'f',5); // qDebug() << q_("%1").arg(MoonCulm,0,'f',5);
lastJDMoon = myJD;
}; // Comes from if (std::abs(myJD-lastJDMoon)>JDsec || LastObject!= Kind) }; // Comes from if (std::abs(myJD-lastJDMoon)>JDsec || LastObject!= Kind)
// Find out the days of Full Moon: // Find out the days of Full Moon:
if (Kind==2 && show_FullMoon) // || show_SuperMoon)) if (Kind==2 && show_FullMoon) // || show_SuperMoon))
{ {
// Only estimate date of Full Moon if we have changed Lunar month: // Only estimate date of Full Moon if we have changed Lunar month:
if (myJD > nextFullMoon || myJD < prevFullMoon) if (myJD > nextFullMoon || myJD < prevFullMoon)
{ {
skipping to change at line 1297 skipping to change at line 1324
double nT; double nT;
double dT = std::modf((myJD-RefFullMoon)/MoonT,&nT); double dT = std::modf((myJD-RefFullMoon)/MoonT,&nT);
if (dT>0.5) {nT += 1.0;}; if (dT>0.5) {nT += 1.0;};
if (dT<-0.5) {nT -= 1.0;}; if (dT<-0.5) {nT -= 1.0;};
double TempFullMoon = RefFullMoon + nT*MoonT; double TempFullMoon = RefFullMoon + nT*MoonT;
// Improve the estimate iteratively (Secant method over Lunar-phase vs. time): // Improve the estimate iteratively (Secant method over Lunar-phase vs. time):
dT = 0.1/1440.; // 6 seconds. Our time span for the finite-difference derivative estimate. dT = 0.1/1440.; // 6 seconds. Our time span for the finite-difference derivative estimate.
double Deriv1, Deriv2; // Variables for temporal use // double Deriv1, Deriv2; // Variables for temporal use
. .
double Sec1, Sec2, SecMed, Temp1, Temp2; // Variable double Sec1, Sec2, Temp1, Temp2; // Variables for te
s for temporal use. mporal use.
double iniEst1, iniEst2; // JD values that MUST inc lude the solution within them. double iniEst1, iniEst2; // JD values that MUST inc lude the solution within them.
double Phase1, Phase2, PhaseMed; double Phase1;
for (int j=0; j<2; j++) for (int j=0; j<2; j++)
{ // Two steps: one for the previos Full Moon and th e other for the next one. { // Two steps: one for the previos Full Moon and th e other for the next one.
iniEst1 = TempFullMoon - 0.25*MoonT; iniEst1 = TempFullMoon - 0.25*MoonT;
iniEst2 = TempFullMoon + 0.25*MoonT; iniEst2 = TempFullMoon + 0.25*MoonT;
Sec1 = iniEst1; // TempFullMoon - 0.05*MoonT ; // Initial estimates of Full-Moon dates Sec1 = iniEst1; // TempFullMoon - 0.05*MoonT ; // Initial estimates of Full-Moon dates
Sec2 = iniEst2; // TempFullMoon + 0.05*MoonT ; Sec2 = iniEst2; // TempFullMoon + 0.05*MoonT ;
getSunMoonCoords(core,Sec1,RAS,DecS,RA,Dec,E
clLon,false);
Temp1 = EclLon; //Lambda(RA,Dec,RAS,DecS);
getSunMoonCoords(core,Sec2,RAS,DecS,RA,Dec,E
clLon,false);
Temp2 = EclLon; //Lambda(RA,Dec,RAS,DecS);
for (int i=0; i<100; i++) // A limit of 100 iterations. for (int i=0; i<100; i++) // A limit of 100 iterations.
{ {
getSunMoonCoords(core,Sec1+dT/2.,RAS Phase1 = (Sec2-Sec1)/(Temp1-Temp2)*
,DecS,RA,Dec,false); Temp1+Sec1;
Temp1 = Lambda(RA,Dec,RAS,DecS); getSunMoonCoords(core,Phase1,RAS,Dec
getSunMoonCoords(core,Sec1-dT/2.,RAS S,RA,Dec,EclLon,false);
,DecS,RA,Dec,false);
Temp2 = Lambda(RA,Dec,RAS,DecS);
Deriv1 = (Temp1-Temp2)/dT;
Phase1 = (Temp1+Temp2)/2.;
getSunMoonCoords(core,Sec2+dT/2.,RAS
,DecS,RA,Dec,false);
Temp1 = Lambda(RA,Dec,RAS,DecS);
getSunMoonCoords(core,Sec2-dT/2.,RAS
,DecS,RA,Dec,false);
Temp2 = Lambda(RA,Dec,RAS,DecS);
Deriv2 = (Temp1-Temp2)/dT;
Phase2 = (Temp1+Temp2)/2.;
SecMed = (Sec2+Sec1)/2.;
getSunMoonCoords(core,SecMed+dT/2.,R
AS,DecS,RA,Dec,false);
Temp1 = Lambda(RA,Dec,RAS,DecS);
getSunMoonCoords(core,SecMed-dT/2.,R
AS,DecS,RA,Dec,false);
Temp2 = Lambda(RA,Dec,RAS,DecS);
// DerivMed = (Temp1-Temp2)/dT; if (Temp1*EclLon < 0.0)
PhaseMed = (Temp1+Temp2)/2.; {
Sec2 = Phase1;
Temp2 = EclLon;
} else {
Sec1 = Phase1;
Temp1 = EclLon;
Temp1 = Sec2 - Deriv2*(Sec2-Sec1)/(D eriv2-Deriv1); };
// Force the solution to fall within // qDebug() << QString("%1 %2 %3 %4 ").
the range of good possible solutions: arg(Sec1).arg(Sec2).arg(Temp1).arg(Temp2);
if (Temp1 < iniEst1 || Temp1 > iniEs
t2) if (std::abs(Sec2-Sec1) < 10.*dT) /
{ / 1 minute accuracy; convergence.
if (Phase1>Phase2)
{
Sec2 = (Phase2 > Pha
seMed)?Sec2:SecMed;
} else
{
Sec1 = Sec2;
Sec2 = (Phase1>Phase
Med)?Sec1:SecMed;
};
} else
{ {
Sec1 = Sec2; Sec2 = Temp1; TempFullMoon = (Sec1+Sec2)/2
.;
// qDebug() << QString("%1%2 ")
.arg(TempFullMoon);
break;
}; };
if (std::abs(Sec2-Sec1) < 10.*dT) {T
empFullMoon = Temp1; break;} // 1 minute accuracy. Convergence.
}; };
if (TempFullMoon > myJD) if (TempFullMoon > myJD)
{ {
nextFullMoon = TempFullMoon; nextFullMoon = TempFullMoon;
TempFullMoon -= MoonT; TempFullMoon -= MoonT;
} else } else
{ {
prevFullMoon = TempFullMoon; prevFullMoon = TempFullMoon;
TempFullMoon += MoonT; TempFullMoon += MoonT;
skipping to change at line 1426 skipping to change at line 1435
{ {
bestNight = ""; bestNight = "";
ObsRange = ""; ObsRange = "";
AcroCos = ""; AcroCos = "";
}; };
// Return the Moon and Earth to its current position: // Return the Moon and Earth to its current position:
if (Kind<3) if (Kind<3)
{ {
getSunMoonCoords(core,myJD,RAS,DecS,RA,Dec,true); getSunMoonCoords(core,myJD,RAS,DecS,RA,Dec,EclLon,true);
} else } else
{ {
getPlanetCoords(core,myJD,RA,Dec,true); getPlanetCoords(core,myJD,RA,Dec,true);
}; };
lastJDMoon = myJD;
return raises; return raises;
} }
////////////////////////////////// //////////////////////////////////
/// STUFF FOR THE GUI CONFIG /// STUFF FOR THE GUI CONFIG
bool Observability::configureGui(bool show) bool Observability::configureGui(bool show)
{ {
if (show) if (show)
{ {
StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance() .getGui()); StelGui* gui = dynamic_cast<StelGui*>(StelApp::getInstance() .getGui());
gui->getGuiActions("actionShow_Observability_ConfigDialog")- >setChecked(true); gui->getGuiAction("actionShow_Observability_ConfigDialog")-> setChecked(true);
} }
return true; return true;
} }
void Observability::restoreDefaults(void) void Observability::restoreDefaults(void)
{ {
restoreDefaultConfigIni(); restoreDefaultConfigIni();
readSettingsFromConfig(); readSettingsFromConfig();
} }
void Observability::restoreDefaultConfigIni(void) void Observability::restoreDefaultConfigIni(void)
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
conf->beginGroup("Observability");
// delete all existing settings... // delete all existing settings...
conf->remove(""); conf->remove("");
// Set defaults // Set defaults
conf->setValue("Observability/font_size", 15); conf->setValue("font_size", 15);
conf->setValue("Observability/Sun_Altitude", 12); conf->setValue("Sun_Altitude", 12);
conf->setValue("Observability/font_color", "0,0.5,1"); conf->setValue("Horizon_Altitude", 0);
conf->setValue("Observability/show_AcroCos", true); conf->setValue("font_color", "0,0.5,1");
conf->setValue("Observability/show_Good_Nights", true); conf->setValue("show_AcroCos", true);
conf->setValue("Observability/show_Best_Night", true); conf->setValue("show_Good_Nights", true);
conf->setValue("Observability/show_Today", true); conf->setValue("show_Best_Night", true);
conf->setValue("Observability/show_FullMoon", true); conf->setValue("show_Today", true);
// conf->setValue("Observability/show_Crescent", true); conf->setValue("show_FullMoon", true);
// conf->setValue("Observability/show_SuperMoon", true); // conf->setValue("show_Crescent", true);
// conf->setValue("show_SuperMoon", true);
conf->endGroup();
} }
void Observability::readSettingsFromConfig(void) void Observability::readSettingsFromConfig(void)
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
conf->beginGroup("Observability");
// Load settings from main config file // Load settings from main config file
fontSize = conf->value("Observability/font_size",15).toInt(); fontSize = conf->value("font_size",15).toInt();
font.setPixelSize(fontSize); font.setPixelSize(fontSize);
fontColor = StelUtils::strToVec3f(conf->value("Observability/font_co fontColor = StelUtils::strToVec3f(conf->value("font_color", "0,0.5,1
lor", "0,0.5,1").toString()); ").toString());
show_AcroCos = conf->value("Observability/show_AcroCos", true).toBoo show_AcroCos = conf->value("show_AcroCos", true).toBool();
l(); show_Good_Nights = conf->value("show_Good_Nights", true).toBool();
show_Good_Nights = conf->value("Observability/show_Good_Nights", tru show_Best_Night = conf->value("show_Best_Night", true).toBool();
e).toBool(); show_Today = conf->value("show_Today", true).toBool();
show_Best_Night = conf->value("Observability/show_Best_Night", true) show_FullMoon = conf->value("show_FullMoon", true).toBool();
.toBool(); // show_Crescent = conf->value("show_Crescent", true).toBool();
show_Today = conf->value("Observability/show_Today", true).toBool(); // show_SuperMoon = conf->value("show_SuperMoon", true).toBool();
show_FullMoon = conf->value("Observability/show_FullMoon", true).toB
ool();
// show_Crescent = conf->value("Observability/show_Crescent", true).toB
ool();
// show_SuperMoon = conf->value("Observability/show_SuperMoon", true).t
oBool();
iAltitude = conf->value("Observability/Sun_Altitude", 12).toInt(); iAltitude = conf->value("Sun_Altitude", 12).toInt();
AstroTwiAlti = -((double)iAltitude)/Rad2Deg ; AstroTwiAlti = -((double)iAltitude)/Rad2Deg ;
iHorizAltitude = conf->value("Horizon_Altitude", 0).toInt();
HorizAlti = ((double)iHorizAltitude)/Rad2Deg ;
conf->endGroup();
} }
void Observability::saveSettingsToConfig(void) void Observability::saveSettingsToConfig(void)
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
QString fontColorStr = QString("%1,%2,%3").arg(fontColor[0],0,'f',2) .arg(fontColor[1],0,'f',2).arg(fontColor[2],0,'f',2); QString fontColorStr = QString("%1,%2,%3").arg(fontColor[0],0,'f',2) .arg(fontColor[1],0,'f',2).arg(fontColor[2],0,'f',2);
// Set updated values // Set updated values
conf->setValue("Observability/font_size", fontSize); conf->beginGroup("Observability");
conf->setValue("Observability/Sun_Altitude", iAltitude); conf->setValue("font_size", fontSize);
conf->setValue("Observability/font_color", fontColorStr); conf->setValue("Sun_Altitude", iAltitude);
conf->setValue("Observability/show_AcroCos", show_AcroCos); conf->setValue("Horizon_Altitude", iHorizAltitude);
conf->setValue("Observability/show_Good_Nights", show_Good_Nights); conf->setValue("font_color", fontColorStr);
conf->setValue("Observability/show_Best_Night", show_Best_Night); conf->setValue("show_AcroCos", show_AcroCos);
conf->setValue("Observability/show_Today", show_Today); conf->setValue("show_Good_Nights", show_Good_Nights);
conf->setValue("Observability/show_FullMoon", show_FullMoon); conf->setValue("show_Best_Night", show_Best_Night);
// conf->setValue("Observability/show_Crescent", show_Crescent); conf->setValue("show_Today", show_Today);
// conf->setValue("Observability/show_SuperMoon", show_SuperMoon); conf->setValue("show_FullMoon", show_FullMoon);
// conf->setValue("show_Crescent", show_Crescent);
// conf->setValue("show_SuperMoon", show_SuperMoon);
conf->endGroup();
} }
void Observability::setShow(int output, bool setVal) void Observability::setShow(int output, bool setVal)
{ {
switch(output) switch(output)
{ {
case 1: {show_Today = setVal; break;} case 1: {show_Today = setVal; break;}
case 2: {show_AcroCos = setVal; break;} case 2: {show_AcroCos = setVal; break;}
case 3: {show_Good_Nights = setVal; break;} case 3: {show_Good_Nights = setVal; break;}
case 4: {show_Best_Night = setVal; break;} case 4: {show_Best_Night = setVal; break;}
skipping to change at line 1561 skipping to change at line 1582
int Observability::getFontSize(void) int Observability::getFontSize(void)
{ {
return fontSize; return fontSize;
} }
int Observability::getSunAltitude(void) int Observability::getSunAltitude(void)
{ {
return iAltitude; return iAltitude;
} }
int Observability::getHorizAltitude(void)
{
return iHorizAltitude;
}
void Observability::setFontColor(int color, int value) void Observability::setFontColor(int color, int value)
{ {
float fValue = (float)(value) / 100.; float fValue = (float)(value) / 100.;
fontColor[color] = fValue; fontColor[color] = fValue;
} }
void Observability::setFontSize(int value) void Observability::setFontSize(int value)
{ {
fontSize = value; fontSize = value;
} }
void Observability::setSunAltitude(int value) void Observability::setSunAltitude(int value)
{ {
AstroTwiAlti = -((double) value)/Rad2Deg ; AstroTwiAlti = -((double) value)/Rad2Deg ;
iAltitude = value; iAltitude = value;
configChanged = true; configChanged = true;
} }
void Observability::setHorizAltitude(int value)
{
HorizAlti = ((double) value)/Rad2Deg ;
iHorizAltitude = value;
configChanged = true;
}
/// END OF STUFF FOR THE GUI CONFIG. /// END OF STUFF FOR THE GUI CONFIG.
/////////////////////////////// ///////////////////////////////
// Enable the Observability: // Enable the Observability:
void Observability::enableObservability(bool b) void Observability::enableObservability(bool b)
{ {
flagShowObservability = b; flagShowObservability = b;
} }
 End of changes. 76 change blocks. 
191 lines changed or deleted 212 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/