LandscapeMgr.cpp   LandscapeMgr.cpp 
skipping to change at line 155 skipping to change at line 155
sNorth = trans.qtranslate("N"); sNorth = trans.qtranslate("N");
sSouth = trans.qtranslate("S"); sSouth = trans.qtranslate("S");
sEast = trans.qtranslate("E"); sEast = trans.qtranslate("E");
sWest = trans.qtranslate("W"); sWest = trans.qtranslate("W");
} }
LandscapeMgr::LandscapeMgr() LandscapeMgr::LandscapeMgr()
: atmosphere(NULL) : atmosphere(NULL)
, cardinalsPoints(NULL) , cardinalsPoints(NULL)
, landscape(NULL) , landscape(NULL)
, oldLandscape(NULL)
, flagLandscapeSetsLocation(false) , flagLandscapeSetsLocation(false)
, flagLandscapeAutoSelection(false) , flagLandscapeAutoSelection(false)
, flagLightPollutionFromDatabase(false) , flagLightPollutionFromDatabase(false)
, flagLandscapeUseMinimalBrightness(false) , flagLandscapeUseMinimalBrightness(false)
, defaultMinimalBrightness(0.01) , defaultMinimalBrightness(0.01)
, flagLandscapeSetsMinimalBrightness(false) , flagLandscapeSetsMinimalBrightness(false)
, flagAtmosphereAutoEnabling(false) , flagAtmosphereAutoEnabling(false)
{ {
setObjectName("LandscapeMgr"); setObjectName("LandscapeMgr");
skipping to change at line 180 skipping to change at line 181
directories.next(); directories.next();
packagedLandscapeIDs << directories.fileName(); packagedLandscapeIDs << directories.fileName();
} }
packagedLandscapeIDs.removeDuplicates(); packagedLandscapeIDs.removeDuplicates();
} }
LandscapeMgr::~LandscapeMgr() LandscapeMgr::~LandscapeMgr()
{ {
delete atmosphere; delete atmosphere;
delete cardinalsPoints; delete cardinalsPoints;
if (oldLandscape)
{
delete oldLandscape;
oldLandscape=NULL;
}
delete landscape; delete landscape;
landscape = NULL; landscape = NULL;
} }
/************************************************************************* /*************************************************************************
Reimplementation of the getCallOrder method Reimplementation of the getCallOrder method
*************************************************************************/ *************************************************************************/
double LandscapeMgr::getCallOrder(StelModuleActionName actionName) const double LandscapeMgr::getCallOrder(StelModuleActionName actionName) const
{ {
if (actionName==StelModule::ActionDraw) if (actionName==StelModule::ActionDraw)
return StelApp::getInstance().getModuleMgr().getModule("Mete orMgr")->getCallOrder(actionName)+20; return StelApp::getInstance().getModuleMgr().getModule("Spor adicMeteorMgr")->getCallOrder(actionName)+20;
if (actionName==StelModule::ActionUpdate) if (actionName==StelModule::ActionUpdate)
return StelApp::getInstance().getModuleMgr().getModule("Sola rSystem")->getCallOrder(actionName)+10; return StelApp::getInstance().getModuleMgr().getModule("Sola rSystem")->getCallOrder(actionName)+10;
// GZ The next 2 lines are only required to test landscape transpare ncy. They should be commented away for releases. // GZ The next 2 lines are only required to test landscape transpare ncy. They should be commented away for releases.
if (actionName==StelModule::ActionHandleMouseClicks) if (actionName==StelModule::ActionHandleMouseClicks)
return StelApp::getInstance().getModuleMgr().getModule("Stel MovementMgr")->getCallOrder(actionName)-1; return StelApp::getInstance().getModuleMgr().getModule("Stel MovementMgr")->getCallOrder(actionName)-1;
return 0; return 0;
} }
void LandscapeMgr::update(double deltaTime) void LandscapeMgr::update(double deltaTime)
{ {
atmosphere->update(deltaTime); atmosphere->update(deltaTime);
if (oldLandscape)
{
// This is only when transitioning to newly loaded landscape
. We must draw the old one until the new one is faded in completely.
oldLandscape->update(deltaTime);
if (getIsLandscapeFullyVisible())
{
oldLandscape->setFlagShow(false);
if (oldLandscape->getEffectiveLandFadeValue()< 0.01f
)
{
delete oldLandscape;
oldLandscape=NULL;
}
}
}
landscape->update(deltaTime); landscape->update(deltaTime);
cardinalsPoints->update(deltaTime); cardinalsPoints->update(deltaTime);
// Compute the atmosphere color and intensity // Compute the atmosphere color and intensity
// Compute the sun position in local coordinate // Compute the sun position in local coordinate
SolarSystem* ssystem = (SolarSystem*)StelApp::getInstance().getModul eMgr().getModule("SolarSystem"); SolarSystem* ssystem = (SolarSystem*)StelApp::getInstance().getModul eMgr().getModule("SolarSystem");
StelCore* core = StelApp::getInstance().getCore(); StelCore* core = StelApp::getInstance().getCore();
Vec3d sunPos = ssystem->getSun()->getAltAzPosApparent(core); Vec3d sunPos = ssystem->getSun()->getAltAzPosApparent(core);
// Compute the moon position in local coordinate // Compute the moon position in local coordinate
Vec3d moonPos = ssystem->getMoon()->getAltAzPosApparent(core); Vec3d moonPos = ssystem->getMoon()->getAltAzPosApparent(core);
atmosphere->computeColor(core->getJDay(), sunPos, moonPos, // GZ: First parameter in next call is used for particularly earth-b
ound computations in Schaefer's sky brightness model. Difference DeltaT mak
es no difference here.
atmosphere->computeColor(core->getJDE(), sunPos, moonPos,
ssystem->getMoon()->getPhaseAngle(ssystem->getEarth()->getHe liocentricEclipticPos()), ssystem->getMoon()->getPhaseAngle(ssystem->getEarth()->getHe liocentricEclipticPos()),
core, core->getCurrentLocation().latitude, core->getCurrentL ocation().altitude, core, core->getCurrentLocation().latitude, core->getCurrentL ocation().altitude,
15.f, 40.f); // Temperature = 15c, relative humidity = 40 % 15.f, 40.f); // Temperature = 15c, relative humidity = 40 %
core->getSkyDrawer()->reportLuminanceInFov(3.75+atmosphere->getAvera geLuminance()*3.5, true); core->getSkyDrawer()->reportLuminanceInFov(3.75+atmosphere->getAvera geLuminance()*3.5, true);
// NOTE: Simple workaround for brightness of landscape when observin
g from the Sun.
if (core->getCurrentLocation().planetName.contains("Sun"))
{
landscape->setBrightness(1.0f, 1.0f);
return;
}
// Compute the ground luminance based on every planets around // Compute the ground luminance based on every planets around
// TBD: Reactivate and verify this code!? Source, reference? // TBD: Reactivate and verify this code!? Source, reference?
// float groundLuminance = 0; // float groundLuminance = 0;
// const vector<Planet*>& allPlanets = ssystem->getAllPlanets(); // const vector<Planet*>& allPlanets = ssystem->getAllPlanets();
// for (vector<Planet*>::const_iterator i=allPlanets.begin();i!=allPlan ets.end();++i) // for (vector<Planet*>::const_iterator i=allPlanets.begin();i!=allPlan ets.end();++i)
// { // {
// Vec3d pos = (*i)->getAltAzPos(core); // Vec3d pos = (*i)->getAltAzPos(core);
// pos.normalize(); // pos.normalize();
// if (pos[2] <= 0) // if (pos[2] <= 0)
// { // {
skipping to change at line 261 skipping to change at line 290
float landscapeBrightness=0.0f; float landscapeBrightness=0.0f;
if (getFlagLandscapeUseMinimalBrightness()) if (getFlagLandscapeUseMinimalBrightness())
{ {
// Setting from landscape.ini has priority if enabled // Setting from landscape.ini has priority if enabled
if (getFlagLandscapeSetsMinimalBrightness() && landscape->ge tLandscapeMinimalBrightness()>=0) if (getFlagLandscapeSetsMinimalBrightness() && landscape->ge tLandscapeMinimalBrightness()>=0)
landscapeBrightness = landscape->getLandscapeMinimal Brightness(); landscapeBrightness = landscape->getLandscapeMinimal Brightness();
else else
landscapeBrightness = getDefaultMinimalBrightness(); landscapeBrightness = getDefaultMinimalBrightness();
} }
// We define the solar brightness contribution zero when the sun is // With atmosphere on, we define the solar brightness contribution z
8 degrees below the horizon. ero when the sun is 8 degrees below the horizon.
float sinSunAngle = sin(qMin(M_PI_2, asin(sunPos[2])+8.*M_PI/180.)); // The multiplier of 1.5 just looks better, it somehow represents il
if(sinSunAngle > -0.1/1.5 ) lumination by scattered sunlight.
landscapeBrightness += 1.5*(sinSunAngle+0.1/1.5); // Else, we should account for sun's diameter but else just apply La
mbertian Cos-rule and check with landscape opacity.
float sinSunAngle = 0.0f;
if(atmosphere->getFlagShow())
{
sinSunAngle=sin(qMin(M_PI_2, asin(sunPos[2])+8.*M_PI/180.));
if(sinSunAngle > -0.1/1.5 )
landscapeBrightness += 1.5*(sinSunAngle+0.1/1.5);
}
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.
sinSunAngle=sin(qMin(M_PI_2, asin(sunPos[2]-landscape->getSi
nMinAltitudeLimit()) + (0.25f *M_PI/180.)));
if(sinSunAngle > 0.0f)
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)
lunarAddonBrightness = qMax(0.2/-12.*ssystem->getMoon()->get VMagnitudeWithExtinction(core),0.)*moonPos[2]; lunarAddonBrightness = qMax(0.2/-12.*ssystem->getMoon()->get VMagnitudeWithExtinction(core),0.)*moonPos[2];
landscapeBrightness += qMax(lunarAddonBrightness, pollutionAddonBrig htness); landscapeBrightness += qMax(lunarAddonBrightness, pollutionAddonBrig htness);
skipping to change at line 288 skipping to change at line 331
// If the atmosphere is on, a solar eclipse might darken the sky // If the atmosphere is on, a solar eclipse might darken the sky
// otherwise we just use the sun position calculation above // otherwise we just use the sun position calculation above
landscapeBrightness *= (atmosphere->getRealDisplayIntensityF actor()+0.1); landscapeBrightness *= (atmosphere->getRealDisplayIntensityF actor()+0.1);
} }
// TODO: should calculate dimming with solar eclipse even without at mosphere on // TODO: should calculate dimming with solar eclipse even without at mosphere on
// Brightness can't be over 1.f (see https://bugs.launchpad.net/stel larium/+bug/1115364) // Brightness can't be over 1.f (see https://bugs.launchpad.net/stel larium/+bug/1115364)
if (landscapeBrightness>0.95) if (landscapeBrightness>0.95)
landscapeBrightness = 0.95; landscapeBrightness = 0.95;
if (core->getCurrentLocation().planetName.contains("Sun")) // GZ's rules and intentions for lightscape brightness:
// lightscapeBrightness >0 makes sense only for sun below horizon.
// If atmosphere on, we mix it in with darkening twilight. If atmosp
here off, we can switch on more apruptly.
// Note however that lightscape rendering does not per se depend on
atmosphere on/off.
// This allows for illuminated windows or light panels on spaceships
. If a landscape's lightscape
// contains light smog of a city, it should also be shown if atmosph
ere is switched off.
// (Configure another landscape without light smog to avoid, or just
switch off lightscape.)
float lightscapeBrightness=0.0f;
float sinSunAlt = sunPos[2];
if (atmosphere->getFlagShow())
{ {
// NOTE: Simple workaround for brightness of landscape when // light pollution layer is mixed in at -3...-8 degrees.
observing from the Sun. if (sinSunAlt<-0.14f)
landscape->setBrightness(1.f, 0.0f); lightscapeBrightness=1.0f;
else if (sinSunAlt<-0.05f)
lightscapeBrightness = 1.0f-(sinSunAlt+0.14)/(-0.05+
0.14);
} }
else else
{ {
float lightscapeBrightness=0.0f; // If we have no atmosphere, we can assume windows and panel
// light pollution layer is mixed in at -3...-8 degrees. s on spaceships etc. are switched on whenever the sun does not shine, i.e.
float sunAlt = sunPos[2]; when sun is blocked by landscape.
if (sunAlt<-0.14f) lightscapeBrightness= landscape->getOpacity(sunPos);
lightscapeBrightness=1.0f;
else
{
if (sunAlt<-0.05f)
lightscapeBrightness = 1.0f-(sunAlt+0.14)/(-
0.05+0.14);
}
if (sunAlt<=0.f && !atmosphere->getFlagShow() && !getFlagLan
dscapeUseMinimalBrightness())
landscape->setBrightness(0.f, 0.f);
else
landscape->setBrightness(landscapeBrightness, lights
capeBrightness);
} }
landscape->setBrightness(landscapeBrightness, lightscapeBrightness);
} }
void LandscapeMgr::draw(StelCore* core) void LandscapeMgr::draw(StelCore* core)
{ {
// Draw the atmosphere // Draw the atmosphere
atmosphere->draw(core); atmosphere->draw(core);
// Draw the landscape // Draw the landscape
if (oldLandscape)
oldLandscape->draw(core);
landscape->draw(core); landscape->draw(core);
// Draw the cardinal points // Draw the cardinal points
cardinalsPoints->draw(core, StelApp::getInstance().getCore()->getCur rentLocation().latitude); cardinalsPoints->draw(core, StelApp::getInstance().getCore()->getCur rentLocation().latitude);
} }
void LandscapeMgr::init() void LandscapeMgr::init()
{ {
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
Q_ASSERT(conf); Q_ASSERT(conf);
skipping to change at line 349 skipping to change at line 396
cardinalsPoints = new Cardinals(); cardinalsPoints = new Cardinals();
cardinalsPoints->setFlagShow(conf->value("viewing/flag_cardinal_poin ts",true).toBool()); cardinalsPoints->setFlagShow(conf->value("viewing/flag_cardinal_poin ts",true).toBool());
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());
bool ok =true; bool ok =true;
setAtmosphereBortleLightPollution(conf->value("stars/init_bortle_sca le",3).toInt(&ok)); setAtmosphereBortleLightPollution(conf->value("stars/init_bortle_sca le",3).toInt(&ok));
if (!ok) if (!ok)
{ {
conf->setValue("stars/init_bortle_scale",3); conf->setValue("stars/init_bortle_scale",3);
setAtmosphereBortleLightPollution(3); setAtmosphereBortleLightPollution(3);
ok = true; ok = true;
} }
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(colorSchemeChanged(const QString&)), this, SLOT( setStelStyle(const QString&))); 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");
} }
void LandscapeMgr::setStelStyle(const QString& section) void LandscapeMgr::setStelStyle(const QString& section)
{ {
// Load colors from config file // Load colors from config file
QSettings* conf = StelApp::getInstance().getSettings(); QSettings* conf = StelApp::getInstance().getSettings();
QString defaultColor = conf->value(section+"/default_color").toStrin g(); QString defaultColor = conf->value(section+"/default_color").toStrin g();
setColorCardinalPoints(StelUtils::strToVec3f(conf->value(section+"/c ardinal_color", defaultColor).toString())); setColorCardinalPoints(StelUtils::strToVec3f(conf->value(section+"/c ardinal_color", defaultColor).toString()));
} }
skipping to change at line 393 skipping to change at line 442
// 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 default landscape " << "l andscapes/" + id + "/landscape.ini";
return false; return false;
} }
// Keep current landscape for a while, while new landscape fades in!
// 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());
delete landscape; 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.
if (oldLandscape)
delete oldLandscape;
oldLandscape = landscape; // keep old while transitioning!
landscape = newLandscape; landscape = newLandscape;
}
currentLandscapeID = id;
if (getFlagLandscapeSetsLocation() && landscape->hasLocation())
{
StelApp::getInstance().getCore()->moveObserverTo(landscape->
getLocation(), changeLocationDuration);
StelSkyDrawer* drawer=StelApp::getInstance().getCore()->getS
kyDrawer();
if (landscape->getDefaultFogSetting() >-1) if (getFlagLandscapeSetsLocation() && landscape->hasLocation
{ ())
setFlagFog((bool) landscape->getDefaultFogSetting())
;
landscape->setFlagShowFog((bool) landscape->getDefau
ltFogSetting());
}
if (landscape->getDefaultBortleIndex() > 0)
{
setAtmosphereBortleLightPollution(landscape->getDefa
ultBortleIndex());
drawer->setBortleScaleIndex(landscape->getDefaultBor
tleIndex());
}
if (landscape->getDefaultAtmosphericExtinction() >= 0.0)
{
drawer->setExtinctionCoefficient(landscape->getDefau
ltAtmosphericExtinction());
}
if (landscape->getDefaultAtmosphericTemperature() > -273.15)
{ {
drawer->setAtmosphereTemperature(landscape->getDefau StelApp::getInstance().getCore()->moveObserverTo(lan
ltAtmosphericTemperature()); dscape->getLocation(), changeLocationDuration);
} StelSkyDrawer* drawer=StelApp::getInstance().getCore
if (landscape->getDefaultAtmosphericPressure() >= 0.0) ()->getSkyDrawer();
{
drawer->setAtmospherePressure(landscape->getDefaultA if (landscape->getDefaultFogSetting() >-1)
tmosphericPressure()); {
} setFlagFog((bool) landscape->getDefaultFogSe
else if (landscape->getDefaultAtmosphericPressure() == -1.0) tting());
{ landscape->setFlagShowFog((bool) landscape->
// compute standard pressure for standard atmosphere getDefaultFogSetting());
in given altitude if landscape.ini coded as atmospheric_pressure=-1 }
// International altitude formula found in Wikipedia if (landscape->getDefaultBortleIndex() > 0)
. {
double alt=landscape->getLocation().altitude; setAtmosphereBortleLightPollution(landscape-
double p=1013.25*std::pow(1-(0.0065*alt)/288.15, 5.2 >getDefaultBortleIndex());
55); drawer->setBortleScaleIndex(landscape->getDe
drawer->setAtmospherePressure(p); faultBortleIndex());
}
if (landscape->getDefaultAtmosphericExtinction() >=
0.0)
{
drawer->setExtinctionCoefficient(landscape->
getDefaultAtmosphericExtinction());
}
if (landscape->getDefaultAtmosphericTemperature() >
-273.15)
{
drawer->setAtmosphereTemperature(landscape->
getDefaultAtmosphericTemperature());
}
if (landscape->getDefaultAtmosphericPressure() >= 0.
0)
{
drawer->setAtmospherePressure(landscape->get
DefaultAtmosphericPressure());
}
else if (landscape->getDefaultAtmosphericPressure()
== -1.0)
{
// compute standard pressure for standard at
mosphere in given altitude if landscape.ini coded as atmospheric_pressure=-
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;
// 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;
QMap<QString,QString> nameToDirMap = getNameToDirMap(); QMap<QString,QString> nameToDirMap = getNameToDirMap();
skipping to change at line 476 skipping to change at line 532
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);
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());
} }
void LandscapeMgr::setFlagLandscape(const bool displayed) void LandscapeMgr::setFlagLandscape(const bool displayed)
{ {
if (oldLandscape && !displayed)
oldLandscape->setFlagShow(false);
if(landscape->getFlagShow() != displayed) { if(landscape->getFlagShow() != displayed) {
landscape->setFlagShow(displayed); landscape->setFlagShow(displayed);
emit landscapeDisplayedChanged(displayed); emit landscapeDisplayedChanged(displayed);
} }
} }
bool LandscapeMgr::getFlagLandscape() const bool LandscapeMgr::getFlagLandscape() const
{ {
return landscape->getFlagShow(); return landscape->getFlagShow();
} }
bool LandscapeMgr::getIsLandscapeFullyVisible() const bool LandscapeMgr::getIsLandscapeFullyVisible() const
{ {
return landscape->getIsFullyVisible(); return landscape->getIsFullyVisible();
} }
float LandscapeMgr::getLandscapeSinMinAltitudeLimit() const
{
return landscape->getSinMinAltitudeLimit();
}
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;
skipping to change at line 536 skipping to change at line 600
landscape->setFlagShowIllumination(displayed); landscape->setFlagShowIllumination(displayed);
emit illuminationDisplayedChanged(displayed); emit illuminationDisplayedChanged(displayed);
} }
} }
bool LandscapeMgr::getFlagIllumination() const bool LandscapeMgr::getFlagIllumination() const
{ {
return landscape->getFlagShowIllumination(); return landscape->getFlagShowIllumination();
} }
void LandscapeMgr::setFlagLabels(const bool displayed)
{
if (landscape->getFlagShowLabels() != displayed) {
landscape->setFlagShowLabels(displayed);
emit labelsDisplayedChanged(displayed);
}
}
bool LandscapeMgr::getFlagLabels() const
{
return landscape->getFlagShowLabels();
}
void LandscapeMgr::setFlagLandscapeAutoSelection(bool enableAutoSelect) void LandscapeMgr::setFlagLandscapeAutoSelection(bool enableAutoSelect)
{ {
flagLandscapeAutoSelection = enableAutoSelect; flagLandscapeAutoSelection = enableAutoSelect;
} }
bool LandscapeMgr::getFlagLandscapeAutoSelection() const bool LandscapeMgr::getFlagLandscapeAutoSelection() const
{ {
return flagLandscapeAutoSelection; return flagLandscapeAutoSelection;
} }
skipping to change at line 749 skipping to change at line 826
else else
{ {
qDebug() << "Unknown landscape type: \"" << s << "\""; qDebug() << "Unknown landscape type: \"" << s << "\"";
// to avoid making this a fatal error, will load as a fishey e // to avoid making this a fatal error, will load as a fishey e
// if this fails, it just won't draw // if this fails, it just won't draw
ldscp = new LandscapeFisheye(); ldscp = new LandscapeFisheye();
} }
ldscp->load(landscapeIni, landscapeId); ldscp->load(landscapeIni, landscapeId);
QSettings *conf=StelApp::getInstance().getSettings();
ldscp->setLabelFontSize(conf->value("landscape/label_font_size", 15)
.toInt());
return ldscp; return ldscp;
} }
QString LandscapeMgr::nameToID(const QString& name) const QString LandscapeMgr::nameToID(const QString& name) const
{ {
QMap<QString,QString> nameToDirMap = getNameToDirMap(); QMap<QString,QString> nameToDirMap = getNameToDirMap();
if (nameToDirMap.find(name)!=nameToDirMap.end()) if (nameToDirMap.find(name)!=nameToDirMap.end())
{ {
Q_ASSERT(0); Q_ASSERT(0);
skipping to change at line 813 skipping to change at line 892
//qDebug() << "LandscapeMgr: No 'landscapes' subdirectory ex ists in" << parentDestinationDir.absolutePath(); //qDebug() << "LandscapeMgr: No 'landscapes' subdirectory ex ists in" << parentDestinationDir.absolutePath();
if (!parentDestinationDir.mkdir("landscapes")) if (!parentDestinationDir.mkdir("landscapes"))
{ {
qWarning() << "LandscapeMgr: Unable to install lands cape: Unable to create sub-directory 'landscapes' in" << QDir::toNativeSepa rators(parentDestinationDir.absolutePath()); qWarning() << "LandscapeMgr: Unable to install lands cape: Unable to create sub-directory 'landscapes' in" << QDir::toNativeSepa rators(parentDestinationDir.absolutePath());
emit errorUnableToOpen(QDir::cleanPath(parentDestina tionDir.filePath("landscapes")));//parentDestinationDir.absolutePath() emit errorUnableToOpen(QDir::cleanPath(parentDestina tionDir.filePath("landscapes")));//parentDestinationDir.absolutePath()
return QString(); return QString();
} }
} }
QDir destinationDir (parentDestinationDir.absoluteFilePath("landscap es")); QDir destinationDir (parentDestinationDir.absoluteFilePath("landscap es"));
QZipReader reader(sourceFilePath); Stel::QZipReader reader(sourceFilePath);
if (reader.status() != QZipReader::NoError) if (reader.status() != Stel::QZipReader::NoError)
{ {
qWarning() << "LandscapeMgr: Unable to open as a ZIP archive :" << QDir::toNativeSeparators(sourceFilePath); qWarning() << "LandscapeMgr: Unable to open as a ZIP archive :" << QDir::toNativeSeparators(sourceFilePath);
emit errorNotArchive(); emit errorNotArchive();
return QString(); return QString();
} }
//Detect top directory //Detect top directory
QString topDir, iniPath; QString topDir, iniPath;
QList<QZipReader::FileInfo> infoList = reader.fileInfoList(); QList<Stel::QZipReader::FileInfo> infoList = reader.fileInfoList();
foreach(QZipReader::FileInfo info, infoList) foreach(Stel::QZipReader::FileInfo info, infoList)
{ {
QFileInfo fileInfo(info.filePath); QFileInfo fileInfo(info.filePath);
if (fileInfo.fileName() == "landscape.ini") if (fileInfo.fileName() == "landscape.ini")
{ {
iniPath = info.filePath; iniPath = info.filePath;
topDir = fileInfo.dir().path(); topDir = fileInfo.dir().path();
break; break;
} }
} }
if (topDir.isEmpty()) if (topDir.isEmpty())
skipping to change at line 888 skipping to change at line 967
{ {
qWarning() << "LandscapeMgr: A subdirectory" << landscapeID << "already exists in" << QDir::toNativeSeparators(destinationDir.absoluteP ath()) << "Its contents may be overwritten."; qWarning() << "LandscapeMgr: A subdirectory" << landscapeID << "already exists in" << QDir::toNativeSeparators(destinationDir.absoluteP ath()) << "Its contents may be overwritten.";
} }
else if(!destinationDir.mkdir(landscapeID)) else if(!destinationDir.mkdir(landscapeID))
{ {
qWarning() << "LandscapeMgr: Unable to install landscape. Un able to create" << landscapeID << "directory in" << QDir::toNativeSeparator s(destinationDir.absolutePath()); qWarning() << "LandscapeMgr: Unable to install landscape. Un able to create" << landscapeID << "directory in" << QDir::toNativeSeparator s(destinationDir.absolutePath());
emit errorUnableToOpen(QDir::cleanPath(destinationDir.filePa th(landscapeID))); emit errorUnableToOpen(QDir::cleanPath(destinationDir.filePa th(landscapeID)));
return QString(); return QString();
} }
destinationDir.cd(landscapeID); destinationDir.cd(landscapeID);
foreach(QZipReader::FileInfo info, infoList) foreach(Stel::QZipReader::FileInfo info, infoList)
{ {
QFileInfo fileInfo(info.filePath); QFileInfo fileInfo(info.filePath);
if (info.isFile && fileInfo.dir().path() == topDir) if (info.isFile && fileInfo.dir().path() == topDir)
{ {
QByteArray data = reader.fileData(info.filePath); QByteArray data = reader.fileData(info.filePath);
QFile out(destinationDir.filePath(fileInfo.fileName( ))); QFile out(destinationDir.filePath(fileInfo.fileName( )));
if (out.open(QIODevice::WriteOnly)) if (out.open(QIODevice::WriteOnly))
{ {
out.write(data); out.write(data);
out.close(); out.close();
 End of changes. 28 change blocks. 
81 lines changed or deleted 185 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/