Nova.cpp   Nova.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 "Nova.hpp" #include "Nova.hpp"
#include "StelObject.hpp" #include "StelObject.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelCore.hpp" #include "StelCore.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 "StarMgr.hpp"
#include "StelRenderer.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelPainter.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>
Nova::Nova(const QVariantMap& map) Nova::Nova(const QVariantMap& map)
: initialized(false) : initialized(false),
designation(""),
novaName(""),
novaType(""),
maxMagnitude(21.),
minMagnitude(21.),
peakJD(0.),
m2(-1),
m3(-1),
m6(-1),
m9(-1),
RA(0.),
Dec(0.),
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();
novaName = map.value("name").toString(); novaName = map.value("name").toString();
novaType = map.value("type").toString(); novaType = map.value("type").toString();
maxMagnitude = map.value("maxMagnitude").toFloat(); maxMagnitude = map.value("maxMagnitude").toFloat();
minMagnitude = map.value("minMagnitude", 21).toFloat(); minMagnitude = map.value("minMagnitude", 21).toFloat();
skipping to change at line 87 skipping to change at line 102
map["m3"] = m3; map["m3"] = m3;
map["m6"] = m6; map["m6"] = m6;
map["m9"] = m9; map["m9"] = m9;
map["RA"] = RA; map["RA"] = RA;
map["Dec"] = Dec; map["Dec"] = Dec;
map["distance"] = distance; map["distance"] = distance;
return map; return map;
} }
float Nova::getSelectPriority(const StelCore* core) const
{
//Same as StarWrapper::getSelectPriority()
return getVMagnitude(core, false);
}
QString Nova::getEnglishName() const QString Nova::getEnglishName() const
{ {
return novaName; return novaName;
} }
QString Nova::getNameI18n() const QString Nova::getNameI18n() const
{ {
return novaName; return novaName;
} }
skipping to change at line 117 skipping to change at line 126
QString Nova::getMaxBrightnessDate(const double JD) const QString Nova::getMaxBrightnessDate(const double JD) const
{ {
return StelApp::getInstance().getLocaleMgr().getPrintableDateLocal(J D); return StelApp::getInstance().getLocaleMgr().getPrintableDateLocal(J D);
} }
QString Nova::getInfoString(const StelCore* core, const InfoStringGroup& fl ags) const QString Nova::getInfoString(const StelCore* core, const InfoStringGroup& fl ags) const
{ {
QString str; QString str;
QTextStream oss(&str); QTextStream oss(&str);
double mag = getVMagnitude(core, false); double mag = getVMagnitude(core);
if (flags&Name) if (flags&Name)
{ {
QString name = novaName.isEmpty() ? QString("<h2>%1</h2>").a rg(designation) : QString("<h2>%1 (%2)</h2>").arg(novaName).arg(designation ); QString name = novaName.isEmpty() ? QString("<h2>%1</h2>").a rg(designation) : QString("<h2>%1 (%2)</h2>").arg(novaName).arg(designation );
oss << name; oss << name;
} }
if (flags&Extra1) if (flags&ObjectType)
oss << q_("Type: <b>%1</b> (%2)").arg(q_("nova")).arg(novaTy pe) << "<br />"; oss << q_("Type: <b>%1</b> (%2)").arg(q_("nova")).arg(novaTy pe) << "<br />";
if (flags&Magnitude) if (flags&Magnitude)
{ {
if (core->getSkyDrawer()->getFlagHasAtmosphere()) if (core->getSkyDrawer()->getFlagHasAtmosphere())
oss << q_("Magnitude: <b>%1</b> (extincted to: <b>%2</b>)"). oss << q_("Magnitude: <b>%1</b> (extincted to: <b>%2</b>)").
arg(QString::number(getVMagnitude(core, false), 'f', 2), arg(QString::number(mag, 'f', 2),
QString::number(getVMagnitude(core, true), 'f', 2)) << "<br>"; QString::number(getVMagnitudeWithExtinction(core), '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, 0, 'f', 2) << "<b r>";
} }
// Ra/Dec etc. // Ra/Dec etc.
oss << getPositionInfoString(core, flags); oss << getPositionInfoString(core, flags);
if (flags&Extra1) if (flags&Extra)
{ {
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 Nova::getInfoColor(void) const Vec3f Nova::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 Nova::getVMagnitude(const StelCore* core, bool withExtinction) const float Nova::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], &ex
tinctionMag);
}
// OK, start from minimal brightness // OK, start from minimal brightness
double vmag = minMagnitude; double vmag = minMagnitude;
double currentJD = core->getJDay(); double currentJD = core->getJDay();
double deltaJD = std::abs(peakJD-currentJD); double deltaJD = std::abs(peakJD-currentJD);
// Fill "default" values for mX // Fill "default" values for mX
int t2; int t2 = m2;
if (m2 < 0) if (m2 < 0)
{ {
// m2 is unset, check type of nova // m2 is unset, check type of nova
if (novaType.contains("NA", Qt::CaseSensitive)) if (novaType.contains("NA", Qt::CaseSensitive))
t2 = 10; // Ok, "fast" nova t2 = 10; // Ok, "fast" nova
if (novaType.contains("NB", Qt::CaseSensitive)) if (novaType.contains("NB", Qt::CaseSensitive))
t2 = 80; // Ok, "slow" nova t2 = 80; // Ok, "slow" nova
if (novaType.contains("NC", Qt::CaseSensitive)) if (novaType.contains("NC", Qt::CaseSensitive))
t2 = 200; // Ok, "very slow" nova t2 = 200; // Ok, "very slow" nova
} }
else
t2 = m2;
int t3; int t3 = m3;
if (m3 < 0) if (m3 < 0)
{ {
// m3 is unset, check type of nova // m3 is unset, check type of nova
if (novaType.contains("NA", Qt::CaseSensitive)) if (novaType.contains("NA", Qt::CaseSensitive))
t3 = 30; // Ok, "fast" nova t3 = 30; // Ok, "fast" nova
if (novaType.contains("NB", Qt::CaseSensitive)) if (novaType.contains("NB", Qt::CaseSensitive))
t3 = 160; // Ok, "slow" nova t3 = 160; // Ok, "slow" nova
if (novaType.contains("NC", Qt::CaseSensitive)) if (novaType.contains("NC", Qt::CaseSensitive))
t3 = 300; // Ok, "very slow" nova t3 = 300; // Ok, "very slow" nova
} }
else
t3 = m3;
int t6; int t6 = m6;
if (m6 < 0) if (m6 < 0)
{ {
// m3 is unset, check type of nova // m3 is unset, check type of nova
if (novaType.contains("NA", Qt::CaseSensitive)) if (novaType.contains("NA", Qt::CaseSensitive))
t6 = 100; // Ok, "fast" nova t6 = 100; // Ok, "fast" nova
if (novaType.contains("NB", Qt::CaseSensitive)) if (novaType.contains("NB", Qt::CaseSensitive))
t6 = 300; // Ok, "slow" nova t6 = 300; // Ok, "slow" nova
if (novaType.contains("NC", Qt::CaseSensitive)) if (novaType.contains("NC", Qt::CaseSensitive))
t6 = 1200; // Ok, "very slow" nova t6 = 1200; // Ok, "very slow" nova
} }
else
t6 = m6;
int t9; int t9 = m9;
if (m9 < 0) if (m9 < 0)
{ {
// m3 is unset, check type of nova // m3 is unset, check type of nova
if (novaType.contains("NA", Qt::CaseSensitive)) if (novaType.contains("NA", Qt::CaseSensitive))
t9 = 400; // Ok, "fast" nova t9 = 400; // Ok, "fast" nova
if (novaType.contains("NB", Qt::CaseSensitive)) if (novaType.contains("NB", Qt::CaseSensitive))
t9 = 1000; // Ok, "slow" nova t9 = 1000; // Ok, "slow" nova
if (novaType.contains("NC", Qt::CaseSensitive)) if (novaType.contains("NC", Qt::CaseSensitive))
t9 = 3000; // Ok, "very slow" nova t9 = 3000; // Ok, "very slow" nova
} }
else
t9 = m9;
// Calculate light curve // Calculate light curve
if (peakJD<=currentJD) if (peakJD<=currentJD)
{ {
float step; float step;
float d2 = maxMagnitude+2.f; float d2 = maxMagnitude+2.f;
float d3 = maxMagnitude+3.f; float d3 = maxMagnitude+3.f;
float d6 = maxMagnitude+6.f; float d6 = maxMagnitude+6.f;
if (deltaJD>0 && deltaJD<=t2) if (deltaJD>0 && deltaJD<=t2)
skipping to change at line 285 skipping to change at line 278
if (deltaJD<=dt) if (deltaJD<=dt)
{ {
float step = (minMagnitude - maxMagnitude)/dt; // 3 days for outburst float step = (minMagnitude - maxMagnitude)/dt; // 3 days for outburst
vmag = maxMagnitude + step*deltaJD; vmag = maxMagnitude + step*deltaJD;
} }
} }
if (vmag>minMagnitude) if (vmag>minMagnitude)
vmag = minMagnitude; vmag = minMagnitude;
return vmag + extinctionMag; return vmag;
} }
double Nova::getAngularSize(const StelCore*) const double Nova::getAngularSize(const StelCore*) const
{ {
return 0.00001; return 0.00001;
} }
void Nova::update(double deltaTime) void Nova::update(double deltaTime)
{ {
labelsFader.update((int)(deltaTime*1000)); labelsFader.update((int)(deltaTime*1000));
} }
void Nova::draw(StelCore* core, StelRenderer* renderer, StelProjectorP proj ector) void Nova::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(RA, Dec, XYZ); StelUtils::spheToRect(RA, Dec, 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())
{ {
QString name = novaName.isEmpty() ? designation : no vaName; QString name = novaName.isEmpty() ? designation : no vaName;
renderer->drawText(TextParams(XYZ, projector, name). shift(shift, shift).useGravity()); painter->drawText(XYZ, name, 0, shift, shift, false) ;
} }
} }
sd->postDrawPointSource(projector); sd->postDrawPointSource(painter);
} }
 End of changes. 27 change blocks. 
59 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/