LandscapeMgr.cpp   LandscapeMgr.cpp 
skipping to change at line 303 skipping to change at line 303
float sinSunAngle = 0.0f; float sinSunAngle = 0.0f;
if(atmosphere->getFlagShow()) if(atmosphere->getFlagShow())
{ {
sinSunAngle=sin(qMin(M_PI_2, asin(sunPos[2])+8.*M_PI/180.)); sinSunAngle=sin(qMin(M_PI_2, asin(sunPos[2])+8.*M_PI/180.));
if(sinSunAngle > -0.1/1.5 ) if(sinSunAngle > -0.1/1.5 )
landscapeBrightness += 1.5*(sinSunAngle+0.1/1.5); landscapeBrightness += 1.5*(sinSunAngle+0.1/1.5);
} }
else else
{ {
// In case we have exceptionally deep horizons ("Little Prin ce planet"), the sun will rise somehow over that line and demand light on t he landscape. // In case we have exceptionally deep horizons ("Little Prin ce planet"), the sun will rise somehow over that line and demand light on t he landscape.
sinSunAngle=sin(qMin(M_PI_2, asin(sunPos[2]-landscape->getSi nMinAltitudeLimit()) + (0.25f *M_PI/180.))); sinSunAngle=sin(qMin(M_PI_2, asin(qMax(-1.0, qMin(1.0, sunPo s[2]-landscape->getSinMinAltitudeLimit()))) + (0.25f *M_PI/180.)));
if(sinSunAngle > 0.0f) if(sinSunAngle > 0.0f)
landscapeBrightness += (1.0f-landscape->getOpacity( sunPos))*sinSunAngle; landscapeBrightness += (1.0f-landscape->getOpacity( sunPos))*sinSunAngle;
} }
// GZ: 2013-09-25 Take light pollution into account! // GZ: 2013-09-25 Take light pollution into account!
StelSkyDrawer* drawer=StelApp::getInstance().getCore()->getSkyDrawer (); StelSkyDrawer* drawer=StelApp::getInstance().getCore()->getSkyDrawer ();
float pollutionAddonBrightness=(drawer->getBortleScaleIndex()-1.0f)* 0.025f; // 0..8, so we assume empirical linear brightening 0..0.02 float pollutionAddonBrightness=(drawer->getBortleScaleIndex()-1.0f)* 0.025f; // 0..8, so we assume empirical linear brightening 0..0.02
float lunarAddonBrightness=0.f; float lunarAddonBrightness=0.f;
if (moonPos[2] > -0.1/1.5) if (moonPos[2] > -0.1/1.5)
skipping to change at line 398 skipping to change at line 398
setFlagLandscapeSetsLocation(conf->value("landscape/flag_landscape_s ets_location",false).toBool()); setFlagLandscapeSetsLocation(conf->value("landscape/flag_landscape_s ets_location",false).toBool());
setFlagLandscapeAutoSelection(conf->value("viewing/flag_landscape_au toselection", false).toBool()); setFlagLandscapeAutoSelection(conf->value("viewing/flag_landscape_au toselection", false).toBool());
// Set minimal brightness for landscape. This feature has been added for folks which say "landscape is super dark, please add light". --AW // Set minimal brightness for landscape. This feature has been added for folks which say "landscape is super dark, please add light". --AW
setDefaultMinimalBrightness(conf->value("landscape/minimal_brightnes s", 0.01).toFloat()); setDefaultMinimalBrightness(conf->value("landscape/minimal_brightnes s", 0.01).toFloat());
setFlagLandscapeUseMinimalBrightness(conf->value("landscape/flag_min imal_brightness", false).toBool()); setFlagLandscapeUseMinimalBrightness(conf->value("landscape/flag_min imal_brightness", false).toBool());
setFlagLandscapeSetsMinimalBrightness(conf->value("landscape/flag_la ndscape_sets_minimal_brightness",false).toBool()); setFlagLandscapeSetsMinimalBrightness(conf->value("landscape/flag_la ndscape_sets_minimal_brightness",false).toBool());
setFlagAtmosphereAutoEnable(conf->value("viewing/flag_atmosphere_aut o_enable",true).toBool()); setFlagAtmosphereAutoEnable(conf->value("viewing/flag_atmosphere_aut o_enable",true).toBool());
setFlagIllumination(conf->value("landscape/flag_enable_illumination_ layer", true).toBool()); setFlagIllumination(conf->value("landscape/flag_enable_illumination_ layer", true).toBool());
setFlagLabels(conf->value("landscape/flag_enable_labels", true).toBo ol()); setFlagLabels(conf->value("landscape/flag_enable_labels", true).toBo ol());
bool ok =true; // Load colors from config file
setAtmosphereBortleLightPollution(conf->value("stars/init_bortle_sca QString defaultColor = conf->value("color/default_color").toString()
le",3).toInt(&ok)); ;
if (!ok) setColorCardinalPoints(StelUtils::strToVec3f(conf->value("color/card
{ inal_color", defaultColor).toString()));
conf->setValue("stars/init_bortle_scale",3);
setAtmosphereBortleLightPollution(3);
ok = true;
}
StelApp *app = &StelApp::getInstance(); StelApp *app = &StelApp::getInstance();
//Bortle scale is managed by SkyDrawer
StelSkyDrawer* drawer = app->getCore()->getSkyDrawer();
setAtmosphereBortleLightPollution(drawer->getBortleScaleIndex());
connect(app->getCore(), SIGNAL(locationChanged(StelLocation)), this,
SLOT(updateLocationBasedPollution(StelLocation)));
connect(drawer, SIGNAL(bortleScaleIndexChanged(int)), this, SLOT(set
AtmosphereBortleLightPollution(int)));
connect(app, SIGNAL(languageChanged()), this, SLOT(updateI18n())); connect(app, SIGNAL(languageChanged()), this, SLOT(updateI18n()));
connect(app, SIGNAL(colorSchemeChanged(const QString&)), this, SLOT( setStelStyle(const QString&)));
QString displayGroup = N_("Display Options"); QString displayGroup = N_("Display Options");
addAction("actionShow_Atmosphere", displayGroup, N_("Atmosphere"), " atmosphereDisplayed", "A"); addAction("actionShow_Atmosphere", displayGroup, N_("Atmosphere"), " atmosphereDisplayed", "A");
addAction("actionShow_Fog", displayGroup, N_("Fog"), "fogDisplayed", "F"); addAction("actionShow_Fog", displayGroup, N_("Fog"), "fogDisplayed", "F");
addAction("actionShow_Cardinal_Points", displayGroup, N_("Cardinal p oints"), "cardinalsPointsDisplayed", "Q"); addAction("actionShow_Cardinal_Points", displayGroup, N_("Cardinal p oints"), "cardinalsPointsDisplayed", "Q");
addAction("actionShow_Ground", displayGroup, N_("Ground"), "landscap eDisplayed", "G"); addAction("actionShow_Ground", displayGroup, N_("Ground"), "landscap eDisplayed", "G");
addAction("actionShow_LandscapeIllumination", displayGroup, N_("Illu mination"), "illuminationDisplayed", "Shift+G"); addAction("actionShow_LandscapeIllumination", displayGroup, N_("Illu mination"), "illuminationDisplayed", "Shift+G");
addAction("actionShow_LandscapeLabels", displayGroup, N_("Labels"), "labelsDisplayed", "Ctrl+Shift+G"); addAction("actionShow_LandscapeLabels", displayGroup, N_("Labels"), "labelsDisplayed", "Ctrl+Shift+G");
} addAction("actionShow_LightPollution_Database", displayGroup, N_("Li
ght pollution data from locations database"), "databaseUsage");
void LandscapeMgr::setStelStyle(const QString& section)
{
// Load colors from config file
QSettings* conf = StelApp::getInstance().getSettings();
QString defaultColor = conf->value(section+"/default_color").toStrin
g();
setColorCardinalPoints(StelUtils::strToVec3f(conf->value(section+"/c
ardinal_color", defaultColor).toString()));
} }
bool LandscapeMgr::setCurrentLandscapeID(const QString& id, const double ch angeLocationDuration) bool LandscapeMgr::setCurrentLandscapeID(const QString& id, const double ch angeLocationDuration)
{ {
if (id.isEmpty()) if (id.isEmpty())
return false; return false;
//prevent unnecessary changes/file access
if(id==currentLandscapeID)
return false;
// We want to lookup the landscape ID (dir) from the name. // We want to lookup the landscape ID (dir) from the name.
Landscape* newLandscape = createFromFile(StelFileMgr::findFile("land scapes/" + id + "/landscape.ini"), id); Landscape* newLandscape = createFromFile(StelFileMgr::findFile("land scapes/" + id + "/landscape.ini"), id);
if (!newLandscape) if (!newLandscape)
{ {
qWarning() << "ERROR while loading default landscape " << "l andscapes/" + id + "/landscape.ini"; qWarning() << "ERROR while loading landscape " << "landscape s/" + id + "/landscape.ini";
return false; return false;
} }
// Keep current landscape for a while, while new landscape fades in! // Keep current landscape for a while, while new landscape fades in!
// This prevents subhorizon sun or grid becoming briefly visible. // This prevents subhorizon sun or grid becoming briefly visible.
if (landscape) if (landscape)
{ {
// Copy display parameters from previous landscape to new on e // Copy display parameters from previous landscape to new on e
newLandscape->setFlagShow(landscape->getFlagShow()); newLandscape->setFlagShow(landscape->getFlagShow());
newLandscape->setFlagShowFog(landscape->getFlagShowFog()); newLandscape->setFlagShowFog(landscape->getFlagShowFog());
newLandscape->setFlagShowIllumination(landscape->getFlagShow Illumination()); newLandscape->setFlagShowIllumination(landscape->getFlagShow Illumination());
newLandscape->setFlagShowLabels(landscape->getFlagShowLabels ()); newLandscape->setFlagShowLabels(landscape->getFlagShowLabels ());
//in case we already fade out one old landscape (if switchin g too rapidly): the old one has to go immediately. //in case we already fade out one old landscape (if switchin g too rapidly): the old one has to go immediately.
if (oldLandscape) if (oldLandscape)
delete oldLandscape; delete oldLandscape;
oldLandscape = landscape; // keep old while transitioning! oldLandscape = landscape; // keep old while transitioning!
landscape = newLandscape; }
landscape=newLandscape;
currentLandscapeID = id;
if (getFlagLandscapeSetsLocation() && landscape->hasLocation if (getFlagLandscapeSetsLocation() && landscape->hasLocation())
()) {
{ StelApp::getInstance().getCore()->moveObserverTo(landscape->
StelApp::getInstance().getCore()->moveObserverTo(lan getLocation(), changeLocationDuration);
dscape->getLocation(), changeLocationDuration); StelSkyDrawer* drawer=StelApp::getInstance().getCore()->getS
StelSkyDrawer* drawer=StelApp::getInstance().getCore kyDrawer();
()->getSkyDrawer();
if (landscape->getDefaultFogSetting() >-1) if (landscape->getDefaultFogSetting() >-1)
{ {
setFlagFog((bool) landscape->getDefaultFogSe setFlagFog((bool) landscape->getDefaultFogSetting())
tting()); ;
landscape->setFlagShowFog((bool) landscape-> landscape->setFlagShowFog((bool) landscape->getDefau
getDefaultFogSetting()); ltFogSetting());
} }
if (landscape->getDefaultBortleIndex() > 0) if (landscape->getDefaultBortleIndex() > 0)
{ {
setAtmosphereBortleLightPollution(landscape- drawer->setBortleScaleIndex(landscape->getDefaultBor
>getDefaultBortleIndex()); tleIndex());
drawer->setBortleScaleIndex(landscape->getDe }
faultBortleIndex()); if (landscape->getDefaultAtmosphericExtinction() >= 0.0)
} {
if (landscape->getDefaultAtmosphericExtinction() >= drawer->setExtinctionCoefficient(landscape->getDefau
0.0) ltAtmosphericExtinction());
{ }
drawer->setExtinctionCoefficient(landscape-> if (landscape->getDefaultAtmosphericTemperature() > -273.15)
getDefaultAtmosphericExtinction()); {
} drawer->setAtmosphereTemperature(landscape->getDefau
if (landscape->getDefaultAtmosphericTemperature() > ltAtmosphericTemperature());
-273.15) }
{ if (landscape->getDefaultAtmosphericPressure() >= 0.0)
drawer->setAtmosphereTemperature(landscape-> {
getDefaultAtmosphericTemperature()); drawer->setAtmospherePressure(landscape->getDefaultA
} tmosphericPressure());
if (landscape->getDefaultAtmosphericPressure() >= 0. }
0) else if (landscape->getDefaultAtmosphericPressure() == -1.0)
{ {
drawer->setAtmospherePressure(landscape->get // compute standard pressure for standard atmosphere
DefaultAtmosphericPressure()); in given altitude if landscape.ini coded as atmospheric_pressure=-1
} // International altitude formula found in Wikipedia
else if (landscape->getDefaultAtmosphericPressure() .
== -1.0) double alt=landscape->getLocation().altitude;
{ double p=1013.25*std::pow(1-(0.0065*alt)/288.15, 5.2
// compute standard pressure for standard at 55);
mosphere in given altitude if landscape.ini coded as atmospheric_pressure=- drawer->setAtmospherePressure(p);
1
// International altitude formula found in W
ikipedia.
double alt=landscape->getLocation().altitude
;
double p=1013.25*std::pow(1-(0.0065*alt)/288
.15, 5.255);
drawer->setAtmospherePressure(p);
}
} }
} }
currentLandscapeID = id;
emit currentLandscapeChanged(currentLandscapeID,getCurrentLandscapeN
ame());
// else qDebug() << "Will not set new location; Landscape location: planet: " << landscape->getLocation().planetName << "name: " << landscape-> getLocation().name; // else qDebug() << "Will not set new location; Landscape location: planet: " << landscape->getLocation().planetName << "name: " << landscape-> getLocation().name;
return true; return true;
} }
bool LandscapeMgr::setCurrentLandscapeName(const QString& name, const doubl e changeLocationDuration) bool LandscapeMgr::setCurrentLandscapeName(const QString& name, const doubl e changeLocationDuration)
{ {
if (name.isEmpty()) if (name.isEmpty())
return false; return false;
skipping to change at line 525 skipping to change at line 522
} }
// Change the default landscape to the landscape with the ID specified. // Change the default landscape to the landscape with the ID specified.
bool LandscapeMgr::setDefaultLandscapeID(const QString& id) bool LandscapeMgr::setDefaultLandscapeID(const QString& id)
{ {
if (id.isEmpty()) if (id.isEmpty())
return false; return false;
defaultLandscapeID = id; defaultLandscapeID = id;
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
conf->setValue("init_location/landscape_name", id); conf->setValue("init_location/landscape_name", id);
emit defaultLandscapeChanged(id);
return true; return true;
} }
void LandscapeMgr::updateI18n() void LandscapeMgr::updateI18n()
{ {
// Translate all labels with the new language // Translate all labels with the new language
if (cardinalsPoints) cardinalsPoints->updateI18n(); if (cardinalsPoints) cardinalsPoints->updateI18n();
landscape->loadLabels(getCurrentLandscapeID()); landscape->loadLabels(getCurrentLandscapeID());
} }
skipping to change at line 570 skipping to change at line 568
bool LandscapeMgr::getFlagUseLightPollutionFromDatabase() const bool LandscapeMgr::getFlagUseLightPollutionFromDatabase() const
{ {
return flagLightPollutionFromDatabase; return flagLightPollutionFromDatabase;
} }
void LandscapeMgr::setFlagUseLightPollutionFromDatabase(const bool usage) void LandscapeMgr::setFlagUseLightPollutionFromDatabase(const bool usage)
{ {
if (flagLightPollutionFromDatabase != usage) if (flagLightPollutionFromDatabase != usage)
{ {
flagLightPollutionFromDatabase = usage; flagLightPollutionFromDatabase = usage;
StelCore* core = StelApp::getInstance().getCore();
//this was previously logic in ViewDialog, but should really
be on a non-GUI layer
if (usage)
{
StelLocation loc = core->getCurrentLocation();
updateLocationBasedPollution(loc);
}
emit lightPollutionUsageChanged(usage); emit lightPollutionUsageChanged(usage);
} }
} }
void LandscapeMgr::updateLocationBasedPollution(StelLocation loc)
{
if(flagLightPollutionFromDatabase)
{
//this was previously logic in ViewDialog, but should really
be on a non-GUI layer
StelCore* core = StelApp::getInstance().getCore();
int bIdx = loc.bortleScaleIndex;
if (!loc.planetName.contains("Earth")) // location not on Ea
rth...
bIdx = 1;
if (bIdx<1) // ...or it observatory, or it unknown location
bIdx = loc.DEFAULT_BORTLE_SCALE_INDEX;
core->getSkyDrawer()->setBortleScaleIndex(bIdx);
}
}
void LandscapeMgr::setFlagFog(const bool displayed) void LandscapeMgr::setFlagFog(const bool displayed)
{ {
if (landscape->getFlagShowFog() != displayed) { if (landscape->getFlagShowFog() != displayed) {
landscape->setFlagShowFog(displayed); landscape->setFlagShowFog(displayed);
emit fogDisplayedChanged(displayed); emit fogDisplayedChanged(displayed);
} }
} }
bool LandscapeMgr::getFlagFog() const bool LandscapeMgr::getFlagFog() const
{ {
skipping to change at line 615 skipping to change at line 639
} }
} }
bool LandscapeMgr::getFlagLabels() const bool LandscapeMgr::getFlagLabels() const
{ {
return landscape->getFlagShowLabels(); return landscape->getFlagShowLabels();
} }
void LandscapeMgr::setFlagLandscapeAutoSelection(bool enableAutoSelect) void LandscapeMgr::setFlagLandscapeAutoSelection(bool enableAutoSelect)
{ {
flagLandscapeAutoSelection = enableAutoSelect; if(enableAutoSelect != flagLandscapeAutoSelection)
{
flagLandscapeAutoSelection = enableAutoSelect;
emit flagLandscapeAutoSelectionChanged(enableAutoSelect);
}
} }
bool LandscapeMgr::getFlagLandscapeAutoSelection() const bool LandscapeMgr::getFlagLandscapeAutoSelection() const
{ {
return flagLandscapeAutoSelection; return flagLandscapeAutoSelection;
} }
void LandscapeMgr::setFlagAtmosphereAutoEnable(bool b) void LandscapeMgr::setFlagAtmosphereAutoEnable(bool b)
{ {
flagAtmosphereAutoEnabling = b; if(b != flagAtmosphereAutoEnabling)
{
flagAtmosphereAutoEnabling = b;
emit setFlagAtmosphereAutoEnableChanged(b);
}
} }
bool LandscapeMgr::getFlagAtmosphereAutoEnable() const bool LandscapeMgr::getFlagAtmosphereAutoEnable() const
{ {
return flagAtmosphereAutoEnabling; return flagAtmosphereAutoEnabling;
} }
/********************************************************************* /*********************************************************************
Retrieve list of the names of all the available landscapes Retrieve list of the names of all the available landscapes
*********************************************************************/ *********************************************************************/
skipping to change at line 770 skipping to change at line 803
float LandscapeMgr::getAtmosphereLightPollutionLuminance() const float LandscapeMgr::getAtmosphereLightPollutionLuminance() const
{ {
return atmosphere->getLightPollutionLuminance(); return atmosphere->getLightPollutionLuminance();
} }
//! Set the light pollution following the Bortle Scale //! Set the light pollution following the Bortle Scale
void LandscapeMgr::setAtmosphereBortleLightPollution(const int bIndex) void LandscapeMgr::setAtmosphereBortleLightPollution(const int bIndex)
{ {
// This is an empirical formula // This is an empirical formula
setAtmosphereLightPollutionLuminance(qMax(0.,0.0004*std::pow(bIndex- 1, 2.1))); setAtmosphereLightPollutionLuminance(qMax(0.,0.0004*std::pow(bIndex- 1, 2.1)));
emit lightPollutionChanged();
}
//! Get the light pollution following the Bortle Scale
int LandscapeMgr::getAtmosphereBortleLightPollution() const
{
return (int)std::pow(getAtmosphereLightPollutionLuminance()/0.0004,
1./2.1) + 1;
} }
void LandscapeMgr::setZRotation(const float d) void LandscapeMgr::setZRotation(const float d)
{ {
if (landscape) if (landscape)
landscape->setZRotation(d); landscape->setZRotation(d);
} }
float LandscapeMgr::getLuminance() const float LandscapeMgr::getLuminance() const
{ {
return atmosphere->getRealDisplayIntensityFactor(); return atmosphere->getRealDisplayIntensityFactor();
} }
float LandscapeMgr::getAtmosphereAverageLuminance() const float LandscapeMgr::getAtmosphereAverageLuminance() const
{ {
return atmosphere->getAverageLuminance(); return atmosphere->getAverageLuminance();
} }
// Override auto-computed luminance. Only use when you know what you are do
ing, and don't forget to unfreeze the average by calling this function with
a negative value.
void LandscapeMgr::setAtmosphereAverageLuminance(const float overrideLum)
{
atmosphere->setAverageLuminance(overrideLum);
}
Landscape* LandscapeMgr::createFromFile(const QString& landscapeFile, const QString& landscapeId) Landscape* LandscapeMgr::createFromFile(const QString& landscapeFile, const QString& landscapeId)
{ {
QSettings landscapeIni(landscapeFile, StelIniFormat); QSettings landscapeIni(landscapeFile, StelIniFormat);
QString s; QString s;
if (landscapeIni.status() != QSettings::NoError) if (landscapeIni.status() != QSettings::NoError)
{ {
qWarning() << "ERROR parsing landscape.ini file: " << QDir:: toNativeSeparators(landscapeFile); qWarning() << "ERROR parsing landscape.ini file: " << QDir:: toNativeSeparators(landscapeFile);
s = ""; s = "";
} }
else else
 End of changes. 18 change blocks. 
88 lines changed or deleted 119 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/