ConstellationMgr.cpp   ConstellationMgr.cpp 
skipping to change at line 29 skipping to change at line 29
*/ */
#include <vector> #include <vector>
#include <QDebug> #include <QDebug>
#include <QFile> #include <QFile>
#include <QImageReader> #include <QImageReader>
#include <QSettings> #include <QSettings>
#include <QRegExp> #include <QRegExp>
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
#include <QDir>
#include "ConstellationMgr.hpp" #include "ConstellationMgr.hpp"
#include "Constellation.hpp" #include "Constellation.hpp"
#include "StarMgr.hpp" #include "StarMgr.hpp"
#include "StelUtils.hpp" #include "StelUtils.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "renderer/StelRenderer.hpp" #include "renderer/StelRenderer.hpp"
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelObjectMgr.hpp" #include "StelObjectMgr.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
skipping to change at line 131 skipping to change at line 132
// Find constellation art. If this doesn't exist, warn, but continu e using "" // Find constellation art. If this doesn't exist, warn, but continu e using ""
// the loadLinesAndArt function knows how to handle this (just loads lines). // the loadLinesAndArt function knows how to handle this (just loads lines).
QString conArtFile; QString conArtFile;
try try
{ {
conArtFile = StelFileMgr::findFile("skycultures/"+skyCulture Dir+"/constellationsart.fab"); conArtFile = StelFileMgr::findFile("skycultures/"+skyCulture Dir+"/constellationsart.fab");
} }
catch (std::runtime_error& e) catch (std::runtime_error& e)
{ {
qDebug() << "No constellationsart.fab file found for sky cul ture " << skyCultureDir; qDebug() << "No constellationsart.fab file found for sky cul ture " << QDir::toNativeSeparators(skyCultureDir);
} }
try try
{ {
// first of all, remove constellations from the list of sele cted objects in StelObjectMgr, since we are going to delete them // first of all, remove constellations from the list of sele cted objects in StelObjectMgr, since we are going to delete them
deselectConstellations(); deselectConstellations();
loadLinesAndArt(StelFileMgr::findFile("skycultures/"+skyCult ureDir+"/constellationship.fab"), conArtFile, skyCultureDir); loadLinesAndArt(StelFileMgr::findFile("skycultures/"+skyCult ureDir+"/constellationship.fab"), conArtFile, skyCultureDir);
// load constellation names // load constellation names
loadNames(StelFileMgr::findFile("skycultures/" + skyCultureD ir + "/constellation_names.eng.fab")); loadNames(StelFileMgr::findFile("skycultures/" + skyCultureD ir + "/constellation_names.eng.fab"));
// Translate constellation names for the new sky culture // Translate constellation names for the new sky culture
updateI18n(); updateI18n();
} }
catch (std::runtime_error& e) catch (std::runtime_error& e)
{ {
qWarning() << "ERROR: while loading new constellation data f or sky culture " qWarning() << "ERROR: while loading new constellation data f or sky culture "
<< skyCultureDir << ", reason: " << e.what() << endl ; << QDir::toNativeSeparators(skyCultureDir) << ", rea son: " << e.what() << endl;
} }
// TODO: do we need to have an else { clearBoundaries(); } ? // TODO: do we need to have an else { clearBoundaries(); } ?
// load constellation boundaries // load constellation boundaries
try try
{ {
loadBoundaries(StelFileMgr::findFile("skycultures/" + skyCul tureDir + "/constellations_boundaries.dat")); loadBoundaries(StelFileMgr::findFile("skycultures/" + skyCul tureDir + "/constellations_boundaries.dat"));
} }
catch (std::runtime_error& e) catch (std::runtime_error& e)
{ {
skipping to change at line 305 skipping to change at line 306
float ConstellationMgr::getFontSize() const float ConstellationMgr::getFontSize() const
{ {
return asterFont.pixelSize(); return asterFont.pixelSize();
} }
void ConstellationMgr::loadLinesAndArt(const QString &fileName, const QStri ng &artfileName, const QString& cultureName) void ConstellationMgr::loadLinesAndArt(const QString &fileName, const QStri ng &artfileName, const QString& cultureName)
{ {
QFile in(fileName); QFile in(fileName);
if (!in.open(QIODevice::ReadOnly | QIODevice::Text)) if (!in.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
qWarning() << "Can't open constellation data file" << fileNa me << "for culture" << cultureName; qWarning() << "Can't open constellation data file" << QDir:: toNativeSeparators(fileName) << "for culture" << cultureName;
Q_ASSERT(0); Q_ASSERT(0);
} }
int totalRecords=0; int totalRecords=0;
QString record; QString record;
QRegExp commentRx("^(\\s*#.*|\\s*)$"); QRegExp commentRx("^(\\s*#.*|\\s*)$");
while (!in.atEnd()) while (!in.atEnd())
{ {
record = QString::fromUtf8(in.readLine()); record = QString::fromUtf8(in.readLine());
if (!commentRx.exactMatch(record)) if (!commentRx.exactMatch(record))
skipping to change at line 370 skipping to change at line 371
setFlagLines(linesDisplayed); setFlagLines(linesDisplayed);
setFlagLabels(namesDisplayed); setFlagLabels(namesDisplayed);
setFlagBoundaries(boundariesDisplayed); setFlagBoundaries(boundariesDisplayed);
// It's possible to have no art - just constellations // It's possible to have no art - just constellations
if (artfileName.isNull() || artfileName.isEmpty()) if (artfileName.isNull() || artfileName.isEmpty())
return; return;
QFile fic(artfileName); QFile fic(artfileName);
if (!fic.open(QIODevice::ReadOnly | QIODevice::Text)) if (!fic.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
qWarning() << "Can't open constellation art file" << fileNam e << "for culture" << cultureName; qWarning() << "Can't open constellation art file" << QDir::t oNativeSeparators(fileName) << "for culture" << cultureName;
return; return;
} }
totalRecords=0; totalRecords=0;
while (!fic.atEnd()) while (!fic.atEnd())
{ {
record = QString::fromUtf8(fic.readLine()); record = QString::fromUtf8(fic.readLine());
if (!commentRx.exactMatch(record)) if (!commentRx.exactMatch(record))
totalRecords++; totalRecords++;
} }
skipping to change at line 438 skipping to change at line 439
{ {
QString texturePath(texfile); QString texturePath(texfile);
try try
{ {
texturePath = StelFileMgr::findFile("skycult ures/"+cultureName+"/"+texfile); texturePath = StelFileMgr::findFile("skycult ures/"+cultureName+"/"+texfile);
} }
catch (std::runtime_error& e) catch (std::runtime_error& e)
{ {
// if the texture isn't found in the skycult ures/[culture] directory, // if the texture isn't found in the skycult ures/[culture] directory,
// try the central textures diectory. // try the central textures diectory.
qWarning() << "WARNING, could not locate tex ture file " << texfile qWarning() << "WARNING, could not locate tex ture file " << QDir::toNativeSeparators(texfile)
<< " in the skycultures/" << cultur eName << " in the skycultures/" << cultur eName
<< " directory... looking in gener al textures/ directory..."; << " directory... looking in gener al textures/ directory...";
try try
{ {
texturePath = StelFileMgr::findFile( QString("textures/")+texfile); texturePath = StelFileMgr::findFile( QString("textures/")+texfile);
} }
catch(std::exception& e2) catch(std::exception& e2)
{ {
qWarning() << "ERROR: could not find texture, " << texfile << ": " << e2.what(); qWarning() << "ERROR: could not find texture, " << QDir::toNativeSeparators(texfile) << ": " << e2.what();
} }
} }
cons->artTexturePath = texturePath; cons->artTexturePath = texturePath;
// This is one part that is less convenient than bef ore the GL refactor // This is one part that is less convenient than bef ore the GL refactor
// (due to the StelRenderer not being globally (Stel Core) available. // (due to the StelRenderer not being globally (Stel Core) available.
// We need to determine texture size manually here. // We need to determine texture size manually here.
// Try to get the size from the file without loading data // Try to get the size from the file without loading data
skipping to change at line 618 skipping to change at line 619
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter) for (iter = asterisms.begin(); iter != asterisms.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" << namesFile; 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()
QRegExp recRx("^\\s*(\\w+)\\s+\"(.*)\"\\s+_[(]\"(.*)\"[)]\\n"); QRegExp recRx("^\\s*(\\w+)\\s+\"(.*)\"\\s+_[(]\"(.*)\"[)]\\n");
skipping to change at line 651 skipping to change at line 652
lineNumber++; lineNumber++;
// Skip comments // Skip comments
if (commentRx.exactMatch(record)) if (commentRx.exactMatch(record))
continue; continue;
totalRecords++; totalRecords++;
if (!recRx.exactMatch(record)) if (!recRx.exactMatch(record))
{ {
qWarning() << "ERROR - cannot parse record at line" << lineNumber << "in constellation names file" << namesFile; qWarning() << "ERROR - cannot parse record at line" << lineNumber << "in constellation names file" << QDir::toNativeSeparators( namesFile);
} }
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 != NULL)
{ {
aster->nativeName = recRx.capturedTexts().at (2); aster->nativeName = recRx.capturedTexts().at (2);
aster->englishName = recRx.capturedTexts().a t(3); aster->englishName = recRx.capturedTexts().a t(3);
skipping to change at line 698 skipping to change at line 699
const int delta = (int)(deltaTime*1000); const int delta = (int)(deltaTime*1000);
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter) for (iter = asterisms.begin(); iter != asterisms.end(); ++iter)
{ {
(*iter)->update(delta); (*iter)->update(delta);
} }
} }
void ConstellationMgr::setArtIntensity(const double intensity) void ConstellationMgr::setArtIntensity(const double intensity)
{ {
if (artIntensity != intensity) if (artIntensity != intensity)
{
artIntensity = intensity; artIntensity = intensity;
vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++it vector < Constellation * >::const_iterator iter;
er) for (iter = asterisms.begin(); iter != asterisms.end(); ++iter)
{ {
(*iter)->artFader.setMaxValue(artIntensity); (*iter)->artFader.setMaxValue(artIntensity);
}
emit artIntensityChanged(intensity);
} }
emit artIntensityChanged(intensity);
} }
double ConstellationMgr::getArtIntensity() const double ConstellationMgr::getArtIntensity() const
{ {
return artIntensity; return artIntensity;
} }
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;
for (iter = asterisms.begin(); iter != asterisms.end(); ++it vector < Constellation * >::const_iterator iter;
er) for (iter = asterisms.begin(); iter != asterisms.end(); ++iter)
{ {
(*iter)->artFader.setDuration((int) (duration * 1000 (*iter)->artFader.setDuration((int) (duration * 1000.f));
.f));
}
emit artFadeDurationChanged(duration);
} }
emit artFadeDurationChanged(duration);
} }
float ConstellationMgr::getArtFadeDuration() const float ConstellationMgr::getArtFadeDuration() const
{ {
return artFadeDuration; return artFadeDuration;
} }
void ConstellationMgr::setFlagLines(const bool displayed) void ConstellationMgr::setFlagLines(const bool displayed)
{ {
if(linesDisplayed != displayed) if(linesDisplayed != displayed)
skipping to change at line 1030 skipping to change at line 1029
} }
allBoundarySegments.clear(); allBoundarySegments.clear();
qDebug() << "Loading constellation boundary data ... "; qDebug() << "Loading constellation boundary data ... ";
// Modified boundary file by Torsten Bronger with permission // Modified boundary file by Torsten Bronger with permission
// http://pp3.sourceforge.net // http://pp3.sourceforge.net
QFile dataFile(boundaryFile); QFile dataFile(boundaryFile);
if (!dataFile.open(QIODevice::ReadOnly | QIODevice::Text)) if (!dataFile.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
qWarning() << "Boundary file " << boundaryFile << " not foun d"; 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 = NULL;
QString consname; QString consname;
i = 0; i = 0;
skipping to change at line 1135 skipping to change at line 1134
if (objwcap==objw) return *iter; if (objwcap==objw) return *iter;
} }
return NULL; return NULL;
} }
QStringList ConstellationMgr::listMatchingObjectsI18n(const QString& objPre fix, int maxNbItem) const QStringList ConstellationMgr::listMatchingObjectsI18n(const QString& objPre fix, int maxNbItem) const
{ {
QStringList result; QStringList result;
if (maxNbItem==0) return result; if (maxNbItem==0) return result;
QString objw = objPrefix.toUpper(); QString cn;
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter) for (iter = asterisms.begin(); iter != asterisms.end(); ++iter)
{ {
QString constw = (*iter)->getNameI18n().mid(0, objw.size()). cn = (*iter)->getNameI18n();
toUpper(); if (cn.contains(objPrefix,Qt::CaseInsensitive))
if (constw==objw)
{ {
result << (*iter)->getNameI18n(); result << cn;
if (result.size()==maxNbItem) if (result.size()==maxNbItem)
return result; return result;
} }
} }
return result; return result;
} }
QStringList ConstellationMgr::listMatchingObjects(const QString& objPrefix, int maxNbItem) const QStringList ConstellationMgr::listMatchingObjects(const QString& objPrefix, int maxNbItem) const
{ {
QStringList result; QStringList result;
if (maxNbItem==0) return result; if (maxNbItem==0) return result;
QString objw = objPrefix.toUpper(); QString cn;
vector < Constellation * >::const_iterator iter; vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter) for (iter = asterisms.begin(); iter != asterisms.end(); ++iter)
{ {
QString constw = (*iter)->getEnglishName().mid(0, objw.size( cn = (*iter)->getEnglishName();
)).toUpper(); if (cn.contains(objPrefix, Qt::CaseInsensitive))
if (constw==objw)
{ {
result << (*iter)->getEnglishName(); result << cn;
if (result.size()==maxNbItem) if (result.size()==maxNbItem)
return result; return result;
} }
} }
return result; return result;
} }
QStringList ConstellationMgr::listAllObjects(bool inEnglish) const QStringList ConstellationMgr::listAllObjects(bool inEnglish) const
{ {
QStringList result; QStringList result;
 End of changes. 22 change blocks. 
39 lines changed or deleted 31 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/