StelObject.cpp   StelObject.cpp 
skipping to change at line 21 skipping to change at line 21
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* 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., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
*/ */
#include "StelObject.hpp" #include "StelObject.hpp"
#include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "StelSkyDrawer.hpp" #include "StelSkyDrawer.hpp"
#include "RefractionExtinction.hpp" #include "RefractionExtinction.hpp"
#include "StelLocation.hpp" #include "StelLocation.hpp"
#include "SolarSystem.hpp"
#include "StelModuleMgr.hpp"
#include <QRegExp> #include <QRegExp>
#include <QDebug> #include <QDebug>
Vec3d StelObject::getEquinoxEquatorialPos(const StelCore* core) const Vec3d StelObject::getEquinoxEquatorialPos(const StelCore* core) const
{ {
return core->j2000ToEquinoxEqu(getJ2000EquatorialPos(core)); return core->j2000ToEquinoxEqu(getJ2000EquatorialPos(core));
} }
// Get observer local sidereal coordinate // Get observer local sidereal coordinate
Vec3d StelObject::getSideralPosGeometric(const StelCore* core) const Vec3d StelObject::getSiderealPosGeometric(const StelCore* core) const
{ {
// Hour Angle corrected to Delta-T value // Hour Angle corrected to Delta-T value
double dt = (core->getDeltaT(core->getJDay())/240.)*M_PI/180.; double dt = (core->getDeltaT(core->getJDay())/240.)*M_PI/180.;
return Mat4d::zrotation(-core->getLocalSideralTime()+dt)* getEquinox EquatorialPos(core); return Mat4d::zrotation(-core->getLocalSiderealTime()+dt)* getEquino xEquatorialPos(core);
} }
// Get observer local sidereal coordinates, deflected by refraction // Get observer local sidereal coordinates, deflected by refraction
Vec3d StelObject::getSideralPosApparent(const StelCore* core) const Vec3d StelObject::getSiderealPosApparent(const StelCore* core) const
{ {
Vec3d v=getAltAzPosApparent(core); Vec3d v=getAltAzPosApparent(core);
v = core->altAzToEquinoxEqu(v, StelCore::RefractionOff); v = core->altAzToEquinoxEqu(v, StelCore::RefractionOff);
// Hour Angle corrected to Delta-T value // Hour Angle corrected to Delta-T value
double dt = (core->getDeltaT(core->getJDay())/240.)*M_PI/180.; double dt = (core->getDeltaT(core->getJDay())/240.)*M_PI/180.;
return Mat4d::zrotation(-core->getLocalSideralTime()+dt)*v; return Mat4d::zrotation(-core->getLocalSiderealTime()+dt)*v;
} }
Vec3d StelObject::getAltAzPosGeometric(const StelCore* core) const Vec3d StelObject::getAltAzPosGeometric(const StelCore* core) const
{ {
return core->j2000ToAltAz(getJ2000EquatorialPos(core), StelCore::Ref ractionOff); return core->j2000ToAltAz(getJ2000EquatorialPos(core), StelCore::Ref ractionOff);
} }
// Get observer-centered alt/az position // Get observer-centered alt/az position
Vec3d StelObject::getAltAzPosApparent(const StelCore* core) const Vec3d StelObject::getAltAzPosApparent(const StelCore* core) const
{ {
return core->j2000ToAltAz(getJ2000EquatorialPos(core), StelCore::Ref ractionOn); return core->j2000ToAltAz(getJ2000EquatorialPos(core), StelCore::Ref ractionOn);
} }
// Get observer-centered alt/az position // Get observer-centered alt/az position
Vec3d StelObject::getAltAzPosAuto(const StelCore* core) const Vec3d StelObject::getAltAzPosAuto(const StelCore* core) const
{ {
return core->j2000ToAltAz(getJ2000EquatorialPos(core)); return core->j2000ToAltAz(getJ2000EquatorialPos(core));
} }
// Get observer-centered galactic position // Get observer-centered galactic position
Vec3d StelObject::getJ2000GalacticPos(const StelCore *core) const Vec3d StelObject::getGalacticPos(const StelCore *core) const
{ {
return core->j2000ToGalactic(getJ2000EquatorialPos(core)); return core->j2000ToGalactic(getJ2000EquatorialPos(core));
} }
float StelObject::getVMagnitude(const StelCore* core, bool withExtinction) const float StelObject::getVMagnitude(const StelCore* core) const
{ {
Q_UNUSED(core); Q_UNUSED(core);
Q_UNUSED(withExtinction);
return 99; return 99;
} }
float StelObject::getSelectPriority(const StelCore* core) const
{
float extMag = getVMagnitudeWithExtinction(core);
if (extMag>15.f)
extMag=15.f;
return extMag;
}
float StelObject::getVMagnitudeWithExtinction(const StelCore* core) const
{
Vec3d altAzPos = getAltAzPosGeometric(core);
altAzPos.normalize();
float vMag = getVMagnitude(core);
// GZ 2014-01-02: without the test, planets flicker stupidly in full
sky atmosphere-less view.
if (core->getSkyDrawer()->getFlagHasAtmosphere())
core->getSkyDrawer()->getExtinction().forward(altAzPos, &vMa
g);
return vMag;
}
// Format the positional info string contain J2000/of date/altaz/hour angle positions for the object // Format the positional info string contain J2000/of date/altaz/hour angle positions for the object
QString StelObject::getPositionInfoString(const StelCore *core, const InfoS tringGroup& flags) const QString StelObject::getPositionInfoString(const StelCore *core, const InfoS tringGroup& flags) const
{ {
bool withAtmosphere=core->getSkyDrawer()->getFlagHasAtmosphere(); bool withAtmosphere=core->getSkyDrawer()->getFlagHasAtmosphere();
QString res; QString res;
if (flags&RaDecJ2000) if (flags&RaDecJ2000)
{ {
double dec_j2000, ra_j2000; double dec_j2000, ra_j2000;
StelUtils::rectToSphe(&ra_j2000,&dec_j2000,getJ2000Equatoria lPos(core)); StelUtils::rectToSphe(&ra_j2000,&dec_j2000,getJ2000Equatoria lPos(core));
res += q_("RA/DE (J2000): %1/%2").arg(StelUtils::radToHmsStr (ra_j2000,true), StelUtils::radToDmsStr(dec_j2000,true)) + "<br>"; res += q_("RA/DE (J2000): %1/%2").arg(StelUtils::radToHmsStr (ra_j2000,true), StelUtils::radToDmsStr(dec_j2000,true)) + "<br>";
} }
if (flags&RaDecOfDate) if (flags&RaDecOfDate)
{ {
double dec_equ, ra_equ; double dec_equ, ra_equ;
StelUtils::rectToSphe(&ra_equ,&dec_equ,getEquinoxEquatorialP os(core)); StelUtils::rectToSphe(&ra_equ,&dec_equ,getEquinoxEquatorialP os(core));
res += q_("RA/DE (of date): %1/%2").arg(StelUtils::radToHmsS tr(ra_equ), StelUtils::radToDmsStr(dec_equ)) + "<br>"; res += q_("RA/DE (of date): %1/%2").arg(StelUtils::radToHmsS tr(ra_equ), StelUtils::radToDmsStr(dec_equ)) + "<br>";
} }
if (flags&GalCoordJ2000) if (flags&GalacticCoord)
{ {
double glong, glat; double glong, glat;
StelUtils::rectToSphe(&glong, &glat, getJ2000GalacticPos(cor StelUtils::rectToSphe(&glong, &glat, getGalacticPos(core));
e));
// Note that Gal. Coords are DEFINED in B1950 coordinates, a
nd writing "J2000" to them does not make any sense.
res += q_("Galactic longitude/latitude: %1/%2").arg(StelUtil s::radToDmsStr(glong,true), StelUtils::radToDmsStr(glat,true)) + "<br>"; res += q_("Galactic longitude/latitude: %1/%2").arg(StelUtil s::radToDmsStr(glong,true), StelUtils::radToDmsStr(glat,true)) + "<br>";
} }
if (flags&HourAngle) if (flags&HourAngle)
{ {
double dec_sidereal, ra_sidereal; double dec_sidereal, ra_sidereal;
StelUtils::rectToSphe(&ra_sidereal,&dec_sidereal,getSideralP osGeometric(core)); StelUtils::rectToSphe(&ra_sidereal,&dec_sidereal,getSidereal PosGeometric(core));
ra_sidereal = 2.*M_PI-ra_sidereal; ra_sidereal = 2.*M_PI-ra_sidereal;
if (withAtmosphere) if (withAtmosphere)
{ {
res += q_("Hour angle/DE: %1/%2").arg(StelUtils::radToHm StelUtils::rectToSphe(&ra_sidereal,&dec_sidereal,getSide
sStr(ra_sidereal), StelUtils::radToDmsStr(dec_sidereal)) + " " + q_("(geome realPosApparent(core));
tric)") + "<br>";
StelUtils::rectToSphe(&ra_sidereal,&dec_sidereal,getSide
ralPosApparent(core));
ra_sidereal = 2.*M_PI-ra_sidereal; ra_sidereal = 2.*M_PI-ra_sidereal;
res += q_("Hour angle/DE: %1/%2").arg(StelUtils::radToHm sStr(ra_sidereal), StelUtils::radToDmsStr(dec_sidereal)) + " " + q_("(appar ent)") + "<br>"; res += q_("Hour angle/DE: %1/%2").arg(StelUtils::radToHm sStr(ra_sidereal), StelUtils::radToDmsStr(dec_sidereal)) + " " + q_("(appar ent)") + "<br>";
} }
else else
{
res += q_("Hour angle/DE: %1/%2").arg(StelUtils::radToHm sStr(ra_sidereal), StelUtils::radToDmsStr(dec_sidereal)) + " " + "<br>"; res += q_("Hour angle/DE: %1/%2").arg(StelUtils::radToHm sStr(ra_sidereal), StelUtils::radToDmsStr(dec_sidereal)) + " " + "<br>";
}
} }
if (flags&AltAzi) if (flags&AltAzi)
{ {
// calculate alt az // calculate alt az
double az,alt; double az,alt;
StelUtils::rectToSphe(&az,&alt,getAltAzPosGeometric(core)); StelUtils::rectToSphe(&az,&alt,getAltAzPosGeometric(core));
az = 3.*M_PI - az; // N is zero, E is 90 degrees az = 3.*M_PI - az; // N is zero, E is 90 degrees
if (az > M_PI*2) if (az > M_PI*2)
az -= M_PI*2; az -= M_PI*2;
if (withAtmosphere) if (withAtmosphere)
{ {
res += q_("Az/Alt: %1/%2").arg(StelUtils::radToDmsStr(az
), StelUtils::radToDmsStr(alt)) + " " + q_("(geometric)") + "<br>";
StelUtils::rectToSphe(&az,&alt,getAltAzPosApparent(core) ); StelUtils::rectToSphe(&az,&alt,getAltAzPosApparent(core) );
az = 3.*M_PI - az; // N is zero, E is 90 degrees az = 3.*M_PI - az; // N is zero, E is 90 degrees
if (az > M_PI*2) if (az > M_PI*2)
az -= M_PI*2; az -= M_PI*2;
res += q_("Az/Alt: %1/%2").arg(StelUtils::radToDmsStr(az ), StelUtils::radToDmsStr(alt)) + " " + q_("(apparent)") + "<br>"; res += q_("Az/Alt: %1/%2").arg(StelUtils::radToDmsStr(az ), StelUtils::radToDmsStr(alt)) + " " + q_("(apparent)") + "<br>";
} }
else else
{
res += q_("Az/Alt: %1/%2").arg(StelUtils::radToDmsStr(az ), StelUtils::radToDmsStr(alt)) + " " + "<br>"; res += q_("Az/Alt: %1/%2").arg(StelUtils::radToDmsStr(az ), StelUtils::radToDmsStr(alt)) + " " + "<br>";
}
}
if ((flags&EclTopocentricCoord) && (core->getCurrentLocation().plane
tName=="Earth"))
{
static SolarSystem *ssystem=GETSTELMODULE(SolarSystem);
double ecl= ssystem->getEarth()->getRotObliquity(2451545.0);
double ra_equ, dec_equ, lambda, beta;
StelUtils::rectToSphe(&ra_equ,&dec_equ,getEquinoxEquatorialP
os(core));
StelUtils::ctRadec2Ecl(ra_equ, dec_equ, ecl, &lambda, &beta)
;
if (lambda<0) lambda+=2.0*M_PI;
res += q_("Ecliptic Topocentric (of J2000): %1/%2").arg(Stel
Utils::radToDmsStr(lambda, true), StelUtils::radToDmsStr(beta, true)) + "<b
r>";
ecl= ssystem->getEarth()->getRotObliquity(core->getJDay());
StelUtils::rectToSphe(&ra_equ,&dec_equ,getEquinoxEquatorialP
os(core));
StelUtils::ctRadec2Ecl(ra_equ, dec_equ, ecl, &lambda, &beta)
;
if (lambda<0) lambda+=2.0*M_PI;
res += q_("Ecliptic Topocentric (of date): %1/%2").arg(StelU
tils::radToDmsStr(lambda, true), StelUtils::radToDmsStr(beta, true)) + "<br
>";
} }
return res; return res;
} }
// Apply post processing on the info string // Apply post processing on the info string
void StelObject::postProcessInfoString(QString& str, const InfoStringGroup& flags) const void StelObject::postProcessInfoString(QString& str, const InfoStringGroup& flags) const
{ {
// chomp trailing line breaks // chomp trailing line breaks
str.replace(QRegExp("<br(\\s*/)?>\\s*$"), ""); str.replace(QRegExp("<br(\\s*/)?>\\s*$"), "");
if (flags&PlainText) if (flags&PlainText)
{ {
str.replace("<b>", ""); str.replace("<b>", "");
str.replace("</b>", ""); str.replace("</b>", "");
str.replace("<h2>", ""); str.replace("<h2>", "");
str.replace("</h2>", "\n"); str.replace("</h2>", "\n");
str.replace("<br>", "\n"); str.replace(QRegExp("<br(\\s*/)?>"), "\n");
} }
else else
{ {
str.prepend(QString("<font color=%1>").arg(StelUtils::vec3fT oHtmlColor(getInfoColor()))); str.prepend(QString("<font color=%1>").arg(StelUtils::vec3fT oHtmlColor(getInfoColor())));
str.append(QString("</font>")); str.append(QString("</font>"));
} }
} }
 End of changes. 20 change blocks. 
23 lines changed or deleted 65 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/