Supernova.cpp   Supernova.cpp 
skipping to change at line 21 skipping to change at line 21
* 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 "Supernova.hpp" #include "Supernova.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 "StarMgr.hpp"
#include "StelRenderer.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StarMgr.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>
Supernova::Supernova(const QVariantMap& map) Supernova::Supernova(const QVariantMap& map)
: initialized(false) : initialized(false),
designation(""),
sntype(""),
maxMagnitude(21.),
peakJD(0.),
snra(0.),
snde(0.),
note(""),
distance(0.)
{ {
// 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();
sntype = map.value("type").toString(); sntype = map.value("type").toString();
maxMagnitude = map.value("maxMagnitude").toFloat(); maxMagnitude = map.value("maxMagnitude").toFloat();
peakJD = map.value("peakJD").toDouble(); peakJD = map.value("peakJD").toDouble();
snra = StelUtils::getDecAngle(map.value("alpha").toString()); snra = StelUtils::getDecAngle(map.value("alpha").toString());
skipping to change at line 77 skipping to change at line 86
map["maxMagnitude"] = maxMagnitude; map["maxMagnitude"] = maxMagnitude;
map["peakJD"] = peakJD; map["peakJD"] = peakJD;
map["snra"] = snra; map["snra"] = snra;
map["snde"] = snde; map["snde"] = snde;
map["note"] = note; map["note"] = note;
map["distance"] = distance; map["distance"] = distance;
return map; return map;
} }
float Supernova::getSelectPriority(const StelCore* core) const
{
//Same as StarWrapper::getSelectPriority()
return getVMagnitude(core, false);
}
QString Supernova::getNameI18n(void) const QString Supernova::getNameI18n(void) const
{ {
QString name = designation; QString name = designation;
if (note.size()!=0) if (note.size()!=0)
name = QString("%1 (%2)").arg(name).arg(q_(note)); name = QString("%1 (%2)").arg(name).arg(q_(note));
return name; return name;
} }
QString Supernova::getEnglishName(void) const QString Supernova::getEnglishName(void) const
skipping to change at line 108 skipping to change at line 111
return name; return name;
} }
QString Supernova::getMaxBrightnessDate(const double JD) const QString Supernova::getMaxBrightnessDate(const double JD) const
{ {
return StelApp::getInstance().getLocaleMgr().getPrintableDateLocal(J D); return StelApp::getInstance().getLocaleMgr().getPrintableDateLocal(J D);
} }
QString Supernova::getInfoString(const StelCore* core, const InfoStringGrou p& flags) const QString Supernova::getInfoString(const StelCore* core, const InfoStringGrou p& flags) const
{ {
QString str; float maglimit = 21.f;
QString str, mag = "--", mage = "--";
QTextStream oss(&str); QTextStream oss(&str);
double mag = getVMagnitude(core, false); if (getVMagnitude(core) <= maglimit)
{
mag = QString::number(getVMagnitude(core), 'f', 2);
mage = QString::number(getVMagnitudeWithExtinction(core), 'f
', 2);
}
if (flags&Name) if (flags&Name)
{ {
oss << "<h2>" << designation; oss << "<h2>" << designation;
if (note.size()!=0) if (note.size()!=0)
oss << " (" << q_(note) << ")"; oss << " (" << q_(note) << ")";
oss << "</h2>"; oss << "</h2>";
} }
if (flags&Extra1) if (flags&ObjectType)
oss << q_("Type: <b>%1</b>").arg(q_("supernova")) << "<br /> "; oss << q_("Type: <b>%1</b>").arg(q_("supernova")) << "<br /> ";
if (flags&Magnitude && mag <= core->getSkyDrawer()->getLimitMagnitud e()) if (flags&Magnitude)
{ {
if (core->getSkyDrawer()->getFlagHasAtmosphere()) if (core->getSkyDrawer()->getFlagHasAtmosphere() && getVMagnitud
oss << q_("Magnitude: <b>%1</b> (extincted to: <b>%2</b>)"). e(core) <= maglimit)
arg(QString::number(getVMagnitude(core, false), 'f', 2), oss << q_("Magnitude: <b>%1</b> (extincted to: <b>%2</b>)").
arg(mag, mage) << "<br>";
QString::number(getVMagnitude(core, true), 'f', 2)) << "<br>";
else else
oss << q_("Magnitude: <b>%1</b>").arg(mag, 0, 'f', 2) << "<b r>"; oss << q_("Magnitude: <b>%1</b>").arg(mag) << "<br>";
} }
// Ra/Dec etc. // Ra/Dec etc.
oss << getPositionInfoString(core, flags); oss << getPositionInfoString(core, flags);
if (flags&Extra1) if (flags&Extra)
{ {
oss << q_("Type of supernova: %1").arg(sntype) << "<br>"; oss << q_("Type of supernova: %1").arg(sntype) << "<br>";
oss << q_("Maximum brightness: %1").arg(getMaxBrightnessDate (peakJD)) << "<br>"; oss << q_("Maximum brightness: %1").arg(getMaxBrightnessDate (peakJD)) << "<br>";
if (distance>0) if (distance>0)
oss << q_("Distance: %1 Light Years").arg(distance*1 000) << "<br>"; oss << q_("Distance: %1 Light Years").arg(distance*1 000) << "<br>";
} }
postProcessInfoString(str, flags); postProcessInfoString(str, flags);
return str; return str;
} }
Vec3f Supernova::getInfoColor(void) const Vec3f Supernova::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 Supernova::getVMagnitude(const StelCore* core, bool withExtinction) c onst float Supernova::getVMagnitude(const StelCore* core) const
{ {
float extinctionMag=0.0; // track magnitude loss
if (withExtinction && core->getSkyDrawer()->getFlagHasAtmosphere())
{
Vec3d altAz=getAltAzPosApparent(core);
altAz.normalize();
core->getSkyDrawer()->getExtinction().forward(&altAz[2], &extinc
tionMag);
}
double vmag = 20; double vmag = 20;
double currentJD = core->getJDay(); double currentJD = core->getJDay();
double deltaJD = std::abs(peakJD-currentJD); double deltaJD = std::abs(peakJD-currentJD);
// Use supernova light curve model from here - http://www.astronet.r u/db/msg/1188703 // Use supernova light curve model from here - http://www.astronet.r u/db/msg/1188703
if (sntype.contains("II", Qt::CaseSensitive)) if (sntype.contains("II", Qt::CaseSensitive))
{ {
// Type II // Type II
if (peakJD<=currentJD) if (peakJD<=currentJD)
skipping to change at line 216 skipping to change at line 215
{ {
if (deltaJD<=15) if (deltaJD<=15)
vmag = maxMagnitude + 1.13 * deltaJD; vmag = maxMagnitude + 1.13 * deltaJD;
} }
} }
if (vmag<maxMagnitude) if (vmag<maxMagnitude)
vmag = maxMagnitude; vmag = maxMagnitude;
return vmag + extinctionMag; return vmag;
} }
double Supernova::getAngularSize(const StelCore*) const double Supernova::getAngularSize(const StelCore*) const
{ {
return 0.00001; return 0.00001;
} }
void Supernova::update(double deltaTime) void Supernova::update(double deltaTime)
{ {
labelsFader.update((int)(deltaTime*1000)); labelsFader.update((int)(deltaTime*1000));
} }
void Supernova::draw(StelCore* core, StelRenderer* renderer, StelProjectorP projector) void Supernova::draw(StelCore* core, StelPainter& painter)
{ {
StelSkyDrawer* sd = core->getSkyDrawer(); StelSkyDrawer* sd = core->getSkyDrawer();
StarMgr* smgr = GETSTELMODULE(StarMgr); // It's need for checking di splaying of labels for stars StarMgr* smgr = GETSTELMODULE(StarMgr); // It's need for checking di splaying of labels for stars
Vec3f color = Vec3f(1.f,1.f,1.f); Vec3f color = Vec3f(1.f,1.f,1.f);
if (StelApp::getInstance().getVisionModeNight()) RCMag rcMag;
color = StelUtils::getNightColor(color); float size, shift;
float rcMag[2], size, shift;
double mag; double mag;
StelUtils::spheToRect(snra, snde, XYZ); StelUtils::spheToRect(snra, snde, XYZ);
mag = getVMagnitude(core, true); mag = getVMagnitudeWithExtinction(core);
sd->preDrawPointSource(); sd->preDrawPointSource(&painter);
float mlimit = sd->getLimitMagnitude(); float mlimit = sd->getLimitMagnitude();
if (mag <= mlimit) if (mag <= mlimit)
{ {
sd->computeRCMag(mag, rcMag); sd->computeRCMag(mag, &rcMag);
const Vec3f XYZf(XYZ[0], XYZ[1], XYZ[2]); sd->drawPointSource(&painter, Vec3f(XYZ[0], XYZ[1], XYZ[2]),
Vec3f win; rcMag, color, false);
if(sd->pointSourceVisible(&(*projector), XYZf, rcMag, false, painter.setColor(color[0], color[1], color[2], 1);
win)) size = getAngularSize(NULL)*M_PI/180.*painter.getProjector()
{ ->getPixelPerRadAtCenter();
sd->drawPointSource(win, rcMag, color);
}
renderer->setGlobalColor(color[0], color[1], color[2], 1);
size = getAngularSize(NULL)*M_PI/180.*projector->getPixelPer
RadAtCenter();
shift = 6.f + size/1.8f; shift = 6.f + size/1.8f;
if (labelsFader.getInterstate()<=0.f && (mag+5.f)<mlimit && smgr->getFlagLabels()) if (labelsFader.getInterstate()<=0.f && (mag+5.f)<mlimit && smgr->getFlagLabels())
{ {
renderer->drawText(TextParams(XYZ, projector, design ation).shift(shift, shift).useGravity()); painter.drawText(XYZ, designation, 0, shift, shift, false);
} }
} }
sd->postDrawPointSource(projector); sd->postDrawPointSource(&painter);
} }
 End of changes. 23 change blocks. 
52 lines changed or deleted 44 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/