Observability.cpp   Observability.cpp 
skipping to change at line 278 skipping to change at line 278
bool locChanged, yearChanged; bool locChanged, yearChanged;
StelObjectP selectedObject; StelObjectP selectedObject;
PlanetP ssObject, parentPlanet; PlanetP ssObject, parentPlanet;
// Only execute plugin if we are on Earth. // Only execute plugin if we are on Earth.
if (core->getCurrentLocation().planetName != "Earth") if (core->getCurrentLocation().planetName != "Earth")
return; return;
// Set the painter: // Set the painter:
StelPainter painter(core->getProjection2d()); StelPainter painter(core->getProjection2d());
painter.setColor(fontColor[0],fontColor[1],fontColor[2],1); painter.setColor(fontColor[0],fontColor[1],fontColor[2],1.f);
font.setPixelSize(fontSize); font.setPixelSize(fontSize);
painter.setFont(font); painter.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->getJD(); double currJD = core->getJD();
double currJDint; double currJDint;
// GMTShift = StelUtils::getGMTShiftFromQT(currJD)/24.0; // 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 ;
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
// NOW WE CHECK THE CHANGED PARAMETERS W.R.T. THE PREVIOUS FRAME: // NOW WE CHECK THE CHANGED PARAMETERS W.R.T. THE PREVIOUS FRAME:
skipping to change at line 360 skipping to change at line 357
configChanged = true; configChanged = true;
souChanged = 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)
{ {
updateSunH(); updateSunH();
lastJDMoon = 0.0; lastJDMoon = 0.0;
}; };
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
// NOW WE DEAL WITH THE SOURCE (OR SCREEN-CENTER) POSITION: // NOW WE DEAL WITH THE SOURCE (OR SCREEN-CENTER) POSITION:
if (isScreen) // Always re-compute everything for the screen center. if (isScreen) // Always re-compute everything for the screen center.
souChanged = true; souChanged = true;
skipping to change at line 459 skipping to change at line 457
LocPos = core->j2000ToAltAz(currentPos, StelCore::Refraction Off); LocPos = core->j2000ToAltAz(currentPos, StelCore::Refraction Off);
} }
// Convert EquPos to RA/Dec: // Convert EquPos to RA/Dec:
toRADec(EquPos, selRA, selDec); toRADec(EquPos, selRA, selDec);
// Compute source's altitude (in radians): // Compute source's altitude (in radians):
alti = std::asin(LocPos[2]); alti = std::asin(LocPos[2]);
// Force re-computation of ephemeris if the location changes or the user ch anges the configuration: // Force re-computation of ephemeris if the location changes or the user ch anges the configuration:
if (locChanged || configChanged) if (locChanged || configChanged || yearChanged)
{ {
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 = calculateHourAngle(mylat,alti,selDec); double currH = calculateHourAngle(mylat,alti,selDec);
skipping to change at line 827 skipping to change at line 825
lineObservableRange = msgAbo veHoriz.arg(dateRange); lineObservableRange = msgAbo veHoriz.arg(dateRange);
}; };
}; // 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 lineSpacing = (int) (1.3* ( (double) fontSize)); // between lin StelProjector::StelProjectorParams params = core->getCurrentStelProj
es ectorParams();
int lineSpacing = (int) (params.devicePixelsPerPixel * 1.3 * ( (doub
le) fontSize)); // between lines
int groupSpacing = 6*fontSize; // between daily and yearly results int groupSpacing = 6*fontSize; // between daily and yearly results
int yLine = 8*fontSize+110; int yLine = 8*fontSize+110;
int xLine = 80; int xLine = 80;
if (show_Today) if (show_Today)
{ {
//renderer->drawText(TextParams(xLine, yLine,q_("TODAY:"))); //renderer->drawText(TextParams(xLine, yLine,q_("TODAY:")));
painter.drawText(xLine, yLine, msgToday); painter.drawText(xLine, yLine, msgToday);
painter.drawText(xLine + fontSize, yLine - lineSpacing, RS2) ; painter.drawText(xLine + fontSize, yLine - lineSpacing, RS2) ;
painter.drawText(xLine + fontSize, yLine - lineSpacing*2, RS 1); painter.drawText(xLine + fontSize, yLine - lineSpacing*2, RS 1);
skipping to change at line 1031 skipping to change at line 1030
// Compute Earth's position throughout the year: // Compute Earth's position throughout the year:
Vec3d pos, sunPos; Vec3d pos, sunPos;
for (int i=0; i<nDays; i++) for (int i=0; i<nDays; i++)
{ {
yearJD[i].first = Jan1stJD + (double)i; yearJD[i].first = Jan1stJD + (double)i;
yearJD[i].second = yearJD[i].first+core->computeDeltaT(yearJ D[i].first)/86400.0; yearJD[i].second = yearJD[i].first+core->computeDeltaT(yearJ D[i].first)/86400.0;
myEarth->computePosition(yearJD[i].second); myEarth->computePosition(yearJD[i].second);
myEarth->computeTransMatrix(yearJD[i].first, yearJD[i].secon d); myEarth->computeTransMatrix(yearJD[i].first, yearJD[i].secon d);
pos = myEarth->getHeliocentricEclipticPos(); pos = myEarth->getHeliocentricEclipticPos();
sunPos = core->j2000ToEquinoxEqu((core->matVsop87ToJ2000)*(- pos)); sunPos = core->j2000ToEquinoxEqu((StelCore::matVsop87ToJ2000 )*(-pos));
EarthPos[i] = -pos; EarthPos[i] = -pos;
toRADec(sunPos,sunRA[i],sunDec[i]); toRADec(sunPos,sunRA[i],sunDec[i]);
}; };
//Return the Earth to its current time: //Return the Earth to its current time:
myEarth->computePosition(myJD.second); myEarth->computePosition(myJD.second);
myEarth->computeTransMatrix(myJD.first, myJD.second); myEarth->computeTransMatrix(myJD.first, myJD.second);
} }
/////////////////////////////////////////////////// ///////////////////////////////////////////////////
skipping to change at line 1265 skipping to change at line 1264
myMoon->computeTransMatrix(JD.first, JD.second); myMoon->computeTransMatrix(JD.first, JD.second);
} }
else // Compute coordinates: else // Compute coordinates:
{ {
myEarth->computePosition(JD.second); myEarth->computePosition(JD.second);
myEarth->computeTransMatrix(JD.first, JD.second); myEarth->computeTransMatrix(JD.first, JD.second);
Vec3d earthPos = myEarth->getHeliocentricEclipticPos(); Vec3d earthPos = myEarth->getHeliocentricEclipticPos();
double curSidT; double curSidT;
// Sun coordinates: // Sun coordinates:
Vec3d sunPos = core->j2000ToEquinoxEqu((core->matVsop87ToJ20 00)*(-earthPos)); Vec3d sunPos = core->j2000ToEquinoxEqu((StelCore::matVsop87T oJ2000)*(-earthPos));
toRADec(sunPos, raSun, decSun); toRADec(sunPos, raSun, decSun);
// Moon coordinates: // Moon coordinates:
curSidT = myEarth->getSiderealTime(JD.first, JD.second)/Rad2 Deg; curSidT = myEarth->getSiderealTime(JD.first, JD.second)/Rad2 Deg;
RotObserver = (Mat4d::zrotation(curSidT))*ObserverLoc; RotObserver = (Mat4d::zrotation(curSidT))*ObserverLoc;
LocTrans = (core->matVsop87ToJ2000)*(Mat4d::translation(-ear thPos)); LocTrans = (StelCore::matVsop87ToJ2000)*(Mat4d::translation( -earthPos));
myMoon->computePosition(JD.second); myMoon->computePosition(JD.second);
myMoon->computeTransMatrix(JD.first, JD.second); myMoon->computeTransMatrix(JD.first, JD.second);
Vec3d moonPos = myMoon->getHeliocentricEclipticPos(); Vec3d moonPos = myMoon->getHeliocentricEclipticPos();
sunPos = (core->j2000ToEquinoxEqu(LocTrans*moonPos))-RotObse rver; sunPos = (core->j2000ToEquinoxEqu(LocTrans*moonPos))-RotObse rver;
eclLon = moonPos[0]*earthPos[1] - moonPos[1]*earthPos[0]; eclLon = moonPos[0]*earthPos[1] - moonPos[1]*earthPos[0];
toRADec(sunPos,raMoon,decMoon); toRADec(sunPos,raMoon,decMoon);
}; };
} }
skipping to change at line 1311 skipping to change at line 1310
Vec3d earthPos = myEarth->getHeliocentricEclipticPos(); Vec3d earthPos = myEarth->getHeliocentricEclipticPos();
// double curSidT; // double curSidT;
// Sun coordinates: // Sun coordinates:
// Pos2 = core->j2000ToEquinoxEqu((core->matVsop87ToJ2000)*(-Po s0)); // Pos2 = core->j2000ToEquinoxEqu((core->matVsop87ToJ2000)*(-Po s0));
// toRADec(Pos2,RASun,DecSun); // toRADec(Pos2,RASun,DecSun);
// Moon coordinates: // Moon coordinates:
// curSidT = myEarth->getSiderealTime(JD)/Rad2Deg; // curSidT = myEarth->getSiderealTime(JD)/Rad2Deg;
// RotObserver = (Mat4d::zrotation(curSidT))*ObserverLoc; // RotObserver = (Mat4d::zrotation(curSidT))*ObserverLoc;
LocTrans = (core->matVsop87ToJ2000)*(Mat4d::translation(-ear thPos)); LocTrans = (StelCore::matVsop87ToJ2000)*(Mat4d::translation( -earthPos));
myMoon->computePosition(JD.second); myMoon->computePosition(JD.second);
myMoon->computeTransMatrix(JD.first, JD.second); myMoon->computeTransMatrix(JD.first, JD.second);
Pos1 = myMoon->getHeliocentricEclipticPos(); Pos1 = myMoon->getHeliocentricEclipticPos();
Pos2 = (core->j2000ToEquinoxEqu(LocTrans*Pos1)); //-RotObser ver; Pos2 = (core->j2000ToEquinoxEqu(LocTrans*Pos1)); //-RotObser ver;
distance = std::sqrt(Pos2*Pos2); distance = std::sqrt(Pos2*Pos2);
// toRADec(Pos2,RAMoon,DecMoon); // toRADec(Pos2,RAMoon,DecMoon);
}; };
} }
skipping to change at line 1345 skipping to change at line 1344
myEarth->computeTransMatrix(JD.first, JD.second); myEarth->computeTransMatrix(JD.first, JD.second);
} else } else
{ {
// Compute planet's position: // Compute planet's position:
myPlanet->computePosition(JD.second); myPlanet->computePosition(JD.second);
myPlanet->computeTransMatrix(JD.first, JD.second); myPlanet->computeTransMatrix(JD.first, JD.second);
Pos1 = myPlanet->getHeliocentricEclipticPos(); Pos1 = myPlanet->getHeliocentricEclipticPos();
myEarth->computePosition(JD.second); myEarth->computePosition(JD.second);
myEarth->computeTransMatrix(JD.first, JD.second); myEarth->computeTransMatrix(JD.first, JD.second);
Pos2 = myEarth->getHeliocentricEclipticPos(); Pos2 = myEarth->getHeliocentricEclipticPos();
LocTrans = (core->matVsop87ToJ2000)*(Mat4d::translation(-Pos 2)); LocTrans = (StelCore::matVsop87ToJ2000)*(Mat4d::translation( -Pos2));
Pos2 = core->j2000ToEquinoxEqu(LocTrans*Pos1); Pos2 = core->j2000ToEquinoxEqu(LocTrans*Pos1);
toRADec(Pos2,RA,Dec); toRADec(Pos2,RA,Dec);
}; };
} }
////////////////////////////////////////////// //////////////////////////////////////////////
////////////////////////////////////////////// //////////////////////////////////////////////
// Solves Moon's, Sun's, or Planet's ephemeris by bissection. // Solves Moon's, Sun's, or Planet's ephemeris by bissection.
bool Observability::calculateSolarSystemEvents(StelCore* core, int bodyType ) bool Observability::calculateSolarSystemEvents(StelCore* core, int bodyType )
skipping to change at line 1372 skipping to change at line 1371
//Vec3d Observer; //Vec3d Observer;
hHoriz = calculateHourAngle(mylat, refractedHorizonAlt, selDec); hHoriz = calculateHourAngle(mylat, refractedHorizonAlt, 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 (qAbs(myJD.first-lastJDMoon)>StelCore::JD_SECOND || lastType!=bod yType || souChanged) if (qAbs(myJD.first-lastJDMoon)>StelCore::JD_SECOND || lastType!=bod yType || souChanged)
{ {
// qDebug() << q_("%1 %2 %3 %4").arg(Kind).arg(LastObject)
.arg(myJD,0,'f',5).arg(lastJDMoon,0,'f',5);
lastType = bodyType; lastType = bodyType;
myEarth->computePosition(myJD.second); myEarth->computePosition(myJD.second);
myEarth->computeTransMatrix(myJD.first, myJD.second); myEarth->computeTransMatrix(myJD.first, myJD.second);
Vec3d earthPos = myEarth->getHeliocentricEclipticPos(); Vec3d earthPos = myEarth->getHeliocentricEclipticPos();
if (bodyType == 1) // Sun position if (bodyType == 1) // Sun position
{ {
Pos2 = core->j2000ToEquinoxEqu((core->matVsop87ToJ20 00)*(-earthPos)); Pos2 = core->j2000ToEquinoxEqu((StelCore::matVsop87T oJ2000)*(-earthPos));
} }
else if (bodyType==2) // Moon position else if (bodyType==2) // Moon position
{ {
curSidT = myEarth->getSiderealTime(myJD.first, myJD. second)/Rad2Deg; curSidT = myEarth->getSiderealTime(myJD.first, myJD. second)/Rad2Deg;
RotObserver = (Mat4d::zrotation(curSidT))*ObserverLo c; RotObserver = (Mat4d::zrotation(curSidT))*ObserverLo c;
LocTrans = (core->matVsop87ToJ2000)*(Mat4d::translat ion(-earthPos)); LocTrans = (StelCore::matVsop87ToJ2000)*(Mat4d::tran slation(-earthPos));
myMoon->computePosition(myJD.second); myMoon->computePosition(myJD.second);
myMoon->computeTransMatrix(myJD.first, myJD.second); myMoon->computeTransMatrix(myJD.first, myJD.second);
Pos1 = myMoon->getHeliocentricEclipticPos(); Pos1 = myMoon->getHeliocentricEclipticPos();
Pos2 = (core->j2000ToEquinoxEqu(LocTrans*Pos1))-RotO bserver; Pos2 = (core->j2000ToEquinoxEqu(LocTrans*Pos1))-RotO bserver;
} }
else // Planet position else // Planet position
{ {
myPlanet->computePosition(myJD.second); myPlanet->computePosition(myJD.second);
myPlanet->computeTransMatrix(myJD.first, myJD.second ); myPlanet->computeTransMatrix(myJD.first, myJD.second );
Pos1 = myPlanet->getHeliocentricEclipticPos(); Pos1 = myPlanet->getHeliocentricEclipticPos();
LocTrans = (core->matVsop87ToJ2000)*(Mat4d::translat ion(-earthPos)); LocTrans = (StelCore::matVsop87ToJ2000)*(Mat4d::tran slation(-earthPos));
Pos2 = core->j2000ToEquinoxEqu(LocTrans*Pos1); Pos2 = core->j2000ToEquinoxEqu(LocTrans*Pos1);
}; };
toRADec(Pos2,ra,dec); toRADec(Pos2,ra,dec);
Vec3d moonAltAz = core->equinoxEquToAltAz(Pos2, StelCore::Re fractionOff); Vec3d moonAltAz = core->equinoxEquToAltAz(Pos2, StelCore::Re fractionOff);
hasRisen = moonAltAz[2] > refractedHorizonAlt; hasRisen = moonAltAz[2] > refractedHorizonAlt;
// 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:
skipping to change at line 1541 skipping to change at line 1538
// Compute eph. times for mod. coordinates: // Compute eph. times for mod. coordinates:
tempH = -Hcurr*TFrac; tempH = -Hcurr*TFrac;
// Check convergence: // Check convergence:
if (qAbs(tempH-tempEphH)<StelCore::JD_SECOND) break; if (qAbs(tempH-tempEphH)<StelCore::JD_SECOND) break;
tempEphH = tempH; tempEphH = tempH;
MoonCulm = myJD.first + (tempEphH/24.); MoonCulm = myJD.first + (tempEphH/24.);
culmAlt = qAbs(mylat-dec); // 90 - altitude at trans it. culmAlt = qAbs(mylat-dec); // 90 - altitude at trans it.
}; };
// qDebug() << q_("%1").arg(MoonCulm,0,'f',5);
lastJDMoon = myJD.first; lastJDMoon = myJD.first;
}; // Comes from if (qAbs(myJD.first-lastJDMoon)>JDsec || LastObject !=Kind) }; // Comes from if (qAbs(myJD.first-lastJDMoon)>JDsec || LastObject !=Kind)
// Find out the days of Full Moon: // Find out the days of Full Moon:
if (bodyType==2 && show_FullMoon) // || show_SuperMoon)) if (bodyType==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.first > nextFullMoon || myJD.first < prevFullMoon) if (myJD.first > nextFullMoon || myJD.first < prevFullMoon)
skipping to change at line 1605 skipping to change at line 1600
if (Temp1*eclLon < 0.0) if (Temp1*eclLon < 0.0)
{ {
Sec2.first = Phase1; Sec2.first = Phase1;
Temp2 = eclLon; Temp2 = eclLon;
} else { } else {
Sec1.first = Phase1; Sec1.first = Phase1;
Temp1 = eclLon; Temp1 = eclLon;
}; };
// qDebug() << QString("%1 %2 %3 %4 ").
arg(Sec1).arg(Sec2).arg(Temp1).arg(Temp2);
if (qAbs(Sec2.first-Sec1.first) < 10 .*dT) // 1 minute accuracy; convergence. if (qAbs(Sec2.first-Sec1.first) < 10 .*dT) // 1 minute accuracy; convergence.
{ {
TempFullMoon = (Sec1.first+S ec2.first)/2.; TempFullMoon = (Sec1.first+S ec2.first)/2.;
// qDebug() << QString("%1%2 ") .arg(TempFullMoon);
break; break;
}; };
}; };
if (TempFullMoon > myJD.first) if (TempFullMoon > myJD.first)
{ {
nextFullMoon = TempFullMoon; nextFullMoon = TempFullMoon;
TempFullMoon -= MoonT; TempFullMoon -= MoonT;
} else } else
skipping to change at line 1869 skipping to change at line 1861
void Observability::setHorizonAltitude(int altitude) void Observability::setHorizonAltitude(int altitude)
{ {
horizonAltitude = ((double) altitude)/Rad2Deg ; horizonAltitude = ((double) altitude)/Rad2Deg ;
horizonAltDeg = altitude; horizonAltDeg = altitude;
configChanged = true; configChanged = true;
} }
void Observability::showReport(bool b) void Observability::showReport(bool b)
{ {
flagShowReport = b; if (b!=flagShowReport)
{
flagShowReport = b;
emit flagReportVisibilityChanged(b);
}
} }
 End of changes. 19 change blocks. 
25 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/