ConstellationMgr.cpp   ConstellationMgr.cpp 
skipping to change at line 61 skipping to change at line 61
artFadeDuration(1.), artFadeDuration(1.),
artIntensity(0), artIntensity(0),
artDisplayed(0), artDisplayed(0),
boundariesDisplayed(0), boundariesDisplayed(0),
linesDisplayed(0), linesDisplayed(0),
namesDisplayed(0) namesDisplayed(0)
{ {
setObjectName("ConstellationMgr"); setObjectName("ConstellationMgr");
Q_ASSERT(hipStarMgr); Q_ASSERT(hipStarMgr);
isolateSelected = false; isolateSelected = false;
asterFont.setPixelSize(15);
} }
ConstellationMgr::~ConstellationMgr() ConstellationMgr::~ConstellationMgr()
{ {
std::vector<Constellation *>::iterator iter; std::vector<Constellation *>::iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); iter++) for (iter = asterisms.begin(); iter != asterisms.end(); iter++)
{ {
delete(*iter); delete(*iter);
} }
skipping to change at line 95 skipping to change at line 94
lastLoadedSkyCulture = "dummy"; lastLoadedSkyCulture = "dummy";
asterFont.setPixelSize(conf->value("viewing/constellation_font_size" , 14).toInt()); asterFont.setPixelSize(conf->value("viewing/constellation_font_size" , 14).toInt());
setFlagLines(conf->value("viewing/flag_constellation_drawing").toBoo l()); setFlagLines(conf->value("viewing/flag_constellation_drawing").toBoo l());
setFlagLabels(conf->value("viewing/flag_constellation_name").toBool( )); setFlagLabels(conf->value("viewing/flag_constellation_name").toBool( ));
setFlagBoundaries(conf->value("viewing/flag_constellation_boundaries ",false).toBool()); setFlagBoundaries(conf->value("viewing/flag_constellation_boundaries ",false).toBool());
setArtIntensity(conf->value("viewing/constellation_art_intensity", 0 .5f).toFloat()); setArtIntensity(conf->value("viewing/constellation_art_intensity", 0 .5f).toFloat());
setArtFadeDuration(conf->value("viewing/constellation_art_fade_durat ion",2.f).toFloat()); setArtFadeDuration(conf->value("viewing/constellation_art_fade_durat ion",2.f).toFloat());
setFlagArt(conf->value("viewing/flag_constellation_art").toBool()); setFlagArt(conf->value("viewing/flag_constellation_art").toBool());
setFlagIsolateSelected(conf->value("viewing/flag_constellation_isola te_selected", setFlagIsolateSelected(conf->value("viewing/flag_constellation_isola te_selected",
conf->value("viewing/flag_constel lation_pick", false).toBool() ).toBool()); conf->value("viewing/flag_constellation_pick" , false).toBool() ).toBool());
StelObjectMgr *objectManager = GETSTELMODULE(StelObjectMgr); StelObjectMgr *objectManager = GETSTELMODULE(StelObjectMgr);
objectManager->registerStelObjectMgr(this); objectManager->registerStelObjectMgr(this);
connect(objectManager, SIGNAL(selectedObjectChanged(StelModule::Stel ModuleSelectAction)), connect(objectManager, SIGNAL(selectedObjectChanged(StelModule::Stel ModuleSelectAction)),
this, SLOT(selectedObjectChange(StelModule::StelModu leSelectAction))); this, SLOT(selectedObjectChange(StelModule::StelModu leSelectAction)));
StelApp *app = &StelApp::getInstance(); StelApp *app = &StelApp::getInstance();
connect(app, SIGNAL(languageChanged()), this, SLOT(updateI18n())); connect(app, SIGNAL(languageChanged()), this, SLOT(updateI18n()));
connect(app, SIGNAL(skyCultureChanged(const QString&)), this, SLOT(u pdateSkyCulture(const QString&))); connect(app, SIGNAL(skyCultureChanged(const QString&)), this, SLOT(u pdateSkyCulture(const QString&)));
connect(app, SIGNAL(colorSchemeChanged(const QString&)), this, SLOT( setStelStyle(const QString&))); connect(app, SIGNAL(colorSchemeChanged(const QString&)), this, SLOT( setStelStyle(const QString&)));
skipping to change at line 153 skipping to change at line 152
else else
loadLinesAndArt(fic, conArtFile, skyCultureDir); loadLinesAndArt(fic, conArtFile, skyCultureDir);
// load constellation names // load constellation names
fic = StelFileMgr::findFile("skycultures/" + skyCultureDir + "/const ellation_names.eng.fab"); fic = StelFileMgr::findFile("skycultures/" + skyCultureDir + "/const ellation_names.eng.fab");
if (fic.isEmpty()) if (fic.isEmpty())
qWarning() << "ERROR loading constellation names from file: " << fic; qWarning() << "ERROR loading constellation names from file: " << fic;
else else
loadNames(fic); loadNames(fic);
// load seasonal rules
loadSeasonalRules(StelFileMgr::findFile("skycultures/" + skyCultureD
ir + "/seasonal_rules.fab"));
// Translate constellation names for the new sky culture // Translate constellation names for the new sky culture
updateI18n(); updateI18n();
// load constellation boundaries // load constellation boundaries
// First try load constellation boundaries from sky culture // First try load constellation boundaries from sky culture
fic = StelFileMgr::findFile("skycultures/" + skyCultureDir + "/const ellations_boundaries.dat"); fic = StelFileMgr::findFile("skycultures/" + skyCultureDir + "/const ellations_boundaries.dat");
bool existBoundaries = false; bool existBoundaries = false;
if (fic.isEmpty()) if (fic.isEmpty())
{ {
qWarning() << "ERROR loading constellation boundaries file i n sky culture: " << skyCultureDir; qWarning() << "ERROR loading constellation boundaries file i n sky culture: " << skyCultureDir;
skipping to change at line 673 skipping to change at line 675
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)
{
// Constellation not loaded yet
if (asterisms.empty()) return;
bool flag = true;
if (rulesFile.isEmpty())
flag = false;
// clear previous names
vector < Constellation * >::const_iterator iter;
for (iter = asterisms.begin(); iter != asterisms.end(); ++iter)
{
(*iter)->beginSeason = 1;
(*iter)->endSeason = 12;
(*iter)->seasonalRuleEnabled = flag;
}
// Current starlore didn't support the seasonal rules
if (!flag)
return;
// Open file
QFile seasonalRulesFile(rulesFile);
if (!seasonalRulesFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
qDebug() << "Cannot open file" << QDir::toNativeSeparators(r
ulesFile);
return;
}
// Now parse the file
// lines to ignore which start with a # or are empty
QRegExp commentRx("^(\\s*#.*|\\s*)$");
// lines which look like records - we use the RE to extract the fiel
ds
// which will be available in recRx.capturedTexts()
QRegExp recRx("^\\s*(\\w+)\\s+(\\w+)\\s+(\\w+)\\n");
// Some more variables to use in the parsing
Constellation *aster;
QString record, shortName;
// keep track of how many records we processed.
int totalRecords=0;
int readOk=0;
int lineNumber=0;
while (!seasonalRulesFile.atEnd())
{
record = QString::fromUtf8(seasonalRulesFile.readLine());
lineNumber++;
// Skip comments
if (commentRx.exactMatch(record))
continue;
totalRecords++;
if (!recRx.exactMatch(record))
{
qWarning() << "ERROR - cannot parse record at line"
<< lineNumber << "in seasonal rules file" << QDir::toNativeSeparators(rules
File);
}
else
{
shortName = recRx.capturedTexts().at(1);
aster = findFromAbbreviation(shortName);
// If the constellation exists, set the English name
if (aster != NULL)
{
aster->beginSeason = recRx.capturedTexts().a
t(2).toInt();
aster->endSeason = recRx.capturedTexts().at(
3).toInt();
readOk++;
}
else
{
qWarning() << "WARNING - constellation abbre
viation" << shortName << "not found when loading seasonal rules for constel
lations";
}
}
}
seasonalRulesFile.close();
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 = asterisms.begin(); iter != asterisms.end(); ++iter)
{ {
(*iter)->nameI18 = trans.qtranslate((*iter)->englishName); (*iter)->nameI18 = trans.qtranslate((*iter)->englishName);
} }
} }
 End of changes. 4 change blocks. 
2 lines changed or deleted 96 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/