Commit eed6f16b authored by Jasem Mutlaq's avatar Jasem Mutlaq

Add updateCoordsNow() for situations when we need to force recomputation of...

Add updateCoordsNow() for situations when we need to force recomputation of coordinates regardless of time lapses. Use it where it is expected in the code.
parent e25809a4
......@@ -854,7 +854,7 @@ void Scheduler::evaluateJobs()
if (score < 0)
{
// If Altitude or Dark score are negative, we try to schedule a better time for altitude and dark sky period.
if (calculateAltitudeTime(job, job->getMinAltitude() > 0 ? job->getMinAltitude() : minAltitude->minimum()), job->getMinMoonSeparation())
if (calculateAltitudeTime(job, job->getMinAltitude() > 0 ? job->getMinAltitude() : minAltitude->minimum(), job->getMinMoonSeparation()))
{
//appendLogText(i18n("%1 observation job is scheduled at %2", job->getName(), job->getStartupTime().toString()));
job->setState(SchedulerJob::JOB_SCHEDULED);
......@@ -1554,7 +1554,7 @@ double Scheduler::getCurrentMoonSeparation(SchedulerJob *job)
ut = geo->LTtoUT(KStarsData::Instance()->lt());
KSNumbers ksnum(ut.djd());
LST = geo->GSTtoLST( ut.gst() );
moon->updateCoords(&ksnum, true, geo->lat(), &LST);
moon->updateCoords(&ksnum, true, geo->lat(), &LST, true);
// Moon/Sky separation p
return moon->angularDistanceTo(&p).Degrees();
......@@ -1577,7 +1577,7 @@ int16_t Scheduler::getMoonSeparationScore(SchedulerJob *job, QDateTime when)
ut = geo->LTtoUT(when);
KSNumbers ksnum(ut.djd());
LST = geo->GSTtoLST( ut.gst() );
moon->updateCoords(&ksnum, true, geo->lat(), &LST);
moon->updateCoords(&ksnum, true, geo->lat(), &LST, true);
double moonAltitude = moon->alt().Degrees();
......
......@@ -384,7 +384,7 @@ void SchedulerJob::setTargetCoords(dms ra, dms dec)
targetCoords.setRA0(ra);
targetCoords.setDec0(dec);
targetCoords.updateCoords(KStarsData::Instance()->updateNum());
targetCoords.updateCoordsNow(KStarsData::Instance()->updateNum());
}
......@@ -74,7 +74,7 @@ void KSAlmanac::RiseSetTime( SkyObject *o, double *riseTime, double *setTime, QT
KSNumbers num( dt.djd() );
dms LST = geo->GSTtoLST( dt.gst() );
o->updateCoords( &num, true, geo->lat(), &LST );
o->updateCoords( &num, true, geo->lat(), &LST, true );
if ( o->checkCircumpolar( geo->lat() ) ) {
if ( o->alt().Degrees() > 0.0 ) {
//Circumpolar, signal it this way:
......@@ -98,7 +98,7 @@ void KSAlmanac::findDawnDusk() {
KSNumbers num( today.djd() );
dms LST = geo->GSTtoLST( today.gst() );
m_Sun.updateCoords( &num, true, geo->lat(), &LST ); // We can abuse our own copy of the sun
m_Sun.updateCoords( &num, true, geo->lat(), &LST, true ); // We can abuse our own copy of the sun
double dawn, da, dusk, du, max_alt, min_alt;
double last_h = -12.0;
double last_alt = findAltitude( &m_Sun, last_h );
......@@ -142,8 +142,8 @@ void KSAlmanac::findMoonPhase() {
KSNumbers num( today.djd() );
dms LST = geo->GSTtoLST( today.gst() );
m_Sun.updateCoords( &num, true, geo->lat(), &LST ); // We can abuse our own copy of the sun and/or moon
m_Moon.updateCoords( &num, true, geo->lat(), &LST );
m_Sun.updateCoords( &num, true, geo->lat(), &LST, true ); // We can abuse our own copy of the sun and/or moon
m_Moon.updateCoords( &num, true, geo->lat(), &LST, true );
m_Moon.findPhase( &m_Sun );
MoonPhase = m_Moon.phase().Degrees();
}
......
......@@ -76,7 +76,7 @@ void SkyMesh::aperture(SkyPoint *p0, double radius, MeshBufNum_t bufNum)
printf(" ra1 = %8.4f dec1 = %8.4f\n", p1.ra().Degrees(), p1.dec().Degrees() );
SkyPoint p2 = p1;
p2.updateCoords( data->updateNum() );
p2.updateCoordsNow( data->updateNum() );
printf(" ra2 = %8.4f dec2 = %8.4f\n", p2.ra().Degrees(), p2.dec().Degrees() );
printf("p0 - p1 = %6.4f degrees\n", p0->angularDistanceTo( &p1 ).Degrees() );
printf("p0 - p2 = %6.4f degrees\n", p0->angularDistanceTo( &p2 ).Degrees() );
......
......@@ -253,8 +253,7 @@ public:
/** Determine the current coordinates (RA, Dec) from the catalog
*coordinates (RA0, Dec0), accounting for both precession and nutation.
*@param num pointer to KSNumbers object containing current values of
*time-dependent variables.
*@param num pointer to KSNumbers object containing current values of time-dependent variables.
*@param includePlanets does nothing in this implementation (see KSPlanetBase::updateCoords()).
*@param lat does nothing in this implementation (see KSPlanetBase::updateCoords()).
*@param LST does nothing in this implementation (see KSPlanetBase::updateCoords()).
......@@ -262,6 +261,12 @@ public:
*/
virtual void updateCoords( const KSNumbers *num, bool includePlanets=true, const dms *lat=0, const dms *LST=0, bool forceRecompute = false );
/**
* @brief updateCoordsNow Shortcut for updateCoords( const KSNumbers *num, false, NULL, NULL, true)
* @param num pointer to KSNumbers object containing current values of time-dependent variables.
*/
void updateCoordsNow(const KSNumbers *num) { updateCoords(num, false, NULL, NULL, true); }
/** Computes the apparent coordinates for this SkyPoint for any epoch,
*accounting for the effects of precession, nutation, and aberration.
*Similar to updateCoords(), but the starting epoch need not be
......
......@@ -356,11 +356,11 @@ void AltVsTime::processObject( SkyObject *o, bool forceAdd ) {
KStarsData* data = KStarsData::Instance();
if ( o->isSolarSystem() ) {
oldNum = new KSNumbers( data->ut().djd() );
o->updateCoords( num, true, geo->lat(), data->lst() );
o->updateCoords( num, true, geo->lat(), data->lst(), true );
}
//precess coords to target epoch
o->updateCoords( num );
o->updateCoordsNow( num );
// vector used for computing the points needed for drawing the graph
QVector<double> y(100), t(100);
......@@ -433,7 +433,7 @@ void AltVsTime::processObject( SkyObject *o, bool forceAdd ) {
//restore original position
if ( o->isSolarSystem() ) {
o->updateCoords( oldNum, true, data->geo()->lat(), data->lst() );
o->updateCoords( oldNum, true, data->geo()->lat(), data->lst(), true );
delete oldNum;
}
o->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
......@@ -987,11 +987,11 @@ void AltVsTime::slotUpdateDateLoc() {
//If the object is in the solar system, recompute its position for the given date
if ( o->isSolarSystem() ) {
oldNum = new KSNumbers( data->ut().djd() );
o->updateCoords( num, true, geo->lat(), &LST );
o->updateCoords( num, true, geo->lat(), &LST, true );
}
//precess coords to target epoch
o->updateCoords( num );
o->updateCoordsNow( num );
//update pList entry
pList.replace( i, o );
......@@ -1011,7 +1011,7 @@ void AltVsTime::slotUpdateDateLoc() {
}
o->EquatorialToHorizontal( data->lst(), data->geo()->lat() );
} else { //assume unfound object is a custom object
pList.at(i)->updateCoords( num ); //precess to desired epoch
pList.at(i)->updateCoordsNow( num ); //precess to desired epoch
KPlotObject *po = new KPlotObject( Qt::white, KPlotObject::Lines, 3 );
for ( double h=-12.0; h<=12.0; h+=0.5 ) {
......@@ -1278,7 +1278,7 @@ void AltVsTime::setDawnDusk()
dms LST = geo->GSTtoLST( today.gst() );
KSSun sun;
sun.updateCoords( &num, true, geo->lat(), &LST );
sun.updateCoords( &num, true, geo->lat(), &LST, true );
double dawn, da, dusk, du, max_alt, min_alt;
double last_h = -12.0;
double last_alt = findAltitude( &sun, last_h );
......
......@@ -145,7 +145,7 @@ dms KSConjunct::findDistance(long double jd, SkyObject *Object1, KSPlanetBase *O
if( p )
p->findPosition(&num, geoPlace->lat(), &LST, m_Earth);
else
Object1->updateCoords( &num );
Object1->updateCoordsNow( &num );
Object2->findPosition(&num, geoPlace->lat(), &LST, m_Earth);
dist.setRadians(Object1 -> angularDistanceTo(Object2).radians());
......
......@@ -155,7 +155,7 @@ void WUTDialog::init() {
KSNumbers *oldNum = new KSNumbers( data->ut().djd() );
dms LST = geo->GSTtoLST( T0.gst() );
oSun->updateCoords( num, true, geo->lat(), &LST );
oSun->updateCoords( num, true, geo->lat(), &LST, true );
if ( oSun->checkCircumpolar( geo->lat() ) ) {
if ( oSun->alt().Degrees() > 0.0 ) {
sRise = i18n( "circumpolar" );
......@@ -205,7 +205,7 @@ void WUTDialog::init() {
moonSet = oMoon->riseSetTime( UT0, geo, false );
//check to see if Moon is circumpolar
oMoon->updateCoords( num, true, geo->lat(), &LST );
oMoon->updateCoords( num, true, geo->lat(), &LST, true );
if ( oMoon->checkCircumpolar( geo->lat() ) ) {
if ( oMoon->alt().Degrees() > 0.0 ) {
sRise = i18n( "circumpolar" );
......@@ -234,8 +234,8 @@ void WUTDialog::init() {
int(100.0*oMoon->illum() ) ) );
//Restore Sun's and Moon's coordinates, and recompute Moon's original Phase
oMoon->updateCoords( oldNum, true, geo->lat(), data->lst() );
oSun->updateCoords( oldNum, true, geo->lat(), data->lst() );
oMoon->updateCoords( oldNum, true, geo->lat(), data->lst(), true );
oSun->updateCoords( oldNum, true, geo->lat(), data->lst(), true );
oMoon->findPhase(0);
if ( WUT->CategoryListWidget->currentItem() )
......
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