Pulsar.cpp   Pulsar.cpp 
skipping to change at line 19 skipping to change at line 19
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* 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 "config.h"
#include "Pulsar.hpp" #include "Pulsar.hpp"
#include "Pulsars.hpp" #include "Pulsars.hpp"
#include "StelObject.hpp" #include "StelObject.hpp"
#include "StelPainter.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.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 "renderer/StelRenderer.hpp" #include "StelProjector.hpp"
#include <QTextStream> #include <QTextStream>
#include <QDebug> #include <QDebug>
#include <QVariant> #include <QVariant>
#include <QVariantMap> #include <QVariantMap>
#include <QVariant> #include <QVariant>
#include <QList> #include <QList>
#define PSR_INERTIA 1.0e45 /* Typical moment of inertia for a pulsar */ #define PSR_INERTIA 1.0e45 /* Typical moment of inertia for a pulsar */
StelTextureSP Pulsar::markerTexture;
bool Pulsar::distributionMode = false;
bool Pulsar::glitchFlag = false;
Vec3f Pulsar::markerColor = Vec3f(0.4f,0.5f,1.0f);
Vec3f Pulsar::glitchColor = Vec3f(0.2f,0.3f,1.0f);
Pulsar::Pulsar(const QVariantMap& map) Pulsar::Pulsar(const QVariantMap& map)
: initialized(false) : initialized(false),
designation(""),
RA(0.),
DE(0.),
parallax(0.),
period(0.),
frequency(0.),
pfrequency(0.),
pderivative(0.),
dmeasure(0.),
bperiod(0.),
eccentricity(0.),
w50(0.),
s400(0.),
s600(0.),
s1400(0.),
distance(0.),
glitch(-1),
notes("")
{ {
// 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();
parallax = map.value("parallax").toFloat(); parallax = map.value("parallax").toFloat();
period = map.value("period").toDouble(); period = map.value("period").toDouble();
bperiod = map.value("bperiod").toDouble(); bperiod = map.value("bperiod").toDouble();
frequency = map.value("frequency").toDouble(); frequency = map.value("frequency").toDouble();
skipping to change at line 62 skipping to change at line 91
pderivative = map.value("pderivative").toDouble(); pderivative = map.value("pderivative").toDouble();
dmeasure = map.value("dmeasure").toDouble(); dmeasure = map.value("dmeasure").toDouble();
eccentricity = map.value("eccentricity").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());
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(); distance = map.value("distance").toFloat();
glitch = map.value("glitch").toInt();
notes = map.value("notes").toString(); notes = map.value("notes").toString();
// If barycentric period not set then calculate it // If barycentric period not set then calculate it
if (period==0 && frequency>0) if (period==0 && frequency>0)
{ {
period = 1/frequency; period = 1/frequency;
} }
// If barycentric period derivative not set then calculate it // If barycentric period derivative not set then calculate it
if (pderivative==0) if (pderivative==0)
{ {
skipping to change at line 102 skipping to change at line 132
map["dmeasure"] = dmeasure; map["dmeasure"] = dmeasure;
map["eccentricity"] = eccentricity; map["eccentricity"] = eccentricity;
map["RA"] = RA; map["RA"] = RA;
map["DE"] = DE; map["DE"] = DE;
map["period"] = period; map["period"] = period;
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["distance"] = distance;
map["glitch"] = glitch;
map["notes"] = notes; 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() return StelObject::getSelectPriority(core)-2.f;
return getVMagnitude(core, false);
} }
QString Pulsar::getInfoString(const StelCore* core, const InfoStringGroup& flags) const QString Pulsar::getInfoString(const StelCore* core, const InfoStringGroup& flags) const
{ {
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&ObjectType)
{ {
oss << q_("Type: <b>%1</b>").arg(q_("pulsar")) << "<br />";
if (glitch==0)
oss << q_("Type: <b>%1</b>").arg(q_("pulsar")) << "<
br />";
else
{
QString sglitch;
if (glitch==1)
sglitch = q_("has one registered glitch");
else
{
// TRANSLATORS: Full phrase is "Has X regist
ered glitches", where X is number
sglitch = q_("has %1 registered glitches").a
rg(glitch);
}
oss << q_("Type: <b>%1</b> (%2)").arg(q_("pulsar wit
h glitches")).arg(sglitch) << "<br />";
}
} }
// Ra/Dec etc. // Ra/Dec etc.
oss << getPositionInfoString(core, flags); oss << getPositionInfoString(core, flags);
if (flags&Extra1) if (flags&Extra)
{ {
if (period>0) if (period>0)
{ {
//TRANSLATORS: Unit of measure for period - seconds //TRANSLATORS: Unit of measure for period - seconds
oss << q_("Barycentric period: %1 s").arg(QString::n umber(period, 'f', 16)) << "<br>"; oss << q_("Barycentric period: %1 s").arg(QString::n umber(period, 'f', 16)) << "<br>";
} }
if (pderivative>0) if (pderivative>0)
{ {
oss << q_("Time derivative of barycentric period: %1 ").arg(QString::number(pderivative, 'e', 5)) << "<br>"; oss << q_("Time derivative of barycentric period: %1 ").arg(QString::number(pderivative, 'e', 5)) << "<br>";
} }
skipping to change at line 228 skipping to change at line 272
oss << "<br>" << q_("Notes: %1").arg(getPulsarTypeIn foString(notes)) << "<br>"; 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 Vec3f(1.0, 1.0, 1.0);
} }
float Pulsar::getVMagnitude(const StelCore* core, bool withExtinction) cons t float Pulsar::getVMagnitude(const StelCore* core) const
{ {
float extinctionMag=0.0; // track magnitude loss Q_UNUSED(core);
if (withExtinction && core->getSkyDrawer()->getFlagHasAtmosphere())
{
Vec3d altAz=getAltAzPosApparent(core);
altAz.normalize();
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;
if (GETSTELMODULE(Pulsars)->getDisplayMode()) if (distributionMode)
{ {
return 3.f; return 3.f;
} }
else else
{ {
return vmag + extinctionMag; return vmag;
} }
} }
float Pulsar::getVMagnitudeWithExtinction(const StelCore *core) const
{
return getVMagnitude(core);
}
double Pulsar::getEdot(double p0, double p1) const double Pulsar::getEdot(double p0, double p1) const
{ {
if (p0>0 && p1!=0) if (p0>0 && p1!=0)
{ {
// Calculate spin down energy loss rate (ergs/s) // Calculate spin down energy loss rate (ergs/s)
return 4.0 * M_PI * M_PI * PSR_INERTIA * p1 / pow(p0,3); return 4.0 * M_PI * M_PI * PSR_INERTIA * p1 / pow(p0,3);
} }
else else
{ {
return 0.0; return 0.0;
skipping to change at line 332 skipping to change at line 374
double Pulsar::getAngularSize(const StelCore*) const double Pulsar::getAngularSize(const StelCore*) const
{ {
return 0.00001; return 0.00001;
} }
void Pulsar::update(double deltaTime) void Pulsar::update(double deltaTime)
{ {
labelsFader.update((int)(deltaTime*1000)); labelsFader.update((int)(deltaTime*1000));
} }
void Pulsar::draw(StelCore* core, StelRenderer* renderer, StelProjectorP pr void Pulsar::draw(StelCore* core, StelPainter *painter)
ojector,
StelTextureNew* markerTexture)
{ {
StelSkyDrawer* sd = core->getSkyDrawer(); StelSkyDrawer* sd = core->getSkyDrawer();
double mag = getVMagnitudeWithExtinction(core);
StelUtils::spheToRect(RA, DE, XYZ);
Vec3f color = Vec3f(0.4f,0.5f,1.2f); Vec3d win;
if (StelApp::getInstance().getVisionModeNight()) // Check visibility of pulsar
color = StelUtils::getNightColor(color); if (!(painter->getProjector()->projectCheck(XYZ, win)))
return;
double mag = getVMagnitude(core, true);
StelUtils::spheToRect(RA, DE, XYZ); glEnable(GL_BLEND);
renderer->setBlendMode(BlendMode_Add); glBlendFunc(GL_ONE, GL_ONE);
renderer->setGlobalColor(color[0], color[1], color[2]); if (glitch>0 && glitchFlag)
painter->setColor(glitchColor[0], glitchColor[1], glitchColo
r[2], 1);
else
painter->setColor(markerColor[0], markerColor[1], markerColo
r[2], 1);
float mlimit = sd->getLimitMagnitude();
if (mag <= sd->getLimitMagnitude()) if (mag <= mlimit)
{ {
markerTexture->bind(); Pulsar::markerTexture->bind();
const float size = getAngularSize(NULL)*M_PI/180.*projector- float size = getAngularSize(NULL)*M_PI/180.*painter->getProj
>getPixelPerRadAtCenter(); ector()->getPixelPerRadAtCenter();
const float shift = 5.f + size/1.6f; float shift = 5.f + size/1.6f;
if (labelsFader.getInterstate()<=0.f)
{ painter->drawSprite2dMode(XYZ, distributionMode ? 4.f : 5.f)
Vec3d win; ;
if(!projector->project(XYZ, win)){return;}
if (GETSTELMODULE(Pulsars)->getDisplayMode()) if (labelsFader.getInterstate()<=0.f && !distributionMode &&
{ (mag+2.f)<mlimit)
renderer->drawTexturedRect(win[0] - 4, win[1 {
] - 4, 8, 8); painter->drawText(XYZ, designation, 0, shift, shift,
} false);
else
{
renderer->drawTexturedRect(win[0] - 5, win[1
] - 5, 10, 10);
renderer->drawText(TextParams(XYZ, projector
, designation).shift(shift, shift).useGravity());
}
} }
} }
} }
 End of changes. 24 change blocks. 
52 lines changed or deleted 95 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/