Pulsar.cpp   Pulsar.cpp 
skipping to change at line 20 skipping to change at line 20
* 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 "Pulsar.hpp" #include "Pulsar.hpp"
#include "Pulsars.hpp"
#include "StelObject.hpp" #include "StelObject.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include "StelTexture.hpp" #include "StelTexture.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelSkyDrawer.hpp" #include "StelSkyDrawer.hpp"
#include <QTextStream> #include <QTextStream>
#include <QDebug> #include <QDebug>
#include <QVariant> #include <QVariant>
#include <QtOpenGL> #include <QtOpenGL>
#include <QVariantMap> #include <QVariantMap>
#include <QVariant> #include <QVariant>
#include <QList> #include <QList>
#define PSR_INERTIA 1.0e45 /* Typical moment of inertia for a pulsar */
StelTextureSP Pulsar::markerTexture; StelTextureSP Pulsar::markerTexture;
Pulsar::Pulsar(const QVariantMap& map) Pulsar::Pulsar(const QVariantMap& map)
: initialized(false) : initialized(false)
{ {
// return initialized if the mandatory fields are not present // return initialized if the mandatory fields are not present
if (!map.contains("designation")) if (!map.contains("designation"))
return; return;
designation = map.value("designation").toString(); designation = map.value("designation").toString();
distance = map.value("distance").toFloat(); parallax = map.value("parallax").toFloat();
period = map.value("period").toDouble(); period = map.value("period").toDouble();
bperiod = map.value("bperiod").toDouble();
frequency = map.value("frequency").toDouble();
pfrequency = map.value("pfrequency").toDouble();
pderivative = map.value("pderivative").toDouble();
dmeasure = map.value("dmeasure").toDouble();
eccentricity = map.value("eccentricity").toDouble();
RA = StelUtils::getDecAngle(map.value("RA").toString()); RA = StelUtils::getDecAngle(map.value("RA").toString());
DE = StelUtils::getDecAngle(map.value("DE").toString()); DE = StelUtils::getDecAngle(map.value("DE").toString());
ntype = map.value("ntype").toInt();
We = map.value("We").toFloat();
w50 = map.value("w50").toFloat(); w50 = map.value("w50").toFloat();
s400 = map.value("s400").toFloat(); s400 = map.value("s400").toFloat();
s600 = map.value("s600").toFloat(); s600 = map.value("s600").toFloat();
s1400 = map.value("s1400").toFloat(); s1400 = map.value("s1400").toFloat();
distance = map.value("distance").toFloat();
notes = map.value("notes").toString();
// If barycentric period not set then calculate it
if (period==0 && frequency>0)
{
period = 1/frequency;
}
// If barycentric period derivative not set then calculate it
if (pderivative==0)
{
pderivative = getP1(period, pfrequency);
}
initialized = true; initialized = true;
} }
Pulsar::~Pulsar() Pulsar::~Pulsar()
{ {
// //
} }
QVariantMap Pulsar::getMap(void) QVariantMap Pulsar::getMap(void)
{ {
QVariantMap map; QVariantMap map;
map["designation"] = designation; map["designation"] = designation;
map["distance"] = distance; map["parallax"] = parallax;
map["bperiod"] = bperiod;
map["frequency"] = frequency;
map["pfrequency"] = pfrequency;
map["pderivative"] = pderivative;
map["dmeasure"] = dmeasure;
map["eccentricity"] = eccentricity;
map["RA"] = RA; map["RA"] = RA;
map["DE"] = DE; map["DE"] = DE;
map["period"] = period; map["period"] = period;
map["ntype"] = ntype;
map["We"] = We;
map["w50"] = w50; map["w50"] = w50;
map["s400"] = s400; map["s400"] = s400;
map["s600"] = s600; map["s600"] = s600;
map["s1400"] = s1400; map["s1400"] = s1400;
map["distance"] = distance;
map["notes"] = notes;
return map; return map;
} }
float Pulsar::getSelectPriority(const StelCore* core) const float Pulsar::getSelectPriority(const StelCore* core) const
{ {
//Same as StarWrapper::getSelectPriority() //Same as StarWrapper::getSelectPriority()
return getVMagnitude(core, false); return getVMagnitude(core, false);
} }
skipping to change at line 102 skipping to change at line 128
{ {
QString str; QString str;
QTextStream oss(&str); QTextStream oss(&str);
if (flags&Name) if (flags&Name)
{ {
oss << "<h2>" << designation << "</h2>"; oss << "<h2>" << designation << "</h2>";
} }
if (flags&Extra1) if (flags&Extra1)
oss << q_("Type: <b>%1</b>").arg(q_("pulsar")) << "<br />"; {
oss << q_("Type: <b>%1</b>").arg(q_("pulsar")) << "<br />";
}
// Ra/Dec etc. // Ra/Dec etc.
oss << getPositionInfoString(core, flags); oss << getPositionInfoString(core, flags);
if (flags&Extra1) if (flags&Extra1)
{ {
oss << q_("Barycentric period: %1 s").arg(QString::number(pe if (period>0)
riod, 'f', 16)) << "<br>";
if (distance>0)
{ {
oss << q_("Distance: %1 kpc (%2 ly)").arg(distance). //TRANSLATORS: Unit of measure for period - seconds
arg(distance*3261.563777) << "<br>"; oss << q_("Barycentric period: %1 s").arg(QString::n
umber(period, 'f', 16)) << "<br>";
} }
if (ntype>0) if (pderivative>0)
{ {
oss << q_("Type of pulsar: %1").arg(getPulsarTypeInf oString(ntype)) << "<br>"; oss << q_("Time derivative of barycentric period: %1 ").arg(QString::number(pderivative, 'e', 5)) << "<br>";
} }
if (We>0) if (dmeasure>0)
{ {
oss << q_("Equivalent width of the integrated pulse oss << QString("%1 %2 %3<sup>-3</sup> %4 %5")
profile: %1 ms").arg(QString::number(We, 'f', 2)) << "<br>"; .arg(q_("Dispersion measure:"))
.arg(QString::number(dmeasure, 'f', 3))
//TRANSLATORS: Unit of measure for distance -
centimeters
.arg(q_("cm"))
.arg(QChar(0x00B7))
//TRANSLATORS: Unit of measure for distance -
parsecs
.arg(q_("pc"));
oss << "<br>";
}
double edot = getEdot(period, pderivative);
if (edot>0)
{
oss << q_("Spin down energy loss rate: %1 ergs/s").a
rg(QString::number(edot, 'e', 2)) << "<br>";
}
if (bperiod>0)
{
oss << q_("Binary period of pulsar: %1 days").arg(QS
tring::number(bperiod, 'f', 12)) << "<br>";
}
if (eccentricity>0)
{
oss << q_("Eccentricity: %1").arg(QString::number(ec
centricity, 'f', 10)) << "<br>";
}
if (parallax>0)
{
//TRANSLATORS: Unit of measure for annual parallax -
milliarcseconds
oss << q_("Annual parallax: %1 mas").arg(parallax) <
< "<br>";
}
if (distance>0)
{
oss << q_("Distance based on electron density model:
%1 kpc (%2 ly)").arg(distance).arg(distance*3261.563777) << "<br>";
} }
if (w50>0) if (w50>0)
{ {
oss << q_("Profile width at 50% of peak: %1 ms").arg (QString::number(w50, 'f', 2)) << "<br>"; oss << q_("Profile width at 50% of peak: %1 ms").arg (QString::number(w50, 'f', 2)) << "<br>";
} }
if (s400>0) if (s400>0)
{ {
oss << QString("%1 %2%3: %4 %5") oss << QString("%1 %2%3: %4 %5")
// TRANSLATORS: Full phrase is "Time averaged flux density at XXXMHz" // TRANSLATORS: Full phrase is "Time averaged flux density at XXXMHz"
.arg(q_("Time averaged flux density at")) .arg(q_("Time averaged flux density at"))
skipping to change at line 162 skipping to change at line 220
oss << QString("%1 %2%3: %4 %5") oss << QString("%1 %2%3: %4 %5")
// TRANSLATORS: Full phrase is "Time averaged flux density at XXXMHz" // TRANSLATORS: Full phrase is "Time averaged flux density at XXXMHz"
.arg(q_("Time averaged flux density at")) .arg(q_("Time averaged flux density at"))
.arg(1400) .arg(1400)
// TRANSLATORS: Unit of measurement of freque ncy // TRANSLATORS: Unit of measurement of freque ncy
.arg(q_("MHz")) .arg(q_("MHz"))
.arg(QString::number(s1400, 'f', 2)) .arg(QString::number(s1400, 'f', 2))
// TRANSLATORS: mJy is milliJansky(10-26W/m2/ Hz) // TRANSLATORS: mJy is milliJansky(10-26W/m2/ Hz)
.arg(q_("mJy")) << "<br>"; .arg(q_("mJy")) << "<br>";
} }
if (notes.length()>0)
{
oss << "<br>" << q_("Notes: %1").arg(getPulsarTypeIn
foString(notes)) << "<br>";
}
} }
postProcessInfoString(str, flags); postProcessInfoString(str, flags);
return str; return str;
} }
Vec3f Pulsar::getInfoColor(void) const Vec3f Pulsar::getInfoColor(void) const
{ {
return StelApp::getInstance().getVisionModeNight() ? Vec3f(0.6, 0.0, 0.0) : Vec3f(1.0, 1.0, 1.0); return StelApp::getInstance().getVisionModeNight() ? Vec3f(0.6, 0.0, 0.0) : Vec3f(1.0, 1.0, 1.0);
} }
skipping to change at line 186 skipping to change at line 248
if (withExtinction && core->getSkyDrawer()->getFlagHasAtmosphere()) if (withExtinction && core->getSkyDrawer()->getFlagHasAtmosphere())
{ {
Vec3d altAz=getAltAzPosApparent(core); Vec3d altAz=getAltAzPosApparent(core);
altAz.normalize(); altAz.normalize();
core->getSkyDrawer()->getExtinction().forward(&altAz[2], &extinc tionMag); core->getSkyDrawer()->getExtinction().forward(&altAz[2], &extinc tionMag);
} }
// Calculate fake visual magnitude as function by distance - minimal magnitude is 6 // Calculate fake visual magnitude as function by distance - minimal magnitude is 6
float vmag = distance + 6.f; float vmag = distance + 6.f;
return vmag + extinctionMag; if (GETSTELMODULE(Pulsars)->getDisplayMode())
} {
return 3.f;
double Pulsar::getAngularSize(const StelCore*) const }
{ else
return 0.00001; {
return vmag + extinctionMag;
}
} }
void Pulsar::update(double deltaTime) double Pulsar::getEdot(double p0, double p1) const
{ {
labelsFader.update((int)(deltaTime*1000)); if (p0>0 && p1!=0)
{
// Calculate spin down energy loss rate (ergs/s)
return 4.0 * M_PI * M_PI * PSR_INERTIA * p1 / pow(p0,3);
}
else
{
return 0.0;
}
} }
void Pulsar::draw(StelCore* core, StelPainter& painter) double Pulsar::getP1(double p0, double f1) const
{ {
StelSkyDrawer* sd = core->getSkyDrawer(); if (p0>0 && f1!=0)
Vec3f color = Vec3f(0.4f,0.5f,1.2f);
double mag = getVMagnitude(core, true);
StelUtils::spheToRect(RA, DE, XYZ);
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
painter.setColor(color[0], color[1], color[2], 1);
if (mag <= sd->getLimitMagnitude())
{ {
// Calculate derivative of barycentric period
Pulsar::markerTexture->bind(); return -1.0 * p0 * p0 * f1;
float size = getAngularSize(NULL)*M_PI/180.*painter.getProje }
ctor()->getPixelPerRadAtCenter(); else
float shift = 5.f + size/1.6f; {
if (labelsFader.getInterstate()<=0.f) return 0.0;
{
painter.drawSprite2dMode(XYZ, 5);
painter.drawText(XYZ, designation, 0, shift, shift,
false);
}
} }
} }
QString Pulsar::getPulsarTypeInfoString(const int flags) const QString Pulsar::getPulsarTypeInfoString(QString pcode) const
{ {
QStringList out; QStringList out;
if (flags&C) if (pcode.contains("AXP"))
{ {
// TRANSLATORS: Type of pulsar out.append(q_("anomalous X-ray pulsar or soft gamma-ray repe
out.append(q_("globular cluster association")); ater with detected pulsations"));
} }
if (flags&S) if (pcode.contains("BINARY") || bperiod>0)
{ {
// TRANSLATORS: Type of pulsar out.append(q_("has one or more binary companions"));
out.append(q_("SNR association"));
} }
if (flags&G) if (pcode.contains("HE"))
{ {
// TRANSLATORS: Type of pulsar out.append(q_("with pulsed emission from radio to infrared o
out.append(q_("glitches in period")); r higher frequencies"));
} }
if (flags&B) if (pcode.contains("NRAD"))
{ {
// TRANSLATORS: Type of pulsar out.append(q_("with pulsed emission only at infrared or high
out.append(q_("binary or multiple pulsar")); er frequencies"));
} }
if (flags&M) if (pcode.contains("RADIO"))
{ {
// TRANSLATORS: Type of pulsar out.append(q_("with pulsed emission in the radio band"));
out.append(q_("millisecond pulsar"));
} }
if (flags&R) if (pcode.contains("RRAT"))
{ {
// TRANSLATORS: Type of pulsar out.append(q_("with intermittently pulsed radio emission"));
out.append(q_("recycled pulsar"));
} }
if (flags&I) if (pcode.contains("XINS"))
{ {
// TRANSLATORS: Type of pulsar out.append(q_("isolated neutron star with pulsed thermal X-r
out.append(q_("radio interpulse")); ay emission but no detectable radio emission"));
} }
if (flags&H) return out.join(",<br />");
{ }
// TRANSLATORS: Type of pulsar
out.append(q_("optical, X-ray or Gamma-ray pulsed emission ( double Pulsar::getAngularSize(const StelCore*) const
high energy)")); {
} return 0.00001;
}
void Pulsar::update(double deltaTime)
{
labelsFader.update((int)(deltaTime*1000));
}
void Pulsar::draw(StelCore* core, StelPainter& painter)
{
StelSkyDrawer* sd = core->getSkyDrawer();
Vec3f color = Vec3f(0.4f,0.5f,1.2f);
if (StelApp::getInstance().getVisionModeNight())
color = StelUtils::getNightColor(color);
double mag = getVMagnitude(core, true);
StelUtils::spheToRect(RA, DE, XYZ);
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE);
painter.setColor(color[0], color[1], color[2], 1);
if (flags&E) if (mag <= sd->getLimitMagnitude())
{ {
// TRANSLATORS: Type of pulsar
out.append(q_("extragalactic (in MC) pulsar"));
}
return out.join(", "); Pulsar::markerTexture->bind();
float size = getAngularSize(NULL)*M_PI/180.*painter.getProje
ctor()->getPixelPerRadAtCenter();
float shift = 5.f + size/1.6f;
if (labelsFader.getInterstate()<=0.f)
{
if (GETSTELMODULE(Pulsars)->getDisplayMode())
{
painter.drawSprite2dMode(XYZ, 4);
painter.drawText(XYZ, " ", 0, shift, shift,
false);
}
else
{
painter.drawSprite2dMode(XYZ, 5);
painter.drawText(XYZ, designation, 0, shift,
shift, false);
}
}
}
} }
 End of changes. 42 change blocks. 
81 lines changed or deleted 179 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/