MinorPlanet.cpp   MinorPlanet.cpp 
skipping to change at line 25 skipping to change at line 25
* *
* 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 "MinorPlanet.hpp" #include "MinorPlanet.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelNavigator.hpp"
#include "StelTexture.hpp" #include "StelTexture.hpp"
#include "StelTextureMgr.hpp" #include "StelTextureMgr.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include <QRegExp> #include <QRegExp>
#include <QDebug> #include <QDebug>
MinorPlanet::MinorPlanet(const QString& englishName, MinorPlanet::MinorPlanet(const QString& englishName,
int flagLighting, int flagLighting,
double radius, double radius,
double oblateness, double oblateness,
Vec3f color, Vec3f color,
float albedo, float albedo,
const QString& atexMapName, const QString& atexMapName,
posFuncType coordFunc, posFuncType coordFunc,
void* auserDataPtr, void* auserDataPtr,
OsulatingFunctType *osculat ingFunc, OsculatingFunctType *oscula tingFunc,
bool acloseOrbit, bool acloseOrbit,
bool hidden) bool hidden)
: Planet (englishName, : Planet (englishName,
flagLighti ng, flagLighti ng,
radius, radius,
oblateness , oblateness ,
color, color,
albedo, albedo,
atexMapNam e, atexMapNam e,
coordFunc, coordFunc,
auserDataP tr, auserDataP tr,
osculating Func, osculating Func,
acloseOrbi t, acloseOrbi t,
hidden, hidden,
false) //N o atmosphere false) //N o atmosphere
{ {
texMapName = atexMapName; texMapName = atexMapName;
lastOrbitJD =0; lastOrbitJD =0;
deltaJD = JD_SECOND; deltaJD = StelCore::JD_SECOND;
orbitCached = 0; orbitCached = 0;
closeOrbit = acloseOrbit; closeOrbit = acloseOrbit;
eclipticPos=Vec3d(0.,0.,0.); eclipticPos=Vec3d(0.,0.,0.);
rotLocalToParent = Mat4d::identity(); rotLocalToParent = Mat4d::identity();
texMap = StelApp::getInstance().getTextureManager().createTextureThr ead("textures/"+texMapName, StelTexture::StelTextureParams(true, GL_LINEAR, GL_REPEAT)); texMap = StelApp::getInstance().getTextureManager().createTextureThr ead("textures/"+texMapName, StelTexture::StelTextureParams(true, GL_LINEAR, GL_REPEAT));
//MinorPlanet specific members //MinorPlanet specific members
minorPlanetNumber = 0; minorPlanetNumber = 0;
absoluteMagnitude = 0; absoluteMagnitude = 0;
skipping to change at line 167 skipping to change at line 167
void MinorPlanet::setProvisionalDesignation(QString designation) void MinorPlanet::setProvisionalDesignation(QString designation)
{ {
//TODO: This feature has to be implemented better, anyway. //TODO: This feature has to be implemented better, anyway.
provisionalDesignationHtml = renderProvisionalDesignationinHtml(desi gnation); provisionalDesignationHtml = renderProvisionalDesignationinHtml(desi gnation);
} }
QString MinorPlanet::getInfoString(const StelCore *core, const InfoStringGr oup &flags) const QString MinorPlanet::getInfoString(const StelCore *core, const InfoStringGr oup &flags) const
{ {
//Mostly copied from Planet::getInfoString(): //Mostly copied from Planet::getInfoString():
const StelNavigator* nav = core->getNavigator();
QString str; QString str;
QTextStream oss(&str); QTextStream oss(&str);
if (flags&Name) if (flags&Name)
{ {
oss << "<h2>"; oss << "<h2>";
if (minorPlanetNumber) if (minorPlanetNumber)
oss << QString("(%1) ").arg(minorPlanetNumber); oss << QString("(%1) ").arg(minorPlanetNumber);
if (nameIsProvisionalDesignation) if (nameIsProvisionalDesignation)
skipping to change at line 194 skipping to change at line 193
oss << QString::fromUtf8(" (\xC3\x97") << sphereScal e << ")"; oss << QString::fromUtf8(" (\xC3\x97") << sphereScal e << ")";
oss << "</h2>"; oss << "</h2>";
if (!nameIsProvisionalDesignation && !provisionalDesignation Html.isEmpty()) if (!nameIsProvisionalDesignation && !provisionalDesignation Html.isEmpty())
{ {
oss << QString(q_("Provisional designation: %1")).ar g(provisionalDesignationHtml); oss << QString(q_("Provisional designation: %1")).ar g(provisionalDesignationHtml);
oss << "<br>"; oss << "<br>";
} }
} }
if (flags&Magnitude) if (flags&Magnitude)
oss << q_("Magnitude: <b>%1</b>").arg(getVMagnitude(nav), 0, 'f', 2) << "<br>"; oss << q_("Magnitude: <b>%1</b>").arg(getVMagnitude(core), 0 , 'f', 2) << "<br>";
if (flags&AbsoluteMagnitude) if (flags&AbsoluteMagnitude)
{ {
//TODO: Make sure absolute magnitude is a sane value //TODO: Make sure absolute magnitude is a sane value
//If the H-G system is not used, use the default radius/albe do mechanism //If the H-G system is not used, use the default radius/albe do mechanism
if (slopeParameter < 0) if (slopeParameter < 0)
{ {
oss << q_("Absolute Magnitude: %1").arg(getVMagnitud e(nav) - 5. * (std::log10(getJ2000EquatorialPos(nav).length()*AU/PARSEC)-1. ), 0, 'f', 2) << "<br>"; oss << q_("Absolute Magnitude: %1").arg(getVMagnitud e(core) - 5. * (std::log10(getJ2000EquatorialPos(core).length()*AU/PARSEC)- 1.), 0, 'f', 2) << "<br>";
} }
else else
{ {
oss << q_("Absolute Magnitude: %1").arg(absoluteMagn itude, 0, 'f', 2) << "<br>"; oss << q_("Absolute Magnitude: %1").arg(absoluteMagn itude, 0, 'f', 2) << "<br>";
} }
} }
oss << getPositionInfoString(core, flags); oss << getPositionInfoString(core, flags);
if (flags&Distance) if (flags&Distance)
{ {
// xgettext:no-c-format // xgettext:no-c-format
oss << q_("Distance: %1AU").arg(getJ2000EquatorialPos(nav).l ength(), 0, 'f', 8) << "<br>"; oss << q_("Distance: %1AU").arg(getJ2000EquatorialPos(core). length(), 0, 'f', 8) << "<br>";
} }
if (flags&Size) if (flags&Size)
oss << q_("Apparent diameter: %1").arg(StelUtils::radToDmsSt r(2.*getAngularSize(core)*M_PI/180., true)); oss << q_("Apparent diameter: %1").arg(StelUtils::radToDmsSt r(2.*getAngularSize(core)*M_PI/180., true));
//This doesn't work, even if setOpenExternalLinks(true) is used in I nfoPanel //This doesn't work, even if setOpenExternalLinks(true) is used in I nfoPanel
/* /*
if (flags&Extra1) if (flags&Extra1)
oss << QString("<br><a href=\"http://ssd.jpl.nasa.gov/sbdb.c gi?sstr=%1\">JPL Small-Body Database Browser</a>").arg( (minorPlanetNumber) ? QString::number(minorPlanetNumber) : englishName ); oss << QString("<br><a href=\"http://ssd.jpl.nasa.gov/sbdb.c gi?sstr=%1\">JPL Small-Body Database Browser</a>").arg( (minorPlanetNumber) ? QString::number(minorPlanetNumber) : englishName );
*/ */
postProcessInfoString(str, flags); postProcessInfoString(str, flags);
return str; return str;
} }
float MinorPlanet::getVMagnitude(const StelNavigator *nav) const float MinorPlanet::getVMagnitude(const StelCore* core) const
{ {
//If the H-G system is not used, use the default radius/albedo mecha nism //If the H-G system is not used, use the default radius/albedo mecha nism
if (slopeParameter < 0) if (slopeParameter < 0)
{ {
return Planet::getVMagnitude(nav); return Planet::getVMagnitude(core);
} }
//Calculate phase angle //Calculate phase angle
//(Code copied from Planet::getVMagnitude()) //(Code copied from Planet::getVMagnitude())
//(LOL, this is actually vector substraction + the cosine theorem :) ) //(LOL, this is actually vector substraction + the cosine theorem :) )
const Vec3d& observerHelioPos = nav->getObserverHeliocentricEcliptic Pos(); const Vec3d& observerHelioPos = core->getObserverHeliocentricEclipti cPos();
const double observerRq = observerHelioPos.lengthSquared(); const double observerRq = observerHelioPos.lengthSquared();
const Vec3d& planetHelioPos = getHeliocentricEclipticPos(); const Vec3d& planetHelioPos = getHeliocentricEclipticPos();
const double planetRq = planetHelioPos.lengthSquared(); const double planetRq = planetHelioPos.lengthSquared();
const double observerPlanetRq = (observerHelioPos - planetHelioPos). lengthSquared(); const double observerPlanetRq = (observerHelioPos - planetHelioPos). lengthSquared();
const double cos_chi = (observerPlanetRq + planetRq - observerRq)/(2 .0*sqrt(observerPlanetRq*planetRq)); const double cos_chi = (observerPlanetRq + planetRq - observerRq)/(2 .0*sqrt(observerPlanetRq*planetRq));
double phaseAngle = std::acos(cos_chi); double phaseAngle = std::acos(cos_chi);
//Calculate reduced magnitude (magnitude without the influence of di stance) //Calculate reduced magnitude (magnitude without the influence of di stance)
//Source of the formulae: http://www.britastro.org/asteroids/dymock4 .pdf //Source of the formulae: http://www.britastro.org/asteroids/dymock4 .pdf
const double phi1 = std::exp(-3.33 * std::pow(std::tan(phaseAngle/2) , 0.63)); const double phi1 = std::exp(-3.33 * std::pow(std::tan(phaseAngle/2) , 0.63));
 End of changes. 10 change blocks. 
10 lines changed or deleted 9 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/