Comet.cpp   Comet.cpp 
skipping to change at line 24 skipping to change at line 24
* *
* 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 "Comet.hpp" #include "Comet.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>
Comet::Comet(const QString& englishName, Comet::Comet(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));
//Comet specific members //Comet specific members
absoluteMagnitude = 0; absoluteMagnitude = 0;
slopeParameter = -1;//== uninitialized: used in getVMagnitude() slopeParameter = -1;//== uninitialized: used in getVMagnitude()
skipping to change at line 103 skipping to change at line 103
//TODO: More checks? //TODO: More checks?
//TODO: Make it set-once like the number? //TODO: Make it set-once like the number?
absoluteMagnitude = magnitude; absoluteMagnitude = magnitude;
slopeParameter = slope; slopeParameter = slope;
} }
QString Comet::getInfoString(const StelCore *core, const InfoStringGroup &f lags) const QString Comet::getInfoString(const StelCore *core, const InfoStringGroup &f lags) 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>";
oss << q_(englishName); // UI translation can differ from s ky translation oss << q_(englishName); // UI translation can differ from s ky translation
oss.setRealNumberNotation(QTextStream::FixedNotation); oss.setRealNumberNotation(QTextStream::FixedNotation);
oss.setRealNumberPrecision(1); oss.setRealNumberPrecision(1);
if (sphereScale != 1.f) if (sphereScale != 1.f)
oss << QString::fromUtf8(" (\xC3\x97") << sphereScal e << ")"; oss << QString::fromUtf8(" (\xC3\x97") << sphereScal e << ")";
oss << "</h2>"; oss << "</h2>";
} }
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 two parameter magnitude system is not use, don't di splay this //If the two parameter magnitude system is not use, don't di splay this
//value. (Using radius/albedo doesn't make any sense for com ets.) //value. (Using radius/albedo doesn't make any sense for com ets.)
if (slopeParameter >= 0) if (slopeParameter >= 0)
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));
*/ */
postProcessInfoString(str, flags); postProcessInfoString(str, flags);
return str; return str;
} }
float Comet::getVMagnitude(const StelNavigator *nav) const float Comet::getVMagnitude(const StelCore* core) const
{ {
//If the two parameter system is not used, //If the two parameter system is not used,
//use the default radius/albedo mechanism //use the default radius/albedo mechanism
if (slopeParameter < 0) if (slopeParameter < 0)
{ {
return Planet::getVMagnitude(nav); return Planet::getVMagnitude(core);
} }
//Calculate distances //Calculate distances
const Vec3d& observerHeliocentricPosition = nav->getObserverHeliocen tricEclipticPos(); const Vec3d& observerHeliocentricPosition = core->getObserverHelioce ntricEclipticPos();
const Vec3d& cometHeliocentricPosition = getHeliocentricEclipticPos( ); const Vec3d& cometHeliocentricPosition = getHeliocentricEclipticPos( );
const double cometSunDistance = std::sqrt(cometHeliocentricPosition. lengthSquared()); const double cometSunDistance = std::sqrt(cometHeliocentricPosition. lengthSquared());
const double observerCometDistance = std::sqrt((observerHeliocentric Position - cometHeliocentricPosition).lengthSquared()); const double observerCometDistance = std::sqrt((observerHeliocentric Position - cometHeliocentricPosition).lengthSquared());
//Calculate apparent magnitude //Calculate apparent magnitude
//Sources: http://www.clearskyinstitute.com/xephem/help/xephem.html# mozTocId564354 //Sources: http://www.clearskyinstitute.com/xephem/help/xephem.html# mozTocId564354
//(XEphem manual, section 7.1.2.3 "Magnitude models"), also //(XEphem manual, section 7.1.2.3 "Magnitude models"), also
//http://www.ayton.id.au/gary/Science/Astronomy/Ast_comets.htm#Comet %20facts: //http://www.ayton.id.au/gary/Science/Astronomy/Ast_comets.htm#Comet %20facts:
double apparentMagnitude = absoluteMagnitude + 5 * std::log10(observ erCometDistance) + 2.5 * slopeParameter * std::log10(cometSunDistance); double apparentMagnitude = absoluteMagnitude + 5 * std::log10(observ erCometDistance) + 2.5 * slopeParameter * std::log10(cometSunDistance);
 End of changes. 9 change blocks. 
10 lines changed or deleted 8 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/