ConstellationMgr.cpp   ConstellationMgr.cpp 
skipping to change at line 74 skipping to change at line 74
constellationLineThickness(1.) constellationLineThickness(1.)
{ {
setObjectName("ConstellationMgr"); setObjectName("ConstellationMgr");
Q_ASSERT(hipStarMgr); Q_ASSERT(hipStarMgr);
} }
ConstellationMgr::~ConstellationMgr() ConstellationMgr::~ConstellationMgr()
{ {
std::vector<Constellation *>::iterator iter; std::vector<Constellation *>::iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); iter++) for (iter = constellations.begin(); iter != constellations.end(); it er++)
{ {
delete(*iter); delete(*iter);
} }
vector<vector<Vec3f> *>::iterator iter1; vector<vector<Vec3f> *>::iterator iter1;
for (iter1 = allBoundarySegments.begin(); iter1 != allBoundarySegmen ts.end(); ++iter1) for (iter1 = allBoundarySegments.begin(); iter1 != allBoundarySegmen ts.end(); ++iter1)
{ {
delete (*iter1); delete (*iter1);
} }
allBoundarySegments.clear(); allBoundarySegments.clear();
skipping to change at line 233 skipping to change at line 233
void ConstellationMgr::selectedObjectChange(StelModule::StelModuleSelectAct ion action) void ConstellationMgr::selectedObjectChange(StelModule::StelModuleSelectAct ion action)
{ {
StelObjectMgr* omgr = GETSTELMODULE(StelObjectMgr); StelObjectMgr* omgr = GETSTELMODULE(StelObjectMgr);
Q_ASSERT(omgr); Q_ASSERT(omgr);
const QList<StelObjectP> newSelected = omgr->getSelectedObject(); const QList<StelObjectP> newSelected = omgr->getSelectedObject();
if (newSelected.empty()) if (newSelected.empty())
{ {
// Even if do not have anything selected, KEEP constellation selection intact // Even if do not have anything selected, KEEP constellation selection intact
// (allows viewing constellations without distraction from s tar pointer animation) // (allows viewing constellations without distraction from s tar pointer animation)
// setSelected(NULL); // setSelected(Q_NULLPTR);
return; return;
} }
const QList<StelObjectP> newSelectedConst = omgr->getSelectedObject( "Constellation"); const QList<StelObjectP> newSelectedConst = omgr->getSelectedObject( "Constellation");
if (!newSelectedConst.empty()) if (!newSelectedConst.empty())
{ {
// If removing this selection // If removing this selection
if(action == StelModule::RemoveFromSelection) if(action == StelModule::RemoveFromSelection)
{ {
unsetSelectedConst((Constellation *)newSelectedConst [0].data()); unsetSelectedConst((Constellation *)newSelectedConst [0].data());
skipping to change at line 265 skipping to change at line 265
newSelectedObject = omgr->getSelectedObject(); newSelectedObject = omgr->getSelectedObject();
else else
newSelectedObject = omgr->getSelectedObject("Star"); newSelectedObject = omgr->getSelectedObject("Star");
if (!newSelectedObject.empty()) if (!newSelectedObject.empty())
{ {
setSelected(newSelectedObject[0].data()); setSelected(newSelectedObject[0].data());
} }
else else
{ {
setSelected(NULL); setSelected(Q_NULLPTR);
} }
} }
} }
void ConstellationMgr::deselectConstellations(void) void ConstellationMgr::deselectConstellations(void)
{ {
selected.clear(); selected.clear();
StelObjectMgr* omgr = GETSTELMODULE(StelObjectMgr); StelObjectMgr* omgr = GETSTELMODULE(StelObjectMgr);
Q_ASSERT(omgr); Q_ASSERT(omgr);
const QList<StelObjectP> currSelection = omgr->getSelectedObject(); const QList<StelObjectP> currSelection = omgr->getSelectedObject();
skipping to change at line 406 skipping to change at line 406
while (!in.atEnd()) while (!in.atEnd())
{ {
record = QString::fromUtf8(in.readLine()); record = QString::fromUtf8(in.readLine());
if (!commentRx.exactMatch(record)) if (!commentRx.exactMatch(record))
totalRecords++; totalRecords++;
} }
in.seek(0); in.seek(0);
// delete existing data, if any // delete existing data, if any
vector < Constellation * >::iterator iter; vector < Constellation * >::iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter) for (iter = constellations.begin(); iter != constellations.end(); ++ iter)
delete(*iter); delete(*iter);
asterisms.clear(); constellations.clear();
Constellation *cons = NULL; Constellation *cons = Q_NULLPTR;
// read the file of line patterns, adding a record per non-comment l ine // read the file of line patterns, adding a record per non-comment l ine
int currentLineNumber = 0; // line in file int currentLineNumber = 0; // line in file
int readOk = 0; // count of records processed OK int readOk = 0; // count of records processed OK
while (!in.atEnd()) while (!in.atEnd())
{ {
record = QString::fromUtf8(in.readLine()); record = QString::fromUtf8(in.readLine());
currentLineNumber++; currentLineNumber++;
if (commentRx.exactMatch(record)) if (commentRx.exactMatch(record))
continue; continue;
cons = new Constellation; cons = new Constellation;
if(cons->read(record, hipStarMgr)) if(cons->read(record, hipStarMgr))
{ {
cons->artFader.setMaxValue(artIntensity); cons->artFader.setMaxValue(artIntensity);
cons->artFader.setDuration((int) (artFadeDuration * 1000.f)); cons->artFader.setDuration((int) (artFadeDuration * 1000.f));
cons->setFlagArt(artDisplayed); cons->setFlagArt(artDisplayed);
cons->setFlagBoundaries(boundariesDisplayed); cons->setFlagBoundaries(boundariesDisplayed);
cons->setFlagLines(linesDisplayed); cons->setFlagLines(linesDisplayed);
cons->setFlagLabels(namesDisplayed); cons->setFlagLabels(namesDisplayed);
asterisms.push_back(cons); constellations.push_back(cons);
++readOk; ++readOk;
} }
else else
{ {
qWarning() << "ERROR reading constellation lines rec ord at line " << currentLineNumber << "for culture" << cultureName; qWarning() << "ERROR reading constellation lines rec ord at line " << currentLineNumber << "for culture" << cultureName;
delete cons; delete cons;
} }
} }
in.close(); in.close();
qDebug() << "Loaded" << readOk << "/" << totalRecords << "constellat ion records successfully for culture" << cultureName; qDebug() << "Loaded" << readOk << "/" << totalRecords << "constellat ion records successfully for culture" << cultureName;
skipping to change at line 504 skipping to change at line 504
if (rStr.status()!=QTextStream::Ok) if (rStr.status()!=QTextStream::Ok)
{ {
qWarning() << "ERROR parsing constellation art recor d at line" << currentLineNumber << "of art file for culture" << cultureName ; qWarning() << "ERROR parsing constellation art recor d at line" << currentLineNumber << "of art file for culture" << cultureName ;
continue; continue;
} }
// Draw loading bar // Draw loading bar
// lb.SetMessage(q_("Loading Constellation Art: %1/%2").arg(cur rentLineNumber).arg(totalRecords)); // lb.SetMessage(q_("Loading Constellation Art: %1/%2").arg(cur rentLineNumber).arg(totalRecords));
// lb.Draw((float)(currentLineNumber)/totalRecords); // lb.Draw((float)(currentLineNumber)/totalRecords);
cons = NULL; cons = Q_NULLPTR;
cons = findFromAbbreviation(shortname); cons = findFromAbbreviation(shortname);
if (!cons) if (!cons)
{ {
qWarning() << "ERROR in constellation art file at li ne" << currentLineNumber << "for culture" << cultureName qWarning() << "ERROR in constellation art file at li ne" << currentLineNumber << "for culture" << cultureName
<< "constellation" << shortname < < "unknown"; << "constellation" << shortname < < "unknown";
} }
else else
{ {
QString texturePath = StelFileMgr::findFile("skycult ures/"+cultureName+"/"+texfile); QString texturePath = StelFileMgr::findFile("skycult ures/"+cultureName+"/"+texfile);
if (texturePath.isEmpty()) if (texturePath.isEmpty())
{ {
qWarning() << "ERROR: could not find texture , " << QDir::toNativeSeparators(texfile); qWarning() << "ERROR: could not find texture , " << QDir::toNativeSeparators(texfile);
} }
cons->artTexture = StelApp::getInstance().getTexture Manager().createTextureThread(texturePath); cons->artTexture = StelApp::getInstance().getTexture Manager().createTextureThread(texturePath);
int texSizeX = 0, texSizeY = 0; int texSizeX = 0, texSizeY = 0;
if (cons->artTexture==NULL || !cons->artTexture->get Dimensions(texSizeX, texSizeY)) if (cons->artTexture==Q_NULLPTR || !cons->artTexture ->getDimensions(texSizeX, texSizeY))
{ {
qWarning() << "Texture dimension not availab le"; qWarning() << "Texture dimension not availab le";
} }
StelCore* core = StelApp::getInstance().getCore(); StelCore* core = StelApp::getInstance().getCore();
Vec3d s1 = hipStarMgr->searchHP(hp1)->getJ2000Equato rialPos(core); Vec3d s1 = hipStarMgr->searchHP(hp1)->getJ2000Equato rialPos(core);
Vec3d s2 = hipStarMgr->searchHP(hp2)->getJ2000Equato rialPos(core); Vec3d s2 = hipStarMgr->searchHP(hp2)->getJ2000Equato rialPos(core);
Vec3d s3 = hipStarMgr->searchHP(hp3)->getJ2000Equato rialPos(core); Vec3d s3 = hipStarMgr->searchHP(hp3)->getJ2000Equato rialPos(core);
// To transform from texture coordinate to 2d coordi nate we need to find X with XA = B // To transform from texture coordinate to 2d coordi nate we need to find X with XA = B
skipping to change at line 600 skipping to change at line 600
} }
// Draw constellations art textures // Draw constellations art textures
void ConstellationMgr::drawArt(StelPainter& sPainter) const void ConstellationMgr::drawArt(StelPainter& sPainter) const
{ {
sPainter.setBlending(true, GL_ONE, GL_ONE); sPainter.setBlending(true, GL_ONE, GL_ONE);
sPainter.setCullFace(true); sPainter.setCullFace(true);
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
SphericalRegionP region = sPainter.getProjector()->getViewportConvex Polygon(); SphericalRegionP region = sPainter.getProjector()->getViewportConvex Polygon();
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter) for (iter = constellations.begin(); iter != constellations.end(); ++ iter)
{ {
(*iter)->drawArtOptim(sPainter, *region); (*iter)->drawArtOptim(sPainter, *region);
} }
sPainter.setCullFace(false); sPainter.setCullFace(false);
} }
// Draw constellations lines // Draw constellations lines
void ConstellationMgr::drawLines(StelPainter& sPainter, const StelCore* cor e) const void ConstellationMgr::drawLines(StelPainter& sPainter, const StelCore* cor e) const
{ {
sPainter.setBlending(true); sPainter.setBlending(true);
if (constellationLineThickness>1.f) if (constellationLineThickness>1.f)
sPainter.setLineWidth(constellationLineThickness); // set li ne thickness sPainter.setLineWidth(constellationLineThickness); // set li ne thickness
sPainter.setLineSmooth(true); sPainter.setLineSmooth(true);
const SphericalCap& viewportHalfspace = sPainter.getProjector()->get BoundingCap(); const SphericalCap& viewportHalfspace = sPainter.getProjector()->get BoundingCap();
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter) for (iter = constellations.begin(); iter != constellations.end(); ++ iter)
{ {
(*iter)->drawOptim(sPainter, core, viewportHalfspace); (*iter)->drawOptim(sPainter, core, viewportHalfspace);
} }
if (constellationLineThickness>1.f) if (constellationLineThickness>1.f)
sPainter.setLineWidth(1.f); // restore line thickness sPainter.setLineWidth(1.f); // restore line thickness
sPainter.setLineSmooth(false); sPainter.setLineSmooth(false);
} }
// Draw the names of all the constellations // Draw the names of all the constellations
void ConstellationMgr::drawNames(StelPainter& sPainter) const void ConstellationMgr::drawNames(StelPainter& sPainter) const
{ {
sPainter.setBlending(true); sPainter.setBlending(true);
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); iter++) for (iter = constellations.begin(); iter != constellations.end(); it er++)
{ {
// Check if in the field of view // Check if in the field of view
if (sPainter.getProjector()->projectCheck((*iter)->XYZname, (*iter)->XYname)) if (sPainter.getProjector()->projectCheck((*iter)->XYZname, (*iter)->XYname))
(*iter)->drawName(sPainter, constellationDisplayStyl e); (*iter)->drawName(sPainter, constellationDisplayStyl e);
} }
} }
Constellation *ConstellationMgr::isStarIn(const StelObject* s) const Constellation *ConstellationMgr::isStarIn(const StelObject* s) const
{ {
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter) for (iter = constellations.begin(); iter != constellations.end(); ++ iter)
{ {
// Check if the star is in one of the constellation // Check if the star is in one of the constellation
if ((*iter)->isStarIn(s)) if ((*iter)->isStarIn(s))
{ {
return (*iter); return (*iter);
} }
} }
return NULL; return Q_NULLPTR;
} }
Constellation* ConstellationMgr::findFromAbbreviation(const QString& abbrev iation) const Constellation* ConstellationMgr::findFromAbbreviation(const QString& abbrev iation) const
{ {
// search in uppercase only // search in uppercase only
//QString tname = abbreviation.toUpper(); //QString tname = abbreviation.toUpper();
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter) for (iter = constellations.begin(); iter != constellations.end(); ++ iter)
{ {
//if ((*iter)->abbreviation.toUpper() == tname) //if ((*iter)->abbreviation.toUpper() == tname)
if ((*iter)->abbreviation.compare(abbreviation, Qt::CaseInse nsitive) == 0) if ((*iter)->abbreviation.compare(abbreviation, Qt::CaseInse nsitive) == 0)
{ {
//if ((*iter)->abbreviation != abbreviation) //if ((*iter)->abbreviation != abbreviation)
// qDebug() << "ConstellationMgr::findFromAbbre viation: not a perfect match, but sufficient:" << (*iter)->abbreviation << "vs." << abbreviation; // qDebug() << "ConstellationMgr::findFromAbbre viation: not a perfect match, but sufficient:" << (*iter)->abbreviation << "vs." << abbreviation;
return (*iter); return (*iter);
} }
//else qDebug() << "Comparison mismatch: " << abbreviation < < "vs." << (*iter)->abbreviation; //else qDebug() << "Comparison mismatch: " << abbreviation < < "vs." << (*iter)->abbreviation;
} }
return NULL; return Q_NULLPTR;
} }
// Can't find constellation from a position because it's not well localized // Can't find constellation from a position because it's not well localized
QList<StelObjectP> ConstellationMgr::searchAround(const Vec3d&, double, con st StelCore*) const QList<StelObjectP> ConstellationMgr::searchAround(const Vec3d&, double, con st StelCore*) const
{ {
return QList<StelObjectP>(); return QList<StelObjectP>();
} }
void ConstellationMgr::loadNames(const QString& namesFile) void ConstellationMgr::loadNames(const QString& namesFile)
{ {
// Constellation not loaded yet // Constellation not loaded yet
if (asterisms.empty()) return; if (constellations.empty()) return;
// clear previous names // clear previous names
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter) for (iter = constellations.begin(); iter != constellations.end(); ++ iter)
{ {
(*iter)->englishName.clear(); (*iter)->englishName.clear();
} }
// Open file // Open file
QFile commonNameFile(namesFile); QFile commonNameFile(namesFile);
if (!commonNameFile.open(QIODevice::ReadOnly | QIODevice::Text)) if (!commonNameFile.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
qDebug() << "Cannot open file" << QDir::toNativeSeparators(n amesFile); qDebug() << "Cannot open file" << QDir::toNativeSeparators(n amesFile);
return; return;
} }
// Now parse the file // Now parse the file
// lines to ignore which start with a # or are empty // lines to ignore which start with a # or are empty
QRegExp commentRx("^(\\s*#.*|\\s*)$"); QRegExp commentRx("^(\\s*#.*|\\s*)$");
// lines which look like records - we use the RE to extract the fiel ds // lines which look like records - we use the RE to extract the fiel ds
// which will be available in recRx.capturedTexts() // which will be available in recRx.capturedTexts()
// abbreviation is allowed to start with a dot to mark as "hidden". // abbreviation is allowed to start with a dot to mark as "hidden".
QRegExp recRx("^\\s*(\\.?\\w+)\\s+\"(.*)\"\\s+_[(]\"(.*)\"[)]\\n"); QRegExp recRx("^\\s*(\\.?\\w+)\\s+\"(.*)\"\\s+_[(]\"(.*)\"[)]\\n");
QRegExp ctxRx("(.*)\",\\s*\"(.*)");
// Some more variables to use in the parsing // Some more variables to use in the parsing
Constellation *aster; Constellation *aster;
QString record, shortName; QString record, shortName, ctxt;
// keep track of how many records we processed. // keep track of how many records we processed.
int totalRecords=0; int totalRecords=0;
int readOk=0; int readOk=0;
int lineNumber=0; int lineNumber=0;
while (!commonNameFile.atEnd()) while (!commonNameFile.atEnd())
{ {
record = QString::fromUtf8(commonNameFile.readLine()); record = QString::fromUtf8(commonNameFile.readLine());
lineNumber++; lineNumber++;
skipping to change at line 737 skipping to change at line 738
if (!recRx.exactMatch(record)) if (!recRx.exactMatch(record))
{ {
qWarning() << "ERROR - cannot parse record at line" << lineNumber << "in constellation names file" << QDir::toNativeSeparators( namesFile) << ":" << record; qWarning() << "ERROR - cannot parse record at line" << lineNumber << "in constellation names file" << QDir::toNativeSeparators( namesFile) << ":" << record;
} }
else else
{ {
shortName = recRx.capturedTexts().at(1); shortName = recRx.capturedTexts().at(1);
aster = findFromAbbreviation(shortName); aster = findFromAbbreviation(shortName);
// If the constellation exists, set the English name // If the constellation exists, set the English name
if (aster != NULL) if (aster != Q_NULLPTR)
{ {
aster->nativeName = recRx.capturedTexts().at (2); aster->nativeName = recRx.capturedTexts().at (2);
aster->englishName = recRx.capturedTexts().a ctxt = recRx.capturedTexts().at(3);
t(3); if (ctxRx.exactMatch(ctxt))
{
aster->englishName = ctxRx.capturedT
exts().at(1);
aster->context = ctxRx.capturedTexts
().at(2);
}
else
{
aster->englishName = ctxt;
aster->context = "";
}
readOk++; readOk++;
// Some skycultures already have empty nativ eNames. Fill those. // Some skycultures already have empty nativ eNames. Fill those.
if (aster->nativeName.isEmpty()) if (aster->nativeName.isEmpty())
aster->nativeName=aster->englishName ; aster->nativeName=aster->englishName ;
} }
else else
{ {
qWarning() << "WARNING - constellation abbre viation" << shortName << "not found when loading constellation names"; qWarning() << "WARNING - constellation abbre viation" << shortName << "not found when loading constellation names";
} }
} }
} }
commonNameFile.close(); commonNameFile.close();
qDebug() << "Loaded" << readOk << "/" << totalRecords << "constellat ion names"; qDebug() << "Loaded" << readOk << "/" << totalRecords << "constellat ion names";
} }
void ConstellationMgr::loadSeasonalRules(const QString& rulesFile) void ConstellationMgr::loadSeasonalRules(const QString& rulesFile)
{ {
// Constellation not loaded yet // Constellation not loaded yet
if (asterisms.empty()) return; if (constellations.empty()) return;
bool flag = true; bool flag = true;
if (rulesFile.isEmpty()) if (rulesFile.isEmpty())
flag = false; flag = false;
// clear previous names // clear previous names
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter) for (iter = constellations.begin(); iter != constellations.end(); ++ iter)
{ {
(*iter)->beginSeason = 1; (*iter)->beginSeason = 1;
(*iter)->endSeason = 12; (*iter)->endSeason = 12;
(*iter)->seasonalRuleEnabled = flag; (*iter)->seasonalRuleEnabled = flag;
} }
// Current starlore didn't support the seasonal rules // Current starlore didn't support the seasonal rules
if (!flag) if (!flag)
return; return;
skipping to change at line 822 skipping to change at line 833
if (!recRx.exactMatch(record)) if (!recRx.exactMatch(record))
{ {
qWarning() << "ERROR - cannot parse record at line" << lineNumber << "in seasonal rules file" << QDir::toNativeSeparators(rules File); qWarning() << "ERROR - cannot parse record at line" << lineNumber << "in seasonal rules file" << QDir::toNativeSeparators(rules File);
} }
else else
{ {
shortName = recRx.capturedTexts().at(1); shortName = recRx.capturedTexts().at(1);
aster = findFromAbbreviation(shortName); aster = findFromAbbreviation(shortName);
// If the constellation exists, set the English name // If the constellation exists, set the English name
if (aster != NULL) if (aster != Q_NULLPTR)
{ {
aster->beginSeason = recRx.capturedTexts().a t(2).toInt(); aster->beginSeason = recRx.capturedTexts().a t(2).toInt();
aster->endSeason = recRx.capturedTexts().at( 3).toInt(); aster->endSeason = recRx.capturedTexts().at( 3).toInt();
readOk++; readOk++;
} }
else else
{ {
qWarning() << "WARNING - constellation abbre viation" << shortName << "not found when loading seasonal rules for constel lations"; qWarning() << "WARNING - constellation abbre viation" << shortName << "not found when loading seasonal rules for constel lations";
} }
} }
} }
seasonalRulesFile.close(); seasonalRulesFile.close();
qDebug() << "Loaded" << readOk << "/" << totalRecords << "seasonal r ules"; qDebug() << "Loaded" << readOk << "/" << totalRecords << "seasonal r ules";
} }
void ConstellationMgr::updateI18n() void ConstellationMgr::updateI18n()
{ {
const StelTranslator& trans = StelApp::getInstance().getLocaleMgr(). getSkyTranslator(); const StelTranslator& trans = StelApp::getInstance().getLocaleMgr(). getSkyTranslator();
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter) for (iter = constellations.begin(); iter != constellations.end(); ++ iter)
{ {
(*iter)->nameI18 = trans.qtranslate((*iter)->englishName); (*iter)->nameI18 = trans.qtranslate((*iter)->englishName);
} }
} }
// update faders // update faders
void ConstellationMgr::update(double deltaTime) void ConstellationMgr::update(double deltaTime)
{ {
//calculate FOV fade value, linear fade between artIntensityMaximumF ov and artIntensityMinimumFov //calculate FOV fade value, linear fade between artIntensityMaximumF ov and artIntensityMinimumFov
double fov = StelApp::getInstance().getCore()->getMovementMgr()->get CurrentFov(); double fov = StelApp::getInstance().getCore()->getMovementMgr()->get CurrentFov();
Constellation::artIntensityFovScale = qBound(0.0,(fov - artIntensity MinimumFov) / (artIntensityMaximumFov - artIntensityMinimumFov),1.0); Constellation::artIntensityFovScale = qBound(0.0,(fov - artIntensity MinimumFov) / (artIntensityMaximumFov - artIntensityMinimumFov),1.0);
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
const int delta = (int)(deltaTime*1000); const int delta = (int)(deltaTime*1000);
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter) for (iter = constellations.begin(); iter != constellations.end(); ++ iter)
{ {
(*iter)->update(delta); (*iter)->update(delta);
} }
} }
void ConstellationMgr::setArtIntensity(const float intensity) void ConstellationMgr::setArtIntensity(const float intensity)
{ {
if (artIntensity != intensity) if (artIntensity != intensity)
{ {
artIntensity = intensity; artIntensity = intensity;
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++it er) for (iter = constellations.begin(); iter != constellations.e nd(); ++iter)
{ {
(*iter)->artFader.setMaxValue(artIntensity); (*iter)->artFader.setMaxValue(artIntensity);
} }
emit artIntensityChanged(intensity); emit artIntensityChanged(intensity);
} }
} }
float ConstellationMgr::getArtIntensity() const float ConstellationMgr::getArtIntensity() const
{ {
skipping to change at line 911 skipping to change at line 922
return artIntensityMaximumFov; return artIntensityMaximumFov;
} }
void ConstellationMgr::setArtFadeDuration(const float duration) void ConstellationMgr::setArtFadeDuration(const float duration)
{ {
if (artFadeDuration != duration) if (artFadeDuration != duration)
{ {
artFadeDuration = duration; artFadeDuration = duration;
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++it er) for (iter = constellations.begin(); iter != constellations.e nd(); ++iter)
{ {
(*iter)->artFader.setDuration((int) (duration * 1000 .f)); (*iter)->artFader.setDuration((int) (duration * 1000 .f));
} }
emit artFadeDurationChanged(duration); emit artFadeDurationChanged(duration);
} }
} }
float ConstellationMgr::getArtFadeDuration() const float ConstellationMgr::getArtFadeDuration() const
{ {
return artFadeDuration; return artFadeDuration;
skipping to change at line 940 skipping to change at line 951
{ {
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = selected.begin(); iter != selected.end() ; ++iter) for (iter = selected.begin(); iter != selected.end() ; ++iter)
{ {
(*iter)->setFlagLines(linesDisplayed); (*iter)->setFlagLines(linesDisplayed);
} }
} }
else else
{ {
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end (); ++iter) for (iter = constellations.begin(); iter != constell ations.end(); ++iter)
{ {
(*iter)->setFlagLines(linesDisplayed); (*iter)->setFlagLines(linesDisplayed);
} }
} }
emit linesDisplayedChanged(displayed); emit linesDisplayedChanged(displayed);
} }
} }
bool ConstellationMgr::getFlagLines(void) const bool ConstellationMgr::getFlagLines(void) const
{ {
skipping to change at line 970 skipping to change at line 981
{ {
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = selected.begin(); iter != selected.end() ; ++iter) for (iter = selected.begin(); iter != selected.end() ; ++iter)
{ {
(*iter)->setFlagBoundaries(boundariesDisplay ed); (*iter)->setFlagBoundaries(boundariesDisplay ed);
} }
} }
else else
{ {
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end (); ++iter) for (iter = constellations.begin(); iter != constell ations.end(); ++iter)
{ {
(*iter)->setFlagBoundaries(boundariesDisplay ed); (*iter)->setFlagBoundaries(boundariesDisplay ed);
} }
} }
emit boundariesDisplayedChanged(displayed); emit boundariesDisplayedChanged(displayed);
} }
} }
bool ConstellationMgr::getFlagBoundaries(void) const bool ConstellationMgr::getFlagBoundaries(void) const
{ {
skipping to change at line 1000 skipping to change at line 1011
{ {
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = selected.begin(); iter != selected.end() ; ++iter) for (iter = selected.begin(); iter != selected.end() ; ++iter)
{ {
(*iter)->setFlagArt(artDisplayed); (*iter)->setFlagArt(artDisplayed);
} }
} }
else else
{ {
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end (); ++iter) for (iter = constellations.begin(); iter != constell ations.end(); ++iter)
{ {
(*iter)->setFlagArt(artDisplayed); (*iter)->setFlagArt(artDisplayed);
} }
} }
emit artDisplayedChanged(displayed); emit artDisplayedChanged(displayed);
} }
} }
bool ConstellationMgr::getFlagArt(void) const bool ConstellationMgr::getFlagArt(void) const
{ {
skipping to change at line 1028 skipping to change at line 1039
namesDisplayed = displayed; namesDisplayed = displayed;
if (selected.begin() != selected.end() && isolateSelected) if (selected.begin() != selected.end() && isolateSelected)
{ {
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = selected.begin(); iter != selected.end() ; ++iter) for (iter = selected.begin(); iter != selected.end() ; ++iter)
(*iter)->setFlagLabels(namesDisplayed); (*iter)->setFlagLabels(namesDisplayed);
} }
else else
{ {
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end (); ++iter) for (iter = constellations.begin(); iter != constell ations.end(); ++iter)
(*iter)->setFlagLabels(namesDisplayed); (*iter)->setFlagLabels(namesDisplayed);
} }
emit namesDisplayedChanged(displayed); emit namesDisplayedChanged(displayed);
} }
} }
bool ConstellationMgr::getFlagLabels(void) const bool ConstellationMgr::getFlagLabels(void) const
{ {
return namesDisplayed; return namesDisplayed;
} }
skipping to change at line 1050 skipping to change at line 1061
void ConstellationMgr::setFlagIsolateSelected(const bool isolate) void ConstellationMgr::setFlagIsolateSelected(const bool isolate)
{ {
if (isolateSelected != isolate) if (isolateSelected != isolate)
{ {
isolateSelected = isolate; isolateSelected = isolate;
// when turning off isolated selection mode, clear exisiting isolated selections. // when turning off isolated selection mode, clear exisiting isolated selections.
if (!isolateSelected) if (!isolateSelected)
{ {
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end (); ++iter) for (iter = constellations.begin(); iter != constell ations.end(); ++iter)
{ {
(*iter)->setFlagLines(getFlagLines()); (*iter)->setFlagLines(getFlagLines());
(*iter)->setFlagLabels(getFlagLabels()); (*iter)->setFlagLabels(getFlagLabels());
(*iter)->setFlagArt(getFlagArt()); (*iter)->setFlagArt(getFlagArt());
(*iter)->setFlagBoundaries(getFlagBoundaries ()); (*iter)->setFlagBoundaries(getFlagBoundaries ());
} }
} }
emit isolateSelectedChanged(isolate); emit isolateSelectedChanged(isolate);
} }
} }
skipping to change at line 1085 skipping to change at line 1096
} }
StelObject* ConstellationMgr::getSelected(void) const StelObject* ConstellationMgr::getSelected(void) const
{ {
return *selected.begin(); // TODO return all or just remove this me thod return *selected.begin(); // TODO return all or just remove this me thod
} }
void ConstellationMgr::setSelected(const QString& abbreviation) void ConstellationMgr::setSelected(const QString& abbreviation)
{ {
Constellation * c = findFromAbbreviation(abbreviation); Constellation * c = findFromAbbreviation(abbreviation);
if(c != NULL) setSelectedConst(c); if(c != Q_NULLPTR) setSelectedConst(c);
} }
StelObjectP ConstellationMgr::setSelectedStar(const QString& abbreviation) StelObjectP ConstellationMgr::setSelectedStar(const QString& abbreviation)
{ {
Constellation * c = findFromAbbreviation(abbreviation); Constellation * c = findFromAbbreviation(abbreviation);
if(c != NULL) if(c != Q_NULLPTR)
{ {
setSelectedConst(c); setSelectedConst(c);
return c->getBrightestStarInConstellation(); return c->getBrightestStarInConstellation();
} }
return NULL; return Q_NULLPTR;
} }
void ConstellationMgr::setSelectedConst(Constellation * c) void ConstellationMgr::setSelectedConst(Constellation * c)
{ {
// update states for other constellations to fade them out // update states for other constellations to fade them out
if (c != NULL) if (c != Q_NULLPTR)
{ {
selected.push_back(c); selected.push_back(c);
if (isolateSelected) if (isolateSelected)
{ {
if (!getFlagConstellationPick()) if (!getFlagConstellationPick())
{ {
// Propagate current settings to newly selec ted constellation // Propagate current settings to newly selec ted constellation
c->setFlagLines(getFlagLines()); c->setFlagLines(getFlagLines());
c->setFlagLabels(getFlagLabels()); c->setFlagLabels(getFlagLabels());
c->setFlagArt(getFlagArt()); c->setFlagArt(getFlagArt());
c->setFlagBoundaries(getFlagBoundaries()); c->setFlagBoundaries(getFlagBoundaries());
vector < Constellation * >::const_iterator i ter; vector < Constellation * >::const_iterator i ter;
for (iter = asterisms.begin(); iter != aster isms.end(); ++iter) for (iter = constellations.begin(); iter != constellations.end(); ++iter)
{ {
bool match = false; bool match = false;
vector < Constellation * >::const_it erator s_iter; vector < Constellation * >::const_it erator s_iter;
for (s_iter = selected.begin(); s_it er != selected.end(); ++s_iter) for (s_iter = selected.begin(); s_it er != selected.end(); ++s_iter)
{ {
if( (*iter)==(*s_iter) ) if( (*iter)==(*s_iter) )
{ {
match=true; // this is a selected constellation match=true; // this is a selected constellation
break; break;
} }
skipping to change at line 1143 skipping to change at line 1154
(*iter)->setFlagLines(false) ; (*iter)->setFlagLines(false) ;
(*iter)->setFlagLabels(false ); (*iter)->setFlagLabels(false );
(*iter)->setFlagArt(false); (*iter)->setFlagArt(false);
(*iter)->setFlagBoundaries(f alse); (*iter)->setFlagBoundaries(f alse);
} }
} }
} }
else else
{ {
vector < Constellation * >::const_iterator i ter; vector < Constellation * >::const_iterator i ter;
for (iter = asterisms.begin(); iter != aster isms.end(); ++iter) for (iter = constellations.begin(); iter != constellations.end(); ++iter)
{ {
(*iter)->setFlagLines(false); (*iter)->setFlagLines(false);
(*iter)->setFlagLabels(false); (*iter)->setFlagLabels(false);
(*iter)->setFlagArt(false); (*iter)->setFlagArt(false);
(*iter)->setFlagBoundaries(false); (*iter)->setFlagBoundaries(false);
} }
// Propagate current settings to newly selec ted constellation // Propagate current settings to newly selec ted constellation
c->setFlagLines(getFlagLines()); c->setFlagLines(getFlagLines());
c->setFlagLabels(getFlagLabels()); c->setFlagLabels(getFlagLabels());
skipping to change at line 1169 skipping to change at line 1180
} }
else else
Constellation::singleSelected = false; // For bounda ries Constellation::singleSelected = false; // For bounda ries
} }
else else
{ {
if (selected.begin() == selected.end()) return; if (selected.begin() == selected.end()) return;
// Otherwise apply standard flags to all constellations // Otherwise apply standard flags to all constellations
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++it er) for (iter = constellations.begin(); iter != constellations.e nd(); ++iter)
{ {
(*iter)->setFlagLines(getFlagLines()); (*iter)->setFlagLines(getFlagLines());
(*iter)->setFlagLabels(getFlagLabels()); (*iter)->setFlagLabels(getFlagLabels());
(*iter)->setFlagArt(getFlagArt()); (*iter)->setFlagArt(getFlagArt());
(*iter)->setFlagBoundaries(getFlagBoundaries()); (*iter)->setFlagBoundaries(getFlagBoundaries());
} }
// And remove all selections // And remove all selections
selected.clear(); selected.clear();
} }
} }
//! Remove a constellation from the selected constellation list //! Remove a constellation from the selected constellation list
void ConstellationMgr::unsetSelectedConst(Constellation * c) void ConstellationMgr::unsetSelectedConst(Constellation * c)
{ {
if (c != NULL) if (c != Q_NULLPTR)
{ {
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
int n=0; int n=0;
for (iter = selected.begin(); iter != selected.end(); ++iter ) for (iter = selected.begin(); iter != selected.end(); ++iter )
{ {
if( (*iter)->getEnglishName() == c->getEnglishName() ) if( (*iter)->getEnglishName() == c->getEnglishName() )
{ {
selected.erase(selected.begin()+n, selected. begin()+n+1); selected.erase(selected.begin()+n, selected. begin()+n+1);
iter--; iter--;
n--; n--;
} }
n++; n++;
} }
// If no longer any selection, restore all flags on all cons tellations // If no longer any selection, restore all flags on all cons tellations
if (selected.begin() == selected.end()) if (selected.begin() == selected.end())
{ {
// Otherwise apply standard flags to all constellati ons // Otherwise apply standard flags to all constellati ons
for (iter = asterisms.begin(); iter != asterisms.end (); ++iter) for (iter = constellations.begin(); iter != constell ations.end(); ++iter)
{ {
(*iter)->setFlagLines(getFlagLines()); (*iter)->setFlagLines(getFlagLines());
(*iter)->setFlagLabels(getFlagLabels()); (*iter)->setFlagLabels(getFlagLabels());
(*iter)->setFlagArt(getFlagArt()); (*iter)->setFlagArt(getFlagArt());
(*iter)->setFlagBoundaries(getFlagBoundaries ()); (*iter)->setFlagBoundaries(getFlagBoundaries ());
} }
Constellation::singleSelected = false; // For bounda ries Constellation::singleSelected = false; // For bounda ries
} }
skipping to change at line 1233 skipping to change at line 1244
c->setFlagArt(false); c->setFlagArt(false);
c->setFlagBoundaries(false); c->setFlagBoundaries(false);
Constellation::singleSelected = true; // For bounda ries Constellation::singleSelected = true; // For bounda ries
} }
} }
} }
bool ConstellationMgr::loadBoundaries(const QString& boundaryFile) bool ConstellationMgr::loadBoundaries(const QString& boundaryFile)
{ {
Constellation *cons = NULL; Constellation *cons = Q_NULLPTR;
unsigned int i, j; unsigned int i, j;
// delete existing boundaries if any exist // delete existing boundaries if any exist
vector<vector<Vec3f> *>::iterator iter; vector<vector<Vec3f> *>::iterator iter;
for (iter = allBoundarySegments.begin(); iter != allBoundarySegments .end(); ++iter) for (iter = allBoundarySegments.begin(); iter != allBoundarySegments .end(); ++iter)
{ {
delete (*iter); delete (*iter);
} }
allBoundarySegments.clear(); allBoundarySegments.clear();
skipping to change at line 1259 skipping to change at line 1270
if (!dataFile.open(QIODevice::ReadOnly | QIODevice::Text)) if (!dataFile.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
qWarning() << "Boundary file " << QDir::toNativeSeparators(b oundaryFile) << " not found"; qWarning() << "Boundary file " << QDir::toNativeSeparators(b oundaryFile) << " not found";
return false; return false;
} }
QTextStream istr(&dataFile); QTextStream istr(&dataFile);
float DE, RA; float DE, RA;
Vec3f XYZ; Vec3f XYZ;
unsigned num, numc; unsigned num, numc;
vector<Vec3f> *points = NULL; vector<Vec3f> *points = Q_NULLPTR;
QString consname; QString consname;
i = 0; i = 0;
while (!istr.atEnd()) while (!istr.atEnd())
{ {
points = new vector<Vec3f>; points = new vector<Vec3f>;
num = 0; num = 0;
istr >> num; istr >> num;
if(num == 0) continue; // empty line if(num == 0) continue; // empty line
skipping to change at line 1301 skipping to change at line 1312
// not used? // not used?
if (consname == "SER1" || consname == "SER2") consna me = "SER"; if (consname == "SER1" || consname == "SER2") consna me = "SER";
cons = findFromAbbreviation(consname); cons = findFromAbbreviation(consname);
if (!cons) if (!cons)
qWarning() << "ERROR while processing bounda ry file - cannot find constellation: " << consname; qWarning() << "ERROR while processing bounda ry file - cannot find constellation: " << consname;
else else
cons->isolatedBoundarySegments.push_back(poi nts); cons->isolatedBoundarySegments.push_back(poi nts);
} }
if (cons) cons->sharedBoundarySegments.push_back(points); if (cons)
{
cons->sharedBoundarySegments.push_back(points);
points=Q_NULLPTR; // Avoid Coverity resource leak wa
rning. (CID48925).
}
i++; i++;
} }
dataFile.close(); dataFile.close();
qDebug() << "Loaded" << i << "constellation boundary segments"; qDebug() << "Loaded" << i << "constellation boundary segments";
delete points; if (points)
{
delete points; // See if Coverity complains here? (CID48925)
.
points=Q_NULLPTR;
}
return true; return true;
} }
void ConstellationMgr::drawBoundaries(StelPainter& sPainter) const void ConstellationMgr::drawBoundaries(StelPainter& sPainter) const
{ {
sPainter.setBlending(false); sPainter.setBlending(false);
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter) for (iter = constellations.begin(); iter != constellations.end(); ++ iter)
{ {
(*iter)->drawBoundaryOptim(sPainter); (*iter)->drawBoundaryOptim(sPainter);
} }
} }
StelObjectP ConstellationMgr::searchByNameI18n(const QString& nameI18n) con st StelObjectP ConstellationMgr::searchByNameI18n(const QString& nameI18n) con st
{ {
QString objw = nameI18n.toUpper(); QString objw = nameI18n.toUpper();
vector <Constellation*>::const_iterator iter; vector <Constellation*>::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter) for (iter = constellations.begin(); iter != constellations.end(); ++ iter)
{ {
QString objwcap = (*iter)->nameI18.toUpper(); QString objwcap = (*iter)->nameI18.toUpper();
if (objwcap==objw) return *iter; if (objwcap==objw) return *iter;
} }
return NULL; return Q_NULLPTR;
} }
StelObjectP ConstellationMgr::searchByName(const QString& name) const StelObjectP ConstellationMgr::searchByName(const QString& name) const
{ {
QString objw = name.toUpper(); QString objw = name.toUpper();
vector <Constellation*>::const_iterator iter; vector <Constellation*>::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter) for (iter = constellations.begin(); iter != constellations.end(); ++ iter)
{ {
QString objwcap = (*iter)->englishName.toUpper(); QString objwcap = (*iter)->englishName.toUpper();
if (objwcap==objw) return *iter; if (objwcap==objw) return *iter;
objwcap = (*iter)->abbreviation.toUpper(); objwcap = (*iter)->abbreviation.toUpper();
if (objwcap==objw) return *iter; if (objwcap==objw) return *iter;
} }
return NULL; return Q_NULLPTR;
}
StelObjectP ConstellationMgr::searchByID(const QString &id) const
{
vector <Constellation*>::const_iterator iter;
for (iter = constellations.begin(); iter != constellations.end(); ++
iter)
{
if ((*iter)->getID() == id) return *iter;
}
return Q_NULLPTR;
} }
QStringList ConstellationMgr::listMatchingObjects(const QString& objPrefix, int maxNbItem, bool useStartOfWords, bool inEnglish) const QStringList ConstellationMgr::listMatchingObjects(const QString& objPrefix, int maxNbItem, bool useStartOfWords, bool inEnglish) const
{ {
QStringList result; QStringList result;
if (maxNbItem <= 0) if (maxNbItem <= 0)
{ {
return result; return result;
} }
vector<Constellation*>::const_iterator iter; vector<Constellation*>::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter) for (iter = constellations.begin(); iter != constellations.end(); ++ iter)
{ {
QString name = inEnglish ? (*iter)->getEnglishName() : (*ite r)->getNameI18n(); QString name = inEnglish ? (*iter)->getEnglishName() : (*ite r)->getNameI18n();
if (!matchObjectName(name, objPrefix, useStartOfWords)) if (!matchObjectName(name, objPrefix, useStartOfWords))
{ {
continue; continue;
} }
result.append(name); result.append(name);
if (result.size() >= maxNbItem) if (result.size() >= maxNbItem)
{ {
skipping to change at line 1383 skipping to change at line 1411
result.sort(); result.sort();
return result; return result;
} }
QStringList ConstellationMgr::listAllObjects(bool inEnglish) const QStringList ConstellationMgr::listAllObjects(bool inEnglish) const
{ {
QStringList result; QStringList result;
if (inEnglish) if (inEnglish)
{ {
foreach(Constellation* constellation, asterisms) foreach(Constellation* constellation, constellations)
{ {
result << constellation->getEnglishName(); result << constellation->getEnglishName();
} }
} }
else else
{ {
foreach(Constellation* constellation, asterisms) foreach(Constellation* constellation, constellations)
{ {
result << constellation->getNameI18n(); result << constellation->getNameI18n();
} }
} }
return result; return result;
} }
QString ConstellationMgr::getStelObjectType() const
{
return Constellation::CONSTELLATION_TYPE;
}
void ConstellationMgr::setSelected(const StelObject *s) void ConstellationMgr::setSelected(const StelObject *s)
{ {
if (!s) if (!s)
setSelectedConst(NULL); setSelectedConst(Q_NULLPTR);
else else
{ {
if (StelApp::getInstance().getSkyCultureMgr().getCurrentSkyC ultureBoundariesIdx()==0) // generic IAU boundaries if (StelApp::getInstance().getSkyCultureMgr().getCurrentSkyC ultureBoundariesIdx()==0) // generic IAU boundaries
setSelectedConst(isObjectIn(s)); setSelectedConst(isObjectIn(s));
else else
setSelectedConst(isStarIn(s)); setSelectedConst(isStarIn(s));
} }
} }
Constellation* ConstellationMgr::isObjectIn(const StelObject *s) const Constellation* ConstellationMgr::isObjectIn(const StelObject *s) const
{ {
StelCore *core = StelApp::getInstance().getCore(); StelCore *core = StelApp::getInstance().getCore();
QString IAUConst = core->getIAUConstellation(s->getJ2000EquatorialPo s(core)); QString IAUConst = core->getIAUConstellation(s->getEquinoxEquatorial Pos(core));
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter) for (iter = constellations.begin(); iter != constellations.end(); ++ iter)
{ {
// Check if the object is in the constellation // Check if the object is in the constellation
if ((*iter)->getShortName().toUpper()==IAUConst.toUpper()) if ((*iter)->getShortName().toUpper()==IAUConst.toUpper())
return (*iter); return (*iter);
} }
return NULL; return Q_NULLPTR;
} }
 End of changes. 60 change blocks. 
60 lines changed or deleted 97 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/