Constellation.cpp   Constellation.cpp 
skipping to change at line 39 skipping to change at line 39
#include "StelModuleMgr.hpp" #include "StelModuleMgr.hpp"
#include "StelTranslator.hpp" #include "StelTranslator.hpp"
#include "ConstellationMgr.hpp" #include "ConstellationMgr.hpp"
#include <algorithm> #include <algorithm>
#include <QString> #include <QString>
#include <QTextStream> #include <QTextStream>
#include <QDebug> #include <QDebug>
#include <QFontMetrics> #include <QFontMetrics>
const QString Constellation::CONSTELLATION_TYPE = QStringLiteral("Constella
tion");
Vec3f Constellation::lineColor = Vec3f(0.4,0.4,0.8); Vec3f Constellation::lineColor = Vec3f(0.4,0.4,0.8);
Vec3f Constellation::labelColor = Vec3f(0.4,0.4,0.8); Vec3f Constellation::labelColor = Vec3f(0.4,0.4,0.8);
Vec3f Constellation::boundaryColor = Vec3f(0.8,0.3,0.3); Vec3f Constellation::boundaryColor = Vec3f(0.8,0.3,0.3);
bool Constellation::singleSelected = false; bool Constellation::singleSelected = false;
bool Constellation::seasonalRuleEnabled = false; bool Constellation::seasonalRuleEnabled = false;
float Constellation::artIntensityFovScale = 1.0f; float Constellation::artIntensityFovScale = 1.0f;
Constellation::Constellation() Constellation::Constellation()
: numberOfSegments(0) : numberOfSegments(0)
, beginSeason(0) , beginSeason(0)
, endSeason(0) , endSeason(0)
, asterism(NULL) , constellation(Q_NULLPTR)
{ {
} }
Constellation::~Constellation() Constellation::~Constellation()
{ {
delete[] asterism; delete[] constellation;
asterism = NULL; constellation = Q_NULLPTR;
} }
bool Constellation::read(const QString& record, StarMgr *starMgr) bool Constellation::read(const QString& record, StarMgr *starMgr)
{ {
unsigned int HP; unsigned int HP;
abbreviation.clear(); abbreviation.clear();
numberOfSegments = 0; numberOfSegments = 0;
QString buf(record); QString buf(record);
QTextStream istr(&buf, QIODevice::ReadOnly); QTextStream istr(&buf, QIODevice::ReadOnly);
QString abb; QString abb;
istr >> abb >> numberOfSegments; istr >> abb >> numberOfSegments;
if (istr.status()!=QTextStream::Ok) if (istr.status()!=QTextStream::Ok)
return false; return false;
// It's better to allow mixed-case abbreviations now that they can b e displayed on screen. We then need toUpper() in comparisons. // It's better to allow mixed-case abbreviations now that they can b e displayed on screen. We then need toUpper() in comparisons.
//abbreviation = abb.toUpper(); //abbreviation = abb.toUpper();
abbreviation=abb; abbreviation=abb;
asterism = new StelObjectP[numberOfSegments*2]; constellation = new StelObjectP[numberOfSegments*2];
for (unsigned int i=0;i<numberOfSegments*2;++i) for (unsigned int i=0;i<numberOfSegments*2;++i)
{ {
HP = 0; HP = 0;
istr >> HP; istr >> HP;
if(HP == 0) if(HP == 0)
{ {
// TODO: why is this delete commented? // TODO: why is this delete commented?
// delete[] asterism; // delete[] constellation;
return false; return false;
} }
asterism[i]=starMgr->searchHP(HP); constellation[i]=starMgr->searchHP(HP);
if (!asterism[i]) if (!constellation[i])
{ {
qWarning() << "Error in Constellation " << abbreviat ion << " asterism : can't find star HP= " << HP; qWarning() << "Error in Constellation " << abbreviat ion << " asterism : can't find star HP= " << HP;
// TODO: why is this delete commented? // TODO: why is this delete commented?
// delete[] asterism; // delete[] constellation;
return false; return false;
} }
} }
XYZname.set(0.,0.,0.); XYZname.set(0.,0.,0.);
for(unsigned int ii=0;ii<numberOfSegments*2;++ii) for(unsigned int ii=0;ii<numberOfSegments*2;++ii)
{ {
XYZname+= asterism[ii]->getJ2000EquatorialPos(StelApp::getIn stance().getCore()); XYZname+= constellation[ii]->getJ2000EquatorialPos(StelApp:: getInstance().getCore());
} }
XYZname.normalize(); XYZname.normalize();
return true; return true;
} }
void Constellation::drawOptim(StelPainter& sPainter, const StelCore* core, const SphericalCap& viewportHalfspace) const void Constellation::drawOptim(StelPainter& sPainter, const StelCore* core, const SphericalCap& viewportHalfspace) const
{ {
if (lineFader.getInterstate()<=0.0001f) if (lineFader.getInterstate()<=0.0001f)
return; return;
if (checkVisibility()) if (checkVisibility())
{ {
sPainter.setColor(lineColor[0], lineColor[1], lineColor[2], lineFader.getInterstate()); sPainter.setColor(lineColor[0], lineColor[1], lineColor[2], lineFader.getInterstate());
Vec3d star1; Vec3d star1;
Vec3d star2; Vec3d star2;
for (unsigned int i=0;i<numberOfSegments;++i) for (unsigned int i=0;i<numberOfSegments;++i)
{ {
star1=asterism[2*i]->getJ2000EquatorialPos(core); star1=constellation[2*i]->getJ2000EquatorialPos(core
star2=asterism[2*i+1]->getJ2000EquatorialPos(core); );
star2=constellation[2*i+1]->getJ2000EquatorialPos(co
re);
star1.normalize(); star1.normalize();
star2.normalize(); star2.normalize();
sPainter.drawGreatCircleArc(star1, star2, &viewportH alfspace); sPainter.drawGreatCircleArc(star1, star2, &viewportH alfspace);
} }
} }
} }
void Constellation::drawName(StelPainter& sPainter, ConstellationMgr::Const ellationDisplayStyle style) const void Constellation::drawName(StelPainter& sPainter, ConstellationMgr::Const ellationDisplayStyle style) const
{ {
if (!nameFader.getInterstate()) if (!nameFader.getInterstate())
skipping to change at line 194 skipping to change at line 196
SphericalRegionP region = sPainter.getProjector()->getViewportConvex Polygon(); SphericalRegionP region = sPainter.getProjector()->getViewportConvex Polygon();
drawArtOptim(sPainter, *region); drawArtOptim(sPainter, *region);
sPainter.setCullFace(false); sPainter.setCullFace(false);
} }
const Constellation* Constellation::isStarIn(const StelObject* s) const const Constellation* Constellation::isStarIn(const StelObject* s) const
{ {
for(unsigned int i=0;i<numberOfSegments*2;++i) for(unsigned int i=0;i<numberOfSegments*2;++i)
{ {
// asterism[i]==s test was not working // constellation[i]==s test was not working
if (asterism[i]->getEnglishName()==s->getEnglishName()) if (constellation[i]->getEnglishName()==s->getEnglishName())
{ {
// qDebug() << "Const matched. " << getEnglishName() ; // qDebug() << "Const matched. " << getEnglishName() ;
return this; return this;
} }
} }
return NULL; return Q_NULLPTR;
} }
void Constellation::update(int deltaTime) void Constellation::update(int deltaTime)
{ {
lineFader.update(deltaTime); lineFader.update(deltaTime);
nameFader.update(deltaTime); nameFader.update(deltaTime);
artFader.update(deltaTime); artFader.update(deltaTime);
boundaryFader.update(deltaTime); boundaryFader.update(deltaTime);
} }
skipping to change at line 305 skipping to change at line 307
} }
StelObjectP Constellation::getBrightestStarInConstellation(void) const StelObjectP Constellation::getBrightestStarInConstellation(void) const
{ {
float maxMag = 99.f; float maxMag = 99.f;
StelObjectP brightest; StelObjectP brightest;
// maybe the brightest star has always odd index, // maybe the brightest star has always odd index,
// so check all segment endpoints: // so check all segment endpoints:
for (int i=2*numberOfSegments-1;i>=0;i--) for (int i=2*numberOfSegments-1;i>=0;i--)
{ {
const float Mag = asterism[i]->getVMagnitude(0); const float Mag = constellation[i]->getVMagnitude(0);
if (Mag < maxMag) if (Mag < maxMag)
{ {
brightest = asterism[i]; brightest = constellation[i];
maxMag = Mag; maxMag = Mag;
} }
} }
return brightest; return brightest;
} }
 End of changes. 13 change blocks. 
16 lines changed or deleted 21 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/