Quasar.cpp   Quasar.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 "Quasar.hpp" #include "Quasar.hpp"
#include "Quasars.hpp" #include "Quasars.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 <QTextStream> #include <QTextStream>
#include <QDebug> #include <QDebug>
#include <QVariant> #include <QVariant>
#include <QVariantMap> #include <QVariantMap>
#include <QVariant> #include <QVariant>
#include <QList> #include <QList>
StelTextureSP Quasar::markerTexture;
bool Quasar::distributionMode = false;
Vec3f Quasar::markerColor = Vec3f(1.0f,0.5f,0.4f);
Quasar::Quasar(const QVariantMap& map) Quasar::Quasar(const QVariantMap& map)
: initialized(false) : initialized(false),
designation(""),
VMagnitude(21.),
AMagnitude(21.),
bV(0.),
qRA(0.),
qDE(0.),
redshift(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();
VMagnitude = map.value("Vmag").toFloat(); VMagnitude = map.value("Vmag").toFloat();
AMagnitude = map.value("Amag").toFloat(); AMagnitude = map.value("Amag").toFloat();
bV = map.value("bV").toFloat(); bV = map.value("bV").toFloat();
qRA = StelUtils::getDecAngle(map.value("RA").toString()); qRA = StelUtils::getDecAngle(map.value("RA").toString());
skipping to change at line 74 skipping to change at line 89
map["Vmag"] = VMagnitude; map["Vmag"] = VMagnitude;
map["Amag"] = AMagnitude; map["Amag"] = AMagnitude;
map["bV"] = bV; map["bV"] = bV;
map["RA"] = qRA; map["RA"] = qRA;
map["DE"] = qDE; map["DE"] = qDE;
map["z"] = redshift; map["z"] = redshift;
return map; return map;
} }
float Quasar::getSelectPriority(const StelCore* core) const
{
//Same as StarWrapper::getSelectPriority()
return getVMagnitude(core, false);
}
QString Quasar::getInfoString(const StelCore* core, const InfoStringGroup& flags) const QString Quasar::getInfoString(const StelCore* core, const InfoStringGroup& flags) 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)
{ {
oss << "<h2>" << designation << "</h2>"; oss << "<h2>" << designation << "</h2>";
} }
if (flags&Extra1) if (flags&ObjectType)
oss << q_("Type: <b>%1</b>").arg(q_("quasar")) << "<br />"; oss << q_("Type: <b>%1</b>").arg(q_("quasar")) << "<br />";
if (flags&Magnitude) if (flags&Magnitude)
{ {
if (core->getSkyDrawer()->getFlagHasAtmosphere()) if (core->getSkyDrawer()->getFlagHasAtmosphere())
{ {
if (bV!=0) oss << q_("Magnitude: <b>%1</b> (extincted to: <b>%2
{ </b>)").arg(QString::number(mag, 'f', 2),
oss << q_("Magnitude: <b>%1</b> (extincted t
o: <b>%2</b>. B-V: <b>%3</b>)").arg(QString::number(mag, 'f', 2), QString::number(getVMagnitudeWithExtinction(core), 'f', 2)) <<
"<br />";
QString::number(getVMagnitude(core, tru
e), 'f', 2),
QString::number(bV, 'f', 2)) << "<br />
";
}
else
{
oss << q_("Magnitude: <b>%1</b> (extincted t
o: <b>%2</b>)").arg(QString::number(mag, 'f', 2),
QString::number(getVMagnitude(core, true), 'f', 2)) <<
"<br />";
}
} }
else else
{ {
if (bV!=0) oss << q_("Magnitude: <b>%1</b>").arg(mag, 0, 'f', 2
{ ) << "<br />";
oss << q_("Magnitude: <b>%1</b> (B-V: <b>%2<
/b>)").arg(mag, 0, 'f', 2).arg(bV, 0, 'f', 2) << "<br />";
}
else
{
oss << q_("Magnitude: <b>%1</b>").arg(mag, 0
, 'f', 2) << "<br />";
}
} }
if (AMagnitude!=0) if (AMagnitude!=0)
{ {
oss << q_("Absolute Magnitude: %1").arg(AMagnitude, 0, 'f', 2) << "<br />"; oss << q_("Absolute Magnitude: %1").arg(AMagnitude, 0, 'f', 2) << "<br />";
} }
} }
if (flags&Extra)
{
oss << q_("Color Index (B-V): <b>%1</b>").arg(QString::numbe
r(bV, 'f', 2)) << "<br>";
}
// Ra/Dec etc. // Ra/Dec etc.
oss << getPositionInfoString(core, flags); oss << getPositionInfoString(core, flags);
if (flags&Extra1) if (flags&Extra)
{ {
if (redshift>0) if (redshift>0)
{ {
oss << q_("Z (redshift): %1").arg(redshift) << "<br />"; oss << q_("Z (redshift): %1").arg(redshift) << "<br />";
} }
} }
postProcessInfoString(str, flags); postProcessInfoString(str, flags);
return str; return str;
} }
Vec3f Quasar::getInfoColor(void) const Vec3f Quasar::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 Quasar::getVMagnitude(const StelCore* core, bool withExtinction) cons t float Quasar::getVMagnitude(const StelCore* core) const
{ {
float extinctionMag=0.0; // track magnitude loss Q_UNUSED(core);
if (withExtinction && core->getSkyDrawer()->getFlagHasAtmosphere()) return VMagnitude;
{
Vec3d altAz=getAltAzPosApparent(core);
altAz.normalize();
core->getSkyDrawer()->getExtinction().forward(&altAz[2], &ex
tinctionMag);
}
return VMagnitude + extinctionMag;
} }
double Quasar::getAngularSize(const StelCore*) const double Quasar::getAngularSize(const StelCore*) const
{ {
return 0.00001; return 0.00001;
} }
float Quasar::getSelectPriority(const StelCore* core) const
{
float mag = getVMagnitudeWithExtinction(core);
if (distributionMode)
mag = 4.f;
return mag;
}
void Quasar::update(double deltaTime) void Quasar::update(double deltaTime)
{ {
labelsFader.update((int)(deltaTime*1000)); labelsFader.update((int)(deltaTime*1000));
} }
void Quasar::draw(StelCore* core, StelRenderer* renderer, StelProjectorP pr ojector, StelTextureNew* markerTexture) void Quasar::draw(StelCore* core, StelPainter& painter)
{ {
StelSkyDrawer* sd = core->getSkyDrawer(); StelSkyDrawer* sd = core->getSkyDrawer();
const Vec3f color = sd->indexToColor(BvToColorIndex(bV))*0.75f; Vec3f color = sd->indexToColor(BvToColorIndex(bV))*0.75f;
Vec3f dcolor = Vec3f(1.2f,0.5f,0.4f); RCMag rcMag;
if (StelApp::getInstance().getVisionModeNight()) float size, shift=0;
dcolor = StelUtils::getNightColor(dcolor);
float rcMag[2], size, shift;
double mag; double mag;
StelUtils::spheToRect(qRA, qDE, XYZ); StelUtils::spheToRect(qRA, qDE, XYZ);
mag = getVMagnitude(core, true); mag = getVMagnitudeWithExtinction(core);
if (GETSTELMODULE(Quasars)->getDisplayMode()) if (distributionMode)
{ {
renderer->setBlendMode(BlendMode_Add); glEnable(GL_BLEND);
renderer->setGlobalColor(dcolor[0], dcolor[1], dcolor[2], 1) glBlendFunc(GL_ONE, GL_ONE);
; painter.setColor(markerColor[0], markerColor[1], markerColor
markerTexture->bind(); [2], 1);
Quasar::markerTexture->bind();
//size = getAngularSize(NULL)*M_PI/180.*painter.getProjector
()->getPixelPerRadAtCenter();
if (labelsFader.getInterstate()<=0.f) if (labelsFader.getInterstate()<=0.f)
{ {
Vec3d win; painter.drawSprite2dMode(XYZ, 4);
if(projector->project(XYZ, win))
{
renderer->drawTexturedRect(win[0] - 4, win[1
] - 4, 8, 8);
}
} }
} }
else else
{ {
sd->preDrawPointSource(); sd->preDrawPointSource(&painter);
if (mag <= sd->getLimitMagnitude()) if (mag <= sd->getLimitMagnitude())
{ {
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],
Vec3f win; XYZ[2]), rcMag, sd->indexToColor(BvToColorIndex(bV)), true);
if(sd->pointSourceVisible(&(*projector), XYZf, rcMag painter.setColor(color[0], color[1], color[2], 1);
, false, win)) size = getAngularSize(NULL)*M_PI/180.*painter.getPro
{ jector()->getPixelPerRadAtCenter();
sd->drawPointSource(win, rcMag, sd->indexToC
olor(BvToColorIndex(bV)));
}
renderer->setGlobalColor(color[0], color[1], color[2
], 1.0f);
size = getAngularSize(NULL)*M_PI/180.*projector->get
PixelPerRadAtCenter();
shift = 6.f + size/1.8f; shift = 6.f + size/1.8f;
if (labelsFader.getInterstate()<=0.f) if (labelsFader.getInterstate()<=0.f)
{ {
renderer->drawText(TextParams(XYZ, projector , designation).shift(shift, shift).useGravity()); painter.drawText(XYZ, designation, 0, shift, shift, false);
} }
} }
sd->postDrawPointSource(projector); sd->postDrawPointSource(&painter);
} }
} }
unsigned char Quasar::BvToColorIndex(float b_v) unsigned char Quasar::BvToColorIndex(float b_v)
{ {
double dBV = b_v; double dBV = b_v;
dBV *= 1000.0; dBV *= 1000.0;
if (dBV < -500) if (dBV < -500)
{ {
dBV = -500; dBV = -500;
 End of changes. 27 change blocks. 
87 lines changed or deleted 69 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/